From d9014f328a92a3486fef2b345555c9772f1ec53c Mon Sep 17 00:00:00 2001 From: Fadekemi Adebayo <82163647+Shopiley@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:04:53 +0100 Subject: [PATCH] [Lexical] Chore: Update default skipInitialization to false for registerMutationListener (#6857) --- packages/lexical-website/docs/concepts/listeners.md | 2 +- packages/lexical/src/LexicalEditor.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/lexical-website/docs/concepts/listeners.md b/packages/lexical-website/docs/concepts/listeners.md index 834db37c0bf..ef95f1c6d0b 100644 --- a/packages/lexical-website/docs/concepts/listeners.md +++ b/packages/lexical-website/docs/concepts/listeners.md @@ -84,7 +84,7 @@ handle external UI state and UI features relating to specific types of node. If any existing nodes are in the DOM, and skipInitialization is not true, the listener will be called immediately with an updateTag of 'registerMutationListener' where all nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option -(default is currently true for backwards compatibility in 0.17.x but will change to false in 0.18.0). +(whose default was previously true for backwards compatibility with <=0.16.1 but has been changed to false as of 0.21.0). ```js const removeMutationListener = editor.registerMutationListener( diff --git a/packages/lexical/src/LexicalEditor.ts b/packages/lexical/src/LexicalEditor.ts index 174b18cb62c..9223e571544 100644 --- a/packages/lexical/src/LexicalEditor.ts +++ b/packages/lexical/src/LexicalEditor.ts @@ -216,13 +216,13 @@ export interface MutationListenerOptions { /** * Skip the initial call of the listener with pre-existing DOM nodes. * - * The default is currently true for backwards compatibility with <= 0.16.1 - * but this default is expected to change to false in 0.17.0. + * The default was previously true for backwards compatibility with <= 0.16.1 + * but this default has been changed to false as of 0.21.0. */ skipInitialization?: boolean; } -const DEFAULT_SKIP_INITIALIZATION = true; +const DEFAULT_SKIP_INITIALIZATION = false; export type UpdateListener = (arg0: { dirtyElements: Map; @@ -844,7 +844,7 @@ export class LexicalEditor { * If any existing nodes are in the DOM, and skipInitialization is not true, the listener * will be called immediately with an updateTag of 'registerMutationListener' where all * nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option - * (default is currently true for backwards compatibility in 0.16.x but will change to false in 0.17.0). + * (whose default was previously true for backwards compatibility with <=0.16.1 but has been changed to false as of 0.21.0). * * @param klass - The class of the node that you want to listen to mutations on. * @param listener - The logic you want to run when the node is mutated.