mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	added readOnly attribute which puts text editor into readonly mode #371
This commit is contained in:
		@@ -107,6 +107,7 @@ function init() {
 | 
			
		||||
$(document).on('click', "a[data-action='note']", goToLink);
 | 
			
		||||
$(document).on('click', 'div.popover-content a, div.ui-tooltip-content a', goToLink);
 | 
			
		||||
$(document).on('dblclick', '#note-detail-text a', goToLink);
 | 
			
		||||
$(document).on('click', '#note-detail-text.ck-read-only a', goToLink);
 | 
			
		||||
$(document).on('click', 'span.ck-button__label', e => {
 | 
			
		||||
    // this is a link preview dialog from CKEditor link editing
 | 
			
		||||
    // for some reason clicked element is span
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
import libraryLoader from "./library_loader.js";
 | 
			
		||||
import noteDetailService from './note_detail.js';
 | 
			
		||||
import treeService from './tree.js';
 | 
			
		||||
import attributeService from "./attributes.js";
 | 
			
		||||
 | 
			
		||||
const $component = $('#note-detail-text');
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +20,8 @@ async function show() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    textEditor.isReadOnly = await isReadOnly();
 | 
			
		||||
 | 
			
		||||
    textEditor.setData(noteDetailService.getCurrentNote().content);
 | 
			
		||||
 | 
			
		||||
    $component.show();
 | 
			
		||||
@@ -36,6 +39,12 @@ function getContent() {
 | 
			
		||||
    return content;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function isReadOnly() {
 | 
			
		||||
    const attributes = await attributeService.getAttributes();
 | 
			
		||||
 | 
			
		||||
    return attributes.some(attr => attr.type === 'label' && attr.name === 'readOnly');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function focus() {
 | 
			
		||||
    $component.focus();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								src/public/libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/public/libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -17,6 +17,7 @@ const BUILTIN_ATTRIBUTES = [
 | 
			
		||||
    { type: 'label', name: 'appCss' },
 | 
			
		||||
    { type: 'label', name: 'hideChildrenOverview' },
 | 
			
		||||
    { type: 'label', name: 'hidePromotedAttributes' },
 | 
			
		||||
    { type: 'label', name: 'readOnly' },
 | 
			
		||||
 | 
			
		||||
    // relation names
 | 
			
		||||
    { type: 'relation', name: 'runOnNoteView' },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user