mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	small refactorings of auto readonly size
This commit is contained in:
		| @@ -85,16 +85,16 @@ const TPL = ` | |||||||
| <div> | <div> | ||||||
|     <h4>Automatic readonly size</h4> |     <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"> |     <div class="form-group"> | ||||||
|         <label for="automatic-readonly-size">Automatic readonly size (text notes)</label> |         <label for="auto-readonly-size-text">Automatic readonly size (text notes)</label> | ||||||
|         <input class="form-control" id="automatic-readonly-size-text" type="number"> |         <input class="form-control" id="auto-readonly-size-text" type="number"> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <div class="form-group"> |     <div class="form-group"> | ||||||
|         <label for="automatic-readonly-size">Automatic readonly size (code notes)</label> |         <label for="auto-readonly-size-code">Automatic readonly size (code notes)</label> | ||||||
|         <input class="form-control" id="automatic-readonly-size-code" type="number"> |         <input class="form-control" id="auto-readonly-size-code" type="number"> | ||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
|  |  | ||||||
| @@ -184,19 +184,19 @@ export default class ProtectedSessionOptions { | |||||||
|             return false; |             return false; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.$autoReadonlySize = $("#automatic-readonly-size-text"); |         this.$autoReadonlySizeText = $("#auto-readonly-size-text"); | ||||||
|  |  | ||||||
|         this.$autoReadonlySize.on('change', () => { |         this.$autoReadonlySizeText.on('change', () => { | ||||||
|             const opts = { 'autoReadonlySize': this.$autoReadonlySize.val() }; |             const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() }; | ||||||
|             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); |             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | ||||||
|  |  | ||||||
|             return false; |             return false; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.$autoCodeReadonlySize = $("#automatic-readonly-size-code"); |         this.$autoReadonlySizeCode = $("#auto-readonly-size-code"); | ||||||
|  |  | ||||||
|         this.$autoCodeReadonlySize.on('change', () => { |         this.$autoReadonlySizeCode.on('change', () => { | ||||||
|             const opts = { 'autoCodeReadonlySize': this.$autoReadonlySize.val() }; |             const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeText.val() }; | ||||||
|             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); |             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | ||||||
|  |  | ||||||
|             return false; |             return false; | ||||||
| @@ -214,7 +214,7 @@ 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.$autoReadonlySizeText.val(options['autoReadonlySizeText']); | ||||||
|         this.$autoCodeReadonlySize.val(options['autoCodeReadonlySize']); |         this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -193,12 +193,12 @@ class NoteContext extends Component { | |||||||
|  |  | ||||||
|         const noteComplement = await this.getNoteComplement(); |         const noteComplement = await this.getNoteComplement(); | ||||||
|  |  | ||||||
|         const SIZE_LIMIT = this.note.type === 'text' ? |         const sizeLimit = this.note.type === 'text' ? | ||||||
|             options.getInt('autoReadonlySize') |             options.getInt('autoReadonlySizeText') | ||||||
|                 : options.getInt('autoCodeReadonlySize'); |                 : options.getInt('autoReadonlySizeCode'); | ||||||
|  |  | ||||||
|         return noteComplement.content |         return noteComplement.content | ||||||
|             && noteComplement.content.length > SIZE_LIMIT |             && noteComplement.content.length > sizeLimit | ||||||
|             && !this.note.hasLabel('autoReadOnlyDisabled'); |             && !this.note.hasLabel('autoReadOnlyDisabled'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,8 +43,8 @@ const ALLOWED_OPTIONS = new Set([ | |||||||
|     'similarNotesExpanded', |     'similarNotesExpanded', | ||||||
|     'headingStyle', |     'headingStyle', | ||||||
|     'autoCollapseNoteTree', |     'autoCollapseNoteTree', | ||||||
|     'autoReadonlySize', |     'autoReadonlySizeText', | ||||||
|     'autoCodeReadonlySize' |     'autoReadonlySizeCode' | ||||||
| ]); | ]); | ||||||
|  |  | ||||||
| function getOptions() { | function getOptions() { | ||||||
|   | |||||||
| @@ -87,8 +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: 'autoReadonlySizeText', value: '10000', isSynced: false }, | ||||||
|     { name: 'autoCodeReadonlySize', value: '30000', isSynced: false }, |     { name: 'autoReadonlySizeCode', value: '30000', isSynced: false }, | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| function initStartupOptions() { | function initStartupOptions() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user