From be5d353bc4834ce8ec2fc66290153a091f23e760 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 27 Jul 2020 11:55:15 +0800 Subject: [PATCH] - Linting: max-len, exponentiation operator --- src/common/utilities.js | 15 ++- src/editor/canvg/canvg.js | 106 ++++++++++++++---- src/editor/contextmenu.js | 5 +- src/editor/embedapi-dom.js | 7 +- src/editor/embedapi.js | 6 +- src/editor/extensions/ext-markers.js | 7 +- src/editor/extensions/ext-mathjax.js | 8 +- src/editor/extensions/ext-overview_window.js | 18 ++- src/editor/extensions/ext-polygon.js | 10 +- src/editor/jgraduate/jQuery.jGraduate.js | 10 +- src/editor/jspdf/jspdf.plugin.svgToPdf.js | 5 +- src/editor/svg-editor.js | 11 +- src/editor/svgicons/jQuery.svgIcons.js | 4 +- .../dynamic-import-polyfill/importModule.js | 6 +- src/svgcanvas/sanitize.js | 4 +- src/svgcanvas/svgcanvas.js | 23 +++- 16 files changed, 188 insertions(+), 57 deletions(-) diff --git a/src/common/utilities.js b/src/common/utilities.js index 3ce7b625..e30cf483 100644 --- a/src/common/utilities.js +++ b/src/common/utilities.js @@ -502,10 +502,10 @@ export const getPathBBox = function (path) { const getCalc = function (j, P1, P2, P3) { return function (t) { - return 1 - Math.pow(t, 3) * P0[j] + - 3 * 1 - Math.pow(t, 2) * t * P1[j] + - 3 * (1 - t) * Math.pow(t, 2) * P2[j] + - Math.pow(t, 3) * P3[j]; + return 1 - t ** 3 * P0[j] + + 3 * 1 - t ** 2 * t * P1[j] + + 3 * (1 - t) * t ** 2 * P2[j] + + t ** 3 * P3[j]; }; }; @@ -538,7 +538,7 @@ export const getPathBBox = function (path) { } continue; } - const b2ac = Math.pow(b, 2) - 4 * c * a; + const b2ac = b ** 2 - 4 * c * a; if (b2ac < 0) { continue; } const t1 = (-b + Math.sqrt(b2ac)) / (2 * a); if (t1 > 0 && t1 < 1) { bounds[j].push(calc(t1)); } @@ -888,7 +888,10 @@ export const getBBoxOfElementAsPath = function (elem, addSVGElementFromJson, pat * @param {module:path.EditorContext#addCommandToHistory|module:draw.DrawCanvasInit#addCommandToHistory} addCommandToHistory - see [canvas.addCommandToHistory]{@link module:svgcanvas~addCommandToHistory} * @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized. */ -export const convertToPath = function (elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) { +export const convertToPath = function ( + elem, attrs, addSVGElementFromJson, pathActions, + clearSelection, addToSelection, hstry, addCommandToHistory +) { const batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes diff --git a/src/editor/canvg/canvg.js b/src/editor/canvg/canvg.js index 461c22e6..b1117328 100644 --- a/src/editor/canvg/canvg.js +++ b/src/editor/canvg/canvg.js @@ -637,7 +637,9 @@ function build (opts) { } }); - const data = svg.trim(svg.compressSpaces(v)).replace(/\)([a-zA-Z])/g, ') $1').replace(/\)(\s?,\s?)/g, ') ').split(/\s(?=[a-z])/); + const data = svg.trim(svg.compressSpaces(v)).replace( + /\)([a-zA-Z])/g, ') $1' + ).replace(/\)(\s?,\s?)/g, ') ').split(/\s(?=[a-z])/); this.transforms = data.map((d) => { const type = svg.trim(d.split('(')[0]); const s = d.split('(')[1].replace(')', ''); @@ -688,10 +690,25 @@ function build (opts) { ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y')); } else { // align - if (align.startsWith('xMid') && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0); - if (align.endsWith('YMid') && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0); - if (align.startsWith('xMax') && ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) ctx.translate(width - desiredWidth, 0); - if (align.endsWith('YMax') && ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) ctx.translate(0, height - desiredHeight); + if (align.startsWith('xMid') && + ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) { + ctx.translate(width / 2.0 - desiredWidth / 2.0, 0); + } + if (align.endsWith('YMid') && + ((meetOrSlice === 'meet' && scaleMin === scaleX) || (meetOrSlice === 'slice' && scaleMax === scaleX))) { + ctx.translate(0, height / 2.0 - desiredHeight / 2.0); + } + if (align.startsWith('xMax') && + ((meetOrSlice === 'meet' && scaleMin === scaleY) || (meetOrSlice === 'slice' && scaleMax === scaleY))) { + ctx.translate(width - desiredWidth, 0); + } + if (align.endsWith('YMax') && + ((meetOrSlice === 'meet' && scaleMin === scaleX) || + (meetOrSlice === 'slice' && scaleMax === scaleX) + ) + ) { + ctx.translate(0, height - desiredHeight); + } } // scale @@ -1634,19 +1651,37 @@ function build (opts) { // render me using a temporary svg element const tempSvg = new svg.Element.svg(); - tempSvg.attributes.viewBox = new svg.Property('viewBox', this.attribute('viewBox').value); - tempSvg.attributes.refX = new svg.Property('refX', this.attribute('refX').value); - tempSvg.attributes.refY = new svg.Property('refY', this.attribute('refY').value); - tempSvg.attributes.width = new svg.Property('width', this.attribute('markerWidth').value); - tempSvg.attributes.height = new svg.Property('height', this.attribute('markerHeight').value); - tempSvg.attributes.fill = new svg.Property('fill', this.attribute('fill').valueOrDefault('black')); - tempSvg.attributes.stroke = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none')); + tempSvg.attributes.viewBox = new svg.Property( + 'viewBox', this.attribute('viewBox').value + ); + tempSvg.attributes.refX = new svg.Property( + 'refX', this.attribute('refX').value + ); + tempSvg.attributes.refY = new svg.Property( + 'refY', this.attribute('refY').value + ); + tempSvg.attributes.width = new svg.Property( + 'width', this.attribute('markerWidth').value + ); + tempSvg.attributes.height = new svg.Property( + 'height', this.attribute('markerHeight').value + ); + tempSvg.attributes.fill = new svg.Property( + 'fill', this.attribute('fill').valueOrDefault('black') + ); + tempSvg.attributes.stroke = new svg.Property( + 'stroke', this.attribute('stroke').valueOrDefault('none') + ); tempSvg.children = this.children; tempSvg.render(ctx); ctx.restore(); - if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth); - if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle); + if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === + 'strokeWidth' + ) ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth); + if (this.attribute('orient').valueOrDefault('auto') === 'auto') { + ctx.rotate(-angle); + } ctx.translate(-point.x, -point.y); } }; @@ -2246,8 +2281,17 @@ function build (opts) { if (this.hasText) { // render as text element super.renderChildren(ctx); - const fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); - svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.toPixels('y'), this.x + this.measureText(ctx), this.y)); + const fontSize = new svg.Property( + 'fontSize', svg.Font.Parse(svg.ctx.font).fontSize + ); + svg.Mouse.checkBoundingBox( + this, new svg.BoundingBox( + this.x, + this.y - fontSize.toPixels('y'), + this.x + this.measureText(ctx), + this.y + ) + ); } else { // render as temporary group const g = new svg.Element.g(); @@ -2445,18 +2489,33 @@ function build (opts) { if (!isNullish(element)) { let tempSvg = element; if (element.type === 'symbol') { - // render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement) + // render me using a temporary svg element in symbol cases + // (https://www.w3.org/TR/SVG/struct.html#UseElement) tempSvg = new svg.Element.svg(); tempSvg.type = 'svg'; - tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value); - tempSvg.attributes.preserveAspectRatio = new svg.Property('preserveAspectRatio', element.attribute('preserveAspectRatio').value); - tempSvg.attributes.overflow = new svg.Property('overflow', element.attribute('overflow').value); + tempSvg.attributes.viewBox = new svg.Property( + 'viewBox', element.attribute('viewBox').value + ); + tempSvg.attributes.preserveAspectRatio = new svg.Property( + 'preserveAspectRatio', element.attribute('preserveAspectRatio').value + ); + tempSvg.attributes.overflow = new svg.Property( + 'overflow', element.attribute('overflow').value + ); tempSvg.children = element.children; } if (tempSvg.type === 'svg') { // if symbol or svg, inherit width/height from me - if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value); - if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value); + if (this.attribute('width').hasValue()) { + tempSvg.attributes.width = new svg.Property( + 'width', this.attribute('width').value + ); + } + if (this.attribute('height').hasValue()) { + tempSvg.attributes.height = new svg.Property( + 'height', this.attribute('height').value + ); + } } const oldParent = tempSvg.parent; tempSvg.parent = null; @@ -2907,7 +2966,8 @@ function build (opts) { } }, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility? - return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new + // eslint-disable-next-line promise/avoid-new + return new Promise((resolve, reject) => { if (svg.ImagesLoaded()) { waitingForImages = false; draw(resolve); diff --git a/src/editor/contextmenu.js b/src/editor/contextmenu.js index 4513c31a..2a51f8da 100644 --- a/src/editor/contextmenu.js +++ b/src/editor/contextmenu.js @@ -44,7 +44,10 @@ const menuItemIsValid = function (menuItem) { export const add = function (menuItem) { // menuItem: {id, label, shortcut, action} if (!menuItemIsValid(menuItem)) { - throw new TypeError('Menu items must be defined and have at least properties: id, label, action, where action must be a function'); + throw new TypeError( + 'Menu items must be defined and have at least properties: ' + + 'id, label, action, where action must be a function' + ); } if (menuItem.id in contextMenuExtensions) { throw new Error('Cannot add extension "' + menuItem.id + '", an extension by that name already exists"'); diff --git a/src/editor/embedapi-dom.js b/src/editor/embedapi-dom.js index 3eb72974..802e7331 100644 --- a/src/editor/embedapi-dom.js +++ b/src/editor/embedapi-dom.js @@ -30,7 +30,12 @@ function handleSvgData (data, error) { * @returns {void} */ function loadSvg () { - const svgexample = 'Layer 1'; + const svgexample = '' + + 'Layer 1' + + ''; svgCanvas.setSvgString(svgexample); } diff --git a/src/editor/embedapi.js b/src/editor/embedapi.js index c1b4bfe0..dd6459c4 100644 --- a/src/editor/embedapi.js +++ b/src/editor/embedapi.js @@ -71,7 +71,11 @@ function messageListener (e) { e.source !== this.frame.contentWindow || (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) ) { - console.log(`The origin ${e.origin} was not whitelisted as an origin from which responses may be received by this ${window.origin} script.`); // eslint-disable-line no-console + // eslint-disable-next-line no-console -- Info for developers + console.error( + `The origin ${e.origin} was not whitelisted as an origin from ` + + `which responses may be received by this ${window.origin} script.` + ); return; } addCallback(this, data); diff --git a/src/editor/extensions/ext-markers.js b/src/editor/extensions/ext-markers.js index c521eff1..ec8628e7 100644 --- a/src/editor/extensions/ext-markers.js +++ b/src/editor/extensions/ext-markers.js @@ -53,8 +53,11 @@ export default { rightarrow: {element: 'path', attr: {d: 'M100,50 L0,90 L30,50 L0,10 Z'}}, textmarker: - {element: 'text', attr: {x: 0, y: 0, 'stroke-width': 0, stroke: 'none', 'font-size': 75, 'font-family': 'serif', 'text-anchor': 'left', - 'xml:space': 'preserve'}}, + {element: 'text', attr: { + x: 0, y: 0, 'stroke-width': 0, stroke: 'none', + 'font-size': 75, 'font-family': 'serif', 'text-anchor': 'left', + 'xml:space': 'preserve' + }}, forwardslash: {element: 'path', attr: {d: 'M30,100 L70,0'}}, reverseslash: diff --git a/src/editor/extensions/ext-mathjax.js b/src/editor/extensions/ext-mathjax.js index 9f649b9b..f64568de 100644 --- a/src/editor/extensions/ext-mathjax.js +++ b/src/editor/extensions/ext-mathjax.js @@ -59,7 +59,9 @@ export default { mathjax: { embed_svg: 'Save as mathematics', embed_mathml: 'Save as figure', - svg_save_warning: 'The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore. ', + svg_save_warning: 'The math will be transformed into a figure is ' + + 'manipulatable like everything else. You will not be able to ' + + 'manipulate the TeX-code anymore.', mathml_save_warning: 'Advised. The math will be saved as a figure.', title: 'Mathematics code editor' } @@ -149,7 +151,9 @@ export default { 'Mathematics Editor' + '' + + 'TeX code.' + + '' + '' + '' + '' + diff --git a/src/editor/extensions/ext-overview_window.js b/src/editor/extensions/ext-overview_window.js index 8910c79d..c2518af1 100644 --- a/src/editor/extensions/ext-overview_window.js +++ b/src/editor/extensions/ext-overview_window.js @@ -22,13 +22,21 @@ export default { // Define and insert the base html element. const propsWindowHtml = - '
' + - '
' + - '
' + - '' + + '
' + + '
' + + '
' + + '' + ' ' + '' + - '
' + + '
' + '
' + '
' + '
' + diff --git a/src/editor/extensions/ext-polygon.js b/src/editor/extensions/ext-polygon.js index df026dd7..7968fca9 100644 --- a/src/editor/extensions/ext-polygon.js +++ b/src/editor/extensions/ext-polygon.js @@ -170,7 +170,11 @@ export default { // TODO: Needs to be done after orig icon loads setTimeout(function () { // Create source save/cancel buttons - /* const save = */ $('#tool_source_save').clone().hide().attr('id', 'polygon_save').unbind().appendTo('#tool_source_back').click(function () { + /* const save = */ $('#tool_source_save').clone().hide().attr( + 'id', 'polygon_save' + ).unbind().appendTo( + '#tool_source_back' + ).click(function () { if (!editingitex) { return; } @@ -188,7 +192,9 @@ export default { // setSelectMode(); }); - /* const cancel = */ $('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () { + /* const cancel = */ $('#tool_source_cancel').clone().hide().attr( + 'id', 'polygon_cancel' + ).unbind().appendTo('#tool_source_back').click(function () { endChanges(); }); }, 3000); diff --git a/src/editor/jgraduate/jQuery.jGraduate.js b/src/editor/jgraduate/jQuery.jGraduate.js index 50b2c48d..6ebdd50c 100644 --- a/src/editor/jgraduate/jQuery.jGraduate.js +++ b/src/editor/jgraduate/jQuery.jGraduate.js @@ -664,7 +664,9 @@ export default function jQueryPluginJGraduate ($) { } if (opac === null) opac = 1; - const pickerD = 'M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z'; + const pickerD = 'M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,' + + '3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,' + + '2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z'; const pathbg = mkElem('path', { d: pickerD, @@ -802,7 +804,11 @@ export default function jQueryPluginJGraduate ($) { } else { const x = -cX * (scaleX - 1); const y = -cY * (scaleY - 1); - curGradient.setAttribute('gradientTransform', rot + 'translate(' + x + ',' + y + ') scale(' + scaleX + ',' + scaleY + ')'); + curGradient.setAttribute( + 'gradientTransform', + rot + 'translate(' + x + ',' + y + ') scale(' + + scaleX + ',' + scaleY + ')' + ); // $('#ang').removeClass('dis'); } } diff --git a/src/editor/jspdf/jspdf.plugin.svgToPdf.js b/src/editor/jspdf/jspdf.plugin.svgToPdf.js index 2ced7391..7f5d245c 100644 --- a/src/editor/jspdf/jspdf.plugin.svgToPdf.js +++ b/src/editor/jspdf/jspdf.plugin.svgToPdf.js @@ -266,7 +266,10 @@ const svgElementToPdf = function (element, pdf, options) { pdf.setLineWidth(k * Number.parseInt(node.getAttribute('stroke-width'))); } const strokeColor = node.getAttribute('stroke'); - if (attributeIsNotEmpty(strokeColor) && node.getAttribute('stroke-width') !== '0' && node.getAttribute('stroke-opacity') !== '0') { + if (attributeIsNotEmpty(strokeColor) && + node.getAttribute('stroke-width') !== '0' && + node.getAttribute('stroke-opacity') !== '0' + ) { const strokeRGB = new RGBColor(strokeColor); if (strokeRGB.ok) { // hasStrokeColor = true; diff --git a/src/editor/svg-editor.js b/src/editor/svg-editor.js index 6a8e330d..b962682e 100644 --- a/src/editor/svg-editor.js +++ b/src/editor/svg-editor.js @@ -476,7 +476,11 @@ editor.loadContentAndPrefs = function () { } else if (window.widget) { defaultPrefs[key] = window.widget.preferenceForKey(storeKey); } else { - const result = document.cookie.match(new RegExp('(?:^|;\\s*)' + Utils.regexEscape(encodeURIComponent(storeKey)) + '=([^;]+)')); + const result = document.cookie.match( + new RegExp('(?:^|;\\s*)' + Utils.regexEscape( + encodeURIComponent(storeKey) + ) + '=([^;]+)') + ); defaultPrefs[key] = result ? decodeURIComponent(result[1]) : ''; } }); @@ -3602,7 +3606,10 @@ editor.init = function () { str = ''; $.each(colorBlocks, function (i, e) { if (e === 'chessboard') { - str += '
'; + str += '
'; } else { str += '
'; } diff --git a/src/editor/svgicons/jQuery.svgIcons.js b/src/editor/svgicons/jQuery.svgIcons.js index deebb388..ffba43fa 100644 --- a/src/editor/svgicons/jQuery.svgIcons.js +++ b/src/editor/svgicons/jQuery.svgIcons.js @@ -294,7 +294,9 @@ export default function jQueryPluginSVGIcons ($) { elems = $(svgdoc.firstChild).children(); // .getElementsByTagName('foreignContent'); if (!opts.no_img) { - const testSrc = dataPre + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D'; + const testSrc = dataPre + + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zd' + + 'mciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D'; testImg = $(new Image()).attr({ src: testSrc, diff --git a/src/external/dynamic-import-polyfill/importModule.js b/src/external/dynamic-import-polyfill/importModule.js index cc7fd1bb..758dee5c 100644 --- a/src/external/dynamic-import-polyfill/importModule.js +++ b/src/external/dynamic-import-polyfill/importModule.js @@ -161,7 +161,11 @@ export function importModule (url, atts = {}, {returnDefault = false} = {}) { script.addEventListener('error', scriptOnError); script.addEventListener('load', scriptOnLoad); const absURL = toAbsoluteURL(url); - const loader = `import * as m from '${absURL.replace(/'/g, "\\'")}'; window.${vector} = ${returnDefault ? 'm.default || ' : ''}m;`; // export Module + const loader = `import * as m from '${ + absURL.replace(/'/g, "\\'") + }'; window.${vector} = ${ + returnDefault ? 'm.default || ' : '' + }m;`; // export Module const blob = new Blob([loader], {type: 'text/javascript'}); script.src = URL.createObjectURL(blob); diff --git a/src/svgcanvas/sanitize.js b/src/svgcanvas/sanitize.js index e915e306..7666d0cb 100644 --- a/src/svgcanvas/sanitize.js +++ b/src/svgcanvas/sanitize.js @@ -151,7 +151,9 @@ export const sanitizeSvg = function (node) { const attrNsURI = attr.namespaceURI; // Check that an attribute with the correct localName in the correct namespace is on // our whitelist or is a namespace declaration for one of our allowed namespaces - if (!({}.hasOwnProperty.call(allowedAttrsNS, attrLocalName) && attrNsURI === allowedAttrsNS[attrLocalName] && attrNsURI !== NS.XMLNS) && + if (!({}.hasOwnProperty.call(allowedAttrsNS, attrLocalName) && + attrNsURI === allowedAttrsNS[attrLocalName] && attrNsURI !== NS.XMLNS + ) && !(attrNsURI === NS.XMLNS && REVERSE_NS[attr.value])) { // TODO(codedread): Programmatically add the se: attributes to the NS-aware whitelist. // Bypassing the whitelist to allow se: prefixes. diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index ec0926eb..d5a60a83 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -156,7 +156,8 @@ const svgdoc = container.ownerDocument; const svgroot = svgdoc.importNode( text2xml( '' + + 'width="' + dimensions[0] + '" height="' + dimensions[1] + + '" x="' + dimensions[0] + '" y="' + dimensions[1] + '" overflow="visible">' + '' + '' + '' + @@ -2433,7 +2434,9 @@ const mouseMove = function (evt) { bSpline = getBsplinePoint(nextParameter); nextPos = bSpline; bSpline = getBsplinePoint(parameter); - sumDistance += Math.sqrt((nextPos.x - bSpline.x) * (nextPos.x - bSpline.x) + (nextPos.y - bSpline.y) * (nextPos.y - bSpline.y)); + sumDistance += Math.sqrt((nextPos.x - bSpline.x) * + (nextPos.x - bSpline.x) + (nextPos.y - bSpline.y) * + (nextPos.y - bSpline.y)); if (sumDistance > THRESHOLD_DIST) { sumDistance -= THRESHOLD_DIST; @@ -3841,7 +3844,8 @@ this.svgToString = function (elem, indent) { */ this.embedImage = function (src) { // Todo: Remove this Promise in favor of making an async/await `Image.load` utility - return new Promise(function (resolve, reject) { // eslint-disable-line promise/avoid-new + // eslint-disable-next-line promise/avoid-new + return new Promise(function (resolve, reject) { // load in the image and once it's loaded, get the dimensions $(new Image()).load(function (response, status, xhr) { if (status === 'error') { @@ -3999,7 +4003,8 @@ this.rasterExport = async function (imgType, quality, exportWindowName, opts = { await canvg(c, svg); // Todo: Make async/await utility in place of `toBlob`, so we can remove this constructor - return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new + // eslint-disable-next-line promise/avoid-new + return new Promise((resolve, reject) => { const dataURLType = type.toLowerCase(); const datauri = quality ? c.toDataURL('image/' + dataURLType, quality) @@ -6148,7 +6153,10 @@ this.convertToPath = function (elem, getBBox) { opacity: curShape.opacity, visibility: 'hidden' }; - return convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory); + return convertToPath( + elem, attrs, addSVGElementFromJson, pathActions, + clearSelection, addToSelection, hstry, addCommandToHistory + ); }; /** @@ -7263,7 +7271,10 @@ this.setBackground = function (color, url) { }); const div = document.createElement('div'); assignAttributes(div, { - style: 'pointer-events:none;width:100%;height:100%;background-image:url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);' + style: 'pointer-events:none;width:100%;height:100%;' + + 'background-image:url(data:image/gif;base64,' + + 'R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+' + + 'gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);' }); bgPattern.appendChild(div); bg.append(bgPattern);