|
@@ -5,7 +5,7 @@ import {
|
|
|
markdown, markdownLanguage,
|
|
markdown, markdownLanguage,
|
|
|
} from '@codemirror/lang-markdown';
|
|
} from '@codemirror/lang-markdown';
|
|
|
import { syntaxHighlighting, HighlightStyle, defaultHighlightStyle } from '@codemirror/language';
|
|
import { syntaxHighlighting, HighlightStyle, defaultHighlightStyle } from '@codemirror/language';
|
|
|
-import { languages } from '@codemirror/language-data';
|
|
|
|
|
|
|
+import { languages, deleteMarkupBackward } from '@codemirror/language-data';
|
|
|
import {
|
|
import {
|
|
|
EditorState, Prec, type Extension,
|
|
EditorState, Prec, type Extension,
|
|
|
} from '@codemirror/state';
|
|
} from '@codemirror/state';
|
|
@@ -27,6 +27,10 @@ import { useInsertText, type InsertText } from './utils/insert-text';
|
|
|
import { useReplaceText, type ReplaceText } from './utils/replace-text';
|
|
import { useReplaceText, type ReplaceText } from './utils/replace-text';
|
|
|
import { useSetCaretLine, type SetCaretLine } from './utils/set-caret-line';
|
|
import { useSetCaretLine, type SetCaretLine } from './utils/set-caret-line';
|
|
|
|
|
|
|
|
|
|
+const markdownKeymap = [
|
|
|
|
|
+ { key: 'Backspace', run: deleteMarkupBackward },
|
|
|
|
|
+ { key: 'Enter', run: }
|
|
|
|
|
+];
|
|
|
|
|
|
|
|
const markdownHighlighting = HighlightStyle.define([
|
|
const markdownHighlighting = HighlightStyle.define([
|
|
|
{ tag: tags.heading1, class: 'cm-header-1 cm-header' },
|
|
{ tag: tags.heading1, class: 'cm-header-1 cm-header' },
|
|
@@ -58,6 +62,7 @@ export type UseCodeMirrorEditor = {
|
|
|
const defaultExtensions: Extension[] = [
|
|
const defaultExtensions: Extension[] = [
|
|
|
EditorView.lineWrapping,
|
|
EditorView.lineWrapping,
|
|
|
markdown({ base: markdownLanguage, codeLanguages: languages }),
|
|
markdown({ base: markdownLanguage, codeLanguages: languages }),
|
|
|
|
|
+ // keymap.of(markdownKeymap),
|
|
|
keymap.of([indentWithTab]),
|
|
keymap.of([indentWithTab]),
|
|
|
Prec.lowest(keymap.of(defaultKeymap)),
|
|
Prec.lowest(keymap.of(defaultKeymap)),
|
|
|
syntaxHighlighting(markdownHighlighting),
|
|
syntaxHighlighting(markdownHighlighting),
|