- Build: Update
- Linting: Update to-do - Linting: Disable console inline for now to get CI passing - npm: Update devDeps.
This commit is contained in:
596
dist/index-es.js
vendored
596
dist/index-es.js
vendored
@@ -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) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -3616,7 +3646,7 @@ var typeMap_ = {};
|
|||||||
* @function module:units.ElementContainer#getRoundDigits
|
* @function module:units.ElementContainer#getRoundDigits
|
||||||
* @returns {Integer} The number of digits number should be rounded to
|
* @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 */
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
|
||||||
@@ -3859,8 +3889,7 @@ var HistoryEventTypes = {
|
|||||||
AFTER_APPLY: 'after_apply',
|
AFTER_APPLY: 'after_apply',
|
||||||
BEFORE_UNAPPLY: 'before_unapply',
|
BEFORE_UNAPPLY: 'before_unapply',
|
||||||
AFTER_UNAPPLY: 'after_unapply'
|
AFTER_UNAPPLY: 'after_unapply'
|
||||||
}; // const removedElements = {};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for commands.
|
* Base class for commands.
|
||||||
*/
|
*/
|
||||||
@@ -3879,6 +3908,51 @@ var Command = /*#__PURE__*/function () {
|
|||||||
value: function getText() {
|
value: function getText() {
|
||||||
return this.text;
|
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;
|
return Command;
|
||||||
@@ -3927,12 +4001,6 @@ var Command = /*#__PURE__*/function () {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the type.
|
|
||||||
* @function module:history.HistoryCommand#type
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event module:history~Command#event:history
|
* @event module:history~Command#event:history
|
||||||
* @type {module:history.HistoryCommand}
|
* @type {module:history.HistoryCommand}
|
||||||
@@ -3985,36 +4053,21 @@ var MoveElementCommand = /*#__PURE__*/function (_Command) {
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.MoveElementCommand"}
|
* Re-positions the element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(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
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
|
var _this2 = this;
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Positions the element back to its original location.
|
* Positions the element back to its original location.
|
||||||
@@ -4026,30 +4079,16 @@ var MoveElementCommand = /*#__PURE__*/function (_Command) {
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this3 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
|
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return MoveElementCommand;
|
return MoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
MoveElementCommand.type = MoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element that was added to the DOM.
|
* History command for an element that was added to the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4065,47 +4104,33 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) {
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function InsertElementCommand(elem, text) {
|
function InsertElementCommand(elem, text) {
|
||||||
var _this2;
|
var _this4;
|
||||||
|
|
||||||
_classCallCheck(this, InsertElementCommand);
|
_classCallCheck(this, InsertElementCommand);
|
||||||
|
|
||||||
_this2 = _super2.call(this);
|
_this4 = _super2.call(this);
|
||||||
_this2.elem = elem;
|
_this4.elem = elem;
|
||||||
_this2.text = text || 'Create ' + elem.tagName;
|
_this4.text = text || 'Create ' + elem.tagName;
|
||||||
_this2.parent = elem.parentNode;
|
_this4.parent = elem.parentNode;
|
||||||
_this2.nextSibling = _this2.elem.nextSibling;
|
_this4.nextSibling = _this4.elem.nextSibling;
|
||||||
return _this2;
|
return _this4;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.InsertElementCommand"}
|
* Re-inserts the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(InsertElementCommand, [{
|
_createClass(InsertElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.InsertElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-inserts the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this5 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the element.
|
* Removes the element.
|
||||||
@@ -4117,31 +4142,18 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) {
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this6 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent = this.elem.parentNode;
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.elem.remove();
|
_this6.parent = _this6.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this6.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @returns {Element[]} Array with element associated with this command
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "elements",
|
|
||||||
value: function elements() {
|
|
||||||
return [this.elem];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return InsertElementCommand;
|
return InsertElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
InsertElementCommand.type = InsertElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element removed from the DOM.
|
* History command for an element removed from the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4159,51 +4171,38 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) {
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
||||||
var _this3;
|
var _this7;
|
||||||
|
|
||||||
_classCallCheck(this, RemoveElementCommand);
|
_classCallCheck(this, RemoveElementCommand);
|
||||||
|
|
||||||
_this3 = _super3.call(this);
|
_this7 = _super3.call(this);
|
||||||
_this3.elem = elem;
|
_this7.elem = elem;
|
||||||
_this3.text = text || 'Delete ' + elem.tagName;
|
_this7.text = text || 'Delete ' + elem.tagName;
|
||||||
_this3.nextSibling = oldNextSibling;
|
_this7.nextSibling = oldNextSibling;
|
||||||
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
||||||
|
|
||||||
removeElementFromListMap(elem);
|
removeElementFromListMap(elem);
|
||||||
return _this3;
|
return _this7;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.RemoveElementCommand"}
|
* Re-removes the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(RemoveElementCommand, [{
|
_createClass(RemoveElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.RemoveElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-removes the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this8 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
this.parent = this.elem.parentNode;
|
removeElementFromListMap(_this8.elem);
|
||||||
this.elem.remove();
|
_this8.parent = _this8.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this8.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Re-adds the new element.
|
* Re-adds the new element.
|
||||||
@@ -4215,38 +4214,25 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) {
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this9 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, 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) {
|
if (window.console) {
|
||||||
console.log('Error: reference element was lost'); // eslint-disable-line no-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;
|
return RemoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
||||||
*/
|
*/
|
||||||
@@ -4272,182 +4258,148 @@ var ChangeElementCommand = /*#__PURE__*/function (_Command4) {
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function ChangeElementCommand(elem, attrs, text) {
|
function ChangeElementCommand(elem, attrs, text) {
|
||||||
var _this4;
|
var _this10;
|
||||||
|
|
||||||
_classCallCheck(this, ChangeElementCommand);
|
_classCallCheck(this, ChangeElementCommand);
|
||||||
|
|
||||||
_this4 = _super4.call(this);
|
_this10 = _super4.call(this);
|
||||||
_this4.elem = elem;
|
_this10.elem = elem;
|
||||||
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
||||||
_this4.newValues = {};
|
_this10.newValues = {};
|
||||||
_this4.oldValues = attrs;
|
_this10.oldValues = attrs;
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
if (attr === '#text') {
|
if (attr === '#text') {
|
||||||
_this4.newValues[attr] = elem.textContent;
|
_this10.newValues[attr] = elem.textContent;
|
||||||
} else if (attr === '#href') {
|
} else if (attr === '#href') {
|
||||||
_this4.newValues[attr] = getHref(elem);
|
_this10.newValues[attr] = getHref(elem);
|
||||||
} else {
|
} else {
|
||||||
_this4.newValues[attr] = elem.getAttribute(attr);
|
_this10.newValues[attr] = elem.getAttribute(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this4;
|
return _this10;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.ChangeElementCommand"}
|
* Performs the stored change action.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(ChangeElementCommand, [{
|
_createClass(ChangeElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.ChangeElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Performs the stored change action.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {true}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
var _this5 = this;
|
var _this11 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this11.newValues).forEach(function (_ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
attr = _ref2[0],
|
||||||
|
value = _ref2[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.newValues).forEach(function (_ref) {
|
if (attr === '#text') {
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
_this11.elem.textContent = value;
|
||||||
attr = _ref2[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref2[1];
|
setHref(_this11.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this11.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this5.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this11.elem.textContent = '';
|
||||||
setHref(_this5.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this5.elem.setAttribute(attr, value);
|
_this11.elem.setAttribute(attr, '');
|
||||||
|
|
||||||
|
_this11.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this5.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this5.elem.setAttribute(attr, '');
|
|
||||||
|
|
||||||
_this5.elem.removeAttribute(attr);
|
if (attr === 'transform') {
|
||||||
}
|
bChangedTransform = true;
|
||||||
|
}
|
||||||
|
}); // relocate rotational transform, if necessary
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (!bChangedTransform) {
|
||||||
bChangedTransform = true;
|
var angle = getRotationAngle(_this11.elem);
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
if (angle) {
|
||||||
var angle = getRotationAngle(this.elem);
|
var bbox = _this11.elem.getBBox();
|
||||||
|
|
||||||
if (angle) {
|
var cx = bbox.x + bbox.width / 2;
|
||||||
var bbox = this.elem.getBBox();
|
var cy = bbox.y + bbox.height / 2;
|
||||||
var cx = bbox.x + bbox.width / 2,
|
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
||||||
cy = bbox.y + bbox.height / 2;
|
|
||||||
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
|
||||||
|
|
||||||
if (rotate !== this.elem.getAttribute('transform')) {
|
if (rotate !== _this11.elem.getAttribute('transform')) {
|
||||||
this.elem.setAttribute('transform', rotate);
|
_this11.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Reverses the stored change action.
|
* Reverses the stored change action.
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
* @fires module:history~Command#event:history
|
* @fires module:history~Command#event:history
|
||||||
* @returns {true}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
var _this6 = this;
|
var _this12 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this12.oldValues).forEach(function (_ref3) {
|
||||||
|
var _ref4 = _slicedToArray(_ref3, 2),
|
||||||
|
attr = _ref4[0],
|
||||||
|
value = _ref4[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.oldValues).forEach(function (_ref3) {
|
if (attr === '#text') {
|
||||||
var _ref4 = _slicedToArray(_ref3, 2),
|
_this12.elem.textContent = value;
|
||||||
attr = _ref4[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref4[1];
|
setHref(_this12.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this12.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this6.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this12.elem.textContent = '';
|
||||||
setHref(_this6.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this6.elem.setAttribute(attr, value);
|
_this12.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this6.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this6.elem.removeAttribute(attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (attr === 'transform') {
|
||||||
bChangedTransform = true;
|
bChangedTransform = true;
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
|
||||||
var angle = getRotationAngle(this.elem);
|
|
||||||
|
|
||||||
if (angle) {
|
|
||||||
var bbox = this.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);
|
|
||||||
}
|
}
|
||||||
}
|
}); // relocate rotational transform, if necessary
|
||||||
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
|
||||||
|
if (!bChangedTransform) {
|
||||||
|
var angle = getRotationAngle(_this12.elem);
|
||||||
|
|
||||||
|
if (angle) {
|
||||||
|
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 !== _this12.elem.getAttribute('transform')) {
|
||||||
|
_this12.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
||||||
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
removeElementFromListMap(_this12.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return ChangeElementCommand;
|
return ChangeElementCommand;
|
||||||
}(Command);
|
}(Command); // TODO: create a 'typing' command object that tracks changes in text
|
||||||
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // 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
|
// 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
|
// and they both affect the same element, then collapse the two commands into one
|
||||||
|
|
||||||
@@ -4465,49 +4417,35 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function BatchCommand(text) {
|
function BatchCommand(text) {
|
||||||
var _this7;
|
var _this13;
|
||||||
|
|
||||||
_classCallCheck(this, BatchCommand);
|
_classCallCheck(this, BatchCommand);
|
||||||
|
|
||||||
_this7 = _super5.call(this);
|
_this13 = _super5.call(this);
|
||||||
_this7.text = text || 'Batch Command';
|
_this13.text = text || 'Batch Command';
|
||||||
_this7.stack = [];
|
_this13.stack = [];
|
||||||
return _this7;
|
return _this13;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.BatchCommand"}
|
* Runs "apply" on all subcommands.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(BatchCommand, [{
|
_createClass(BatchCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.BatchCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Runs "apply" on all subcommands.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this14 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var len = this.stack.length;
|
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this14.stack.forEach(function (stackItem) {
|
||||||
for (var i = 0; i < len; ++i) {
|
// eslint-disable-next-line no-console
|
||||||
this.stack[i].apply(handler);
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
}
|
stackItem && stackItem.apply(handler);
|
||||||
|
});
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Runs "unapply" on all subcommands.
|
* Runs "unapply" on all subcommands.
|
||||||
@@ -4519,17 +4457,15 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this15 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = this.stack.length - 1; i >= 0; i--) {
|
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.stack[i].unapply(handler);
|
_this15.stack.forEach(function (stackItem) {
|
||||||
}
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
if (handler) {
|
stackItem && stackItem.unapply(handler);
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Iterate through all our subcommands.
|
* Iterate through all our subcommands.
|
||||||
@@ -4543,6 +4479,7 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
|
|||||||
var cmd = this.stack.length;
|
var cmd = this.stack.length;
|
||||||
|
|
||||||
while (cmd--) {
|
while (cmd--) {
|
||||||
|
if (!this.stack[cmd]) continue;
|
||||||
var thisElems = this.stack[cmd].elements();
|
var thisElems = this.stack[cmd].elements();
|
||||||
var elem = thisElems.length;
|
var elem = thisElems.length;
|
||||||
|
|
||||||
@@ -4564,6 +4501,8 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
|
|||||||
}, {
|
}, {
|
||||||
key: "addSubCommand",
|
key: "addSubCommand",
|
||||||
value: function addSubCommand(cmd) {
|
value: function addSubCommand(cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(cmd !== null, 'cmd should not be null');
|
||||||
this.stack.push(cmd);
|
this.stack.push(cmd);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -4579,7 +4518,6 @@ var BatchCommand = /*#__PURE__*/function (_Command5) {
|
|||||||
|
|
||||||
return BatchCommand;
|
return BatchCommand;
|
||||||
}(Command);
|
}(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 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 visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
|
||||||
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
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 editorContext_$1 = null;
|
||||||
var domdoc_ = null;
|
var domdoc_ = null;
|
||||||
@@ -9446,6 +9384,9 @@ var copyElem = function copyElem(el, getNextId) {
|
|||||||
var isNullish = function isNullish(val) {
|
var isNullish = function isNullish(val) {
|
||||||
return val === null || val === undefined;
|
return val === null || val === undefined;
|
||||||
};
|
};
|
||||||
|
var $q = function $q(sel) {
|
||||||
|
return document.querySelector(sel);
|
||||||
|
};
|
||||||
|
|
||||||
/* globals jQuery */
|
/* globals jQuery */
|
||||||
|
|
||||||
@@ -14210,18 +14151,18 @@ function SvgCanvas(container, config) {
|
|||||||
var cmdType = cmd.type();
|
var cmdType = cmd.type();
|
||||||
var isApply = eventType === EventTypes.AFTER_APPLY;
|
var isApply = eventType === EventTypes.AFTER_APPLY;
|
||||||
|
|
||||||
if (cmdType === MoveElementCommand$1.type()) {
|
if (cmdType === 'MoveElementCommand') {
|
||||||
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
||||||
|
|
||||||
if (parent === svgcontent) {
|
if (parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
|
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
|
||||||
if (cmd.parent === svgcontent) {
|
if (cmd.parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdType === InsertElementCommand$1.type()) {
|
if (cmdType === 'InsertElementCommand') {
|
||||||
if (isApply) {
|
if (isApply) {
|
||||||
restoreRefElems(cmd.elem);
|
restoreRefElems(cmd.elem);
|
||||||
}
|
}
|
||||||
@@ -14232,7 +14173,7 @@ function SvgCanvas(container, config) {
|
|||||||
if (cmd.elem && cmd.elem.tagName === 'use') {
|
if (cmd.elem && cmd.elem.tagName === 'use') {
|
||||||
setUseData(cmd.elem);
|
setUseData(cmd.elem);
|
||||||
}
|
}
|
||||||
} else if (cmdType === ChangeElementCommand$1.type()) {
|
} else if (cmdType === 'ChangeElementCommand') {
|
||||||
// if we are changing layer names, re-identify all layers
|
// if we are changing layer names, re-identify all layers
|
||||||
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
@@ -28661,6 +28602,7 @@ function loadStylesheets(stylesheets) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $q$1 = $q;
|
||||||
var editor = {};
|
var editor = {};
|
||||||
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
||||||
return func(jq);
|
return func(jq);
|
||||||
@@ -35533,7 +35475,7 @@ editor.init = function () {
|
|||||||
var btn;
|
var btn;
|
||||||
|
|
||||||
if (opts.sel) {
|
if (opts.sel) {
|
||||||
btn = document.querySelector(opts.sel);
|
btn = $q$1(opts.sel);
|
||||||
|
|
||||||
if (btn === null) {
|
if (btn === null) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
14
dist/index-es.min.js
vendored
14
dist/index-es.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index-es.min.js.map
vendored
2
dist/index-es.min.js.map
vendored
File diff suppressed because one or more lines are too long
596
dist/index-umd.js
vendored
596
dist/index-umd.js
vendored
@@ -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) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -3622,7 +3652,7 @@
|
|||||||
* @function module:units.ElementContainer#getRoundDigits
|
* @function module:units.ElementContainer#getRoundDigits
|
||||||
* @returns {Integer} The number of digits number should be rounded to
|
* @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 */
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
|
||||||
@@ -3865,8 +3895,7 @@
|
|||||||
AFTER_APPLY: 'after_apply',
|
AFTER_APPLY: 'after_apply',
|
||||||
BEFORE_UNAPPLY: 'before_unapply',
|
BEFORE_UNAPPLY: 'before_unapply',
|
||||||
AFTER_UNAPPLY: 'after_unapply'
|
AFTER_UNAPPLY: 'after_unapply'
|
||||||
}; // const removedElements = {};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for commands.
|
* Base class for commands.
|
||||||
*/
|
*/
|
||||||
@@ -3885,6 +3914,51 @@
|
|||||||
value: function getText() {
|
value: function getText() {
|
||||||
return this.text;
|
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;
|
return Command;
|
||||||
@@ -3933,12 +4007,6 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the type.
|
|
||||||
* @function module:history.HistoryCommand#type
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event module:history~Command#event:history
|
* @event module:history~Command#event:history
|
||||||
* @type {module:history.HistoryCommand}
|
* @type {module:history.HistoryCommand}
|
||||||
@@ -3991,36 +4059,21 @@
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.MoveElementCommand"}
|
* Re-positions the element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(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
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
|
var _this2 = this;
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Positions the element back to its original location.
|
* Positions the element back to its original location.
|
||||||
@@ -4032,30 +4085,16 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this3 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
|
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return MoveElementCommand;
|
return MoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
MoveElementCommand.type = MoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element that was added to the DOM.
|
* History command for an element that was added to the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4071,47 +4110,33 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function InsertElementCommand(elem, text) {
|
function InsertElementCommand(elem, text) {
|
||||||
var _this2;
|
var _this4;
|
||||||
|
|
||||||
_classCallCheck(this, InsertElementCommand);
|
_classCallCheck(this, InsertElementCommand);
|
||||||
|
|
||||||
_this2 = _super2.call(this);
|
_this4 = _super2.call(this);
|
||||||
_this2.elem = elem;
|
_this4.elem = elem;
|
||||||
_this2.text = text || 'Create ' + elem.tagName;
|
_this4.text = text || 'Create ' + elem.tagName;
|
||||||
_this2.parent = elem.parentNode;
|
_this4.parent = elem.parentNode;
|
||||||
_this2.nextSibling = _this2.elem.nextSibling;
|
_this4.nextSibling = _this4.elem.nextSibling;
|
||||||
return _this2;
|
return _this4;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.InsertElementCommand"}
|
* Re-inserts the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(InsertElementCommand, [{
|
_createClass(InsertElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.InsertElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-inserts the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this5 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the element.
|
* Removes the element.
|
||||||
@@ -4123,31 +4148,18 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this6 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent = this.elem.parentNode;
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.elem.remove();
|
_this6.parent = _this6.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this6.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @returns {Element[]} Array with element associated with this command
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "elements",
|
|
||||||
value: function elements() {
|
|
||||||
return [this.elem];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return InsertElementCommand;
|
return InsertElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
InsertElementCommand.type = InsertElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element removed from the DOM.
|
* History command for an element removed from the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4165,51 +4177,38 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
||||||
var _this3;
|
var _this7;
|
||||||
|
|
||||||
_classCallCheck(this, RemoveElementCommand);
|
_classCallCheck(this, RemoveElementCommand);
|
||||||
|
|
||||||
_this3 = _super3.call(this);
|
_this7 = _super3.call(this);
|
||||||
_this3.elem = elem;
|
_this7.elem = elem;
|
||||||
_this3.text = text || 'Delete ' + elem.tagName;
|
_this7.text = text || 'Delete ' + elem.tagName;
|
||||||
_this3.nextSibling = oldNextSibling;
|
_this7.nextSibling = oldNextSibling;
|
||||||
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
||||||
|
|
||||||
removeElementFromListMap(elem);
|
removeElementFromListMap(elem);
|
||||||
return _this3;
|
return _this7;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.RemoveElementCommand"}
|
* Re-removes the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(RemoveElementCommand, [{
|
_createClass(RemoveElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.RemoveElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-removes the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this8 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
this.parent = this.elem.parentNode;
|
removeElementFromListMap(_this8.elem);
|
||||||
this.elem.remove();
|
_this8.parent = _this8.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this8.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Re-adds the new element.
|
* Re-adds the new element.
|
||||||
@@ -4221,38 +4220,25 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this9 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, 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) {
|
if (window.console) {
|
||||||
console.log('Error: reference element was lost'); // eslint-disable-line no-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;
|
return RemoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
||||||
*/
|
*/
|
||||||
@@ -4278,182 +4264,148 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function ChangeElementCommand(elem, attrs, text) {
|
function ChangeElementCommand(elem, attrs, text) {
|
||||||
var _this4;
|
var _this10;
|
||||||
|
|
||||||
_classCallCheck(this, ChangeElementCommand);
|
_classCallCheck(this, ChangeElementCommand);
|
||||||
|
|
||||||
_this4 = _super4.call(this);
|
_this10 = _super4.call(this);
|
||||||
_this4.elem = elem;
|
_this10.elem = elem;
|
||||||
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
||||||
_this4.newValues = {};
|
_this10.newValues = {};
|
||||||
_this4.oldValues = attrs;
|
_this10.oldValues = attrs;
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
if (attr === '#text') {
|
if (attr === '#text') {
|
||||||
_this4.newValues[attr] = elem.textContent;
|
_this10.newValues[attr] = elem.textContent;
|
||||||
} else if (attr === '#href') {
|
} else if (attr === '#href') {
|
||||||
_this4.newValues[attr] = getHref(elem);
|
_this10.newValues[attr] = getHref(elem);
|
||||||
} else {
|
} else {
|
||||||
_this4.newValues[attr] = elem.getAttribute(attr);
|
_this10.newValues[attr] = elem.getAttribute(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this4;
|
return _this10;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.ChangeElementCommand"}
|
* Performs the stored change action.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(ChangeElementCommand, [{
|
_createClass(ChangeElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.ChangeElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Performs the stored change action.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {true}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
var _this5 = this;
|
var _this11 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this11.newValues).forEach(function (_ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
attr = _ref2[0],
|
||||||
|
value = _ref2[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.newValues).forEach(function (_ref) {
|
if (attr === '#text') {
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
_this11.elem.textContent = value;
|
||||||
attr = _ref2[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref2[1];
|
setHref(_this11.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this11.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this5.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this11.elem.textContent = '';
|
||||||
setHref(_this5.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this5.elem.setAttribute(attr, value);
|
_this11.elem.setAttribute(attr, '');
|
||||||
|
|
||||||
|
_this11.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this5.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this5.elem.setAttribute(attr, '');
|
|
||||||
|
|
||||||
_this5.elem.removeAttribute(attr);
|
if (attr === 'transform') {
|
||||||
}
|
bChangedTransform = true;
|
||||||
|
}
|
||||||
|
}); // relocate rotational transform, if necessary
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (!bChangedTransform) {
|
||||||
bChangedTransform = true;
|
var angle = getRotationAngle(_this11.elem);
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
if (angle) {
|
||||||
var angle = getRotationAngle(this.elem);
|
var bbox = _this11.elem.getBBox();
|
||||||
|
|
||||||
if (angle) {
|
var cx = bbox.x + bbox.width / 2;
|
||||||
var bbox = this.elem.getBBox();
|
var cy = bbox.y + bbox.height / 2;
|
||||||
var cx = bbox.x + bbox.width / 2,
|
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
||||||
cy = bbox.y + bbox.height / 2;
|
|
||||||
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
|
||||||
|
|
||||||
if (rotate !== this.elem.getAttribute('transform')) {
|
if (rotate !== _this11.elem.getAttribute('transform')) {
|
||||||
this.elem.setAttribute('transform', rotate);
|
_this11.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Reverses the stored change action.
|
* Reverses the stored change action.
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
* @fires module:history~Command#event:history
|
* @fires module:history~Command#event:history
|
||||||
* @returns {true}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
var _this6 = this;
|
var _this12 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this12.oldValues).forEach(function (_ref3) {
|
||||||
|
var _ref4 = _slicedToArray(_ref3, 2),
|
||||||
|
attr = _ref4[0],
|
||||||
|
value = _ref4[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.oldValues).forEach(function (_ref3) {
|
if (attr === '#text') {
|
||||||
var _ref4 = _slicedToArray(_ref3, 2),
|
_this12.elem.textContent = value;
|
||||||
attr = _ref4[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref4[1];
|
setHref(_this12.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this12.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this6.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this12.elem.textContent = '';
|
||||||
setHref(_this6.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this6.elem.setAttribute(attr, value);
|
_this12.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this6.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this6.elem.removeAttribute(attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (attr === 'transform') {
|
||||||
bChangedTransform = true;
|
bChangedTransform = true;
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
|
||||||
var angle = getRotationAngle(this.elem);
|
|
||||||
|
|
||||||
if (angle) {
|
|
||||||
var bbox = this.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);
|
|
||||||
}
|
}
|
||||||
}
|
}); // relocate rotational transform, if necessary
|
||||||
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
|
||||||
|
if (!bChangedTransform) {
|
||||||
|
var angle = getRotationAngle(_this12.elem);
|
||||||
|
|
||||||
|
if (angle) {
|
||||||
|
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 !== _this12.elem.getAttribute('transform')) {
|
||||||
|
_this12.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
||||||
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
removeElementFromListMap(_this12.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return ChangeElementCommand;
|
return ChangeElementCommand;
|
||||||
}(Command);
|
}(Command); // TODO: create a 'typing' command object that tracks changes in text
|
||||||
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // 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
|
// 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
|
// and they both affect the same element, then collapse the two commands into one
|
||||||
|
|
||||||
@@ -4471,49 +4423,35 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function BatchCommand(text) {
|
function BatchCommand(text) {
|
||||||
var _this7;
|
var _this13;
|
||||||
|
|
||||||
_classCallCheck(this, BatchCommand);
|
_classCallCheck(this, BatchCommand);
|
||||||
|
|
||||||
_this7 = _super5.call(this);
|
_this13 = _super5.call(this);
|
||||||
_this7.text = text || 'Batch Command';
|
_this13.text = text || 'Batch Command';
|
||||||
_this7.stack = [];
|
_this13.stack = [];
|
||||||
return _this7;
|
return _this13;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.BatchCommand"}
|
* Runs "apply" on all subcommands.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(BatchCommand, [{
|
_createClass(BatchCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.BatchCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Runs "apply" on all subcommands.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this14 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var len = this.stack.length;
|
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this14.stack.forEach(function (stackItem) {
|
||||||
for (var i = 0; i < len; ++i) {
|
// eslint-disable-next-line no-console
|
||||||
this.stack[i].apply(handler);
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
}
|
stackItem && stackItem.apply(handler);
|
||||||
|
});
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Runs "unapply" on all subcommands.
|
* Runs "unapply" on all subcommands.
|
||||||
@@ -4525,17 +4463,15 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this15 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = this.stack.length - 1; i >= 0; i--) {
|
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.stack[i].unapply(handler);
|
_this15.stack.forEach(function (stackItem) {
|
||||||
}
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
if (handler) {
|
stackItem && stackItem.unapply(handler);
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Iterate through all our subcommands.
|
* Iterate through all our subcommands.
|
||||||
@@ -4549,6 +4485,7 @@
|
|||||||
var cmd = this.stack.length;
|
var cmd = this.stack.length;
|
||||||
|
|
||||||
while (cmd--) {
|
while (cmd--) {
|
||||||
|
if (!this.stack[cmd]) continue;
|
||||||
var thisElems = this.stack[cmd].elements();
|
var thisElems = this.stack[cmd].elements();
|
||||||
var elem = thisElems.length;
|
var elem = thisElems.length;
|
||||||
|
|
||||||
@@ -4570,6 +4507,8 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "addSubCommand",
|
key: "addSubCommand",
|
||||||
value: function addSubCommand(cmd) {
|
value: function addSubCommand(cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(cmd !== null, 'cmd should not be null');
|
||||||
this.stack.push(cmd);
|
this.stack.push(cmd);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -4585,7 +4524,6 @@
|
|||||||
|
|
||||||
return BatchCommand;
|
return BatchCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
BatchCommand.type = BatchCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8016,8 +7954,8 @@
|
|||||||
|
|
||||||
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
|
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 visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
|
||||||
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
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 editorContext_$1 = null;
|
||||||
var domdoc_ = null;
|
var domdoc_ = null;
|
||||||
@@ -9452,6 +9390,9 @@
|
|||||||
var isNullish = function isNullish(val) {
|
var isNullish = function isNullish(val) {
|
||||||
return val === null || val === undefined;
|
return val === null || val === undefined;
|
||||||
};
|
};
|
||||||
|
var $q = function $q(sel) {
|
||||||
|
return document.querySelector(sel);
|
||||||
|
};
|
||||||
|
|
||||||
/* globals jQuery */
|
/* globals jQuery */
|
||||||
|
|
||||||
@@ -14216,18 +14157,18 @@
|
|||||||
var cmdType = cmd.type();
|
var cmdType = cmd.type();
|
||||||
var isApply = eventType === EventTypes.AFTER_APPLY;
|
var isApply = eventType === EventTypes.AFTER_APPLY;
|
||||||
|
|
||||||
if (cmdType === MoveElementCommand$1.type()) {
|
if (cmdType === 'MoveElementCommand') {
|
||||||
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
||||||
|
|
||||||
if (parent === svgcontent) {
|
if (parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
|
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
|
||||||
if (cmd.parent === svgcontent) {
|
if (cmd.parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdType === InsertElementCommand$1.type()) {
|
if (cmdType === 'InsertElementCommand') {
|
||||||
if (isApply) {
|
if (isApply) {
|
||||||
restoreRefElems(cmd.elem);
|
restoreRefElems(cmd.elem);
|
||||||
}
|
}
|
||||||
@@ -14238,7 +14179,7 @@
|
|||||||
if (cmd.elem && cmd.elem.tagName === 'use') {
|
if (cmd.elem && cmd.elem.tagName === 'use') {
|
||||||
setUseData(cmd.elem);
|
setUseData(cmd.elem);
|
||||||
}
|
}
|
||||||
} else if (cmdType === ChangeElementCommand$1.type()) {
|
} else if (cmdType === 'ChangeElementCommand') {
|
||||||
// if we are changing layer names, re-identify all layers
|
// if we are changing layer names, re-identify all layers
|
||||||
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
@@ -28667,6 +28608,7 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $q$1 = $q;
|
||||||
var editor = {};
|
var editor = {};
|
||||||
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
||||||
return func(jq);
|
return func(jq);
|
||||||
@@ -35539,7 +35481,7 @@
|
|||||||
var btn;
|
var btn;
|
||||||
|
|
||||||
if (opts.sel) {
|
if (opts.sel) {
|
||||||
btn = document.querySelector(opts.sel);
|
btn = $q$1(opts.sel);
|
||||||
|
|
||||||
if (btn === null) {
|
if (btn === null) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
14
dist/index-umd.min.js
vendored
14
dist/index-umd.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index-umd.min.js.map
vendored
2
dist/index-umd.min.js.map
vendored
File diff suppressed because one or more lines are too long
5328
dist/svgcanvas-iife.js
vendored
5328
dist/svgcanvas-iife.js
vendored
File diff suppressed because it is too large
Load Diff
8
dist/svgcanvas-iife.min.js
vendored
8
dist/svgcanvas-iife.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/svgcanvas-iife.min.js.map
vendored
2
dist/svgcanvas-iife.min.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -419,6 +419,7 @@ export class BatchCommand extends Command {
|
|||||||
apply (handler) {
|
apply (handler) {
|
||||||
super.apply(handler, () => {
|
super.apply(handler, () => {
|
||||||
this.stack.forEach((stackItem) => {
|
this.stack.forEach((stackItem) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.assert(stackItem, 'stack item should not be null');
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
stackItem && stackItem.apply(handler);
|
stackItem && stackItem.apply(handler);
|
||||||
});
|
});
|
||||||
@@ -434,6 +435,7 @@ export class BatchCommand extends Command {
|
|||||||
unapply (handler) {
|
unapply (handler) {
|
||||||
super.unapply(handler, () => {
|
super.unapply(handler, () => {
|
||||||
this.stack.forEach((stackItem) => {
|
this.stack.forEach((stackItem) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.assert(stackItem, 'stack item should not be null');
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
stackItem && stackItem.unapply(handler);
|
stackItem && stackItem.unapply(handler);
|
||||||
});
|
});
|
||||||
@@ -464,6 +466,7 @@ export class BatchCommand extends Command {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
addSubCommand (cmd) {
|
addSubCommand (cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.assert(cmd !== null, 'cmd should not be null');
|
console.assert(cmd !== null, 'cmd should not be null');
|
||||||
this.stack.push(cmd);
|
this.stack.push(cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ let typeMap_ = {};
|
|||||||
* @returns {Integer} The number of digits number should be rounded to
|
* @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 */
|
/* eslint-disable jsdoc/valid-types */
|
||||||
/**
|
/**
|
||||||
* @typedef {PlainObject} module:units.TypeMap
|
* @typedef {PlainObject} module:units.TypeMap
|
||||||
|
|||||||
@@ -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) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -3619,7 +3649,7 @@
|
|||||||
* @function module:units.ElementContainer#getRoundDigits
|
* @function module:units.ElementContainer#getRoundDigits
|
||||||
* @returns {Integer} The number of digits number should be rounded to
|
* @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 */
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
|
||||||
@@ -3862,8 +3892,7 @@
|
|||||||
AFTER_APPLY: 'after_apply',
|
AFTER_APPLY: 'after_apply',
|
||||||
BEFORE_UNAPPLY: 'before_unapply',
|
BEFORE_UNAPPLY: 'before_unapply',
|
||||||
AFTER_UNAPPLY: 'after_unapply'
|
AFTER_UNAPPLY: 'after_unapply'
|
||||||
}; // const removedElements = {};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for commands.
|
* Base class for commands.
|
||||||
*/
|
*/
|
||||||
@@ -3882,6 +3911,51 @@
|
|||||||
value: function getText() {
|
value: function getText() {
|
||||||
return this.text;
|
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;
|
return Command;
|
||||||
@@ -3930,12 +4004,6 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the type.
|
|
||||||
* @function module:history.HistoryCommand#type
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event module:history~Command#event:history
|
* @event module:history~Command#event:history
|
||||||
* @type {module:history.HistoryCommand}
|
* @type {module:history.HistoryCommand}
|
||||||
@@ -3988,36 +4056,21 @@
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.MoveElementCommand"}
|
* Re-positions the element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(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
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
|
var _this2 = this;
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Positions the element back to its original location.
|
* Positions the element back to its original location.
|
||||||
@@ -4029,30 +4082,16 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this3 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
|
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return MoveElementCommand;
|
return MoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
MoveElementCommand.type = MoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element that was added to the DOM.
|
* History command for an element that was added to the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4068,47 +4107,33 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function InsertElementCommand(elem, text) {
|
function InsertElementCommand(elem, text) {
|
||||||
var _this2;
|
var _this4;
|
||||||
|
|
||||||
_classCallCheck(this, InsertElementCommand);
|
_classCallCheck(this, InsertElementCommand);
|
||||||
|
|
||||||
_this2 = _super2.call(this);
|
_this4 = _super2.call(this);
|
||||||
_this2.elem = elem;
|
_this4.elem = elem;
|
||||||
_this2.text = text || 'Create ' + elem.tagName;
|
_this4.text = text || 'Create ' + elem.tagName;
|
||||||
_this2.parent = elem.parentNode;
|
_this4.parent = elem.parentNode;
|
||||||
_this2.nextSibling = _this2.elem.nextSibling;
|
_this4.nextSibling = _this4.elem.nextSibling;
|
||||||
return _this2;
|
return _this4;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.InsertElementCommand"}
|
* Re-inserts the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(InsertElementCommand, [{
|
_createClass(InsertElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.InsertElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-inserts the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this5 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the element.
|
* Removes the element.
|
||||||
@@ -4120,31 +4145,18 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this6 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent = this.elem.parentNode;
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.elem.remove();
|
_this6.parent = _this6.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this6.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @returns {Element[]} Array with element associated with this command
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "elements",
|
|
||||||
value: function elements() {
|
|
||||||
return [this.elem];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return InsertElementCommand;
|
return InsertElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
InsertElementCommand.type = InsertElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element removed from the DOM.
|
* History command for an element removed from the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4162,51 +4174,38 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
||||||
var _this3;
|
var _this7;
|
||||||
|
|
||||||
_classCallCheck(this, RemoveElementCommand);
|
_classCallCheck(this, RemoveElementCommand);
|
||||||
|
|
||||||
_this3 = _super3.call(this);
|
_this7 = _super3.call(this);
|
||||||
_this3.elem = elem;
|
_this7.elem = elem;
|
||||||
_this3.text = text || 'Delete ' + elem.tagName;
|
_this7.text = text || 'Delete ' + elem.tagName;
|
||||||
_this3.nextSibling = oldNextSibling;
|
_this7.nextSibling = oldNextSibling;
|
||||||
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
||||||
|
|
||||||
removeElementFromListMap(elem);
|
removeElementFromListMap(elem);
|
||||||
return _this3;
|
return _this7;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.RemoveElementCommand"}
|
* Re-removes the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(RemoveElementCommand, [{
|
_createClass(RemoveElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.RemoveElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-removes the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this8 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
this.parent = this.elem.parentNode;
|
removeElementFromListMap(_this8.elem);
|
||||||
this.elem.remove();
|
_this8.parent = _this8.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this8.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Re-adds the new element.
|
* Re-adds the new element.
|
||||||
@@ -4218,38 +4217,25 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this9 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, 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) {
|
if (window.console) {
|
||||||
console.log('Error: reference element was lost'); // eslint-disable-line no-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;
|
return RemoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
||||||
*/
|
*/
|
||||||
@@ -4275,182 +4261,148 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function ChangeElementCommand(elem, attrs, text) {
|
function ChangeElementCommand(elem, attrs, text) {
|
||||||
var _this4;
|
var _this10;
|
||||||
|
|
||||||
_classCallCheck(this, ChangeElementCommand);
|
_classCallCheck(this, ChangeElementCommand);
|
||||||
|
|
||||||
_this4 = _super4.call(this);
|
_this10 = _super4.call(this);
|
||||||
_this4.elem = elem;
|
_this10.elem = elem;
|
||||||
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
||||||
_this4.newValues = {};
|
_this10.newValues = {};
|
||||||
_this4.oldValues = attrs;
|
_this10.oldValues = attrs;
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
if (attr === '#text') {
|
if (attr === '#text') {
|
||||||
_this4.newValues[attr] = elem.textContent;
|
_this10.newValues[attr] = elem.textContent;
|
||||||
} else if (attr === '#href') {
|
} else if (attr === '#href') {
|
||||||
_this4.newValues[attr] = getHref(elem);
|
_this10.newValues[attr] = getHref(elem);
|
||||||
} else {
|
} else {
|
||||||
_this4.newValues[attr] = elem.getAttribute(attr);
|
_this10.newValues[attr] = elem.getAttribute(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this4;
|
return _this10;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.ChangeElementCommand"}
|
* Performs the stored change action.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(ChangeElementCommand, [{
|
_createClass(ChangeElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.ChangeElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Performs the stored change action.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {true}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
var _this5 = this;
|
var _this11 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this11.newValues).forEach(function (_ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
attr = _ref2[0],
|
||||||
|
value = _ref2[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.newValues).forEach(function (_ref) {
|
if (attr === '#text') {
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
_this11.elem.textContent = value;
|
||||||
attr = _ref2[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref2[1];
|
setHref(_this11.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this11.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this5.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this11.elem.textContent = '';
|
||||||
setHref(_this5.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this5.elem.setAttribute(attr, value);
|
_this11.elem.setAttribute(attr, '');
|
||||||
|
|
||||||
|
_this11.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this5.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this5.elem.setAttribute(attr, '');
|
|
||||||
|
|
||||||
_this5.elem.removeAttribute(attr);
|
if (attr === 'transform') {
|
||||||
}
|
bChangedTransform = true;
|
||||||
|
}
|
||||||
|
}); // relocate rotational transform, if necessary
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (!bChangedTransform) {
|
||||||
bChangedTransform = true;
|
var angle = getRotationAngle(_this11.elem);
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
if (angle) {
|
||||||
var angle = getRotationAngle(this.elem);
|
var bbox = _this11.elem.getBBox();
|
||||||
|
|
||||||
if (angle) {
|
var cx = bbox.x + bbox.width / 2;
|
||||||
var bbox = this.elem.getBBox();
|
var cy = bbox.y + bbox.height / 2;
|
||||||
var cx = bbox.x + bbox.width / 2,
|
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
||||||
cy = bbox.y + bbox.height / 2;
|
|
||||||
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
|
||||||
|
|
||||||
if (rotate !== this.elem.getAttribute('transform')) {
|
if (rotate !== _this11.elem.getAttribute('transform')) {
|
||||||
this.elem.setAttribute('transform', rotate);
|
_this11.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Reverses the stored change action.
|
* Reverses the stored change action.
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
* @fires module:history~Command#event:history
|
* @fires module:history~Command#event:history
|
||||||
* @returns {true}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
var _this6 = this;
|
var _this12 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this12.oldValues).forEach(function (_ref3) {
|
||||||
|
var _ref4 = _slicedToArray(_ref3, 2),
|
||||||
|
attr = _ref4[0],
|
||||||
|
value = _ref4[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.oldValues).forEach(function (_ref3) {
|
if (attr === '#text') {
|
||||||
var _ref4 = _slicedToArray(_ref3, 2),
|
_this12.elem.textContent = value;
|
||||||
attr = _ref4[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref4[1];
|
setHref(_this12.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this12.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this6.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this12.elem.textContent = '';
|
||||||
setHref(_this6.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this6.elem.setAttribute(attr, value);
|
_this12.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this6.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this6.elem.removeAttribute(attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (attr === 'transform') {
|
||||||
bChangedTransform = true;
|
bChangedTransform = true;
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
|
||||||
var angle = getRotationAngle(this.elem);
|
|
||||||
|
|
||||||
if (angle) {
|
|
||||||
var bbox = this.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);
|
|
||||||
}
|
}
|
||||||
}
|
}); // relocate rotational transform, if necessary
|
||||||
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
|
||||||
|
if (!bChangedTransform) {
|
||||||
|
var angle = getRotationAngle(_this12.elem);
|
||||||
|
|
||||||
|
if (angle) {
|
||||||
|
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 !== _this12.elem.getAttribute('transform')) {
|
||||||
|
_this12.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
||||||
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
removeElementFromListMap(_this12.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return ChangeElementCommand;
|
return ChangeElementCommand;
|
||||||
}(Command);
|
}(Command); // TODO: create a 'typing' command object that tracks changes in text
|
||||||
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // 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
|
// 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
|
// and they both affect the same element, then collapse the two commands into one
|
||||||
|
|
||||||
@@ -4468,49 +4420,35 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function BatchCommand(text) {
|
function BatchCommand(text) {
|
||||||
var _this7;
|
var _this13;
|
||||||
|
|
||||||
_classCallCheck(this, BatchCommand);
|
_classCallCheck(this, BatchCommand);
|
||||||
|
|
||||||
_this7 = _super5.call(this);
|
_this13 = _super5.call(this);
|
||||||
_this7.text = text || 'Batch Command';
|
_this13.text = text || 'Batch Command';
|
||||||
_this7.stack = [];
|
_this13.stack = [];
|
||||||
return _this7;
|
return _this13;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.BatchCommand"}
|
* Runs "apply" on all subcommands.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(BatchCommand, [{
|
_createClass(BatchCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.BatchCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Runs "apply" on all subcommands.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this14 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var len = this.stack.length;
|
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this14.stack.forEach(function (stackItem) {
|
||||||
for (var i = 0; i < len; ++i) {
|
// eslint-disable-next-line no-console
|
||||||
this.stack[i].apply(handler);
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
}
|
stackItem && stackItem.apply(handler);
|
||||||
|
});
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Runs "unapply" on all subcommands.
|
* Runs "unapply" on all subcommands.
|
||||||
@@ -4522,17 +4460,15 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this15 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = this.stack.length - 1; i >= 0; i--) {
|
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.stack[i].unapply(handler);
|
_this15.stack.forEach(function (stackItem) {
|
||||||
}
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
if (handler) {
|
stackItem && stackItem.unapply(handler);
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Iterate through all our subcommands.
|
* Iterate through all our subcommands.
|
||||||
@@ -4546,6 +4482,7 @@
|
|||||||
var cmd = this.stack.length;
|
var cmd = this.stack.length;
|
||||||
|
|
||||||
while (cmd--) {
|
while (cmd--) {
|
||||||
|
if (!this.stack[cmd]) continue;
|
||||||
var thisElems = this.stack[cmd].elements();
|
var thisElems = this.stack[cmd].elements();
|
||||||
var elem = thisElems.length;
|
var elem = thisElems.length;
|
||||||
|
|
||||||
@@ -4567,6 +4504,8 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "addSubCommand",
|
key: "addSubCommand",
|
||||||
value: function addSubCommand(cmd) {
|
value: function addSubCommand(cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(cmd !== null, 'cmd should not be null');
|
||||||
this.stack.push(cmd);
|
this.stack.push(cmd);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -4582,7 +4521,6 @@
|
|||||||
|
|
||||||
return BatchCommand;
|
return BatchCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
BatchCommand.type = BatchCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8013,8 +7951,8 @@
|
|||||||
|
|
||||||
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
|
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 visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
|
||||||
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
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 editorContext_$1 = null;
|
||||||
var domdoc_ = null;
|
var domdoc_ = null;
|
||||||
@@ -9449,6 +9387,9 @@
|
|||||||
var isNullish = function isNullish(val) {
|
var isNullish = function isNullish(val) {
|
||||||
return val === null || val === undefined;
|
return val === null || val === undefined;
|
||||||
};
|
};
|
||||||
|
var $q = function $q(sel) {
|
||||||
|
return document.querySelector(sel);
|
||||||
|
};
|
||||||
|
|
||||||
/* globals jQuery */
|
/* globals jQuery */
|
||||||
|
|
||||||
@@ -14213,18 +14154,18 @@
|
|||||||
var cmdType = cmd.type();
|
var cmdType = cmd.type();
|
||||||
var isApply = eventType === EventTypes.AFTER_APPLY;
|
var isApply = eventType === EventTypes.AFTER_APPLY;
|
||||||
|
|
||||||
if (cmdType === MoveElementCommand$1.type()) {
|
if (cmdType === 'MoveElementCommand') {
|
||||||
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
||||||
|
|
||||||
if (parent === svgcontent) {
|
if (parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
|
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
|
||||||
if (cmd.parent === svgcontent) {
|
if (cmd.parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdType === InsertElementCommand$1.type()) {
|
if (cmdType === 'InsertElementCommand') {
|
||||||
if (isApply) {
|
if (isApply) {
|
||||||
restoreRefElems(cmd.elem);
|
restoreRefElems(cmd.elem);
|
||||||
}
|
}
|
||||||
@@ -14235,7 +14176,7 @@
|
|||||||
if (cmd.elem && cmd.elem.tagName === 'use') {
|
if (cmd.elem && cmd.elem.tagName === 'use') {
|
||||||
setUseData(cmd.elem);
|
setUseData(cmd.elem);
|
||||||
}
|
}
|
||||||
} else if (cmdType === ChangeElementCommand$1.type()) {
|
} else if (cmdType === 'ChangeElementCommand') {
|
||||||
// if we are changing layer names, re-identify all layers
|
// if we are changing layer names, re-identify all layers
|
||||||
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
@@ -28664,6 +28605,7 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $q$1 = $q;
|
||||||
var editor = {};
|
var editor = {};
|
||||||
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
||||||
return func(jq);
|
return func(jq);
|
||||||
@@ -35536,7 +35478,7 @@
|
|||||||
var btn;
|
var btn;
|
||||||
|
|
||||||
if (opts.sel) {
|
if (opts.sel) {
|
||||||
btn = document.querySelector(opts.sel);
|
btn = $q$1(opts.sel);
|
||||||
|
|
||||||
if (btn === null) {
|
if (btn === null) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
179
package-lock.json
generated
179
package-lock.json
generated
@@ -25,47 +25,37 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/core": {
|
"@babel/core": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.5.tgz",
|
||||||
"integrity": "sha512-3A0tS0HWpy4XujGc7QtOIHTeNwUgWaZc/WuS5YQrfhU67jnVmsD6OGPc1AKHH0LJHQICGncy3+YUjIhVlfDdcA==",
|
"integrity": "sha512-O34LQooYVDXPl7QWCdW9p4NR+QlzOr7xShPPJz8GsuCU3/8ua/wqTr7gmnxXv+WBESiGU/G5s16i6tUvHkNb+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.10.4",
|
"@babel/code-frame": "^7.10.4",
|
||||||
"@babel/generator": "^7.10.4",
|
"@babel/generator": "^7.10.5",
|
||||||
"@babel/helper-module-transforms": "^7.10.4",
|
"@babel/helper-module-transforms": "^7.10.5",
|
||||||
"@babel/helpers": "^7.10.4",
|
"@babel/helpers": "^7.10.4",
|
||||||
"@babel/parser": "^7.10.4",
|
"@babel/parser": "^7.10.5",
|
||||||
"@babel/template": "^7.10.4",
|
"@babel/template": "^7.10.4",
|
||||||
"@babel/traverse": "^7.10.4",
|
"@babel/traverse": "^7.10.5",
|
||||||
"@babel/types": "^7.10.4",
|
"@babel/types": "^7.10.5",
|
||||||
"convert-source-map": "^1.7.0",
|
"convert-source-map": "^1.7.0",
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.1.0",
|
||||||
"gensync": "^1.0.0-beta.1",
|
"gensync": "^1.0.0-beta.1",
|
||||||
"json5": "^2.1.2",
|
"json5": "^2.1.2",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"resolve": "^1.3.2",
|
"resolve": "^1.3.2",
|
||||||
"semver": "^5.4.1",
|
"semver": "^5.4.1",
|
||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": {
|
"@babel/generator": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.5.tgz",
|
||||||
"integrity": "sha512-toLIHUIAgcQygFZRAQcsLQV3CBuX6yOIru1kJk/qqqvcRmZrYe6WavZTSG+bB8MxhnL9YPf+pKQfuiP161q7ng==",
|
"integrity": "sha512-3vXxr3FEW7E7lJZiWQ3bM4+v/Vyr9C+hpolQ8BGFr9Y8Ri2tFLWTixmwKBafDujO1WVah4fhZBeU1bieKdghig==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/types": "^7.10.4",
|
"@babel/types": "^7.10.5",
|
||||||
"jsesc": "^2.5.1",
|
"jsesc": "^2.5.1",
|
||||||
"lodash": "^4.17.13",
|
|
||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -90,27 +80,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/helper-member-expression-to-functions": {
|
"@babel/helper-member-expression-to-functions": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.5.tgz",
|
||||||
"integrity": "sha512-m5j85pK/KZhuSdM/8cHUABQTAslV47OjfIB9Cc7P+PvlAoBzdb79BGNfw8RhT5Mq3p+xGd0ZfAKixbrUZx0C7A==",
|
"integrity": "sha512-HiqJpYD5+WopCXIAbQDG0zye5XYVvcO9w/DHp5GsaGkRUaamLj2bEtu6i8rnGGprAhHM3qidCMgp71HF4endhA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/types": "^7.10.4"
|
"@babel/types": "^7.10.5"
|
||||||
}
|
|
||||||
},
|
|
||||||
"@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/helper-module-transforms": {
|
"@babel/helper-module-transforms": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.5.tgz",
|
||||||
"integrity": "sha512-Er2FQX0oa3nV7eM1o0tNCTx7izmQtwAQsIiaLRWtavAAEcskb0XJ5OjJbVrYXWOTr8om921Scabn4/tzlx7j1Q==",
|
"integrity": "sha512-4P+CWMJ6/j1W915ITJaUkadLObmCRRSC234uctJfn/vHrsLNxsR8dwlcXv9ZhJWzl77awf+mWXSZEKt5t0OnlA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/helper-module-imports": "^7.10.4",
|
"@babel/helper-module-imports": "^7.10.4",
|
||||||
@@ -118,8 +99,8 @@
|
|||||||
"@babel/helper-simple-access": "^7.10.4",
|
"@babel/helper-simple-access": "^7.10.4",
|
||||||
"@babel/helper-split-export-declaration": "^7.10.4",
|
"@babel/helper-split-export-declaration": "^7.10.4",
|
||||||
"@babel/template": "^7.10.4",
|
"@babel/template": "^7.10.4",
|
||||||
"@babel/types": "^7.10.4",
|
"@babel/types": "^7.10.5",
|
||||||
"lodash": "^4.17.13"
|
"lodash": "^4.17.19"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/helper-optimise-call-expression": {
|
"@babel/helper-optimise-call-expression": {
|
||||||
@@ -162,12 +143,6 @@
|
|||||||
"@babel/types": "^7.10.4"
|
"@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": {
|
"@babel/helpers": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.4",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz",
|
||||||
@@ -179,21 +154,10 @@
|
|||||||
"@babel/types": "^7.10.4"
|
"@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": {
|
"@babel/parser": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.5.tgz",
|
||||||
"integrity": "sha512-8jHII4hf+YVDsskTF6WuMB3X4Eh+PsUkC2ljq22so5rHvH+T8BzyL94VOdyFLNR8tBSVXOTbNHOKpR4TfRxVtA==",
|
"integrity": "sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@babel/template": {
|
"@babel/template": {
|
||||||
@@ -208,38 +172,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/traverse": {
|
"@babel/traverse": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.5.tgz",
|
||||||
"integrity": "sha512-aSy7p5THgSYm4YyxNGz6jZpXf+Ok40QF3aA2LyIONkDHpAcJzDUqlCKXv6peqYUs2gmic849C/t2HKw2a2K20Q==",
|
"integrity": "sha512-yc/fyv2gUjPqzTz0WHeRJH2pv7jA9kA7mBX2tXl/x5iOE81uaVPuGPtaYk7wmkx4b67mQ7NqI8rmT2pF47KYKQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.10.4",
|
"@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-function-name": "^7.10.4",
|
||||||
"@babel/helper-split-export-declaration": "^7.10.4",
|
"@babel/helper-split-export-declaration": "^7.10.4",
|
||||||
"@babel/parser": "^7.10.4",
|
"@babel/parser": "^7.10.5",
|
||||||
"@babel/types": "^7.10.4",
|
"@babel/types": "^7.10.5",
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.1.0",
|
||||||
"globals": "^11.1.0",
|
"globals": "^11.1.0",
|
||||||
"lodash": "^4.17.13"
|
"lodash": "^4.17.19"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/types": {
|
"@babel/types": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.5.tgz",
|
||||||
"integrity": "sha512-UTCFOxC3FsFHb7lkRMVvgLzaRVamXuAs2Tz4wajva4WxtVY82eZeaUBtC2Zt95FU9TiznuC0Zk35tsim8jeVpg==",
|
"integrity": "sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/helper-validator-identifier": "^7.10.4",
|
"@babel/helper-validator-identifier": "^7.10.4",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"to-fast-properties": "^2.0.0"
|
"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": {
|
"@babel/node": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/node/-/node-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/node/-/node-7.10.5.tgz",
|
||||||
"integrity": "sha512-U41uyQkG0J1ezCb8KCdhDJotQF68Z/OsUbcgdxaC0M4JoXKZVdaKQJ+ecnr7aaWjNLt0Vee6Vddj6VL4JEMJnQ==",
|
"integrity": "sha512-suosS7zZ2roj+fYVCnDuVezUbRc0sdoyF0Gj/1FzWxD4ebbGiBGtL5qyqHH4NO34B5m4vWWYWgyNhSsrqS8vwA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/register": "^7.10.4",
|
"@babel/register": "^7.10.5",
|
||||||
"commander": "^4.0.1",
|
"commander": "^4.0.1",
|
||||||
"core-js": "^3.2.1",
|
"core-js": "^3.2.1",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"node-environment-flags": "^1.0.5",
|
"node-environment-flags": "^1.0.5",
|
||||||
"regenerator-runtime": "^0.13.4",
|
"regenerator-runtime": "^0.13.4",
|
||||||
"resolve": "^1.13.1",
|
"resolve": "^1.13.1",
|
||||||
@@ -2554,13 +2512,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/register": {
|
"@babel/register": {
|
||||||
"version": "7.10.4",
|
"version": "7.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/register/-/register-7.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/register/-/register-7.10.5.tgz",
|
||||||
"integrity": "sha512-whHmgGiWNVyTVnYTSawtDWhaeYsc+noeU8Rmi+MPnbGhDYmr5QpEDMrQcIA07D2RUv0BlThPcN89XcHCqq/O4g==",
|
"integrity": "sha512-eYHdLv43nyvmPn9bfNfrcC4+iYNwdQ8Pxk1MFJuU/U5LpSYl/PH4dFMazCYZDFVi8ueG3shvO+AQfLrxpYulQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"find-cache-dir": "^2.0.0",
|
"find-cache-dir": "^2.0.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.19",
|
||||||
"make-dir": "^2.1.0",
|
"make-dir": "^2.1.0",
|
||||||
"pirates": "^4.0.0",
|
"pirates": "^4.0.0",
|
||||||
"source-map-support": "^0.5.16"
|
"source-map-support": "^0.5.16"
|
||||||
@@ -3473,9 +3431,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@rollup/plugin-babel": {
|
"@rollup/plugin-babel": {
|
||||||
"version": "5.0.4",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.1.0.tgz",
|
||||||
"integrity": "sha512-MBtNoi5gqBEbqy1gE9jZBfPsi10kbuK2CEu9bx53nk1Z3ATRvBOoZ/GsbhXOeVbS76xXi/DeYM+vYX6EGIDv9A==",
|
"integrity": "sha512-zXBEYmfiLAMvB+ZBa6m/q9hsQYAq1sUFdjuP1F6C2pf6uQcpHwAWQveZgzS63zXdKPUYHD3Dr7BhjCqcr0bbLw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/helper-module-imports": "^7.7.4",
|
"@babel/helper-module-imports": "^7.7.4",
|
||||||
@@ -6644,15 +6602,6 @@
|
|||||||
"sha.js": "^2.4.8"
|
"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": {
|
"cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
@@ -6844,9 +6793,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cypress": {
|
"cypress": {
|
||||||
"version": "4.9.0",
|
"version": "4.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-4.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/cypress/-/cypress-4.10.0.tgz",
|
||||||
"integrity": "sha512-qGxT5E0j21FPryzhb0OBjCdhoR/n1jXtumpFFSBPYWsaZZhNaBvc3XlBUDEZKkkXPsqUFYiyhWdHN/zo0t5FcA==",
|
"integrity": "sha512-eFv1WPp4zFrAgZ6mwherBGVsTpHvay/hEF5F7U7yfAkTxsUQn/ZG/LdX67fIi3bKDTQXYzFv/CvywlQSeug8Bg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@cypress/listr-verbose-renderer": "0.4.1",
|
"@cypress/listr-verbose-renderer": "0.4.1",
|
||||||
@@ -8072,9 +8021,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"eslint-plugin-chai-expect": {
|
"eslint-plugin-chai-expect": {
|
||||||
"version": "2.1.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-expect/-/eslint-plugin-chai-expect-2.2.0.tgz",
|
||||||
"integrity": "sha512-rd0/4mjMV6c3i0o4DKkWI4uaFN9DK707kW+/fDphaDI6HVgxXnhML9Xgt5vHnTXmSSnDhupuCFBgsEAEpchXmQ==",
|
"integrity": "sha512-ExTJKhgeYMfY8wDj3UiZmgpMKJOUHGNHmWMlxT49JUDB1vTnw0sSNfXJSxnX+LcebyBD/gudXzjzD136WqPJrQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"eslint-plugin-chai-expect-keywords": {
|
"eslint-plugin-chai-expect-keywords": {
|
||||||
@@ -8278,14 +8227,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eslint-plugin-jsdoc": {
|
"eslint-plugin-jsdoc": {
|
||||||
"version": "28.6.1",
|
"version": "29.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-28.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-29.2.0.tgz",
|
||||||
"integrity": "sha512-Z3y7hcNPDuhL339D1KOf9SY8pMAxYxhaG4QLtu3KVn20k/hNF1u6WQv44wvuSCb6OfPJ4say37RUlSNqIjR+mw==",
|
"integrity": "sha512-B1a8LWPkkxyxIp4y3pnRQR18j03Wp+V9gDE7IjQG/MvWAzp5gqXM0q71gXRAZMvWUjujAsNg8B9v1csl+/zkvw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"comment-parser": "^0.7.5",
|
"comment-parser": "^0.7.5",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"jsdoctypeparser": "^7.0.0",
|
"jsdoctypeparser": "^8.0.0",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"regextras": "^0.7.1",
|
"regextras": "^0.7.1",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
@@ -11451,9 +11400,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsdoctypeparser": {
|
"jsdoctypeparser": {
|
||||||
"version": "7.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-8.0.0.tgz",
|
||||||
"integrity": "sha512-6vWPn5qSy+MbgCVjXsQKVkRywhs+IxFU7Chw72DKsWoGueYp6QX8eTc55+EA0yPGYfhmglb1gfi283asXirfGQ==",
|
"integrity": "sha512-eLCs6s4JqN8TjFJfgdiLHRvogLhOAJz+5RIA2FtoMe6ZDyuvghvppnlIToqAEnVbxRqLMrfnNXpW8FpmR6IMBw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"jsdom": {
|
"jsdom": {
|
||||||
@@ -15314,9 +15263,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rollup": {
|
"rollup": {
|
||||||
"version": "2.19.0",
|
"version": "2.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.21.0.tgz",
|
||||||
"integrity": "sha512-nny5Vs4jwY3vbQAXgOyU4ZDZqLvMKm/umnsVry/demVL6ve8ke1XhdpYE0eiWencASmx/qFPw6pP8P7MLJl9XA==",
|
"integrity": "sha512-BEGgy+wSzux7Ycq58pRiWEOBZaXRXTuvzl1gsm7gqmsAHxkWf9nyA5V2LN9fGSHhhDQd0/C13iRzSh4bbIpWZQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fsevents": "~2.1.2"
|
"fsevents": "~2.1.2"
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -141,24 +141,24 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.10.4",
|
"@babel/core": "^7.10.5",
|
||||||
"@babel/node": "^7.10.4",
|
"@babel/node": "^7.10.5",
|
||||||
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
|
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
|
||||||
"@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4",
|
"@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4",
|
||||||
"@babel/preset-env": "^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/code-coverage": "^3.8.1",
|
||||||
"@cypress/fiddle": "^1.18.2",
|
"@cypress/fiddle": "^1.18.2",
|
||||||
"@fintechstudios/eslint-plugin-chai-as-promised": "^3.0.2",
|
"@fintechstudios/eslint-plugin-chai-as-promised": "^3.0.2",
|
||||||
"@mysticatea/eslint-plugin": "^13.0.0",
|
"@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",
|
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
|
||||||
"coffeescript": "^2.5.1",
|
"coffeescript": "^2.5.1",
|
||||||
"copyfiles": "^2.3.0",
|
"copyfiles": "^2.3.0",
|
||||||
"core-js-bundle": "^3.6.5",
|
"core-js-bundle": "^3.6.5",
|
||||||
"coveradge": "^0.6.0",
|
"coveradge": "^0.6.0",
|
||||||
"cross-var": "^1.1.0",
|
"cross-var": "^1.1.0",
|
||||||
"cypress": "^4.9.0",
|
"cypress": "^4.10.0",
|
||||||
"cypress-axe": "^0.8.1",
|
"cypress-axe": "^0.8.1",
|
||||||
"cypress-multi-reporters": "^1.4.0",
|
"cypress-multi-reporters": "^1.4.0",
|
||||||
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
|
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
"eslint-config-ash-nazg": "^22.5.1",
|
"eslint-config-ash-nazg": "^22.5.1",
|
||||||
"eslint-config-standard": "^14.1.1",
|
"eslint-config-standard": "^14.1.1",
|
||||||
"eslint-plugin-array-func": "^3.1.6",
|
"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-expect-keywords": "^2.0.1",
|
||||||
"eslint-plugin-chai-friendly": "^0.6.0",
|
"eslint-plugin-chai-friendly": "^0.6.0",
|
||||||
"eslint-plugin-compat": "^3.8.0",
|
"eslint-plugin-compat": "^3.8.0",
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
"eslint-plugin-html": "^6.0.2",
|
"eslint-plugin-html": "^6.0.2",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"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-markdown": "^1.0.2",
|
||||||
"eslint-plugin-mocha": "^7.0.1",
|
"eslint-plugin-mocha": "^7.0.1",
|
||||||
"eslint-plugin-mocha-cleanup": "^1.8.0",
|
"eslint-plugin-mocha-cleanup": "^1.8.0",
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
"remark-cli": "^8.0.0",
|
"remark-cli": "^8.0.0",
|
||||||
"remark-lint-ordered-list-marker-value": "^2.0.1",
|
"remark-lint-ordered-list-marker-value": "^2.0.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "2.19.0",
|
"rollup": "2.21.0",
|
||||||
"rollup-plugin-re": "^1.0.7",
|
"rollup-plugin-re": "^1.0.7",
|
||||||
"rollup-plugin-terser": "^6.1.0",
|
"rollup-plugin-terser": "^6.1.0",
|
||||||
"stackblur-canvas": "^2.3.0",
|
"stackblur-canvas": "^2.3.0",
|
||||||
|
|||||||
@@ -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) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -3619,7 +3649,7 @@
|
|||||||
* @function module:units.ElementContainer#getRoundDigits
|
* @function module:units.ElementContainer#getRoundDigits
|
||||||
* @returns {Integer} The number of digits number should be rounded to
|
* @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 */
|
/* eslint-disable jsdoc/valid-types */
|
||||||
|
|
||||||
@@ -3862,8 +3892,7 @@
|
|||||||
AFTER_APPLY: 'after_apply',
|
AFTER_APPLY: 'after_apply',
|
||||||
BEFORE_UNAPPLY: 'before_unapply',
|
BEFORE_UNAPPLY: 'before_unapply',
|
||||||
AFTER_UNAPPLY: 'after_unapply'
|
AFTER_UNAPPLY: 'after_unapply'
|
||||||
}; // const removedElements = {};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for commands.
|
* Base class for commands.
|
||||||
*/
|
*/
|
||||||
@@ -3882,6 +3911,51 @@
|
|||||||
value: function getText() {
|
value: function getText() {
|
||||||
return this.text;
|
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;
|
return Command;
|
||||||
@@ -3930,12 +4004,6 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives the type.
|
|
||||||
* @function module:history.HistoryCommand#type
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event module:history~Command#event:history
|
* @event module:history~Command#event:history
|
||||||
* @type {module:history.HistoryCommand}
|
* @type {module:history.HistoryCommand}
|
||||||
@@ -3988,36 +4056,21 @@
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.MoveElementCommand"}
|
* Re-positions the element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(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
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
// TODO(codedread): Refactor this common event code into a base HistoryCommand class.
|
var _this2 = this;
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this2.elem = _this2.newParent.insertBefore(_this2.elem, _this2.newNextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Positions the element back to its original location.
|
* Positions the element back to its original location.
|
||||||
@@ -4029,30 +4082,16 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this3 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
|
_get(_getPrototypeOf(MoveElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
|
_this3.elem = _this3.oldParent.insertBefore(_this3.elem, _this3.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return MoveElementCommand;
|
return MoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
MoveElementCommand.type = MoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element that was added to the DOM.
|
* History command for an element that was added to the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4068,47 +4107,33 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function InsertElementCommand(elem, text) {
|
function InsertElementCommand(elem, text) {
|
||||||
var _this2;
|
var _this4;
|
||||||
|
|
||||||
_classCallCheck(this, InsertElementCommand);
|
_classCallCheck(this, InsertElementCommand);
|
||||||
|
|
||||||
_this2 = _super2.call(this);
|
_this4 = _super2.call(this);
|
||||||
_this2.elem = elem;
|
_this4.elem = elem;
|
||||||
_this2.text = text || 'Create ' + elem.tagName;
|
_this4.text = text || 'Create ' + elem.tagName;
|
||||||
_this2.parent = elem.parentNode;
|
_this4.parent = elem.parentNode;
|
||||||
_this2.nextSibling = _this2.elem.nextSibling;
|
_this4.nextSibling = _this4.elem.nextSibling;
|
||||||
return _this2;
|
return _this4;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.InsertElementCommand"}
|
* Re-inserts the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(InsertElementCommand, [{
|
_createClass(InsertElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.InsertElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-inserts the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this5 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this5.elem = _this5.parent.insertBefore(_this5.elem, _this5.nextSibling);
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the element.
|
* Removes the element.
|
||||||
@@ -4120,31 +4145,18 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this6 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent = this.elem.parentNode;
|
_get(_getPrototypeOf(InsertElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.elem.remove();
|
_this6.parent = _this6.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this6.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @returns {Element[]} Array with element associated with this command
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "elements",
|
|
||||||
value: function elements() {
|
|
||||||
return [this.elem];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return InsertElementCommand;
|
return InsertElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
InsertElementCommand.type = InsertElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* History command for an element removed from the DOM.
|
* History command for an element removed from the DOM.
|
||||||
* @implements {module:history.HistoryCommand}
|
* @implements {module:history.HistoryCommand}
|
||||||
@@ -4162,51 +4174,38 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
|
||||||
var _this3;
|
var _this7;
|
||||||
|
|
||||||
_classCallCheck(this, RemoveElementCommand);
|
_classCallCheck(this, RemoveElementCommand);
|
||||||
|
|
||||||
_this3 = _super3.call(this);
|
_this7 = _super3.call(this);
|
||||||
_this3.elem = elem;
|
_this7.elem = elem;
|
||||||
_this3.text = text || 'Delete ' + elem.tagName;
|
_this7.text = text || 'Delete ' + elem.tagName;
|
||||||
_this3.nextSibling = oldNextSibling;
|
_this7.nextSibling = oldNextSibling;
|
||||||
_this3.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
_this7.parent = oldParent; // special hack for webkit: remove this element's entry in the svgTransformLists map
|
||||||
|
|
||||||
removeElementFromListMap(elem);
|
removeElementFromListMap(elem);
|
||||||
return _this3;
|
return _this7;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.RemoveElementCommand"}
|
* Re-removes the new element.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(RemoveElementCommand, [{
|
_createClass(RemoveElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.RemoveElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Re-removes the new element.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this8 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
_get(_getPrototypeOf(RemoveElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
this.parent = this.elem.parentNode;
|
removeElementFromListMap(_this8.elem);
|
||||||
this.elem.remove();
|
_this8.parent = _this8.elem.parentNode;
|
||||||
|
|
||||||
if (handler) {
|
_this8.elem.remove();
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Re-adds the new element.
|
* Re-adds the new element.
|
||||||
@@ -4218,38 +4217,25 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this9 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, 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) {
|
if (window.console) {
|
||||||
console.log('Error: reference element was lost'); // eslint-disable-line no-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;
|
return RemoveElementCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
* @typedef {"#text"|"#href"|string} module:history.CommandAttributeName
|
||||||
*/
|
*/
|
||||||
@@ -4275,182 +4261,148 @@
|
|||||||
* @param {string} text - An optional string visible to user related to this change
|
* @param {string} text - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function ChangeElementCommand(elem, attrs, text) {
|
function ChangeElementCommand(elem, attrs, text) {
|
||||||
var _this4;
|
var _this10;
|
||||||
|
|
||||||
_classCallCheck(this, ChangeElementCommand);
|
_classCallCheck(this, ChangeElementCommand);
|
||||||
|
|
||||||
_this4 = _super4.call(this);
|
_this10 = _super4.call(this);
|
||||||
_this4.elem = elem;
|
_this10.elem = elem;
|
||||||
_this4.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
_this10.text = text ? 'Change ' + elem.tagName + ' ' + text : 'Change ' + elem.tagName;
|
||||||
_this4.newValues = {};
|
_this10.newValues = {};
|
||||||
_this4.oldValues = attrs;
|
_this10.oldValues = attrs;
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
if (attr === '#text') {
|
if (attr === '#text') {
|
||||||
_this4.newValues[attr] = elem.textContent;
|
_this10.newValues[attr] = elem.textContent;
|
||||||
} else if (attr === '#href') {
|
} else if (attr === '#href') {
|
||||||
_this4.newValues[attr] = getHref(elem);
|
_this10.newValues[attr] = getHref(elem);
|
||||||
} else {
|
} else {
|
||||||
_this4.newValues[attr] = elem.getAttribute(attr);
|
_this10.newValues[attr] = elem.getAttribute(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this4;
|
return _this10;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.ChangeElementCommand"}
|
* Performs the stored change action.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(ChangeElementCommand, [{
|
_createClass(ChangeElementCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.ChangeElementCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Performs the stored change action.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {true}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
var _this5 = this;
|
var _this11 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this11.newValues).forEach(function (_ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
attr = _ref2[0],
|
||||||
|
value = _ref2[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.newValues).forEach(function (_ref) {
|
if (attr === '#text') {
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
_this11.elem.textContent = value;
|
||||||
attr = _ref2[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref2[1];
|
setHref(_this11.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this11.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this5.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this11.elem.textContent = '';
|
||||||
setHref(_this5.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this5.elem.setAttribute(attr, value);
|
_this11.elem.setAttribute(attr, '');
|
||||||
|
|
||||||
|
_this11.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this5.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this5.elem.setAttribute(attr, '');
|
|
||||||
|
|
||||||
_this5.elem.removeAttribute(attr);
|
if (attr === 'transform') {
|
||||||
}
|
bChangedTransform = true;
|
||||||
|
}
|
||||||
|
}); // relocate rotational transform, if necessary
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (!bChangedTransform) {
|
||||||
bChangedTransform = true;
|
var angle = getRotationAngle(_this11.elem);
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
if (angle) {
|
||||||
var angle = getRotationAngle(this.elem);
|
var bbox = _this11.elem.getBBox();
|
||||||
|
|
||||||
if (angle) {
|
var cx = bbox.x + bbox.width / 2;
|
||||||
var bbox = this.elem.getBBox();
|
var cy = bbox.y + bbox.height / 2;
|
||||||
var cx = bbox.x + bbox.width / 2,
|
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
||||||
cy = bbox.y + bbox.height / 2;
|
|
||||||
var rotate = ['rotate(', angle, ' ', cx, ',', cy, ')'].join('');
|
|
||||||
|
|
||||||
if (rotate !== this.elem.getAttribute('transform')) {
|
if (rotate !== _this11.elem.getAttribute('transform')) {
|
||||||
this.elem.setAttribute('transform', rotate);
|
_this11.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Reverses the stored change action.
|
* Reverses the stored change action.
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
* @fires module:history~Command#event:history
|
* @fires module:history~Command#event:history
|
||||||
* @returns {true}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
var _this6 = this;
|
var _this12 = this;
|
||||||
|
|
||||||
if (handler) {
|
_get(_getPrototypeOf(ChangeElementCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
var bChangedTransform = false;
|
||||||
}
|
Object.entries(_this12.oldValues).forEach(function (_ref3) {
|
||||||
|
var _ref4 = _slicedToArray(_ref3, 2),
|
||||||
|
attr = _ref4[0],
|
||||||
|
value = _ref4[1];
|
||||||
|
|
||||||
var bChangedTransform = false;
|
if (value) {
|
||||||
Object.entries(this.oldValues).forEach(function (_ref3) {
|
if (attr === '#text') {
|
||||||
var _ref4 = _slicedToArray(_ref3, 2),
|
_this12.elem.textContent = value;
|
||||||
attr = _ref4[0],
|
} else if (attr === '#href') {
|
||||||
value = _ref4[1];
|
setHref(_this12.elem, value);
|
||||||
|
} else {
|
||||||
if (value) {
|
_this12.elem.setAttribute(attr, value);
|
||||||
if (attr === '#text') {
|
}
|
||||||
_this6.elem.textContent = value;
|
} else if (attr === '#text') {
|
||||||
} else if (attr === '#href') {
|
_this12.elem.textContent = '';
|
||||||
setHref(_this6.elem, value);
|
|
||||||
} else {
|
} else {
|
||||||
_this6.elem.setAttribute(attr, value);
|
_this12.elem.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
} else if (attr === '#text') {
|
|
||||||
_this6.elem.textContent = '';
|
|
||||||
} else {
|
|
||||||
_this6.elem.removeAttribute(attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr === 'transform') {
|
if (attr === 'transform') {
|
||||||
bChangedTransform = true;
|
bChangedTransform = true;
|
||||||
}
|
|
||||||
}); // relocate rotational transform, if necessary
|
|
||||||
|
|
||||||
if (!bChangedTransform) {
|
|
||||||
var angle = getRotationAngle(this.elem);
|
|
||||||
|
|
||||||
if (angle) {
|
|
||||||
var bbox = this.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);
|
|
||||||
}
|
}
|
||||||
}
|
}); // relocate rotational transform, if necessary
|
||||||
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
|
||||||
|
if (!bChangedTransform) {
|
||||||
|
var angle = getRotationAngle(_this12.elem);
|
||||||
|
|
||||||
|
if (angle) {
|
||||||
|
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 !== _this12.elem.getAttribute('transform')) {
|
||||||
|
_this12.elem.setAttribute('transform', rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // Remove transformlist to prevent confusion that causes bugs like 575.
|
||||||
|
|
||||||
|
|
||||||
removeElementFromListMap(this.elem);
|
removeElementFromListMap(_this12.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];
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
return ChangeElementCommand;
|
return ChangeElementCommand;
|
||||||
}(Command);
|
}(Command); // TODO: create a 'typing' command object that tracks changes in text
|
||||||
ChangeElementCommand.type = ChangeElementCommand.prototype.type; // 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
|
// 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
|
// and they both affect the same element, then collapse the two commands into one
|
||||||
|
|
||||||
@@ -4468,49 +4420,35 @@
|
|||||||
* @param {string} [text] - An optional string visible to user related to this change
|
* @param {string} [text] - An optional string visible to user related to this change
|
||||||
*/
|
*/
|
||||||
function BatchCommand(text) {
|
function BatchCommand(text) {
|
||||||
var _this7;
|
var _this13;
|
||||||
|
|
||||||
_classCallCheck(this, BatchCommand);
|
_classCallCheck(this, BatchCommand);
|
||||||
|
|
||||||
_this7 = _super5.call(this);
|
_this13 = _super5.call(this);
|
||||||
_this7.text = text || 'Batch Command';
|
_this13.text = text || 'Batch Command';
|
||||||
_this7.stack = [];
|
_this13.stack = [];
|
||||||
return _this7;
|
return _this13;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @returns {"svgedit.history.BatchCommand"}
|
* Runs "apply" on all subcommands.
|
||||||
*/
|
* @param {module:history.HistoryEventHandler} handler
|
||||||
|
* @fires module:history~Command#event:history
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
_createClass(BatchCommand, [{
|
_createClass(BatchCommand, [{
|
||||||
key: "type",
|
|
||||||
value: function type() {
|
|
||||||
// eslint-disable-line class-methods-use-this
|
|
||||||
return 'svgedit.history.BatchCommand';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Runs "apply" on all subcommands.
|
|
||||||
* @param {module:history.HistoryEventHandler} handler
|
|
||||||
* @fires module:history~Command#event:history
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}, {
|
|
||||||
key: "apply",
|
key: "apply",
|
||||||
value: function apply(handler) {
|
value: function apply(handler) {
|
||||||
if (handler) {
|
var _this14 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_APPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var len = this.stack.length;
|
_get(_getPrototypeOf(BatchCommand.prototype), "apply", this).call(this, handler, function () {
|
||||||
|
_this14.stack.forEach(function (stackItem) {
|
||||||
for (var i = 0; i < len; ++i) {
|
// eslint-disable-next-line no-console
|
||||||
this.stack[i].apply(handler);
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
}
|
stackItem && stackItem.apply(handler);
|
||||||
|
});
|
||||||
if (handler) {
|
});
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Runs "unapply" on all subcommands.
|
* Runs "unapply" on all subcommands.
|
||||||
@@ -4522,17 +4460,15 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "unapply",
|
key: "unapply",
|
||||||
value: function unapply(handler) {
|
value: function unapply(handler) {
|
||||||
if (handler) {
|
var _this15 = this;
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.BEFORE_UNAPPLY, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = this.stack.length - 1; i >= 0; i--) {
|
_get(_getPrototypeOf(BatchCommand.prototype), "unapply", this).call(this, handler, function () {
|
||||||
this.stack[i].unapply(handler);
|
_this15.stack.forEach(function (stackItem) {
|
||||||
}
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(stackItem, 'stack item should not be null');
|
||||||
if (handler) {
|
stackItem && stackItem.unapply(handler);
|
||||||
handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this);
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Iterate through all our subcommands.
|
* Iterate through all our subcommands.
|
||||||
@@ -4546,6 +4482,7 @@
|
|||||||
var cmd = this.stack.length;
|
var cmd = this.stack.length;
|
||||||
|
|
||||||
while (cmd--) {
|
while (cmd--) {
|
||||||
|
if (!this.stack[cmd]) continue;
|
||||||
var thisElems = this.stack[cmd].elements();
|
var thisElems = this.stack[cmd].elements();
|
||||||
var elem = thisElems.length;
|
var elem = thisElems.length;
|
||||||
|
|
||||||
@@ -4567,6 +4504,8 @@
|
|||||||
}, {
|
}, {
|
||||||
key: "addSubCommand",
|
key: "addSubCommand",
|
||||||
value: function addSubCommand(cmd) {
|
value: function addSubCommand(cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.assert(cmd !== null, 'cmd should not be null');
|
||||||
this.stack.push(cmd);
|
this.stack.push(cmd);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -4582,7 +4521,6 @@
|
|||||||
|
|
||||||
return BatchCommand;
|
return BatchCommand;
|
||||||
}(Command);
|
}(Command);
|
||||||
BatchCommand.type = BatchCommand.prototype.type;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8013,8 +7951,8 @@
|
|||||||
|
|
||||||
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time
|
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 visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath';
|
||||||
var visElemsArr = visElems.split(','); // const hidElems = 'clipPath,defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath';
|
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 editorContext_$1 = null;
|
||||||
var domdoc_ = null;
|
var domdoc_ = null;
|
||||||
@@ -9449,6 +9387,9 @@
|
|||||||
var isNullish = function isNullish(val) {
|
var isNullish = function isNullish(val) {
|
||||||
return val === null || val === undefined;
|
return val === null || val === undefined;
|
||||||
};
|
};
|
||||||
|
var $q = function $q(sel) {
|
||||||
|
return document.querySelector(sel);
|
||||||
|
};
|
||||||
|
|
||||||
/* globals jQuery */
|
/* globals jQuery */
|
||||||
|
|
||||||
@@ -14213,18 +14154,18 @@
|
|||||||
var cmdType = cmd.type();
|
var cmdType = cmd.type();
|
||||||
var isApply = eventType === EventTypes.AFTER_APPLY;
|
var isApply = eventType === EventTypes.AFTER_APPLY;
|
||||||
|
|
||||||
if (cmdType === MoveElementCommand$1.type()) {
|
if (cmdType === 'MoveElementCommand') {
|
||||||
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
var parent = isApply ? cmd.newParent : cmd.oldParent;
|
||||||
|
|
||||||
if (parent === svgcontent) {
|
if (parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
} else if (cmdType === InsertElementCommand$1.type() || cmdType === RemoveElementCommand$1.type()) {
|
} else if (cmdType === 'InsertElementCommand' || cmdType === 'RemoveElementCommand') {
|
||||||
if (cmd.parent === svgcontent) {
|
if (cmd.parent === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdType === InsertElementCommand$1.type()) {
|
if (cmdType === 'InsertElementCommand') {
|
||||||
if (isApply) {
|
if (isApply) {
|
||||||
restoreRefElems(cmd.elem);
|
restoreRefElems(cmd.elem);
|
||||||
}
|
}
|
||||||
@@ -14235,7 +14176,7 @@
|
|||||||
if (cmd.elem && cmd.elem.tagName === 'use') {
|
if (cmd.elem && cmd.elem.tagName === 'use') {
|
||||||
setUseData(cmd.elem);
|
setUseData(cmd.elem);
|
||||||
}
|
}
|
||||||
} else if (cmdType === ChangeElementCommand$1.type()) {
|
} else if (cmdType === 'ChangeElementCommand') {
|
||||||
// if we are changing layer names, re-identify all layers
|
// if we are changing layer names, re-identify all layers
|
||||||
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
if (cmd.elem.tagName === 'title' && cmd.elem.parentNode.parentNode === svgcontent) {
|
||||||
identifyLayers();
|
identifyLayers();
|
||||||
@@ -28664,6 +28605,7 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $q$1 = $q;
|
||||||
var editor = {};
|
var editor = {};
|
||||||
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
var $$b = [jQueryPluginJSHotkeys, jQueryPluginSVGIcons, jQueryPluginJGraduate, jQueryPluginSpinButton, jQueryPluginSVG, jQueryContextMenu, jPicker].reduce(function (jq, func) {
|
||||||
return func(jq);
|
return func(jq);
|
||||||
@@ -35536,7 +35478,7 @@
|
|||||||
var btn;
|
var btn;
|
||||||
|
|
||||||
if (opts.sel) {
|
if (opts.sel) {
|
||||||
btn = document.querySelector(opts.sel);
|
btn = $q$1(opts.sel);
|
||||||
|
|
||||||
if (btn === null) {
|
if (btn === null) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user