diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 6b88cf5..3fa4ff3 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -5573,6 +5573,53 @@ + + { + if (!editor) return; + // Try list indent first - run() returns true if it succeeded + const sank = editor.chain().focus().sinkListItem('listItem').run(); + if (!sank) { + const sankTask = editor.chain().focus().sinkListItem('taskItem').run(); + if (!sankTask && editor.state.selection.empty) { + editor.chain().focus().insertContent('\t').run(); + } + } + }} title="Indent"> + + + { + if (!editor) return; + const lifted = editor.chain().focus().liftListItem('listItem').run(); + if (!lifted) { + const liftedTask = editor.chain().focus().liftListItem('taskItem').run(); + if (!liftedTask && editor.state.selection.empty) { + // Remove leading tab/spaces from current line + const { from } = editor.state.selection; + const pos = editor.state.doc.resolve(from); + const lineStart = pos.start(pos.depth); + const lineText = editor.state.doc.textBetween(lineStart, pos.end(pos.depth)); + if (lineText.startsWith('\t')) { + editor.chain().focus().command(({ tr }) => { + tr.delete(lineStart, lineStart + 1); + return true; + }).run(); + } else if (lineText.startsWith(' ')) { + editor.chain().focus().command(({ tr }) => { + tr.delete(lineStart, lineStart + 4); + return true; + }).run(); + } else if (lineText.startsWith(' ')) { + editor.chain().focus().command(({ tr }) => { + tr.delete(lineStart, lineStart + 2); + return true; + }).run(); + } + } + } + }} title="Outdent"> + + +