From 76f34e3eaf265ae6626e000fccd5a98bce77c9a2 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 8 Nov 2022 22:55:11 +0100 Subject: [PATCH] small tweaks of linewrap option --- .../app/widgets/dialogs/options/code_notes.js | 21 +++++++++++-------- .../app/widgets/type_widgets/editable_code.js | 4 ++-- src/routes/api/options.js | 2 +- src/services/options_init.js | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/public/app/widgets/dialogs/options/code_notes.js b/src/public/app/widgets/dialogs/options/code_notes.js index c533755e9..a5bee4180 100644 --- a/src/public/app/widgets/dialogs/options/code_notes.js +++ b/src/public/app/widgets/dialogs/options/code_notes.js @@ -2,19 +2,22 @@ import mimeTypesService from "../../../services/mime_types.js"; import options from "../../../services/options.js"; import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; -import utils from "../../../services/utils.js"; const TPL = ` -

Use vim keybindings in CodeNotes (no ex mode)

+

Use vim keybindings in code notes (no ex mode)

-

Wrap lines in CodeNotes

+
+ +

Wrap lines in code notes

- - + +
+
+

Available MIME types in the dropdown

`; @@ -29,9 +32,9 @@ export default class CodeNotesOptions { server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); - this.$linewrapEnabled = $("#linewrap-enabled"); - this.$linewrapEnabled.on('change', () => { - const opts = { 'linewrapEnabled': this.$linewrapEnabled.is(":checked") ? "true" : "false" }; + this.$codeLineWrapEnabled = $("#line-wrap-enabled"); + this.$codeLineWrapEnabled.on('change', () => { + const opts = { 'codeLineWrapEnabled': this.$codeLineWrapEnabled.is(":checked") ? "true" : "false" }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); @@ -41,7 +44,7 @@ export default class CodeNotesOptions { async optionsLoaded(options) { this.$mimeTypes.empty(); this.$vimKeymapEnabled.prop("checked", options['vimKeymapEnabled'] === 'true'); - this.$linewrapEnabled.prop("checked", options['linewrapEnabled'] === 'true'); + this.$codeLineWrapEnabled.prop("checked", options['codeLineWrapEnabled'] === 'true'); let idCtr = 1; for (const mimeType of await mimeTypesService.getMimeTypes()) { diff --git a/src/public/app/widgets/type_widgets/editable_code.js b/src/public/app/widgets/type_widgets/editable_code.js index 779f2337f..143c65458 100644 --- a/src/public/app/widgets/type_widgets/editable_code.js +++ b/src/public/app/widgets/type_widgets/editable_code.js @@ -58,9 +58,9 @@ export default class EditableCodeTypeWidget extends TypeWidget { gutters: ["CodeMirror-lint-markers"], lineNumbers: true, tabindex: 300, - // we linewrap partly also because without it horizontal scrollbar displays only when you scroll + // we line wrap partly also because without it horizontal scrollbar displays only when you scroll // all the way to the bottom of the note. With line wrap there's no horizontal scrollbar so no problem - lineWrapping: options.is('linewrapEnabled'), + lineWrapping: options.is('codeLineWrapEnabled'), dragDrop: false, // with true the editor inlines dropped files which is not what we expect placeholder: "Type the content of your code note here..." }); diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 85673c905..07def4479 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -33,7 +33,7 @@ const ALLOWED_OPTIONS = new Set([ 'editedNotesWidget', 'calendarWidget', 'vimKeymapEnabled', - 'linewrapEnabled', + 'codeLineWrapEnabled', 'codeNotesMimeTypes', 'spellCheckEnabled', 'spellCheckLanguageCode', diff --git a/src/services/options_init.js b/src/services/options_init.js index 1612ad2b5..703e299ab 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -62,7 +62,7 @@ const defaultOptions = [ { name: 'imageJpegQuality', value: '75', isSynced: true }, { name: 'autoFixConsistencyIssues', value: 'true', isSynced: false }, { name: 'vimKeymapEnabled', value: 'false', isSynced: false }, - { name: 'linewrapEnabled', value: 'true', isSynced: false }, + { name: 'codeLineWrapEnabled', value: 'true', isSynced: false }, { name: 'codeNotesMimeTypes', value: '["text/x-csrc","text/x-c++src","text/x-csharp","text/css","text/x-go","text/x-groovy","text/x-haskell","text/html","message/http","text/x-java","application/javascript;env=frontend","application/javascript;env=backend","application/json","text/x-kotlin","text/x-markdown","text/x-perl","text/x-php","text/x-python","text/x-ruby",null,"text/x-sql","text/x-sqlite;schema=trilium","text/x-swift","text/xml","text/x-yaml"]', isSynced: true }, { name: 'leftPaneWidth', value: '25', isSynced: false }, { name: 'leftPaneVisible', value: 'true', isSynced: false },