🐛 tab support

This commit is contained in:
2026-02-28 10:40:26 +10:00
parent 02c5a09538
commit 62cd20c723
9 changed files with 81 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ import { EditorView, Decoration, type DecorationSet, hoverTooltip, keymap } from
import { EditorState, StateField, StateEffect, Annotation, RangeSetBuilder, Compartment, Transaction } from '@codemirror/state'
import { markdown } from '@codemirror/lang-markdown'
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'
import { history, defaultKeymap, historyKeymap, invertedEffects, selectAll } from '@codemirror/commands'
import { history, defaultKeymap, historyKeymap, invertedEffects, selectAll, indentLess } from '@codemirror/commands'
import { marked } from 'marked'
import DOMPurify from 'dompurify'
import { useEditorStore } from '../../store/editorStore'
@@ -375,7 +375,18 @@ export function MarkdownEditor(): JSX.Element {
doc: '',
extensions: [
history(),
keymap.of([...defaultKeymap, ...historyKeymap]),
keymap.of([
{
key: 'Tab',
run: (view) => {
view.dispatch(view.state.replaceSelection(' '))
return true
}
},
{ key: 'Shift-Tab', run: indentLess },
...defaultKeymap,
...historyKeymap
]),
markdown(),
syntaxHighlighting(defaultHighlightStyle),
rawAnnotationsField,