mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	small refactorings of auto readonly size
This commit is contained in:
		
							parent
							
								
									b85cf07a28
								
							
						
					
					
						commit
						9c9a3fc030
					
				@ -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']);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,8 +43,8 @@ const ALLOWED_OPTIONS = new Set([
 | 
			
		||||
    'similarNotesExpanded',
 | 
			
		||||
    'headingStyle',
 | 
			
		||||
    'autoCollapseNoteTree',
 | 
			
		||||
    'autoReadonlySize',
 | 
			
		||||
    'autoCodeReadonlySize'
 | 
			
		||||
    'autoReadonlySizeText',
 | 
			
		||||
    'autoReadonlySizeCode'
 | 
			
		||||
]);
 | 
			
		||||
 | 
			
		||||
function getOptions() {
 | 
			
		||||
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user