editor: update tiptap to v2.10.4 (#6872)

* editor: update tiptap to v2.9.1

* editor: update tiptap & pkgs to 2.10.4

* editor: update test snapshots
This commit is contained in:
Abdullah Atta
2024-12-30 14:51:50 +05:00
committed by GitHub
parent 193007370a
commit 800f3ca5d3
10 changed files with 1165 additions and 954 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -35,33 +35,33 @@
"@notesnook/theme": "file:../theme",
"@notesnook/ui": "file:../ui",
"@social-embed/lib": "^0.1.0-next.7",
"@tiptap/core": "2.6.6",
"@tiptap/extension-blockquote": "^2.6.6",
"@tiptap/extension-bullet-list": "^2.6.6",
"@tiptap/extension-character-count": "2.6.6",
"@tiptap/extension-code": "^2.6.6",
"@tiptap/extension-color": "2.6.6",
"@tiptap/extension-font-family": "2.6.6",
"@tiptap/extension-heading": "^2.6.6",
"@tiptap/extension-history": "2.6.6",
"@tiptap/extension-horizontal-rule": "2.6.6",
"@tiptap/extension-list-item": "^2.6.6",
"@tiptap/extension-list-keymap": "2.6.6",
"@tiptap/extension-ordered-list": "^2.6.6",
"@tiptap/extension-placeholder": "2.6.6",
"@tiptap/extension-subscript": "2.6.6",
"@tiptap/extension-superscript": "2.6.6",
"@tiptap/extension-table": "2.6.6",
"@tiptap/extension-table-cell": "2.6.6",
"@tiptap/extension-table-header": "2.6.6",
"@tiptap/extension-table-row": "2.6.6",
"@tiptap/extension-task-item": "2.6.6",
"@tiptap/extension-task-list": "2.6.6",
"@tiptap/extension-text-align": "2.6.6",
"@tiptap/extension-text-style": "2.6.6",
"@tiptap/extension-underline": "2.6.6",
"@tiptap/pm": "2.6.6",
"@tiptap/starter-kit": "2.6.6",
"@tiptap/core": "^2.10.4",
"@tiptap/extension-blockquote": "2.10.4",
"@tiptap/extension-bullet-list": "2.10.4",
"@tiptap/extension-character-count": "2.10.4",
"@tiptap/extension-code": "2.10.4",
"@tiptap/extension-color": "2.10.4",
"@tiptap/extension-font-family": "2.10.4",
"@tiptap/extension-heading": "2.10.4",
"@tiptap/extension-history": "2.10.4",
"@tiptap/extension-horizontal-rule": "2.10.4",
"@tiptap/extension-list-item": "2.10.4",
"@tiptap/extension-list-keymap": "2.10.4",
"@tiptap/extension-ordered-list": "2.10.4",
"@tiptap/extension-placeholder": "2.10.4",
"@tiptap/extension-subscript": "2.10.4",
"@tiptap/extension-superscript": "2.10.4",
"@tiptap/extension-table": "2.10.4",
"@tiptap/extension-table-cell": "2.10.4",
"@tiptap/extension-table-header": "2.10.4",
"@tiptap/extension-table-row": "2.10.4",
"@tiptap/extension-task-item": "2.10.4",
"@tiptap/extension-task-list": "2.10.4",
"@tiptap/extension-text-align": "2.10.4",
"@tiptap/extension-text-style": "2.10.4",
"@tiptap/extension-underline": "2.10.4",
"@tiptap/pm": "2.10.4",
"@tiptap/starter-kit": "2.10.4",
"alfaaz": "^1.1.0",
"async-mutex": "^0.5.0",
"clipboard-polyfill": "4.1.0",
@@ -73,7 +73,7 @@
"nanoid": "^5.0.7",
"prism-themes": "^1.9.0",
"prosemirror-codemark": "^0.4.2",
"prosemirror-view": "1.34.2",
"prosemirror-view": "1.37.1",
"re-resizable": "^6.9.18",
"react-colorful": "^5.6.1",
"redent": "^4.0.0",
@@ -128,4 +128,4 @@
"url": "git://github.com/streetwriters/notesnook.git",
"directory": "packages/editor"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,54 +0,0 @@
diff --git a/node_modules/@tiptap/extension-list-keymap/dist/index.cjs b/node_modules/@tiptap/extension-list-keymap/dist/index.cjs
index 0f8ae36..adeee92 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) => {
@@ -111,6 +113,11 @@ const handleBackspace = (editor, name, parentListTypes) => {
if (!listItemPos) {
return false;
}
+ // if the current position is not at the start of the list item
+ // then join backward i.e. join within the list item
+ if (listItemPos.$pos.parentOffset !== 0) {
+ return editor.commands.joinBackward();
+ }
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
const prevNode = $prev.node(listItemPos.depth);
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
diff --git a/node_modules/@tiptap/extension-list-keymap/dist/index.js b/node_modules/@tiptap/extension-list-keymap/dist/index.js
index f7ab1e4..6ea03d5 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) => {
@@ -107,6 +109,11 @@ const handleBackspace = (editor, name, parentListTypes) => {
if (!listItemPos) {
return false;
}
+ // if the current position is not at the start of the list item
+ // then join backward i.e. join within the list item
+ if (listItemPos.$pos.parentOffset !== 0) {
+ return editor.commands.joinBackward();
+ }
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
const prevNode = $prev.node(listItemPos.depth);
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);

View File

@@ -1,8 +1,8 @@
diff --git a/node_modules/prosemirror-view/dist/index.cjs b/node_modules/prosemirror-view/dist/index.cjs
index 8ea57c7..aeda01d 100644
index 5903e89..6a85c3d 100644
--- a/node_modules/prosemirror-view/dist/index.cjs
+++ b/node_modules/prosemirror-view/dist/index.cjs
@@ -3456,7 +3456,7 @@ editHandlers.drop = function (view, _event) {
@@ -3482,7 +3482,7 @@ editHandlers.drop = function (view, _event) {
});
tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));
}
@@ -12,10 +12,10 @@ index 8ea57c7..aeda01d 100644
};
handlers.focus = function (view) {
diff --git a/node_modules/prosemirror-view/dist/index.js b/node_modules/prosemirror-view/dist/index.js
index 9583dc3..991bf0a 100644
index d0c1f9d..f5b3f53 100644
--- a/node_modules/prosemirror-view/dist/index.js
+++ b/node_modules/prosemirror-view/dist/index.js
@@ -3731,7 +3731,7 @@ editHandlers.drop = (view, _event) => {
@@ -3754,7 +3754,7 @@ editHandlers.drop = (view, _event) => {
tr.mapping.maps[tr.mapping.maps.length - 1].forEach((_from, _to, _newFrom, newTo) => end = newTo);
tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));
}

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`paste text > with markdown link 1`] = `"<div><div contenteditable="true" translate="no" class="tiptap ProseMirror" tabindex="0"><p><a target="_blank" rel="noopener noreferrer nofollow" href="example.com">test</a></p></div></div>"`;
exports[`paste text > with markdown link 1`] = `"<div><div contenteditable="true" translate="no" class="ProseMirror"></div><div contenteditable="true" role="textbox" translate="no" class="tiptap ProseMirror" tabindex="0"><p><a target="_blank" rel="noopener noreferrer nofollow" href="example.com">test</a></p></div></div>"`;
exports[`paste text > with multiple markdown links 1`] = `"<div><div contenteditable="true" translate="no" class="tiptap ProseMirror" tabindex="0"><p><a target="_blank" rel="noopener noreferrer nofollow" href="example.com">test</a> some text <a target="_blank" rel="noopener noreferrer nofollow" href="example2.com">test2</a></p></div></div>"`;
exports[`paste text > with multiple markdown links 1`] = `"<div><div contenteditable="true" translate="no" class="ProseMirror"></div><div contenteditable="true" role="textbox" translate="no" class="tiptap ProseMirror" tabindex="0"><p><a target="_blank" rel="noopener noreferrer nofollow" href="example.com">test</a> some text <a target="_blank" rel="noopener noreferrer nofollow" href="example2.com">test2</a></p></div></div>"`;

View File

@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`hitting backspace at the start of first list item 1`] = `"<div><div contenteditable="true" translate="no" class="tiptap ProseMirror" tabindex="0"><p>item1</p><ul><li><p>item2</p></li></ul></div></div>"`;
exports[`hitting backspace at the start of first list item 1`] = `"<div><div contenteditable="true" translate="no" class="ProseMirror"></div><div contenteditable="true" role="textbox" translate="no" class="tiptap ProseMirror" tabindex="0"><p>item1</p><ul><li><p>item2</p></li></ul></div></div>"`;
exports[`hitting backspace at the start of the second (or next) list item 1`] = `"<div><div contenteditable="true" translate="no" class="tiptap ProseMirror" tabindex="0"><ul><li><p>item1item2</p></li></ul></div></div>"`;
exports[`hitting backspace at the start of the second (or next) list item 1`] = `"<div><div contenteditable="true" translate="no" class="ProseMirror"></div><div contenteditable="true" role="textbox" translate="no" class="tiptap ProseMirror" tabindex="0"><ul><li><p>item1item2</p></li></ul></div></div>"`;
exports[`hitting backspace at the start of the second (or next) paragraph inside the list item 1`] = `"<div><div contenteditable="true" translate="no" class="tiptap ProseMirror" tabindex="0"><ul><li><p>item 1item 2</p></li></ul></div></div>"`;
exports[`hitting backspace at the start of the second (or next) paragraph inside the list item 1`] = `"<div><div contenteditable="true" translate="no" class="ProseMirror"></div><div contenteditable="true" role="textbox" translate="no" class="tiptap ProseMirror" tabindex="0"><ul><li><p>item 1item 2</p></li></ul></div></div>"`;