eslint rule for declarations

This commit is contained in:
JFH
2021-05-28 17:03:29 +02:00
parent 01b022b1e7
commit 99ee706c18
56 changed files with 488 additions and 486 deletions

View File

@@ -51,19 +51,19 @@ export const init = function (editorContext) {
* @type {module:path.EditorContext#remapElement}
*/
export const remapElement = function (selected, changes, m) {
const remap = function (x, y) { return transformPoint(x, y, m); },
scalew = function (w) { return m.a * w; },
scaleh = function (h) { return m.d * h; },
doSnapping = editorContext_.getGridSnapping() && selected.parentNode.parentNode.localName === 'svg',
finishUp = function () {
if (doSnapping) {
Object.entries(changes).forEach(([ o, value ]) => {
changes[o] = snapToGrid(value);
});
}
assignAttributes(selected, changes, 1000, true);
},
box = getBBox(selected);
const remap = function (x, y) { return transformPoint(x, y, m); };
const scalew = function (w) { return m.a * w; };
const scaleh = function (h) { return m.d * h; };
const doSnapping = editorContext_.getGridSnapping() && selected.parentNode.parentNode.localName === 'svg';
const finishUp = function () {
if (doSnapping) {
Object.entries(changes).forEach(([ o, value ]) => {
changes[o] = snapToGrid(value);
});
}
assignAttributes(selected, changes, 1000, true);
};
const box = getBBox(selected);
for (let i = 0; i < 2; i++) {
const type = i === 0 ? 'fill' : 'stroke';
@@ -98,8 +98,8 @@ export const remapElement = function (selected, changes, m) {
if (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && (m.e !== 0 || m.f !== 0)) {
// [T][M] = [M][T']
// therefore [T'] = [M_inv][T][M]
const existing = transformListToTransform(selected).matrix,
tNew = matrixMultiply(existing.inverse(), m, existing);
const existing = transformListToTransform(selected).matrix;
const tNew = matrixMultiply(existing.inverse(), m, existing);
changes.x = Number.parseFloat(changes.x) + tNew.e;
changes.y = Number.parseFloat(changes.y) + tNew.f;
} else {
@@ -153,7 +153,7 @@ export const remapElement = function (selected, changes, m) {
changes.cy = c.y;
// take the minimum of the new selected box's dimensions for the new circle radius
const tbox = transformBox(box.x, box.y, box.width, box.height, m);
const w = tbox.tr.x - tbox.tl.x, h = tbox.bl.y - tbox.tl.y;
const w = tbox.tr.x - tbox.tl.x; const h = tbox.bl.y - tbox.tl.y;
changes.r = Math.min(w / 2, h / 2);
if (changes.r) { changes.r = Math.abs(changes.r); }
@@ -220,8 +220,8 @@ export const remapElement = function (selected, changes, m) {
}
len = changes.d.length;
const firstseg = changes.d[0],
currentpt = remap(firstseg.x, firstseg.y);
const firstseg = changes.d[0];
const currentpt = remap(firstseg.x, firstseg.y);
changes.d[0].x = currentpt.x;
changes.d[0].y = currentpt.y;
for (let i = 1; i < len; ++i) {
@@ -230,8 +230,8 @@ export const remapElement = function (selected, changes, m) {
// if absolute or first segment, we want to remap x, y, x1, y1, x2, y2
// if relative, we want to scalew, scaleh
if (type % 2 === 0) { // absolute
const thisx = (seg.x !== undefined) ? seg.x : currentpt.x, // for V commands
thisy = (seg.y !== undefined) ? seg.y : currentpt.y; // for H commands
const thisx = (seg.x !== undefined) ? seg.x : currentpt.x; // for V commands
const thisy = (seg.y !== undefined) ? seg.y : currentpt.y; // for H commands
const pt = remap(thisx, thisy);
const pt1 = remap(seg.x1, seg.y1);
const pt2 = remap(seg.x2, seg.y2);

View File

@@ -479,7 +479,7 @@ export class Drawing {
this.layer_map = {};
const numchildren = this.svgElem_.childNodes.length;
// loop through all children of SVG element
const orphans = [], layernames = [];
const orphans = []; const layernames = [];
let layer = null;
let childgroups = false;
for (let i = 0; i < numchildren; ++i) {

View File

@@ -123,7 +123,7 @@ export const setGroupTitleMethod = function (val) {
*/
export const setDocumentTitleMethod = function (newTitle) {
const childs = elemContext_.getSVGContent().childNodes;
let docTitle = false, oldTitle = '';
let docTitle = false; let oldTitle = '';
const batchCmd = new BatchCommand('Change Image Title');
@@ -174,7 +174,7 @@ export const setResolutionMethod = function (x, y) {
batchCmd = new BatchCommand('Fit Canvas to Content');
const visEls = getVisibleElements();
elemContext_.getCanvas().addToSelection(visEls);
const dx = [], dy = [];
const dx = []; const dy = [];
visEls.forEach(function(_item, _i){
dx.push(bbox.x * -1);
dy.push(bbox.y * -1);

View File

@@ -41,14 +41,14 @@ export const init = function (eventContext) {
};
export const getBsplinePoint = function (t) {
const spline = { x: 0, y: 0 },
p0 = { x: eventContext_.getControllPoint2('x'), y: eventContext_.getControllPoint2('y') },
p1 = { x: eventContext_.getControllPoint1('x'), y: eventContext_.getControllPoint1('y') },
p2 = { x: eventContext_.getStart('x'), y: eventContext_.getStart('y') },
p3 = { x: eventContext_.getEnd('x'), y: eventContext_.getEnd('y') },
S = 1.0 / 6.0,
t2 = t * t,
t3 = t2 * t;
const spline = { x: 0, y: 0 };
const p0 = { x: eventContext_.getControllPoint2('x'), y: eventContext_.getControllPoint2('y') };
const p1 = { x: eventContext_.getControllPoint1('x'), y: eventContext_.getControllPoint1('y') };
const p2 = { x: eventContext_.getStart('x'), y: eventContext_.getStart('y') };
const p3 = { x: eventContext_.getEnd('x'), y: eventContext_.getEnd('y') };
const S = 1.0 / 6.0;
const t2 = t * t;
const t3 = t2 * t;
const m = [
[ -1, 3, -3, 1 ],
@@ -89,14 +89,14 @@ export const mouseMoveEvent = function (evt) {
if (!eventContext_.getStarted()) { return; }
if (evt.button === 1 || eventContext_.getCanvas().spaceKey) { return; }
let i, xya, cx, cy, dx, dy, len, angle, box,
selected = selectedElements[0];
let i; let xya; let cx; let cy; let dx; let dy; let len; let angle; let box;
let selected = selectedElements[0];
const
pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm()),
pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm());
mouseX = pt.x * currentZoom,
mouseY = pt.y * currentZoom,
shape = getElem(eventContext_.getId());
const mouseX = pt.x * currentZoom;
const mouseY = pt.y * currentZoom;
const shape = getElem(eventContext_.getId());
let realX = mouseX / currentZoom;
let x = realX;
@@ -171,8 +171,8 @@ export const mouseMoveEvent = function (evt) {
// - if newList contains selected, do nothing
// - if newList doesn't contain selected, remove it from selected
// - for any newList that was not in selectedElements, add it to selected
const elemsToRemove = selectedElements.slice(), elemsToAdd = [],
newList = eventContext_.getIntersectionList();
const elemsToRemove = selectedElements.slice(); const elemsToAdd = [];
const newList = eventContext_.getIntersectionList();
// For every element in the intersection, add if not present in selectedElements.
len = newList.length;
@@ -205,9 +205,9 @@ export const mouseMoveEvent = function (evt) {
tlist = getTransformList(selected);
const hasMatrix = hasMatrixTransform(tlist);
box = hasMatrix ? eventContext_.getInitBbox() : utilsGetBBox(selected);
let left = box.x,
top = box.y,
{ width, height } = box;
let left = box.x;
let top = box.y;
let { width, height } = box;
dx = (x - eventContext_.getStartX());
dy = (y - eventContext_.getStartY());
@@ -221,8 +221,8 @@ export const mouseMoveEvent = function (evt) {
// if rotated, adjust the dx,dy values
angle = getRotationAngle(selected);
if (angle) {
const r = Math.sqrt(dx * dx + dy * dy),
theta = Math.atan2(dy, dx) - angle * Math.PI / 180.0;
const r = Math.sqrt(dx * dx + dy * dy);
const theta = Math.atan2(dy, dx) - angle * Math.PI / 180.0;
dx = r * Math.cos(theta);
dy = r * Math.sin(theta);
}
@@ -237,10 +237,10 @@ export const mouseMoveEvent = function (evt) {
}
let // ts = null,
tx = 0, ty = 0,
sy = height ? (height + dy) / height : 1,
sx = width ? (width + dx) / width : 1;
// if we are dragging on the north side, then adjust the scale factor and ty
tx = 0; let ty = 0;
let sy = height ? (height + dy) / height : 1;
let sx = width ? (width + dx) / width : 1;
// if we are dragging on the north side, then adjust the scale factor and ty
if (eventContext_.getCurrentResizeMode().includes('n')) {
sy = height ? (height - dy) / height : 1;
ty = height;
@@ -253,9 +253,9 @@ export const mouseMoveEvent = function (evt) {
}
// update the transform list with translate,scale,translate
const translateOrigin = eventContext_.getSVGRoot().createSVGTransform(),
scale = eventContext_.getSVGRoot().createSVGTransform(),
translateBack = eventContext_.getSVGRoot().createSVGTransform();
const translateOrigin = eventContext_.getSVGRoot().createSVGTransform();
const scale = eventContext_.getSVGRoot().createSVGTransform();
const translateBack = eventContext_.getSVGRoot().createSVGTransform();
if (eventContext_.getCurConfig().gridSnapping) {
left = snapToGrid(left);
@@ -332,9 +332,9 @@ export const mouseMoveEvent = function (evt) {
case 'image': {
const square = (eventContext_.getCurrentMode() === 'square') || evt.shiftKey;
let
w = Math.abs(x - eventContext_.getStartX()),
h = Math.abs(y - eventContext_.getStartY());
let newX, newY;
w = Math.abs(x - eventContext_.getStartX());
let h = Math.abs(y - eventContext_.getStartY());
let newX; let newY;
if (square) {
w = h = Math.max(w, h);
newX = eventContext_.getStartX() < x ? eventContext_.getStartX() : eventContext_.getStartX() - w;
@@ -440,7 +440,7 @@ export const mouseMoveEvent = function (evt) {
}
if (evt.shiftKey) {
const { path } = pathModule;
let x1, y1;
let x1; let y1;
if (path) {
x1 = path.dragging ? path.dragging[0] : eventContext_.getStartX();
y1 = path.dragging ? path.dragging[1] : eventContext_.getStartY();
@@ -484,8 +484,8 @@ export const mouseMoveEvent = function (evt) {
box = utilsGetBBox(selected);
cx = box.x + box.width / 2;
cy = box.y + box.height / 2;
const m = getMatrix(selected),
center = transformPoint(cx, cy, m);
const m = getMatrix(selected);
const center = transformPoint(cx, cy, m);
cx = center.x;
cy = center.y;
angle = ((Math.atan2(cy - y, cx - x) * (180 / Math.PI)) - 90) % 360;
@@ -541,11 +541,11 @@ export const mouseUpEvent = function (evt) {
const tempJustSelected = eventContext_.getJustSelected();
eventContext_.setJustSelected(null);
if (!eventContext_.getStarted()) { return; }
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm()),
mouseX = pt.x * currentZoom,
mouseY = pt.y * currentZoom,
x = mouseX / currentZoom,
y = mouseY / currentZoom;
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm());
const mouseX = pt.x * currentZoom;
const mouseY = pt.y * currentZoom;
const x = mouseX / currentZoom;
const y = mouseY / currentZoom;
let element = getElem(eventContext_.getId());
let keep = false;
@@ -934,9 +934,9 @@ export const mouseDownEvent = function (evt) {
eventContext_.setRootSctm($id('svgcontent').querySelector('g').getScreenCTM().inverse());
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm()),
mouseX = pt.x * currentZoom,
mouseY = pt.y * currentZoom;
const pt = transformPoint(evt.pageX, evt.pageY, eventContext_.getrootSctm());
const mouseX = pt.x * currentZoom;
const mouseY = pt.y * currentZoom;
evt.preventDefault();
@@ -945,8 +945,8 @@ export const mouseDownEvent = function (evt) {
eventContext_.setLastClickPoint(pt);
}
let x = mouseX / currentZoom,
y = mouseY / currentZoom;
let x = mouseX / currentZoom;
let y = mouseY / currentZoom;
let mouseTarget = eventContext_.getCanvas().getMouseTarget(evt);
if (mouseTarget.tagName === 'a' && mouseTarget.childNodes.length === 1) {
@@ -1099,8 +1099,8 @@ export const mouseDownEvent = function (evt) {
mouseTarget.style.vectorEffect = 'non-scaling-stroke';
if (iswebkit) { delayedStroke(mouseTarget); }
const all = mouseTarget.getElementsByTagName('*'),
len = all.length;
const all = mouseTarget.getElementsByTagName('*');
const len = all.length;
for (let i = 0; i < len; i++) {
if (!all[i].style) { // mathML
continue;
@@ -1344,7 +1344,7 @@ export const DOMMouseScrollEvent = function (e) {
let factor = Math.max(3 / 4, Math.min(4 / 3, (delta)));
let wZoom, hZoom;
let wZoom; let hZoom;
if (factor > 1) {
wZoom = Math.ceil(editorW / workareaViewW * factor * 100) / 100;
hZoom = Math.ceil(editorH / workareaViewH * factor * 100) / 100;

View File

@@ -377,8 +377,8 @@ export class ChangeElementCommand extends Command {
const angle = getRotationAngle(this.elem);
if (angle) {
const bbox = this.elem.getBBox();
const cx = bbox.x + bbox.width / 2,
cy = bbox.y + bbox.height / 2;
const cx = bbox.x + bbox.width / 2;
const cy = bbox.y + bbox.height / 2;
const rotate = [ 'rotate(', angle, ' ', cx, ',', cy, ')' ].join('');
if (rotate !== this.elem.getAttribute('transform')) {
this.elem.setAttribute('transform', rotate);
@@ -585,7 +585,7 @@ export class UndoManager {
beginUndoableChange (attrName, elems) {
const p = ++this.undoChangeStackPointer;
let i = elems.length;
const oldValues = new Array(i), elements = new Array(i);
const oldValues = new Array(i); const elements = new Array(i);
while (i--) {
const elem = elems[i];
if (isNullish(elem)) { continue; }

View File

@@ -19,8 +19,8 @@
* @returns {external:jQuery}
*/
export default function jQueryPluginSVG ($) {
const proxied = $.fn.attr,
svgns = 'http://www.w3.org/2000/svg';
const proxied = $.fn.attr;
const svgns = 'http://www.w3.org/2000/svg';
/**
* @typedef {PlainObject<string, string|Float>} module:jQueryAttr.Attributes
*/

View File

@@ -114,15 +114,15 @@ export const hasMatrixTransform = function (tlist) {
* @returns {module:math.TransformedBox}
*/
export const transformBox = function (l, t, w, h, m) {
const tl = transformPoint(l, t, m),
tr = transformPoint((l + w), t, m),
bl = transformPoint(l, (t + h), m),
br = transformPoint((l + w), (t + h), m),
const tl = transformPoint(l, t, m);
const tr = transformPoint((l + w), t, m);
const bl = transformPoint(l, (t + h), m);
const br = transformPoint((l + w), (t + h), m);
minx = Math.min(tl.x, tr.x, bl.x, br.x),
maxx = Math.max(tl.x, tr.x, bl.x, br.x),
miny = Math.min(tl.y, tr.y, bl.y, br.y),
maxy = Math.max(tl.y, tr.y, bl.y, br.y);
const minx = Math.min(tl.x, tr.x, bl.x, br.x);
const maxx = Math.max(tl.x, tr.x, bl.x, br.x);
const miny = Math.min(tl.y, tr.y, bl.y, br.y);
const maxy = Math.max(tl.y, tr.y, bl.y, br.y);
return {
tl,

View File

@@ -97,7 +97,7 @@ export const pasteElementsMethod = function (type, x, y) {
pasteContext_.getCanvas().selectOnly(pasted);
if (type !== 'in_place') {
let ctrX, ctrY;
let ctrX; let ctrY;
if (!type) {
ctrX = pasteContext_.getLastClickPoint('x');
@@ -108,10 +108,10 @@ export const pasteElementsMethod = function (type, x, y) {
}
const bbox = getStrokedBBoxDefaultVisible(pasted);
const cx = ctrX - (bbox.x + bbox.width / 2),
cy = ctrY - (bbox.y + bbox.height / 2),
dx = [],
dy = [];
const cx = ctrX - (bbox.x + bbox.width / 2);
const cy = ctrY - (bbox.y + bbox.height / 2);
const dx = [];
const dy = [];
pasted.forEach(function(_item){
dx.push(cx);

View File

@@ -48,19 +48,19 @@ export const init = function (pathActionsContext) {
export const convertPath = function (pth, toRel) {
const { pathSegList } = pth;
const len = pathSegList.numberOfItems;
let curx = 0, cury = 0;
let curx = 0; let cury = 0;
let d = '';
let lastM = null;
for (let i = 0; i < len; ++i) {
const seg = pathSegList.getItem(i);
// if these properties are not in the segment, set them to zero
let x = seg.x || 0,
y = seg.y || 0,
x1 = seg.x1 || 0,
y1 = seg.y1 || 0,
x2 = seg.x2 || 0,
y2 = seg.y2 || 0;
let x = seg.x || 0;
let y = seg.y || 0;
let x1 = seg.x1 || 0;
let y1 = seg.y1 || 0;
let x2 = seg.x2 || 0;
let y2 = seg.y2 || 0;
const type = seg.pathSegType;
const pathMap = pathActionsContext_.getPathMap();
@@ -232,7 +232,7 @@ function pathDSegment (letter, points, morePoints, lastPoint) {
*/
export const pathActionsMethod = (function () {
let subpath = false;
let newPoint, firstCtrl;
let newPoint; let firstCtrl;
let currentPath = null;
let hasMoved = false;
@@ -265,7 +265,7 @@ export const pathActionsMethod = (function () {
// - https://www.codeproject.com/KB/graphics/BezierSpline.aspx?msg=2956963
// - https://www.ian-ko.com/ET_GeoWizards/UserGuide/smooth.htm
// - https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-der.html
let curpos = points.getItem(0), prevCtlPt = null;
let curpos = points.getItem(0); let prevCtlPt = null;
let d = [];
d.push([ 'M', curpos.x, ',', curpos.y, ' C' ].join(''));
for (i = 1; i <= (N - 4); i += 3) {
@@ -332,9 +332,9 @@ export const pathActionsMethod = (function () {
let mouseY = startY; // Was this meant to work with the other `mouseY`? (was defined globally so adding `let` to at least avoid a global)
const currentZoom = editorContext_.getCurrentZoom();
let x = mouseX / currentZoom,
y = mouseY / currentZoom,
stretchy = getElem('path_stretch_line');
let x = mouseX / currentZoom;
let y = mouseY / currentZoom;
let stretchy = getElem('path_stretch_line');
newPoint = [ x, y ];
if (editorContext_.getGridSnapping()) {
@@ -384,7 +384,7 @@ export const pathActionsMethod = (function () {
while (i) {
i--;
const item = seglist.getItem(i);
const px = item.x, py = item.y;
const px = item.x; const py = item.y;
// found a matching point
if (x >= (px - FUZZ) && x <= (px + FUZZ) &&
y >= (py - FUZZ) && y <= (py + FUZZ)
@@ -464,7 +464,7 @@ export const pathActionsMethod = (function () {
const num = drawnPath.pathSegList.numberOfItems;
const last = drawnPath.pathSegList.getItem(num - 1);
const lastx = last.x, lasty = last.y;
const lastx = last.x; const lasty = last.y;
if (evt.shiftKey) {
const xya = snapToAngle(lastx, lasty, x, y);
@@ -904,7 +904,7 @@ export const pathActionsMethod = (function () {
if (type === 1) { continue; }
const pts = [];
[ '', 1, 2 ].forEach(function(n){
const x = seg['x' + n], y = seg['y' + n];
const x = seg['x' + n]; const y = seg['y' + n];
if (x !== undefined && y !== undefined) {
const pt = transformPoint(x, y, m);
pts.splice(pts.length, 0, pt.x, pt.y);
@@ -1050,7 +1050,7 @@ export const pathActionsMethod = (function () {
return;
}
let lastM, zSeg;
let lastM; let zSeg;
// Find this sub-path's closing point and remove
for (let i = 0; i < list.numberOfItems; i++) {

View File

@@ -544,7 +544,7 @@ export class Segment {
* @returns {void}
*/
setLinked (num) {
let seg, anum, pt;
let seg; let anum; let pt;
if (num === 2) {
anum = 1;
seg = this.next;
@@ -744,7 +744,7 @@ export class Path {
if (!seg.prev) { return; }
const { prev } = seg;
let newseg, newX, newY;
let newseg; let newX; let newY;
switch (seg.item.pathSegType) {
case 4: {
newX = (seg.item.x + prev.item.x) / 2;

View File

@@ -382,26 +382,26 @@ export const getSegSelector = getSegSelectorMethod;
*/
export const smoothControlPoints = function (ct1, ct2, pt) {
// each point must not be the origin
const x1 = ct1.x - pt.x,
y1 = ct1.y - pt.y,
x2 = ct2.x - pt.x,
y2 = ct2.y - pt.y;
const x1 = ct1.x - pt.x;
const y1 = ct1.y - pt.y;
const x2 = ct2.x - pt.x;
const y2 = ct2.y - pt.y;
if ((x1 !== 0 || y1 !== 0) && (x2 !== 0 || y2 !== 0)) {
const
r1 = Math.sqrt(x1 * x1 + y1 * y1),
r2 = Math.sqrt(x2 * x2 + y2 * y2),
nct1 = editorContext_.getSVGRoot().createSVGPoint(),
nct2 = editorContext_.getSVGRoot().createSVGPoint();
let anglea = Math.atan2(y1, x1),
angleb = Math.atan2(y2, x2);
r1 = Math.sqrt(x1 * x1 + y1 * y1);
const r2 = Math.sqrt(x2 * x2 + y2 * y2);
const nct1 = editorContext_.getSVGRoot().createSVGPoint();
const nct2 = editorContext_.getSVGRoot().createSVGPoint();
let anglea = Math.atan2(y1, x1);
let angleb = Math.atan2(y2, x2);
if (anglea < 0) { anglea += 2 * Math.PI; }
if (angleb < 0) { angleb += 2 * Math.PI; }
const angleBetween = Math.abs(anglea - angleb),
angleDiff = Math.abs(Math.PI - angleBetween) / 2;
const angleBetween = Math.abs(anglea - angleb);
const angleDiff = Math.abs(Math.PI - angleBetween) / 2;
let newAnglea, newAngleb;
let newAnglea; let newAngleb;
if (anglea - angleb > 0) {
newAnglea = angleBetween < Math.PI ? (anglea + angleDiff) : (anglea - angleDiff);
newAngleb = angleBetween < Math.PI ? (angleb - angleDiff) : (angleb + angleDiff);
@@ -443,7 +443,7 @@ export const removePath_ = function (id) {
if (id in pathData) { delete pathData[id]; }
};
let newcx, newcy, oldcx, oldcy, angle;
let newcx; let newcy; let oldcx; let oldcy; let angle;
const getRotVals = function (x, y) {
let dx = x - oldcx;
@@ -493,10 +493,10 @@ export const recalcRotatedPath = function () {
newcy = box.y + box.height / 2;
// un-rotate the new center to the proper position
const dx = newcx - oldcx,
dy = newcy - oldcy,
r = Math.sqrt(dx * dx + dy * dy),
theta = Math.atan2(dy, dx) + angle;
const dx = newcx - oldcx;
const dy = newcy - oldcy;
const r = Math.sqrt(dx * dx + dy * dy);
const theta = Math.atan2(dy, dx) + angle;
newcx = r * Math.cos(theta) + oldcx;
newcy = r * Math.sin(theta) + oldcy;
@@ -506,12 +506,12 @@ export const recalcRotatedPath = function () {
let i = list.numberOfItems;
while (i) {
i -= 1;
const seg = list.getItem(i),
type = seg.pathSegType;
const seg = list.getItem(i);
const type = seg.pathSegType;
if (type === 1) { continue; }
const rvals = getRotVals(seg.x, seg.y),
points = [ rvals.x, rvals.y ];
const rvals = getRotVals(seg.x, seg.y);
const points = [ rvals.x, rvals.y ];
if (!isNullish(seg.x1) && !isNullish(seg.x2)) {
const cVals1 = getRotVals(seg.x1, seg.y1);
const cVals2 = getRotVals(seg.x2, seg.y2);
@@ -525,8 +525,8 @@ export const recalcRotatedPath = function () {
// selectedBBoxes[0].width = box.width; selectedBBoxes[0].height = box.height;
// now we must set the new transform to be rotated around the new center
const Rnc = editorContext_.getSVGRoot().createSVGTransform(),
tlist = getTransformList(currentPath);
const Rnc = editorContext_.getSVGRoot().createSVGTransform();
const tlist = getTransformList(currentPath);
Rnc.setRotate((angle * 180.0 / Math.PI), newcx, newcy);
tlist.replaceItem(Rnc, 0);
};
@@ -613,19 +613,19 @@ const pathMap = [
export const convertPath = function (pth, toRel) {
const { pathSegList } = pth;
const len = pathSegList.numberOfItems;
let curx = 0, cury = 0;
let curx = 0; let cury = 0;
let d = '';
let lastM = null;
for (let i = 0; i < len; ++i) {
const seg = pathSegList.getItem(i);
// if these properties are not in the segment, set them to zero
let x = seg.x || 0,
y = seg.y || 0,
x1 = seg.x1 || 0,
y1 = seg.y1 || 0,
x2 = seg.x2 || 0,
y2 = seg.y2 || 0;
let x = seg.x || 0;
let y = seg.y || 0;
let x1 = seg.x1 || 0;
let y1 = seg.y1 || 0;
let x2 = seg.x2 || 0;
let y2 = seg.y2 || 0;
const type = seg.pathSegType;
let letter = pathMap[type][toRel ? 'toLowerCase' : 'toUpperCase']();

View File

@@ -249,7 +249,7 @@ export const recalculateDimensions = function (selected) {
// save the start transform value too
initial.transform = context_.getStartTransform() || '';
let oldcenter, newcenter;
let oldcenter; let newcenter;
// if it's a regular group, we have special processing to flatten transforms
if ((selected.tagName === 'g' && !gsvg) || selected.tagName === 'a') {
@@ -281,7 +281,7 @@ export const recalculateDimensions = function (selected) {
}
}
const N = tlist.numberOfItems;
let tx = 0, ty = 0, operation = 0;
let tx = 0; let ty = 0; let operation = 0;
let firstM;
if (N) {
@@ -296,9 +296,9 @@ export const recalculateDimensions = function (selected) {
// if the children are unrotated, pass the scale down directly
// otherwise pass the equivalent matrix() down directly
const tm = tlist.getItem(N - 3).matrix,
sm = tlist.getItem(N - 2).matrix,
tmn = tlist.getItem(N - 1).matrix;
const tm = tlist.getItem(N - 3).matrix;
const sm = tlist.getItem(N - 2).matrix;
const tmn = tlist.getItem(N - 1).matrix;
const children = selected.childNodes;
let c = children.length;
@@ -360,9 +360,9 @@ export const recalculateDimensions = function (selected) {
// [S2] = [T2_inv][M_inv][T][S][-T][M][-T2_inv]
const s2 = matrixMultiply(t2.inverse(), m.inverse(), tm, sm, tmn, m, t2n.inverse());
const translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
const translateOrigin = svgroot.createSVGTransform();
const scale = svgroot.createSVGTransform();
const translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(t2n.e, t2n.f);
scale.setScale(s2.a, s2.d);
translateBack.setTranslate(t2.e, t2.f);
@@ -477,8 +477,8 @@ export const recalculateDimensions = function (selected) {
// keep pushing it down to the children
} else if (N === 1 && tlist.getItem(0).type === 1 && !gangle) {
operation = 1;
const m = tlist.getItem(0).matrix,
children = selected.childNodes;
const m = tlist.getItem(0).matrix;
const children = selected.childNodes;
let c = children.length;
while (c--) {
const child = children.item(c);
@@ -549,9 +549,9 @@ export const recalculateDimensions = function (selected) {
const rold = roldt.matrix;
const rnew = svgroot.createSVGTransform();
rnew.setRotate(gangle, newcenter.x, newcenter.y);
const rnewInv = rnew.matrix.inverse(),
mInv = m.inverse(),
extrat = matrixMultiply(mInv, rnewInv, rold, m);
const rnewInv = rnew.matrix.inverse();
const mInv = m.inverse();
const extrat = matrixMultiply(mInv, rnewInv, rold, m);
tx = extrat.e;
ty = extrat.f;
@@ -691,9 +691,9 @@ export const recalculateDimensions = function (selected) {
} else if ((N === 1 || (N > 1 && tlist.getItem(1).type !== 3)) &&
tlist.getItem(0).type === 2) {
operation = 2; // translate
const oldxlate = tlist.getItem(0).matrix,
meq = transformListToTransform(tlist, 1).matrix,
meqInv = meq.inverse();
const oldxlate = tlist.getItem(0).matrix;
const meq = transformListToTransform(tlist, 1).matrix;
const meqInv = meq.inverse();
m = matrixMultiply(meqInv, oldxlate, meq);
tlist.removeItem(0);
// else if this child now has a matrix imposition (from a parent group)

View File

@@ -107,12 +107,12 @@ export class Selector {
*/
resize(bbox) {
const dataStorage = svgFactory_.getDataStorage();
const selectedBox = this.selectorRect,
mgr = selectorManager_,
selectedGrips = mgr.selectorGrips,
selected = this.selectedElement,
sw = selected.getAttribute('stroke-width'),
currentZoom = svgFactory_.getCurrentZoom();
const selectedBox = this.selectorRect;
const mgr = selectorManager_;
const selectedGrips = mgr.selectorGrips;
const selected = this.selectedElement;
const sw = selected.getAttribute('stroke-width');
const currentZoom = svgFactory_.getCurrentZoom();
let offset = 1 / currentZoom;
if (selected.getAttribute('stroke') !== 'none' && !isNaN(sw)) {
offset += (sw / 2);
@@ -147,7 +147,7 @@ export class Selector {
}
// apply the transforms
const l = bbox.x, t = bbox.y, w = bbox.width, h = bbox.height;
const l = bbox.x; const t = bbox.y; const w = bbox.width; const h = bbox.height;
// bbox = {x: l, y: t, width: w, height: h}; // Not in use
// we need to handle temporary transforms too
@@ -156,16 +156,16 @@ export class Selector {
// *
offset *= currentZoom;
const nbox = transformBox(l * currentZoom, t * currentZoom, w * currentZoom, h * currentZoom, m),
{ aabox } = nbox;
let nbax = aabox.x - offset,
nbay = aabox.y - offset,
nbaw = aabox.width + (offset * 2),
nbah = aabox.height + (offset * 2);
const nbox = transformBox(l * currentZoom, t * currentZoom, w * currentZoom, h * currentZoom, m);
const { aabox } = nbox;
let nbax = aabox.x - offset;
let nbay = aabox.y - offset;
let nbaw = aabox.width + (offset * 2);
let nbah = aabox.height + (offset * 2);
// now if the shape is rotated, un-rotate it
const cx = nbax + nbaw / 2,
cy = nbay + nbah / 2;
const cx = nbax + nbaw / 2;
const cy = nbay + nbah / 2;
const angle = getRotationAngle(selected);
if (angle) {
@@ -179,10 +179,10 @@ export class Selector {
// calculate the axis-aligned bbox
const { tl } = nbox;
let minx = tl.x,
miny = tl.y,
maxx = tl.x,
maxy = tl.y;
let minx = tl.x;
let miny = tl.y;
let maxx = tl.x;
let maxy = tl.y;
const { min, max } = Math;
@@ -447,8 +447,8 @@ export class SelectorManager {
*/
releaseSelector(elem) {
if (isNullish(elem)) { return; }
const N = this.selectors.length,
sel = this.selectorMap[elem.id];
const N = this.selectors.length;
const sel = this.selectorMap[elem.id];
if (sel && !sel.locked) {
// TODO(codedread): Ensure this exists in this module.
console.warn('WARNING! selector was released but was already unlocked');

View File

@@ -112,7 +112,7 @@ export const moveUpDownSelected = function (dir) {
elementContext_.setCurBBoxes([]);
// curBBoxes = [];
let closest, foundCur;
let closest; let foundCur;
// jQuery sorts this list
const list = elementContext_.getIntersectionList(getStrokedBBoxDefaultVisible([ selected ]));
if (dir === 'Down') { list.reverse(); }
@@ -230,7 +230,7 @@ export const moveSelectedElements = function (dx, dy, undoable) {
export const cloneSelectedElements = function (x, y) {
const selectedElements = elementContext_.getSelectedElements();
const currentGroup = elementContext_.getCurrentGroup();
let i, elem;
let i; let elem;
const batchCmd = new BatchCommand('Clone Elements');
// find all the elements selected (stop at first null)
const len = selectedElements.length;
@@ -290,9 +290,9 @@ export const alignSelectedElements = function (type, relativeTo) {
const bboxes = []; // angles = [];
const len = selectedElements.length;
if (!len) { return; }
let minx = Number.MAX_VALUE, maxx = Number.MIN_VALUE,
miny = Number.MAX_VALUE, maxy = Number.MIN_VALUE;
let curwidth = Number.MIN_VALUE, curheight = Number.MIN_VALUE;
let minx = Number.MAX_VALUE; let maxx = Number.MIN_VALUE;
let miny = Number.MAX_VALUE; let maxy = Number.MIN_VALUE;
let curwidth = Number.MIN_VALUE; let curheight = Number.MIN_VALUE;
for (let i = 0; i < len; ++i) {
if (isNullish(selectedElements[i])) { break; }
const elem = selectedElements[i];
@@ -537,7 +537,7 @@ export const pushGroupProperty = function (g, undoable) {
filter: g.getAttribute('filter'),
opacity: g.getAttribute('opacity'),
};
let gfilter, gblur, changes;
let gfilter; let gblur; let changes;
const drawing = elementContext_.getDrawing();
for (let i = 0; i < len; i++) {
@@ -672,8 +672,8 @@ export const pushGroupProperty = function (g, undoable) {
// [ gm ] [ chm ] = [ chm ] [ gm' ]
// [ gm' ] = [ chmInv ] [ gm ] [ chm ]
const chm = transformListToTransform(chtlist).matrix,
chmInv = chm.inverse();
const chm = transformListToTransform(chtlist).matrix;
const chmInv = chm.inverse();
const gm = matrixMultiply(chmInv, m, chm);
newxform.setMatrix(gm);
chtlist.appendItem(newxform);

View File

@@ -351,7 +351,7 @@ export const setRotationAngle = function (val, preventUndo) {
const elem = selectedElements[0];
const oldTransform = elem.getAttribute('transform');
const bbox = utilsGetBBox(elem);
const cx = bbox.x + bbox.width / 2, cy = bbox.y + bbox.height / 2;
const cx = bbox.x + bbox.width / 2; const cy = bbox.y + bbox.height / 2;
const tlist = getTransformList(elem);
// only remove the real rotational transform if present (i.e. at index=0)

View File

@@ -501,7 +501,7 @@ export const setSvgString = function (xmlString, preventUndo) {
*/
export const importSvgString = function (xmlString) {
const dataStorage = svgContext_.getDataStorage();
let j, ts, useEl;
let j; let ts; let useEl;
try {
// Get unique ID
const uid = encode64(xmlString.length + xmlString).substr(0, 32);
@@ -534,11 +534,11 @@ export const importSvgString = function (xmlString) {
svgContext_.getCanvas().uniquifyElems(svg);
const innerw = convertToNum('width', svg.getAttribute('width')),
innerh = convertToNum('height', svg.getAttribute('height')),
innervb = svg.getAttribute('viewBox'),
// if no explicit viewbox, create one out of the width and height
vb = innervb ? innervb.split(' ') : [ 0, 0, innerw, innerh ];
const innerw = convertToNum('width', svg.getAttribute('width'));
const innerh = convertToNum('height', svg.getAttribute('height'));
const innervb = svg.getAttribute('viewBox');
// if no explicit viewbox, create one out of the width and height
const vb = innervb ? innervb.split(' ') : [ 0, 0, innerw, innerh ];
for (j = 0; j < 4; ++j) {
vb[j] = Number(vb[j]);
}
@@ -908,8 +908,8 @@ export const uniquifyElemsMethod = function (g) {
const attrnode = n.getAttributeNode(attr);
if (attrnode) {
// the incoming file has been sanitized, so we should be able to safely just strip off the leading #
const url = svgContext_.getCanvas().getUrlFromAttr(attrnode.value),
refid = url ? url.substr(1) : null;
const url = svgContext_.getCanvas().getUrlFromAttr(attrnode.value);
const refid = url ? url.substr(1) : null;
if (refid) {
if (!(refid in ids)) {
// add this id to our map
@@ -1012,7 +1012,7 @@ export const removeUnusedDefElemsMethod = function () {
const allEls = svgContext_.getSVGContent().getElementsByTagNameNS(NS.SVG, '*');
const allLen = allEls.length;
let i, j;
let i; let j;
for (i = 0; i < allLen; i++) {
const el = allEls[i];
for (j = 0; j < alen; j++) {

View File

@@ -1131,8 +1131,8 @@ class SvgCanvas {
if (!elemsToRemove.length) { return; }
// find every element and remove it from our array copy
const newSelectedItems = [],
len = selectedElements.length;
const newSelectedItems = [];
const len = selectedElements.length;
for (let i = 0; i < len; ++i) {
const elem = selectedElements[i];
if (elem) {
@@ -1175,8 +1175,8 @@ class SvgCanvas {
maxx: null,
maxy: null
};
const THRESHOLD_DIST = 0.8,
STEP_COUNT = 10;
const THRESHOLD_DIST = 0.8;
const STEP_COUNT = 10;
let dAttr = null;
let startX = null;
let startY = null;

View File

@@ -43,7 +43,7 @@ export const textActionsMethod = (function () {
let chardata = [];
let textbb; // , transbb;
let matrix;
let lastX, lastY;
let lastX; let lastY;
let allowDbl;
/**
@@ -135,10 +135,10 @@ export const textActionsMethod = (function () {
cursor.setAttribute('visibility', 'hidden');
const tl = ptToScreen(startbb.x, textbb.y),
tr = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y),
bl = ptToScreen(startbb.x, textbb.y + textbb.height),
br = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y + textbb.height);
const tl = ptToScreen(startbb.x, textbb.y);
const tr = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y);
const bl = ptToScreen(startbb.x, textbb.y + textbb.height);
const br = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y + textbb.height);
const dstr = 'M' + tl.x + ',' + tl.y +
' L' + tr.x + ',' + tr.y +
@@ -276,9 +276,9 @@ export const textActionsMethod = (function () {
function selectWord (evt) {
if (!allowDbl || !curtext) { return; }
const currentZoom = textActionsContext_.getCurrentZoom();
const ept = transformPoint(evt.pageX, evt.pageY, textActionsContext_.getrootSctm()),
mouseX = ept.x * currentZoom,
mouseY = ept.y * currentZoom;
const ept = transformPoint(evt.pageX, evt.pageY, textActionsContext_.getrootSctm());
const mouseX = ept.x * currentZoom;
const mouseY = ept.y * currentZoom;
const pt = screenToPt(mouseX, mouseY);
const index = getIndexFromPoint(pt.x, pt.y);
@@ -461,7 +461,7 @@ export const textActionsMethod = (function () {
*/
init (_inputElem) {
if (!curtext) { return; }
let i, end;
let i; let end;
// if (supportsEditableText()) {
// curtext.select();
// return;

View File

@@ -245,8 +245,8 @@ export const changeSelectedAttributeNoUndoMethod = function (attr, newValue, ele
const center = transformPoint(
box.x + box.width / 2, box.y + box.height / 2, transformListToTransform(tlist).matrix
);
const cx = center.x,
cy = center.y;
const cx = center.x;
const cy = center.y;
const newrot = undoContext_.getSVGRoot().createSVGTransform();
newrot.setRotate(angle, cx, cy);
tlist.insertItemBefore(newrot, n);

View File

@@ -163,8 +163,8 @@ export function encode64(input) {
}
const output = new Array(Math.floor((input.length + 2) / 3) * 4);
let i = 0,
p = 0;
let i = 0;
let p = 0;
do {
const chr1 = input.charCodeAt(i++);
const chr2 = input.charCodeAt(i++);
@@ -264,9 +264,9 @@ export const dataURLToObjectURL = function (dataurl) {
if (typeof Uint8Array === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) {
return '';
}
const arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]);
const arr = dataurl.split(',');
const mime = arr[0].match(/:(.*?);/)[1];
const bstr = atob(arr[1]);
/*
const [prefix, suffix] = dataurl.split(','),
{groups: {mime}} = prefix.match(/:(?<mime>.*?);/),
@@ -333,7 +333,7 @@ export const text2xml = function (sXML) {
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
}
let out, dXML;
let out; let dXML;
try {
dXML = (window.DOMParser) ? new DOMParser() : new window.ActiveXObject('Microsoft.XMLDOM');
dXML.async = false;
@@ -514,9 +514,9 @@ export const getPathBBox = function (path) {
bounds[1].push(P0[1]);
if (seg.x1) {
const P1 = [ seg.x1, seg.y1 ],
P2 = [ seg.x2, seg.y2 ],
P3 = [ seg.x, seg.y ];
const P1 = [ seg.x1, seg.y1 ];
const P2 = [ seg.x2, seg.y2 ];
const P3 = [ seg.x, seg.y ];
for (let j = 0; j < 2; j++) {
const calc = getCalc(j, P1, P2, P3);
@@ -573,7 +573,7 @@ function groupBBFix(selected) {
}
const ref = editorContext_.getDataStorage().get(selected, 'ref');
let matched = null;
let ret, copy;
let ret; let copy;
if (ref) {
let elements = [];
@@ -737,7 +737,7 @@ export const getPathDFromSegments = function (pathSegments) {
export const getPathDFromElement = function (elem) {
// Possibly the cubed root of 6, but 1.81 works best
let num = 1.81;
let d, rx, ry;
let d; let rx; let ry;
switch (elem.tagName) {
case 'ellipse':
case 'circle': {
@@ -779,9 +779,9 @@ export const getPathDFromElement = function (elem) {
rx = elem.getAttribute('rx');
ry = elem.getAttribute('ry');
const b = elem.getBBox();
const { x, y } = b,
w = b.width,
h = b.height;
const { x, y } = b;
const w = b.width;
const h = b.height;
num = 4 - num; // Why? Because!
d = (!rx && !ry)