Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions resources/web/model_new/js/ckeditor_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,24 @@ const editorConfig = {
language: editorLanguage
};

script.onload = () => {
let editorsInitialized = false;
function initEditors() {
if (editorsInitialized) return;
editorsInitialized = true;
ClassicEditor.create(document.querySelector('#editor'), editorConfig).then( editor => {
window.projectEditor = editor;
});
ClassicEditor.create(document.querySelector('#profile-editor'), editorConfig).then( editor => {
window.profileEditor = editor;
});
};
}

// Initialise the editors once the translation file has loaded. If it fails to
// load (e.g. the resolved locale has no translation file such as "en-us", which
// happens when editor.html is opened without a ?lang= and the webview reports
// navigator.language as en-US), still initialise the editors so the description
// field is usable instead of leaving the page without an editor.
script.onload = initEditors;
script.onerror = initEditors;

document.head.appendChild(script);