mirror of
https://github.com/kou029w/quot.git
synced 2025-01-31 14:28:06 +00:00
auto indent
This commit is contained in:
parent
66a9f4b780
commit
85b02bf020
1 changed files with 6 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { onCleanup, onMount } from "solid-js";
|
import { onCleanup, onMount } from "solid-js";
|
||||||
import { minimalSetup } from "codemirror";
|
import { minimalSetup } from "codemirror";
|
||||||
import { emacsStyleKeymap, indentWithTab } from "@codemirror/commands";
|
import { emacsStyleKeymap, indentWithTab } from "@codemirror/commands";
|
||||||
import { indentUnit } from "@codemirror/language";
|
import { indentService, indentUnit } from "@codemirror/language";
|
||||||
import { EditorView, keymap } from "@codemirror/view";
|
import { EditorView, keymap } from "@codemirror/view";
|
||||||
import type Pages from "../../protocol/pages";
|
import type Pages from "../../protocol/pages";
|
||||||
import "./editor.css";
|
import "./editor.css";
|
||||||
|
@ -37,6 +37,11 @@ export default (props: {
|
||||||
}),
|
}),
|
||||||
EditorView.lineWrapping,
|
EditorView.lineWrapping,
|
||||||
indentUnit.of(" "),
|
indentUnit.of(" "),
|
||||||
|
indentService.of((context, pos) => {
|
||||||
|
const previousLine = context.lineAt(pos, -1).text;
|
||||||
|
if (previousLine.trim() === "") return null;
|
||||||
|
return /^[ \t]*/.exec(previousLine)?.[0]?.length ?? null;
|
||||||
|
}),
|
||||||
keymap.of([indentWithTab, ...emacsStyleKeymap]),
|
keymap.of([indentWithTab, ...emacsStyleKeymap]),
|
||||||
minimalSetup,
|
minimalSetup,
|
||||||
quotLanguage,
|
quotLanguage,
|
||||||
|
|
Loading…
Add table
Reference in a new issue