enforce a few eslint rules
This commit is contained in:
@@ -26,11 +26,11 @@ export default {
|
||||
async init (S) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor);
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const
|
||||
addElem = svgCanvas.addSVGElementFromJson,
|
||||
{nonce} = S,
|
||||
{ nonce } = S,
|
||||
prefix = 'se_arrow_';
|
||||
|
||||
let selElems, arrowprefix, randomizeIds = S.randomize_ids;
|
||||
@@ -64,8 +64,8 @@ export default {
|
||||
arrowprefix = (randomizeIds) ? `${prefix}${nonce}_` : prefix;
|
||||
|
||||
const pathdata = {
|
||||
fw: {d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', refx: 8, id: arrowprefix + 'fw'},
|
||||
bk: {d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', refx: 2, id: arrowprefix + 'bk'}
|
||||
fw: { d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', refx: 8, id: arrowprefix + 'fw' },
|
||||
bk: { d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', refx: 2, id: arrowprefix + 'bk' }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -214,14 +214,14 @@ export default {
|
||||
*/
|
||||
function colorChanged (elem) {
|
||||
const color = elem.getAttribute('stroke');
|
||||
const mtypes = ['start', 'mid', 'end'];
|
||||
const mtypes = [ 'start', 'mid', 'end' ];
|
||||
const defs = svgCanvas.findDefs();
|
||||
|
||||
mtypes.forEach(function(type){
|
||||
const marker = getLinked(elem, 'marker-' + type);
|
||||
if (!marker) { return; }
|
||||
|
||||
const curColor = marker.children.getAttribute('fill');
|
||||
const curColor = marker.children.getAttribute('fill');
|
||||
const curD = marker.children.getAttribute('d');
|
||||
if (curColor === color) { return; }
|
||||
|
||||
@@ -236,7 +236,7 @@ export default {
|
||||
newMarker = marker;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!newMarker) {
|
||||
// Create a new marker with this color
|
||||
const lastId = marker.id;
|
||||
@@ -290,12 +290,12 @@ export default {
|
||||
}),
|
||||
callback () {
|
||||
$id("arrow_panel").style.display = 'none';
|
||||
|
||||
|
||||
// Set ID so it can be translated in locale file
|
||||
$id('arrow_list option').setAttribute('id', 'connector_no_arrow');
|
||||
},
|
||||
async addLangData ({_lang, importLocale}) {
|
||||
const {langList} = await importLocale();
|
||||
async addLangData ({ _lang, importLocale }) {
|
||||
const { langList } = await importLocale();
|
||||
return {
|
||||
data: langList
|
||||
};
|
||||
@@ -304,7 +304,7 @@ export default {
|
||||
// Use this to update the current selected elements
|
||||
selElems = opts.elems;
|
||||
|
||||
const markerElems = ['line', 'path', 'polyline', 'polygon'];
|
||||
const markerElems = [ 'line', 'path', 'polyline', 'polygon' ];
|
||||
let i = selElems.length;
|
||||
while (i--) {
|
||||
const elem = selElems[i];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: 'Arrows',
|
||||
langList: [
|
||||
{id: 'arrow_none', textContent: 'No arrow'}
|
||||
{ id: 'arrow_none', textContent: 'No arrow' }
|
||||
],
|
||||
contextTools: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: 'Arrows',
|
||||
langList: [
|
||||
{id: 'arrow_none', textContent: 'Sans flèche'}
|
||||
{ id: 'arrow_none', textContent: 'Sans flèche' }
|
||||
],
|
||||
contextTools: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: '箭头',
|
||||
langList: [
|
||||
{id: 'arrow_none', textContent: '无箭头'}
|
||||
{ id: 'arrow_none', textContent: '无箭头' }
|
||||
],
|
||||
contextTools: [
|
||||
{
|
||||
|
||||
@@ -24,10 +24,10 @@ const loadExtensionTranslation = async function (lang) {
|
||||
// The button toggles whether the path is open or closed
|
||||
export default {
|
||||
name: 'closepath',
|
||||
async init ({_importLocale}) {
|
||||
async init ({ _importLocale }) {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
let selElems;
|
||||
const updateButton = function (path) {
|
||||
|
||||
@@ -202,7 +202,7 @@ export default {
|
||||
let addThis;
|
||||
// Grab the ends
|
||||
const parts = [];
|
||||
['start', 'end'].forEach(function (pos, i) {
|
||||
[ 'start', 'end' ].forEach(function (pos, i) {
|
||||
const key = 'c_' + pos;
|
||||
let part = dataStorage.get(ethis, key);
|
||||
if (part === null || part === undefined) { // Does this ever return nullish values?
|
||||
@@ -210,7 +210,7 @@ export default {
|
||||
ethis.attributes['se:connector'].value.split(' ')[i]
|
||||
);
|
||||
dataStorage.put(ethis, 'c_' + pos, part.id);
|
||||
dataStorage.put(ethis, pos + '_bb', svgCanvas.getStrokedBBox([part]));
|
||||
dataStorage.put(ethis, pos + '_bb', svgCanvas.getStrokedBBox([ part ]));
|
||||
} else part = document.getElementById(part);
|
||||
parts.push(part);
|
||||
}, ethis);
|
||||
@@ -233,7 +233,7 @@ export default {
|
||||
continue;
|
||||
}
|
||||
if (elems.includes(cElem) || addThis) {
|
||||
const bb = svgCanvas.getStrokedBBox([cElem]);
|
||||
const bb = svgCanvas.getStrokedBBox([ cElem ]);
|
||||
connections.push({
|
||||
elem: cElem,
|
||||
connector: ethis,
|
||||
@@ -268,7 +268,7 @@ export default {
|
||||
const pre = conn.is_start ? 'start' : 'end';
|
||||
|
||||
// Update bbox for this element
|
||||
const bb = svgCanvas.getStrokedBBox([elem]);
|
||||
const bb = svgCanvas.getStrokedBBox([ elem ]);
|
||||
bb.x = conn.start_x;
|
||||
bb.y = conn.start_y;
|
||||
dataStorage.put(line, pre + '_bb', bb);
|
||||
@@ -338,8 +338,8 @@ export default {
|
||||
if (conn) {
|
||||
curthis.setAttribute('class', 'se_connector');
|
||||
const connData = conn.split(' ');
|
||||
const sbb = svgCanvas.getStrokedBBox([getElem(connData[0])]);
|
||||
const ebb = svgCanvas.getStrokedBBox([getElem(connData[1])]);
|
||||
const sbb = svgCanvas.getStrokedBBox([ getElem(connData[0]) ]);
|
||||
const ebb = svgCanvas.getStrokedBBox([ getElem(connData[1]) ]);
|
||||
dataStorage.put(curthis, 'c_start', connData[0]);
|
||||
dataStorage.put(curthis, 'c_end', connData[1]);
|
||||
dataStorage.put(curthis, 'start_bb', sbb);
|
||||
@@ -393,7 +393,7 @@ export default {
|
||||
startElem = fo ? fo : mouseTarget;
|
||||
|
||||
// Get center of source element
|
||||
const bb = svgCanvas.getStrokedBBox([startElem]);
|
||||
const bb = svgCanvas.getStrokedBBox([ startElem ]);
|
||||
const x = bb.x + bb.width / 2;
|
||||
const y = bb.y + bb.height / 2;
|
||||
|
||||
@@ -453,7 +453,7 @@ export default {
|
||||
// Look for selected connector elements
|
||||
if (elem && dataStorage.has(elem, 'c_start')) {
|
||||
// Remove the "translate" transform given to move
|
||||
svgCanvas.removeFromSelection([elem]);
|
||||
svgCanvas.removeFromSelection([ elem ]);
|
||||
svgCanvas.getTransformList(elem).clear();
|
||||
}
|
||||
}
|
||||
@@ -520,7 +520,7 @@ export default {
|
||||
};
|
||||
}
|
||||
|
||||
const bb = svgCanvas.getStrokedBBox([endElem]);
|
||||
const bb = svgCanvas.getStrokedBBox([ endElem ]);
|
||||
|
||||
const pt = getBBintersect(startX, startY, bb, getOffset('start', curLine));
|
||||
setPoint(curLine, 'end', pt.x, pt.y, true);
|
||||
@@ -531,7 +531,7 @@ export default {
|
||||
curLine.setAttributeNS(seNs, 'se:connector', connStr);
|
||||
curLine.setAttribute('class', 'se_connector');
|
||||
curLine.setAttribute('opacity', 1);
|
||||
svgCanvas.addToSelection([curLine]);
|
||||
svgCanvas.addToSelection([ curLine ]);
|
||||
svgCanvas.moveToBottomSelectedElement();
|
||||
selManager.requestSelector(curLine).showGrips(false);
|
||||
started = false;
|
||||
@@ -618,14 +618,14 @@ export default {
|
||||
elem.remove();
|
||||
svgCanvas.clearSelection();
|
||||
pline.id = id;
|
||||
svgCanvas.addToSelection([pline]);
|
||||
svgCanvas.addToSelection([ pline ]);
|
||||
elem = pline;
|
||||
}
|
||||
}
|
||||
// Update line if it's a connector
|
||||
if (elem.getAttribute('class') === 'se_connector') {
|
||||
const start = getElem(dataStorage.get(elem, 'c_start'));
|
||||
updateConnectors([start]);
|
||||
updateConnectors([ start ]);
|
||||
} else {
|
||||
updateConnectors();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: 'Connector',
|
||||
langList: [
|
||||
{id: 'mode_connect', title: 'Connect two objects'}
|
||||
{ id: 'mode_connect', title: 'Connect two objects' }
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: 'Connector',
|
||||
langList: [
|
||||
{id: 'mode_connect', title: 'Connecter deux objets'}
|
||||
{ id: 'mode_connect', title: 'Connecter deux objets' }
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
name: '连接器',
|
||||
langList: [
|
||||
{id: 'mode_connect', title: '连接两个对象'}
|
||||
{ id: 'mode_connect', title: '连接两个对象' }
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
// enable-eye-dropper if one element is selected
|
||||
let elem = null;
|
||||
if (!opts.multiselected && opts.elems[0] &&
|
||||
!['svg', 'g', 'use'].includes(opts.elems[0].nodeName)
|
||||
![ 'svg', 'g', 'use' ].includes(opts.elems[0].nodeName)
|
||||
) {
|
||||
elem = opts.elems[0];
|
||||
tool.classList.remove('disabled');
|
||||
@@ -94,7 +94,7 @@ export default {
|
||||
if (mode === 'eyedropper') {
|
||||
const e = opts.event;
|
||||
const { target } = e;
|
||||
if (!['svg', 'g', 'use'].includes(target.nodeName)) {
|
||||
if (![ 'svg', 'g', 'use' ].includes(target.nodeName)) {
|
||||
const changes = {};
|
||||
|
||||
const change = function (elem, attrname, newvalue) {
|
||||
|
||||
@@ -24,9 +24,9 @@ export default {
|
||||
name: 'foreignobject',
|
||||
async init (S) {
|
||||
const svgEditor = this;
|
||||
const {text2xml, NS} = S;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { text2xml, NS } = S;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const
|
||||
// {svgcontent} = S,
|
||||
// addElem = svgCanvas.addSVGElementFromJson,
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
if (!fcRules) {
|
||||
fcRules = document.createElement('style');
|
||||
fcRules.setAttribute('id', 'fc_rules');
|
||||
document.getElementsByTagName("head")[0].appendChild(fcRules);
|
||||
document.getElementsByTagName("head")[0].appendChild(fcRules);
|
||||
}
|
||||
fcRules.textContent = !on ? '' : ' #tool_topath { display: none !important; }';
|
||||
$id('foreignObject_panel').style.display = (on) ? 'block' : 'none';
|
||||
@@ -85,11 +85,11 @@ export default {
|
||||
// run it through our sanitizer to remove anything we do not support
|
||||
svgCanvas.sanitizeSvg(newDoc.documentElement);
|
||||
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
|
||||
svgCanvas.call('changed', [elt]);
|
||||
svgCanvas.call('changed', [ elt ]);
|
||||
svgCanvas.clearSelection();
|
||||
} catch (e) {
|
||||
// Todo: Surface error to user
|
||||
console.log(e);
|
||||
console.log(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export default {
|
||||
svgCanvas.call('changed', selElems);
|
||||
}
|
||||
|
||||
const buttons = [{
|
||||
const buttons = [ {
|
||||
id: 'tool_foreign',
|
||||
icon: 'foreignobject-tool.png',
|
||||
type: 'mode',
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
showForeignEditor();
|
||||
}
|
||||
}
|
||||
}];
|
||||
} ];
|
||||
|
||||
const contextTools = [
|
||||
{
|
||||
@@ -279,7 +279,7 @@ export default {
|
||||
height: newFO.getAttribute('height'),
|
||||
};
|
||||
const keep = (attrs.width !== '0' || attrs.height !== '0');
|
||||
svgCanvas.addToSelection([newFO], true);
|
||||
svgCanvas.addToSelection([ newFO ], true);
|
||||
|
||||
return {
|
||||
keep,
|
||||
|
||||
@@ -22,17 +22,17 @@ const loadExtensionTranslation = async function (lang) {
|
||||
|
||||
export default {
|
||||
name: 'grid',
|
||||
async init ({NS, getTypeMap}) {
|
||||
async init ({ NS, getTypeMap }) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const svgdoc = document.getElementById('svgcanvas').ownerDocument;
|
||||
const {assignAttributes} = svgCanvas;
|
||||
const { assignAttributes } = svgCanvas;
|
||||
const hcanvas = document.createElement('canvas');
|
||||
const canvBG = $id('canvasBackground');
|
||||
const units = getTypeMap(); // Assumes prior `init()` call on `units.js` module
|
||||
const intervals = [0.01, 0.1, 1, 10, 100, 1000];
|
||||
const intervals = [ 0.01, 0.1, 1, 10, 100, 1000 ];
|
||||
let showGrid = svgEditor.configObj.curConfig.showGrid || false;
|
||||
|
||||
hcanvas.style.display = 'none';
|
||||
@@ -166,7 +166,7 @@ export default {
|
||||
$id('view_grid').addEventListener("click", () => {
|
||||
svgEditor.configObj.curConfig.showGrid = showGrid = !showGrid;
|
||||
gridUpdate();
|
||||
});
|
||||
});
|
||||
|
||||
if (showGrid) {
|
||||
gridUpdate();
|
||||
|
||||
@@ -28,13 +28,13 @@ const loadExtensionTranslation = async function (lang) {
|
||||
|
||||
export default {
|
||||
name: 'helloworld',
|
||||
async init ({_importLocale}) {
|
||||
async init ({ _importLocale }) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {svgCanvas} = svgEditor;
|
||||
const { svgCanvas } = svgEditor;
|
||||
return {
|
||||
name: strings.name,
|
||||
events: [{
|
||||
events: [ {
|
||||
// Must match the icon ID in helloworld-icon.xml
|
||||
id: 'hello_world',
|
||||
// Tooltip text
|
||||
@@ -45,7 +45,7 @@ export default {
|
||||
// automatically be de-pressed.
|
||||
svgCanvas.setMode('hello_world');
|
||||
}
|
||||
}],
|
||||
} ],
|
||||
// This is triggered when the main mouse button is pressed down
|
||||
// on the editor canvas (not the tool panels)
|
||||
mouseDown () {
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
if (svgCanvas.getMode() === 'hello_world') {
|
||||
// The returned object must include "started" with
|
||||
// a value of true in order for mouseUp to be triggered
|
||||
return {started: true};
|
||||
return { started: true };
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
@@ -70,16 +70,16 @@ export default {
|
||||
const y = opts.mouse_y / zoom;
|
||||
|
||||
// We do our own formatting
|
||||
let {text} = strings;
|
||||
let { text } = strings;
|
||||
[
|
||||
['x', x],
|
||||
['y', y]
|
||||
].forEach(([prop, val]) => {
|
||||
[ 'x', x ],
|
||||
[ 'y', y ]
|
||||
].forEach(([ prop, val ]) => {
|
||||
text = text.replace('{' + prop + '}', val);
|
||||
});
|
||||
|
||||
// Show the text using the custom alert function
|
||||
alert(text);
|
||||
alert(text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
}
|
||||
});
|
||||
svgCanvas.clearSelection();
|
||||
svgCanvas.addToSelection([newImage]);
|
||||
svgCanvas.addToSelection([ newImage ]);
|
||||
svgCanvas.setImageURL(url);
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ export default {
|
||||
* @returns {void}
|
||||
*/
|
||||
async function onMessage({ origin, data: response }) {
|
||||
if (!response || !['string', 'object'].includes(typeof response)) {
|
||||
if (!response || ![ 'string', 'object' ].includes(typeof response)) {
|
||||
// Do nothing
|
||||
return;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ export default {
|
||||
break;
|
||||
case 'm': {
|
||||
// Import multiple
|
||||
multiArr.push([(svgStr ? 'svg' : 'img'), response]);
|
||||
multiArr.push([ (svgStr ? 'svg' : 'img'), response ]);
|
||||
curMeta = pending[id];
|
||||
let title;
|
||||
if (svgStr) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
import {jml, body, nbsp} from 'jamilih';
|
||||
import { jml, body, nbsp } from 'jamilih';
|
||||
import $ from 'query-result';
|
||||
import {manipulation} from 'qr-manipulation';
|
||||
import { manipulation } from 'qr-manipulation';
|
||||
|
||||
manipulation($, jml);
|
||||
|
||||
@@ -20,16 +20,16 @@ async function processResults (url) {
|
||||
* @returns {external:JamilihArray}
|
||||
*/
|
||||
function queryLink (query) {
|
||||
return ['a', {
|
||||
return [ 'a', {
|
||||
href: jsVoid,
|
||||
dataset: {value: query},
|
||||
$on: {click (e) {
|
||||
dataset: { value: query },
|
||||
$on: { click (e) {
|
||||
e.preventDefault();
|
||||
const {value} = this.dataset;
|
||||
const { value } = this.dataset;
|
||||
$('#query')[0].$set(value);
|
||||
$('#openclipart')[0].$submit();
|
||||
}}
|
||||
}, [query]];
|
||||
} }
|
||||
}, [ query ] ];
|
||||
}
|
||||
|
||||
const r = await fetch(url);
|
||||
@@ -38,14 +38,14 @@ async function processResults (url) {
|
||||
|
||||
if (!json || json.msg !== 'success') {
|
||||
// Todo: This could use a generic alert library instead
|
||||
alert('There was a problem downloading the results');
|
||||
alert('There was a problem downloading the results');
|
||||
return;
|
||||
}
|
||||
const {payload, info: {
|
||||
const { payload, info: {
|
||||
results: numResults,
|
||||
pages,
|
||||
current_page: currentPage
|
||||
}} = json;
|
||||
} } = json;
|
||||
|
||||
// $('#page')[0].value = currentPage;
|
||||
// $('#page')[0].max = pages;
|
||||
@@ -60,21 +60,21 @@ async function processResults (url) {
|
||||
// - `svg`'s: `png_thumb`, `png_full_lossy`, `png_2400px`
|
||||
const semiColonSep = '; ' + nbsp;
|
||||
$('#results').jml('div', [
|
||||
['span', [
|
||||
[ 'span', [
|
||||
'Number of results: ',
|
||||
numResults
|
||||
]],
|
||||
] ],
|
||||
semiColonSep,
|
||||
['span', [
|
||||
[ 'span', [
|
||||
'page ',
|
||||
currentPage,
|
||||
' out of ',
|
||||
pages
|
||||
]],
|
||||
] ],
|
||||
...payload.map(({
|
||||
title, description, id,
|
||||
uploader, created,
|
||||
svg: {url: svgURL},
|
||||
svg: { url: svgURL },
|
||||
detail_link: detailLink,
|
||||
tags_array: tagsArray,
|
||||
downloaded_by: downloadedBy,
|
||||
@@ -82,11 +82,11 @@ async function processResults (url) {
|
||||
}) => {
|
||||
const imgHW = '100px';
|
||||
const colonSep = ': ' + nbsp;
|
||||
return ['div', [
|
||||
['button', {style: 'margin-right: 8px; border: 2px solid black;', dataset: {id, value: svgURL}, $on: {
|
||||
return [ 'div', [
|
||||
[ 'button', { style: 'margin-right: 8px; border: 2px solid black;', dataset: { id, value: svgURL }, $on: {
|
||||
async click (e) {
|
||||
e.preventDefault();
|
||||
const {value: svgurl} = this.dataset;
|
||||
const { value: svgurl } = this.dataset;
|
||||
// console.log('this', id, svgurl);
|
||||
const post = (message) => {
|
||||
// Todo: Make origin customizable as set by opening window
|
||||
@@ -109,73 +109,73 @@ async function processResults (url) {
|
||||
data: svg
|
||||
});
|
||||
}
|
||||
}}, [
|
||||
} }, [
|
||||
// If we wanted interactive versions despite security risk:
|
||||
// ['object', {data: svgURL, type: 'image/svg+xml'}]
|
||||
['img', {src: svgURL, style: `width: ${imgHW}; height: ${imgHW};`}]
|
||||
]],
|
||||
['b', [title]],
|
||||
[ 'img', { src: svgURL, style: `width: ${imgHW}; height: ${imgHW};` } ]
|
||||
] ],
|
||||
[ 'b', [ title ] ],
|
||||
' ',
|
||||
['i', [description]],
|
||||
[ 'i', [ description ] ],
|
||||
' ',
|
||||
['span', [
|
||||
[ 'span', [
|
||||
'(ID: ',
|
||||
['a', {
|
||||
[ 'a', {
|
||||
href: jsVoid,
|
||||
dataset: {value: id},
|
||||
dataset: { value: id },
|
||||
$on: {
|
||||
click (e) {
|
||||
e.preventDefault();
|
||||
const {value} = this.dataset;
|
||||
const { value } = this.dataset;
|
||||
$('#byids')[0].$set(value);
|
||||
$('#openclipart')[0].$submit();
|
||||
}
|
||||
}
|
||||
}, [id]],
|
||||
}, [ id ] ],
|
||||
')'
|
||||
]],
|
||||
] ],
|
||||
' ',
|
||||
['i', [
|
||||
['a', {
|
||||
[ 'i', [
|
||||
[ 'a', {
|
||||
href: detailLink,
|
||||
target: '_blank'
|
||||
}, ['Details']]
|
||||
]],
|
||||
['br'],
|
||||
['span', [
|
||||
['u', ['Uploaded by']], colonSep,
|
||||
}, [ 'Details' ] ]
|
||||
] ],
|
||||
[ 'br' ],
|
||||
[ 'span', [
|
||||
[ 'u', [ 'Uploaded by' ] ], colonSep,
|
||||
queryLink(uploader),
|
||||
semiColonSep
|
||||
]],
|
||||
['span', [
|
||||
['u', ['Download count']], colonSep,
|
||||
] ],
|
||||
[ 'span', [
|
||||
[ 'u', [ 'Download count' ] ], colonSep,
|
||||
downloadedBy,
|
||||
semiColonSep
|
||||
]],
|
||||
['span', [
|
||||
['u', ['Times used as favorite']], colonSep,
|
||||
] ],
|
||||
[ 'span', [
|
||||
[ 'u', [ 'Times used as favorite' ] ], colonSep,
|
||||
totalFavorites,
|
||||
semiColonSep
|
||||
]],
|
||||
['span', [
|
||||
['u', ['Created date']], colonSep,
|
||||
] ],
|
||||
[ 'span', [
|
||||
[ 'u', [ 'Created date' ] ], colonSep,
|
||||
created
|
||||
]],
|
||||
['br'],
|
||||
['u', ['Tags']], colonSep,
|
||||
] ],
|
||||
[ 'br' ],
|
||||
[ 'u', [ 'Tags' ] ], colonSep,
|
||||
...tagsArray.map((tag) => {
|
||||
return ['span', [
|
||||
return [ 'span', [
|
||||
' ',
|
||||
queryLink(tag)
|
||||
]];
|
||||
] ];
|
||||
})
|
||||
]];
|
||||
] ];
|
||||
}),
|
||||
['br'], ['br'],
|
||||
[ 'br' ], [ 'br' ],
|
||||
(currentPage === 1 || pages <= 2
|
||||
? ''
|
||||
: ['span', [
|
||||
['a', {
|
||||
: [ 'span', [
|
||||
[ 'a', {
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click (e) {
|
||||
@@ -184,14 +184,14 @@ async function processResults (url) {
|
||||
$('#openclipart')[0].$submit();
|
||||
}
|
||||
}
|
||||
}, ['First']],
|
||||
}, [ 'First' ] ],
|
||||
' '
|
||||
]]
|
||||
] ]
|
||||
),
|
||||
(currentPage === 1
|
||||
? ''
|
||||
: ['span', [
|
||||
['a', {
|
||||
: [ 'span', [
|
||||
[ 'a', {
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click (e) {
|
||||
@@ -200,14 +200,14 @@ async function processResults (url) {
|
||||
$('#openclipart')[0].$submit();
|
||||
}
|
||||
}
|
||||
}, ['Prev']],
|
||||
}, [ 'Prev' ] ],
|
||||
' '
|
||||
]]
|
||||
] ]
|
||||
),
|
||||
(currentPage === pages
|
||||
? ''
|
||||
: ['span', [
|
||||
['a', {
|
||||
: [ 'span', [
|
||||
[ 'a', {
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click (e) {
|
||||
@@ -216,14 +216,14 @@ async function processResults (url) {
|
||||
$('#openclipart')[0].$submit();
|
||||
}
|
||||
}
|
||||
}, ['Next']],
|
||||
}, [ 'Next' ] ],
|
||||
' '
|
||||
]]
|
||||
] ]
|
||||
),
|
||||
(currentPage === pages || pages <= 2
|
||||
? ''
|
||||
: ['span', [
|
||||
['a', {
|
||||
: [ 'span', [
|
||||
[ 'a', {
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click (e) {
|
||||
@@ -232,20 +232,20 @@ async function processResults (url) {
|
||||
$('#openclipart')[0].$submit();
|
||||
}
|
||||
}
|
||||
}, ['Last']],
|
||||
}, [ 'Last' ] ],
|
||||
' '
|
||||
]]
|
||||
] ]
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
jml('div', [
|
||||
['style', [
|
||||
[ 'style', [
|
||||
`.control {
|
||||
padding-top: 10px;
|
||||
}`
|
||||
]],
|
||||
['form', {
|
||||
] ],
|
||||
[ 'form', {
|
||||
id: 'openclipart',
|
||||
$custom: {
|
||||
async $submit () {
|
||||
@@ -253,7 +253,7 @@ jml('div', [
|
||||
[
|
||||
'query', 'sort', 'amount', 'page', 'byids'
|
||||
].forEach((prop) => {
|
||||
const {value} = $('#' + prop)[0];
|
||||
const { value } = $('#' + prop)[0];
|
||||
if (value) {
|
||||
url.searchParams.set(prop, value);
|
||||
}
|
||||
@@ -269,12 +269,12 @@ jml('div', [
|
||||
}
|
||||
}, [
|
||||
// Todo: i18nize
|
||||
['fieldset', [
|
||||
['legend', ['Search terms']],
|
||||
['div', {class: 'control'}, [
|
||||
['label', [
|
||||
[ 'fieldset', [
|
||||
[ 'legend', [ 'Search terms' ] ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'label', [
|
||||
'Query (Title, description, uploader, or tag): ',
|
||||
['input', {id: 'query', name: 'query', placeholder: 'cat', $custom: {
|
||||
[ 'input', { id: 'query', name: 'query', placeholder: 'cat', $custom: {
|
||||
$set (value) {
|
||||
$('#byids')[0].value = '';
|
||||
this.value = value;
|
||||
@@ -283,16 +283,16 @@ jml('div', [
|
||||
change () {
|
||||
$('#byids')[0].value = '';
|
||||
}
|
||||
}}]
|
||||
]]
|
||||
]],
|
||||
['br'],
|
||||
} } ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'br' ],
|
||||
' OR ',
|
||||
['br'],
|
||||
['div', {class: 'control'}, [
|
||||
['label', [
|
||||
[ 'br' ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'label', [
|
||||
'IDs (single or comma-separated): ',
|
||||
['input', {id: 'byids', name: 'ids', placeholder: '271380, 265741', $custom: {
|
||||
[ 'input', { id: 'byids', name: 'ids', placeholder: '271380, 265741', $custom: {
|
||||
$set (value) {
|
||||
$('#query')[0].value = '';
|
||||
this.value = value;
|
||||
@@ -301,47 +301,47 @@ jml('div', [
|
||||
change () {
|
||||
$('#query')[0].value = '';
|
||||
}
|
||||
}}]
|
||||
]]
|
||||
]]
|
||||
]],
|
||||
['fieldset', [
|
||||
['legend', ['Configuring results']],
|
||||
['div', {class: 'control'}, [
|
||||
['label', [
|
||||
} } ]
|
||||
] ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'fieldset', [
|
||||
[ 'legend', [ 'Configuring results' ] ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'label', [
|
||||
'Sort by: ',
|
||||
['select', {id: 'sort'}, [
|
||||
[ 'select', { id: 'sort' }, [
|
||||
// Todo: i18nize first values
|
||||
['Date', 'date'],
|
||||
['Downloads', 'downloads'],
|
||||
['Favorited', 'favorites']
|
||||
].map(([text, value = text]) => {
|
||||
return ['option', {value}, [text]];
|
||||
})]
|
||||
]]
|
||||
]],
|
||||
['div', {class: 'control'}, [
|
||||
['label', [
|
||||
[ 'Date', 'date' ],
|
||||
[ 'Downloads', 'downloads' ],
|
||||
[ 'Favorited', 'favorites' ]
|
||||
].map(([ text, value = text ]) => {
|
||||
return [ 'option', { value }, [ text ] ];
|
||||
}) ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'label', [
|
||||
'Results per page: ',
|
||||
['input', {
|
||||
[ 'input', {
|
||||
id: 'amount', name: 'amount', value: 10,
|
||||
type: 'number', min: 1, max: 200, step: 1, pattern: '\\d+'}]
|
||||
]]
|
||||
]],
|
||||
['div', {class: 'control'}, [
|
||||
['label', [
|
||||
type: 'number', min: 1, max: 200, step: 1, pattern: '\\d+' } ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'label', [
|
||||
'Page number: ',
|
||||
['input', {
|
||||
[ 'input', {
|
||||
// max: 1, // We'll change this based on available results
|
||||
id: 'page', name: 'page', value: 1, style: 'width: 40px;',
|
||||
type: 'number', min: 1, step: 1, pattern: '\\d+'
|
||||
}]
|
||||
]]
|
||||
]]
|
||||
]],
|
||||
['div', {class: 'control'}, [
|
||||
['input', {type: 'submit'}]
|
||||
]]
|
||||
]],
|
||||
['div', {id: 'results'}]
|
||||
} ]
|
||||
] ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'div', { class: 'control' }, [
|
||||
[ 'input', { type: 'submit' } ]
|
||||
] ]
|
||||
] ],
|
||||
[ 'div', { id: 'results' } ]
|
||||
], body);
|
||||
|
||||
@@ -47,12 +47,12 @@ export default {
|
||||
async init (S) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {$} = S;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { $ } = S;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const // {svgcontent} = S,
|
||||
addElem = svgCanvas.addSVGElementFromJson;
|
||||
const mtypes = ['start', 'mid', 'end'];
|
||||
const mtypes = [ 'start', 'mid', 'end' ];
|
||||
const markerPrefix = 'se_marker_';
|
||||
const idPrefix = 'mkr_';
|
||||
|
||||
@@ -64,35 +64,35 @@ export default {
|
||||
const markerTypes = {
|
||||
nomarker: {},
|
||||
leftarrow:
|
||||
{element: 'path', attr: {d: 'M0,50 L100,90 L70,50 L100,10 Z'}},
|
||||
{ element: 'path', attr: { d: 'M0,50 L100,90 L70,50 L100,10 Z' } },
|
||||
rightarrow:
|
||||
{element: 'path', attr: {d: 'M100,50 L0,90 L30,50 L0,10 Z'}},
|
||||
{ element: 'path', attr: { d: 'M100,50 L0,90 L30,50 L0,10 Z' } },
|
||||
textmarker:
|
||||
{element: 'text', attr: {
|
||||
{ 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'}},
|
||||
{ element: 'path', attr: { d: 'M30,100 L70,0' } },
|
||||
reverseslash:
|
||||
{element: 'path', attr: {d: 'M30,0 L70,100'}},
|
||||
{ element: 'path', attr: { d: 'M30,0 L70,100' } },
|
||||
verticalslash:
|
||||
{element: 'path', attr: {d: 'M50,0 L50,100'}},
|
||||
{ element: 'path', attr: { d: 'M50,0 L50,100' } },
|
||||
box:
|
||||
{element: 'path', attr: {d: 'M20,20 L20,80 L80,80 L80,20 Z'}},
|
||||
{ element: 'path', attr: { d: 'M20,20 L20,80 L80,80 L80,20 Z' } },
|
||||
star:
|
||||
{element: 'path', attr: {d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z'}},
|
||||
{ element: 'path', attr: { d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z' } },
|
||||
xmark:
|
||||
{element: 'path', attr: {d: 'M20,80 L80,20 M80,80 L20,20'}},
|
||||
{ element: 'path', attr: { d: 'M20,80 L80,20 M80,80 L20,20' } },
|
||||
triangle:
|
||||
{element: 'path', attr: {d: 'M10,80 L50,20 L80,80 Z'}},
|
||||
{ element: 'path', attr: { d: 'M10,80 L50,20 L80,80 Z' } },
|
||||
mcircle:
|
||||
{element: 'circle', attr: {r: 30, cx: 50, cy: 50}}
|
||||
{ element: 'circle', attr: { r: 30, cx: 50, cy: 50 } }
|
||||
};
|
||||
|
||||
// duplicate shapes to support unfilled (open) marker types with an _o suffix
|
||||
['leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle'].forEach((v) => {
|
||||
[ 'leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle' ].forEach((v) => {
|
||||
markerTypes[v + '_o'] = markerTypes[v];
|
||||
});
|
||||
|
||||
@@ -288,7 +288,7 @@ export default {
|
||||
const x2 = Number(elem.getAttribute('x2'));
|
||||
const y1 = Number(elem.getAttribute('y1'));
|
||||
const y2 = Number(elem.getAttribute('y2'));
|
||||
const {id} = elem;
|
||||
const { id } = elem;
|
||||
|
||||
const midPt = (' ' + ((x1 + x2) / 2) + ',' + ((y1 + y2) / 2) + ' ');
|
||||
const pline = addElem({
|
||||
@@ -315,7 +315,7 @@ export default {
|
||||
elem.remove();
|
||||
svgCanvas.clearSelection();
|
||||
pline.id = id;
|
||||
svgCanvas.addToSelection([pline]);
|
||||
svgCanvas.addToSelection([ pline ]);
|
||||
S.addCommandToHistory(batchCmd);
|
||||
return pline;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ export default {
|
||||
* @returns {void}
|
||||
*/
|
||||
function setMarker () {
|
||||
const poslist = {start_marker: 'start', mid_marker: 'mid', end_marker: 'end'};
|
||||
const poslist = { start_marker: 'start', mid_marker: 'mid', end_marker: 'end' };
|
||||
const pos = poslist[this.id];
|
||||
const markerName = 'marker-' + pos;
|
||||
const el = selElems[0];
|
||||
@@ -471,7 +471,7 @@ export default {
|
||||
* @returns {string}
|
||||
*/
|
||||
function getTitle (id) {
|
||||
const {langList} = strings;
|
||||
const { langList } = strings;
|
||||
const item = langList.find((itm) => {
|
||||
return itm.id === id;
|
||||
});
|
||||
@@ -519,7 +519,7 @@ export default {
|
||||
icon: id + '.svg',
|
||||
title,
|
||||
type: 'context',
|
||||
events: {click: setArrowFromButton},
|
||||
events: { click: setArrowFromButton },
|
||||
panel: 'marker_panel',
|
||||
list: listname,
|
||||
isDefault: def
|
||||
@@ -536,38 +536,38 @@ export default {
|
||||
panel: 'marker_panel',
|
||||
id: 'start_marker',
|
||||
size: 3,
|
||||
events: {change: setMarker}
|
||||
events: { change: setMarker }
|
||||
}, {
|
||||
type: 'button-select',
|
||||
panel: 'marker_panel',
|
||||
id: 'start_marker_list',
|
||||
colnum: 3,
|
||||
events: {change: setArrowFromButton}
|
||||
events: { change: setArrowFromButton }
|
||||
}, {
|
||||
type: 'input',
|
||||
panel: 'marker_panel',
|
||||
id: 'mid_marker',
|
||||
defval: '',
|
||||
size: 3,
|
||||
events: {change: setMarker}
|
||||
events: { change: setMarker }
|
||||
}, {
|
||||
type: 'button-select',
|
||||
panel: 'marker_panel',
|
||||
id: 'mid_marker_list',
|
||||
colnum: 3,
|
||||
events: {change: setArrowFromButton}
|
||||
events: { change: setArrowFromButton }
|
||||
}, {
|
||||
type: 'input',
|
||||
panel: 'marker_panel',
|
||||
id: 'end_marker',
|
||||
size: 3,
|
||||
events: {change: setMarker}
|
||||
events: { change: setMarker }
|
||||
}, {
|
||||
type: 'button-select',
|
||||
panel: 'marker_panel',
|
||||
id: 'end_marker_list',
|
||||
colnum: 3,
|
||||
events: {change: setArrowFromButton}
|
||||
events: { change: setArrowFromButton }
|
||||
}
|
||||
];
|
||||
|
||||
@@ -580,15 +580,15 @@ export default {
|
||||
$id("marker_panel").style.display = 'none';
|
||||
}
|
||||
},
|
||||
/* async */ addLangData ({_importLocale, _lang}) {
|
||||
return {data: strings.langList};
|
||||
/* async */ addLangData ({ _importLocale, _lang }) {
|
||||
return { data: strings.langList };
|
||||
},
|
||||
selectedChanged (opts) {
|
||||
// Use this to update the current selected elements
|
||||
// console.log('selectChanged',opts);
|
||||
selElems = opts.elems;
|
||||
|
||||
const markerElems = ['line', 'path', 'polyline', 'polygon'];
|
||||
const markerElems = [ 'line', 'path', 'polyline', 'polygon' ];
|
||||
|
||||
let i = selElems.length;
|
||||
while (i--) {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
export default {
|
||||
name: 'Markers',
|
||||
langList: [
|
||||
{id: 'nomarker', title: 'No Marker'},
|
||||
{id: 'leftarrow', title: 'Left Arrow'},
|
||||
{id: 'rightarrow', title: 'Right Arrow'},
|
||||
{id: 'textmarker', title: 'Text Marker'},
|
||||
{id: 'forwardslash', title: 'Forward Slash'},
|
||||
{id: 'reverseslash', title: 'Reverse Slash'},
|
||||
{id: 'verticalslash', title: 'Vertical Slash'},
|
||||
{id: 'box', title: 'Box'},
|
||||
{id: 'star', title: 'Star'},
|
||||
{id: 'xmark', title: 'X'},
|
||||
{id: 'triangle', title: 'Triangle'},
|
||||
{id: 'mcircle', title: 'Circle'},
|
||||
{id: 'leftarrow_o', title: 'Open Left Arrow'},
|
||||
{id: 'rightarrow_o', title: 'Open Right Arrow'},
|
||||
{id: 'box_o', title: 'Open Box'},
|
||||
{id: 'star_o', title: 'Open Star'},
|
||||
{id: 'triangle_o', title: 'Open Triangle'},
|
||||
{id: 'mcircle_o', title: 'Open Circle'}
|
||||
{ id: 'nomarker', title: 'No Marker' },
|
||||
{ id: 'leftarrow', title: 'Left Arrow' },
|
||||
{ id: 'rightarrow', title: 'Right Arrow' },
|
||||
{ id: 'textmarker', title: 'Text Marker' },
|
||||
{ id: 'forwardslash', title: 'Forward Slash' },
|
||||
{ id: 'reverseslash', title: 'Reverse Slash' },
|
||||
{ id: 'verticalslash', title: 'Vertical Slash' },
|
||||
{ id: 'box', title: 'Box' },
|
||||
{ id: 'star', title: 'Star' },
|
||||
{ id: 'xmark', title: 'X' },
|
||||
{ id: 'triangle', title: 'Triangle' },
|
||||
{ id: 'mcircle', title: 'Circle' },
|
||||
{ id: 'leftarrow_o', title: 'Open Left Arrow' },
|
||||
{ id: 'rightarrow_o', title: 'Open Right Arrow' },
|
||||
{ id: 'box_o', title: 'Open Box' },
|
||||
{ id: 'star_o', title: 'Open Star' },
|
||||
{ id: 'triangle_o', title: 'Open Triangle' },
|
||||
{ id: 'mcircle_o', title: 'Open Circle' }
|
||||
],
|
||||
contextTools: [
|
||||
{
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
export default {
|
||||
name: '标记',
|
||||
langList: [
|
||||
{id: 'nomarker', title: '无标记'},
|
||||
{id: 'leftarrow', title: '左箭头'},
|
||||
{id: 'rightarrow', title: '右箭头'},
|
||||
{id: 'textmarker', title: '文本'},
|
||||
{id: 'forwardslash', title: '斜杠'},
|
||||
{id: 'reverseslash', title: '反斜杠'},
|
||||
{id: 'verticalslash', title: '垂直线'},
|
||||
{id: 'box', title: '方块'},
|
||||
{id: 'star', title: '星形'},
|
||||
{id: 'xmark', title: 'X'},
|
||||
{id: 'triangle', title: '三角形'},
|
||||
{id: 'mcircle', title: '圆形'},
|
||||
{id: 'leftarrow_o', title: '左箭头(空心)'},
|
||||
{id: 'rightarrow_o', title: '右箭头(空心)'},
|
||||
{id: 'box_o', title: '方块(空心)'},
|
||||
{id: 'star_o', title: '星形(空心)'},
|
||||
{id: 'triangle_o', title: '三角形(空心)'},
|
||||
{id: 'mcircle_o', title: '圆形(空心)'}
|
||||
{ id: 'nomarker', title: '无标记' },
|
||||
{ id: 'leftarrow', title: '左箭头' },
|
||||
{ id: 'rightarrow', title: '右箭头' },
|
||||
{ id: 'textmarker', title: '文本' },
|
||||
{ id: 'forwardslash', title: '斜杠' },
|
||||
{ id: 'reverseslash', title: '反斜杠' },
|
||||
{ id: 'verticalslash', title: '垂直线' },
|
||||
{ id: 'box', title: '方块' },
|
||||
{ id: 'star', title: '星形' },
|
||||
{ id: 'xmark', title: 'X' },
|
||||
{ id: 'triangle', title: '三角形' },
|
||||
{ id: 'mcircle', title: '圆形' },
|
||||
{ id: 'leftarrow_o', title: '左箭头(空心)' },
|
||||
{ id: 'rightarrow_o', title: '右箭头(空心)' },
|
||||
{ id: 'box_o', title: '方块(空心)' },
|
||||
{ id: 'star_o', title: '星形(空心)' },
|
||||
{ id: 'triangle_o', title: '三角形(空心)' },
|
||||
{ id: 'mcircle_o', title: '圆形(空心)' }
|
||||
],
|
||||
contextTools: [
|
||||
{
|
||||
|
||||
@@ -23,11 +23,11 @@ const loadExtensionTranslation = async function (lang) {
|
||||
|
||||
export default {
|
||||
name: 'mathjax',
|
||||
async init ({$}) {
|
||||
async init ({ $ }) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
|
||||
// Configuration of the MathJax extention.
|
||||
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
// mathjaxSrc = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
|
||||
// Had been on https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG.js
|
||||
// Obtained Text-AMS-MML_SVG.js from https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/config/TeX-AMS-MML_SVG.js
|
||||
{uiStrings} = svgEditor;
|
||||
{ uiStrings } = svgEditor;
|
||||
let
|
||||
math,
|
||||
locationX,
|
||||
@@ -86,7 +86,7 @@ export default {
|
||||
const code = $id('mathjax_code_textarea').value;
|
||||
// displaystyle to force MathJax NOT to use the inline style. Because it is
|
||||
// less fancy!
|
||||
MathJax.Hub.queue.Push(['Text', math, '\\displaystyle{' + code + '}']);
|
||||
MathJax.Hub.queue.Push([ 'Text', math, '\\displaystyle{' + code + '}' ]);
|
||||
|
||||
/*
|
||||
* The MathJax library doesn't want to bloat your webpage so it creates
|
||||
@@ -134,7 +134,7 @@ export default {
|
||||
);
|
||||
}
|
||||
|
||||
const buttons = [{
|
||||
const buttons = [ {
|
||||
id: 'tool_mathjax',
|
||||
type: 'mode',
|
||||
icon: 'mathjax.png',
|
||||
@@ -167,7 +167,7 @@ export default {
|
||||
'</span></label>' +
|
||||
'<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' +
|
||||
'</fieldset>' +
|
||||
'</div>';
|
||||
'</div>';
|
||||
$id('svg_prefs').parentNode.insertBefore(div, $id('svg_prefs').nextSibling);
|
||||
div.style.display = 'none';
|
||||
// Add functionality and picture to cancel button.
|
||||
@@ -191,19 +191,19 @@ export default {
|
||||
// When MathJax is loaded get the div where the math will be rendered.
|
||||
MathJax.Hub.queue.Push(function () {
|
||||
math = MathJax.Hub.getAllJax('#mathjax_creator')[0];
|
||||
console.log(math);
|
||||
console.log(math);
|
||||
mathjaxLoaded = true;
|
||||
console.log('MathJax Loaded');
|
||||
console.log('MathJax Loaded');
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('Failed loading MathJax.');
|
||||
console.log('Failed loading MathJax.');
|
||||
// eslint-disable-next-line no-alert
|
||||
alert('Failed loading MathJax. You will not be able to change the mathematics.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
} ];
|
||||
|
||||
return {
|
||||
name: strings.name,
|
||||
@@ -214,7 +214,7 @@ export default {
|
||||
|
||||
mouseDown () {
|
||||
if (svgCanvas.getMode() === 'mathjax') {
|
||||
return {started: true};
|
||||
return { started: true };
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
@@ -227,7 +227,7 @@ export default {
|
||||
locationY = opts.mouse_y / zoom;
|
||||
|
||||
$id("mathjax").style.display = 'block';
|
||||
return {started: false}; // Otherwise the last selected object dissapears.
|
||||
return { started: false }; // Otherwise the last selected object dissapears.
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
export default {
|
||||
name: 'opensave',
|
||||
init ({encode64}) {
|
||||
init ({ encode64 }) {
|
||||
const svgEditor = this;
|
||||
|
||||
svgEditor.setCustomHandlers({
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
const done = this.configObj.pref('save_notice_done');
|
||||
|
||||
if (done !== 'all') {
|
||||
const note = svgEditor.i18next.t('notification.saveFromBrowser', { type: 'SVG'});
|
||||
const note = svgEditor.i18next.t('notification.saveFromBrowser', { type: 'SVG' });
|
||||
|
||||
this.configObj.pref('save_notice_done', 'all');
|
||||
if (done !== 'part') {
|
||||
|
||||
@@ -11,9 +11,9 @@ import { dragmove } from '../../../editor/dragmove/dragmove.js';
|
||||
|
||||
export default {
|
||||
name: 'overview_window',
|
||||
init ({_$, isChrome}) {
|
||||
init ({ _$, isChrome }) {
|
||||
const svgEditor = this;
|
||||
const {$id} = svgEditor.svgCanvas;
|
||||
const { $id } = svgEditor.svgCanvas;
|
||||
const overviewWindowGlobals = {};
|
||||
// Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and
|
||||
// https://code.google.com/p/chromium/issues/detail?id=565120.
|
||||
|
||||
@@ -23,8 +23,8 @@ export default {
|
||||
name: 'placemark',
|
||||
async init (_S) {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const addElem = svgCanvas.addSVGElementFromJson;
|
||||
let
|
||||
selElems,
|
||||
@@ -40,29 +40,29 @@ export default {
|
||||
const markerTypes = {
|
||||
nomarker: {},
|
||||
forwardslash:
|
||||
{element: 'path', attr: {d: 'M30,100 L70,0'}},
|
||||
{ element: 'path', attr: { d: 'M30,100 L70,0' } },
|
||||
reverseslash:
|
||||
{element: 'path', attr: {d: 'M30,0 L70,100'}},
|
||||
{ element: 'path', attr: { d: 'M30,0 L70,100' } },
|
||||
verticalslash:
|
||||
{element: 'path', attr: {d: 'M50,0 L50,100'}},
|
||||
{ element: 'path', attr: { d: 'M50,0 L50,100' } },
|
||||
xmark:
|
||||
{element: 'path', attr: {d: 'M20,80 L80,20 M80,80 L20,20'}},
|
||||
{ element: 'path', attr: { d: 'M20,80 L80,20 M80,80 L20,20' } },
|
||||
leftarrow:
|
||||
{element: 'path', attr: {d: 'M0,50 L100,90 L70,50 L100,10 Z'}},
|
||||
{ element: 'path', attr: { d: 'M0,50 L100,90 L70,50 L100,10 Z' } },
|
||||
rightarrow:
|
||||
{element: 'path', attr: {d: 'M100,50 L0,90 L30,50 L0,10 Z'}},
|
||||
{ element: 'path', attr: { d: 'M100,50 L0,90 L30,50 L0,10 Z' } },
|
||||
box:
|
||||
{element: 'path', attr: {d: 'M20,20 L20,80 L80,80 L80,20 Z'}},
|
||||
{ element: 'path', attr: { d: 'M20,20 L20,80 L80,80 L80,20 Z' } },
|
||||
star:
|
||||
{element: 'path', attr: {d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z'}},
|
||||
{ element: 'path', attr: { d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z' } },
|
||||
mcircle:
|
||||
{element: 'circle', attr: {r: 30, cx: 50, cy: 50}},
|
||||
{ element: 'circle', attr: { r: 30, cx: 50, cy: 50 } },
|
||||
triangle:
|
||||
{element: 'path', attr: {d: 'M10,80 L50,20 L80,80 Z'}}
|
||||
{ element: 'path', attr: { d: 'M10,80 L50,20 L80,80 Z' } }
|
||||
};
|
||||
|
||||
// duplicate shapes to support unfilled (open) marker types with an _o suffix
|
||||
['leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle'].forEach((v) => {
|
||||
[ 'leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle' ].forEach((v) => {
|
||||
markerTypes[v + '_o'] = markerTypes[v];
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ export default {
|
||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||
var elements = elem.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [, , type, n] = i.id.split('_');
|
||||
const [ , , type, n ] = i.id.split('_');
|
||||
if (type === 'txt') {
|
||||
txt.textContent = items[n];
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export default {
|
||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||
var elements = elem.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [, , type] = i.id.split('_');
|
||||
const [ , , type ] = i.id.split('_');
|
||||
if (type === 'txt') {
|
||||
i.style.cssText = 'font-family:' + font + ';font-size:'+fontSize+';';
|
||||
}
|
||||
@@ -204,14 +204,14 @@ export default {
|
||||
if (marker) { marker.remove(); }
|
||||
el.removeAttribute(markerName);
|
||||
if (val === 'nomarker') {
|
||||
svgCanvas.call('changed', [el]);
|
||||
svgCanvas.call('changed', [ el ]);
|
||||
return;
|
||||
}
|
||||
// Set marker on element
|
||||
const id = 'placemark_marker_' + el.id;
|
||||
addMarker(id, val);
|
||||
el.setAttribute(markerName, 'url(#' + id + ')');
|
||||
svgCanvas.call('changed', [el]);
|
||||
svgCanvas.call('changed', [ el ]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ export default {
|
||||
* @returns {string}
|
||||
*/
|
||||
function getTitle (id) {
|
||||
const {langList} = strings;
|
||||
const { langList } = strings;
|
||||
const item = langList.find((itm) => {
|
||||
return itm.id === id;
|
||||
});
|
||||
@@ -294,7 +294,7 @@ export default {
|
||||
icon: 'markers-' + id + '.png',
|
||||
title,
|
||||
type: 'context',
|
||||
events: {click: setArrowFromButton},
|
||||
events: { click: setArrowFromButton },
|
||||
panel: 'placemark_panel',
|
||||
list: 'placemark_marker',
|
||||
isDefault: id === 'leftarrow'
|
||||
@@ -303,7 +303,7 @@ export default {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
const buttons = [{
|
||||
const buttons = [ {
|
||||
id: 'tool_placemark',
|
||||
icon: 'placemark.png',
|
||||
type: 'mode',
|
||||
@@ -314,14 +314,14 @@ export default {
|
||||
svgCanvas.setMode('placemark');
|
||||
}
|
||||
}
|
||||
}];
|
||||
} ];
|
||||
const contextTools = [
|
||||
{
|
||||
type: 'button-select',
|
||||
panel: 'placemark_panel',
|
||||
id: 'placemark_marker',
|
||||
colnum: 3,
|
||||
events: {change: setArrowFromButton}
|
||||
events: { change: setArrowFromButton }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
@@ -375,7 +375,7 @@ export default {
|
||||
font = font.join(' ');
|
||||
const x0 = opts.start_x + 10, y0 = opts.start_y + 10;
|
||||
let maxlen = 0;
|
||||
const children = [{
|
||||
const children = [ {
|
||||
element: 'line',
|
||||
attr: {
|
||||
id: id + '_pline_0',
|
||||
@@ -388,7 +388,7 @@ export default {
|
||||
x2: x0,
|
||||
y2: y0
|
||||
}
|
||||
}];
|
||||
} ];
|
||||
items.forEach((i, n) => {
|
||||
maxlen = Math.max(maxlen, i.length);
|
||||
children.push({
|
||||
@@ -418,7 +418,7 @@ export default {
|
||||
'font-size': fontSize,
|
||||
'text-anchor': 'start'
|
||||
},
|
||||
children: [i]
|
||||
children: [ i ]
|
||||
});
|
||||
});
|
||||
if (items.length > 0) {
|
||||
@@ -479,7 +479,7 @@ export default {
|
||||
newPM.setAttribute('y', y);
|
||||
const elements = newPM.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [, , type, n] = i.id.split('_');
|
||||
const [ , , type, n ] = i.id.split('_');
|
||||
const y0 = y + (fontSize + 6) * n,
|
||||
x0 = x + maxlen * fontSize * 0.5 + fontSize;
|
||||
const nx = (x + (x0 - x) / 2 < px) ? x0 : x;
|
||||
@@ -534,7 +534,7 @@ export default {
|
||||
const txt = [];
|
||||
const elements = elem.children;
|
||||
Array.prototype.forEach.call(elements, function(i){
|
||||
const [, , type] = i.id.split('_');
|
||||
const [ , , type ] = i.id.split('_');
|
||||
if (type === 'txt') {
|
||||
$id('placemarkFont').value = (
|
||||
i.getAttribute('font-family') + ' ' + i.getAttribute('font-size')
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
export default {
|
||||
name: 'placemark',
|
||||
langList: [
|
||||
{id: 'nomarker', title: 'No Marker'},
|
||||
{id: 'leftarrow', title: 'Left Arrow'},
|
||||
{id: 'rightarrow', title: 'Right Arrow'},
|
||||
{id: 'forwardslash', title: 'Forward Slash'},
|
||||
{id: 'reverseslash', title: 'Reverse Slash'},
|
||||
{id: 'verticalslash', title: 'Vertical Slash'},
|
||||
{id: 'box', title: 'Box'},
|
||||
{id: 'star', title: 'Star'},
|
||||
{id: 'xmark', title: 'X'},
|
||||
{id: 'triangle', title: 'Triangle'},
|
||||
{id: 'mcircle', title: 'Circle'},
|
||||
{id: 'leftarrow_o', title: 'Open Left Arrow'},
|
||||
{id: 'rightarrow_o', title: 'Open Right Arrow'},
|
||||
{id: 'box_o', title: 'Open Box'},
|
||||
{id: 'star_o', title: 'Open Star'},
|
||||
{id: 'triangle_o', title: 'Open Triangle'},
|
||||
{id: 'mcircle_o', title: 'Open Circle'}
|
||||
{ id: 'nomarker', title: 'No Marker' },
|
||||
{ id: 'leftarrow', title: 'Left Arrow' },
|
||||
{ id: 'rightarrow', title: 'Right Arrow' },
|
||||
{ id: 'forwardslash', title: 'Forward Slash' },
|
||||
{ id: 'reverseslash', title: 'Reverse Slash' },
|
||||
{ id: 'verticalslash', title: 'Vertical Slash' },
|
||||
{ id: 'box', title: 'Box' },
|
||||
{ id: 'star', title: 'Star' },
|
||||
{ id: 'xmark', title: 'X' },
|
||||
{ id: 'triangle', title: 'Triangle' },
|
||||
{ id: 'mcircle', title: 'Circle' },
|
||||
{ id: 'leftarrow_o', title: 'Open Left Arrow' },
|
||||
{ id: 'rightarrow_o', title: 'Open Right Arrow' },
|
||||
{ id: 'box_o', title: 'Open Box' },
|
||||
{ id: 'star_o', title: 'Open Star' },
|
||||
{ id: 'triangle_o', title: 'Open Triangle' },
|
||||
{ id: 'mcircle_o', title: 'Open Circle' }
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@ export default {
|
||||
name: 'polygon',
|
||||
async init (_S) {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
// const editingitex = false;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
let selElems;
|
||||
@@ -36,7 +36,7 @@ export default {
|
||||
*/
|
||||
const showPanel = (on) => {
|
||||
$id('polygon_panel').style.display = (on) ? 'block' : 'none';
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} attr
|
||||
@@ -80,8 +80,8 @@ export default {
|
||||
if (this.leftPanel.updateLeftPanel('tool_polygon')) {
|
||||
svgCanvas.setMode('polygon');
|
||||
showPanel(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Add the context panel and its handler(s)
|
||||
const panelTemplate = document.createElement("template");
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
const fill = newFO.getAttribute('fill');
|
||||
const strokecolor = newFO.getAttribute('strokecolor');
|
||||
const strokeWidth = Number(newFO.getAttribute('strokeWidth'));
|
||||
|
||||
|
||||
let x = opts.mouse_x;
|
||||
let y = opts.mouse_y;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* adopted for moinmoins item storage. It sends in one post png and svg data
|
||||
* (I agree to dual license my work to additional GPLv2 or later)
|
||||
*/
|
||||
import {Canvg as canvg} from 'canvg';
|
||||
import { Canvg as canvg } from 'canvg';
|
||||
|
||||
const loadExtensionTranslation = async function (lang) {
|
||||
let translationModule;
|
||||
@@ -24,11 +24,11 @@ const loadExtensionTranslation = async function (lang) {
|
||||
|
||||
export default {
|
||||
name: 'server_moinsave',
|
||||
async init ({encode64}) {
|
||||
async init ({ encode64 }) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const saveSvgAction = '/+modify';
|
||||
|
||||
// Create upload target (hidden iframe)
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
svgEditor.setCustomHandlers({
|
||||
async save (win, data) {
|
||||
const svg = '<?xml version="1.0"?>\n' + data;
|
||||
const {pathname} = new URL(location);
|
||||
const { pathname } = new URL(location);
|
||||
const name = pathname.replace(/\/+get\//, '');
|
||||
const svgData = encode64(svg);
|
||||
if (!$id('export_canvas')) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
export default {
|
||||
name: 'php_savefile',
|
||||
init ({$}) {
|
||||
init ({ $ }) {
|
||||
const svgEditor = this;
|
||||
const {
|
||||
canvas: svgCanvas
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
||||
filename = getFileNameFromTitle();
|
||||
|
||||
$.post(saveSvgAction, {output_svg: svg, filename});
|
||||
$.post(saveSvgAction, { output_svg: svg, filename });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @copyright 2010 Alexis Deveria
|
||||
*
|
||||
*/
|
||||
import {Canvg as canvg} from 'canvg';
|
||||
import { Canvg as canvg } from 'canvg';
|
||||
|
||||
const loadExtensionTranslation = async function (lang) {
|
||||
let translationModule;
|
||||
@@ -23,7 +23,7 @@ const loadExtensionTranslation = async function (lang) {
|
||||
|
||||
export default {
|
||||
name: 'server_opensave',
|
||||
async init ({$, decode64, encode64}) {
|
||||
async init ({ $, decode64, encode64 }) {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const {
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
},
|
||||
canvas: svgCanvas
|
||||
} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { $id } = svgCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -130,11 +130,11 @@ export default {
|
||||
<input type="hidden" name="filename" value="${xhtmlEscape(filename)}">`;
|
||||
document.body.append(form);
|
||||
form.submit();
|
||||
form.remove();
|
||||
form.remove();
|
||||
},
|
||||
// Todo: Integrate this extension with a new built-in exportWindowType, "download"
|
||||
async exportImage (win, data) {
|
||||
const {issues, mimeType, quality} = data;
|
||||
const { issues, mimeType, quality } = data;
|
||||
|
||||
if (!$id('export_canvas')) {
|
||||
const canvasx = document.createElement("CANVAS");
|
||||
@@ -227,7 +227,7 @@ export default {
|
||||
openSvgForm.enctype = 'multipart/form-data';
|
||||
openSvgForm.method = 'post';
|
||||
openSvgForm.target = 'output_frame';
|
||||
|
||||
|
||||
|
||||
// Create import form
|
||||
const importSvgForm = openSvgForm.cloneNode(true);
|
||||
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
init () {
|
||||
const svgEditor = this;
|
||||
const canv = svgEditor.svgCanvas;
|
||||
const {$id} = canv;
|
||||
const { $id } = canv;
|
||||
const svgroot = canv.getRootElem();
|
||||
let lastBBox = {};
|
||||
|
||||
@@ -32,7 +32,7 @@ export default {
|
||||
src="./images/shapelib.svg"></se-explorerbutton>
|
||||
`;
|
||||
$id('tools_left').append(buttonTemplate.content.cloneNode(true));
|
||||
$id('tool_shapelib').addEventListener("click", () => {
|
||||
$id('tool_shapelib').addEventListener("click", () => {
|
||||
canv.setMode(modeId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export default {
|
||||
name: 'star',
|
||||
async init (_S) {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const {$id} = svgCanvas;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
let selElems;
|
||||
let started;
|
||||
let newFO;
|
||||
@@ -70,7 +70,7 @@ export default {
|
||||
if (this.leftPanel.updateLeftPanel('tool_polygon')) {
|
||||
svgCanvas.setMode('star');
|
||||
showPanel(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add the context panel and its handler(s)
|
||||
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
name: 'storage',
|
||||
init () {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas, storage} = svgEditor;
|
||||
const { svgCanvas, storage } = svgEditor;
|
||||
|
||||
// We could empty any already-set data for users when they decline storage,
|
||||
// but it would be a risk for users who wanted to store but accidentally
|
||||
@@ -157,12 +157,12 @@ export default {
|
||||
setSVGContentStorage(svgCanvas.getSvgString());
|
||||
}
|
||||
|
||||
svgEditor.setConfig({no_save_warning: true}); // No need for explicit saving at all once storage is on
|
||||
svgEditor.setConfig({ no_save_warning: true }); // No need for explicit saving at all once storage is on
|
||||
// svgEditor.showSaveWarning = false;
|
||||
|
||||
const {curPrefs} = svgEditor.configObj;
|
||||
const { curPrefs } = svgEditor.configObj;
|
||||
|
||||
Object.entries(curPrefs).forEach(([key, val]) => {
|
||||
Object.entries(curPrefs).forEach(([ key, val ]) => {
|
||||
const store = (val !== undefined);
|
||||
key = 'svg-edit-' + key;
|
||||
if (!store) {
|
||||
|
||||
@@ -85,7 +85,7 @@ export class SeStorageDialog extends HTMLElement {
|
||||
constructor () {
|
||||
super();
|
||||
// create the shadowDom and insert the template
|
||||
this._shadowRoot = this.attachShadow({mode: 'open'});
|
||||
this._shadowRoot = this.attachShadow({ mode: 'open' });
|
||||
this._shadowRoot.append(template.content.cloneNode(true));
|
||||
this.$dialog = this._shadowRoot.querySelector('#dialog_box');
|
||||
this.$storage = this._shadowRoot.querySelector('#js-storage');
|
||||
@@ -99,7 +99,7 @@ export class SeStorageDialog extends HTMLElement {
|
||||
* @returns {any} observed
|
||||
*/
|
||||
static get observedAttributes () {
|
||||
return ['dialog', 'storage'];
|
||||
return [ 'dialog', 'storage' ];
|
||||
}
|
||||
/**
|
||||
* @function attributeChangedCallback
|
||||
@@ -149,11 +149,11 @@ export class SeStorageDialog extends HTMLElement {
|
||||
*/
|
||||
connectedCallback () {
|
||||
const onSubmitHandler = (e, action) => {
|
||||
const triggerEvent = new CustomEvent('change', {detail: {
|
||||
const triggerEvent = new CustomEvent('change', { detail: {
|
||||
trigger: action,
|
||||
select: this.$storageInput.value,
|
||||
checkbox: this.$rememberInput.checked
|
||||
}});
|
||||
} });
|
||||
this.dispatchEvent(triggerEvent);
|
||||
};
|
||||
this.$okBtn.addEventListener('click', (evt) => onSubmitHandler(evt, 'ok'));
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const saveMessage = 'save',
|
||||
readMessage = 'read',
|
||||
excludedMessages = [readMessage, saveMessage];
|
||||
excludedMessages = [ readMessage, saveMessage ];
|
||||
|
||||
let pathID;
|
||||
this.canvas.bind(
|
||||
@@ -40,11 +40,11 @@ export default {
|
||||
* @throws {Error} Unexpected event type
|
||||
* @returns {void}
|
||||
*/
|
||||
(win, {data, origin}) => {
|
||||
(win, { data, origin }) => {
|
||||
// console.log('data, origin', data, origin);
|
||||
let type, content;
|
||||
try {
|
||||
({type, pathID, content} = data.webappfind); // May throw if data is not an object
|
||||
({ type, pathID, content } = data.webappfind); // May throw if data is not an object
|
||||
if (origin !== location.origin || // We are only interested in a message sent as though within this URL by our browser add-on
|
||||
excludedMessages.includes(type) // Avoid our post below (other messages might be possible in the future which may also need to be excluded if your subsequent code makes assumptions on the type of message this is)
|
||||
) {
|
||||
@@ -81,7 +81,7 @@ export default {
|
||||
: window.location.origin
|
||||
);
|
||||
*/
|
||||
const buttons = [{
|
||||
const buttons = [ {
|
||||
id: 'webappfind_save', //
|
||||
icon: 'webappfind.png',
|
||||
type: 'app_menu',
|
||||
@@ -106,7 +106,7 @@ export default {
|
||||
);
|
||||
}
|
||||
}
|
||||
}];
|
||||
} ];
|
||||
|
||||
return {
|
||||
name: strings.name,
|
||||
|
||||
@@ -8,11 +8,11 @@ export default {
|
||||
name: 'xdomain-messaging',
|
||||
init () {
|
||||
const svgEditor = this;
|
||||
const {svgCanvas} = svgEditor;
|
||||
const { svgCanvas } = svgEditor;
|
||||
try {
|
||||
window.addEventListener('message', function (e) {
|
||||
// We accept and post strings for the sake of IE9 support
|
||||
if (!e.data || !['string', 'object'].includes(typeof e.data) || e.data.charAt() === '|') {
|
||||
if (!e.data || ![ 'string', 'object' ].includes(typeof e.data) || e.data.charAt() === '|') {
|
||||
return;
|
||||
}
|
||||
const data = typeof e.data === 'object' ? e.data : JSON.parse(e.data);
|
||||
@@ -22,13 +22,13 @@ export default {
|
||||
// The default is not to allow any origins, including even the same domain or
|
||||
// if run on a `file:///` URL. See `svgedit-config-es.js` for an example of how
|
||||
// to configure
|
||||
const {allowedOrigins} = svgEditor.configObj.curConfig;
|
||||
const { allowedOrigins } = svgEditor.configObj.curConfig;
|
||||
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
|
||||
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`);
|
||||
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`);
|
||||
return;
|
||||
}
|
||||
const cbid = data.id;
|
||||
const {name, args} = data;
|
||||
const { name, args } = data;
|
||||
const message = {
|
||||
namespace: 'svg-edit',
|
||||
id: cbid
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
e.source.postMessage(JSON.stringify(message), '*');
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('Error with xdomain message listener: ' + err);
|
||||
console.log('Error with xdomain message listener: ' + err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user