diff --git a/src/public/app/dialogs/options/other.js b/src/public/app/dialogs/options/other.js index 213075252..aa5458f41 100644 --- a/src/public/app/dialogs/options/other.js +++ b/src/public/app/dialogs/options/other.js @@ -80,6 +80,22 @@ const TPL = ` + + +
+

Automatic readonly size

+ +

Automatic readonly note size is the size after which notes will be readonly if automatic readonly is enabled.

+ +
+ + +
+ +
+ + +
`; export default class ProtectedSessionOptions { @@ -167,6 +183,24 @@ export default class ProtectedSessionOptions { return false; }); + + this.$autoReadonlySize = $("#automatic-readonly-size-text"); + + this.$autoReadonlySize.on('change', () => { + const opts = { 'autoReadonlySize': this.$autoReadonlySize.val() }; + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); + + return false; + }); + + this.$autoCodeReadonlySize = $("#automatic-readonly-size-code"); + + this.$autoCodeReadonlySize.on('change', () => { + const opts = { 'autoCodeReadonlySize': this.$autoReadonlySize.val() }; + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); + + return false; + }); } optionsLoaded(options) { @@ -179,5 +213,8 @@ export default class ProtectedSessionOptions { this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']); this.$imageJpegQuality.val(options['imageJpegQuality']); + + this.$autoReadonlySize.val(options['autoReadonlySize']); + this.$autoCodeReadonlySize.val(options['autoCodeReadonlySize']); } } diff --git a/src/public/app/services/note_context.js b/src/public/app/services/note_context.js index f69712bb1..c5c0de959 100644 --- a/src/public/app/services/note_context.js +++ b/src/public/app/services/note_context.js @@ -6,6 +6,7 @@ import treeService from "./tree.js"; import Component from "../widgets/component.js"; import froca from "./froca.js"; import hoistedNoteService from "./hoisted_note.js"; +import options from "./options.js"; class NoteContext extends Component { /** @@ -192,7 +193,9 @@ class NoteContext extends Component { const noteComplement = await this.getNoteComplement(); - const SIZE_LIMIT = this.note.type === 'text' ? 10000 : 30000; + const SIZE_LIMIT = this.note.type === 'text' ? + options.getInt('autoReadonlySize') + : options.getInt('autoCodeReadonlySize'); return noteComplement.content && noteComplement.content.length > SIZE_LIMIT diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 46a612636..8f1463267 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -42,7 +42,9 @@ const ALLOWED_OPTIONS = new Set([ 'promotedAttributesExpanded', 'similarNotesExpanded', 'headingStyle', - 'autoCollapseNoteTree' + 'autoCollapseNoteTree', + 'autoReadonlySize', + 'autoCodeReadonlySize' ]); function getOptions() { diff --git a/src/services/options_init.js b/src/services/options_init.js index d0e2cd203..81913fabe 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -87,6 +87,8 @@ const defaultOptions = [ { name: 'debugModeEnabled', value: 'false', isSynced: false }, { name: 'headingStyle', value: 'underline', isSynced: true }, { name: 'autoCollapseNoteTree', value: 'true', isSynced: true }, + { name: 'autoReadonlySize', value: '10000', isSynced: false }, + { name: 'autoCodeReadonlySize', value: '30000', isSynced: false }, ]; function initStartupOptions() {