Skip to content

attaching editor to an element other than body: Init, setHtml, getHtml, initFromHtml, navigator/tree#415

Open
hayden-t wants to merge 8 commits intogivanz:masterfrom
hayden-t:patch-3
Open

attaching editor to an element other than body: Init, setHtml, getHtml, initFromHtml, navigator/tree#415
hayden-t wants to merge 8 commits intogivanz:masterfrom
hayden-t:patch-3

Conversation

@hayden-t
Copy link

@hayden-t hayden-t commented Oct 9, 2025

No description provided.

@hayden-t
Copy link
Author

hayden-t commented Dec 1, 2025

Ive just now found a problem with setHTML is that it wont execute inline js/script, which is often inserted as part of components, so that errors are thrown in the editor when trying to adjust slides, eg slider. It seems to get the script to execute you have to replace the whole iframe, so it really needs a seperate function or option to accept html code rather than url.

setHTML is originally used just for the code editor option, and now it seems doesnt really fit for being used to replace dom content during(just after) iframe load when there is scripts involved, im just looking into alternatives.

@hayden-t hayden-t changed the title allow targeting editor to an element other than body Dec 1, 2025
@hayden-t hayden-t changed the title allow targeting editor to an element other than body: Init, setHtml, getHtml Dec 4, 2025
@hayden-t
Copy link
Author

hayden-t commented Dec 4, 2025

ok so i worked out if a blob and bloburl is made of html and sent to the builder instead of iframe url it will execute inline html, so this is better/preferred method than setHtml if you need to supply builder contents this way. so i added new function

initFromHtml: function(html, callback, targetElement){
//creating the iframe content via full html as a blob allows inline js to execute
const blob = new Blob([html], { type: 'text/html' });
const blobUrl = URL.createObjectURL(blob);
this.init(blobUrl, callback, targetElement);
},

i forge this bit, its needed otherwise blob url is altered and wont load
@hayden-t hayden-t changed the title attaching editor to an element other than body: Init, setHtml, getHtml, initFromHtml Dec 11, 2025
and have tree created during iframe load too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant