Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Extension } from "@tiptap/core";
import { liftTarget } from "@tiptap/pm/transform";

const KeyboardShortcuts = ({ onSubmit, shortcuts, isBlockQuoteActive }) =>
Extension.create({
Expand All @@ -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,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -94,6 +95,7 @@ const useCustomExtensions = ({
shortcuts: keyboardShortcuts,
isBlockQuoteActive: options.includes(EDITOR_OPTIONS.BLOCKQUOTE),
}),
ListKeymap,
];
if (isVideoEmbedActive) {
customExtensions.push(Embeds);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
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/[email protected]":
version "2.6.6"
resolved "https://registry.yarnpkg.com/@tiptap/extension-mention/-/extension-mention-2.6.6.tgz#c46878bed263eb0ddb8f57b33530dd4ae7000920"
Expand Down
Loading