#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

@@ -70,7 +70,7 @@ import {
preventClickDefault, walkTree, getBBoxOfElementAsPath, convertToPath, encode64, decode64,
getVisibleElements, dropXMLInternalSubset, init as utilsInit,
getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible, isNullish, blankPageObjectURL,
$id, $qa, $qq, getFeGaussianBlur
$id, $qa, $qq, getFeGaussianBlur, stringToHTML, insertChildAtIndex
} from './utilities.js';
import {
transformPoint, matrixMultiply, hasMatrixTransform, transformListToTransform,
@@ -188,6 +188,8 @@ class SvgCanvas {
this.$id = $id;
this.$qq = $qq;
this.$qa = $qa;
this.stringToHTML = stringToHTML;
this.insertChildAtIndex = insertChildAtIndex;
this.getClosest = getClosest;
this.getParents = getParents;
/** A storage solution aimed at replacing jQuerys data function.

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);