From 53c1be91f8043cf5168ee984af43c2a7af6601a4 Mon Sep 17 00:00:00 2001 From: Abhay V Ashokan Date: Wed, 23 Apr 2025 20:31:15 +0530 Subject: [PATCH 1/3] Revert "Added backspace keyboard shortcut to custom handle the issues in deleting the list item. (#1191)" This reverts commit 166d28333b23a137da13ccbd40f372942711105e. --- .../KeyboardShortcuts/ExtensionConfig.js | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/components/Editor/CustomExtensions/KeyboardShortcuts/ExtensionConfig.js b/src/components/Editor/CustomExtensions/KeyboardShortcuts/ExtensionConfig.js index 8ac4eed5..d1666638 100644 --- a/src/components/Editor/CustomExtensions/KeyboardShortcuts/ExtensionConfig.js +++ b/src/components/Editor/CustomExtensions/KeyboardShortcuts/ExtensionConfig.js @@ -1,5 +1,4 @@ import { Extension } from "@tiptap/core"; -import { liftTarget } from "@tiptap/pm/transform"; const KeyboardShortcuts = ({ onSubmit, shortcuts, isBlockQuoteActive }) => Extension.create({ @@ -21,40 +20,6 @@ const KeyboardShortcuts = ({ onSubmit, shortcuts, isBlockQuoteActive }) => return false; }, - // To fix the issue with backspace on the empty list item moving the focus to the block on top. - // https://github.com/ueberdosis/tiptap/issues/2829#issuecomment-1511064298 - Backspace: () => - this.editor.commands.command(({ tr }) => { - const { selection, doc } = tr; - const { $cursor } = selection; - const depth = $cursor?.depth; - - if ( - $cursor && - depth >= 3 && // At least the structure is doc -> orderedList/bulletList -> listItem -> paragraph - $cursor.parent.type.name === "paragraph" && // The cursor is inside a paragraph. - $cursor.parentOffset === 0 && // The cursor is at the beginning of the paragraph. - $cursor.node(depth - 1).type.name === "listItem" && // The paragraph is inside a listItem. - $cursor.index(depth - 1) === 0 && // The paragraph is at the beginning of the listItem. - $cursor.index(depth - 2) === 0 // The listItem is at the beginning of the list. - ) { - const listItemNode = $cursor.node(depth - 1); - const listItemPos = $cursor.before(depth - 1); - const $contentBegin = doc.resolve(listItemPos + 1); - const $contentEnd = doc.resolve( - listItemPos + listItemNode.nodeSize - 1 - ); - const range = $contentBegin.blockRange($contentEnd); - const target = liftTarget(range); - if (target !== null) { - tr.lift(range, target); - - return true; - } - } - - return false; - }), ...shortcuts, }; }, From 3a74dbb098c011bb91346c02389b6f918f72c094 Mon Sep 17 00:00:00 2001 From: Abhay V Ashokan Date: Thu, 24 Apr 2025 17:39:34 +0530 Subject: [PATCH 2/3] Added @tiptap/extension-list-keymap --- package.json | 1 + yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 902c9043..192fae04 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "@tiptap/extension-highlight": "2.6.6", "@tiptap/extension-image": "2.6.6", "@tiptap/extension-link": "2.6.6", + "@tiptap/extension-list-keymap": "2.11.7", "@tiptap/extension-mention": "2.6.6", "@tiptap/extension-placeholder": "2.6.6", "@tiptap/extension-table": "2.6.6", diff --git a/yarn.lock b/yarn.lock index a15372a7..d04507b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4018,6 +4018,11 @@ resolved "https://registry.yarnpkg.com/@tiptap/extension-list-item/-/extension-list-item-2.6.6.tgz#fedb7d5b3293d487eb5b9773abe8eb8a0a395428" integrity sha512-k+oEzZu2cgVKqPqOP1HzASOKLpTEV9m7mRVPAbuaaX8mSyvIgD6f+JUx9PvgYv//D918wk98LMoRBFX53tDJ4w== +"@tiptap/extension-list-keymap@2.11.7": + version "2.11.7" + resolved "https://registry.yarnpkg.com/@tiptap/extension-list-keymap/-/extension-list-keymap-2.11.7.tgz#a89a94e961c69d89c06b5071417f9adb78659787" + integrity sha512-t1XgD6+NNxEW9KrI7eK/RnXV/zBsHbYwzn4g0V3+NYQS7siaeCHHN0JwGhVPx1RojYeg+zq9NEj+fr4f3G7XAw== + "@tiptap/extension-mention@2.6.6": version "2.6.6" resolved "https://registry.yarnpkg.com/@tiptap/extension-mention/-/extension-mention-2.6.6.tgz#c46878bed263eb0ddb8f57b33530dd4ae7000920" From adf7e3f9e3493c322a455541ee4157b56fc7c619 Mon Sep 17 00:00:00 2001 From: Abhay V Ashokan Date: Thu, 24 Apr 2025 17:40:20 +0530 Subject: [PATCH 3/3] Added new extension to the list of custom extensions --- .../Editor/CustomExtensions/hooks/useCustomExtensions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Editor/CustomExtensions/hooks/useCustomExtensions.js b/src/components/Editor/CustomExtensions/hooks/useCustomExtensions.js index bc73b2fa..7ac99486 100644 --- a/src/components/Editor/CustomExtensions/hooks/useCustomExtensions.js +++ b/src/components/Editor/CustomExtensions/hooks/useCustomExtensions.js @@ -6,6 +6,7 @@ import Color from "@tiptap/extension-color"; import Document from "@tiptap/extension-document"; import Focus from "@tiptap/extension-focus"; import Highlight from "@tiptap/extension-highlight"; +import ListKeymap from "@tiptap/extension-list-keymap"; import TableCell from "@tiptap/extension-table-cell"; import TableHeader from "@tiptap/extension-table-header"; import TableRow from "@tiptap/extension-table-row"; @@ -94,6 +95,7 @@ const useCustomExtensions = ({ shortcuts: keyboardShortcuts, isBlockQuoteActive: options.includes(EDITOR_OPTIONS.BLOCKQUOTE), }), + ListKeymap, ]; if (isVideoEmbedActive) { customExtensions.push(Embeds);