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
Fix corner case preventing notes from being created before ckeditor is initialized (#849)
jasontan056adb8caa8a272
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex c159fedc70..ef32c609d2 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -635,7 +635,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {extraOptions.saveSelection = false;}- if (extraOptions.saveSelection) {+ if (extraOptions.saveSelection && utils.isCKEditorInitialized()) {[extraOptions.title, extraOptions.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());}@@ -648,7 +648,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {type: extraOptions.type});- if (extraOptions.saveSelection) {+ if (extraOptions.saveSelection && utils.isCKEditorInitialized()) {// we remove the selection only after it was saved to server to make sure we don't lose anythingwindow.cutToNote.removeSelection();}@@ -870,7 +870,7 @@ window.glob.cutIntoNote = () => createNoteInto(true);keyboardActionService.setGlobalActionHandler('CutIntoNote', () => createNoteInto(true));-keyboardActionService.setGlobalActionHandler('CreateNoteInto', createNoteInto);+keyboardActionService.setGlobalActionHandler('CreateNoteInto', () => createNoteInto(true));keyboardActionService.setGlobalActionHandler('ScrollToActiveNote', scrollToActiveNote);diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.jsindex 2c6c0e9f1f..b4b51a0f98 100644--- a/src/public/javascripts/services/utils.js+++ b/src/public/javascripts/services/utils.js@@ -248,6 +248,10 @@ function copySelectionToClipboard() {}}+function isCKEditorInitialized() {+ return !!(window && window.cutToNote);+}+export default {reloadApp,parseDate,@@ -281,5 +285,6 @@ export default {clearBrowserCache,getUrlForDownload,normalizeShortcut,- copySelectionToClipboard+ copySelectionToClipboard,+ isCKEditorInitialized};\ No newline at end of file