Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(backend_log): disable some editor features to increase performance
Elian Doran7c1b13a2e709
diff --git a/apps/client/src/widgets/type_widgets/content/backend_log.ts b/apps/client/src/widgets/type_widgets/content/backend_log.tsindex 150591fae4..b6f78f9fab 100644--- a/apps/client/src/widgets/type_widgets/content/backend_log.ts+++ b/apps/client/src/widgets/type_widgets/content/backend_log.ts@@ -1,6 +1,7 @@import server from "../../../services/server.js";import AbstractCodeTypeWidget from "../abstract_code_type_widget.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;"><style>@@ -38,9 +39,10 @@ export default class BackendLogWidget extends AbstractCodeTypeWidget {this.refresh();}- getExtraOpts(): Partial<CodeMirrorOpts> {+ getExtraOpts(): Partial<EditorConfig> {return {- readOnly: true+ readOnly: true,+ preferPerformance: true};}diff --git a/docs/Release Notes/Release Notes/v0.94.0.md b/docs/Release Notes/Release Notes/v0.94.0.mdindex 631d878473..c024d34249 100644--- a/docs/Release Notes/Release Notes/v0.94.0.md+++ b/docs/Release Notes/Release Notes/v0.94.0.md@@ -39,6 +39,7 @@* 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* [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.).## 📖 Documentationdiff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.tsindex 64f3156a48..8d6687be86 100644--- a/packages/codemirror/src/index.ts+++ b/packages/codemirror/src/index.ts@@ -20,6 +20,8 @@ export interface EditorConfig {lineWrapping?: boolean;vimKeybindings?: 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;onContentChanged?: ContentChangedListener;}@@ -51,19 +53,10 @@ export default class CodeMirror extends EditorView {...extensions,languageCompartment.of([]),lineWrappingCompartment.of(config.lineWrapping ? EditorView.lineWrapping : []),- themeCompartment.of([- syntaxHighlighting(defaultHighlightStyle, { fallback: true })- ]),-searchMatchHighlightTheme,searchHighlightCompartment.of([]),-highlightActiveLine(),- highlightSelectionMatches(),- bracketMatching(),lineNumbers(),- foldGutter(),- indentationMarkers(),indentUnit.of(" ".repeat(4)),keymap.of([...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) {// Logic specific to editable notesif (config.placeholder) {