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 crash on select all + backspace with lists
Abdullah Atta732185a69d70
diff --git a/packages/editor/patches/@tiptap+core+2.2.4.patch b/packages/editor/patches/@tiptap+core+2.2.4.patchindex 889dbffad..9bc4daad5 100644--- a/packages/editor/patches/@tiptap+core+2.2.4.patch+++ b/packages/editor/patches/@tiptap+core+2.2.4.patch@@ -1,7 +1,16 @@diff --git a/node_modules/@tiptap/core/dist/index.cjs b/node_modules/@tiptap/core/dist/index.cjs-index 1ea30e0..b6f4899 100644+index 1ea30e0..b5d15e3 100644--- a/node_modules/@tiptap/core/dist/index.cjs+++ b/node_modules/@tiptap/core/dist/index.cjs+@@ -1327,7 +1327,7 @@ const cut = (originRange, targetPos) => ({ editor, tr }) => {+ tr.deleteRange(originRange.from, originRange.to);+ const newPos = tr.mapping.map(targetPos);+ tr.insert(newPos, contentSlice.content);+- tr.setSelection(new state.TextSelection(tr.doc.resolve(newPos - 1)));++ tr.setSelection(new state.TextSelection(tr.doc.resolve(Math.max(0, newPos - 1))));+ return true;+ };+@@ -1901,9 +1901,24 @@ const lift = (typeOrName, attributes = {}) => ({ state, dispatch }) => {return commands$1.lift(state, dispatch);};@@ -31,9 +40,18 @@ index 1ea30e0..b6f4899 100644const liftListItem = typeOrName => ({ state, dispatch }) => {const type = getNodeType(typeOrName, state.schema);diff --git a/node_modules/@tiptap/core/dist/index.js b/node_modules/@tiptap/core/dist/index.js-index 554e919..23a99fd 100644+index 554e919..cdd21be 100644--- a/node_modules/@tiptap/core/dist/index.js+++ b/node_modules/@tiptap/core/dist/index.js+@@ -1323,7 +1323,7 @@ const cut = (originRange, targetPos) => ({ editor, tr }) => {+ tr.deleteRange(originRange.from, originRange.to);+ const newPos = tr.mapping.map(targetPos);+ tr.insert(newPos, contentSlice.content);+- tr.setSelection(new TextSelection(tr.doc.resolve(newPos - 1)));++ tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(0, newPos - 1))));+ return true;+ };+@@ -1897,9 +1897,24 @@ const lift = (typeOrName, attributes = {}) => ({ state, dispatch }) => {return lift$1(state, dispatch);};diff --git a/packages/editor/patches/@tiptap+extension-list-keymap+2.2.4.patch b/packages/editor/patches/@tiptap+extension-list-keymap+2.2.4.patchnew file mode 100644index 000000000..f2b7adf81--- /dev/null+++ b/packages/editor/patches/@tiptap+extension-list-keymap+2.2.4.patch@@ -0,0 +1,30 @@+diff --git a/node_modules/@tiptap/extension-list-keymap/dist/index.cjs b/node_modules/@tiptap/extension-list-keymap/dist/index.cjs+index 9cd822f..1539b13 100644+--- a/node_modules/@tiptap/extension-list-keymap/dist/index.cjs++++ b/node_modules/@tiptap/extension-list-keymap/dist/index.cjs+@@ -82,7 +82,9 @@ const handleBackspace = (editor, name, parentListTypes) => {+ // the previous item is a list (orderedList or bulletList)+ // move the cursor into the list and delete the current item+ if (!core.isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {+- const { $anchor } = editor.state.selection;++ const { $anchor, empty } = editor.state.selection;++ if (!empty) return false;+++ const $listPos = editor.state.doc.resolve($anchor.before() - 1);+ const listDescendants = [];+ $listPos.node().descendants((node, pos) => {+diff --git a/node_modules/@tiptap/extension-list-keymap/dist/index.js b/node_modules/@tiptap/extension-list-keymap/dist/index.js+index e759826..11a385f 100644+--- a/node_modules/@tiptap/extension-list-keymap/dist/index.js++++ b/node_modules/@tiptap/extension-list-keymap/dist/index.js+@@ -78,7 +78,9 @@ const handleBackspace = (editor, name, parentListTypes) => {+ // the previous item is a list (orderedList or bulletList)+ // move the cursor into the list and delete the current item+ if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {+- const { $anchor } = editor.state.selection;++ const { $anchor, empty } = editor.state.selection;++ if (!empty) return false;+++ const $listPos = editor.state.doc.resolve($anchor.before() - 1);+ const listDescendants = [];+ $listPos.node().descendants((node, pos) => {