mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(code): reintroduce some commented-out behaviours
This commit is contained in:
parent
00a9908907
commit
bedbc9373c
@ -80,28 +80,22 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
show() {
|
show() {
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
|
|
||||||
// if (this.codeEditor) {
|
|
||||||
// // show can be called before render
|
|
||||||
// this.codeEditor.refresh();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
this.$editor.focus();
|
|
||||||
this.codeEditor.focus();
|
this.codeEditor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToEnd() {
|
scrollToEnd() {
|
||||||
// this.codeEditor.setCursor(this.codeEditor.lineCount(), 0);
|
this.codeEditor.scrollToEnd();
|
||||||
// this.codeEditor.focus();
|
this.codeEditor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
if (this.codeEditor) {
|
if (this.codeEditor) {
|
||||||
// this.spacedUpdate.allowUpdateWithoutChange(() => {
|
this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||||
// this.codeEditor.setValue("");
|
this.codeEditor.setText("");
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { defaultKeymap, history, historyKeymap } 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, EditorState, type Extension } from "@codemirror/state";
|
import { Compartment, EditorSelection, EditorState, type Extension } from "@codemirror/state";
|
||||||
import { highlightSelectionMatches } from "@codemirror/search";
|
import { highlightSelectionMatches } from "@codemirror/search";
|
||||||
import { vim } from "@replit/codemirror-vim";
|
import { vim } from "@replit/codemirror-vim";
|
||||||
import byMimeType from "./syntax_highlighting.js";
|
import byMimeType from "./syntax_highlighting.js";
|
||||||
@ -137,6 +137,15 @@ export default class CodeMirror extends EditorView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToEnd() {
|
||||||
|
const endPos = this.state.doc.length;
|
||||||
|
this.dispatch({
|
||||||
|
selection: EditorSelection.cursor(endPos),
|
||||||
|
effects: EditorView.scrollIntoView(endPos, { y: "end" }),
|
||||||
|
scrollIntoView: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async setMimeType(mime: string) {
|
async setMimeType(mime: string) {
|
||||||
let newExtension: Extension[] = [];
|
let newExtension: Extension[] = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user