diff --git a/ui/packages/editor/src/extensions/indent/index.ts b/ui/packages/editor/src/extensions/indent/index.ts index 81d310387..d0418460b 100644 --- a/ui/packages/editor/src/extensions/indent/index.ts +++ b/ui/packages/editor/src/extensions/indent/index.ts @@ -30,6 +30,7 @@ type IndentOptions = { }; const Indent = Extension.create({ name: "indent", + priority: 10000, addOptions() { return { @@ -115,6 +116,28 @@ const Indent = Extension.create({ "Shift-Tab": getOutdent(false), "Mod-]": getIndent(), "Mod-[": getOutdent(false), + Backspace: ({ editor }) => { + const { selection } = editor.state; + const { $from } = selection; + + if ($from.parentOffset === 0) { + const node = $from.parent; + + if (node.attrs.lineIndent) { + return editor + .chain() + .focus() + .updateAttributes(node.type.name, { lineIndent: false }) + .run(); + } + + if (node.attrs.indent && node.attrs.indent > 0) { + return getOutdent(false)({ editor }); + } + } + + return false; + }, }; }, diff --git a/ui/packages/editor/src/extensions/paragraph/index.ts b/ui/packages/editor/src/extensions/paragraph/index.ts index 553431ce8..4794e004b 100644 --- a/ui/packages/editor/src/extensions/paragraph/index.ts +++ b/ui/packages/editor/src/extensions/paragraph/index.ts @@ -176,6 +176,11 @@ export function handleDeletePreviousNode( return false; } + const allowGapCursor = nodeBefore.type.spec.allowGapCursor; + if (!allowGapCursor) { + return false; + } + if (deleteNodeByPos($from.doc.resolve(beforePos - 1))(tr)) { dispatch(tr); return true;