feat(backend_log): disable some editor features to increase performance

This commit is contained in:
Elian Doran 2025-05-15 15:32:09 +03:00
parent 9133aab6ad
commit 7c1b13a2e7
No known key found for this signature in database
3 changed files with 20 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import server from "../../../services/server.js"; import server from "../../../services/server.js";
import AbstractCodeTypeWidget from "../abstract_code_type_widget.js"; import AbstractCodeTypeWidget from "../abstract_code_type_widget.js";
import type { EventData } from "../../../components/app_context.js"; import type { EventData } from "../../../components/app_context.js";
import type { EditorConfig } from "@triliumnext/codemirror";
const TPL = /*html*/`<div style="height: 100%; display: flex; flex-direction: column;"> const TPL = /*html*/`<div style="height: 100%; display: flex; flex-direction: column;">
<style> <style>
@ -38,9 +39,10 @@ export default class BackendLogWidget extends AbstractCodeTypeWidget {
this.refresh(); this.refresh();
} }
getExtraOpts(): Partial<CodeMirrorOpts> { getExtraOpts(): Partial<EditorConfig> {
return { return {
readOnly: true readOnly: true,
preferPerformance: true
}; };
} }

View File

@ -39,6 +39,7 @@
* Slight organization in Appearance settings: code block themes are now in "Text Notes", added a "Related settings" section in Appearance. * Slight organization in Appearance settings: code block themes are now in "Text Notes", added a "Related settings" section in Appearance.
* [Added support for opening and activating a note in a new tab using Ctrl+Shift+click on notes in the launcher pane, note tree, or note images](https://github.com/TriliumNext/Notes/pull/1854) by @SiriusXT * [Added support for opening and activating a note in a new tab using Ctrl+Shift+click on notes in the launcher pane, note tree, or note images](https://github.com/TriliumNext/Notes/pull/1854) by @SiriusXT
* [Style and footnote improvements](https://github.com/TriliumNext/Notes/pull/1913) by @SiriusXT * [Style and footnote improvements](https://github.com/TriliumNext/Notes/pull/1913) by @SiriusXT
* Backend log: disable some editor features in order to increase performance for large logs (syntax highlighting, folding, etc.).
## 📖 Documentation ## 📖 Documentation

View File

@ -20,6 +20,8 @@ export interface EditorConfig {
lineWrapping?: boolean; lineWrapping?: boolean;
vimKeybindings?: boolean; vimKeybindings?: boolean;
readOnly?: boolean; readOnly?: boolean;
/** Disables some of the nice-to-have features (bracket matching, syntax highlighting, indentation markers) in order to improve performance. */
preferPerformance?: boolean;
tabIndex?: number; tabIndex?: number;
onContentChanged?: ContentChangedListener; onContentChanged?: ContentChangedListener;
} }
@ -51,19 +53,10 @@ export default class CodeMirror extends EditorView {
...extensions, ...extensions,
languageCompartment.of([]), languageCompartment.of([]),
lineWrappingCompartment.of(config.lineWrapping ? EditorView.lineWrapping : []), lineWrappingCompartment.of(config.lineWrapping ? EditorView.lineWrapping : []),
themeCompartment.of([
syntaxHighlighting(defaultHighlightStyle, { fallback: true })
]),
searchMatchHighlightTheme, searchMatchHighlightTheme,
searchHighlightCompartment.of([]), searchHighlightCompartment.of([]),
highlightActiveLine(), highlightActiveLine(),
highlightSelectionMatches(),
bracketMatching(),
lineNumbers(), lineNumbers(),
foldGutter(),
indentationMarkers(),
indentUnit.of(" ".repeat(4)), indentUnit.of(" ".repeat(4)),
keymap.of([ keymap.of([
...defaultKeymap, ...defaultKeymap,
@ -72,6 +65,19 @@ export default class CodeMirror extends EditorView {
]) ])
] ]
if (!config.preferPerformance) {
extensions = [
...extensions,
themeCompartment.of([
syntaxHighlighting(defaultHighlightStyle, { fallback: true })
]),
highlightSelectionMatches(),
bracketMatching(),
foldGutter(),
indentationMarkers(),
];
}
if (!config.readOnly) { if (!config.readOnly) {
// Logic specific to editable notes // Logic specific to editable notes
if (config.placeholder) { if (config.placeholder) {