#326 unpositioned extension button in wrong place
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user