mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fix for protected note freezing because of double initialization of CKEditor
This commit is contained in:
		| @@ -132,7 +132,7 @@ function newNoteCreated() { | ||||
| } | ||||
|  | ||||
| async function handleProtectedSession() { | ||||
|     await protectedSessionService.ensureProtectedSession(currentNote.isProtected, false); | ||||
|     const newSessionCreated = await protectedSessionService.ensureProtectedSession(currentNote.isProtected, false); | ||||
|  | ||||
|     if (currentNote.isProtected) { | ||||
|         protectedSessionHolder.touchProtectedSession(); | ||||
| @@ -141,6 +141,8 @@ async function handleProtectedSession() { | ||||
|     // this might be important if we focused on protected note when not in protected note and we got a dialog | ||||
|     // to login, but we chose instead to come to another node - at that point the dialog is still visible and this will close it. | ||||
|     protectedSessionService.ensureDialogIsClosed(); | ||||
|  | ||||
|     return newSessionCreated; | ||||
| } | ||||
|  | ||||
| async function loadNoteDetail(noteId) { | ||||
| @@ -168,7 +170,11 @@ async function loadNoteDetail(noteId) { | ||||
|  | ||||
|         $noteDetailComponents.hide(); | ||||
|  | ||||
|         await handleProtectedSession(); | ||||
|         const newSessionCreated = await handleProtectedSession(); | ||||
|         if (newSessionCreated) { | ||||
|             // in such case we're reloading note anyway so no need to continue here. | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         await getComponent(currentNote.type).show(); | ||||
|     } | ||||
|   | ||||
| @@ -9,10 +9,14 @@ async function show() { | ||||
|     if (!textEditor) { | ||||
|         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); | ||||
|  | ||||
|         // textEditor might have been initialized during previous await so checking again | ||||
|         // looks like double initialization can freeze CKEditor pretty badly | ||||
|         if (!textEditor) { | ||||
|             textEditor = await BalloonEditor.create($noteDetailText[0], {}); | ||||
|  | ||||
|             textEditor.model.document.on('change:data', noteDetailService.noteChanged); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     textEditor.setData(noteDetailService.getCurrentNote().content); | ||||
|  | ||||
|   | ||||
| @@ -28,6 +28,7 @@ async function leaveProtectedSession() { | ||||
|     } | ||||
| } | ||||
|  | ||||
| /** returned promise resolves with true if new protected session was established, false if no action was necessary */ | ||||
| function ensureProtectedSession(requireProtectedSession, modal) { | ||||
|     const dfd = $.Deferred(); | ||||
|  | ||||
| @@ -53,7 +54,7 @@ function ensureProtectedSession(requireProtectedSession, modal) { | ||||
|         }); | ||||
|     } | ||||
|     else { | ||||
|         dfd.resolve(); | ||||
|         dfd.resolve(false); | ||||
|     } | ||||
|  | ||||
|     return dfd.promise(); | ||||
| @@ -82,7 +83,7 @@ async function setupProtectedSession() { | ||||
|  | ||||
|         $noteDetailWrapper.show(); | ||||
|  | ||||
|         protectedSessionDeferred.resolve(); | ||||
|         protectedSessionDeferred.resolve(true); | ||||
|         protectedSessionDeferred = null; | ||||
|  | ||||
|         $protectedSessionOnButton.addClass('active'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user