Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
some fixes for CKEditor
azivner7b6ccab8944b
diff --git a/public/javascripts/dialogs/add_link.js b/public/javascripts/dialogs/add_link.jsindex 649cb14d51..fa9b57ce10 100644--- a/public/javascripts/dialogs/add_link.js+++ b/public/javascripts/dialogs/add_link.js@@ -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 isfocus: (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');-- noteDetailEl.summernote('createLink', {- text: linkTitle,- url: 'app#' + notePath,- isNewWindow: true- });+ const editor = noteEditor.getEditor();+ const doc = editor.document;++// 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;diff --git a/public/javascripts/init.js b/public/javascripts/init.jsindex da5d720521..d90efd4e2b 100644--- a/public/javascripts/init.js+++ b/public/javascripts/init.js@@ -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"));diff --git a/public/javascripts/link.js b/public/javascripts/link.jsindex 27e2c5fd14..61e157135c 100644--- a/public/javascripts/link.js+++ b/public/javascripts/link.js@@ -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,diff --git a/public/javascripts/note_editor.js b/public/javascripts/note_editor.jsindex 12898b38c1..ac84e07797 100644--- a/public/javascripts/note_editor.js+++ b/public/javascripts/note_editor.js@@ -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};})();\ No newline at end of file