From c85db3b3e126af0763e10024b8d5b0249814e2bf Mon Sep 17 00:00:00 2001 From: barrulus Date: Sun, 17 Aug 2025 19:32:27 +0100 Subject: [PATCH] Fix TinyMCE loading to use script element instead of dynamic import Replace dynamic import() with traditional script loading for TinyMCE editor to resolve module loading issues. Adds loadScript helper function that creates script elements and handles onload/onerror events properly. --- modules/ui/notes-editor.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ui/notes-editor.js b/modules/ui/notes-editor.js index 10f87e16..215c2c20 100644 --- a/modules/ui/notes-editor.js +++ b/modules/ui/notes-editor.js @@ -67,18 +67,28 @@ function editNotes(id, name) { if (!window.tinymce) { const url = "https://azgaar.github.io/Fantasy-Map-Generator/libs/tinymce/tinymce.min.js"; try { - await import(url); + await loadScript(url); } catch (error) { // error may be caused by failed request being cached, try again with random hash try { const hash = Math.random().toString(36).substring(2, 15); - await import(`${url}#${hash}`); + await loadScript(`${url}#${hash}`); } catch (error) { console.error(error); } } } + function loadScript(src) { + return new Promise((resolve, reject) => { + const script = document.createElement('script'); + script.src = src; + script.onload = resolve; + script.onerror = reject; + document.head.appendChild(script); + }); + } + if (window.tinymce) { window.tinymce._setBaseUrl("https://azgaar.github.io/Fantasy-Map-Generator/libs/tinymce"); tinymce.init({