From fdb8959aa193d61cd23cabea18510aaa4183ba4b Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 9 Dec 2019 20:06:36 +0100 Subject: [PATCH] move mime types loading to avoid race conditions --- .../javascripts/services/note_detail_text.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js index 8cb0f2c20..894f141e3 100644 --- a/src/public/javascripts/services/note_detail_text.js +++ b/src/public/javascripts/services/note_detail_text.js @@ -34,6 +34,16 @@ class NoteDetailText { if (!this.textEditor) { await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); + const codeBlockLanguages = + (await mimeTypesService.getMimeTypes()) + .filter(mt => mt.enabled) + .map(mt => { + return { + language: mt.mime.toLowerCase().replace(/[\W_]+/g,"-"), + label: mt.title + } + }); + // CKEditor since version 12 needs the element to be visible before initialization. At the same time // we want to avoid flicker - i.e. show editor only once everything is ready. That's why we have separate // display of $component in both branches. @@ -42,16 +52,6 @@ class NoteDetailText { // textEditor might have been initialized during previous await so checking again // looks like double initialization can freeze CKEditor pretty badly if (!this.textEditor) { - const codeBlockLanguages = - (await mimeTypesService.getMimeTypes()) - .filter(mt => mt.enabled) - .map(mt => { - return { - language: mt.mime.toLowerCase().replace(/[\W_]+/g,"-"), - label: mt.title - } - }); - this.textEditor = await BalloonEditor.create(this.$editorEl[0], { placeholder: "Type the content of your note here ...", mention: {