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
small refactorings of auto readonly size
zadam9c9a3fc030d7
diff --git a/src/public/app/dialogs/options/other.js b/src/public/app/dialogs/options/other.jsindex aa5458f414..99bde91ecf 100644--- a/src/public/app/dialogs/options/other.js+++ b/src/public/app/dialogs/options/other.js@@ -85,16 +85,16 @@ const TPL = `<div><h4>Automatic readonly size</h4>- <p>Automatic readonly note size is the size after which notes will be readonly if automatic readonly is enabled.</p>+ <p>Automatic readonly note size is the size after which notes will be displayed in a readonly mode (for performance reasons).</p><div class="form-group">- <label for="automatic-readonly-size">Automatic readonly size (text notes)</label>- <input class="form-control" id="automatic-readonly-size-text" type="number">+ <label for="auto-readonly-size-text">Automatic readonly size (text notes)</label>+ <input class="form-control" id="auto-readonly-size-text" type="number"></div><div class="form-group">- <label for="automatic-readonly-size">Automatic readonly size (code notes)</label>- <input class="form-control" id="automatic-readonly-size-code" type="number">+ <label for="auto-readonly-size-code">Automatic readonly size (code notes)</label>+ <input class="form-control" id="auto-readonly-size-code" type="number"></div></div>`;@@ -184,19 +184,19 @@ export default class ProtectedSessionOptions {return false;});- this.$autoReadonlySize = $("#automatic-readonly-size-text");+ this.$autoReadonlySizeText = $("#auto-readonly-size-text");- this.$autoReadonlySize.on('change', () => {- const opts = { 'autoReadonlySize': this.$autoReadonlySize.val() };+ this.$autoReadonlySizeText.on('change', () => {+ const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() };server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));return false;});- this.$autoCodeReadonlySize = $("#automatic-readonly-size-code");+ this.$autoReadonlySizeCode = $("#auto-readonly-size-code");- this.$autoCodeReadonlySize.on('change', () => {- const opts = { 'autoCodeReadonlySize': this.$autoReadonlySize.val() };+ this.$autoReadonlySizeCode.on('change', () => {+ const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeText.val() };server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));return false;@@ -214,7 +214,7 @@ export default class ProtectedSessionOptions {this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);this.$imageJpegQuality.val(options['imageJpegQuality']);- this.$autoReadonlySize.val(options['autoReadonlySize']);- this.$autoCodeReadonlySize.val(options['autoCodeReadonlySize']);+ this.$autoReadonlySizeText.val(options['autoReadonlySizeText']);+ this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']);}}diff --git a/src/public/app/services/note_context.js b/src/public/app/services/note_context.jsindex c5c0de959e..b51db1ce85 100644--- a/src/public/app/services/note_context.js+++ b/src/public/app/services/note_context.js@@ -193,12 +193,12 @@ class NoteContext extends Component {const noteComplement = await this.getNoteComplement();- const SIZE_LIMIT = this.note.type === 'text' ?- options.getInt('autoReadonlySize')- : options.getInt('autoCodeReadonlySize');+ const sizeLimit = this.note.type === 'text' ?+ options.getInt('autoReadonlySizeText')+ : options.getInt('autoReadonlySizeCode');return noteComplement.content- && noteComplement.content.length > SIZE_LIMIT+ && noteComplement.content.length > sizeLimit&& !this.note.hasLabel('autoReadOnlyDisabled');}diff --git a/src/routes/api/options.js b/src/routes/api/options.jsindex 8f1463267d..aa888b9fa4 100644--- a/src/routes/api/options.js+++ b/src/routes/api/options.js@@ -43,8 +43,8 @@ const ALLOWED_OPTIONS = new Set(['similarNotesExpanded','headingStyle','autoCollapseNoteTree',- 'autoReadonlySize',- 'autoCodeReadonlySize'+ 'autoReadonlySizeText',+ 'autoReadonlySizeCode']);function getOptions() {diff --git a/src/services/options_init.js b/src/services/options_init.jsindex 81913fabe8..9b37ac2245 100644--- a/src/services/options_init.js+++ b/src/services/options_init.js@@ -87,8 +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 },+ { name: 'autoReadonlySizeText', value: '10000', isSynced: false },+ { name: 'autoReadonlySizeCode', value: '30000', isSynced: false },];function initStartupOptions() {