A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: fix selection/focus is lost when editor state is updated
Abdullah Attac51406ca0479
diff --git a/packages/editor/src/hooks/use-editor.ts b/packages/editor/src/hooks/use-editor.tsindex f65197826..025c9ec24 100644--- a/packages/editor/src/hooks/use-editor.ts+++ b/packages/editor/src/hooks/use-editor.ts@@ -60,7 +60,10 @@ export const useEditor = (editor.schema,options.parseOptions);- const selection = resolveFocusPosition(doc, options.autofocus);+ const selection =+ editor.state.selection ||+ resolveFocusPosition(doc, options.autofocus);+ const oldIsFocused = editor.isFocused;editor.view.updateState(EditorState.create({doc,@@ -68,6 +71,7 @@ export const useEditor = (selection: selection || undefined}));+ if (oldIsFocused && !editor.isFocused) editor.commands.focus();}editor.options = { ...editor.options, ...options };