mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
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.
This commit is contained in:
parent
11977a42fc
commit
c85db3b3e1
1 changed files with 12 additions and 2 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue