- Build: Update

- Linting: Update to-do
- Linting: Disable console inline for now to get CI passing
- npm: Update devDeps.
This commit is contained in:
Brett Zamir
2020-07-15 09:06:16 +08:00
parent e0d68671ea
commit 5c237535d5
15 changed files with 3806 additions and 4148 deletions

478
dist/index-es.js vendored
View File

@@ -169,6 +169,36 @@ function _createSuper(Derived) {
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
@@ -3616,7 +3646,7 @@ var typeMap_ = {};
* @function module:units.ElementContainer#getRoundDigits
* @returns {Integer} The number of digits number should be rounded to
*/
// Todo[eslint-plugin-jsdoc@>=29.0.0]: See if parsing fixed to allow '%'
// Todo[eslint-plugin-jsdoc@>=30.0.0]: See if parsing fixed to allow '%'
/* eslint-disable jsdoc/valid-types */
@@ -3859,8 +3889,7 @@ var HistoryEventTypes = {
AFTER_APPLY: 'after_apply',
BEFORE_UNAPPLY: 'before_unapply',
AFTER_UNAPPLY: 'after_unapply'
}; // const removedElements = {};
};
/**
* Base class for commands.
*/
@@ -3879,6 +3908,51 @@ var Command = /*#__PURE__*/function () {
value: function getText() {
return this.text;
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} applyFunction
* @returns {void}
*/
}, {
key: "apply",
value: function apply(handler, applyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
applyFunction(handler);
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} unapplyFunction
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler, unapplyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
unapplyFunction();
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
/**
* @returns {Element[]} Array with element associated with this command
* This function needs to be surcharged if multiple elements are returned.
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
}
/**
* @returns {string} String with element associated with this command
*/
}, {
key: "type",
value: function type() {
return this.constructor.name;
}
}]);
return Command;
@@ -3927,12 +4001,6 @@ var Command = /*#__PURE__*/function () {
* @returns {string}
*/
/**
* Gives the type.
* @function module:history.HistoryCommand#type
* @returns {string}
*/
/**
* @event module:history~Command#event:history
* @type {module:history.HistoryCommand}
@@ -3984,17 +4052,6 @@ var MoveElementCommand = /*#__PURE__*/function (_Command) {
_this.newParent = elem.parentNode;
return _this;
}
/**
* @returns {"svgedit.history.MoveElementCommand"}
*/
_createClass(MoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.MoveElementCommand';
}
/**
* Re-positions the element.
* @param {module:history.HistoryEventHandler} handler
@@ -4002,19 +4059,15 @@ var MoveElementCommand = /*#__PURE__*/function (_Command) {
* @returns {void}
*/
}, {
_createClass(MoveElementCommand, [{
key: "apply",
value: function apply(handler) {
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this2 = this;
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
});
}
/**
* Positions the element back to its original location.
@@ -4026,30 +4079,16 @@ var MoveElementCommand = /*#__PURE__*/function (_Command) {
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this3 = this;
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.oldNextSibling);
});
}
}]);
return MoveElementCommand;
}(Command);
MoveElementCommand.type = MoveElementCommand.prototype.type;
/**
* History command for an element that was added to the DOM.
* @implements {module:history.HistoryCommand}
@@ -4065,27 +4104,16 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) {
* @param {string} text - An optional string visible to user related to this change
*/
function InsertElementCommand(elem, text) {
var _this2;
var _this4;
_classCallCheck(this, InsertElementCommand);
_this2 = _super2.call(this);
_this2.elem = elem;
_this2.text = text || 'Create ' + elem.tagName;
_this2.parent = elem.parentNode;
_this2.nextSibling = _this2.elem.nextSibling;
return _this2;
}
/**
* @returns {"svgedit.history.InsertElementCommand"}
*/
_createClass(InsertElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.InsertElementCommand';
_this4 = _super2.call(this);
_this4.elem = elem;
_this4.text = text || 'Create ' + elem.tagName;
_this4.parent = elem.parentNode;
_this4.nextSibling = _this4.elem.nextSibling;
return _this4;
}
/**
* Re-inserts the new element.
@@ -4094,18 +4122,15 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) {
* @returns {void}
*/
}, {
_createClass(InsertElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this5 = this;
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
});
}
/**
* Removes the element.
@@ -4117,31 +4142,18 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) {
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this6 = this;
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this6.parent = _this6.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_this6.elem.remove();
});
}
}]);
return InsertElementCommand;
}(Command);
InsertElementCommand.type = InsertElementCommand.prototype.type;
/**
* History command for an element removed from the DOM.
* @implements {module:history.HistoryCommand}
@@ -4159,29 +4171,18 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) {
* @param {string} [text] - An optional string visible to user related to this change
*/
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
var _this3;
var _this7;
_classCallCheck(this, RemoveElementCommand);
_this3 = _super3.call(this);
_this3.elem = elem;
_this3.text = text || 'Delete ' + elem.tagName;
_this3.nextSibling = oldNextSibling;
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
_this7 = _super3.call(this);
_this7.elem = elem;
_this7.text = text || 'Delete ' + elem.tagName;
_this7.nextSibling = oldNextSibling;
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
removeElementFromListMap(elem);
return _this3;
}
/**
* @returns {"svgedit.history.RemoveElementCommand"}
*/
_createClass(RemoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.RemoveElementCommand';
return _this7;
}
/**
* Re-removes the new element.
@@ -4190,20 +4191,18 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) {
* @returns {void}
*/
}, {
_createClass(RemoveElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this8 = this;
removeElementFromListMap(this.elem);
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
removeElementFromListMap(_this8.elem);
_this8.parent = _this8.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_this8.elem.remove();
});
}
/**
* Re-adds the new element.
@@ -4215,38 +4214,25 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) {
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this9 = this;
removeElementFromListMap(this.elem);
_get(_getPrototypeOf(RemoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
removeElementFromListMap(_this9.elem);
if (isNullish(this.nextSibling)) {
if (isNullish(_this9.nextSibling)) {
if (window.console) {
console.log('Error: reference element was lost'); // eslint-disable-line no-console
}
}
this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
_this9.parent.insertBefore(_this9.elem, _this9.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
});
}
}]);
return RemoveElementCommand;
}(Command);
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
/**
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
*/
@@ -4272,75 +4258,62 @@ var ChangeElementCommand = /*#__PURE__*/function (_Command4) {
* @param {string} text - An optional string visible to user related to this change
*/
function ChangeElementCommand(elem, attrs, text) {
var _this4;
var _this10;
_classCallCheck(this, ChangeElementCommand);
_this4 = _super4.call(this);
_this4.elem = elem;
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this4.newValues = {};
_this4.oldValues = attrs;
_this10 = _super4.call(this);
_this10.elem = elem;
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this10.newValues = {};
_this10.oldValues = attrs;
for (var attr in attrs) {
if (attr === '#text') {
_this4.newValues[attr] = elem.textContent;
_this10.newValues[attr] = elem.textContent;
} else if (attr === '#href') {
_this4.newValues[attr] = getHref(elem);
_this10.newValues[attr] = getHref(elem);
} else {
_this4.newValues[attr] = elem.getAttribute(attr);
_this10.newValues[attr] = elem.getAttribute(attr);
}
}
return _this4;
}
/**
* @returns {"svgedit.history.ChangeElementCommand"}
*/
_createClass(ChangeElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.ChangeElementCommand';
return _this10;
}
/**
* Performs the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
_createClass(ChangeElementCommand, [{
key: "apply",
value: function apply(handler) {
var _this5 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this11 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.newValues).forEach(function (_ref) {
Object.entries(_this11.newValues).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
attr = _ref2[0],
value = _ref2[1];
if (value) {
if (attr === '#text') {
_this5.elem.textContent = value;
_this11.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this5.elem, value);
setHref(_this11.elem, value);
} else {
_this5.elem.setAttribute(attr, value);
_this11.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this5.elem.textContent = '';
_this11.elem.textContent = '';
} else {
_this5.elem.setAttribute(attr, '');
_this11.elem.setAttribute(attr, '');
_this5.elem.removeAttribute(attr);
_this11.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4349,60 +4322,53 @@ var ChangeElementCommand = /*#__PURE__*/function (_Command4) {
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this11.elem);
if (angle) {
var bbox = this.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var bbox = _this11.elem.getBBox();
var cx = bbox.x + bbox.width / 2;
var cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this11.elem.getAttribute('transform')) {
_this11.elem.setAttribute('transform', rotate);
}
}
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
return true;
});
}
/**
* Reverses the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler) {
var _this6 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this12 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.oldValues).forEach(function (_ref3) {
Object.entries(_this12.oldValues).forEach(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
attr = _ref4[0],
value = _ref4[1];
if (value) {
if (attr === '#text') {
_this6.elem.textContent = value;
_this12.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this6.elem, value);
setHref(_this12.elem, value);
} else {
_this6.elem.setAttribute(attr, value);
_this12.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this6.elem.textContent = '';
_this12.elem.textContent = '';
} else {
_this6.elem.removeAttribute(attr);
_this12.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4411,43 +4377,29 @@ var ChangeElementCommand = /*#__PURE__*/function (_Command4) {
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this12.elem);
if (angle) {
var bbox = this.elem.getBBox();
var bbox = _this12.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this12.elem.getAttribute('transform')) {
_this12.elem.setAttribute('transform', rotate);
}
}
} // Remove transformlist to prevent confusion that causes bugs like 575.
removeElementFromListMap(this.elem);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
return true;
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
removeElementFromListMap(_this12.elem);
});
}
}]);
return ChangeElementCommand;
}(Command);
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // TODO: create a 'typing' command object that tracks changes in text
}(Command); // TODO: create a 'typing' command object that tracks changes in text
// if a new Typing command is created and the top command on the stack is also a Typing
// and they both affect the same element, then collapse the two commands into one
@@ -4465,25 +4417,14 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
* @param {string} [text] - An optional string visible to user related to this change
*/
function BatchCommand(text) {
var _this7;
var _this13;
_classCallCheck(this, BatchCommand);
_this7 = _super5.call(this);
_this7.text = text || 'Batch Command';
_this7.stack = [];
return _this7;
}
/**
* @returns {"svgedit.history.BatchCommand"}
*/
_createClass(BatchCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.BatchCommand';
_this13 = _super5.call(this);
_this13.text = text || 'Batch Command';
_this13.stack = [];
return _this13;
}
/**
* Runs "apply" on all subcommands.
@@ -4492,22 +4433,19 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
* @returns {void}
*/
}, {
_createClass(BatchCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this14 = this;
var len = this.stack.length;
for (var i = 0; i < len; ++i) {
this.stack[i].apply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
_this14.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.apply(handler);
});
});
}
/**
* Runs "unapply" on all subcommands.
@@ -4519,17 +4457,15 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this15 = this;
for (var i = this.stack.length - 1; i >= 0; i--) {
this.stack[i].unapply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
_this15.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.unapply(handler);
});
});
}
/**
* Iterate through all our subcommands.
@@ -4543,6 +4479,7 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
var cmd = this.stack.length;
while (cmd--) {
if (!this.stack[cmd]) continue;
var thisElems = this.stack[cmd].elements();
var elem = thisElems.length;
@@ -4564,6 +4501,8 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
}, {
key: "addSubCommand",
value: function addSubCommand(cmd) {
// eslint-disable-next-line no-console
console.assert(cmd !== null, 'cmd should not be null');
this.stack.push(cmd);
}
/**
@@ -4579,7 +4518,6 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
return BatchCommand;
}(Command);
BatchCommand.type = BatchCommand.prototype.type;
/**
*
*/
@@ -8010,8 +7948,8 @@ var $$2 = jQueryPluginSVG(jQuery); // String used to encode base64.
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
var visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var editorContext_$1 = null;
var domdoc_ = null;
@@ -9446,6 +9384,9 @@ var copyElem = function copyElem(el, getNextId) {
var isNullish = function isNullish(val) {
return val === null || val === undefined;
};
var $q = function $q(sel) {
return document.querySelector(sel);
};
/* globals jQuery */
@@ -14210,18 +14151,18 @@ function SvgCanvas(container, config) {
var cmdType = cmd.type();
var isApply = eventType === EventTypes.AFTER_APPLY;
if (cmdType === MoveElementCommand$1.type()) {
if (cmdType === 'MoveElementCommand') {
var parent = isApply ? cmd.newParent : cmd.oldParent;
if (parent === svgcontent) {
identifyLayers();
}
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
if (cmd.parent === svgcontent) {
identifyLayers();
}
if (cmdType === InsertElementCommand$1.type()) {
if (cmdType === 'InsertElementCommand') {
if (isApply) {
restoreRefElems(cmd.elem);
}
@@ -14232,7 +14173,7 @@ function SvgCanvas(container, config) {
if (cmd.elem && cmd.elem.tagName === 'use') {
setUseData(cmd.elem);
}
} else if (cmdType === ChangeElementCommand$1.type()) {
} else if (cmdType === 'ChangeElementCommand') {
// if we are changing layer names, re-identify all layers
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
identifyLayers();
@@ -28661,6 +28602,7 @@ function loadStylesheets(stylesheets) {
}));
}
var $q$1 = $q;
var editor = {};
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
return func(jq);
@@ -35533,7 +35475,7 @@ editor.init = function () {
var btn;
if (opts.sel) {
btn = document.querySelector(opts.sel);
btn = $q$1(opts.sel);
if (btn === null) {
return true;

14
dist/index-es.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

478
dist/index-umd.js vendored
View File

@@ -175,6 +175,36 @@
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
@@ -3622,7 +3652,7 @@
* @function module:units.ElementContainer#getRoundDigits
* @returns {Integer} The number of digits number should be rounded to
*/
// Todo[eslint-plugin-jsdoc@>=29.0.0]: See if parsing fixed to allow '%'
// Todo[eslint-plugin-jsdoc@>=30.0.0]: See if parsing fixed to allow '%'
/* eslint-disable jsdoc/valid-types */
@@ -3865,8 +3895,7 @@
AFTER_APPLY: 'after_apply',
BEFORE_UNAPPLY: 'before_unapply',
AFTER_UNAPPLY: 'after_unapply'
}; // const removedElements = {};
};
/**
* Base class for commands.
*/
@@ -3885,6 +3914,51 @@
value: function getText() {
return this.text;
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} applyFunction
* @returns {void}
*/
}, {
key: "apply",
value: function apply(handler, applyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
applyFunction(handler);
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} unapplyFunction
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler, unapplyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
unapplyFunction();
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
/**
* @returns {Element[]} Array with element associated with this command
* This function needs to be surcharged if multiple elements are returned.
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
}
/**
* @returns {string} String with element associated with this command
*/
}, {
key: "type",
value: function type() {
return this.constructor.name;
}
}]);
return Command;
@@ -3933,12 +4007,6 @@
* @returns {string}
*/
/**
* Gives the type.
* @function module:history.HistoryCommand#type
* @returns {string}
*/
/**
* @event module:history~Command#event:history
* @type {module:history.HistoryCommand}
@@ -3990,17 +4058,6 @@
_this.newParent = elem.parentNode;
return _this;
}
/**
* @returns {"svgedit.history.MoveElementCommand"}
*/
_createClass(MoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.MoveElementCommand';
}
/**
* Re-positions the element.
* @param {module:history.HistoryEventHandler} handler
@@ -4008,19 +4065,15 @@
* @returns {void}
*/
}, {
_createClass(MoveElementCommand, [{
key: "apply",
value: function apply(handler) {
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this2 = this;
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
});
}
/**
* Positions the element back to its original location.
@@ -4032,30 +4085,16 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this3 = this;
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.oldNextSibling);
});
}
}]);
return MoveElementCommand;
}(Command);
MoveElementCommand.type = MoveElementCommand.prototype.type;
/**
* History command for an element that was added to the DOM.
* @implements {module:history.HistoryCommand}
@@ -4071,27 +4110,16 @@
* @param {string} text - An optional string visible to user related to this change
*/
function InsertElementCommand(elem, text) {
var _this2;
var _this4;
_classCallCheck(this, InsertElementCommand);
_this2 = _super2.call(this);
_this2.elem = elem;
_this2.text = text || 'Create ' + elem.tagName;
_this2.parent = elem.parentNode;
_this2.nextSibling = _this2.elem.nextSibling;
return _this2;
}
/**
* @returns {"svgedit.history.InsertElementCommand"}
*/
_createClass(InsertElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.InsertElementCommand';
_this4 = _super2.call(this);
_this4.elem = elem;
_this4.text = text || 'Create ' + elem.tagName;
_this4.parent = elem.parentNode;
_this4.nextSibling = _this4.elem.nextSibling;
return _this4;
}
/**
* Re-inserts the new element.
@@ -4100,18 +4128,15 @@
* @returns {void}
*/
}, {
_createClass(InsertElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this5 = this;
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
});
}
/**
* Removes the element.
@@ -4123,31 +4148,18 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this6 = this;
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this6.parent = _this6.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_this6.elem.remove();
});
}
}]);
return InsertElementCommand;
}(Command);
InsertElementCommand.type = InsertElementCommand.prototype.type;
/**
* History command for an element removed from the DOM.
* @implements {module:history.HistoryCommand}
@@ -4165,29 +4177,18 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
var _this3;
var _this7;
_classCallCheck(this, RemoveElementCommand);
_this3 = _super3.call(this);
_this3.elem = elem;
_this3.text = text || 'Delete ' + elem.tagName;
_this3.nextSibling = oldNextSibling;
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
_this7 = _super3.call(this);
_this7.elem = elem;
_this7.text = text || 'Delete ' + elem.tagName;
_this7.nextSibling = oldNextSibling;
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
removeElementFromListMap(elem);
return _this3;
}
/**
* @returns {"svgedit.history.RemoveElementCommand"}
*/
_createClass(RemoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.RemoveElementCommand';
return _this7;
}
/**
* Re-removes the new element.
@@ -4196,20 +4197,18 @@
* @returns {void}
*/
}, {
_createClass(RemoveElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this8 = this;
removeElementFromListMap(this.elem);
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
removeElementFromListMap(_this8.elem);
_this8.parent = _this8.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_this8.elem.remove();
});
}
/**
* Re-adds the new element.
@@ -4221,38 +4220,25 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this9 = this;
removeElementFromListMap(this.elem);
_get(_getPrototypeOf(RemoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
removeElementFromListMap(_this9.elem);
if (isNullish(this.nextSibling)) {
if (isNullish(_this9.nextSibling)) {
if (window.console) {
console.log('Error: reference element was lost'); // eslint-disable-line no-console
}
}
this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
_this9.parent.insertBefore(_this9.elem, _this9.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
});
}
}]);
return RemoveElementCommand;
}(Command);
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
/**
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
*/
@@ -4278,75 +4264,62 @@
* @param {string} text - An optional string visible to user related to this change
*/
function ChangeElementCommand(elem, attrs, text) {
var _this4;
var _this10;
_classCallCheck(this, ChangeElementCommand);
_this4 = _super4.call(this);
_this4.elem = elem;
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this4.newValues = {};
_this4.oldValues = attrs;
_this10 = _super4.call(this);
_this10.elem = elem;
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this10.newValues = {};
_this10.oldValues = attrs;
for (var attr in attrs) {
if (attr === '#text') {
_this4.newValues[attr] = elem.textContent;
_this10.newValues[attr] = elem.textContent;
} else if (attr === '#href') {
_this4.newValues[attr] = getHref(elem);
_this10.newValues[attr] = getHref(elem);
} else {
_this4.newValues[attr] = elem.getAttribute(attr);
_this10.newValues[attr] = elem.getAttribute(attr);
}
}
return _this4;
}
/**
* @returns {"svgedit.history.ChangeElementCommand"}
*/
_createClass(ChangeElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.ChangeElementCommand';
return _this10;
}
/**
* Performs the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
_createClass(ChangeElementCommand, [{
key: "apply",
value: function apply(handler) {
var _this5 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this11 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.newValues).forEach(function (_ref) {
Object.entries(_this11.newValues).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
attr = _ref2[0],
value = _ref2[1];
if (value) {
if (attr === '#text') {
_this5.elem.textContent = value;
_this11.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this5.elem, value);
setHref(_this11.elem, value);
} else {
_this5.elem.setAttribute(attr, value);
_this11.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this5.elem.textContent = '';
_this11.elem.textContent = '';
} else {
_this5.elem.setAttribute(attr, '');
_this11.elem.setAttribute(attr, '');
_this5.elem.removeAttribute(attr);
_this11.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4355,60 +4328,53 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this11.elem);
if (angle) {
var bbox = this.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var bbox = _this11.elem.getBBox();
var cx = bbox.x + bbox.width / 2;
var cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this11.elem.getAttribute('transform')) {
_this11.elem.setAttribute('transform', rotate);
}
}
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
return true;
});
}
/**
* Reverses the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler) {
var _this6 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this12 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.oldValues).forEach(function (_ref3) {
Object.entries(_this12.oldValues).forEach(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
attr = _ref4[0],
value = _ref4[1];
if (value) {
if (attr === '#text') {
_this6.elem.textContent = value;
_this12.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this6.elem, value);
setHref(_this12.elem, value);
} else {
_this6.elem.setAttribute(attr, value);
_this12.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this6.elem.textContent = '';
_this12.elem.textContent = '';
} else {
_this6.elem.removeAttribute(attr);
_this12.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4417,43 +4383,29 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this12.elem);
if (angle) {
var bbox = this.elem.getBBox();
var bbox = _this12.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this12.elem.getAttribute('transform')) {
_this12.elem.setAttribute('transform', rotate);
}
}
} // Remove transformlist to prevent confusion that causes bugs like 575.
removeElementFromListMap(this.elem);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
return true;
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
removeElementFromListMap(_this12.elem);
});
}
}]);
return ChangeElementCommand;
}(Command);
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // TODO: create a 'typing' command object that tracks changes in text
}(Command); // TODO: create a 'typing' command object that tracks changes in text
// if a new Typing command is created and the top command on the stack is also a Typing
// and they both affect the same element, then collapse the two commands into one
@@ -4471,25 +4423,14 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function BatchCommand(text) {
var _this7;
var _this13;
_classCallCheck(this, BatchCommand);
_this7 = _super5.call(this);
_this7.text = text || 'Batch Command';
_this7.stack = [];
return _this7;
}
/**
* @returns {"svgedit.history.BatchCommand"}
*/
_createClass(BatchCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.BatchCommand';
_this13 = _super5.call(this);
_this13.text = text || 'Batch Command';
_this13.stack = [];
return _this13;
}
/**
* Runs "apply" on all subcommands.
@@ -4498,22 +4439,19 @@
* @returns {void}
*/
}, {
_createClass(BatchCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this14 = this;
var len = this.stack.length;
for (var i = 0; i < len; ++i) {
this.stack[i].apply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
_this14.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.apply(handler);
});
});
}
/**
* Runs "unapply" on all subcommands.
@@ -4525,17 +4463,15 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this15 = this;
for (var i = this.stack.length - 1; i >= 0; i--) {
this.stack[i].unapply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
_this15.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.unapply(handler);
});
});
}
/**
* Iterate through all our subcommands.
@@ -4549,6 +4485,7 @@
var cmd = this.stack.length;
while (cmd--) {
if (!this.stack[cmd]) continue;
var thisElems = this.stack[cmd].elements();
var elem = thisElems.length;
@@ -4570,6 +4507,8 @@
}, {
key: "addSubCommand",
value: function addSubCommand(cmd) {
// eslint-disable-next-line no-console
console.assert(cmd !== null, 'cmd should not be null');
this.stack.push(cmd);
}
/**
@@ -4585,7 +4524,6 @@
return BatchCommand;
}(Command);
BatchCommand.type = BatchCommand.prototype.type;
/**
*
*/
@@ -8016,8 +7954,8 @@
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
var visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var editorContext_$1 = null;
var domdoc_ = null;
@@ -9452,6 +9390,9 @@
var isNullish = function isNullish(val) {
return val === null || val === undefined;
};
var $q = function $q(sel) {
return document.querySelector(sel);
};
/* globals jQuery */
@@ -14216,18 +14157,18 @@
var cmdType = cmd.type();
var isApply = eventType === EventTypes.AFTER_APPLY;
if (cmdType === MoveElementCommand$1.type()) {
if (cmdType === 'MoveElementCommand') {
var parent = isApply ? cmd.newParent : cmd.oldParent;
if (parent === svgcontent) {
identifyLayers();
}
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
if (cmd.parent === svgcontent) {
identifyLayers();
}
if (cmdType === InsertElementCommand$1.type()) {
if (cmdType === 'InsertElementCommand') {
if (isApply) {
restoreRefElems(cmd.elem);
}
@@ -14238,7 +14179,7 @@
if (cmd.elem && cmd.elem.tagName === 'use') {
setUseData(cmd.elem);
}
} else if (cmdType === ChangeElementCommand$1.type()) {
} else if (cmdType === 'ChangeElementCommand') {
// if we are changing layer names, re-identify all layers
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
identifyLayers();
@@ -28667,6 +28608,7 @@
}));
}
var $q$1 = $q;
var editor = {};
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
return func(jq);
@@ -35539,7 +35481,7 @@
var btn;
if (opts.sel) {
btn = document.querySelector(opts.sel);
btn = $q$1(opts.sel);
if (btn === null) {
return true;

14
dist/index-umd.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5328
dist/svgcanvas-iife.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -419,6 +419,7 @@ export class BatchCommand extends Command {
apply (handler) {
super.apply(handler, () => {
this.stack.forEach((stackItem) => {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.apply(handler);
});
@@ -434,6 +435,7 @@ export class BatchCommand extends Command {
unapply (handler) {
super.unapply(handler, () => {
this.stack.forEach((stackItem) => {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.unapply(handler);
});
@@ -464,6 +466,7 @@ export class BatchCommand extends Command {
* @returns {void}
*/
addSubCommand (cmd) {
// eslint-disable-next-line no-console
console.assert(cmd !== null, 'cmd should not be null');
this.stack.push(cmd);
}

View File

@@ -56,7 +56,7 @@ let typeMap_ = {};
* @returns {Integer} The number of digits number should be rounded to
*/
// Todo[eslint-plugin-jsdoc@>=29.0.0]: See if parsing fixed to allow '%'
// Todo[eslint-plugin-jsdoc@>=30.0.0]: See if parsing fixed to allow '%'
/* eslint-disable jsdoc/valid-types */
/**
* @typedef {PlainObject} module:units.TypeMap

View File

@@ -172,6 +172,36 @@
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
@@ -3619,7 +3649,7 @@
* @function module:units.ElementContainer#getRoundDigits
* @returns {Integer} The number of digits number should be rounded to
*/
// Todo[eslint-plugin-jsdoc@>=29.0.0]: See if parsing fixed to allow '%'
// Todo[eslint-plugin-jsdoc@>=30.0.0]: See if parsing fixed to allow '%'
/* eslint-disable jsdoc/valid-types */
@@ -3862,8 +3892,7 @@
AFTER_APPLY: 'after_apply',
BEFORE_UNAPPLY: 'before_unapply',
AFTER_UNAPPLY: 'after_unapply'
}; // const removedElements = {};
};
/**
* Base class for commands.
*/
@@ -3882,6 +3911,51 @@
value: function getText() {
return this.text;
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} applyFunction
* @returns {void}
*/
}, {
key: "apply",
value: function apply(handler, applyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
applyFunction(handler);
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} unapplyFunction
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler, unapplyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
unapplyFunction();
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
/**
* @returns {Element[]} Array with element associated with this command
* This function needs to be surcharged if multiple elements are returned.
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
}
/**
* @returns {string} String with element associated with this command
*/
}, {
key: "type",
value: function type() {
return this.constructor.name;
}
}]);
return Command;
@@ -3930,12 +4004,6 @@
* @returns {string}
*/
/**
* Gives the type.
* @function module:history.HistoryCommand#type
* @returns {string}
*/
/**
* @event module:history~Command#event:history
* @type {module:history.HistoryCommand}
@@ -3987,17 +4055,6 @@
_this.newParent = elem.parentNode;
return _this;
}
/**
* @returns {"svgedit.history.MoveElementCommand"}
*/
_createClass(MoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.MoveElementCommand';
}
/**
* Re-positions the element.
* @param {module:history.HistoryEventHandler} handler
@@ -4005,19 +4062,15 @@
* @returns {void}
*/
}, {
_createClass(MoveElementCommand, [{
key: "apply",
value: function apply(handler) {
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this2 = this;
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
});
}
/**
* Positions the element back to its original location.
@@ -4029,30 +4082,16 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this3 = this;
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.oldNextSibling);
});
}
}]);
return MoveElementCommand;
}(Command);
MoveElementCommand.type = MoveElementCommand.prototype.type;
/**
* History command for an element that was added to the DOM.
* @implements {module:history.HistoryCommand}
@@ -4068,27 +4107,16 @@
* @param {string} text - An optional string visible to user related to this change
*/
function InsertElementCommand(elem, text) {
var _this2;
var _this4;
_classCallCheck(this, InsertElementCommand);
_this2 = _super2.call(this);
_this2.elem = elem;
_this2.text = text || 'Create ' + elem.tagName;
_this2.parent = elem.parentNode;
_this2.nextSibling = _this2.elem.nextSibling;
return _this2;
}
/**
* @returns {"svgedit.history.InsertElementCommand"}
*/
_createClass(InsertElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.InsertElementCommand';
_this4 = _super2.call(this);
_this4.elem = elem;
_this4.text = text || 'Create ' + elem.tagName;
_this4.parent = elem.parentNode;
_this4.nextSibling = _this4.elem.nextSibling;
return _this4;
}
/**
* Re-inserts the new element.
@@ -4097,18 +4125,15 @@
* @returns {void}
*/
}, {
_createClass(InsertElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this5 = this;
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
});
}
/**
* Removes the element.
@@ -4120,31 +4145,18 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this6 = this;
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this6.parent = _this6.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_this6.elem.remove();
});
}
}]);
return InsertElementCommand;
}(Command);
InsertElementCommand.type = InsertElementCommand.prototype.type;
/**
* History command for an element removed from the DOM.
* @implements {module:history.HistoryCommand}
@@ -4162,29 +4174,18 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
var _this3;
var _this7;
_classCallCheck(this, RemoveElementCommand);
_this3 = _super3.call(this);
_this3.elem = elem;
_this3.text = text || 'Delete ' + elem.tagName;
_this3.nextSibling = oldNextSibling;
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
_this7 = _super3.call(this);
_this7.elem = elem;
_this7.text = text || 'Delete ' + elem.tagName;
_this7.nextSibling = oldNextSibling;
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
removeElementFromListMap(elem);
return _this3;
}
/**
* @returns {"svgedit.history.RemoveElementCommand"}
*/
_createClass(RemoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.RemoveElementCommand';
return _this7;
}
/**
* Re-removes the new element.
@@ -4193,20 +4194,18 @@
* @returns {void}
*/
}, {
_createClass(RemoveElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this8 = this;
removeElementFromListMap(this.elem);
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
removeElementFromListMap(_this8.elem);
_this8.parent = _this8.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_this8.elem.remove();
});
}
/**
* Re-adds the new element.
@@ -4218,38 +4217,25 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this9 = this;
removeElementFromListMap(this.elem);
_get(_getPrototypeOf(RemoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
removeElementFromListMap(_this9.elem);
if (isNullish(this.nextSibling)) {
if (isNullish(_this9.nextSibling)) {
if (window.console) {
console.log('Error: reference element was lost'); // eslint-disable-line no-console
}
}
this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
_this9.parent.insertBefore(_this9.elem, _this9.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
});
}
}]);
return RemoveElementCommand;
}(Command);
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
/**
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
*/
@@ -4275,75 +4261,62 @@
* @param {string} text - An optional string visible to user related to this change
*/
function ChangeElementCommand(elem, attrs, text) {
var _this4;
var _this10;
_classCallCheck(this, ChangeElementCommand);
_this4 = _super4.call(this);
_this4.elem = elem;
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this4.newValues = {};
_this4.oldValues = attrs;
_this10 = _super4.call(this);
_this10.elem = elem;
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this10.newValues = {};
_this10.oldValues = attrs;
for (var attr in attrs) {
if (attr === '#text') {
_this4.newValues[attr] = elem.textContent;
_this10.newValues[attr] = elem.textContent;
} else if (attr === '#href') {
_this4.newValues[attr] = getHref(elem);
_this10.newValues[attr] = getHref(elem);
} else {
_this4.newValues[attr] = elem.getAttribute(attr);
_this10.newValues[attr] = elem.getAttribute(attr);
}
}
return _this4;
}
/**
* @returns {"svgedit.history.ChangeElementCommand"}
*/
_createClass(ChangeElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.ChangeElementCommand';
return _this10;
}
/**
* Performs the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
_createClass(ChangeElementCommand, [{
key: "apply",
value: function apply(handler) {
var _this5 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this11 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.newValues).forEach(function (_ref) {
Object.entries(_this11.newValues).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
attr = _ref2[0],
value = _ref2[1];
if (value) {
if (attr === '#text') {
_this5.elem.textContent = value;
_this11.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this5.elem, value);
setHref(_this11.elem, value);
} else {
_this5.elem.setAttribute(attr, value);
_this11.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this5.elem.textContent = '';
_this11.elem.textContent = '';
} else {
_this5.elem.setAttribute(attr, '');
_this11.elem.setAttribute(attr, '');
_this5.elem.removeAttribute(attr);
_this11.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4352,60 +4325,53 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this11.elem);
if (angle) {
var bbox = this.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var bbox = _this11.elem.getBBox();
var cx = bbox.x + bbox.width / 2;
var cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this11.elem.getAttribute('transform')) {
_this11.elem.setAttribute('transform', rotate);
}
}
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
return true;
});
}
/**
* Reverses the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler) {
var _this6 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this12 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.oldValues).forEach(function (_ref3) {
Object.entries(_this12.oldValues).forEach(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
attr = _ref4[0],
value = _ref4[1];
if (value) {
if (attr === '#text') {
_this6.elem.textContent = value;
_this12.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this6.elem, value);
setHref(_this12.elem, value);
} else {
_this6.elem.setAttribute(attr, value);
_this12.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this6.elem.textContent = '';
_this12.elem.textContent = '';
} else {
_this6.elem.removeAttribute(attr);
_this12.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4414,43 +4380,29 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this12.elem);
if (angle) {
var bbox = this.elem.getBBox();
var bbox = _this12.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this12.elem.getAttribute('transform')) {
_this12.elem.setAttribute('transform', rotate);
}
}
} // Remove transformlist to prevent confusion that causes bugs like 575.
removeElementFromListMap(this.elem);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
return true;
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
removeElementFromListMap(_this12.elem);
});
}
}]);
return ChangeElementCommand;
}(Command);
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // TODO: create a 'typing' command object that tracks changes in text
}(Command); // TODO: create a 'typing' command object that tracks changes in text
// if a new Typing command is created and the top command on the stack is also a Typing
// and they both affect the same element, then collapse the two commands into one
@@ -4468,25 +4420,14 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function BatchCommand(text) {
var _this7;
var _this13;
_classCallCheck(this, BatchCommand);
_this7 = _super5.call(this);
_this7.text = text || 'Batch Command';
_this7.stack = [];
return _this7;
}
/**
* @returns {"svgedit.history.BatchCommand"}
*/
_createClass(BatchCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.BatchCommand';
_this13 = _super5.call(this);
_this13.text = text || 'Batch Command';
_this13.stack = [];
return _this13;
}
/**
* Runs "apply" on all subcommands.
@@ -4495,22 +4436,19 @@
* @returns {void}
*/
}, {
_createClass(BatchCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this14 = this;
var len = this.stack.length;
for (var i = 0; i < len; ++i) {
this.stack[i].apply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
_this14.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.apply(handler);
});
});
}
/**
* Runs "unapply" on all subcommands.
@@ -4522,17 +4460,15 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this15 = this;
for (var i = this.stack.length - 1; i >= 0; i--) {
this.stack[i].unapply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
_this15.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.unapply(handler);
});
});
}
/**
* Iterate through all our subcommands.
@@ -4546,6 +4482,7 @@
var cmd = this.stack.length;
while (cmd--) {
if (!this.stack[cmd]) continue;
var thisElems = this.stack[cmd].elements();
var elem = thisElems.length;
@@ -4567,6 +4504,8 @@
}, {
key: "addSubCommand",
value: function addSubCommand(cmd) {
// eslint-disable-next-line no-console
console.assert(cmd !== null, 'cmd should not be null');
this.stack.push(cmd);
}
/**
@@ -4582,7 +4521,6 @@
return BatchCommand;
}(Command);
BatchCommand.type = BatchCommand.prototype.type;
/**
*
*/
@@ -8013,8 +7951,8 @@
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
var visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var editorContext_$1 = null;
var domdoc_ = null;
@@ -9449,6 +9387,9 @@
var isNullish = function isNullish(val) {
return val === null || val === undefined;
};
var $q = function $q(sel) {
return document.querySelector(sel);
};
/* globals jQuery */
@@ -14213,18 +14154,18 @@
var cmdType = cmd.type();
var isApply = eventType === EventTypes.AFTER_APPLY;
if (cmdType === MoveElementCommand$1.type()) {
if (cmdType === 'MoveElementCommand') {
var parent = isApply ? cmd.newParent : cmd.oldParent;
if (parent === svgcontent) {
identifyLayers();
}
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
if (cmd.parent === svgcontent) {
identifyLayers();
}
if (cmdType === InsertElementCommand$1.type()) {
if (cmdType === 'InsertElementCommand') {
if (isApply) {
restoreRefElems(cmd.elem);
}
@@ -14235,7 +14176,7 @@
if (cmd.elem && cmd.elem.tagName === 'use') {
setUseData(cmd.elem);
}
} else if (cmdType === ChangeElementCommand$1.type()) {
} else if (cmdType === 'ChangeElementCommand') {
// if we are changing layer names, re-identify all layers
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
identifyLayers();
@@ -28664,6 +28605,7 @@
}));
}
var $q$1 = $q;
var editor = {};
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
return func(jq);
@@ -35536,7 +35478,7 @@
var btn;
if (opts.sel) {
btn = document.querySelector(opts.sel);
btn = $q$1(opts.sel);
if (btn === null) {
return true;

179
package-lock.json generated
View File

@@ -25,47 +25,37 @@
}
},
"@babel/core": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.4.tgz",
"integrity": "sha512-3A0tS0HWpy4XujGc7QtOIHTeNwUgWaZc/WuS5YQrfhU67jnVmsD6OGPc1AKHH0LJHQICGncy3+YUjIhVlfDdcA==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.5.tgz",
"integrity": "sha512-O34LQooYVDXPl7QWCdW9p4NR+QlzOr7xShPPJz8GsuCU3/8ua/wqTr7gmnxXv+WBESiGU/G5s16i6tUvHkNb+w==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.10.4",
"@babel/generator": "^7.10.4",
"@babel/helper-module-transforms": "^7.10.4",
"@babel/generator": "^7.10.5",
"@babel/helper-module-transforms": "^7.10.5",
"@babel/helpers": "^7.10.4",
"@babel/parser": "^7.10.4",
"@babel/parser": "^7.10.5",
"@babel/template": "^7.10.4",
"@babel/traverse": "^7.10.4",
"@babel/types": "^7.10.4",
"@babel/traverse": "^7.10.5",
"@babel/types": "^7.10.5",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.1",
"json5": "^2.1.2",
"lodash": "^4.17.13",
"lodash": "^4.17.19",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"dependencies": {
"@babel/code-frame": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
"integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
"dev": true,
"requires": {
"@babel/highlight": "^7.10.4"
}
},
"@babel/generator": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.4.tgz",
"integrity": "sha512-toLIHUIAgcQygFZRAQcsLQV3CBuX6yOIru1kJk/qqqvcRmZrYe6WavZTSG+bB8MxhnL9YPf+pKQfuiP161q7ng==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.5.tgz",
"integrity": "sha512-3vXxr3FEW7E7lJZiWQ3bM4+v/Vyr9C+hpolQ8BGFr9Y8Ri2tFLWTixmwKBafDujO1WVah4fhZBeU1bieKdghig==",
"dev": true,
"requires": {
"@babel/types": "^7.10.4",
"@babel/types": "^7.10.5",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
}
},
@@ -90,27 +80,18 @@
}
},
"@babel/helper-member-expression-to-functions": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.4.tgz",
"integrity": "sha512-m5j85pK/KZhuSdM/8cHUABQTAslV47OjfIB9Cc7P+PvlAoBzdb79BGNfw8RhT5Mq3p+xGd0ZfAKixbrUZx0C7A==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.5.tgz",
"integrity": "sha512-HiqJpYD5+WopCXIAbQDG0zye5XYVvcO9w/DHp5GsaGkRUaamLj2bEtu6i8rnGGprAhHM3qidCMgp71HF4endhA==",
"dev": true,
"requires": {
"@babel/types": "^7.10.4"
}
},
"@babel/helper-module-imports": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz",
"integrity": "sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==",
"dev": true,
"requires": {
"@babel/types": "^7.10.4"
"@babel/types": "^7.10.5"
}
},
"@babel/helper-module-transforms": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.4.tgz",
"integrity": "sha512-Er2FQX0oa3nV7eM1o0tNCTx7izmQtwAQsIiaLRWtavAAEcskb0XJ5OjJbVrYXWOTr8om921Scabn4/tzlx7j1Q==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.5.tgz",
"integrity": "sha512-4P+CWMJ6/j1W915ITJaUkadLObmCRRSC234uctJfn/vHrsLNxsR8dwlcXv9ZhJWzl77awf+mWXSZEKt5t0OnlA==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.10.4",
@@ -118,8 +99,8 @@
"@babel/helper-simple-access": "^7.10.4",
"@babel/helper-split-export-declaration": "^7.10.4",
"@babel/template": "^7.10.4",
"@babel/types": "^7.10.4",
"lodash": "^4.17.13"
"@babel/types": "^7.10.5",
"lodash": "^4.17.19"
}
},
"@babel/helper-optimise-call-expression": {
@@ -162,12 +143,6 @@
"@babel/types": "^7.10.4"
}
},
"@babel/helper-validator-identifier": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
"integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==",
"dev": true
},
"@babel/helpers": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz",
@@ -179,21 +154,10 @@
"@babel/types": "^7.10.4"
}
},
"@babel/highlight": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
"integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
"dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.10.4",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
}
},
"@babel/parser": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.4.tgz",
"integrity": "sha512-8jHII4hf+YVDsskTF6WuMB3X4Eh+PsUkC2ljq22so5rHvH+T8BzyL94VOdyFLNR8tBSVXOTbNHOKpR4TfRxVtA==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.5.tgz",
"integrity": "sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ==",
"dev": true
},
"@babel/template": {
@@ -208,38 +172,32 @@
}
},
"@babel/traverse": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.4.tgz",
"integrity": "sha512-aSy7p5THgSYm4YyxNGz6jZpXf+Ok40QF3aA2LyIONkDHpAcJzDUqlCKXv6peqYUs2gmic849C/t2HKw2a2K20Q==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.5.tgz",
"integrity": "sha512-yc/fyv2gUjPqzTz0WHeRJH2pv7jA9kA7mBX2tXl/x5iOE81uaVPuGPtaYk7wmkx4b67mQ7NqI8rmT2pF47KYKQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.10.4",
"@babel/generator": "^7.10.4",
"@babel/generator": "^7.10.5",
"@babel/helper-function-name": "^7.10.4",
"@babel/helper-split-export-declaration": "^7.10.4",
"@babel/parser": "^7.10.4",
"@babel/types": "^7.10.4",
"@babel/parser": "^7.10.5",
"@babel/types": "^7.10.5",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
"lodash": "^4.17.19"
}
},
"@babel/types": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.4.tgz",
"integrity": "sha512-UTCFOxC3FsFHb7lkRMVvgLzaRVamXuAs2Tz4wajva4WxtVY82eZeaUBtC2Zt95FU9TiznuC0Zk35tsim8jeVpg==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.5.tgz",
"integrity": "sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==",
"dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.10.4",
"lodash": "^4.17.13",
"lodash": "^4.17.19",
"to-fast-properties": "^2.0.0"
}
},
"lodash": {
"version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true
}
}
},
@@ -613,15 +571,15 @@
}
},
"@babel/node": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/node/-/node-7.10.4.tgz",
"integrity": "sha512-U41uyQkG0J1ezCb8KCdhDJotQF68Z/OsUbcgdxaC0M4JoXKZVdaKQJ+ecnr7aaWjNLt0Vee6Vddj6VL4JEMJnQ==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/node/-/node-7.10.5.tgz",
"integrity": "sha512-suosS7zZ2roj+fYVCnDuVezUbRc0sdoyF0Gj/1FzWxD4ebbGiBGtL5qyqHH4NO34B5m4vWWYWgyNhSsrqS8vwA==",
"dev": true,
"requires": {
"@babel/register": "^7.10.4",
"@babel/register": "^7.10.5",
"commander": "^4.0.1",
"core-js": "^3.2.1",
"lodash": "^4.17.13",
"lodash": "^4.17.19",
"node-environment-flags": "^1.0.5",
"regenerator-runtime": "^0.13.4",
"resolve": "^1.13.1",
@@ -2554,13 +2512,13 @@
}
},
"@babel/register": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/register/-/register-7.10.4.tgz",
"integrity": "sha512-whHmgGiWNVyTVnYTSawtDWhaeYsc+noeU8Rmi+MPnbGhDYmr5QpEDMrQcIA07D2RUv0BlThPcN89XcHCqq/O4g==",
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/register/-/register-7.10.5.tgz",
"integrity": "sha512-eYHdLv43nyvmPn9bfNfrcC4+iYNwdQ8Pxk1MFJuU/U5LpSYl/PH4dFMazCYZDFVi8ueG3shvO+AQfLrxpYulQw==",
"dev": true,
"requires": {
"find-cache-dir": "^2.0.0",
"lodash": "^4.17.13",
"lodash": "^4.17.19",
"make-dir": "^2.1.0",
"pirates": "^4.0.0",
"source-map-support": "^0.5.16"
@@ -3473,9 +3431,9 @@
"dev": true
},
"@rollup/plugin-babel": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.0.4.tgz",
"integrity": "sha512-MBtNoi5gqBEbqy1gE9jZBfPsi10kbuK2CEu9bx53nk1Z3ATRvBOoZ/GsbhXOeVbS76xXi/DeYM+vYX6EGIDv9A==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.1.0.tgz",
"integrity": "sha512-zXBEYmfiLAMvB+ZBa6m/q9hsQYAq1sUFdjuP1F6C2pf6uQcpHwAWQveZgzS63zXdKPUYHD3Dr7BhjCqcr0bbLw==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.7.4",
@@ -6644,15 +6602,6 @@
"sha.js": "^2.4.8"
}
},
"cross-env": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.2.tgz",
"integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.1"
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -6844,9 +6793,9 @@
}
},
"cypress": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-4.9.0.tgz",
"integrity": "sha512-qGxT5E0j21FPryzhb0OBjCdhoR/n1jXtumpFFSBPYWsaZZhNaBvc3XlBUDEZKkkXPsqUFYiyhWdHN/zo0t5FcA==",
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-4.10.0.tgz",
"integrity": "sha512-eFv1WPp4zFrAgZ6mwherBGVsTpHvay/hEF5F7U7yfAkTxsUQn/ZG/LdX67fIi3bKDTQXYzFv/CvywlQSeug8Bg==",
"dev": true,
"requires": {
"@cypress/listr-verbose-renderer": "0.4.1",
@@ -8072,9 +8021,9 @@
"dev": true
},
"eslint-plugin-chai-expect": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-2.1.0.tgz",
"integrity": "sha512-rd0/4mjMV6c3i0o4DKkWI4uaFN9DK707kW+/fDphaDI6HVgxXnhML9Xgt5vHnTXmSSnDhupuCFBgsEAEpchXmQ==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-2.2.0.tgz",
"integrity": "sha512-ExTJKhgeYMfY8wDj3UiZmgpMKJOUHGNHmWMlxT49JUDB1vTnw0sSNfXJSxnX+LcebyBD/gudXzjzD136WqPJrQ==",
"dev": true
},
"eslint-plugin-chai-expect-keywords": {
@@ -8278,14 +8227,14 @@
}
},
"eslint-plugin-jsdoc": {
"version": "28.6.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-28.6.1.tgz",
"integrity": "sha512-Z3y7hcNPDuhL339D1KOf9SY8pMAxYxhaG4QLtu3KVn20k/hNF1u6WQv44wvuSCb6OfPJ4say37RUlSNqIjR+mw==",
"version": "29.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-29.2.0.tgz",
"integrity": "sha512-B1a8LWPkkxyxIp4y3pnRQR18j03Wp+V9gDE7IjQG/MvWAzp5gqXM0q71gXRAZMvWUjujAsNg8B9v1csl+/zkvw==",
"dev": true,
"requires": {
"comment-parser": "^0.7.5",
"debug": "^4.1.1",
"jsdoctypeparser": "^7.0.0",
"jsdoctypeparser": "^8.0.0",
"lodash": "^4.17.15",
"regextras": "^0.7.1",
"semver": "^7.3.2",
@@ -11451,9 +11400,9 @@
}
},
"jsdoctypeparser": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-7.0.0.tgz",
"integrity": "sha512-6vWPn5qSy+MbgCVjXsQKVkRywhs+IxFU7Chw72DKsWoGueYp6QX8eTc55+EA0yPGYfhmglb1gfi283asXirfGQ==",
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-8.0.0.tgz",
"integrity": "sha512-eLCs6s4JqN8TjFJfgdiLHRvogLhOAJz+5RIA2FtoMe6ZDyuvghvppnlIToqAEnVbxRqLMrfnNXpW8FpmR6IMBw==",
"dev": true
},
"jsdom": {
@@ -15314,9 +15263,9 @@
}
},
"rollup": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.19.0.tgz",
"integrity": "sha512-nny5Vs4jwY3vbQAXgOyU4ZDZqLvMKm/umnsVry/demVL6ve8ke1XhdpYE0eiWencASmx/qFPw6pP8P7MLJl9XA==",
"version": "2.21.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.21.0.tgz",
"integrity": "sha512-BEGgy+wSzux7Ycq58pRiWEOBZaXRXTuvzl1gsm7gqmsAHxkWf9nyA5V2LN9fGSHhhDQd0/C13iRzSh4bbIpWZQ==",
"dev": true,
"requires": {
"fsevents": "~2.1.2"

View File

@@ -141,24 +141,24 @@
],
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/node": "^7.10.4",
"@babel/core": "^7.10.5",
"@babel/node": "^7.10.5",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/register": "^7.10.4",
"@babel/register": "^7.10.5",
"@cypress/code-coverage": "^3.8.1",
"@cypress/fiddle": "^1.18.2",
"@fintechstudios/eslint-plugin-chai-as-promised": "^3.0.2",
"@mysticatea/eslint-plugin": "^13.0.0",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-babel": "^5.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"coffeescript": "^2.5.1",
"copyfiles": "^2.3.0",
"core-js-bundle": "^3.6.5",
"coveradge": "^0.6.0",
"cross-var": "^1.1.0",
"cypress": "^4.9.0",
"cypress": "^4.10.0",
"cypress-axe": "^0.8.1",
"cypress-multi-reporters": "^1.4.0",
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
@@ -166,7 +166,7 @@
"eslint-config-ash-nazg": "^22.5.1",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-array-func": "^3.1.6",
"eslint-plugin-chai-expect": "^2.1.0",
"eslint-plugin-chai-expect": "^2.2.0",
"eslint-plugin-chai-expect-keywords": "^2.0.1",
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-compat": "^3.8.0",
@@ -174,7 +174,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsdoc": "^28.6.1",
"eslint-plugin-jsdoc": "^29.2.0",
"eslint-plugin-markdown": "^1.0.2",
"eslint-plugin-mocha": "^7.0.1",
"eslint-plugin-mocha-cleanup": "^1.8.0",
@@ -209,7 +209,7 @@
"remark-cli": "^8.0.0",
"remark-lint-ordered-list-marker-value": "^2.0.1",
"rimraf": "^3.0.2",
"rollup": "2.19.0",
"rollup": "2.21.0",
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^6.1.0",
"stackblur-canvas": "^2.3.0",

View File

@@ -172,6 +172,36 @@
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
@@ -3619,7 +3649,7 @@
* @function module:units.ElementContainer#getRoundDigits
* @returns {Integer} The number of digits number should be rounded to
*/
// Todo[eslint-plugin-jsdoc@>=29.0.0]: See if parsing fixed to allow '%'
// Todo[eslint-plugin-jsdoc@>=30.0.0]: See if parsing fixed to allow '%'
/* eslint-disable jsdoc/valid-types */
@@ -3862,8 +3892,7 @@
AFTER_APPLY: 'after_apply',
BEFORE_UNAPPLY: 'before_unapply',
AFTER_UNAPPLY: 'after_unapply'
}; // const removedElements = {};
};
/**
* Base class for commands.
*/
@@ -3882,6 +3911,51 @@
value: function getText() {
return this.text;
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} applyFunction
* @returns {void}
*/
}, {
key: "apply",
value: function apply(handler, applyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
applyFunction(handler);
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
/**
* @param {module:history.HistoryEventHandler} handler
* @param {callback} unapplyFunction
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler, unapplyFunction) {
handler && handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
unapplyFunction();
handler && handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
/**
* @returns {Element[]} Array with element associated with this command
* This function needs to be surcharged if multiple elements are returned.
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
}
/**
* @returns {string} String with element associated with this command
*/
}, {
key: "type",
value: function type() {
return this.constructor.name;
}
}]);
return Command;
@@ -3930,12 +4004,6 @@
* @returns {string}
*/
/**
* Gives the type.
* @function module:history.HistoryCommand#type
* @returns {string}
*/
/**
* @event module:history~Command#event:history
* @type {module:history.HistoryCommand}
@@ -3987,17 +4055,6 @@
_this.newParent = elem.parentNode;
return _this;
}
/**
* @returns {"svgedit.history.MoveElementCommand"}
*/
_createClass(MoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.MoveElementCommand';
}
/**
* Re-positions the element.
* @param {module:history.HistoryEventHandler} handler
@@ -4005,19 +4062,15 @@
* @returns {void}
*/
}, {
_createClass(MoveElementCommand, [{
key: "apply",
value: function apply(handler) {
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this2 = this;
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
});
}
/**
* Positions the element back to its original location.
@@ -4029,30 +4082,16 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this3 = this;
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.oldNextSibling);
});
}
}]);
return MoveElementCommand;
}(Command);
MoveElementCommand.type = MoveElementCommand.prototype.type;
/**
* History command for an element that was added to the DOM.
* @implements {module:history.HistoryCommand}
@@ -4068,27 +4107,16 @@
* @param {string} text - An optional string visible to user related to this change
*/
function InsertElementCommand(elem, text) {
var _this2;
var _this4;
_classCallCheck(this, InsertElementCommand);
_this2 = _super2.call(this);
_this2.elem = elem;
_this2.text = text || 'Create ' + elem.tagName;
_this2.parent = elem.parentNode;
_this2.nextSibling = _this2.elem.nextSibling;
return _this2;
}
/**
* @returns {"svgedit.history.InsertElementCommand"}
*/
_createClass(InsertElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.InsertElementCommand';
_this4 = _super2.call(this);
_this4.elem = elem;
_this4.text = text || 'Create ' + elem.tagName;
_this4.parent = elem.parentNode;
_this4.nextSibling = _this4.elem.nextSibling;
return _this4;
}
/**
* Re-inserts the new element.
@@ -4097,18 +4125,15 @@
* @returns {void}
*/
}, {
_createClass(InsertElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this5 = this;
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
});
}
/**
* Removes the element.
@@ -4120,31 +4145,18 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this6 = this;
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
_this6.parent = _this6.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
_this6.elem.remove();
});
}
}]);
return InsertElementCommand;
}(Command);
InsertElementCommand.type = InsertElementCommand.prototype.type;
/**
* History command for an element removed from the DOM.
* @implements {module:history.HistoryCommand}
@@ -4162,29 +4174,18 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
var _this3;
var _this7;
_classCallCheck(this, RemoveElementCommand);
_this3 = _super3.call(this);
_this3.elem = elem;
_this3.text = text || 'Delete ' + elem.tagName;
_this3.nextSibling = oldNextSibling;
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
_this7 = _super3.call(this);
_this7.elem = elem;
_this7.text = text || 'Delete ' + elem.tagName;
_this7.nextSibling = oldNextSibling;
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
removeElementFromListMap(elem);
return _this3;
}
/**
* @returns {"svgedit.history.RemoveElementCommand"}
*/
_createClass(RemoveElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.RemoveElementCommand';
return _this7;
}
/**
* Re-removes the new element.
@@ -4193,20 +4194,18 @@
* @returns {void}
*/
}, {
_createClass(RemoveElementCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this8 = this;
removeElementFromListMap(this.elem);
this.parent = this.elem.parentNode;
this.elem.remove();
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
removeElementFromListMap(_this8.elem);
_this8.parent = _this8.elem.parentNode;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_this8.elem.remove();
});
}
/**
* Re-adds the new element.
@@ -4218,38 +4217,25 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this9 = this;
removeElementFromListMap(this.elem);
_get(_getPrototypeOf(RemoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
removeElementFromListMap(_this9.elem);
if (isNullish(this.nextSibling)) {
if (isNullish(_this9.nextSibling)) {
if (window.console) {
console.log('Error: reference element was lost'); // eslint-disable-line no-console
}
}
this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
_this9.parent.insertBefore(_this9.elem, _this9.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
});
}
}]);
return RemoveElementCommand;
}(Command);
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
/**
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
*/
@@ -4275,75 +4261,62 @@
* @param {string} text - An optional string visible to user related to this change
*/
function ChangeElementCommand(elem, attrs, text) {
var _this4;
var _this10;
_classCallCheck(this, ChangeElementCommand);
_this4 = _super4.call(this);
_this4.elem = elem;
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this4.newValues = {};
_this4.oldValues = attrs;
_this10 = _super4.call(this);
_this10.elem = elem;
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
_this10.newValues = {};
_this10.oldValues = attrs;
for (var attr in attrs) {
if (attr === '#text') {
_this4.newValues[attr] = elem.textContent;
_this10.newValues[attr] = elem.textContent;
} else if (attr === '#href') {
_this4.newValues[attr] = getHref(elem);
_this10.newValues[attr] = getHref(elem);
} else {
_this4.newValues[attr] = elem.getAttribute(attr);
_this10.newValues[attr] = elem.getAttribute(attr);
}
}
return _this4;
}
/**
* @returns {"svgedit.history.ChangeElementCommand"}
*/
_createClass(ChangeElementCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.ChangeElementCommand';
return _this10;
}
/**
* Performs the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
_createClass(ChangeElementCommand, [{
key: "apply",
value: function apply(handler) {
var _this5 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this11 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.newValues).forEach(function (_ref) {
Object.entries(_this11.newValues).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
attr = _ref2[0],
value = _ref2[1];
if (value) {
if (attr === '#text') {
_this5.elem.textContent = value;
_this11.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this5.elem, value);
setHref(_this11.elem, value);
} else {
_this5.elem.setAttribute(attr, value);
_this11.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this5.elem.textContent = '';
_this11.elem.textContent = '';
} else {
_this5.elem.setAttribute(attr, '');
_this11.elem.setAttribute(attr, '');
_this5.elem.removeAttribute(attr);
_this11.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4352,60 +4325,53 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this11.elem);
if (angle) {
var bbox = this.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var bbox = _this11.elem.getBBox();
var cx = bbox.x + bbox.width / 2;
var cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this11.elem.getAttribute('transform')) {
_this11.elem.setAttribute('transform', rotate);
}
}
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
return true;
});
}
/**
* Reverses the stored change action.
* @param {module:history.HistoryEventHandler} handler
* @fires module:history~Command#event:history
* @returns {true}
* @returns {void}
*/
}, {
key: "unapply",
value: function unapply(handler) {
var _this6 = this;
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this12 = this;
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
var bChangedTransform = false;
Object.entries(this.oldValues).forEach(function (_ref3) {
Object.entries(_this12.oldValues).forEach(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
attr = _ref4[0],
value = _ref4[1];
if (value) {
if (attr === '#text') {
_this6.elem.textContent = value;
_this12.elem.textContent = value;
} else if (attr === '#href') {
setHref(_this6.elem, value);
setHref(_this12.elem, value);
} else {
_this6.elem.setAttribute(attr, value);
_this12.elem.setAttribute(attr, value);
}
} else if (attr === '#text') {
_this6.elem.textContent = '';
_this12.elem.textContent = '';
} else {
_this6.elem.removeAttribute(attr);
_this12.elem.removeAttribute(attr);
}
if (attr === 'transform') {
@@ -4414,43 +4380,29 @@
}); // relocate rotational transform, if necessary
if (!bChangedTransform) {
var angle = getRotationAngle(this.elem);
var angle = getRotationAngle(_this12.elem);
if (angle) {
var bbox = this.elem.getBBox();
var bbox = _this12.elem.getBBox();
var cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
if (rotate !== _this12.elem.getAttribute('transform')) {
_this12.elem.setAttribute('transform', rotate);
}
}
} // Remove transformlist to prevent confusion that causes bugs like 575.
removeElementFromListMap(this.elem);
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
return true;
}
/**
* @returns {Element[]} Array with element associated with this command
*/
}, {
key: "elements",
value: function elements() {
return [this.elem];
removeElementFromListMap(_this12.elem);
});
}
}]);
return ChangeElementCommand;
}(Command);
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // TODO: create a 'typing' command object that tracks changes in text
}(Command); // TODO: create a 'typing' command object that tracks changes in text
// if a new Typing command is created and the top command on the stack is also a Typing
// and they both affect the same element, then collapse the two commands into one
@@ -4468,25 +4420,14 @@
* @param {string} [text] - An optional string visible to user related to this change
*/
function BatchCommand(text) {
var _this7;
var _this13;
_classCallCheck(this, BatchCommand);
_this7 = _super5.call(this);
_this7.text = text || 'Batch Command';
_this7.stack = [];
return _this7;
}
/**
* @returns {"svgedit.history.BatchCommand"}
*/
_createClass(BatchCommand, [{
key: "type",
value: function type() {
// eslint-disable-line class-methods-use-this
return 'svgedit.history.BatchCommand';
_this13 = _super5.call(this);
_this13.text = text || 'Batch Command';
_this13.stack = [];
return _this13;
}
/**
* Runs "apply" on all subcommands.
@@ -4495,22 +4436,19 @@
* @returns {void}
*/
}, {
_createClass(BatchCommand, [{
key: "apply",
value: function apply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
}
var _this14 = this;
var len = this.stack.length;
for (var i = 0; i < len; ++i) {
this.stack[i].apply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
_this14.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.apply(handler);
});
});
}
/**
* Runs "unapply" on all subcommands.
@@ -4522,17 +4460,15 @@
}, {
key: "unapply",
value: function unapply(handler) {
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
}
var _this15 = this;
for (var i = this.stack.length - 1; i >= 0; i--) {
this.stack[i].unapply(handler);
}
if (handler) {
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
}
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
_this15.stack.forEach(function (stackItem) {
// eslint-disable-next-line no-console
console.assert(stackItem, 'stack item should not be null');
stackItem && stackItem.unapply(handler);
});
});
}
/**
* Iterate through all our subcommands.
@@ -4546,6 +4482,7 @@
var cmd = this.stack.length;
while (cmd--) {
if (!this.stack[cmd]) continue;
var thisElems = this.stack[cmd].elements();
var elem = thisElems.length;
@@ -4567,6 +4504,8 @@
}, {
key: "addSubCommand",
value: function addSubCommand(cmd) {
// eslint-disable-next-line no-console
console.assert(cmd !== null, 'cmd should not be null');
this.stack.push(cmd);
}
/**
@@ -4582,7 +4521,6 @@
return BatchCommand;
}(Command);
BatchCommand.type = BatchCommand.prototype.type;
/**
*
*/
@@ -8013,8 +7951,8 @@
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
var visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
var editorContext_$1 = null;
var domdoc_ = null;
@@ -9449,6 +9387,9 @@
var isNullish = function isNullish(val) {
return val === null || val === undefined;
};
var $q = function $q(sel) {
return document.querySelector(sel);
};
/* globals jQuery */
@@ -14213,18 +14154,18 @@
var cmdType = cmd.type();
var isApply = eventType === EventTypes.AFTER_APPLY;
if (cmdType === MoveElementCommand$1.type()) {
if (cmdType === 'MoveElementCommand') {
var parent = isApply ? cmd.newParent : cmd.oldParent;
if (parent === svgcontent) {
identifyLayers();
}
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
if (cmd.parent === svgcontent) {
identifyLayers();
}
if (cmdType === InsertElementCommand$1.type()) {
if (cmdType === 'InsertElementCommand') {
if (isApply) {
restoreRefElems(cmd.elem);
}
@@ -14235,7 +14176,7 @@
if (cmd.elem && cmd.elem.tagName === 'use') {
setUseData(cmd.elem);
}
} else if (cmdType === ChangeElementCommand$1.type()) {
} else if (cmdType === 'ChangeElementCommand') {
// if we are changing layer names, re-identify all layers
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
identifyLayers();
@@ -28664,6 +28605,7 @@
}));
}
var $q$1 = $q;
var editor = {};
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
return func(jq);
@@ -35536,7 +35478,7 @@
var btn;
if (opts.sel) {
btn = document.querySelector(opts.sel);
btn = $q$1(opts.sel);
if (btn === null) {
return true;