From 3e82f9b38889ad40dc0c96509980316fc56eafae Mon Sep 17 00:00:00 2001 From: umaranis Date: Tue, 7 May 2024 07:32:05 +1000 Subject: [PATCH] bug: return unregister callback from onMount --- .../svelte-lexical/src/lib/components/toolbar/RedoButton.svelte | 2 +- .../src/lib/components/toolbar/StateStoreRichTextUpdator.svelte | 2 +- .../svelte-lexical/src/lib/components/toolbar/UndoButton.svelte | 2 +- packages/svelte-lexical/src/lib/core/ContentEditable.svelte | 2 +- .../src/lib/core/plugins/HorizontalRulePlugin.svelte | 2 +- .../core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/svelte-lexical/src/lib/components/toolbar/RedoButton.svelte b/packages/svelte-lexical/src/lib/components/toolbar/RedoButton.svelte index a22646f..6d5850c 100644 --- a/packages/svelte-lexical/src/lib/components/toolbar/RedoButton.svelte +++ b/packages/svelte-lexical/src/lib/components/toolbar/RedoButton.svelte @@ -20,7 +20,7 @@ // unregisters onDestroy through returned callback onMount(() => { - editor.registerCommand( + return editor.registerCommand( CAN_REDO_COMMAND, (payload) => { canRedo = payload; diff --git a/packages/svelte-lexical/src/lib/components/toolbar/StateStoreRichTextUpdator.svelte b/packages/svelte-lexical/src/lib/components/toolbar/StateStoreRichTextUpdator.svelte index 839e65c..289162e 100644 --- a/packages/svelte-lexical/src/lib/components/toolbar/StateStoreRichTextUpdator.svelte +++ b/packages/svelte-lexical/src/lib/components/toolbar/StateStoreRichTextUpdator.svelte @@ -139,7 +139,7 @@ // unregisters onDestory using returned callback onMount(() => { - mergeRegister( + return mergeRegister( editor.registerUpdateListener(({editorState}) => { editorState.read(() => { updateToolbar(); diff --git a/packages/svelte-lexical/src/lib/components/toolbar/UndoButton.svelte b/packages/svelte-lexical/src/lib/components/toolbar/UndoButton.svelte index 88da916..9ac4e7f 100644 --- a/packages/svelte-lexical/src/lib/components/toolbar/UndoButton.svelte +++ b/packages/svelte-lexical/src/lib/components/toolbar/UndoButton.svelte @@ -20,7 +20,7 @@ // unregisters onDestroy through returned callback onMount(() => { - editor.registerCommand( + return editor.registerCommand( CAN_UNDO_COMMAND, (payload) => { canUndo = payload; diff --git a/packages/svelte-lexical/src/lib/core/ContentEditable.svelte b/packages/svelte-lexical/src/lib/core/ContentEditable.svelte index 3006e80..05251b1 100644 --- a/packages/svelte-lexical/src/lib/core/ContentEditable.svelte +++ b/packages/svelte-lexical/src/lib/core/ContentEditable.svelte @@ -38,7 +38,7 @@ } isEditable = editor.isEditable(); - editor.registerEditableListener((currentIsEditable) => { + return editor.registerEditableListener((currentIsEditable) => { isEditable = currentIsEditable; }); }); diff --git a/packages/svelte-lexical/src/lib/core/plugins/HorizontalRulePlugin.svelte b/packages/svelte-lexical/src/lib/core/plugins/HorizontalRulePlugin.svelte index 89c1860..1973513 100644 --- a/packages/svelte-lexical/src/lib/core/plugins/HorizontalRulePlugin.svelte +++ b/packages/svelte-lexical/src/lib/core/plugins/HorizontalRulePlugin.svelte @@ -15,7 +15,7 @@ const editor = getEditor(); onMount(() => { - editor.registerCommand( + return editor.registerCommand( INSERT_HORIZONTAL_RULE_COMMAND, (type) => { const selection = getSelection(); diff --git a/packages/svelte-lexical/src/lib/core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte b/packages/svelte-lexical/src/lib/core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte index 22d9d30..486da4a 100644 --- a/packages/svelte-lexical/src/lib/core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte +++ b/packages/svelte-lexical/src/lib/core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte @@ -81,6 +81,6 @@ ]; onMount(() => { - registerMarkdownShortcuts(editor, TRANSFORMERS); + return registerMarkdownShortcuts(editor, TRANSFORMERS); });