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() { | async function handleProtectedSession() { | ||||||
|     await protectedSessionService.ensureProtectedSession(currentNote.isProtected, false); |     const newSessionCreated = await protectedSessionService.ensureProtectedSession(currentNote.isProtected, false); | ||||||
|  |  | ||||||
|     if (currentNote.isProtected) { |     if (currentNote.isProtected) { | ||||||
|         protectedSessionHolder.touchProtectedSession(); |         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 |     // 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. |     // 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(); |     protectedSessionService.ensureDialogIsClosed(); | ||||||
|  |  | ||||||
|  |     return newSessionCreated; | ||||||
| } | } | ||||||
|  |  | ||||||
| async function loadNoteDetail(noteId) { | async function loadNoteDetail(noteId) { | ||||||
| @@ -168,7 +170,11 @@ async function loadNoteDetail(noteId) { | |||||||
|  |  | ||||||
|         $noteDetailComponents.hide(); |         $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(); |         await getComponent(currentNote.type).show(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,9 +9,13 @@ async function show() { | |||||||
|     if (!textEditor) { |     if (!textEditor) { | ||||||
|         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); |         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); | ||||||
|  |  | ||||||
|         textEditor = await BalloonEditor.create($noteDetailText[0], {}); |         // 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.model.document.on('change:data', noteDetailService.noteChanged); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     textEditor.setData(noteDetailService.getCurrentNote().content); |     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) { | function ensureProtectedSession(requireProtectedSession, modal) { | ||||||
|     const dfd = $.Deferred(); |     const dfd = $.Deferred(); | ||||||
|  |  | ||||||
| @@ -53,7 +54,7 @@ function ensureProtectedSession(requireProtectedSession, modal) { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|         dfd.resolve(); |         dfd.resolve(false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return dfd.promise(); |     return dfd.promise(); | ||||||
| @@ -82,7 +83,7 @@ async function setupProtectedSession() { | |||||||
|  |  | ||||||
|         $noteDetailWrapper.show(); |         $noteDetailWrapper.show(); | ||||||
|  |  | ||||||
|         protectedSessionDeferred.resolve(); |         protectedSessionDeferred.resolve(true); | ||||||
|         protectedSessionDeferred = null; |         protectedSessionDeferred = null; | ||||||
|  |  | ||||||
|         $protectedSessionOnButton.addClass('active'); |         $protectedSessionOnButton.addClass('active'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user