mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Add config option to change automatic readonly size (#2174)
This commit is contained in:
parent
bdde52f004
commit
b85cf07a28
@ -80,6 +80,22 @@ const TPL = `
|
|||||||
<label for="note-revision-snapshot-time-interval-in-seconds">Note revision snapshot time interval (in seconds)</label>
|
<label for="note-revision-snapshot-time-interval-in-seconds">Note revision snapshot time interval (in seconds)</label>
|
||||||
<input class="form-control" id="note-revision-snapshot-time-interval-in-seconds" type="number">
|
<input class="form-control" id="note-revision-snapshot-time-interval-in-seconds" type="number">
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
</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">
|
||||||
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class ProtectedSessionOptions {
|
export default class ProtectedSessionOptions {
|
||||||
@ -167,6 +183,24 @@ export default class ProtectedSessionOptions {
|
|||||||
|
|
||||||
return false;
|
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) {
|
optionsLoaded(options) {
|
||||||
@ -179,5 +213,8 @@ export default class ProtectedSessionOptions {
|
|||||||
|
|
||||||
this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);
|
this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);
|
||||||
this.$imageJpegQuality.val(options['imageJpegQuality']);
|
this.$imageJpegQuality.val(options['imageJpegQuality']);
|
||||||
|
|
||||||
|
this.$autoReadonlySize.val(options['autoReadonlySize']);
|
||||||
|
this.$autoCodeReadonlySize.val(options['autoCodeReadonlySize']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import treeService from "./tree.js";
|
|||||||
import Component from "../widgets/component.js";
|
import Component from "../widgets/component.js";
|
||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
|
import options from "./options.js";
|
||||||
|
|
||||||
class NoteContext extends Component {
|
class NoteContext extends Component {
|
||||||
/**
|
/**
|
||||||
@ -192,7 +193,9 @@ class NoteContext extends Component {
|
|||||||
|
|
||||||
const noteComplement = await this.getNoteComplement();
|
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
|
return noteComplement.content
|
||||||
&& noteComplement.content.length > SIZE_LIMIT
|
&& noteComplement.content.length > SIZE_LIMIT
|
||||||
|
@ -42,7 +42,9 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
'promotedAttributesExpanded',
|
'promotedAttributesExpanded',
|
||||||
'similarNotesExpanded',
|
'similarNotesExpanded',
|
||||||
'headingStyle',
|
'headingStyle',
|
||||||
'autoCollapseNoteTree'
|
'autoCollapseNoteTree',
|
||||||
|
'autoReadonlySize',
|
||||||
|
'autoCodeReadonlySize'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
|
@ -87,6 +87,8 @@ const defaultOptions = [
|
|||||||
{ name: 'debugModeEnabled', value: 'false', isSynced: false },
|
{ name: 'debugModeEnabled', value: 'false', isSynced: false },
|
||||||
{ name: 'headingStyle', value: 'underline', isSynced: true },
|
{ name: 'headingStyle', value: 'underline', isSynced: true },
|
||||||
{ name: 'autoCollapseNoteTree', value: 'true', isSynced: true },
|
{ name: 'autoCollapseNoteTree', value: 'true', isSynced: true },
|
||||||
|
{ name: 'autoReadonlySize', value: '10000', isSynced: false },
|
||||||
|
{ name: 'autoCodeReadonlySize', value: '30000', isSynced: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
function initStartupOptions() {
|
function initStartupOptions() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user