mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	some fixes for CKEditor
This commit is contained in:
		
							parent
							
								
									a85bb649cb
								
							
						
					
					
						commit
						7b6ccab894
					
				@ -10,8 +10,6 @@ const addLink = (function() {
 | 
			
		||||
    function showDialog() {
 | 
			
		||||
        glob.activeDialog = dialogEl;
 | 
			
		||||
 | 
			
		||||
        noteDetailEl.summernote('editor.saveRange');
 | 
			
		||||
 | 
			
		||||
        dialogEl.dialog({
 | 
			
		||||
            modal: true,
 | 
			
		||||
            width: 500
 | 
			
		||||
@ -21,7 +19,7 @@ const addLink = (function() {
 | 
			
		||||
        linkTitleEl.val('');
 | 
			
		||||
 | 
			
		||||
        function setDefaultLinkTitle(noteId) {
 | 
			
		||||
            const noteTitle = treeUtils.getNoteTitle(noteId);
 | 
			
		||||
            const noteTitle = noteTree.getNoteTitle(noteId);
 | 
			
		||||
 | 
			
		||||
            linkTitleEl.val(noteTitle);
 | 
			
		||||
        }
 | 
			
		||||
@ -31,7 +29,8 @@ const addLink = (function() {
 | 
			
		||||
            minLength: 0,
 | 
			
		||||
            change: () => {
 | 
			
		||||
                const val = autoCompleteEl.val();
 | 
			
		||||
                const noteId = link.getNodePathFromLabel(val);
 | 
			
		||||
                const notePath = link.getNodePathFromLabel(val);
 | 
			
		||||
                const noteId = treeUtils.getNoteIdFromNotePath(notePath);
 | 
			
		||||
 | 
			
		||||
                if (noteId) {
 | 
			
		||||
                    setDefaultLinkTitle(noteId);
 | 
			
		||||
@ -40,7 +39,8 @@ const addLink = (function() {
 | 
			
		||||
            // this is called when user goes through autocomplete list with keyboard
 | 
			
		||||
            // at this point the item isn't selected yet so we use supplied ui.item to see WHERE the cursor is
 | 
			
		||||
            focus: (event, ui) => {
 | 
			
		||||
                const noteId = link.getNodePathFromLabel(ui.item.value);
 | 
			
		||||
                const notePath = link.getNodePathFromLabel(ui.item.value);
 | 
			
		||||
                const noteId = treeUtils.getNoteIdFromNotePath(notePath);
 | 
			
		||||
 | 
			
		||||
                setDefaultLinkTitle(noteId);
 | 
			
		||||
            }
 | 
			
		||||
@ -57,13 +57,22 @@ const addLink = (function() {
 | 
			
		||||
 | 
			
		||||
            dialogEl.dialog("close");
 | 
			
		||||
 | 
			
		||||
            noteDetailEl.summernote('editor.restoreRange');
 | 
			
		||||
            const editor = noteEditor.getEditor();
 | 
			
		||||
            const doc = editor.document;
 | 
			
		||||
 | 
			
		||||
            noteDetailEl.summernote('createLink', {
 | 
			
		||||
                text: linkTitle,
 | 
			
		||||
                url: 'app#' + notePath,
 | 
			
		||||
                isNewWindow: true
 | 
			
		||||
            });
 | 
			
		||||
//             doc.enqueueChanges( () => {
 | 
			
		||||
// //                const link = '<a href="#' + notePath + '" target="_blank">' + linkTitle + '</a>';
 | 
			
		||||
//
 | 
			
		||||
//                 editor.data.insertContent({
 | 
			
		||||
//                     linkHref: '#' + notePath
 | 
			
		||||
//                 }, doc.selection);
 | 
			
		||||
//             } );
 | 
			
		||||
 | 
			
		||||
            // noteDetailEl.summernote('createLink', {
 | 
			
		||||
            //     text: linkTitle,
 | 
			
		||||
            //     url: 'app#' + notePath,
 | 
			
		||||
            //     isNewWindow: true
 | 
			
		||||
            // });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
@ -82,7 +82,7 @@ $.ui.autocomplete.filter = (array, terms) => {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$(document).tooltip({
 | 
			
		||||
    items: ".note-editable a",
 | 
			
		||||
    items: "#note-detail a",
 | 
			
		||||
    content: function(callback) {
 | 
			
		||||
        const noteId = link.getNotePathFromLink($(this).attr("href"));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -67,7 +67,7 @@ const link = (function() {
 | 
			
		||||
    // of opening the link in new window/tab
 | 
			
		||||
    $(document).on('click', "a[action='note']", goToInternalNote);
 | 
			
		||||
    $(document).on('click', 'div.popover-content a, div.ui-tooltip-content', goToInternalNote);
 | 
			
		||||
    $(document).on('dblclick', '.note-editable a, div.ui-tooltip-content', goToInternalNote);
 | 
			
		||||
    $(document).on('dblclick', '#note-detail a, div.ui-tooltip-content', goToInternalNote);
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        getNodePathFromLabel,
 | 
			
		||||
 | 
			
		||||
@ -82,12 +82,12 @@ const noteEditor = (function() {
 | 
			
		||||
 | 
			
		||||
    function setNoteBackgroundIfProtected(note) {
 | 
			
		||||
        if (note.detail.is_protected) {
 | 
			
		||||
            $(".note-editable").addClass("protected");
 | 
			
		||||
            $("#note-detail").addClass("protected");
 | 
			
		||||
            protectButton.hide();
 | 
			
		||||
            unprotectButton.show();
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            $(".note-editable").removeClass("protected");
 | 
			
		||||
            $("#note-detail").removeClass("protected");
 | 
			
		||||
            protectButton.show();
 | 
			
		||||
            unprotectButton.hide();
 | 
			
		||||
        }
 | 
			
		||||
@ -126,9 +126,6 @@ const noteEditor = (function() {
 | 
			
		||||
 | 
			
		||||
        noteTitleEl.val(currentNote.detail.note_title);
 | 
			
		||||
 | 
			
		||||
        // Clear contents and remove all stored history. This is to prevent undo from going across notes
 | 
			
		||||
        //noteDetailEl.summernote('reset');
 | 
			
		||||
 | 
			
		||||
        editor.setData(currentNote.detail.note_text);
 | 
			
		||||
 | 
			
		||||
        noteChangeDisabled = false;
 | 
			
		||||
@ -142,6 +139,10 @@ const noteEditor = (function() {
 | 
			
		||||
        return await server.get('notes/' + noteId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function getEditor() {
 | 
			
		||||
        return editor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $(document).ready(() => {
 | 
			
		||||
        noteTitleEl.on('input', () => {
 | 
			
		||||
            noteChanged();
 | 
			
		||||
@ -179,6 +180,7 @@ const noteEditor = (function() {
 | 
			
		||||
        loadNote,
 | 
			
		||||
        getCurrentNote,
 | 
			
		||||
        getCurrentNoteId,
 | 
			
		||||
        newNoteCreated
 | 
			
		||||
        newNoteCreated,
 | 
			
		||||
        getEditor
 | 
			
		||||
    };
 | 
			
		||||
})();
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user