#326 unpositioned extension button in wrong place

This commit is contained in:
agriyadev5
2021-07-23 12:46:55 +05:30
parent 83632b65d9
commit 3bce54b3db
7 changed files with 80 additions and 36 deletions

View File

@@ -1375,6 +1375,22 @@ export const mock = ({
getRotationAngle = getRotationAngleUser;
};
export const stringToHTML = (str) => {
const parser = new DOMParser();
const doc = parser.parseFromString(str, 'text/html');
return doc.body.firstChild;
};
export const insertChildAtIndex = function(parent, child, index) {
const doc = stringToHTML(child);
if (!index) index = 0;
if (index >= parent.children.length) {
parent.appendChild(doc);
} else {
parent.insertBefore(doc, parent.children[index]);
}
};
// shortcuts to common DOM functions
export const $id = (id) => document.getElementById(id);
export const $qq = (sel) => document.querySelector(sel);