mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 09:56:36 +01:00 
			
		
		
		
	Fix corner case preventing notes from being created before ckeditor is initialized (#849)
* Pass deleteId to deleteBranch in ensureNoteIsAbsentFromParent * Add checks for whether window.cutToNote is defined. * check ckEditor initialized.
This commit is contained in:
		| @@ -635,7 +635,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { | |||||||
|         extraOptions.saveSelection = false; |         extraOptions.saveSelection = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (extraOptions.saveSelection) { |     if (extraOptions.saveSelection && utils.isCKEditorInitialized()) { | ||||||
|         [extraOptions.title, extraOptions.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml()); |         [extraOptions.title, extraOptions.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -648,7 +648,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { | |||||||
|         type: extraOptions.type |         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 anything |         // we remove the selection only after it was saved to server to make sure we don't lose anything | ||||||
|         window.cutToNote.removeSelection(); |         window.cutToNote.removeSelection(); | ||||||
|     } |     } | ||||||
| @@ -870,7 +870,7 @@ window.glob.cutIntoNote = () => createNoteInto(true); | |||||||
|  |  | ||||||
| keyboardActionService.setGlobalActionHandler('CutIntoNote', () => createNoteInto(true)); | keyboardActionService.setGlobalActionHandler('CutIntoNote', () => createNoteInto(true)); | ||||||
|  |  | ||||||
| keyboardActionService.setGlobalActionHandler('CreateNoteInto', createNoteInto); | keyboardActionService.setGlobalActionHandler('CreateNoteInto', () => createNoteInto(true)); | ||||||
|  |  | ||||||
| keyboardActionService.setGlobalActionHandler('ScrollToActiveNote', scrollToActiveNote); | keyboardActionService.setGlobalActionHandler('ScrollToActiveNote', scrollToActiveNote); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -248,6 +248,10 @@ function copySelectionToClipboard() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function isCKEditorInitialized() { | ||||||
|  |     return !!(window && window.cutToNote); | ||||||
|  | } | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|     reloadApp, |     reloadApp, | ||||||
|     parseDate, |     parseDate, | ||||||
| @@ -281,5 +285,6 @@ export default { | |||||||
|     clearBrowserCache, |     clearBrowserCache, | ||||||
|     getUrlForDownload, |     getUrlForDownload, | ||||||
|     normalizeShortcut, |     normalizeShortcut, | ||||||
|     copySelectionToClipboard |     copySelectionToClipboard, | ||||||
|  |     isCKEditorInitialized | ||||||
| }; | }; | ||||||
		Reference in New Issue
	
	Block a user