upgrade eslint and associated fixes
don't keep ie() by the way
This commit is contained in:
@@ -71,34 +71,27 @@ export const remapElement = function (selected, changes, m) {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const type = i === 0 ? 'fill' : 'stroke';
|
||||
const attrVal = selected.getAttribute(type);
|
||||
if (attrVal && attrVal.startsWith('url(')) {
|
||||
if (m.a < 0 || m.d < 0) {
|
||||
const grad = getRefElem(attrVal);
|
||||
const newgrad = grad.cloneNode(true);
|
||||
if (m.a < 0) {
|
||||
// flip x
|
||||
const x1 = newgrad.getAttribute('x1');
|
||||
const x2 = newgrad.getAttribute('x2');
|
||||
newgrad.setAttribute('x1', -(x1 - 1));
|
||||
newgrad.setAttribute('x2', -(x2 - 1));
|
||||
}
|
||||
|
||||
if (m.d < 0) {
|
||||
// flip y
|
||||
const y1 = newgrad.getAttribute('y1');
|
||||
const y2 = newgrad.getAttribute('y2');
|
||||
newgrad.setAttribute('y1', -(y1 - 1));
|
||||
newgrad.setAttribute('y2', -(y2 - 1));
|
||||
}
|
||||
newgrad.id = editorContext_.getDrawing().getNextId();
|
||||
findDefs().append(newgrad);
|
||||
selected.setAttribute(type, 'url(#' + newgrad.id + ')');
|
||||
if (attrVal && attrVal.startsWith('url(') && (m.a < 0 || m.d < 0)) {
|
||||
const grad = getRefElem(attrVal);
|
||||
const newgrad = grad.cloneNode(true);
|
||||
if (m.a < 0) {
|
||||
// flip x
|
||||
const x1 = newgrad.getAttribute('x1');
|
||||
const x2 = newgrad.getAttribute('x2');
|
||||
newgrad.setAttribute('x1', -(x1 - 1));
|
||||
newgrad.setAttribute('x2', -(x2 - 1));
|
||||
}
|
||||
|
||||
// Not really working :(
|
||||
// if (selected.tagName === 'path') {
|
||||
// reorientGrads(selected, m);
|
||||
// }
|
||||
if (m.d < 0) {
|
||||
// flip y
|
||||
const y1 = newgrad.getAttribute('y1');
|
||||
const y2 = newgrad.getAttribute('y2');
|
||||
newgrad.setAttribute('y1', -(y1 - 1));
|
||||
newgrad.setAttribute('y2', -(y2 - 1));
|
||||
}
|
||||
newgrad.id = editorContext_.getDrawing().getNextId();
|
||||
findDefs().append(newgrad);
|
||||
selected.setAttribute(type, 'url(#' + newgrad.id + ')');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -620,10 +620,8 @@ export const mouseUpEvent = function (evt) {
|
||||
eventContext_.getCanvas().pathActions.select(selectedElements[0]);
|
||||
// if it was a path
|
||||
// else, if it was selected and this is a shift-click, remove it from selection
|
||||
} else if (evt.shiftKey) {
|
||||
if (tempJustSelected !== t) {
|
||||
eventContext_.getCanvas().removeFromSelection([t]);
|
||||
}
|
||||
} else if (evt.shiftKey && tempJustSelected !== t) {
|
||||
eventContext_.getCanvas().removeFromSelection([t]);
|
||||
}
|
||||
} // no change in mouse position
|
||||
|
||||
|
||||
@@ -260,10 +260,8 @@ export class RemoveElementCommand extends Command {
|
||||
unapply (handler) {
|
||||
super.unapply(handler, () => {
|
||||
removeElementFromListMap(this.elem);
|
||||
if (isNullish(this.nextSibling)) {
|
||||
if (window.console) {
|
||||
console.error('Reference element was lost');
|
||||
}
|
||||
if (isNullish(this.nextSibling) && window.console) {
|
||||
console.error('Reference element was lost');
|
||||
}
|
||||
this.parent.insertBefore(this.elem, this.nextSibling); // Don't use `before` or `prepend` as `this.nextSibling` may be `null`
|
||||
});
|
||||
|
||||
@@ -1134,20 +1134,18 @@ export const pathActionsMethod = (function () {
|
||||
cleanup();
|
||||
break;
|
||||
}
|
||||
} else if (item.pathSegType === 2) {
|
||||
if (len > 0) {
|
||||
const prevType = segList.getItem(len - 1).pathSegType;
|
||||
// Path has M M
|
||||
if (prevType === 2) {
|
||||
remItems(len - 1, 1);
|
||||
cleanup();
|
||||
break;
|
||||
} else if (item.pathSegType === 2 && len > 0) {
|
||||
const prevType = segList.getItem(len - 1).pathSegType;
|
||||
// Path has M M
|
||||
if (prevType === 2) {
|
||||
remItems(len - 1, 1);
|
||||
cleanup();
|
||||
break;
|
||||
// Entire path ends with Z M
|
||||
} else if (prevType === 1 && segList.numberOfItems - 1 === len) {
|
||||
remItems(len, 1);
|
||||
cleanup();
|
||||
break;
|
||||
}
|
||||
} else if (prevType === 1 && segList.numberOfItems - 1 === len) {
|
||||
remItems(len, 1);
|
||||
cleanup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,10 +1012,8 @@ export class Path {
|
||||
if (!Array.isArray(indexes)) { indexes = [indexes]; }
|
||||
indexes.forEach((index) => {
|
||||
const seg = this.segs[index];
|
||||
if (seg.ptgrip) {
|
||||
if (!this.selected_pts.includes(index) && index >= 0) {
|
||||
this.selected_pts.push(index);
|
||||
}
|
||||
if (seg.ptgrip && !this.selected_pts.includes(index) && index >= 0) {
|
||||
this.selected_pts.push(index);
|
||||
}
|
||||
});
|
||||
this.selected_pts.sort();
|
||||
|
||||
@@ -107,10 +107,8 @@ export const recalculateDimensions = function (selected) {
|
||||
tlist.removeItem(k);
|
||||
}
|
||||
// remove zero-degree rotations
|
||||
} else if (xform.type === 4) {
|
||||
if (xform.angle === 0) {
|
||||
tlist.removeItem(k);
|
||||
}
|
||||
} else if (xform.type === 4 && xform.angle === 0) {
|
||||
tlist.removeItem(k);
|
||||
}
|
||||
}
|
||||
// End here if all it has is a rotation
|
||||
|
||||
@@ -204,13 +204,10 @@ export const sanitizeSvg = function (node) {
|
||||
const href = getHref(node);
|
||||
if (href &&
|
||||
['filter', 'linearGradient', 'pattern',
|
||||
'radialGradient', 'textPath', 'use'].includes(node.nodeName)) {
|
||||
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
||||
if (href[0] !== '#') {
|
||||
// remove the attribute (but keep the element)
|
||||
setHref(node, '');
|
||||
node.removeAttributeNS(NS.XLINK, 'href');
|
||||
}
|
||||
'radialGradient', 'textPath', 'use'].includes(node.nodeName) && href[0] !== '#') {
|
||||
// remove the attribute (but keep the element)
|
||||
setHref(node, '');
|
||||
node.removeAttributeNS(NS.XLINK, 'href');
|
||||
}
|
||||
|
||||
// Safari crashes on a <use> without a xlink:href, so we just remove the node here
|
||||
|
||||
@@ -284,15 +284,6 @@ export const getIntersectionListMethod = function (rect) {
|
||||
}
|
||||
|
||||
let resultList = null;
|
||||
if (!selectionContext_.isIE()) {
|
||||
if (typeof selectionContext_.getSVGRoot().getIntersectionList === 'function') {
|
||||
// Offset the bbox of the rubber box by the offset of the svgcontent element.
|
||||
rubberBBox.x += Number.parseInt(selectionContext_.getSVGContent().getAttribute('x'));
|
||||
rubberBBox.y += Number.parseInt(selectionContext_.getSVGContent().getAttribute('y'));
|
||||
|
||||
resultList = selectionContext_.getSVGRoot().getIntersectionList(rubberBBox, parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNullish(resultList) || typeof resultList.item !== 'function') {
|
||||
resultList = [];
|
||||
|
||||
@@ -181,12 +181,10 @@ export const svgToString = function (elem, indent) {
|
||||
if (attr.nodeName.startsWith('xmlns:')) { continue; }
|
||||
|
||||
// only serialize attributes we don't use internally
|
||||
if (attrVal !== '' && !attrNames.includes(attr.localName)) {
|
||||
if (!attr.namespaceURI || nsMap[attr.namespaceURI]) {
|
||||
out.push(' ');
|
||||
out.push(attr.nodeName); out.push('="');
|
||||
out.push(attrVal); out.push('"');
|
||||
}
|
||||
if (attrVal !== '' && !attrNames.includes(attr.localName) && (!attr.namespaceURI || nsMap[attr.namespaceURI])) {
|
||||
out.push(' ');
|
||||
out.push(attr.nodeName); out.push('="');
|
||||
out.push(attrVal); out.push('"');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -487,10 +485,8 @@ export const importSvgString = function (xmlString) {
|
||||
|
||||
let useExisting = false;
|
||||
// Look for symbol and make sure symbol exists in image
|
||||
if (svgContext_.getImportIds(uid)) {
|
||||
if ($(svgContext_.getImportIds(uid).symbol).parents('#svgroot').length) {
|
||||
useExisting = true;
|
||||
}
|
||||
if (svgContext_.getImportIds(uid) && $(svgContext_.getImportIds(uid).symbol).parents('#svgroot').length) {
|
||||
useExisting = true;
|
||||
}
|
||||
|
||||
const batchCmd = new BatchCommand('Import Image');
|
||||
|
||||
@@ -93,7 +93,7 @@ import {
|
||||
uniquifyElemsMethod, removeUnusedDefElemsMethod, convertGradientsMethod
|
||||
} from './svg-exec.js';
|
||||
import {
|
||||
isChrome, isIE, isWebkit
|
||||
isChrome, isWebkit
|
||||
} from '../common/browser.js'; // , supportsEditableText
|
||||
import {
|
||||
getTransformList, SVGTransformList as SVGEditTransformList
|
||||
@@ -590,7 +590,6 @@ class SvgCanvas {
|
||||
getExtensions () { return extensions; },
|
||||
setExtensions (key, value) { extensions[key] = value; },
|
||||
getCurrentZoom,
|
||||
isIE,
|
||||
getRubberBox () { return rubberBox; },
|
||||
setCurBBoxes (value) { curBBoxes = value; },
|
||||
getCurBBoxes (value) { return curBBoxes; },
|
||||
@@ -2678,7 +2677,6 @@ class SvgCanvas {
|
||||
* @property {module:history.HistoryCommand} InsertElementCommand
|
||||
* @property {module:browser.isChrome} isChrome
|
||||
* @property {module:math.isIdentity} isIdentity
|
||||
* @property {module:browser.isIE} isIE
|
||||
* @property {module:svgcanvas~logMatrix} logMatrix
|
||||
* @property {module:history.HistoryCommand} MoveElementCommand
|
||||
* @property {module:namespaces.NS} NS
|
||||
@@ -2721,7 +2719,6 @@ class SvgCanvas {
|
||||
InsertElementCommand,
|
||||
isChrome,
|
||||
isIdentity,
|
||||
isIE,
|
||||
logMatrix,
|
||||
MoveElementCommand,
|
||||
NS,
|
||||
|
||||
@@ -208,12 +208,11 @@ export const changeSelectedAttributeNoUndoMethod = function (attr, newValue, ele
|
||||
|
||||
// Use the Firefox ffClone hack for text elements with gradients or
|
||||
// where other text attributes are changed.
|
||||
if (isGecko() && elem.nodeName === 'text' && (/rotate/).test(elem.getAttribute('transform'))) {
|
||||
if (
|
||||
String(newValue).startsWith('url') || (['font-size', 'font-family', 'x', 'y'].includes(attr) && elem.textContent)
|
||||
) {
|
||||
elem = ffClone(elem);
|
||||
}
|
||||
if (isGecko() &&
|
||||
elem.nodeName === 'text' &&
|
||||
(/rotate/).test(elem.getAttribute('transform')) &&
|
||||
(String(newValue).startsWith('url') || (['font-size', 'font-family', 'x', 'y'].includes(attr) && elem.textContent))) {
|
||||
elem = ffClone(elem);
|
||||
}
|
||||
// Timeout needed for Opera & Firefox
|
||||
// codedread: it is now possible for this function to be called with elements
|
||||
|
||||
Reference in New Issue
Block a user