mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(code): reintroduce read-only mode
This commit is contained in:
parent
49838fb773
commit
3e5e19b8a5
@ -39,7 +39,7 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||
this.show();
|
||||
}
|
||||
|
||||
getExtraOpts(): Partial<CodeMirrorOpts> {
|
||||
getExtraOpts() {
|
||||
return {
|
||||
readOnly: true
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
||||
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewUpdate, type EditorViewConfig } from "@codemirror/view";
|
||||
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching, foldGutter } from "@codemirror/language";
|
||||
import { Compartment, type Extension } from "@codemirror/state";
|
||||
import { Compartment, EditorState, type Extension } from "@codemirror/state";
|
||||
import { highlightSelectionMatches } from "@codemirror/search";
|
||||
import { vim } from "@replit/codemirror-vim";
|
||||
import byMimeType from "./syntax_highlighting.js";
|
||||
@ -14,6 +14,7 @@ export interface EditorConfig {
|
||||
placeholder?: string;
|
||||
lineWrapping?: boolean;
|
||||
vimKeybindings?: boolean;
|
||||
readOnly?: boolean;
|
||||
onContentChanged?: ContentChangedListener;
|
||||
}
|
||||
|
||||
@ -51,6 +52,10 @@ export default class CodeMirror extends EditorView {
|
||||
])
|
||||
]
|
||||
|
||||
if (config.readOnly) {
|
||||
extensions.push(EditorState.readOnly.of(true));
|
||||
}
|
||||
|
||||
if (config.placeholder) {
|
||||
extensions.push(placeholder(config.placeholder));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user