allow to give a div other than the default one (with id=svg_editor)

This commit is contained in:
JFH
2021-08-02 00:12:20 +02:00
parent 8644836f4e
commit 5435ab9a59
6 changed files with 13 additions and 28 deletions

View File

@@ -50,10 +50,10 @@ class EditorStartup {
/**
*
*/
constructor () {
constructor (div) {
this.extensionsAdded = false;
this.messageQueue = [];
this.$svgEditor = $id('svg_editor');
this.$svgEditor = div??$id('svg_editor');
}
/**
* Auto-run after a Promise microtask.
@@ -365,7 +365,7 @@ class EditorStartup {
inp.blur();
};
const liElems = document.getElementById('svg_editor').querySelectorAll('button, select, input:not(#text)');
const liElems = this.$svgEditor.querySelectorAll('button, select, input:not(#text)');
Array.prototype.forEach.call(liElems, function(el){
el.addEventListener("focus", (e) => {
inp = e.currentTarget;