mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
refactor(code): stop exposing CodeMirror configuration
This commit is contained in:
parent
c24e1f0ec5
commit
49838fb773
@ -1,4 +1,4 @@
|
|||||||
import { defaultKeymap, history, historyKeymap, indentWithTab } from "@codemirror/commands";
|
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
||||||
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewUpdate, type EditorViewConfig } from "@codemirror/view";
|
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewUpdate, type EditorViewConfig } from "@codemirror/view";
|
||||||
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching, foldGutter } from "@codemirror/language";
|
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching, foldGutter } from "@codemirror/language";
|
||||||
import { Compartment, type Extension } from "@codemirror/state";
|
import { Compartment, type Extension } from "@codemirror/state";
|
||||||
@ -9,7 +9,8 @@ import smartIndentWithTab from "./extensions/custom_tab.js";
|
|||||||
|
|
||||||
type ContentChangedListener = () => void;
|
type ContentChangedListener = () => void;
|
||||||
|
|
||||||
export interface EditorConfig extends EditorViewConfig {
|
export interface EditorConfig {
|
||||||
|
parent: HTMLElement;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
lineWrapping?: boolean;
|
lineWrapping?: boolean;
|
||||||
vimKeybindings?: boolean;
|
vimKeybindings?: boolean;
|
||||||
@ -50,10 +51,6 @@ export default class CodeMirror extends EditorView {
|
|||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
if (Array.isArray(config.extensions)) {
|
|
||||||
extensions = [...extensions, ...config.extensions];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.placeholder) {
|
if (config.placeholder) {
|
||||||
extensions.push(placeholder(config.placeholder));
|
extensions.push(placeholder(config.placeholder));
|
||||||
}
|
}
|
||||||
@ -67,7 +64,7 @@ export default class CodeMirror extends EditorView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super({
|
super({
|
||||||
...config,
|
parent: config.parent,
|
||||||
extensions
|
extensions
|
||||||
});
|
});
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noImplicitOverride": true,
|
"noImplicitOverride": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
|
"lib": [
|
||||||
|
"DOM"
|
||||||
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
"vite/client"
|
"vite/client"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user