enforce a few eslint rules
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* globals $ seConfirm seAlert */
|
||||
import './touch.js';
|
||||
import {convertUnit} from '../common/units.js';
|
||||
import { convertUnit } from '../common/units.js';
|
||||
import {
|
||||
putLocale
|
||||
} from './locale.js';
|
||||
@@ -41,7 +41,7 @@ const readySignal = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const {$id} = SvgCanvas;
|
||||
const { $id } = SvgCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -118,7 +118,7 @@ class EditorStartup {
|
||||
this.layersPanel.init();
|
||||
this.mainMenu.init();
|
||||
|
||||
const {undoMgr} = this.svgCanvas;
|
||||
const { undoMgr } = this.svgCanvas;
|
||||
this.workarea = document.getElementById('workarea');
|
||||
this.canvMenu = document.getElementById('se-cmenu_canvas');
|
||||
this.exportWindow = null;
|
||||
@@ -160,7 +160,7 @@ class EditorStartup {
|
||||
if (!data.output) { // Ignore Chrome
|
||||
return;
|
||||
}
|
||||
const {exportWindowName} = data;
|
||||
const { exportWindowName } = data;
|
||||
if (exportWindowName) {
|
||||
this.exportWindow = window.open('', this.exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class EditorStartup {
|
||||
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
|
||||
* @returns {void}
|
||||
*/
|
||||
function (win, {center, newCtr}) {
|
||||
function (win, { center, newCtr }) {
|
||||
this.updateCanvas(center, newCtr);
|
||||
}.bind(this)
|
||||
);
|
||||
@@ -279,7 +279,7 @@ class EditorStartup {
|
||||
let lastX = null, lastY = null,
|
||||
panning = false, keypan = false;
|
||||
|
||||
$id('svgcanvas').addEventListener('mouseup', function(evt) {
|
||||
$id('svgcanvas').addEventListener('mouseup', function(evt) {
|
||||
if (panning === false) { return true; }
|
||||
|
||||
wArea.scrollLeft -= (evt.clientX - lastX);
|
||||
@@ -290,9 +290,9 @@ class EditorStartup {
|
||||
|
||||
if (evt.type === 'mouseup') { panning = false; }
|
||||
return false;
|
||||
});
|
||||
});
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
$id('svgcanvas').addEventListener('mousemove', function(evt) {
|
||||
$id('svgcanvas').addEventListener('mousemove', function(evt) {
|
||||
if (panning === false) { return true; }
|
||||
|
||||
wArea.scrollLeft -= (evt.clientX - lastX);
|
||||
@@ -322,10 +322,10 @@ class EditorStartup {
|
||||
if (e.target.nodeName !== 'BODY') return;
|
||||
if(e.code.toLowerCase() === 'space'){
|
||||
this.svgCanvas.spaceKey = keypan = true;
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
||||
this.workarea.style.cursor = zoomOutIcon;
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -335,10 +335,10 @@ class EditorStartup {
|
||||
if (e.target.nodeName !== 'BODY') return;
|
||||
if(e.code.toLowerCase() === 'space'){
|
||||
this.svgCanvas.spaceKey = keypan = false;
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
} else if((e.key.toLowerCase() === 'shift') && (this.svgCanvas.getMode() === 'zoom')){
|
||||
this.workarea.style.cursor = zoomInIcon;
|
||||
e.preventDefault();
|
||||
e.preventDefault();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@@ -367,7 +367,7 @@ class EditorStartup {
|
||||
el.addEventListener("focus", (e) => {
|
||||
inp = e.currentTarget;
|
||||
this.uiContext = 'toolbars';
|
||||
this.workarea.addEventListener('mousedown', unfocus);
|
||||
this.workarea.addEventListener('mousedown', unfocus);
|
||||
});
|
||||
el.addEventListener("blur", () => {
|
||||
this.uiContext = 'canvas';
|
||||
@@ -399,12 +399,12 @@ class EditorStartup {
|
||||
);
|
||||
}
|
||||
const winWh = {
|
||||
width: getWidth(),
|
||||
width: getWidth(),
|
||||
height: getHeight()
|
||||
};
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
Object.entries(winWh).forEach(([type, val]) => {
|
||||
Object.entries(winWh).forEach(([ type, val ]) => {
|
||||
const curval = (type === 'width') ? window.innerWidth - 15 : window.innerHeight;
|
||||
this.workarea['scroll' + (type === 'width' ? 'Left' : 'Top')] -= (curval - val) / 2;
|
||||
winWh[type] = curval;
|
||||
@@ -619,14 +619,14 @@ class EditorStartup {
|
||||
editorObj.svgCanvas.alignSelectedElements('m', 'page');
|
||||
editorObj.svgCanvas.alignSelectedElements('c', 'page');
|
||||
// highlight imported element, otherwise we get strange empty selectbox
|
||||
editorObj.svgCanvas.selectOnly([newElement]);
|
||||
editorObj.svgCanvas.selectOnly([ newElement ]);
|
||||
document.getElementById('se-prompt-dialog').setAttribute('close', true);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
} else {
|
||||
// bitmap handling
|
||||
reader = new FileReader();
|
||||
reader.onloadend = function ({target: {result}}) {
|
||||
reader.onloadend = function ({ target: { result } }) {
|
||||
/**
|
||||
* Insert the new image until we know its dimensions.
|
||||
* @param {Float} imageWidth
|
||||
@@ -646,7 +646,7 @@ class EditorStartup {
|
||||
}
|
||||
});
|
||||
editorObj.svgCanvas.setHref(newImage, result);
|
||||
editorObj.svgCanvas.selectOnly([newImage]);
|
||||
editorObj.svgCanvas.selectOnly([ newImage ]);
|
||||
editorObj.svgCanvas.alignSelectedElements('m', 'page');
|
||||
editorObj.svgCanvas.alignSelectedElements('c', 'page');
|
||||
editorObj.topPanelHandlers.updateContextPanel();
|
||||
@@ -715,8 +715,8 @@ class EditorStartup {
|
||||
*/
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
const imported = await import(`./extensions/${encodeURIComponent(extname)}/${encodeURIComponent(extname)}.js`);
|
||||
const {name = extname, init: initfn} = imported.default;
|
||||
return this.addExtension(name, (initfn && initfn.bind(this)), {$, langParam: 'en'}); /** @todo change to current lng */
|
||||
const { name = extname, init: initfn } = imported.default;
|
||||
return this.addExtension(name, (initfn && initfn.bind(this)), { $, langParam: 'en' }); /** @todo change to current lng */
|
||||
} catch (err) {
|
||||
// Todo: Add config to alert any errors
|
||||
console.error('Extension failed to load: ' + extname + '; ', err);
|
||||
@@ -739,8 +739,8 @@ class EditorStartup {
|
||||
*/
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
const imported = await import(encodeURI(extPathName));
|
||||
const {name, init: initfn} = imported.default;
|
||||
return this.addExtension(name, (initfn && initfn.bind(this)), {$});
|
||||
const { name, init: initfn } = imported.default;
|
||||
return this.addExtension(name, (initfn && initfn.bind(this)), { $ });
|
||||
} catch (err) {
|
||||
// Todo: Add config to alert any errors
|
||||
console.error('Extension failed to load: ' + extPathName + '; ', err);
|
||||
@@ -790,9 +790,9 @@ class EditorStartup {
|
||||
* @fires module:svgcanvas.SvgCanvas#event:message
|
||||
* @returns {void}
|
||||
*/
|
||||
messageListener ({data, origin}) {
|
||||
messageListener ({ data, origin }) {
|
||||
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
|
||||
const messageObj = {data, origin};
|
||||
const messageObj = { data, origin };
|
||||
if (!this.extensionsAdded) {
|
||||
this.messageQueue.push(messageObj);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user