- Linting (ESLint): Stricter rules (or switch to warning)

- Breaking internal API change: `updateGripCursor` moved to be class method of Selector rather than instance method
- Breaking internal API change: `subpathIsClosed` moved to be class method of `Path` rather than instance method
- Refactoring: Reuse utilities base64 encoder for SVG icons plugin
- Docs (JSDoc): Fix return of the `mouseUp` (can also be an object) and `mouseDown` (may also be a boolean) of `pathActions`; other JSDoc additions/improvements
This commit is contained in:
Brett Zamir
2018-11-07 14:51:50 +08:00
parent 901c9547fe
commit 7c470e9909
126 changed files with 2081 additions and 1373 deletions

View File

@@ -67,7 +67,7 @@ export default {
}
function getOffset (side, line) {
const giveOffset = !!line.getAttribute('marker-' + side);
const giveOffset = line.getAttribute('marker-' + side);
// const giveOffset = $(line).data(side+'_off');
// TODO: Make this number (5) be based on marker width/height
@@ -170,7 +170,7 @@ export default {
['start', 'end'].forEach(function (pos, i) {
const key = 'c_' + pos;
let part = elData(this, key);
if (part == null) {
if (part === null || part === undefined) { // Does this ever return nullish values?
part = document.getElementById(
this.attributes['se:connector'].value.split(' ')[i]
);
@@ -178,7 +178,7 @@ export default {
elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part]));
} else part = document.getElementById(part);
parts.push(part);
}.bind(this));
}, this);
for (let i = 0; i < 2; i++) {
const cElem = parts[i];
@@ -262,15 +262,15 @@ export default {
(function () {
const gse = svgCanvas.groupSelectedElements;
svgCanvas.groupSelectedElements = function () {
svgCanvas.groupSelectedElements = function (...args) {
svgCanvas.removeFromSelection($(connSel).toArray());
return gse.apply(this, arguments);
return gse.apply(this, args);
};
const mse = svgCanvas.moveSelectedElements;
svgCanvas.moveSelectedElements = function () {
const cmd = mse.apply(this, arguments);
svgCanvas.moveSelectedElements = function (...args) {
const cmd = mse.apply(this, args);
updateConnectors();
return cmd;
};
@@ -331,7 +331,7 @@ export default {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
async addLangData ({lang, importLocale}) {
/* async */ addLangData ({lang, importLocale}) {
return {
data: strings.langList
};
@@ -548,8 +548,8 @@ export default {
const end = elem.getAttribute('marker-end');
curLine = elem;
$(elem)
.data('start_off', !!start)
.data('end_off', !!end);
.data('start_off', Boolean(start))
.data('end_off', Boolean(end));
if (elem.tagName === 'line' && mid) {
// Convert to polyline to accept mid-arrow

View File

@@ -16,7 +16,7 @@ export default {
// https://code.google.com/p/chromium/issues/detail?id=565120.
if (isChrome()) {
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
const chromeVersion = parseInt(navigator.userAgent.substring(verIndex), 10);
const chromeVersion = parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) {
return;
}

View File

@@ -24,7 +24,7 @@ export default {
* @throws {Error} Unexpected event type
* @returns {undefined}
*/
(win, {data, origin}) => {
(win, {data, origin}) => { // eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
let type, content;
try {
@@ -78,17 +78,18 @@ export default {
if (!pathID) { // Not ready yet as haven't received first payload
return;
}
window.postMessage({
webappfind: {
type: saveMessage,
pathID,
content: svgEditor.canvas.getSvgString()
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even
// though file protocol not currently supported by add-on)
? '*'
: window.location.origin
window.postMessage(
{
webappfind: {
type: saveMessage,
pathID,
content: svgEditor.canvas.getSvgString()
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even
// though file protocol not currently supported by add-on)
? '*'
: window.location.origin
);
}
}

View File

@@ -1,12 +1,21 @@
import {jml, body, nbsp} from '../../external/jamilih/jml-es.js';
import $ from '../../external/query-result/esm/index.js';
import {manipulation} from '../../external/qr-manipulation/dist/index-es.js';
manipulation($, jml);
const baseAPIURL = 'https://openclipart.org/search/json/';
/**
* Shows results after query submission.
* @param {string} url
* @returns {undefined}
*/
async function processResults (url) {
/**
* @param {string} query
* @returns {external:JamilihArray}
*/
function queryLink (query) {
return ['a', {
href: 'javascript: void(0);',
@@ -22,7 +31,7 @@ async function processResults (url) {
const r = await fetch(url);
const json = await r.json();
console.log('json', json);
// console.log('json', json);
if (!json || json.msg !== 'success') {
alert('There was a problem downloading the results');
@@ -74,7 +83,7 @@ async function processResults (url) {
async click (e) {
e.preventDefault();
const {value: svgURL, id} = this.dataset;
console.log('this', id, svgURL);
// console.log('this', id, svgURL);
const post = (message) => {
// Todo: Make origin customizable as set by opening window
// Todo: If dropping IE9, avoid stringifying
@@ -90,7 +99,7 @@ async function processResults (url) {
});
const result = await fetch(svgURL);
const svg = await result.text();
console.log('h', svgURL, svg);
// console.log('url and svg', svgURL, svg);
post({
href: svgURL,
data: svg