mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Update dependencies & directly include editor
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { type LanguageSupport, indentUnit } from "@codemirror/language";
|
||||
import { type Extension, EditorState } from "@codemirror/state";
|
||||
import { EditorView, keymap } from "@codemirror/view";
|
||||
|
||||
import { indentWithTab } from "@codemirror/commands";
|
||||
import { basicSetup } from "codemirror";
|
||||
|
||||
export function get_base_extensions(
|
||||
useTab: boolean,
|
||||
tabSize: number,
|
||||
lineWrapping: boolean,
|
||||
placeholder: string | HTMLElement | null | undefined,
|
||||
editable: boolean,
|
||||
readonly: boolean,
|
||||
lang: LanguageSupport | null | undefined
|
||||
): Extension[] {
|
||||
const extensions: Extension[] = [
|
||||
indentUnit.of(" ".repeat(tabSize)),
|
||||
EditorView.editable.of(editable),
|
||||
EditorState.readOnly.of(readonly),
|
||||
basicSetup
|
||||
];
|
||||
|
||||
if (useTab) extensions.push(keymap.of([indentWithTab]));
|
||||
// if (placeholder) extensions.push(placeholderExt(placeholder));
|
||||
if (lang) extensions.push(lang);
|
||||
if (lineWrapping) extensions.push(EditorView.lineWrapping);
|
||||
|
||||
return extensions;
|
||||
}
|
||||
Reference in New Issue
Block a user