- npm: Update devDeps

- Linting (ESLint): New ash-nazg rules
This commit is contained in:
Brett Zamir
2019-02-21 19:41:09 +08:00
parent c2a9798bfe
commit d01abf19d2
27 changed files with 3408 additions and 2812 deletions

View File

@@ -12,7 +12,7 @@ module.exports = {
browser: true
},
settings: {
polyfills: ["url", "promises", "fetch", "queryselector"],
polyfills: ["url", "promises", "fetch", "queryselector", "object-values"],
jsdoc: {
additionalTagNames: {
// In case we need to extend
@@ -145,6 +145,8 @@ module.exports = {
"max-len": ["off", {
ignoreUrls: true,
ignoreRegExpLiterals: true
}]
}],
"unicorn/prefer-query-selector": ["off"],
"unicorn/prefer-node-append": ["off"]
}
};

22
dist/canvg.js vendored
View File

@@ -527,11 +527,10 @@ var canvg = (function (exports) {
}();
RGBColor.getHelpXML = function () {
var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})).concat(_toConsumableArray(Object.keys(simpleColors)));
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
@@ -553,11 +552,11 @@ var canvg = (function (exports) {
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return _typeof(obj);
};
} else {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
};
}
@@ -3225,7 +3224,7 @@ var canvg = (function (exports) {
_classCallCheck(this, _class22);
_this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node));
svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12)));
svg.Animations.push(_assertThisInitialized(_this12));
_this12.duration = 0.0;
_this12.begin = _this12.attribute('begin').toMilliseconds();
_this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds();
@@ -3443,7 +3442,7 @@ var canvg = (function (exports) {
_this13.fontFace = child;
if (child.style('font-family').hasValue()) {
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13));
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13);
}
} else if (child.type === 'missing-glyph') {
_this13.missingGlyph = child;
@@ -3886,7 +3885,7 @@ var canvg = (function (exports) {
}
_this20._isSvg = href.match(/\.svg$/);
svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20)));
svg.Images.push(_assertThisInitialized(_this20));
_this20.loaded = false;
if (!_this20._isSvg) {
@@ -4020,12 +4019,13 @@ var canvg = (function (exports) {
_toConsumableArray(node.childNodes).forEach(function (_ref11) {
var nodeValue = _ref11.nodeValue;
css += nodeValue;
});
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
css = svg.compressSpaces(css); // replace whitespace
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);
var cssDefs = css.split('}');
cssDefs.forEach(function (cssDef) {
if (svg.trim(cssDef) !== '') {

View File

@@ -527,11 +527,10 @@ var svgEditorExtension_server_moinsave = (function () {
}();
RGBColor.getHelpXML = function () {
var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})).concat(_toConsumableArray(Object.keys(simpleColors)));
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
@@ -553,11 +552,11 @@ var svgEditorExtension_server_moinsave = (function () {
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return _typeof(obj);
};
} else {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
};
}
@@ -3225,7 +3224,7 @@ var svgEditorExtension_server_moinsave = (function () {
_classCallCheck(this, _class22);
_this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node));
svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12)));
svg.Animations.push(_assertThisInitialized(_this12));
_this12.duration = 0.0;
_this12.begin = _this12.attribute('begin').toMilliseconds();
_this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds();
@@ -3443,7 +3442,7 @@ var svgEditorExtension_server_moinsave = (function () {
_this13.fontFace = child;
if (child.style('font-family').hasValue()) {
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13));
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13);
}
} else if (child.type === 'missing-glyph') {
_this13.missingGlyph = child;
@@ -3886,7 +3885,7 @@ var svgEditorExtension_server_moinsave = (function () {
}
_this20._isSvg = href.match(/\.svg$/);
svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20)));
svg.Images.push(_assertThisInitialized(_this20));
_this20.loaded = false;
if (!_this20._isSvg) {
@@ -4020,12 +4019,13 @@ var svgEditorExtension_server_moinsave = (function () {
_toConsumableArray(node.childNodes).forEach(function (_ref11) {
var nodeValue = _ref11.nodeValue;
css += nodeValue;
});
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
css = svg.compressSpaces(css); // replace whitespace
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);
var cssDefs = css.split('}');
cssDefs.forEach(function (cssDef) {
if (svg.trim(cssDef) !== '') {

View File

@@ -527,11 +527,10 @@ var svgEditorExtension_server_opensave = (function () {
}();
RGBColor.getHelpXML = function () {
var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})).concat(_toConsumableArray(Object.keys(simpleColors)));
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
@@ -553,11 +552,11 @@ var svgEditorExtension_server_opensave = (function () {
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return _typeof(obj);
};
} else {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
};
}
@@ -3225,7 +3224,7 @@ var svgEditorExtension_server_opensave = (function () {
_classCallCheck(this, _class22);
_this12 = _possibleConstructorReturn(this, _getPrototypeOf(_class22).call(this, node));
svg.Animations.push(_assertThisInitialized(_assertThisInitialized(_this12)));
svg.Animations.push(_assertThisInitialized(_this12));
_this12.duration = 0.0;
_this12.begin = _this12.attribute('begin').toMilliseconds();
_this12.maxDuration = _this12.begin + _this12.attribute('dur').toMilliseconds();
@@ -3443,7 +3442,7 @@ var svgEditorExtension_server_opensave = (function () {
_this13.fontFace = child;
if (child.style('font-family').hasValue()) {
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_assertThisInitialized(_this13));
svg.Definitions[child.style('font-family').value] = _assertThisInitialized(_this13);
}
} else if (child.type === 'missing-glyph') {
_this13.missingGlyph = child;
@@ -3886,7 +3885,7 @@ var svgEditorExtension_server_opensave = (function () {
}
_this20._isSvg = href.match(/\.svg$/);
svg.Images.push(_assertThisInitialized(_assertThisInitialized(_this20)));
svg.Images.push(_assertThisInitialized(_this20));
_this20.loaded = false;
if (!_this20._isSvg) {
@@ -4020,12 +4019,13 @@ var svgEditorExtension_server_opensave = (function () {
_toConsumableArray(node.childNodes).forEach(function (_ref11) {
var nodeValue = _ref11.nodeValue;
css += nodeValue;
});
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
css = svg.compressSpaces(css); // replace whitespace
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);
var cssDefs = css.split('}');
cssDefs.forEach(function (cssDef) {
if (svg.trim(cssDef) !== '') {

View File

@@ -250,11 +250,11 @@
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return _typeof(obj);
};
} else {
_typeof$1 = function _typeof$$1(obj) {
_typeof$1 = function _typeof$1(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
};
}
@@ -268,7 +268,7 @@
}
}
function _defineProperties$1(target, props) {
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
@@ -278,9 +278,9 @@
}
}
function _createClass$1(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
if (staticProps) _defineProperties$1(Constructor, staticProps);
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
@@ -300,14 +300,14 @@
}
function _getPrototypeOf$1(o) {
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf$$1(o) {
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf$1(o);
}
function _setPrototypeOf$1(o, p) {
_setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf$$1(o, p) {
_setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
@@ -332,7 +332,7 @@
if (isNativeReflectConstruct$1()) {
_construct$1 = Reflect.construct;
} else {
_construct$1 = function _construct$$1(Parent, args, Class) {
_construct$1 = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
@@ -352,7 +352,7 @@
function _wrapNativeSuper$1(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper$1 = function _wrapNativeSuper$$1(Class) {
_wrapNativeSuper$1 = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction$1(Class)) return Class;
if (typeof Class !== "function") {
@@ -399,7 +399,7 @@
return _assertThisInitialized$1(self);
}
function _superPropBase$1(object, property) {
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf$1(object);
if (object === null) break;
@@ -408,12 +408,12 @@
return object;
}
function _get$1(target, property, receiver) {
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get$1 = Reflect.get;
_get = Reflect.get;
} else {
_get$1 = function _get$$1(target, property, receiver) {
var base = _superPropBase$1(target, property);
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
@@ -426,7 +426,7 @@
};
}
return _get$1(target, property, receiver || target);
return _get(target, property, receiver || target);
}
function _slicedToArray$1(arr, i) {
@@ -2112,17 +2112,17 @@
return _possibleConstructorReturn$1(this, _getPrototypeOf$1(JamilihMap).apply(this, arguments));
}
_createClass$1(JamilihMap, [{
_createClass(JamilihMap, [{
key: "get",
value: function get$$1(elem) {
elem = typeof elem === 'string' ? $(elem) : elem;
return _get$1(_getPrototypeOf$1(JamilihMap.prototype), "get", this).call(this, elem);
return _get(_getPrototypeOf$1(JamilihMap.prototype), "get", this).call(this, elem);
}
}, {
key: "set",
value: function set(elem, value) {
elem = typeof elem === 'string' ? $(elem) : elem;
return _get$1(_getPrototypeOf$1(JamilihMap.prototype), "set", this).call(this, elem, value);
return _get(_getPrototypeOf$1(JamilihMap.prototype), "set", this).call(this, elem, value);
}
}, {
key: "invoke",
@@ -2153,17 +2153,17 @@
return _possibleConstructorReturn$1(this, _getPrototypeOf$1(JamilihWeakMap).apply(this, arguments));
}
_createClass$1(JamilihWeakMap, [{
_createClass(JamilihWeakMap, [{
key: "get",
value: function get$$1(elem) {
elem = typeof elem === 'string' ? $(elem) : elem;
return _get$1(_getPrototypeOf$1(JamilihWeakMap.prototype), "get", this).call(this, elem);
return _get(_getPrototypeOf$1(JamilihWeakMap.prototype), "get", this).call(this, elem);
}
}, {
key: "set",
value: function set(elem, value) {
elem = typeof elem === 'string' ? $(elem) : elem;
return _get$1(_getPrototypeOf$1(JamilihWeakMap.prototype), "set", this).call(this, elem, value);
return _get(_getPrototypeOf$1(JamilihWeakMap.prototype), "set", this).call(this, elem, value);
}
}, {
key: "invoke",
@@ -2456,11 +2456,11 @@
function _typeof$2(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$2 = function _typeof$$1(obj) {
_typeof$2 = function _typeof$1(obj) {
return _typeof(obj);
};
} else {
_typeof$2 = function _typeof$$1(obj) {
_typeof$2 = function _typeof$1(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
};
}
@@ -3311,13 +3311,13 @@
}, [// Todo: i18nize first values
['Date', 'date'], ['Downloads', 'downloads'], ['Favorited', 'favorites']].map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
text$$1 = _ref2[0],
text = _ref2[0],
_ref2$ = _ref2[1],
value = _ref2$ === void 0 ? text$$1 : _ref2$;
value = _ref2$ === void 0 ? text : _ref2$;
return ['option', {
value: value
}, [text$$1]];
}, [text]];
})]]]]], ['div', {
class: 'control'
}, [['label', ['Results per page: ', ['input', {

189
dist/index-es.js vendored
View File

@@ -5119,7 +5119,7 @@ var editorContext_ = null;
* @returns {undefined}
*/
var init$1 = function init$$1(editorContext) {
var init$1 = function init(editorContext) {
editorContext_ = editorContext;
pathFuncs = [0, 'ClosePath'];
var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'];
@@ -5844,7 +5844,7 @@ function () {
_createClass(Path, [{
key: "init",
value: function init$$1() {
value: function init() {
// Hide all grips, etc
// fixed, needed to work on all found elements, not just first
$$1(getGripContainer()).find('*').each(function () {
@@ -7934,7 +7934,7 @@ var svgroot_ = null;
* @returns {undefined}
*/
var init$2 = function init$$1(editorContext) {
var init$2 = function init(editorContext) {
editorContext_$1 = editorContext;
domdoc_ = editorContext.getDOMDocument();
domcontainer_ = editorContext.getDOMContainer();
@@ -8323,8 +8323,8 @@ var findDefs = function findDefs() {
* @returns {module:utilities.BBoxObject} A BBox-like object
*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var getPathBBox = function getPathBBox(path) {
var seglist = path.pathSegList;
var tot = seglist.numberOfItems;
var bounds = [[], []];
var start = seglist.getItem(0);
@@ -8707,43 +8707,43 @@ var getExtraAttributesForConvertToPath = function getExtraAttributesForConvertTo
* @returns {DOMRect|false} The resulting path's bounding box object.
*/
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) {
var path$$1 = addSVGElementFromJson({
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) {
var path = addSVGElementFromJson({
element: 'path',
attr: getExtraAttributesForConvertToPath(elem)
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d);
path.setAttribute('d', d);
} else {
path$$1.remove();
path.remove();
} // Get the correct BBox of the new path, then discard it
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
var bb = false;
try {
bb = path$$1.getBBox();
bb = path.getBBox();
} catch (e) {// Firefox fails
}
path$$1.remove();
path.remove();
return bb;
};
/**
@@ -8760,57 +8760,57 @@ var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElement
* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.
*/
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) {
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) {
var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes
attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem));
var path$$1 = addSVGElementFromJson({
var path = addSVGElementFromJson({
element: 'path',
attr: attrs
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var id = elem.id;
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d); // Replace the current element with the converted one
path.setAttribute('d', d); // Replace the current element with the converted one
// Reorient if it has a matrix
if (eltrans) {
var tlist = getTransformList(path$$1);
var tlist = getTransformList(path);
if (hasMatrixTransform(tlist)) {
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
}
}
var nextSibling = elem.nextSibling;
batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path));
clearSelection();
elem.remove();
path$$1.setAttribute('id', id);
path$$1.removeAttribute('visibility');
addToSelection([path$$1], true);
path.setAttribute('id', id);
path.removeAttribute('visibility');
addToSelection([path], true);
addCommandToHistory(batchCmd);
return path$$1;
return path;
} // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything.
path$$1.remove();
path.remove();
return null;
};
/**
@@ -8850,7 +8850,7 @@ function bBoxCanBeOptimizedOverNativeGetBBox(angle, hasAMatrixTransform) {
*/
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) {
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
@@ -8873,7 +8873,7 @@ var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFrom
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.includes(elem.tagName)) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
} else if (elem.tagName === 'rect') {
// Look for radius
@@ -8881,7 +8881,7 @@ var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFrom
var ry = elem.getAttribute('ry');
if (rx || ry) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
}
}
@@ -8938,7 +8938,7 @@ function getStrokeOffsetForBBox(elem) {
*/
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) {
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) {
if (!elems || !elems.length) {
return false;
}
@@ -8953,7 +8953,7 @@ var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathA
return;
}
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1);
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);
}); // This shouldn't ever happen...
if (fullBb === undefined) {
@@ -8975,7 +8975,7 @@ var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathA
maxY += offset;
} else {
$$2.each(elems, function (i, elem) {
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1);
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);
if (curBb) {
var _offset = getStrokeOffsetForBBox(elem);
@@ -10979,7 +10979,7 @@ function () {
}, {
key: "copyElem",
value: function copyElem$$1(el) {
value: function copyElem$1(el) {
var that = this;
var getNextIdClosure = function getNextIdClosure() {
@@ -11380,7 +11380,13 @@ var setContext = function setContext(elem) {
canvas_.call('contextset', canvas_.getCurrentGroup());
};
var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support
var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent
/**
* This defines which elements and attributes that we support (or at least
* don't remove)
* @type {PlainObject}
*/
var svgWhiteList_ = {
// SVG Elements
@@ -11392,6 +11398,7 @@ var svgWhiteList_ = {
desc: [],
ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],
feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],
feMorphology: ['class', 'in', 'operator', 'radius'],
filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],
foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],
g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],
@@ -12056,7 +12063,7 @@ var context_;
* @returns {undefined}
*/
var init$5 = function init$$1(editorContext) {
var init$5 = function init(editorContext) {
context_ = editorContext;
};
/**
@@ -12371,6 +12378,7 @@ var recalculateDimensions = function recalculateDimensions(selected) {
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
@@ -12378,6 +12386,7 @@ var recalculateDimensions = function recalculateDimensions(selected) {
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@@ -12402,6 +12411,9 @@ var recalculateDimensions = function recalculateDimensions(selected) {
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@@ -13822,7 +13834,7 @@ function SvgCanvas(container, config) {
return selectedElements;
};
var pathActions$$1 = pathActions;
var pathActions$1 = pathActions;
/**
* This should actually be an intersection as all interfaces should be met.
* @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}
@@ -13837,7 +13849,7 @@ function SvgCanvas(container, config) {
* @implements {module:utilities.EditorContext}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
// Ok since not modifying
getSVGContent: getSVGContent,
addSVGElementFromJson: addSVGElementFromJson,
@@ -14253,13 +14265,13 @@ function SvgCanvas(container, config) {
*/
canvas.pathActions = pathActions$$1;
canvas.pathActions = pathActions$1;
/**
* @implements {module:path.EditorContext#resetD}
*/
function resetD(p) {
p.setAttribute('d', pathActions$$1.convertPath(p));
p.setAttribute('d', pathActions$1.convertPath(p));
}
init$1(
@@ -14308,8 +14320,8 @@ function SvgCanvas(container, config) {
var closedSubpath = _ref.closedSubpath,
grips = _ref.grips;
// TODO: Correct this:
pathActions$$1.canDeleteNodes = true;
pathActions$$1.closed_subpath = closedSubpath;
pathActions$1.canDeleteNodes = true;
pathActions$1.closed_subpath = closedSubpath;
call('pointsAdded', {
closedSubpath: closedSubpath,
grips: grips
@@ -15011,9 +15023,9 @@ function SvgCanvas(container, config) {
var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path'));
paths.forEach(function (path$$1) {
path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1));
pathActions$$1.fixEnd(path$$1);
paths.forEach(function (path) {
path.setAttribute('d', pathActions$1.convertPath(path));
pathActions$1.fixEnd(path);
});
};
/**
@@ -15391,7 +15403,7 @@ function SvgCanvas(container, config) {
addToSelection([mouseTarget]);
justSelected = mouseTarget;
pathActions$$1.clear();
pathActions$1.clear();
} // else if it's a path, go into pathedit mode in mouseup
@@ -15489,12 +15501,11 @@ function SvgCanvas(container, config) {
if (iswebkit) {
delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttribute('stroke');
var stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () {
ele.setAttribute('stroke', _stroke);
if (stroke_ !== null) setTimeout(function () {
ele.setAttribute('stroke', stroke_);
}, 0);
};
}
@@ -15681,7 +15692,7 @@ function SvgCanvas(container, config) {
case 'pathedit':
startX *= currentZoom;
startY *= currentZoom;
pathActions$$1.mouseDown(evt, mouseTarget, startX, startY);
pathActions$1.mouseDown(evt, mouseTarget, startX, startY);
started = true;
break;
@@ -16171,12 +16182,12 @@ function SvgCanvas(container, config) {
}
if (evt.shiftKey) {
var path$$1 = path;
var path$1 = path;
var x1, y1;
if (path$$1) {
x1 = path$$1.dragging ? path$$1.dragging[0] : startX;
y1 = path$$1.dragging ? path$$1.dragging[1] : startY;
if (path$1) {
x1 = path$1.dragging ? path$1.dragging[0] : startX;
y1 = path$1.dragging ? path$1.dragging[1] : startY;
} else {
x1 = startX;
y1 = startY;
@@ -16199,7 +16210,7 @@ function SvgCanvas(container, config) {
}, 100);
}
pathActions$$1.mouseMove(x, y);
pathActions$1.mouseMove(x, y);
break;
}
@@ -16376,7 +16387,7 @@ function SvgCanvas(container, config) {
t = evt.target;
if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {
pathActions$$1.select(selectedElements[0]); // if it was a path
pathActions$1.select(selectedElements[0]); // if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if (evt.shiftKey) {
if (tempJustSelected !== t) {
@@ -16451,7 +16462,7 @@ function SvgCanvas(container, config) {
}
if (keep) {
element = pathActions$$1.smoothPolylineIntoPath(element);
element = pathActions$1.smoothPolylineIntoPath(element);
}
break;
@@ -16530,7 +16541,7 @@ function SvgCanvas(container, config) {
element = null; // continue to be set to true so that mouseMove happens
started = true;
var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY);
var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY);
element = res.element;
keep = res.keep;
break;
@@ -16539,7 +16550,7 @@ function SvgCanvas(container, config) {
case 'pathedit':
keep = true;
element = null;
pathActions$$1.mouseUp(evt);
pathActions$1.mouseUp(evt);
break;
case 'textedit':
@@ -16650,7 +16661,7 @@ function SvgCanvas(container, config) {
cleanupElement(element);
if (currentMode === 'path') {
pathActions$$1.toEditMode(element);
pathActions$1.toEditMode(element);
} else if (curConfig.selectNew) {
selectOnly([element], true);
} // we create the insert command that is stored on the stack
@@ -17257,7 +17268,7 @@ function SvgCanvas(container, config) {
* @param {Element} inputElem Not in use
* @returns {undefined}
*/
init: function init$$1(inputElem) {
init: function init(inputElem) {
if (!curtext) {
return;
}
@@ -17400,7 +17411,7 @@ function SvgCanvas(container, config) {
while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty
pathActions$$1.clear(true); // Keep SVG-Edit comment on top
pathActions$1.clear(true); // Keep SVG-Edit comment on top
$$9.each(svgcontent.childNodes, function (i, node) {
if (i && node.nodeType === 8 && node.data.includes('Created with')) {
@@ -17567,7 +17578,7 @@ function SvgCanvas(container, config) {
out.push(' ');
if (_attr.localName === 'd') {
_attrVal = pathActions$$1.convertPath(elem, true);
_attrVal = pathActions$1.convertPath(elem, true);
}
if (!isNaN(_attrVal)) {
@@ -18796,7 +18807,7 @@ function SvgCanvas(container, config) {
* @implements {module:draw.DrawCanvasInit}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
getCurrentGroup: function getCurrentGroup() {
return currentGroup;
},
@@ -18832,7 +18843,7 @@ function SvgCanvas(container, config) {
*/
this.clear = function () {
pathActions$$1.clear();
pathActions$1.clear();
clearSelection(); // clear the svgcontent node
canvas.clearSvgContentElement(); // create new document
@@ -18850,7 +18861,7 @@ function SvgCanvas(container, config) {
}; // Alias function
this.linkControlPoints = pathActions$$1.linkControlPoints;
this.linkControlPoints = pathActions$1.linkControlPoints;
/**
* @function module:svgcanvas.SvgCanvas#getContentElem
* @returns {Element} The content DOM element
@@ -19341,7 +19352,7 @@ function SvgCanvas(container, config) {
selectorManager.requestSelector(elem).resize();
});
pathActions$$1.zoomChange();
pathActions$1.zoomChange();
runExtensions('zoomChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */
zoomLevel);
@@ -19364,7 +19375,7 @@ function SvgCanvas(container, config) {
this.setMode = function (name) {
pathActions$$1.clear(true);
pathActions$1.clear(true);
textActions.clear();
curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape;
currentMode = name;
@@ -20255,7 +20266,7 @@ function SvgCanvas(container, config) {
this.setSegType = function (newType) {
pathActions$$1.setSegType(newType);
pathActions$1.setSegType(newType);
};
/**
* Convert selected element to a path, or get the BBox of an element-as-path.
@@ -20268,7 +20279,7 @@ function SvgCanvas(container, config) {
*/
this.convertToPath = function (elem, getBBox$$1) {
this.convertToPath = function (elem, getBBox) {
if (isNullish(elem)) {
var elems = selectedElements;
$$9.each(elems, function (i, el) {
@@ -20279,8 +20290,8 @@ function SvgCanvas(container, config) {
return undefined;
}
if (getBBox$$1) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
if (getBBox) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1);
} // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
@@ -20297,7 +20308,7 @@ function SvgCanvas(container, config) {
opacity: curShape.opacity,
visibility: 'hidden'
};
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory);
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory);
};
/**
* This function makes the changes to the elements. It does not add the change
@@ -20312,7 +20323,7 @@ function SvgCanvas(container, config) {
var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) {
if (currentMode === 'pathedit') {
// Editing node
pathActions$$1.moveNode(attr, newValue);
pathActions$1.moveNode(attr, newValue);
}
elems = elems || selectedElements;
@@ -24662,6 +24673,8 @@ function jQueryContextMenu($) {
return $;
}
/* eslint-disable no-bitwise */
/**
* jPicker (Adapted from version 1.1.6)
*
@@ -24773,8 +24786,7 @@ var jPicker = function jPicker($) {
offset = {
l: off.left | 0,
t: off.top | 0
}; // eslint-disable-line no-bitwise
};
clearTimeout(timeout); // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
timeout = setTimeout(function () {
@@ -24848,7 +24860,6 @@ var jPicker = function jPicker($) {
var arrowOffsetX = 0,
arrowOffsetY = 0;
setTimeout(function () {
/* eslint-disable no-bitwise */
if (rangeX > 0) {
// range is greater than zero
// constrain to bounds
@@ -24871,7 +24882,6 @@ var jPicker = function jPicker($) {
left: arrowOffsetX + 'px',
top: arrowOffsetY + 'px'
});
/* eslint no-bitwise: ["error"] */
});
}
/**
@@ -25022,7 +25032,6 @@ var jPicker = function jPicker($) {
var // changed = false,
newMinX, newMaxX, newMinY, newMaxY;
if (isNullish$1(name)) name = 'all';
/* eslint-disable no-bitwise */
switch (name.toLowerCase()) {
case 'minx':
@@ -25059,8 +25068,6 @@ var jPicker = function jPicker($) {
newMaxY = value && value.maxY && value.maxY | 0 || 0;
break;
}
/* eslint no-bitwise: ["error"] */
if (!isNullish$1(newMinX) && minX !== newMinX) {
minX = newMinX;
@@ -29421,7 +29428,7 @@ editor.init = function () {
var _ref6 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, name, init$$1, importLocale;
var extName, url, imported, _imported$name, name, init, importLocale;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
@@ -29455,12 +29462,12 @@ editor.init = function () {
case 7:
imported = _context2.sent;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init$$1 = imported.init;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init;
importLocale = getImportLocale({
defaultLang: langParam,
defaultName: name
});
return _context2.abrupt("return", editor.addExtension(name, init$$1 && init$$1.bind(editor), {
return _context2.abrupt("return", editor.addExtension(name, init && init.bind(editor), {
$: $$b,
importLocale: importLocale
}));
@@ -33277,7 +33284,7 @@ editor.init = function () {
*/
var convertToPath$$1 = function convertToPath$$1() {
var convertToPath = function convertToPath() {
if (!isNullish(selectedElement)) {
svgCanvas.convertToPath();
}
@@ -35113,7 +35120,7 @@ editor.init = function () {
key: 'ctrl+shift+['
}, {
sel: '#tool_topath',
fn: convertToPath$$1,
fn: convertToPath,
evt: 'click'
}, {
sel: '#tool_make_link,#tool_make_link_multi',
@@ -36386,7 +36393,7 @@ editor.loadFromDataURI = function (str) {
*/
editor.addExtension = function (name, init$$1, initArgs) {
editor.addExtension = function (name, init, initArgs) {
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
@@ -36394,7 +36401,7 @@ editor.addExtension = function (name, init$$1, initArgs) {
throw new Error('Extension added too early');
}
return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
return svgCanvas.addExtension.call(this, name, init, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

195
dist/index-umd.js vendored
View File

@@ -1,8 +1,8 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.svgEditor = factory());
}(this, (function () { 'use strict';
(global = global || self, global.svgEditor = factory());
}(this, function () { 'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
@@ -5125,7 +5125,7 @@
* @returns {undefined}
*/
var init$1 = function init$$1(editorContext) {
var init$1 = function init(editorContext) {
editorContext_ = editorContext;
pathFuncs = [0, 'ClosePath'];
var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'];
@@ -5850,7 +5850,7 @@
_createClass(Path, [{
key: "init",
value: function init$$1() {
value: function init() {
// Hide all grips, etc
// fixed, needed to work on all found elements, not just first
$$1(getGripContainer()).find('*').each(function () {
@@ -7940,7 +7940,7 @@
* @returns {undefined}
*/
var init$2 = function init$$1(editorContext) {
var init$2 = function init(editorContext) {
editorContext_$1 = editorContext;
domdoc_ = editorContext.getDOMDocument();
domcontainer_ = editorContext.getDOMContainer();
@@ -8329,8 +8329,8 @@
* @returns {module:utilities.BBoxObject} A BBox-like object
*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var getPathBBox = function getPathBBox(path) {
var seglist = path.pathSegList;
var tot = seglist.numberOfItems;
var bounds = [[], []];
var start = seglist.getItem(0);
@@ -8713,43 +8713,43 @@
* @returns {DOMRect|false} The resulting path's bounding box object.
*/
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) {
var path$$1 = addSVGElementFromJson({
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) {
var path = addSVGElementFromJson({
element: 'path',
attr: getExtraAttributesForConvertToPath(elem)
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d);
path.setAttribute('d', d);
} else {
path$$1.remove();
path.remove();
} // Get the correct BBox of the new path, then discard it
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
var bb = false;
try {
bb = path$$1.getBBox();
bb = path.getBBox();
} catch (e) {// Firefox fails
}
path$$1.remove();
path.remove();
return bb;
};
/**
@@ -8766,57 +8766,57 @@
* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.
*/
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) {
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) {
var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes
attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem));
var path$$1 = addSVGElementFromJson({
var path = addSVGElementFromJson({
element: 'path',
attr: attrs
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var id = elem.id;
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d); // Replace the current element with the converted one
path.setAttribute('d', d); // Replace the current element with the converted one
// Reorient if it has a matrix
if (eltrans) {
var tlist = getTransformList(path$$1);
var tlist = getTransformList(path);
if (hasMatrixTransform(tlist)) {
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
}
}
var nextSibling = elem.nextSibling;
batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path));
clearSelection();
elem.remove();
path$$1.setAttribute('id', id);
path$$1.removeAttribute('visibility');
addToSelection([path$$1], true);
path.setAttribute('id', id);
path.removeAttribute('visibility');
addToSelection([path], true);
addCommandToHistory(batchCmd);
return path$$1;
return path;
} // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything.
path$$1.remove();
path.remove();
return null;
};
/**
@@ -8856,7 +8856,7 @@
*/
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) {
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
@@ -8879,7 +8879,7 @@
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.includes(elem.tagName)) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
} else if (elem.tagName === 'rect') {
// Look for radius
@@ -8887,7 +8887,7 @@
var ry = elem.getAttribute('ry');
if (rx || ry) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
}
}
@@ -8944,7 +8944,7 @@
*/
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) {
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) {
if (!elems || !elems.length) {
return false;
}
@@ -8959,7 +8959,7 @@
return;
}
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1);
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);
}); // This shouldn't ever happen...
if (fullBb === undefined) {
@@ -8981,7 +8981,7 @@
maxY += offset;
} else {
$$2.each(elems, function (i, elem) {
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1);
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);
if (curBb) {
var _offset = getStrokeOffsetForBBox(elem);
@@ -10985,7 +10985,7 @@
}, {
key: "copyElem",
value: function copyElem$$1(el) {
value: function copyElem$1(el) {
var that = this;
var getNextIdClosure = function getNextIdClosure() {
@@ -11386,7 +11386,13 @@
canvas_.call('contextset', canvas_.getCurrentGroup());
};
var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support
var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent
/**
* This defines which elements and attributes that we support (or at least
* don't remove)
* @type {PlainObject}
*/
var svgWhiteList_ = {
// SVG Elements
@@ -11398,6 +11404,7 @@
desc: [],
ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],
feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],
feMorphology: ['class', 'in', 'operator', 'radius'],
filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],
foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],
g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],
@@ -12062,7 +12069,7 @@
* @returns {undefined}
*/
var init$5 = function init$$1(editorContext) {
var init$5 = function init(editorContext) {
context_ = editorContext;
};
/**
@@ -12377,6 +12384,7 @@
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
@@ -12384,6 +12392,7 @@
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@@ -12408,6 +12417,9 @@
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@@ -13828,7 +13840,7 @@
return selectedElements;
};
var pathActions$$1 = pathActions;
var pathActions$1 = pathActions;
/**
* This should actually be an intersection as all interfaces should be met.
* @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}
@@ -13843,7 +13855,7 @@
* @implements {module:utilities.EditorContext}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
// Ok since not modifying
getSVGContent: getSVGContent,
addSVGElementFromJson: addSVGElementFromJson,
@@ -14259,13 +14271,13 @@
*/
canvas.pathActions = pathActions$$1;
canvas.pathActions = pathActions$1;
/**
* @implements {module:path.EditorContext#resetD}
*/
function resetD(p) {
p.setAttribute('d', pathActions$$1.convertPath(p));
p.setAttribute('d', pathActions$1.convertPath(p));
}
init$1(
@@ -14314,8 +14326,8 @@
var closedSubpath = _ref.closedSubpath,
grips = _ref.grips;
// TODO: Correct this:
pathActions$$1.canDeleteNodes = true;
pathActions$$1.closed_subpath = closedSubpath;
pathActions$1.canDeleteNodes = true;
pathActions$1.closed_subpath = closedSubpath;
call('pointsAdded', {
closedSubpath: closedSubpath,
grips: grips
@@ -15017,9 +15029,9 @@
var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path'));
paths.forEach(function (path$$1) {
path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1));
pathActions$$1.fixEnd(path$$1);
paths.forEach(function (path) {
path.setAttribute('d', pathActions$1.convertPath(path));
pathActions$1.fixEnd(path);
});
};
/**
@@ -15397,7 +15409,7 @@
addToSelection([mouseTarget]);
justSelected = mouseTarget;
pathActions$$1.clear();
pathActions$1.clear();
} // else if it's a path, go into pathedit mode in mouseup
@@ -15495,12 +15507,11 @@
if (iswebkit) {
delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttribute('stroke');
var stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () {
ele.setAttribute('stroke', _stroke);
if (stroke_ !== null) setTimeout(function () {
ele.setAttribute('stroke', stroke_);
}, 0);
};
}
@@ -15687,7 +15698,7 @@
case 'pathedit':
startX *= currentZoom;
startY *= currentZoom;
pathActions$$1.mouseDown(evt, mouseTarget, startX, startY);
pathActions$1.mouseDown(evt, mouseTarget, startX, startY);
started = true;
break;
@@ -16177,12 +16188,12 @@
}
if (evt.shiftKey) {
var path$$1 = path;
var path$1 = path;
var x1, y1;
if (path$$1) {
x1 = path$$1.dragging ? path$$1.dragging[0] : startX;
y1 = path$$1.dragging ? path$$1.dragging[1] : startY;
if (path$1) {
x1 = path$1.dragging ? path$1.dragging[0] : startX;
y1 = path$1.dragging ? path$1.dragging[1] : startY;
} else {
x1 = startX;
y1 = startY;
@@ -16205,7 +16216,7 @@
}, 100);
}
pathActions$$1.mouseMove(x, y);
pathActions$1.mouseMove(x, y);
break;
}
@@ -16382,7 +16393,7 @@
t = evt.target;
if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {
pathActions$$1.select(selectedElements[0]); // if it was a path
pathActions$1.select(selectedElements[0]); // if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if (evt.shiftKey) {
if (tempJustSelected !== t) {
@@ -16457,7 +16468,7 @@
}
if (keep) {
element = pathActions$$1.smoothPolylineIntoPath(element);
element = pathActions$1.smoothPolylineIntoPath(element);
}
break;
@@ -16536,7 +16547,7 @@
element = null; // continue to be set to true so that mouseMove happens
started = true;
var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY);
var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY);
element = res.element;
keep = res.keep;
break;
@@ -16545,7 +16556,7 @@
case 'pathedit':
keep = true;
element = null;
pathActions$$1.mouseUp(evt);
pathActions$1.mouseUp(evt);
break;
case 'textedit':
@@ -16656,7 +16667,7 @@
cleanupElement(element);
if (currentMode === 'path') {
pathActions$$1.toEditMode(element);
pathActions$1.toEditMode(element);
} else if (curConfig.selectNew) {
selectOnly([element], true);
} // we create the insert command that is stored on the stack
@@ -17263,7 +17274,7 @@
* @param {Element} inputElem Not in use
* @returns {undefined}
*/
init: function init$$1(inputElem) {
init: function init(inputElem) {
if (!curtext) {
return;
}
@@ -17406,7 +17417,7 @@
while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty
pathActions$$1.clear(true); // Keep SVG-Edit comment on top
pathActions$1.clear(true); // Keep SVG-Edit comment on top
$$9.each(svgcontent.childNodes, function (i, node) {
if (i && node.nodeType === 8 && node.data.includes('Created with')) {
@@ -17573,7 +17584,7 @@
out.push(' ');
if (_attr.localName === 'd') {
_attrVal = pathActions$$1.convertPath(elem, true);
_attrVal = pathActions$1.convertPath(elem, true);
}
if (!isNaN(_attrVal)) {
@@ -18802,7 +18813,7 @@
* @implements {module:draw.DrawCanvasInit}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
getCurrentGroup: function getCurrentGroup() {
return currentGroup;
},
@@ -18838,7 +18849,7 @@
*/
this.clear = function () {
pathActions$$1.clear();
pathActions$1.clear();
clearSelection(); // clear the svgcontent node
canvas.clearSvgContentElement(); // create new document
@@ -18856,7 +18867,7 @@
}; // Alias function
this.linkControlPoints = pathActions$$1.linkControlPoints;
this.linkControlPoints = pathActions$1.linkControlPoints;
/**
* @function module:svgcanvas.SvgCanvas#getContentElem
* @returns {Element} The content DOM element
@@ -19347,7 +19358,7 @@
selectorManager.requestSelector(elem).resize();
});
pathActions$$1.zoomChange();
pathActions$1.zoomChange();
runExtensions('zoomChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */
zoomLevel);
@@ -19370,7 +19381,7 @@
this.setMode = function (name) {
pathActions$$1.clear(true);
pathActions$1.clear(true);
textActions.clear();
curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape;
currentMode = name;
@@ -20261,7 +20272,7 @@
this.setSegType = function (newType) {
pathActions$$1.setSegType(newType);
pathActions$1.setSegType(newType);
};
/**
* Convert selected element to a path, or get the BBox of an element-as-path.
@@ -20274,7 +20285,7 @@
*/
this.convertToPath = function (elem, getBBox$$1) {
this.convertToPath = function (elem, getBBox) {
if (isNullish(elem)) {
var elems = selectedElements;
$$9.each(elems, function (i, el) {
@@ -20285,8 +20296,8 @@
return undefined;
}
if (getBBox$$1) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
if (getBBox) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1);
} // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
@@ -20303,7 +20314,7 @@
opacity: curShape.opacity,
visibility: 'hidden'
};
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory);
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory);
};
/**
* This function makes the changes to the elements. It does not add the change
@@ -20318,7 +20329,7 @@
var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) {
if (currentMode === 'pathedit') {
// Editing node
pathActions$$1.moveNode(attr, newValue);
pathActions$1.moveNode(attr, newValue);
}
elems = elems || selectedElements;
@@ -24668,6 +24679,8 @@
return $;
}
/* eslint-disable no-bitwise */
/**
* jPicker (Adapted from version 1.1.6)
*
@@ -24779,8 +24792,7 @@
offset = {
l: off.left | 0,
t: off.top | 0
}; // eslint-disable-line no-bitwise
};
clearTimeout(timeout); // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
timeout = setTimeout(function () {
@@ -24854,7 +24866,6 @@
var arrowOffsetX = 0,
arrowOffsetY = 0;
setTimeout(function () {
/* eslint-disable no-bitwise */
if (rangeX > 0) {
// range is greater than zero
// constrain to bounds
@@ -24877,7 +24888,6 @@
left: arrowOffsetX + 'px',
top: arrowOffsetY + 'px'
});
/* eslint no-bitwise: ["error"] */
});
}
/**
@@ -25028,7 +25038,6 @@
var // changed = false,
newMinX, newMaxX, newMinY, newMaxY;
if (isNullish$1(name)) name = 'all';
/* eslint-disable no-bitwise */
switch (name.toLowerCase()) {
case 'minx':
@@ -25065,8 +25074,6 @@
newMaxY = value && value.maxY && value.maxY | 0 || 0;
break;
}
/* eslint no-bitwise: ["error"] */
if (!isNullish$1(newMinX) && minX !== newMinX) {
minX = newMinX;
@@ -29427,7 +29434,7 @@
var _ref6 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, name, init$$1, importLocale;
var extName, url, imported, _imported$name, name, init, importLocale;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
@@ -29461,12 +29468,12 @@
case 7:
imported = _context2.sent;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init$$1 = imported.init;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init;
importLocale = getImportLocale({
defaultLang: langParam,
defaultName: name
});
return _context2.abrupt("return", editor.addExtension(name, init$$1 && init$$1.bind(editor), {
return _context2.abrupt("return", editor.addExtension(name, init && init.bind(editor), {
$: $$b,
importLocale: importLocale
}));
@@ -33283,7 +33290,7 @@
*/
var convertToPath$$1 = function convertToPath$$1() {
var convertToPath = function convertToPath() {
if (!isNullish(selectedElement)) {
svgCanvas.convertToPath();
}
@@ -35119,7 +35126,7 @@
key: 'ctrl+shift+['
}, {
sel: '#tool_topath',
fn: convertToPath$$1,
fn: convertToPath,
evt: 'click'
}, {
sel: '#tool_make_link,#tool_make_link_multi',
@@ -36392,7 +36399,7 @@
*/
editor.addExtension = function (name, init$$1, initArgs) {
editor.addExtension = function (name, init, initArgs) {
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
@@ -36400,7 +36407,7 @@
throw new Error('Extension added too early');
}
return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
return svgCanvas.addExtension.call(this, name, init, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu.
@@ -36471,4 +36478,4 @@
return editor;
})));
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -370,11 +370,10 @@
}();
RGBColor.getHelpXML = function () {
var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})).concat(_toConsumableArray(Object.keys(simpleColors)));
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
@@ -428,7 +427,7 @@
});
};
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+)?/g;
var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+|)/g;
var getLinesOptionsOfPoly = function getLinesOptionsOfPoly(node) {
var nums = node.getAttribute('points');

165
dist/svgcanvas-iife.js vendored
View File

@@ -5181,7 +5181,7 @@ var SvgCanvas = (function () {
* @returns {undefined}
*/
var init$1 = function init$$1(editorContext) {
var init$1 = function init(editorContext) {
editorContext_ = editorContext;
pathFuncs = [0, 'ClosePath'];
var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'];
@@ -5906,7 +5906,7 @@ var SvgCanvas = (function () {
_createClass(Path, [{
key: "init",
value: function init$$1() {
value: function init() {
// Hide all grips, etc
// fixed, needed to work on all found elements, not just first
$$1(getGripContainer()).find('*').each(function () {
@@ -7996,7 +7996,7 @@ var SvgCanvas = (function () {
* @returns {undefined}
*/
var init$2 = function init$$1(editorContext) {
var init$2 = function init(editorContext) {
editorContext_$1 = editorContext;
domdoc_ = editorContext.getDOMDocument();
domcontainer_ = editorContext.getDOMContainer();
@@ -8385,8 +8385,8 @@ var SvgCanvas = (function () {
* @returns {module:utilities.BBoxObject} A BBox-like object
*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var getPathBBox = function getPathBBox(path) {
var seglist = path.pathSegList;
var tot = seglist.numberOfItems;
var bounds = [[], []];
var start = seglist.getItem(0);
@@ -8769,43 +8769,43 @@ var SvgCanvas = (function () {
* @returns {DOMRect|false} The resulting path's bounding box object.
*/
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) {
var path$$1 = addSVGElementFromJson({
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) {
var path = addSVGElementFromJson({
element: 'path',
attr: getExtraAttributesForConvertToPath(elem)
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d);
path.setAttribute('d', d);
} else {
path$$1.remove();
path.remove();
} // Get the correct BBox of the new path, then discard it
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
var bb = false;
try {
bb = path$$1.getBBox();
bb = path.getBBox();
} catch (e) {// Firefox fails
}
path$$1.remove();
path.remove();
return bb;
};
/**
@@ -8822,57 +8822,57 @@ var SvgCanvas = (function () {
* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.
*/
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) {
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) {
var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes
attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem));
var path$$1 = addSVGElementFromJson({
var path = addSVGElementFromJson({
element: 'path',
attr: attrs
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var id = elem.id;
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d); // Replace the current element with the converted one
path.setAttribute('d', d); // Replace the current element with the converted one
// Reorient if it has a matrix
if (eltrans) {
var tlist = getTransformList(path$$1);
var tlist = getTransformList(path);
if (hasMatrixTransform(tlist)) {
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
}
}
var nextSibling = elem.nextSibling;
batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path));
clearSelection();
elem.remove();
path$$1.setAttribute('id', id);
path$$1.removeAttribute('visibility');
addToSelection([path$$1], true);
path.setAttribute('id', id);
path.removeAttribute('visibility');
addToSelection([path], true);
addCommandToHistory(batchCmd);
return path$$1;
return path;
} // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything.
path$$1.remove();
path.remove();
return null;
};
/**
@@ -8912,7 +8912,7 @@ var SvgCanvas = (function () {
*/
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) {
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
@@ -8935,7 +8935,7 @@ var SvgCanvas = (function () {
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.includes(elem.tagName)) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
} else if (elem.tagName === 'rect') {
// Look for radius
@@ -8943,7 +8943,7 @@ var SvgCanvas = (function () {
var ry = elem.getAttribute('ry');
if (rx || ry) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
}
}
@@ -9000,7 +9000,7 @@ var SvgCanvas = (function () {
*/
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) {
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) {
if (!elems || !elems.length) {
return false;
}
@@ -9015,7 +9015,7 @@ var SvgCanvas = (function () {
return;
}
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1);
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);
}); // This shouldn't ever happen...
if (fullBb === undefined) {
@@ -9037,7 +9037,7 @@ var SvgCanvas = (function () {
maxY += offset;
} else {
$$2.each(elems, function (i, elem) {
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1);
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);
if (curBb) {
var _offset = getStrokeOffsetForBBox(elem);
@@ -10546,7 +10546,7 @@ var SvgCanvas = (function () {
}, {
key: "copyElem",
value: function copyElem$$1(el) {
value: function copyElem$1(el) {
var that = this;
var getNextIdClosure = function getNextIdClosure() {
@@ -10947,7 +10947,13 @@ var SvgCanvas = (function () {
canvas_.call('contextset', canvas_.getCurrentGroup());
};
var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support
var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent
/**
* This defines which elements and attributes that we support (or at least
* don't remove)
* @type {PlainObject}
*/
var svgWhiteList_ = {
// SVG Elements
@@ -10959,6 +10965,7 @@ var SvgCanvas = (function () {
desc: [],
ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],
feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],
feMorphology: ['class', 'in', 'operator', 'radius'],
filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],
foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],
g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],
@@ -11834,7 +11841,7 @@ var SvgCanvas = (function () {
* @returns {undefined}
*/
var init$5 = function init$$1(editorContext) {
var init$5 = function init(editorContext) {
context_ = editorContext;
};
/**
@@ -12149,6 +12156,7 @@ var SvgCanvas = (function () {
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
@@ -12156,6 +12164,7 @@ var SvgCanvas = (function () {
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@@ -12180,6 +12189,9 @@ var SvgCanvas = (function () {
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@@ -13600,7 +13612,7 @@ var SvgCanvas = (function () {
return selectedElements;
};
var pathActions$$1 = pathActions;
var pathActions$1 = pathActions;
/**
* This should actually be an intersection as all interfaces should be met.
* @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}
@@ -13615,7 +13627,7 @@ var SvgCanvas = (function () {
* @implements {module:utilities.EditorContext}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
// Ok since not modifying
getSVGContent: getSVGContent,
addSVGElementFromJson: addSVGElementFromJson,
@@ -14031,13 +14043,13 @@ var SvgCanvas = (function () {
*/
canvas.pathActions = pathActions$$1;
canvas.pathActions = pathActions$1;
/**
* @implements {module:path.EditorContext#resetD}
*/
function resetD(p) {
p.setAttribute('d', pathActions$$1.convertPath(p));
p.setAttribute('d', pathActions$1.convertPath(p));
}
init$1(
@@ -14086,8 +14098,8 @@ var SvgCanvas = (function () {
var closedSubpath = _ref.closedSubpath,
grips = _ref.grips;
// TODO: Correct this:
pathActions$$1.canDeleteNodes = true;
pathActions$$1.closed_subpath = closedSubpath;
pathActions$1.canDeleteNodes = true;
pathActions$1.closed_subpath = closedSubpath;
call('pointsAdded', {
closedSubpath: closedSubpath,
grips: grips
@@ -14789,9 +14801,9 @@ var SvgCanvas = (function () {
var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path'));
paths.forEach(function (path$$1) {
path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1));
pathActions$$1.fixEnd(path$$1);
paths.forEach(function (path) {
path.setAttribute('d', pathActions$1.convertPath(path));
pathActions$1.fixEnd(path);
});
};
/**
@@ -15169,7 +15181,7 @@ var SvgCanvas = (function () {
addToSelection([mouseTarget]);
justSelected = mouseTarget;
pathActions$$1.clear();
pathActions$1.clear();
} // else if it's a path, go into pathedit mode in mouseup
@@ -15267,12 +15279,11 @@ var SvgCanvas = (function () {
if (iswebkit) {
delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttribute('stroke');
var stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () {
ele.setAttribute('stroke', _stroke);
if (stroke_ !== null) setTimeout(function () {
ele.setAttribute('stroke', stroke_);
}, 0);
};
}
@@ -15459,7 +15470,7 @@ var SvgCanvas = (function () {
case 'pathedit':
startX *= currentZoom;
startY *= currentZoom;
pathActions$$1.mouseDown(evt, mouseTarget, startX, startY);
pathActions$1.mouseDown(evt, mouseTarget, startX, startY);
started = true;
break;
@@ -15949,12 +15960,12 @@ var SvgCanvas = (function () {
}
if (evt.shiftKey) {
var path$$1 = path;
var path$1 = path;
var x1, y1;
if (path$$1) {
x1 = path$$1.dragging ? path$$1.dragging[0] : startX;
y1 = path$$1.dragging ? path$$1.dragging[1] : startY;
if (path$1) {
x1 = path$1.dragging ? path$1.dragging[0] : startX;
y1 = path$1.dragging ? path$1.dragging[1] : startY;
} else {
x1 = startX;
y1 = startY;
@@ -15977,7 +15988,7 @@ var SvgCanvas = (function () {
}, 100);
}
pathActions$$1.mouseMove(x, y);
pathActions$1.mouseMove(x, y);
break;
}
@@ -16154,7 +16165,7 @@ var SvgCanvas = (function () {
t = evt.target;
if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {
pathActions$$1.select(selectedElements[0]); // if it was a path
pathActions$1.select(selectedElements[0]); // if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if (evt.shiftKey) {
if (tempJustSelected !== t) {
@@ -16229,7 +16240,7 @@ var SvgCanvas = (function () {
}
if (keep) {
element = pathActions$$1.smoothPolylineIntoPath(element);
element = pathActions$1.smoothPolylineIntoPath(element);
}
break;
@@ -16308,7 +16319,7 @@ var SvgCanvas = (function () {
element = null; // continue to be set to true so that mouseMove happens
started = true;
var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY);
var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY);
element = res.element;
keep = res.keep;
break;
@@ -16317,7 +16328,7 @@ var SvgCanvas = (function () {
case 'pathedit':
keep = true;
element = null;
pathActions$$1.mouseUp(evt);
pathActions$1.mouseUp(evt);
break;
case 'textedit':
@@ -16428,7 +16439,7 @@ var SvgCanvas = (function () {
cleanupElement(element);
if (currentMode === 'path') {
pathActions$$1.toEditMode(element);
pathActions$1.toEditMode(element);
} else if (curConfig.selectNew) {
selectOnly([element], true);
} // we create the insert command that is stored on the stack
@@ -17035,7 +17046,7 @@ var SvgCanvas = (function () {
* @param {Element} inputElem Not in use
* @returns {undefined}
*/
init: function init$$1(inputElem) {
init: function init(inputElem) {
if (!curtext) {
return;
}
@@ -17178,7 +17189,7 @@ var SvgCanvas = (function () {
while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty
pathActions$$1.clear(true); // Keep SVG-Edit comment on top
pathActions$1.clear(true); // Keep SVG-Edit comment on top
$$8.each(svgcontent.childNodes, function (i, node) {
if (i && node.nodeType === 8 && node.data.includes('Created with')) {
@@ -17345,7 +17356,7 @@ var SvgCanvas = (function () {
out.push(' ');
if (_attr.localName === 'd') {
_attrVal = pathActions$$1.convertPath(elem, true);
_attrVal = pathActions$1.convertPath(elem, true);
}
if (!isNaN(_attrVal)) {
@@ -18574,7 +18585,7 @@ var SvgCanvas = (function () {
* @implements {module:draw.DrawCanvasInit}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
getCurrentGroup: function getCurrentGroup() {
return currentGroup;
},
@@ -18610,7 +18621,7 @@ var SvgCanvas = (function () {
*/
this.clear = function () {
pathActions$$1.clear();
pathActions$1.clear();
clearSelection(); // clear the svgcontent node
canvas.clearSvgContentElement(); // create new document
@@ -18628,7 +18639,7 @@ var SvgCanvas = (function () {
}; // Alias function
this.linkControlPoints = pathActions$$1.linkControlPoints;
this.linkControlPoints = pathActions$1.linkControlPoints;
/**
* @function module:svgcanvas.SvgCanvas#getContentElem
* @returns {Element} The content DOM element
@@ -19119,7 +19130,7 @@ var SvgCanvas = (function () {
selectorManager.requestSelector(elem).resize();
});
pathActions$$1.zoomChange();
pathActions$1.zoomChange();
runExtensions('zoomChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */
zoomLevel);
@@ -19142,7 +19153,7 @@ var SvgCanvas = (function () {
this.setMode = function (name) {
pathActions$$1.clear(true);
pathActions$1.clear(true);
textActions.clear();
curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape;
currentMode = name;
@@ -20033,7 +20044,7 @@ var SvgCanvas = (function () {
this.setSegType = function (newType) {
pathActions$$1.setSegType(newType);
pathActions$1.setSegType(newType);
};
/**
* Convert selected element to a path, or get the BBox of an element-as-path.
@@ -20046,7 +20057,7 @@ var SvgCanvas = (function () {
*/
this.convertToPath = function (elem, getBBox$$1) {
this.convertToPath = function (elem, getBBox) {
if (isNullish(elem)) {
var elems = selectedElements;
$$8.each(elems, function (i, el) {
@@ -20057,8 +20068,8 @@ var SvgCanvas = (function () {
return undefined;
}
if (getBBox$$1) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
if (getBBox) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1);
} // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
@@ -20075,7 +20086,7 @@ var SvgCanvas = (function () {
opacity: curShape.opacity,
visibility: 'hidden'
};
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory);
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory);
};
/**
* This function makes the changes to the elements. It does not add the change
@@ -20090,7 +20101,7 @@ var SvgCanvas = (function () {
var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) {
if (currentMode === 'pathedit') {
// Editing node
pathActions$$1.moveNode(attr, newValue);
pathActions$1.moveNode(attr, newValue);
}
elems = elems || selectedElements;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
/* eslint-disable new-cap, class-methods-use-this */
/* eslint-disable new-cap, class-methods-use-this, @mysticatea/no-use-ignored-vars */
// Todo: Compare with latest canvg (add any improvements of ours) and add full JSDocs (denoting links to standard APIs and which are custom): https://github.com/canvg/canvg
/**
* canvg.js - Javascript SVG parser and renderer on Canvas
@@ -2364,8 +2364,10 @@ function build (opts) {
[...node.childNodes].forEach(({nodeValue}) => {
css += nodeValue;
});
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
css = svg.compressSpaces(css); // replace whitespace
// remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);
const cssDefs = css.split('}');
cssDefs.forEach((cssDef) => {
if (svg.trim(cssDef) !== '') {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-bitwise */
/**
* jPicker (Adapted from version 1.1.6)
*
@@ -96,7 +97,7 @@ const jPicker = function ($) {
*/
function mouseDown (e) {
const off = bar.offset();
offset = {l: off.left | 0, t: off.top | 0}; // eslint-disable-line no-bitwise
offset = {l: off.left | 0, t: off.top | 0};
clearTimeout(timeout);
// using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
timeout = setTimeout(function () {
@@ -165,7 +166,6 @@ const jPicker = function ($) {
let arrowOffsetX = 0,
arrowOffsetY = 0;
setTimeout(function () {
/* eslint-disable no-bitwise */
if (rangeX > 0) { // range is greater than zero
// constrain to bounds
if (x === maxX) arrowOffsetX = barW;
@@ -184,7 +184,6 @@ const jPicker = function ($) {
else arrowOffsetY -= arrowH >> 1;
// set the arrow position based on these offsets
arrow.css({left: arrowOffsetX + 'px', top: arrowOffsetY + 'px'});
/* eslint no-bitwise: ["error"] */
});
}
@@ -287,7 +286,6 @@ const jPicker = function ($) {
newMinY,
newMaxY;
if (isNullish(name)) name = 'all';
/* eslint-disable no-bitwise */
switch (name.toLowerCase()) {
case 'minx':
newMinX = (value && ((value.minX && value.minX | 0) || value | 0)) || 0;
@@ -318,7 +316,6 @@ const jPicker = function ($) {
break;
}
/* eslint no-bitwise: ["error"] */
if (!isNullish(newMinX) && minX !== newMinX) {
minX = newMinX;
rangeX = maxX - minX;

View File

@@ -57,7 +57,7 @@ const removeAttributes = function (node, attributes) {
});
};
const numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+)?/g;
const numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+|)/g;
const getLinesOptionsOfPoly = function (node) {
let nums = node.getAttribute('points');
nums = (nums && nums.match(numRgx)) || [];

View File

@@ -1890,10 +1890,10 @@ const mouseDown = function (evt) {
let delayedStroke;
if (iswebkit) {
delayedStroke = function (ele) {
const _stroke = ele.getAttribute('stroke');
const stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke');
// Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { ele.setAttribute('stroke', _stroke); }, 0);
if (stroke_ !== null) setTimeout(function () { ele.setAttribute('stroke', stroke_); }, 0);
};
}
mouseTarget.style.vectorEffect = 'non-scaling-stroke';

View File

@@ -5122,7 +5122,7 @@
* @returns {undefined}
*/
var init$1 = function init$$1(editorContext) {
var init$1 = function init(editorContext) {
editorContext_ = editorContext;
pathFuncs = [0, 'ClosePath'];
var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'];
@@ -5847,7 +5847,7 @@
_createClass(Path, [{
key: "init",
value: function init$$1() {
value: function init() {
// Hide all grips, etc
// fixed, needed to work on all found elements, not just first
$$1(getGripContainer()).find('*').each(function () {
@@ -7937,7 +7937,7 @@
* @returns {undefined}
*/
var init$2 = function init$$1(editorContext) {
var init$2 = function init(editorContext) {
editorContext_$1 = editorContext;
domdoc_ = editorContext.getDOMDocument();
domcontainer_ = editorContext.getDOMContainer();
@@ -8326,8 +8326,8 @@
* @returns {module:utilities.BBoxObject} A BBox-like object
*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var getPathBBox = function getPathBBox(path) {
var seglist = path.pathSegList;
var tot = seglist.numberOfItems;
var bounds = [[], []];
var start = seglist.getItem(0);
@@ -8710,43 +8710,43 @@
* @returns {DOMRect|false} The resulting path's bounding box object.
*/
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) {
var path$$1 = addSVGElementFromJson({
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) {
var path = addSVGElementFromJson({
element: 'path',
attr: getExtraAttributesForConvertToPath(elem)
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d);
path.setAttribute('d', d);
} else {
path$$1.remove();
path.remove();
} // Get the correct BBox of the new path, then discard it
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
var bb = false;
try {
bb = path$$1.getBBox();
bb = path.getBBox();
} catch (e) {// Firefox fails
}
path$$1.remove();
path.remove();
return bb;
};
/**
@@ -8763,57 +8763,57 @@
* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.
*/
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) {
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) {
var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes
attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem));
var path$$1 = addSVGElementFromJson({
var path = addSVGElementFromJson({
element: 'path',
attr: attrs
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var id = elem.id;
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d); // Replace the current element with the converted one
path.setAttribute('d', d); // Replace the current element with the converted one
// Reorient if it has a matrix
if (eltrans) {
var tlist = getTransformList(path$$1);
var tlist = getTransformList(path);
if (hasMatrixTransform(tlist)) {
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
}
}
var nextSibling = elem.nextSibling;
batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path));
clearSelection();
elem.remove();
path$$1.setAttribute('id', id);
path$$1.removeAttribute('visibility');
addToSelection([path$$1], true);
path.setAttribute('id', id);
path.removeAttribute('visibility');
addToSelection([path], true);
addCommandToHistory(batchCmd);
return path$$1;
return path;
} // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything.
path$$1.remove();
path.remove();
return null;
};
/**
@@ -8853,7 +8853,7 @@
*/
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) {
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
@@ -8876,7 +8876,7 @@
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.includes(elem.tagName)) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
} else if (elem.tagName === 'rect') {
// Look for radius
@@ -8884,7 +8884,7 @@
var ry = elem.getAttribute('ry');
if (rx || ry) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
}
}
@@ -8941,7 +8941,7 @@
*/
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) {
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) {
if (!elems || !elems.length) {
return false;
}
@@ -8956,7 +8956,7 @@
return;
}
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1);
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);
}); // This shouldn't ever happen...
if (fullBb === undefined) {
@@ -8978,7 +8978,7 @@
maxY += offset;
} else {
$$2.each(elems, function (i, elem) {
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1);
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);
if (curBb) {
var _offset = getStrokeOffsetForBBox(elem);
@@ -10982,7 +10982,7 @@
}, {
key: "copyElem",
value: function copyElem$$1(el) {
value: function copyElem$1(el) {
var that = this;
var getNextIdClosure = function getNextIdClosure() {
@@ -11383,7 +11383,13 @@
canvas_.call('contextset', canvas_.getCurrentGroup());
};
var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support
var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent
/**
* This defines which elements and attributes that we support (or at least
* don't remove)
* @type {PlainObject}
*/
var svgWhiteList_ = {
// SVG Elements
@@ -11395,6 +11401,7 @@
desc: [],
ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],
feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],
feMorphology: ['class', 'in', 'operator', 'radius'],
filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],
foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],
g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],
@@ -12059,7 +12066,7 @@
* @returns {undefined}
*/
var init$5 = function init$$1(editorContext) {
var init$5 = function init(editorContext) {
context_ = editorContext;
};
/**
@@ -12374,6 +12381,7 @@
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
@@ -12381,6 +12389,7 @@
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@@ -12405,6 +12414,9 @@
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@@ -13825,7 +13837,7 @@
return selectedElements;
};
var pathActions$$1 = pathActions;
var pathActions$1 = pathActions;
/**
* This should actually be an intersection as all interfaces should be met.
* @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}
@@ -13840,7 +13852,7 @@
* @implements {module:utilities.EditorContext}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
// Ok since not modifying
getSVGContent: getSVGContent,
addSVGElementFromJson: addSVGElementFromJson,
@@ -14256,13 +14268,13 @@
*/
canvas.pathActions = pathActions$$1;
canvas.pathActions = pathActions$1;
/**
* @implements {module:path.EditorContext#resetD}
*/
function resetD(p) {
p.setAttribute('d', pathActions$$1.convertPath(p));
p.setAttribute('d', pathActions$1.convertPath(p));
}
init$1(
@@ -14311,8 +14323,8 @@
var closedSubpath = _ref.closedSubpath,
grips = _ref.grips;
// TODO: Correct this:
pathActions$$1.canDeleteNodes = true;
pathActions$$1.closed_subpath = closedSubpath;
pathActions$1.canDeleteNodes = true;
pathActions$1.closed_subpath = closedSubpath;
call('pointsAdded', {
closedSubpath: closedSubpath,
grips: grips
@@ -15014,9 +15026,9 @@
var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path'));
paths.forEach(function (path$$1) {
path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1));
pathActions$$1.fixEnd(path$$1);
paths.forEach(function (path) {
path.setAttribute('d', pathActions$1.convertPath(path));
pathActions$1.fixEnd(path);
});
};
/**
@@ -15394,7 +15406,7 @@
addToSelection([mouseTarget]);
justSelected = mouseTarget;
pathActions$$1.clear();
pathActions$1.clear();
} // else if it's a path, go into pathedit mode in mouseup
@@ -15492,12 +15504,11 @@
if (iswebkit) {
delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttribute('stroke');
var stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () {
ele.setAttribute('stroke', _stroke);
if (stroke_ !== null) setTimeout(function () {
ele.setAttribute('stroke', stroke_);
}, 0);
};
}
@@ -15684,7 +15695,7 @@
case 'pathedit':
startX *= currentZoom;
startY *= currentZoom;
pathActions$$1.mouseDown(evt, mouseTarget, startX, startY);
pathActions$1.mouseDown(evt, mouseTarget, startX, startY);
started = true;
break;
@@ -16174,12 +16185,12 @@
}
if (evt.shiftKey) {
var path$$1 = path;
var path$1 = path;
var x1, y1;
if (path$$1) {
x1 = path$$1.dragging ? path$$1.dragging[0] : startX;
y1 = path$$1.dragging ? path$$1.dragging[1] : startY;
if (path$1) {
x1 = path$1.dragging ? path$1.dragging[0] : startX;
y1 = path$1.dragging ? path$1.dragging[1] : startY;
} else {
x1 = startX;
y1 = startY;
@@ -16202,7 +16213,7 @@
}, 100);
}
pathActions$$1.mouseMove(x, y);
pathActions$1.mouseMove(x, y);
break;
}
@@ -16379,7 +16390,7 @@
t = evt.target;
if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {
pathActions$$1.select(selectedElements[0]); // if it was a path
pathActions$1.select(selectedElements[0]); // if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if (evt.shiftKey) {
if (tempJustSelected !== t) {
@@ -16454,7 +16465,7 @@
}
if (keep) {
element = pathActions$$1.smoothPolylineIntoPath(element);
element = pathActions$1.smoothPolylineIntoPath(element);
}
break;
@@ -16533,7 +16544,7 @@
element = null; // continue to be set to true so that mouseMove happens
started = true;
var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY);
var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY);
element = res.element;
keep = res.keep;
break;
@@ -16542,7 +16553,7 @@
case 'pathedit':
keep = true;
element = null;
pathActions$$1.mouseUp(evt);
pathActions$1.mouseUp(evt);
break;
case 'textedit':
@@ -16653,7 +16664,7 @@
cleanupElement(element);
if (currentMode === 'path') {
pathActions$$1.toEditMode(element);
pathActions$1.toEditMode(element);
} else if (curConfig.selectNew) {
selectOnly([element], true);
} // we create the insert command that is stored on the stack
@@ -17260,7 +17271,7 @@
* @param {Element} inputElem Not in use
* @returns {undefined}
*/
init: function init$$1(inputElem) {
init: function init(inputElem) {
if (!curtext) {
return;
}
@@ -17403,7 +17414,7 @@
while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty
pathActions$$1.clear(true); // Keep SVG-Edit comment on top
pathActions$1.clear(true); // Keep SVG-Edit comment on top
$$9.each(svgcontent.childNodes, function (i, node) {
if (i && node.nodeType === 8 && node.data.includes('Created with')) {
@@ -17570,7 +17581,7 @@
out.push(' ');
if (_attr.localName === 'd') {
_attrVal = pathActions$$1.convertPath(elem, true);
_attrVal = pathActions$1.convertPath(elem, true);
}
if (!isNaN(_attrVal)) {
@@ -18799,7 +18810,7 @@
* @implements {module:draw.DrawCanvasInit}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
getCurrentGroup: function getCurrentGroup() {
return currentGroup;
},
@@ -18835,7 +18846,7 @@
*/
this.clear = function () {
pathActions$$1.clear();
pathActions$1.clear();
clearSelection(); // clear the svgcontent node
canvas.clearSvgContentElement(); // create new document
@@ -18853,7 +18864,7 @@
}; // Alias function
this.linkControlPoints = pathActions$$1.linkControlPoints;
this.linkControlPoints = pathActions$1.linkControlPoints;
/**
* @function module:svgcanvas.SvgCanvas#getContentElem
* @returns {Element} The content DOM element
@@ -19344,7 +19355,7 @@
selectorManager.requestSelector(elem).resize();
});
pathActions$$1.zoomChange();
pathActions$1.zoomChange();
runExtensions('zoomChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */
zoomLevel);
@@ -19367,7 +19378,7 @@
this.setMode = function (name) {
pathActions$$1.clear(true);
pathActions$1.clear(true);
textActions.clear();
curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape;
currentMode = name;
@@ -20258,7 +20269,7 @@
this.setSegType = function (newType) {
pathActions$$1.setSegType(newType);
pathActions$1.setSegType(newType);
};
/**
* Convert selected element to a path, or get the BBox of an element-as-path.
@@ -20271,7 +20282,7 @@
*/
this.convertToPath = function (elem, getBBox$$1) {
this.convertToPath = function (elem, getBBox) {
if (isNullish(elem)) {
var elems = selectedElements;
$$9.each(elems, function (i, el) {
@@ -20282,8 +20293,8 @@
return undefined;
}
if (getBBox$$1) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
if (getBBox) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1);
} // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
@@ -20300,7 +20311,7 @@
opacity: curShape.opacity,
visibility: 'hidden'
};
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory);
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory);
};
/**
* This function makes the changes to the elements. It does not add the change
@@ -20315,7 +20326,7 @@
var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) {
if (currentMode === 'pathedit') {
// Editing node
pathActions$$1.moveNode(attr, newValue);
pathActions$1.moveNode(attr, newValue);
}
elems = elems || selectedElements;
@@ -24665,6 +24676,8 @@
return $;
}
/* eslint-disable no-bitwise */
/**
* jPicker (Adapted from version 1.1.6)
*
@@ -24776,8 +24789,7 @@
offset = {
l: off.left | 0,
t: off.top | 0
}; // eslint-disable-line no-bitwise
};
clearTimeout(timeout); // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
timeout = setTimeout(function () {
@@ -24851,7 +24863,6 @@
var arrowOffsetX = 0,
arrowOffsetY = 0;
setTimeout(function () {
/* eslint-disable no-bitwise */
if (rangeX > 0) {
// range is greater than zero
// constrain to bounds
@@ -24874,7 +24885,6 @@
left: arrowOffsetX + 'px',
top: arrowOffsetY + 'px'
});
/* eslint no-bitwise: ["error"] */
});
}
/**
@@ -25025,7 +25035,6 @@
var // changed = false,
newMinX, newMaxX, newMinY, newMaxY;
if (isNullish$1(name)) name = 'all';
/* eslint-disable no-bitwise */
switch (name.toLowerCase()) {
case 'minx':
@@ -25062,8 +25071,6 @@
newMaxY = value && value.maxY && value.maxY | 0 || 0;
break;
}
/* eslint no-bitwise: ["error"] */
if (!isNullish$1(newMinX) && minX !== newMinX) {
minX = newMinX;
@@ -29424,7 +29431,7 @@
var _ref6 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, name, init$$1, importLocale;
var extName, url, imported, _imported$name, name, init, importLocale;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
@@ -29458,12 +29465,12 @@
case 7:
imported = _context2.sent;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init$$1 = imported.init;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init;
importLocale = getImportLocale({
defaultLang: langParam,
defaultName: name
});
return _context2.abrupt("return", editor.addExtension(name, init$$1 && init$$1.bind(editor), {
return _context2.abrupt("return", editor.addExtension(name, init && init.bind(editor), {
$: $$b,
importLocale: importLocale
}));
@@ -33280,7 +33287,7 @@
*/
var convertToPath$$1 = function convertToPath$$1() {
var convertToPath = function convertToPath() {
if (!isNullish(selectedElement)) {
svgCanvas.convertToPath();
}
@@ -35116,7 +35123,7 @@
key: 'ctrl+shift+['
}, {
sel: '#tool_topath',
fn: convertToPath$$1,
fn: convertToPath,
evt: 'click'
}, {
sel: '#tool_make_link,#tool_make_link_multi',
@@ -36389,7 +36396,7 @@
*/
editor.addExtension = function (name, init$$1, initArgs) {
editor.addExtension = function (name, init, initArgs) {
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
@@ -36397,7 +36404,7 @@
throw new Error('Extension added too early');
}
return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
return svgCanvas.addExtension.call(this, name, init, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu.

2273
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -76,30 +76,32 @@
],
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/node": "^7.2.0",
"@babel/core": "^7.3.3",
"@babel/node": "^7.2.2",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@mysticatea/eslint-plugin": "^9.0.1",
"axe-testcafe": "^1.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"eslint": "5.10.0",
"eslint-config-ash-nazg": "0.3.0",
"eslint": "5.14.1",
"eslint-config-ash-nazg": "0.4.4",
"eslint-config-standard": "12.0.0",
"eslint-plugin-compat": "2.6.3",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsdoc": "^3.14.0",
"eslint-plugin-markdown": "^1.0.0-rc.0",
"eslint-plugin-no-use-extend-native": "^0.3.12",
"eslint-plugin-node": "8.0.0",
"eslint-plugin-compat": "2.7.0",
"eslint-plugin-eslint-comments": "^3.1.1",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-jsdoc": "^4.1.0",
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-no-use-extend-native": "^0.4.0",
"eslint-plugin-node": "8.0.1",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-qunit": "^4.0.0",
"eslint-plugin-standard": "4.0.0",
"eslint-plugin-testcafe": "^0.2.1",
"eslint-plugin-unicorn": "^6.0.1",
"eslint-plugin-unicorn": "^7.1.0",
"find-in-files": "^0.5.0",
"imageoptim-cli": "^2.0.4",
"jamilih": "^0.43.0",
"imageoptim-cli": "^2.3.5",
"jamilih": "^0.44.0",
"jsdoc": "^3.5.5",
"load-stylesheets": "^0.7.0",
"node-static": "^0.7.11",
@@ -107,20 +109,20 @@
"promise-fs": "^2.0.1",
"qr-manipulation": "https://github.com/brettz9/qr-manipulation",
"query-result": "https://github.com/WebReflection/query-result",
"qunit": "^2.8.0",
"qunit": "^2.9.1",
"remark-cli": "^6.0.1",
"remark-lint-ordered-list-marker-value": "^1.0.2",
"rollup": "0.67.4",
"rollup-plugin-babel": "^4.1.0",
"rollup": "1.2.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^3.0.0",
"sinon": "^7.2.2",
"rollup-plugin-terser": "^4.0.4",
"sinon": "^7.2.4",
"sinon-test": "^2.4.0",
"stackblur-canvas": "^2.2.0",
"testcafe": "^0.23.2"
"testcafe": "^1.0.1"
}
}

View File

@@ -52,3 +52,4 @@ export default [
plugins
}
];
/* eslint-enable import/no-anonymous-default-export */

View File

@@ -5122,7 +5122,7 @@
* @returns {undefined}
*/
var init$1 = function init$$1(editorContext) {
var init$1 = function init(editorContext) {
editorContext_ = editorContext;
pathFuncs = [0, 'ClosePath'];
var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical', 'CurvetoCubicSmooth', 'CurvetoQuadraticSmooth'];
@@ -5847,7 +5847,7 @@
_createClass(Path, [{
key: "init",
value: function init$$1() {
value: function init() {
// Hide all grips, etc
// fixed, needed to work on all found elements, not just first
$$1(getGripContainer()).find('*').each(function () {
@@ -7937,7 +7937,7 @@
* @returns {undefined}
*/
var init$2 = function init$$1(editorContext) {
var init$2 = function init(editorContext) {
editorContext_$1 = editorContext;
domdoc_ = editorContext.getDOMDocument();
domcontainer_ = editorContext.getDOMContainer();
@@ -8326,8 +8326,8 @@
* @returns {module:utilities.BBoxObject} A BBox-like object
*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var getPathBBox = function getPathBBox(path) {
var seglist = path.pathSegList;
var tot = seglist.numberOfItems;
var bounds = [[], []];
var start = seglist.getItem(0);
@@ -8710,43 +8710,43 @@
* @returns {DOMRect|false} The resulting path's bounding box object.
*/
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1) {
var path$$1 = addSVGElementFromJson({
var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) {
var path = addSVGElementFromJson({
element: 'path',
attr: getExtraAttributesForConvertToPath(elem)
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d);
path.setAttribute('d', d);
} else {
path$$1.remove();
path.remove();
} // Get the correct BBox of the new path, then discard it
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
var bb = false;
try {
bb = path$$1.getBBox();
bb = path.getBBox();
} catch (e) {// Firefox fails
}
path$$1.remove();
path.remove();
return bb;
};
/**
@@ -8763,57 +8763,57 @@
* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized.
*/
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory) {
var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) {
var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes
attrs = $$2.extend({}, attrs, getExtraAttributesForConvertToPath(elem));
var path$$1 = addSVGElementFromJson({
var path = addSVGElementFromJson({
element: 'path',
attr: attrs
});
var eltrans = elem.getAttribute('transform');
if (eltrans) {
path$$1.setAttribute('transform', eltrans);
path.setAttribute('transform', eltrans);
}
var id = elem.id;
var parentNode = elem.parentNode;
if (elem.nextSibling) {
elem.before(path$$1);
elem.before(path);
} else {
parentNode.append(path$$1);
parentNode.append(path);
}
var d = getPathDFromElement(elem);
if (d) {
path$$1.setAttribute('d', d); // Replace the current element with the converted one
path.setAttribute('d', d); // Replace the current element with the converted one
// Reorient if it has a matrix
if (eltrans) {
var tlist = getTransformList(path$$1);
var tlist = getTransformList(path);
if (hasMatrixTransform(tlist)) {
pathActions$$1.resetOrientation(path$$1);
pathActions.resetOrientation(path);
}
}
var nextSibling = elem.nextSibling;
batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path$$1));
batchCmd.addSubCommand(new hstry.InsertElementCommand(path));
clearSelection();
elem.remove();
path$$1.setAttribute('id', id);
path$$1.removeAttribute('visibility');
addToSelection([path$$1], true);
path.setAttribute('id', id);
path.removeAttribute('visibility');
addToSelection([path], true);
addCommandToHistory(batchCmd);
return path$$1;
return path;
} // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything.
path$$1.remove();
path.remove();
return null;
};
/**
@@ -8853,7 +8853,7 @@
*/
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1) {
var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) {
// TODO: Fix issue with rotated groups. Currently they work
// fine in FF, but not in other browsers (same problem mentioned
// in Issue 339 comment #2).
@@ -8876,7 +8876,7 @@
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.includes(elem.tagName)) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
} else if (elem.tagName === 'rect') {
// Look for radius
@@ -8884,7 +8884,7 @@
var ry = elem.getAttribute('ry');
if (rx || ry) {
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions);
bb = goodBb;
}
}
@@ -8941,7 +8941,7 @@
*/
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions$$1) {
var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) {
if (!elems || !elems.length) {
return false;
}
@@ -8956,7 +8956,7 @@
return;
}
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions$$1);
fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions);
}); // This shouldn't ever happen...
if (fullBb === undefined) {
@@ -8978,7 +8978,7 @@
maxY += offset;
} else {
$$2.each(elems, function (i, elem) {
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions$$1);
var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions);
if (curBb) {
var _offset = getStrokeOffsetForBBox(elem);
@@ -10982,7 +10982,7 @@
}, {
key: "copyElem",
value: function copyElem$$1(el) {
value: function copyElem$1(el) {
var that = this;
var getNextIdClosure = function getNextIdClosure() {
@@ -11383,7 +11383,13 @@
canvas_.call('contextset', canvas_.getCurrentGroup());
};
var REVERSE_NS = getReverseNS(); // this defines which elements and attributes that we support
var REVERSE_NS = getReverseNS(); // Todo: Split out into core attributes, presentation attributes, etc. so consistent
/**
* This defines which elements and attributes that we support (or at least
* don't remove)
* @type {PlainObject}
*/
var svgWhiteList_ = {
// SVG Elements
@@ -11395,6 +11401,7 @@
desc: [],
ellipse: ['class', 'clip-path', 'clip-rule', 'cx', 'cy', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform'],
feGaussianBlur: ['class', 'color-interpolation-filters', 'id', 'requiredFeatures', 'stdDeviation'],
feMorphology: ['class', 'in', 'operator', 'radius'],
filter: ['class', 'color-interpolation-filters', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'requiredFeatures', 'width', 'x', 'xlink:href', 'y'],
foreignObject: ['class', 'font-size', 'height', 'id', 'opacity', 'requiredFeatures', 'style', 'transform', 'width', 'x', 'y'],
g: ['class', 'clip-path', 'clip-rule', 'id', 'display', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-anchor'],
@@ -12059,7 +12066,7 @@
* @returns {undefined}
*/
var init$5 = function init$$1(editorContext) {
var init$5 = function init(editorContext) {
context_ = editorContext;
};
/**
@@ -12374,6 +12381,7 @@
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
@@ -12381,6 +12389,7 @@
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@@ -12405,6 +12414,9 @@
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@@ -13825,7 +13837,7 @@
return selectedElements;
};
var pathActions$$1 = pathActions;
var pathActions$1 = pathActions;
/**
* This should actually be an intersection as all interfaces should be met.
* @implements {module:utilities.EditorContext#getSVGRoot|module:recalculate.EditorContext#getSVGRoot|module:coords.EditorContext#getSVGRoot|module:path.EditorContext#getSVGRoot}
@@ -13840,7 +13852,7 @@
* @implements {module:utilities.EditorContext}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
// Ok since not modifying
getSVGContent: getSVGContent,
addSVGElementFromJson: addSVGElementFromJson,
@@ -14256,13 +14268,13 @@
*/
canvas.pathActions = pathActions$$1;
canvas.pathActions = pathActions$1;
/**
* @implements {module:path.EditorContext#resetD}
*/
function resetD(p) {
p.setAttribute('d', pathActions$$1.convertPath(p));
p.setAttribute('d', pathActions$1.convertPath(p));
}
init$1(
@@ -14311,8 +14323,8 @@
var closedSubpath = _ref.closedSubpath,
grips = _ref.grips;
// TODO: Correct this:
pathActions$$1.canDeleteNodes = true;
pathActions$$1.closed_subpath = closedSubpath;
pathActions$1.canDeleteNodes = true;
pathActions$1.closed_subpath = closedSubpath;
call('pointsAdded', {
closedSubpath: closedSubpath,
grips: grips
@@ -15014,9 +15026,9 @@
var paths = _toConsumableArray(newDoc.getElementsByTagNameNS(NS.SVG, 'path'));
paths.forEach(function (path$$1) {
path$$1.setAttribute('d', pathActions$$1.convertPath(path$$1));
pathActions$$1.fixEnd(path$$1);
paths.forEach(function (path) {
path.setAttribute('d', pathActions$1.convertPath(path));
pathActions$1.fixEnd(path);
});
};
/**
@@ -15394,7 +15406,7 @@
addToSelection([mouseTarget]);
justSelected = mouseTarget;
pathActions$$1.clear();
pathActions$1.clear();
} // else if it's a path, go into pathedit mode in mouseup
@@ -15492,12 +15504,11 @@
if (iswebkit) {
delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttribute('stroke');
var stroke_ = ele.getAttribute('stroke');
ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () {
ele.setAttribute('stroke', _stroke);
if (stroke_ !== null) setTimeout(function () {
ele.setAttribute('stroke', stroke_);
}, 0);
};
}
@@ -15684,7 +15695,7 @@
case 'pathedit':
startX *= currentZoom;
startY *= currentZoom;
pathActions$$1.mouseDown(evt, mouseTarget, startX, startY);
pathActions$1.mouseDown(evt, mouseTarget, startX, startY);
started = true;
break;
@@ -16174,12 +16185,12 @@
}
if (evt.shiftKey) {
var path$$1 = path;
var path$1 = path;
var x1, y1;
if (path$$1) {
x1 = path$$1.dragging ? path$$1.dragging[0] : startX;
y1 = path$$1.dragging ? path$$1.dragging[1] : startY;
if (path$1) {
x1 = path$1.dragging ? path$1.dragging[0] : startX;
y1 = path$1.dragging ? path$1.dragging[1] : startY;
} else {
x1 = startX;
y1 = startY;
@@ -16202,7 +16213,7 @@
}, 100);
}
pathActions$$1.mouseMove(x, y);
pathActions$1.mouseMove(x, y);
break;
}
@@ -16379,7 +16390,7 @@
t = evt.target;
if (selectedElements[0].nodeName === 'path' && isNullish(selectedElements[1])) {
pathActions$$1.select(selectedElements[0]); // if it was a path
pathActions$1.select(selectedElements[0]); // if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if (evt.shiftKey) {
if (tempJustSelected !== t) {
@@ -16454,7 +16465,7 @@
}
if (keep) {
element = pathActions$$1.smoothPolylineIntoPath(element);
element = pathActions$1.smoothPolylineIntoPath(element);
}
break;
@@ -16533,7 +16544,7 @@
element = null; // continue to be set to true so that mouseMove happens
started = true;
var res = pathActions$$1.mouseUp(evt, element, mouseX, mouseY);
var res = pathActions$1.mouseUp(evt, element, mouseX, mouseY);
element = res.element;
keep = res.keep;
break;
@@ -16542,7 +16553,7 @@
case 'pathedit':
keep = true;
element = null;
pathActions$$1.mouseUp(evt);
pathActions$1.mouseUp(evt);
break;
case 'textedit':
@@ -16653,7 +16664,7 @@
cleanupElement(element);
if (currentMode === 'path') {
pathActions$$1.toEditMode(element);
pathActions$1.toEditMode(element);
} else if (curConfig.selectNew) {
selectOnly([element], true);
} // we create the insert command that is stored on the stack
@@ -17260,7 +17271,7 @@
* @param {Element} inputElem Not in use
* @returns {undefined}
*/
init: function init$$1(inputElem) {
init: function init(inputElem) {
if (!curtext) {
return;
}
@@ -17403,7 +17414,7 @@
while (removeUnusedDefElems() > 0) {} // eslint-disable-line no-empty
pathActions$$1.clear(true); // Keep SVG-Edit comment on top
pathActions$1.clear(true); // Keep SVG-Edit comment on top
$$9.each(svgcontent.childNodes, function (i, node) {
if (i && node.nodeType === 8 && node.data.includes('Created with')) {
@@ -17570,7 +17581,7 @@
out.push(' ');
if (_attr.localName === 'd') {
_attrVal = pathActions$$1.convertPath(elem, true);
_attrVal = pathActions$1.convertPath(elem, true);
}
if (!isNaN(_attrVal)) {
@@ -18799,7 +18810,7 @@
* @implements {module:draw.DrawCanvasInit}
*/
{
pathActions: pathActions$$1,
pathActions: pathActions$1,
getCurrentGroup: function getCurrentGroup() {
return currentGroup;
},
@@ -18835,7 +18846,7 @@
*/
this.clear = function () {
pathActions$$1.clear();
pathActions$1.clear();
clearSelection(); // clear the svgcontent node
canvas.clearSvgContentElement(); // create new document
@@ -18853,7 +18864,7 @@
}; // Alias function
this.linkControlPoints = pathActions$$1.linkControlPoints;
this.linkControlPoints = pathActions$1.linkControlPoints;
/**
* @function module:svgcanvas.SvgCanvas#getContentElem
* @returns {Element} The content DOM element
@@ -19344,7 +19355,7 @@
selectorManager.requestSelector(elem).resize();
});
pathActions$$1.zoomChange();
pathActions$1.zoomChange();
runExtensions('zoomChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-zoomChanged} */
zoomLevel);
@@ -19367,7 +19378,7 @@
this.setMode = function (name) {
pathActions$$1.clear(true);
pathActions$1.clear(true);
textActions.clear();
curProperties = selectedElements[0] && selectedElements[0].nodeName === 'text' ? curText : curShape;
currentMode = name;
@@ -20258,7 +20269,7 @@
this.setSegType = function (newType) {
pathActions$$1.setSegType(newType);
pathActions$1.setSegType(newType);
};
/**
* Convert selected element to a path, or get the BBox of an element-as-path.
@@ -20271,7 +20282,7 @@
*/
this.convertToPath = function (elem, getBBox$$1) {
this.convertToPath = function (elem, getBBox) {
if (isNullish(elem)) {
var elems = selectedElements;
$$9.each(elems, function (i, el) {
@@ -20282,8 +20293,8 @@
return undefined;
}
if (getBBox$$1) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$$1);
if (getBBox) {
return getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions$1);
} // TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
@@ -20300,7 +20311,7 @@
opacity: curShape.opacity,
visibility: 'hidden'
};
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$$1, clearSelection, addToSelection, hstry, addCommandToHistory);
return convertToPath(elem, attrs, addSVGElementFromJson, pathActions$1, clearSelection, addToSelection, hstry, addCommandToHistory);
};
/**
* This function makes the changes to the elements. It does not add the change
@@ -20315,7 +20326,7 @@
var changeSelectedAttributeNoUndo = function changeSelectedAttributeNoUndo(attr, newValue, elems) {
if (currentMode === 'pathedit') {
// Editing node
pathActions$$1.moveNode(attr, newValue);
pathActions$1.moveNode(attr, newValue);
}
elems = elems || selectedElements;
@@ -24665,6 +24676,8 @@
return $;
}
/* eslint-disable no-bitwise */
/**
* jPicker (Adapted from version 1.1.6)
*
@@ -24776,8 +24789,7 @@
offset = {
l: off.left | 0,
t: off.top | 0
}; // eslint-disable-line no-bitwise
};
clearTimeout(timeout); // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
timeout = setTimeout(function () {
@@ -24851,7 +24863,6 @@
var arrowOffsetX = 0,
arrowOffsetY = 0;
setTimeout(function () {
/* eslint-disable no-bitwise */
if (rangeX > 0) {
// range is greater than zero
// constrain to bounds
@@ -24874,7 +24885,6 @@
left: arrowOffsetX + 'px',
top: arrowOffsetY + 'px'
});
/* eslint no-bitwise: ["error"] */
});
}
/**
@@ -25025,7 +25035,6 @@
var // changed = false,
newMinX, newMaxX, newMinY, newMaxY;
if (isNullish$1(name)) name = 'all';
/* eslint-disable no-bitwise */
switch (name.toLowerCase()) {
case 'minx':
@@ -25062,8 +25071,6 @@
newMaxY = value && value.maxY && value.maxY | 0 || 0;
break;
}
/* eslint no-bitwise: ["error"] */
if (!isNullish$1(newMinX) && minX !== newMinX) {
minX = newMinX;
@@ -29424,7 +29431,7 @@
var _ref6 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, name, init$$1, importLocale;
var extName, url, imported, _imported$name, name, init, importLocale;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
@@ -29458,12 +29465,12 @@
case 7:
imported = _context2.sent;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init$$1 = imported.init;
_imported$name = imported.name, name = _imported$name === void 0 ? extName[1] : _imported$name, init = imported.init;
importLocale = getImportLocale({
defaultLang: langParam,
defaultName: name
});
return _context2.abrupt("return", editor.addExtension(name, init$$1 && init$$1.bind(editor), {
return _context2.abrupt("return", editor.addExtension(name, init && init.bind(editor), {
$: $$b,
importLocale: importLocale
}));
@@ -33280,7 +33287,7 @@
*/
var convertToPath$$1 = function convertToPath$$1() {
var convertToPath = function convertToPath() {
if (!isNullish(selectedElement)) {
svgCanvas.convertToPath();
}
@@ -35116,7 +35123,7 @@
key: 'ctrl+shift+['
}, {
sel: '#tool_topath',
fn: convertToPath$$1,
fn: convertToPath,
evt: 'click'
}, {
sel: '#tool_make_link,#tool_make_link_multi',
@@ -36389,7 +36396,7 @@
*/
editor.addExtension = function (name, init$$1, initArgs) {
editor.addExtension = function (name, init, initArgs) {
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
// $(function () {
@@ -36397,7 +36404,7 @@
throw new Error('Extension added too early');
}
return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
return svgCanvas.addExtension.call(this, name, init, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu.

View File

@@ -41,3 +41,4 @@ test('Embedded - no parameters', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
*/
/* eslint-enable qunit/no-commented-tests */