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:
jasontan056 2020-02-02 16:28:19 +08:00 committed by GitHub
parent 7651c53363
commit adb8caa8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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 anything
window.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);

View File

@ -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
};