commit toward svgcanvas/svgedit isolation

master
JFH 2020-12-25 11:38:43 +01:00
parent 797e021dba
commit 9bf5f559bb
27 changed files with 110 additions and 103 deletions

View File

@ -2,7 +2,17 @@
// eslint-disable-next-line node/no-unpublished-import
import deparam from 'deparam';
import * as Utils from '../common/utilities.js';
/**
* Escapes special characters in a regular expression.
* @function regexEscape
* @param {string} str
* @returns {string}
*/
export const regexEscape = function (str) {
// Originally from: http://phpjs.org/functions
return String(str).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g, '\\$&');
};
/**
* @class configObj
*/
@ -345,7 +355,7 @@ export default class ConfigObj {
this.defaultPrefs[key] = window.widget.preferenceForKey(storeKey);
} else {
const result = document.cookie.match(
new RegExp('(?:^|;\\s*)' + Utils.regexEscape(
new RegExp('(?:^|;\\s*)' + regexEscape(
encodeURIComponent(storeKey)
) + '=([^;]+)')
);

View File

@ -18,10 +18,6 @@
import './touch.js';
import {isChrome, isGecko, isMac} from '../common/browser.js';
// Until we split this into smaller files, this helps distinguish utilities
// from local methods
import * as Utils from '../common/utilities.js';
import {getTypeMap, convertUnit, isValidUnit} from '../common/units.js';
import {
hasCustomHandler, getCustomHandler, injectExtendedContextMenuItemsIntoDom
@ -41,7 +37,7 @@ import {
setStrings
} from './locale.js';
const {$qq, $id} = Utils;
const {$id, $qa, isNullish, encode64, decode64, blankPageObjectURL} = SvgCanvas;
const editor = {
/**
@ -367,7 +363,7 @@ editor.init = () => {
const updateContextPanel = () => {
let elem = selectedElement;
// If element has just been deleted, consider it null
if (!Utils.isNullish(elem) && !elem.parentNode) { elem = null; }
if (!isNullish(elem) && !elem.parentNode) { elem = null; }
const currentLayerName = svgCanvas.getCurrentDrawing().getCurrentLayerName();
const currentMode = svgCanvas.getMode();
const unit = configObj.curConfig.baseUnit !== 'px' ? configObj.curConfig.baseUnit : null;
@ -377,7 +373,7 @@ editor.init = () => {
$('#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,' +
'#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel,' +
' #use_panel, #a_panel').hide();
if (!Utils.isNullish(elem)) {
if (!isNullish(elem)) {
const elname = elem.nodeName;
// If this is a link with no transform and one child, pretend
// its child is selected
@ -557,7 +553,7 @@ editor.init = () => {
menuItems.setAttribute((tagName === 'g' ? 'en' : 'dis') + 'ablemenuitems', '#ungroup');
menuItems.setAttribute(((tagName === 'g' || !multiselected) ? 'dis' : 'en') + 'ablemenuitems', '#group');
// if (!Utils.isNullish(elem))
// if (!isNullish(elem))
} else if (multiselected) {
$('#multiselected_panel').show();
menuItems.setAttribute('enablemenuitems', '#group');
@ -695,7 +691,7 @@ editor.init = () => {
// Since saving SVGs by opening a new window was removed in Chrome use artificial link-click
// https://stackoverflow.com/questions/45603201/window-is-not-allowed-to-navigate-top-frame-navigations-to-data-urls
const a = document.createElement('a');
a.href = 'data:image/svg+xml;base64,' + Utils.encode64(svg);
a.href = 'data:image/svg+xml;base64,' + encode64(svg);
a.download = 'icon.svg';
a.style.display = 'none';
document.body.append(a); // Need to append for Firefox
@ -736,7 +732,7 @@ editor.init = () => {
const exportHandler = function (win, data) {
const {issues, exportWindowName} = data;
exportWindow = window.open(Utils.blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
if (!exportWindow || exportWindow.closed) {
/* await */ $.alert(uiStrings.notification.popupWindowBlocked);
@ -790,7 +786,7 @@ editor.init = () => {
const updateLeftPanel = (button) => {
if (button.disabled) return false;
// remove the pressed state on other(s) button(s)
$qq('#tools_left *[pressed]').forEach((b) => { b.pressed = false; });
$qa('#tools_left *[pressed]').forEach((b) => { b.pressed = false; });
// pressed state for the clicked button
$id(button).pressed = true;
return true;
@ -1178,7 +1174,7 @@ editor.init = () => {
*/
const updateToolbar = () => {
let i, len;
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
switch (selectedElement.tagName) {
case 'use':
case 'image':
@ -1224,7 +1220,7 @@ editor.init = () => {
}
// All elements including image and group have opacity
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
const opacPerc = (selectedElement.getAttribute('opacity') || 1.0) * 100;
$('#group_opacity').val(opacPerc);
$('#opac_slider').slider('option', 'value', opacPerc);
@ -1281,11 +1277,11 @@ editor.init = () => {
}
const isNode = mode === 'pathedit';
// if elems[1] is present, then we have more than one element
selectedElement = (elems.length === 1 || Utils.isNullish(elems[1]) ? elems[0] : null);
multiselected = (elems.length >= 2 && !Utils.isNullish(elems[1]));
if (!Utils.isNullish(selectedElement) && !isNode) {
selectedElement = (elems.length === 1 || isNullish(elems[1]) ? elems[0] : null);
multiselected = (elems.length >= 2 && !isNullish(elems[1]));
if (!isNullish(selectedElement) && !isNode) {
updateToolbar();
} // if (!Utils.isNullish(elem))
} // if (!isNullish(elem))
// Deal with pathedit mode
togglePathEditMode(isNode, elems);
@ -1314,7 +1310,7 @@ editor.init = () => {
return;
}
multiselected = (elems.length >= 2 && !Utils.isNullish(elems[1]));
multiselected = (elems.length >= 2 && !isNullish(elems[1]));
// Only updating fields for single elements for now
if (!multiselected) {
switch (mode) {
@ -1361,7 +1357,7 @@ editor.init = () => {
}
// Update selectedElement if element is no longer part of the image.
// This occurs for the text elements in Firefox
} else if (elem && selectedElement && Utils.isNullish(selectedElement.parentNode)) {
} else if (elem && selectedElement && isNullish(selectedElement.parentNode)) {
// || elem && elem.tagName == "path" && !multiselected) { // This was added in r1430, but not sure why
selectedElement = elem;
}
@ -1747,7 +1743,7 @@ editor.init = () => {
* @returns {void}
*/
const changeOpacity = function (ctl, val) {
if (Utils.isNullish(val)) { val = ctl.value; }
if (isNullish(val)) { val = ctl.value; }
$('#group_opacity').val(val);
if (!ctl || !ctl.handle) {
$('#opac_slider').slider('option', 'value', val);
@ -2319,7 +2315,7 @@ editor.init = () => {
* @returns {void}
*/
const deleteSelected = () => {
if (!Utils.isNullish(selectedElement) || multiselected) {
if (!isNullish(selectedElement) || multiselected) {
svgCanvas.deleteSelectedElements();
}
};
@ -2329,7 +2325,7 @@ editor.init = () => {
* @returns {void}
*/
const cutSelected = () => {
if (!Utils.isNullish(selectedElement) || multiselected) {
if (!isNullish(selectedElement) || multiselected) {
svgCanvas.cutSelectedElements();
}
};
@ -2339,7 +2335,7 @@ editor.init = () => {
* @returns {void}
*/
const copySelected = () => {
if (!Utils.isNullish(selectedElement) || multiselected) {
if (!isNullish(selectedElement) || multiselected) {
svgCanvas.copySelectedElements();
}
};
@ -2360,7 +2356,7 @@ editor.init = () => {
* @returns {void}
*/
const moveToTopSelected = () => {
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
svgCanvas.moveToTopSelectedElement();
}
};
@ -2370,7 +2366,7 @@ editor.init = () => {
* @returns {void}
*/
const moveToBottomSelected = () => {
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
svgCanvas.moveToBottomSelectedElement();
}
};
@ -2380,7 +2376,7 @@ editor.init = () => {
* @returns {void}
*/
const moveUpDownSelected = function (dir) {
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
svgCanvas.moveUpDownSelected(dir);
}
};
@ -2390,7 +2386,7 @@ editor.init = () => {
* @returns {void}
*/
const convertToPath = () => {
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
svgCanvas.convertToPath();
}
};
@ -2400,7 +2396,7 @@ editor.init = () => {
* @returns {void}
*/
const reorientPath = () => {
if (!Utils.isNullish(selectedElement)) {
if (!isNullish(selectedElement)) {
path.reorient();
}
};
@ -2410,7 +2406,7 @@ editor.init = () => {
* @returns {Promise<void>} Resolves to `undefined`
*/
const makeHyperlink = async () => {
if (!Utils.isNullish(selectedElement) || multiselected) {
if (!isNullish(selectedElement) || multiselected) {
const url = await $.prompt(uiStrings.notification.enterNewLinkURL, 'http://');
if (url) {
svgCanvas.makeHyperlink(url);
@ -2424,7 +2420,7 @@ editor.init = () => {
* @returns {void}
*/
const moveSelected = function (dx, dy) {
if (!Utils.isNullish(selectedElement) || multiselected) {
if (!isNullish(selectedElement) || multiselected) {
if (configObj.curConfig.gridSnapping) {
// Use grid snap value regardless of zoom level
const multi = svgCanvas.getZoom() * configObj.curConfig.snappingStep;
@ -2507,7 +2503,7 @@ editor.init = () => {
* @returns {void}
*/
const rotateSelected = function (cw, step) {
if (Utils.isNullish(selectedElement) || multiselected) { return; }
if (isNullish(selectedElement) || multiselected) { return; }
if (!cw) { step *= -1; }
const angle = Number.parseFloat($('#angle').val()) + step;
svgCanvas.setRotationAngle(angle);
@ -2634,7 +2630,7 @@ editor.init = () => {
const blob = new Blob([popHTML], {type: 'text/html'});
popURL = URL.createObjectURL(blob);
} else {
popURL = 'data:text/html;base64;charset=utf-8,' + Utils.encode64(popHTML);
popURL = 'data:text/html;base64;charset=utf-8,' + encode64(popHTML);
}
loadingURL = popURL;
}
@ -3918,7 +3914,7 @@ editor.loadFromDataURI = function (str, {noAlert} = {}) {
pre = pre[0];
}
const src = str.slice(pre.length);
return loadSvgString(base64 ? Utils.decode64(src) : decodeURIComponent(src), {noAlert});
return loadSvgString(base64 ? decode64(src) : decodeURIComponent(src), {noAlert});
});
};

View File

@ -7,11 +7,11 @@
import {
snapToGrid, assignAttributes, getBBox, getRefElem, findDefs
} from '../common/utilities.js';
} from './utilities.js';
import {
transformPoint, transformListToTransform, matrixMultiply, transformBox
} from '../common/math.js';
import {getTransformList} from '../common/svgtransformlist.js';
} from './math.js';
import {getTransformList} from './svgtransformlist.js';
const $ = jQuery;

View File

@ -3,7 +3,7 @@
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {isWebkit} from '../common/browser.js';
import {convertPath} from './path.js';
import {preventClickDefault} from '../common/utilities.js';
import {preventClickDefault} from './utilities.js';
// Constants
const $ = jQueryPluginSVG(jQuery);

View File

@ -13,7 +13,7 @@ import {NS} from '../common/namespaces.js';
import {isOpera} from '../common/browser.js';
import {
toXml, getElem
} from '../common/utilities.js';
} from './utilities.js';
import {
copyElem as utilCopyElem
} from './copy-elem.js';

View File

@ -11,7 +11,7 @@ import {NS} from '../common/namespaces.js';
import {
getVisibleElements, getStrokedBBoxDefaultVisible, findDefs,
walkTree, isNullish, getHref, setHref, getElem
} from '../common/utilities.js';
} from './utilities.js';
import {
convertToNum
} from '../common/units.js';

View File

@ -9,16 +9,16 @@ import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attrib
import {
assignAttributes, cleanupElement, getElem, getRotationAngle, snapToGrid, walkTree,
getBBox as utilsGetBBox, isNullish, preventClickDefault, setHref
} from '../common/utilities.js';
} from './utilities.js';
import {
convertAttrs
} from '../common/units.js';
import {
transformPoint, hasMatrixTransform, getMatrix, snapToAngle
} from '../common/math.js';
} from './math.js';
import {
getTransformList
} from '../common/svgtransformlist.js';
} from './svgtransformlist.js';
import {
supportsNonScalingStroke, isWebkit
} from '../common/browser.js';

View File

@ -6,8 +6,8 @@
* @copyright 2010 Jeff Schiller
*/
import {getHref, setHref, getRotationAngle, isNullish} from '../common/utilities.js';
import {removeElementFromListMap} from '../common/svgtransformlist.js';
import {getHref, setHref, getRotationAngle, isNullish} from './utilities.js';
import {removeElementFromListMap} from './svgtransformlist.js';
/**
* Group: Undo/Redo history management.

View File

@ -5,7 +5,7 @@
*
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/
import {getElem, assignAttributes, cleanupElement} from '../common/utilities.js';
import {getElem, assignAttributes, cleanupElement} from './utilities.js';
import {NS} from '../common/namespaces.js';
let jsonContext_ = null;

View File

@ -8,7 +8,7 @@
*/
import {NS} from '../common/namespaces.js';
import {toXml, walkTree, isNullish} from '../common/utilities.js';
import {toXml, walkTree, isNullish} from './utilities.js';
const $ = jQuery;

View File

@ -19,7 +19,7 @@
* @property {Float} y
*/
import {NS} from './namespaces.js';
import {NS} from '../common/namespaces.js';
import {getTransformList} from './svgtransformlist.js';
// Constants

View File

@ -3,7 +3,7 @@
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {
getStrokedBBoxDefaultVisible
} from '../common/utilities.js';
} from './utilities.js';
import * as hstry from './history.js';
// Constants
const $ = jQueryPluginSVG(jQuery);

View File

@ -9,16 +9,16 @@
import {NS} from '../common/namespaces.js';
import {shortFloat} from '../common/units.js';
import {getTransformList} from '../common/svgtransformlist.js';
import {getTransformList} from './svgtransformlist.js';
import {ChangeElementCommand, BatchCommand} from './history.js';
import {
transformPoint, snapToAngle, rectsIntersect,
transformListToTransform
} from '../common/math.js';
} from './math.js';
import {
assignAttributes, getElem, getRotationAngle, snapToGrid, isNullish,
getBBox as utilsGetBBox
} from '../common/utilities.js';
} from './utilities.js';
import {
isWebkit
} from '../common/browser.js';

View File

@ -11,11 +11,11 @@ import {NS} from '../common/namespaces.js';
import {ChangeElementCommand} from './history.js';
import {
transformPoint, getMatrix
} from '../common/math.js';
} from './math.js';
import {
assignAttributes, getRotationAngle, isNullish,
getElem
} from '../common/utilities.js';
} from './utilities.js';
import {
supportsPathInsertItemBefore, supportsPathReplaceItem, isWebkit
} from '../common/browser.js';

View File

@ -7,14 +7,14 @@
* @copyright 2011 Alexis Deveria, 2011 Jeff Schiller
*/
import {getTransformList} from '../common/svgtransformlist.js';
import {getTransformList} from './svgtransformlist.js';
import {shortFloat} from '../common/units.js';
import {transformPoint} from '../common/math.js';
import {transformPoint} from './math.js';
import {
getRotationAngle, getBBox,
getRefElem, findDefs, isNullish,
getBBox as utilsGetBBox
} from '../common/utilities.js';
} from './utilities.js';
import {
init as pathMethodInit, insertItemBeforeMethod, ptObjToArrMethod, getGripPtMethod,
getPointFromGripMethod, addPointGripMethod, getGripContainerMethod, addCtrlGripMethod,

View File

@ -9,14 +9,14 @@ import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attrib
import {NS} from '../common/namespaces.js';
import {convertToNum} from '../common/units.js';
import {isWebkit} from '../common/browser.js';
import {getTransformList} from '../common/svgtransformlist.js';
import {getRotationAngle, getHref, getBBox, getRefElem, isNullish} from '../common/utilities.js';
import {getTransformList} from './svgtransformlist.js';
import {getRotationAngle, getHref, getBBox, getRefElem, isNullish} from './utilities.js';
import {BatchCommand, ChangeElementCommand} from './history.js';
import {remapElement} from './coords.js';
import {
isIdentity, matrixMultiply, transformPoint, transformListToTransform,
hasMatrixTransform
} from '../common/math.js';
} from './math.js';
const $ = jQueryPluginSVG(jQuery);

View File

@ -8,7 +8,7 @@
import {getReverseNS, NS} from '../common/namespaces.js';
import {isGecko} from '../common/browser.js';
import {getHref, setHref, getUrlFromAttr} from '../common/utilities.js';
import {getHref, setHref, getUrlFromAttr} from './utilities.js';
const REVERSE_NS = getReverseNS();

View File

@ -8,9 +8,9 @@
*/
import {isTouch, isWebkit} from '../common/browser.js'; // , isOpera
import {getRotationAngle, getBBox, getStrokedBBox, isNullish} from '../common/utilities.js';
import {transformListToTransform, transformBox, transformPoint} from '../common/math.js';
import {getTransformList} from '../common/svgtransformlist.js';
import {getRotationAngle, getBBox, getStrokedBBox, isNullish} from './utilities.js';
import {transformListToTransform, transformBox, transformPoint} from './math.js';
import {getTransformList} from './svgtransformlist.js';
const $ = jQuery;

View File

@ -13,13 +13,13 @@ import * as pathModule from './path.js';
import {
isNullish, getStrokedBBoxDefaultVisible, setHref, getElem, getHref, getVisibleElements,
findDefs, getRotationAngle, getRefElem, getBBox as utilsGetBBox, walkTreePost, assignAttributes
} from '../common/utilities.js';
} from './utilities.js';
import {
transformPoint, matrixMultiply, transformListToTransform
} from '../common/math.js';
} from './math.js';
import {
getTransformList
} from '../common/svgtransformlist.js';
} from './svgtransformlist.js';
import {
recalculateDimensions
} from './recalculate.js';

View File

@ -9,12 +9,12 @@
import {NS} from '../common/namespaces.js';
import {
isNullish, getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible
} from '../common/utilities.js';
import {transformPoint, transformListToTransform, rectsIntersect} from '../common/math.js';
} from './utilities.js';
import {transformPoint, transformListToTransform, rectsIntersect} from './math.js';
import jQueryPluginSVG from '../common/jQuery.attr.js';
import {
getTransformList
} from '../common/svgtransformlist.js';
} from './svgtransformlist.js';
import * as hstry from './history.js';
const {BatchCommand} = hstry;

View File

@ -14,11 +14,11 @@ import {
text2xml, cleanupElement, findDefs, getHref, preventClickDefault,
toXml, getStrokedBBoxDefaultVisible, encode64, createObjectURL,
dataURLToObjectURL, walkTree, getBBox as utilsGetBBox
} from '../common/utilities.js';
} from './utilities.js';
import {
transformPoint, transformListToTransform
} from '../common/math.js';
import {resetListMap} from '../common/svgtransformlist.js';
} from './math.js';
import {resetListMap} from './svgtransformlist.js';
import {
convertUnit, shortFloat, convertToNum
} from '../common/units.js';

View File

@ -78,12 +78,13 @@ import {
findDefs, getHref, setHref, getRefElem, getRotationAngle, getPathBBox,
preventClickDefault, walkTree, getBBoxOfElementAsPath, convertToPath, encode64, decode64,
getVisibleElements, dropXMLInternalSubset, init as utilsInit,
getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible, isNullish
} from '../common/utilities.js';
getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible, isNullish, blankPageObjectURL,
$id, $qa, $qq
} from './utilities.js';
import {
transformPoint, matrixMultiply, hasMatrixTransform, transformListToTransform,
isIdentity, transformBox
} from '../common/math.js';
} from './math.js';
import {
convertToNum, getTypeMap, init as unitsInit
} from '../common/units.js';
@ -97,7 +98,7 @@ import {
} from '../common/browser.js'; // , supportsEditableText
import {
getTransformList, SVGTransformList as SVGEditTransformList
} from '../common/svgtransformlist.js';
} from './svgtransformlist.js';
import {
remapElement,
init as coordsInit
@ -2743,4 +2744,14 @@ class SvgCanvas {
} // End constructor
} // End class
// attach utilities function to the class that are used by SvgEdit so
// we can avoid using the whole utilities.js file in svgEdit.js
SvgCanvas.isNullish = isNullish;
SvgCanvas.encode64 = encode64;
SvgCanvas.decode64 = decode64;
SvgCanvas.$id = $id;
SvgCanvas.$qq = $qq;
SvgCanvas.$qa = $qa;
SvgCanvas.blankPageObjectURL = blankPageObjectURL;
export default SvgCanvas;

View File

@ -6,7 +6,7 @@
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/
import {NS} from '../common/namespaces.js';
import {text2xml} from '../common/utilities.js';
import {text2xml} from './utilities.js';
/**
* @function module:svgcanvas.svgRootElement svgRootElement the svg node and its children.

View File

@ -7,8 +7,8 @@
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/
import {NS} from './namespaces.js';
import {supportsNativeTransformLists} from './browser.js';
import {NS} from '../common/namespaces.js';
import {supportsNativeTransformLists} from '../common/browser.js';
const svgroot = document.createElementNS(NS.SVG, 'svg');

View File

@ -10,10 +10,10 @@ import jQueryPluginSVG from '../common/jQuery.attr.js';
import {NS} from '../common/namespaces.js';
import {
transformPoint, getMatrix
} from '../common/math.js';
} from './math.js';
import {
assignAttributes, getElem, getBBox as utilsGetBBox
} from '../common/utilities.js';
} from './utilities.js';
import {
supportsGoodTextCharPos
} from '../common/browser.js';

View File

@ -8,16 +8,16 @@ import * as draw from './draw.js';
import * as hstry from './history.js';
import {
getRotationAngle, getBBox as utilsGetBBox, isNullish, setHref, getStrokedBBoxDefaultVisible
} from '../common/utilities.js';
} from './utilities.js';
import {
isGecko
} from '../common/browser.js';
import {
transformPoint, transformListToTransform
} from '../common/math.js';
} from './math.js';
import {
getTransformList
} from '../common/svgtransformlist.js';
} from './svgtransformlist.js';
const {
UndoManager, HistoryEventTypes

View File

@ -7,17 +7,17 @@
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/
import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {NS} from './namespaces.js';
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {NS} from '../common/namespaces.js';
import {getTransformList} from './svgtransformlist.js';
import {setUnitAttr, getTypeMap} from './units.js';
import {setUnitAttr, getTypeMap} from '../common/units.js';
import {
hasMatrixTransform, transformListToTransform, transformBox
} from './math.js';
import {
isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath,
supportsSelectors
} from './browser.js';
} from '../common/browser.js';
// Constants
const $ = jQueryPluginSVG(jQuery);
@ -1298,17 +1298,6 @@ export const snapToGrid = function (value) {
return value;
};
/**
* Escapes special characters in a regular expression.
* @function module:utilities.regexEscape
* @param {string} str
* @returns {string}
*/
export const regexEscape = function (str) {
// Originally from: http://phpjs.org/functions
return String(str).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g, '\\$&');
};
/**
* Prevents default browser click behaviour on the given element.
* @function module:utilities.preventClickDefault
@ -1350,6 +1339,7 @@ export const mock = ({
getRotationAngle = getRotationAngleUser;
};
// shortcuts to common DOM functions
export const $id = (id) => document.getElementById(id);
export const $q = (sel) => document.querySelector(sel);
export const $qq = (sel) => [...document.querySelectorAll(sel)];
export const $qq = (sel) => document.querySelector(sel);
export const $qa = (sel) => [...document.querySelectorAll(sel)];