es6 improvements
This commit is contained in:
@@ -291,7 +291,7 @@ export default class ConfigObj {
|
||||
let { source } = this.urldata
|
||||
if (!source) { // urldata.source may have been null if it ended with '='
|
||||
const src = searchParams.get('source')
|
||||
if (src && src.startsWith('data:')) {
|
||||
if (src?.startsWith('data:')) {
|
||||
source = src
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import LayersPanel from './panels/LayersPanel.js'
|
||||
import MainMenu from './MainMenu.js'
|
||||
import { getParentsUntil } from './components/jgraduate/Util.js'
|
||||
|
||||
const { $id, $qa, isNullish, decode64, blankPageObjectURL } = SvgCanvas
|
||||
const { $id, $qa, decode64, blankPageObjectURL } = SvgCanvas
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -487,8 +487,8 @@ class Editor extends EditorStartup {
|
||||
}
|
||||
const isNode = mode === 'pathedit'
|
||||
// if this.elems[1] is present, then we have more than one element
|
||||
this.selectedElement = (elems.length === 1 || isNullish(elems[1]) ? elems[0] : null)
|
||||
this.multiselected = (elems.length >= 2 && !isNullish(elems[1]))
|
||||
this.selectedElement = (elems.length === 1 || !elems[1] ? elems[0] : null)
|
||||
this.multiselected = (elems.length >= 2 && elems[1])
|
||||
if (this.selectedElement && !isNode) {
|
||||
this.topPanel.update()
|
||||
} // if (elem)
|
||||
@@ -520,7 +520,7 @@ class Editor extends EditorStartup {
|
||||
return
|
||||
}
|
||||
|
||||
this.multiselected = (elems.length >= 2 && !isNullish(elems[1]))
|
||||
this.multiselected = (elems.length >= 2 && elems[1])
|
||||
// Only updating fields for single elements for now
|
||||
if (!this.multiselected) {
|
||||
switch (mode) {
|
||||
@@ -552,7 +552,7 @@ class Editor extends EditorStartup {
|
||||
}
|
||||
|
||||
elems.forEach((elem) => {
|
||||
const isSvgElem = (elem && elem.tagName === 'svg')
|
||||
const isSvgElem = (elem?.tagName === 'svg')
|
||||
if (isSvgElem || this.svgCanvas.isLayer(elem)) {
|
||||
this.layersPanel.populateLayers()
|
||||
// if the element changed was the svg, then it could be a resolution change
|
||||
@@ -561,8 +561,7 @@ class Editor extends EditorStartup {
|
||||
}
|
||||
// Update selectedElement if element is no longer part of the image.
|
||||
// This occurs for the text elements in Firefox
|
||||
} else if (elem && this.selectedElement && isNullish(this.selectedElement.parentNode)) {
|
||||
// || elem && elem.tagName == "path" && !multiselected) { // This was added in r1430, but not sure why
|
||||
} else if (elem && !this.selectedElement?.parentNode) {
|
||||
this.selectedElement = elem
|
||||
}
|
||||
})
|
||||
|
||||
@@ -167,7 +167,7 @@ class MainMenu {
|
||||
</head>
|
||||
<body><h1>${loadingImage}</h1></body>
|
||||
<html>`
|
||||
if (typeof URL !== 'undefined' && URL.createObjectURL) {
|
||||
if (URL?.createObjectURL) {
|
||||
const blob = new Blob([popHTML], { type: 'text/html' })
|
||||
popURL = URL.createObjectURL(blob)
|
||||
} else {
|
||||
|
||||
@@ -127,7 +127,7 @@ function setAttrs (elem, attrs) {
|
||||
} else {
|
||||
Object.entries(attrs).forEach(([aname, val]) => {
|
||||
const prop = elem[aname]
|
||||
if (prop && prop.constructor === 'SVGLength') {
|
||||
if (prop?.constructor === 'SVGLength') {
|
||||
prop.baseVal.value = val
|
||||
} else {
|
||||
elem.setAttribute(aname, val)
|
||||
|
||||
@@ -112,19 +112,6 @@ export class SeMenu extends HTMLElement {
|
||||
set src (value) {
|
||||
this.setAttribute('src', value)
|
||||
}
|
||||
/**
|
||||
* @function connectedCallback
|
||||
* @returns {void}
|
||||
*/
|
||||
/* connectedCallback () {
|
||||
this.$menu.addEventListener('openedchange', (e) => {
|
||||
e.preventDefault();
|
||||
const selectedItem = e?.detail?.closeResult;
|
||||
if (selectedItem !== undefined && selectedItem?.id !== undefined) {
|
||||
document.getElementById(selectedItem.id).click();
|
||||
}
|
||||
});
|
||||
} */
|
||||
}
|
||||
|
||||
// Register
|
||||
|
||||
@@ -269,7 +269,7 @@ export default {
|
||||
curMeta = pending[id]
|
||||
let title
|
||||
if (svgStr) {
|
||||
if (curMeta && curMeta.name) {
|
||||
if (curMeta?.name) {
|
||||
title = curMeta.name
|
||||
} else {
|
||||
// Try to find a title
|
||||
@@ -299,7 +299,7 @@ export default {
|
||||
submit.removeAttribute('disabled')
|
||||
}
|
||||
} else {
|
||||
if (curMeta && curMeta.preview_url) {
|
||||
if (curMeta?.preview_url) {
|
||||
title = curMeta.name || ''
|
||||
entry = document.createElement('span')
|
||||
const img = document.createElement('img')
|
||||
|
||||
@@ -421,7 +421,7 @@ export default {
|
||||
let i = selElems.length
|
||||
while (i--) {
|
||||
const elem = selElems[i]
|
||||
if (elem && elem.getAttribute('shape') === 'star') {
|
||||
if (elem?.getAttribute('shape') === 'star') {
|
||||
if (opts.selectedElement && !opts.multiselected) {
|
||||
$id('starNumPoints').value = elem.getAttribute('point')
|
||||
$id('radialShift').value = elem.getAttribute('radialshift')
|
||||
@@ -429,7 +429,7 @@ export default {
|
||||
} else {
|
||||
showPanel(false, 'star')
|
||||
}
|
||||
} else if (elem && elem.getAttribute('shape') === 'regularPoly') {
|
||||
} else if (elem?.getAttribute('shape') === 'regularPoly') {
|
||||
if (opts.selectedElement && !opts.multiselected) {
|
||||
$id('polySides').value = elem.getAttribute('sides')
|
||||
showPanel(true, 'polygon')
|
||||
|
||||
@@ -187,7 +187,7 @@ class TopPanel {
|
||||
? this.editor.configObj.curConfig.baseUnit
|
||||
: null
|
||||
|
||||
const isNode = currentMode === 'pathedit' // elem ? (elem.id && elem.id.startsWith('pathpointgrip')) : false;
|
||||
const isNode = currentMode === 'pathedit'
|
||||
const menuItems = document.getElementById('se-cmenu_canvas')
|
||||
this.hideTool('selected_panel')
|
||||
this.hideTool('multiselected_panel')
|
||||
|
||||
Reference in New Issue
Block a user