eslint/browser list/accessibility test

master
JFH 2020-07-26 20:11:18 +02:00
parent 630a76c1b6
commit 89e20d49e6
114 changed files with 105155 additions and 93732 deletions

View File

@ -1,343 +1,15 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
extends: ['ash-nazg/sauron-node'], extends: ['eslint:recommended', 'ash-nazg/sauron-node'],
parserOptions: { parserOptions: {
"ecmaVersion": 10,
sourceType: 'module' sourceType: 'module'
}, },
env: { env: {
browser: true browser: true,
es6: true
}, },
settings: {
polyfills: [
],
jsdoc: {
additionalTagNames: {
// In case we need to extend
customTags: []
},
augmentsExtendsReplacesDocs: true
// Todo: Figure out why this is not working and why seem to have to
// disable for all Markdown:
/*
baseConfig: {
rules: {
'no-multi-spaces': 'off'
}
}
*/
}
},
overrides: [
// Locales have no need for importing outside of SVG-Edit
{
files: [
'src/editor/locale/lang.*.js', 'src/editor/extensions/ext-locale/**',
'docs/tutorials/ExtensionDocs.md'
],
rules: {
'import/no-anonymous-default-export': ['off']
}
},
// These browser files don't do importing or requiring
{
files: [
'src/editor/svgpathseg.js',
'src/editor/touch.js',
'src/editor/typedefs.js',
'src/editor/redirect-on-no-module-support.js',
'src/editor/extensions/imagelib/index.js',
'src/external/dom-polyfill/dom-polyfill.js',
'docs/screencasts/svgopen2010/script.js'
],
rules: {
'import/unambiguous': ['off']
}
},
{
files: ['**/*.html', 'docs/screencasts/**'],
globals: {
root: 'off'
},
settings: {
polyfills: [
'document.querySelector',
'history',
'history.pushState',
'history.replaceState',
'location.hash',
'navigator',
'Number.parseFloat',
'Number.parseInt',
'Number.isNaN'
]
},
rules: {
'import/unambiguous': 'off'
}
},
{
files: ['.eslintrc.js', '.ncurc.js', 'tools/mochawesome-cli.js'],
extends: [
'ash-nazg/sauron-node-script'
]
},
// Our Markdown rules (and used for JSDoc examples as well, by way of
// our use of `jsdoc/check-examples` within `ash-nazg`)
{
files: ['**/*.md'],
settings: {
polyfills: [
// Tutorials
'console',
'location.href'
]
},
rules: {
// Todo: Figure out why this is not enough to disable warning
// for examples in my environment (but it is in others')
// Used in examples of assert-close.js plugin
'mocha-cleanup/no-assertions-outside-it': 'off',
'eslint-comments/no-unused-disable': 'warn',
'eol-last': ['off'],
'no-console': ['off'],
'no-undef': ['off'],
'no-unused-vars': ['warn'],
'padded-blocks': ['off'],
'import/unambiguous': ['off'],
'import/no-unresolved': ['off'],
'node/no-missing-import': ['off'],
'no-multi-spaces': 'off',
'sonarjs/no-all-duplicated-branches': 'off',
'node/no-unpublished-import': ['error', {
allowModules: ['@cypress/fiddle']
}],
'no-alert': 'off',
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
indent: 'off'
}
},
// Dis-apply Node rules mistakenly giving errors with browser files,
// and treating Node global `root` as being present for shadowing
{
files: ['src/editor/**', 'src/external/**'],
globals: {
root: 'off'
},
settings: {
polyfills: [
// These are the primary polyfills needed by regular users if
// not present, e.g., with core-js-bundle; also those under
// extensions
'Array.isArray',
'Blob',
'console',
'CustomEvent',
'document.body',
'document.createElementNS',
'document.evaluate',
'document.head',
'document.importNode',
'document.querySelector',
'document.querySelectorAll',
'DOMParser',
'Error',
'FileReader',
'JSON',
'KeyboardEvent',
'location.href',
'location.origin',
'MouseEvent',
'MutationObserver',
'navigator',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'Object.assign',
'Object.defineProperty',
'Object.defineProperties',
'Object.entries',
'Object.getOwnPropertyDescriptor',
'Object.keys',
'Object.values',
'Promise',
'Promise.all',
'Set',
'Uint8Array',
'URL',
'URL.createObjectURL',
'XMLSerializer',
'XMLHttpRequest',
'window.getComputedStyle',
'window.parent',
'window.scrollX',
'window.scrollY'
]
},
rules: {
// Should probably add this rule to ash-nazg as facilitates tree-shaking
'import/no-namespace': ['error'],
'node/no-unsupported-features/node-builtins': 'off'
}
},
// For extensions, `this` is generally assigned to be the more
// descriptive `svgEditor`; they also have no need for importing outside
// of SVG-Edit
{
files: ['src/editor/extensions/**'],
settings: {
polyfills: [
'console',
'fetch',
'location.origin',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'window.postMessage'
]
},
rules: {
'consistent-this': ['error', 'svgEditor'],
'import/no-anonymous-default-export': ['off']
}
},
{
// Node files
files: [
'docs/jsdoc-config.js',
'build/build-html.js',
'rollup.config.js', 'rollup-config.config.js'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Promise.resolve'
]
},
globals: {
require: true
},
rules: {
// We can't put Rollup in npmignore or user can't get access,
// and we have too many modules to add to `peerDependencies`
// so this rule can know them to be available, so we instead
// disable
'node/no-unpublished-import': 'off'
}
},
{
// As consumed by jsdoc, cannot be expressed as ESM
files: ['docs/jsdoc-config.js'],
parserOptions: {
sourceType: 'script'
},
globals: {
module: false
},
rules: {
'import/no-commonjs': 'off',
strict: 'off'
}
},
{
// Should probably have as external, but should still check
files: ['src/editor/canvg/rgbcolor.js'],
settings: {
polyfills: [
'Number.isNaN',
'Number.parseInt',
'Object.assign',
'Object.keys'
]
}
},
{
files: ['cypress/plugins/index.js'],
extends: [
'ash-nazg/sauron-node-script'
]
},
{
files: ['cypress/**'],
extends: [
'plugin:cypress/recommended',
'plugin:mocha/recommended',
'plugin:mocha-cleanup/recommended-no-limits',
'plugin:@fintechstudios/chai-as-promised/recommended',
'plugin:chai-expect-keywords/recommended',
'plugin:chai-expect/recommended',
'plugin:chai-friendly/recommended'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Date.now',
'document.body',
'document.createElementNS',
'document.head',
'DOMParser',
'Number.isNaN',
'Object.keys',
'Object.entries',
'Promise'
]
},
rules: {
// These errors are caused in Cypress files if user has not
// yet instrumented code; need to reinvestigate why we had to
// instrument separately from nyc mocha
'import/no-unresolved': ['error', {ignore: ['/instrumented/']}],
'node/no-missing-import': 'off',
'chai-expect-keywords/no-unsupported-keywords': [
'error', {
allowChaiDOM: true
}
],
// Would be good but seems necessary due to some bugs in Cypress
// in detecting visibility
// 'cypress/no-force': 0,
// Good but would be difficult to enforce (and data-* may not be less
// brittle than IDs/classes anyways)
// 'cypress/require-data-selectors': 0,
'cypress/assertion-before-screenshot': 2,
// Conflicts with Cypress `should`
'mocha-cleanup/invalid-assertions': 0,
// Might see about working around to avoid the option limitation,
// but convenient
'mocha-cleanup/no-expressions-in-assertions': ['error', {
replacementsOnly: true
}],
// Too oppressive when planning to extend a section
'mocha/no-hooks-for-single-case': 0,
// Would be good to enable but needs some refactoring
'mocha/no-setup-in-describe': 0,
'mocha-cleanup/no-outside-declaration': 0,
// Useful to ensure allowing `this.timeout()`, etc., but a
// little oppressive
'mocha/no-mocha-arrows': 0,
// Useful if enabling the regular `prefer-arrow-callback`
// 'mocha/prefer-arrow-callback': 2
'jsdoc/require-jsdoc': 0,
'no-console': 0,
'import/unambiguous': 0
}
}
],
rules: { rules: {
// check-examples is not picking up eslint config properly in some // check-examples is not picking up eslint config properly in some
// environments; see also discussion above // environments; see also discussion above
@ -350,20 +22,6 @@ module.exports = {
'unicorn/regex-shorthand': 0, 'unicorn/regex-shorthand': 0,
// The Babel transform seems to have a problem converting these // The Babel transform seems to have a problem converting these
'prefer-named-capture-group': 'off', 'prefer-named-capture-group': 'off',
// Override these `ash-nazg/sauron` rules which are difficult for us
// to apply at this time
'unicorn/prefer-string-slice': 'off',
'default-case': 'off',
'require-unicode-regexp': 'off',
'max-len': 'off', /* , {
ignoreUrls: true,
ignoreRegExpLiterals: true
} */
'unicorn/prefer-query-selector': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/prefer-node-append': 'off',
'unicorn/no-zero-fractions': 'off',
'unicorn/prefer-number-properties': 'off',
'jsdoc/require-file-overview': ['error', { 'jsdoc/require-file-overview': ['error', {
tags: { tags: {
file: { file: {
@ -392,8 +50,37 @@ module.exports = {
} }
} }
}], }],
// Warning or Off for now but should be reviewed
// Disable for now // Override these rules which are difficult for us
'eslint-comments/require-description': 0 // to apply at this time
} 'unicorn/prefer-string-slice': 'off',
'default-case': 'off',
'require-unicode-regexp': 'off',
'max-len': ['warn', { 'ignoreComments': true, 'code': 130 }], // 130 is too much but too many occurences
'unicorn/prefer-query-selector': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/prefer-node-append': 'off',
'unicorn/no-zero-fractions': 'off',
'unicorn/prefer-number-properties': 'off',
'eslint-comments/require-description': 'off',
'compat/compat': 'warn',
'consistent-this': 'off',
'import/no-anonymous-default-export': 'off',
'node/no-unsupported-features/node-builtins': 'warn',
'prefer-exponentiation-operator': 'warn'
},
overrides: [
// Locales have no need for importing outside of SVG-Edit
// and translations may need a longer line length
{
files: [
'src/editor/locale/lang.*.js', 'src/editor/extensions/ext-locale/**',
'docs/tutorials/ExtensionDocs.md'
],
rules: {
'import/no-anonymous-default-export': 'off',
'max-len': 'off'
}
}
]
}; };

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="421" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h102v20H120zM222 0h87v20h-87zM309 0h112v20H309z"/><path fill="url(#smooth)" d="M0 0h421v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 37.51%</text><text class="high" x="5" y="14">Statements 37.51%</text><text class="shadow" x="125.5" y="15">Branches 28.8%</text><text class="high" x="125" y="14">Branches 28.8%</text><text class="shadow" x="227.5" y="15">Lines 38.46%</text><text class="high" x="227" y="14">Lines 38.46%</text><text class="shadow" x="314.5" y="15">Functions 47.27%</text><text class="high" x="314" y="14">Functions 47.27%</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="orange" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87z"/><path fill="green" stroke="#000" d="M316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 37.49%</text><text class="high" x="5" y="14">Statements 37.49%</text><text class="shadow" x="125.5" y="15">Branches 28.78%</text><text class="high" x="125" y="14">Branches 28.78%</text><text class="shadow" x="234.5" y="15">Lines 38.44%</text><text class="high" x="234" y="14">Lines 38.44%</text><text class="shadow" x="321.5" y="15">Functions 47.27%</text><text class="high" x="321" y="14">Functions 47.27%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,4 +1,3 @@
// eslint-disable-next-line mocha/no-skipped-tests
describe.skip('UI - Accessibility', function () { describe.skip('UI - Accessibility', function () {
beforeEach(() => { beforeEach(() => {
cy.visit('/instrumented/editor/svg-editor-es.html'); cy.visit('/instrumented/editor/svg-editor-es.html');
@ -26,6 +25,15 @@ describe.skip('UI - Accessibility', function () {
locale: Object locale: Object
*/ */
}); });
cy.checkA11y(); cy.checkA11y(
{},
{
rules: {
'label-title-only': { enabled: false },
'page-has-heading-one': { enabled: false },
'region': { enabled: false },
'scrollable-region-focusable': { enabled: false },
}
});
}); });
}); });

5199
dist/canvg.js vendored

File diff suppressed because it is too large Load Diff

84
dist/dom-polyfill.js vendored
View File

@ -1,6 +1,22 @@
(function () { (function () {
'use strict'; 'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js // From https://github.com/inexorabletash/polyfill/blob/master/dom.js
/** /**
@ -15,7 +31,7 @@
*/ */
function mixin(o, ps) { function mixin(o, ps) {
if (!o) return; if (!o) return;
Object.keys(ps).forEach(p => { Object.keys(ps).forEach(function (p) {
if (p in o || p in o.prototype) { if (p in o || p in o.prototype) {
return; return;
} }
@ -36,8 +52,8 @@
function convertNodesIntoANode(nodes) { function convertNodesIntoANode(nodes) {
nodes = nodes.map(node => { nodes = nodes.map(function (node) {
const isNode = node && typeof node === 'object' && 'nodeType' in node; var isNode = node && _typeof(node) === 'object' && 'nodeType' in node;
return isNode ? node : document.createTextNode(node); return isNode ? node : document.createTextNode(node);
}); });
@ -45,24 +61,30 @@
return nodes[0]; return nodes[0];
} }
const node = document.createDocumentFragment(); var node = document.createDocumentFragment();
nodes.forEach(n => { nodes.forEach(function (n) {
node.appendChild(n); node.appendChild(n);
}); });
return node; return node;
} }
const ParentNode = { var ParentNode = {
prepend(...nodes) { prepend: function prepend() {
for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
nodes[_key] = arguments[_key];
}
nodes = convertNodesIntoANode(nodes); nodes = convertNodesIntoANode(nodes);
this.insertBefore(nodes, this.firstChild); this.insertBefore(nodes, this.firstChild);
}, },
append: function append() {
for (var _len2 = arguments.length, nodes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
nodes[_key2] = arguments[_key2];
}
append(...nodes) {
nodes = convertNodesIntoANode(nodes); nodes = convertNodesIntoANode(nodes);
this.appendChild(nodes); this.appendChild(nodes);
} }
}; };
mixin(Document || HTMLDocument, ParentNode); // HTMLDocument for IE8 mixin(Document || HTMLDocument, ParentNode); // HTMLDocument for IE8
@ -70,44 +92,54 @@
mixin(Element, ParentNode); // Mixin ChildNode mixin(Element, ParentNode); // Mixin ChildNode
// https://dom.spec.whatwg.org/#interface-childnode // https://dom.spec.whatwg.org/#interface-childnode
const ChildNode = { var ChildNode = {
before(...nodes) { before: function before() {
const parent = this.parentNode; var parent = this.parentNode;
if (!parent) return; if (!parent) return;
let viablePreviousSibling = this.previousSibling; var viablePreviousSibling = this.previousSibling;
for (var _len3 = arguments.length, nodes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
nodes[_key3] = arguments[_key3];
}
while (nodes.includes(viablePreviousSibling)) { while (nodes.includes(viablePreviousSibling)) {
viablePreviousSibling = viablePreviousSibling.previousSibling; viablePreviousSibling = viablePreviousSibling.previousSibling;
} }
const node = convertNodesIntoANode(nodes); var node = convertNodesIntoANode(nodes);
parent.insertBefore(node, viablePreviousSibling ? viablePreviousSibling.nextSibling : parent.firstChild); parent.insertBefore(node, viablePreviousSibling ? viablePreviousSibling.nextSibling : parent.firstChild);
}, },
after: function after() {
after(...nodes) { var parent = this.parentNode;
const parent = this.parentNode;
if (!parent) return; if (!parent) return;
let viableNextSibling = this.nextSibling; var viableNextSibling = this.nextSibling;
for (var _len4 = arguments.length, nodes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
nodes[_key4] = arguments[_key4];
}
while (nodes.includes(viableNextSibling)) { while (nodes.includes(viableNextSibling)) {
viableNextSibling = viableNextSibling.nextSibling; viableNextSibling = viableNextSibling.nextSibling;
} }
const node = convertNodesIntoANode(nodes); // eslint-disable-next-line unicorn/prefer-modern-dom-apis var node = convertNodesIntoANode(nodes); // eslint-disable-next-line unicorn/prefer-modern-dom-apis
parent.insertBefore(node, viableNextSibling); parent.insertBefore(node, viableNextSibling);
}, },
replaceWith: function replaceWith() {
replaceWith(...nodes) { var parent = this.parentNode;
const parent = this.parentNode;
if (!parent) return; if (!parent) return;
let viableNextSibling = this.nextSibling; var viableNextSibling = this.nextSibling;
for (var _len5 = arguments.length, nodes = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
nodes[_key5] = arguments[_key5];
}
while (nodes.includes(viableNextSibling)) { while (nodes.includes(viableNextSibling)) {
viableNextSibling = viableNextSibling.nextSibling; viableNextSibling = viableNextSibling.nextSibling;
} }
const node = convertNodesIntoANode(nodes); var node = convertNodesIntoANode(nodes);
if (this.parentNode === parent) { if (this.parentNode === parent) {
parent.replaceChild(node, this); parent.replaceChild(node, this);
@ -116,15 +148,13 @@
parent.insertBefore(node, viableNextSibling); parent.insertBefore(node, viableNextSibling);
} }
}, },
remove: function remove() {
remove() {
if (!this.parentNode) { if (!this.parentNode) {
return; return;
} }
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
} }
}; };
mixin(DocumentType, ChildNode); mixin(DocumentType, ChildNode);
mixin(Element, ChildNode); mixin(Element, ChildNode);

View File

@ -1,6 +1,42 @@
var svgEditorExtension_arrows = (function () { var svgEditorExtension_arrows = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-arrows.js * @file ext-arrows.js
* *
@ -11,361 +47,350 @@ var svgEditorExtension_arrows = (function () {
*/ */
var extArrows = { var extArrows = {
name: 'arrows', name: 'arrows',
init: function init(S) {
var _this = this;
async init(S) { return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
const strings = await S.importLocale(); var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools;
const svgEditor = this; return regeneratorRuntime.wrap(function _callee2$(_context2) {
const svgCanvas = svgEditor.canvas; while (1) {
const // {svgcontent} = S, switch (_context2.prev = _context2.next) {
addElem = svgCanvas.addSVGElementFromJson, case 0:
{ colorChanged = function _colorChanged(elem) {
nonce, var color = elem.getAttribute('stroke');
$ var mtypes = ['start', 'mid', 'end'];
} = S, var defs = svgCanvas.findDefs();
prefix = 'se_arrow_'; $.each(mtypes, function (i, type) {
let selElems, var marker = getLinked(elem, 'marker-' + type);
arrowprefix,
randomizeIds = S.randomize_ids;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {void}
*/
function setArrowNonce(win, n) { if (!marker) {
randomizeIds = true; return;
arrowprefix = prefix + n + '_'; }
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk'; var curColor = $(marker).children().attr('fill');
} var curD = $(marker).children().attr('d');
/**
* @param {Window} win if (curColor === color) {
* @returns {void} return;
*/ }
var allMarkers = $(defs).find('marker');
var newMarker = null; // Different color, check if already made
allMarkers.each(function () {
var attrs = $(this).children().attr(['fill', 'd']);
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this;
}
});
if (!newMarker) {
// Create a new marker with this color
var lastId = marker.id;
var dir = lastId.includes('_fw') ? 'fw' : 'bk';
newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);
$(newMarker).children().attr('fill', color);
}
$(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed
var remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
var element = this;
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
});
if (!remove) {
return false;
}
return undefined;
}); // Not found, so can safely remove
if (remove) {
$(marker).remove();
}
});
};
setArrow = function _setArrow() {
resetMarker();
var type = this.value;
if (type === 'none') {
return;
} // Set marker on element
function unsetArrowNonce(win) { var dir = 'fw';
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
}
svgCanvas.bind('setnonce', setArrowNonce); if (type === 'mid_bk') {
svgCanvas.bind('unsetnonce', unsetArrowNonce); type = 'mid';
dir = 'bk';
} else if (type === 'both') {
addMarker('bk', type);
svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');
type = 'end';
dir = 'fw';
} else if (type === 'start') {
dir = 'bk';
}
if (randomizeIds) { addMarker(dir, type);
arrowprefix = prefix + nonce + '_'; svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
} else { svgCanvas.call('changed', selElems);
arrowprefix = prefix; };
}
const pathdata = { addMarker = function _addMarker(dir, type, id) {
fw: { // TODO: Make marker (or use?) per arrow type, since refX can be different
d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', id = id || arrowprefix + dir;
refx: 8, var data = pathdata[dir];
id: arrowprefix + 'fw'
},
bk: {
d: 'm10,0l-10,5l10,5l-5,-5l5,-5z',
refx: 2,
id: arrowprefix + 'bk'
}
};
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
function getLinked(elem, attr) { if (type === 'mid') {
const str = elem.getAttribute(attr); data.refx = 5;
}
if (!str) { var marker = svgCanvas.getElem(id);
return null;
}
const m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?<id>.+)\)/); if (!marker) {
// if (!m || !m.groups.id) { marker = addElem({
element: 'marker',
attr: {
viewBox: '0 0 10 10',
id: id,
refY: 5,
markerUnits: 'strokeWidth',
markerWidth: 5,
markerHeight: 5,
orient: 'auto',
style: 'pointer-events:none' // Currently needed for Opera
if (!m || m.length !== 2) { }
return null; });
} var arrow = addElem({
element: 'path',
attr: {
d: data.d,
fill: '#000000'
}
});
marker.append(arrow);
svgCanvas.findDefs().append(marker);
}
return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); marker.setAttribute('refX', data.refx);
} return marker;
/** };
* @param {boolean} on
* @returns {void}
*/
resetMarker = function _resetMarker() {
var el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
};
function showPanel(on) { showPanel = function _showPanel(on) {
$('#arrow_panel').toggle(on); $('#arrow_panel').toggle(on);
if (on) { if (on) {
const el = selElems[0]; var el = selElems[0];
const end = el.getAttribute('marker-end'); var end = el.getAttribute('marker-end');
const start = el.getAttribute('marker-start'); var start = el.getAttribute('marker-start');
const mid = el.getAttribute('marker-mid'); var mid = el.getAttribute('marker-mid');
let val; var val;
if (end && start) { if (end && start) {
val = 'both'; val = 'both';
} else if (end) { } else if (end) {
val = 'end'; val = 'end';
} else if (start) { } else if (start) {
val = 'start'; val = 'start';
} else if (mid) { } else if (mid) {
val = 'mid'; val = 'mid';
if (mid.includes('bk')) { if (mid.includes('bk')) {
val = 'mid_bk'; val = 'mid_bk';
}
}
if (!start && !mid && !end) {
val = 'none';
}
$('#arrow_list').val(val);
}
};
getLinked = function _getLinked(elem, attr) {
var str = elem.getAttribute(attr);
if (!str) {
return null;
}
var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?<id>.+)\)/);
// if (!m || !m.groups.id) {
if (!m || m.length !== 2) {
return null;
}
return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id);
};
unsetArrowNonce = function _unsetArrowNonce(win) {
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
setArrowNonce = function _setArrowNonce(win, n) {
randomizeIds = true;
arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
_context2.next = 10;
return S.importLocale();
case 10:
strings = _context2.sent;
svgEditor = _this;
svgCanvas = svgEditor.canvas;
// {svgcontent} = S,
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_';
randomizeIds = S.randomize_ids;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {void}
*/
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
if (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
}
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'
}
};
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
contextTools = [{
type: 'select',
panel: 'arrow_panel',
id: 'arrow_list',
defval: 'none',
events: {
change: setArrow
}
}];
return _context2.abrupt("return", {
name: strings.name,
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#arrow_panel').hide(); // Set ID so it can be translated in locale file
$('#arrow_list option')[0].id = 'connector_no_arrow';
},
addLangData: function addLangData(_ref) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var lang, importLocale, _yield$importLocale, langList;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
lang = _ref.lang, importLocale = _ref.importLocale;
_context.next = 3;
return importLocale();
case 3:
_yield$importLocale = _context.sent;
langList = _yield$importLocale.langList;
return _context.abrupt("return", {
data: langList
});
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var markerElems = ['line', 'path', 'polyline', 'polygon'];
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && markerElems.includes(elem.tagName)) {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
},
elementChanged: function elementChanged(opts) {
var elem = opts.elems[0];
if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) {
// const start = elem.getAttribute('marker-start');
// const mid = elem.getAttribute('marker-mid');
// const end = elem.getAttribute('marker-end');
// Has marker, so see if it should match color
colorChanged(elem);
}
}
});
case 21:
case "end":
return _context2.stop();
} }
} }
}, _callee2);
if (!start && !mid && !end) { }))();
val = 'none';
}
$('#arrow_list').val(val);
}
}
/**
*
* @returns {void}
*/
function resetMarker() {
const el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
}
/**
* @param {"bk"|"fw"} dir
* @param {"both"|"mid"|"end"|"start"} type
* @param {string} id
* @returns {Element}
*/
function addMarker(dir, type, id) {
// TODO: Make marker (or use?) per arrow type, since refX can be different
id = id || arrowprefix + dir;
const data = pathdata[dir];
if (type === 'mid') {
data.refx = 5;
}
let marker = svgCanvas.getElem(id);
if (!marker) {
marker = addElem({
element: 'marker',
attr: {
viewBox: '0 0 10 10',
id,
refY: 5,
markerUnits: 'strokeWidth',
markerWidth: 5,
markerHeight: 5,
orient: 'auto',
style: 'pointer-events:none' // Currently needed for Opera
}
});
const arrow = addElem({
element: 'path',
attr: {
d: data.d,
fill: '#000000'
}
});
marker.append(arrow);
svgCanvas.findDefs().append(marker);
}
marker.setAttribute('refX', data.refx);
return marker;
}
/**
*
* @returns {void}
*/
function setArrow() {
resetMarker();
let type = this.value;
if (type === 'none') {
return;
} // Set marker on element
let dir = 'fw';
if (type === 'mid_bk') {
type = 'mid';
dir = 'bk';
} else if (type === 'both') {
addMarker('bk', type);
svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');
type = 'end';
dir = 'fw';
} else if (type === 'start') {
dir = 'bk';
}
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
svgCanvas.call('changed', selElems);
}
/**
* @param {Element} elem
* @returns {void}
*/
function colorChanged(elem) {
const color = elem.getAttribute('stroke');
const mtypes = ['start', 'mid', 'end'];
const defs = svgCanvas.findDefs();
$.each(mtypes, function (i, type) {
const marker = getLinked(elem, 'marker-' + type);
if (!marker) {
return;
}
const curColor = $(marker).children().attr('fill');
const curD = $(marker).children().attr('d');
if (curColor === color) {
return;
}
const allMarkers = $(defs).find('marker');
let newMarker = null; // Different color, check if already made
allMarkers.each(function () {
const attrs = $(this).children().attr(['fill', 'd']);
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this; // eslint-disable-line consistent-this
}
});
if (!newMarker) {
// Create a new marker with this color
const lastId = marker.id;
const dir = lastId.includes('_fw') ? 'fw' : 'bk';
newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);
$(newMarker).children().attr('fill', color);
}
$(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed
let remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
const element = this; // eslint-disable-line consistent-this
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
});
if (!remove) {
return false;
}
return undefined;
}); // Not found, so can safely remove
if (remove) {
$(marker).remove();
}
});
}
const contextTools = [{
type: 'select',
panel: 'arrow_panel',
id: 'arrow_list',
defval: 'none',
events: {
change: setArrow
}
}];
return {
name: strings.name,
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback() {
$('#arrow_panel').hide(); // Set ID so it can be translated in locale file
$('#arrow_list option')[0].id = 'connector_no_arrow';
},
async addLangData({
lang,
importLocale
}) {
const {
langList
} = await importLocale();
return {
data: langList
};
},
selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
const markerElems = ['line', 'path', 'polyline', 'polygon'];
let i = selElems.length;
while (i--) {
const elem = selElems[i];
if (elem && markerElems.includes(elem.tagName)) {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
},
elementChanged(opts) {
const elem = opts.elems[0];
if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) {
// const start = elem.getAttribute('marker-start');
// const mid = elem.getAttribute('marker-mid');
// const end = elem.getAttribute('marker-end');
// Has marker, so see if it should match color
colorChanged(elem);
}
}
};
} }
}; };
return extArrows; return extArrows;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,42 @@
var svgEditorExtension_eyedropper = (function () { var svgEditorExtension_eyedropper = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-eyedropper.js * @file ext-eyedropper.js
* *
@ -11,151 +47,154 @@ var svgEditorExtension_eyedropper = (function () {
*/ */
var extEyedropper = { var extEyedropper = {
name: 'eyedropper', name: 'eyedropper',
init: function init(S) {
var _this = this;
async init(S) { return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
const strings = await S.importLocale(); var strings, svgEditor, $, ChangeElementCommand, svgCanvas, addToHistory, currentStyle, getStyle, buttons;
const svgEditor = this; return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
getStyle = function _getStyle(opts) {
// if we are in eyedropper mode, we don't want to disable the eye-dropper tool
var mode = svgCanvas.getMode();
const { if (mode === 'eyedropper') {
$, return;
ChangeElementCommand }
} = S,
// , svgcontent,
// svgdoc = S.svgroot.parentNode.ownerDocument,
svgCanvas = svgEditor.canvas,
addToHistory = function (cmd) {
svgCanvas.undoMgr.addCommandToHistory(cmd);
},
currentStyle = {
fillPaint: 'red',
fillOpacity: 1.0,
strokePaint: 'black',
strokeOpacity: 1.0,
strokeWidth: 5,
strokeDashArray: null,
opacity: 1.0,
strokeLinecap: 'butt',
strokeLinejoin: 'miter'
};
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts
* @returns {void}
*/
var tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected
function getStyle(opts) { var elem = null;
// if we are in eyedropper mode, we don't want to disable the eye-dropper tool
const mode = svgCanvas.getMode();
if (mode === 'eyedropper') { if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) {
return; elem = opts.elems[0];
} tool.removeClass('disabled'); // grab the current style
const tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected currentStyle.fillPaint = elem.getAttribute('fill') || 'black';
currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0;
currentStyle.strokePaint = elem.getAttribute('stroke');
currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0;
currentStyle.strokeWidth = elem.getAttribute('stroke-width');
currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray');
currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap');
currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin');
currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool
} else {
tool.addClass('disabled');
}
};
let elem = null; _context.next = 3;
return S.importLocale();
if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) { case 3:
elem = opts.elems[0]; strings = _context.sent;
tool.removeClass('disabled'); // grab the current style svgEditor = _this;
$ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
svgCanvas.undoMgr.addCommandToHistory(cmd);
}, currentStyle = {
fillPaint: 'red',
fillOpacity: 1.0,
strokePaint: 'black',
strokeOpacity: 1.0,
strokeWidth: 5,
strokeDashArray: null,
opacity: 1.0,
strokeLinecap: 'butt',
strokeLinejoin: 'miter'
};
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts
* @returns {void}
*/
currentStyle.fillPaint = elem.getAttribute('fill') || 'black'; buttons = [{
currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0; id: 'tool_eyedropper',
currentStyle.strokePaint = elem.getAttribute('stroke'); icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0; type: 'mode',
currentStyle.strokeWidth = elem.getAttribute('stroke-width'); events: {
currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray'); click: function click() {
currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap'); svgCanvas.setMode('eyedropper');
currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin'); }
currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool }
} else { }];
tool.addClass('disabled'); return _context.abrupt("return", {
} name: strings.name,
} svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
// if we have selected an element, grab its paint and enable the eye dropper button
selectedChanged: getStyle,
elementChanged: getStyle,
mouseDown: function mouseDown(opts) {
var mode = svgCanvas.getMode();
const buttons = [{ if (mode === 'eyedropper') {
id: 'tool_eyedropper', var e = opts.event;
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png', var target = e.target;
type: 'mode',
events: {
click() {
svgCanvas.setMode('eyedropper');
}
} if (!['svg', 'g', 'use'].includes(target.nodeName)) {
}]; var changes = {};
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
// if we have selected an element, grab its paint and enable the eye dropper button
selectedChanged: getStyle,
elementChanged: getStyle,
mouseDown(opts) { var change = function change(elem, attrname, newvalue) {
const mode = svgCanvas.getMode(); changes[attrname] = elem.getAttribute(attrname);
elem.setAttribute(attrname, newvalue);
};
if (mode === 'eyedropper') { if (currentStyle.fillPaint) {
const e = opts.event; change(target, 'fill', currentStyle.fillPaint);
const { }
target
} = e;
if (!['svg', 'g', 'use'].includes(target.nodeName)) { if (currentStyle.fillOpacity) {
const changes = {}; change(target, 'fill-opacity', currentStyle.fillOpacity);
}
const change = function (elem, attrname, newvalue) { if (currentStyle.strokePaint) {
changes[attrname] = elem.getAttribute(attrname); change(target, 'stroke', currentStyle.strokePaint);
elem.setAttribute(attrname, newvalue); }
};
if (currentStyle.fillPaint) { if (currentStyle.strokeOpacity) {
change(target, 'fill', currentStyle.fillPaint); change(target, 'stroke-opacity', currentStyle.strokeOpacity);
} }
if (currentStyle.fillOpacity) { if (currentStyle.strokeWidth) {
change(target, 'fill-opacity', currentStyle.fillOpacity); change(target, 'stroke-width', currentStyle.strokeWidth);
} }
if (currentStyle.strokePaint) { if (currentStyle.strokeDashArray) {
change(target, 'stroke', currentStyle.strokePaint); change(target, 'stroke-dasharray', currentStyle.strokeDashArray);
} }
if (currentStyle.strokeOpacity) { if (currentStyle.opacity) {
change(target, 'stroke-opacity', currentStyle.strokeOpacity); change(target, 'opacity', currentStyle.opacity);
} }
if (currentStyle.strokeWidth) { if (currentStyle.strokeLinecap) {
change(target, 'stroke-width', currentStyle.strokeWidth); change(target, 'stroke-linecap', currentStyle.strokeLinecap);
} }
if (currentStyle.strokeDashArray) { if (currentStyle.strokeLinejoin) {
change(target, 'stroke-dasharray', currentStyle.strokeDashArray); change(target, 'stroke-linejoin', currentStyle.strokeLinejoin);
} }
if (currentStyle.opacity) { addToHistory(new ChangeElementCommand(target, changes));
change(target, 'opacity', currentStyle.opacity); }
} }
}
});
if (currentStyle.strokeLinecap) { case 8:
change(target, 'stroke-linecap', currentStyle.strokeLinecap); case "end":
} return _context.stop();
if (currentStyle.strokeLinejoin) {
change(target, 'stroke-linejoin', currentStyle.strokeLinejoin);
}
addToHistory(new ChangeElementCommand(target, changes));
} }
} }
} }, _callee);
}))();
};
} }
}; };
return extEyedropper; return extEyedropper;

View File

@ -1,6 +1,42 @@
var svgEditorExtension_foreignobject = (function () { var svgEditorExtension_foreignobject = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-foreignobject.js * @file ext-foreignobject.js
* *
@ -11,305 +47,315 @@ var svgEditorExtension_foreignobject = (function () {
*/ */
var extForeignobject = { var extForeignobject = {
name: 'foreignobject', name: 'foreignobject',
init: function init(S) {
var _this = this;
async init(S) { return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
const svgEditor = this; var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
const { return regeneratorRuntime.wrap(function _callee2$(_context2) {
$, while (1) {
text2xml, switch (_context2.prev = _context2.next) {
NS, case 0:
importLocale setAttr = function _setAttr(attr, val) {
} = S; svgCanvas.changeSelectedAttribute(attr, val);
const svgCanvas = svgEditor.canvas; svgCanvas.call('changed', selElems);
const // {svgcontent} = S, };
// addElem = svgCanvas.addSVGElementFromJson,
svgdoc = S.svgroot.parentNode.ownerDocument;
const strings = await importLocale();
const properlySourceSizeTextArea = function () { showForeignEditor = function _showForeignEditor() {
// TODO: remove magic numbers here and get values from CSS var elt = selElems[0];
const height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height); if (!elt || editingforeign) {
}; return;
/** }
* @param {boolean} on
* @returns {void} editingforeign = true;
*/ toggleSourceButtons(true);
elt.removeAttribute('fill');
var str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
$('#svg_source_textarea').focus();
};
setForeignString = function _setForeignString(xmlString) {
var elt = selElems[0]; // The parent `Element` to append to
try {
// convert string into XML document
var newDoc = text2xml('<svg xmlns="' + NS.SVG + '" xmlns:xlink="' + NS.XLINK + '">' + xmlString + '</svg>'); // 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.clearSelection();
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false;
}
return true;
};
toggleSourceButtons = function _toggleSourceButtons(on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on);
};
showPanel = function _showPanel(on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#foreignObject_panel').toggle(on);
};
svgEditor = _this;
$ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
svgCanvas = svgEditor.canvas;
svgdoc = S.svgroot.parentNode.ownerDocument;
_context2.next = 11;
return importLocale();
case 11:
strings = _context2.sent;
properlySourceSizeTextArea = function properlySourceSizeTextArea() {
// TODO: remove magic numbers here and get values from CSS
var height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height);
};
/**
* @param {boolean} on
* @returns {void}
*/
function showPanel(on) { editingforeign = false;
let fcRules = $('#fc_rules'); /**
* This function sets the content of element elt to the input XML.
* @param {string} xmlString - The XML text
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
if (!fcRules.length) { buttons = [{
fcRules = $('<style id="fc_rules"></style>').appendTo('head'); id: 'tool_foreign',
} icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('foreign');
}
}
}, {
id: 'edit_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png',
type: 'context',
panel: 'foreignObject_panel',
events: {
click: function click() {
showForeignEditor();
}
}
}];
contextTools = [{
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_width',
size: 3,
events: {
change: function change() {
setAttr('width', this.value);
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_height',
events: {
change: function change() {
setAttr('height', this.value);
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_font_size',
size: 2,
defval: 16,
events: {
change: function change() {
setAttr('font-size', this.value);
}
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#foreignObject_panel').hide();
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }'); var endChanges = function endChanges() {
$('#foreignObject_panel').toggle(on); $('#svg_source_editor').hide();
} editingforeign = false;
/** $('#svg_source_textarea').blur();
* @param {boolean} on toggleSourceButtons(false);
* @returns {void} }; // TODO: Needs to be done after orig icon loads
*/
function toggleSourceButtons(on) { setTimeout(function () {
$('#tool_source_save, #tool_source_cancel').toggle(!on); // Create source save/cancel buttons
$('#foreign_save, #foreign_cancel').toggle(on);
}
let selElems, /* const save = */
started, $('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
newFO, var ok;
editingforeign = false; return regeneratorRuntime.wrap(function _callee$(_context) {
/** while (1) {
* This function sets the content of element elt to the input XML. switch (_context.prev = _context.next) {
* @param {string} xmlString - The XML text case 0:
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. if (editingforeign) {
*/ _context.next = 2;
break;
}
function setForeignString(xmlString) { return _context.abrupt("return");
const elt = selElems[0]; // The parent `Element` to append to
try { case 2:
// convert string into XML document if (setForeignString($('#svg_source_textarea').val())) {
const newDoc = text2xml('<svg xmlns="' + NS.SVG + '" xmlns:xlink="' + NS.XLINK + '">' + xmlString + '</svg>'); // run it through our sanitizer to remove anything we do not support _context.next = 11;
break;
}
svgCanvas.sanitizeSvg(newDoc.documentElement); _context.next = 5;
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true)); return $.confirm('Errors found. Revert to original?');
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false; case 5:
} ok = _context.sent;
return true; if (ok) {
} _context.next = 8;
/** break;
* }
* @returns {void}
*/
return _context.abrupt("return");
function showForeignEditor() { case 8:
const elt = selElems[0]; endChanges();
_context.next = 12;
break;
if (!elt || editingforeign) { case 11:
return; endChanges();
}
editingforeign = true; case 12:
toggleSourceButtons(true); case "end":
elt.removeAttribute('fill'); return _context.stop();
const str = svgCanvas.svgToString(elt, 0); }
$('#svg_source_textarea').val(str); }
$('#svg_source_editor').fadeIn(); }, _callee);
properlySourceSizeTextArea(); })));
$('#svg_source_textarea').focus(); /* const cancel = */
}
/**
* @param {string} attr
* @param {string|Float} val
* @returns {void}
*/
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign') {
return undefined;
}
function setAttr(attr, val) { started = true;
svgCanvas.changeSelectedAttribute(attr, val); newFO = svgCanvas.addSVGElementFromJson({
svgCanvas.call('changed', selElems); element: 'foreignObject',
} attr: {
x: opts.start_x,
y: opts.start_y,
id: svgCanvas.getNextId(),
'font-size': 16,
// cur_text.font_size,
width: '48',
height: '20',
style: 'pointer-events:inherit'
}
});
var m = svgdoc.createElementNS(NS.MATH, 'math');
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
m.setAttribute('display', 'inline');
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
mi.setAttribute('mathvariant', 'normal');
mi.textContent = "\u03A6";
var mo = svgdoc.createElementNS(NS.MATH, 'mo');
mo.textContent = "\u222A";
var mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
mi2.textContent = "\u2133";
m.append(mi, mo, mi2);
newFO.append(m);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign' || !started) {
return undefined;
}
const buttons = [{ var attrs = $(newFO).attr(['width', 'height']);
id: 'tool_foreign', var keep = attrs.width !== '0' || attrs.height !== '0';
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png', svgCanvas.addToSelection([newFO], true);
type: 'mode', return {
events: { keep: keep,
click() { element: newFO
svgCanvas.setMode('foreign'); };
} },
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
} while (i--) {
}, { var elem = selElems[i];
id: 'edit_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png',
type: 'context',
panel: 'foreignObject_panel',
events: {
click() {
showForeignEditor();
}
} if (elem && elem.tagName === 'foreignObject') {
}]; if (opts.selectedElement && !opts.multiselected) {
const contextTools = [{ $('#foreign_font_size').val(elem.getAttribute('font-size'));
type: 'input', $('#foreign_width').val(elem.getAttribute('width'));
panel: 'foreignObject_panel', $('#foreign_height').val(elem.getAttribute('height'));
id: 'foreign_width', showPanel(true);
size: 3, } else {
events: { showPanel(false);
change() { }
setAttr('width', this.value); } else {
} showPanel(false);
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
} case 17:
}, { case "end":
type: 'input', return _context2.stop();
panel: 'foreignObject_panel',
id: 'foreign_height',
events: {
change() {
setAttr('height', this.value);
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_font_size',
size: 2,
defval: 16,
events: {
change() {
setAttr('font-size', this.value);
}
}
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback() {
$('#foreignObject_panel').hide();
const endChanges = function () {
$('#svg_source_editor').hide();
editingforeign = false;
$('#svg_source_textarea').blur();
toggleSourceButtons(false);
}; // 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', 'foreign_save').unbind().appendTo('#tool_source_back').click(async function () {
if (!editingforeign) {
return;
}
if (!setForeignString($('#svg_source_textarea').val())) {
const ok = await $.confirm('Errors found. Revert to original?');
if (!ok) {
return;
}
endChanges();
} else {
endChanges();
} // setSelectMode();
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign') {
return undefined;
}
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
attr: {
x: opts.start_x,
y: opts.start_y,
id: svgCanvas.getNextId(),
'font-size': 16,
// cur_text.font_size,
width: '48',
height: '20',
style: 'pointer-events:inherit'
}
});
const m = svgdoc.createElementNS(NS.MATH, 'math');
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
m.setAttribute('display', 'inline');
const mi = svgdoc.createElementNS(NS.MATH, 'mi');
mi.setAttribute('mathvariant', 'normal');
mi.textContent = '\u03A6';
const mo = svgdoc.createElementNS(NS.MATH, 'mo');
mo.textContent = '\u222A';
const mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
mi2.textContent = '\u2133';
m.append(mi, mo, mi2);
newFO.append(m);
return {
started: true
};
},
mouseUp(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign' || !started) {
return undefined;
}
const attrs = $(newFO).attr(['width', 'height']);
const keep = attrs.width !== '0' || attrs.height !== '0';
svgCanvas.addToSelection([newFO], true);
return {
keep,
element: newFO
};
},
selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
let i = selElems.length;
while (i--) {
const elem = selElems[i];
if (elem && elem.tagName === 'foreignObject') {
if (opts.selectedElement && !opts.multiselected) {
$('#foreign_font_size').val(elem.getAttribute('font-size'));
$('#foreign_width').val(elem.getAttribute('width'));
$('#foreign_height').val(elem.getAttribute('height'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
} }
} }
}, }, _callee2);
}))();
elementChanged(opts) {// const elem = opts.elems[0];
}
};
} }
}; };
return extForeignobject; return extForeignobject;

View File

@ -1,6 +1,42 @@
var svgEditorExtension_grid = (function () { var svgEditorExtension_grid = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-grid.js * @file ext-grid.js
* *
@ -11,177 +47,174 @@ var svgEditorExtension_grid = (function () {
*/ */
var extGrid = { var extGrid = {
name: 'grid', name: 'grid',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
$, var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridDefs, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
NS, return regeneratorRuntime.wrap(function _callee$(_context) {
getTypeMap, while (1) {
importLocale switch (_context.prev = _context.next) {
}) { case 0:
const strings = await importLocale(); gridUpdate = function _gridUpdate() {
const svgEditor = this; if (showGrid) {
const svgCanvas = svgEditor.canvas; updateGrid(svgCanvas.getZoom());
const svgdoc = document.getElementById('svgcanvas').ownerDocument, }
{
assignAttributes
} = svgCanvas,
hcanvas = document.createElement('canvas'),
canvBG = $('#canvasBackground'),
units = getTypeMap(),
// Assumes prior `init()` call on `units.js` module
intervals = [0.01, 0.1, 1, 10, 100, 1000];
let showGrid = svgEditor.curConfig.showGrid || false;
$(hcanvas).hide().appendTo('body');
const canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');
assignAttributes(canvasGrid, {
id: 'canvasGrid',
width: '100%',
height: '100%',
x: 0,
y: 0,
overflow: 'visible',
display: 'none'
});
canvBG.append(canvasGrid);
const gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern
const gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern'); $('#canvasGrid').toggle(showGrid);
assignAttributes(gridPattern, { $('#view_grid').toggleClass('push_button_pressed tool_button');
id: 'gridpattern', };
patternUnits: 'userSpaceOnUse',
x: 0,
// -(value.strokeWidth / 2), // position for strokewidth
y: 0,
// -(value.strokeWidth / 2), // position for strokewidth
width: 100,
height: 100
});
const gridimg = svgdoc.createElementNS(NS.SVG, 'image');
assignAttributes(gridimg, {
x: 0,
y: 0,
width: 100,
height: 100
});
gridPattern.append(gridimg);
gridDefs.append(gridPattern);
$('#canvasGrid').append(gridDefs); // grid-box
const gridBox = svgdoc.createElementNS(NS.SVG, 'rect'); updateGrid = function _updateGrid(zoom) {
assignAttributes(gridBox, { // TODO: Try this with <line> elements, then compare performance difference
width: '100%', var unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px
height: '100%',
x: 0,
y: 0,
'stroke-width': 0,
stroke: 'none',
fill: 'url(#gridpattern)',
style: 'pointer-events: none; display:visible;'
});
$('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {void}
*/
function updateGrid(zoom) { var uMulti = unit * zoom; // Calculate the main number interval
// TODO: Try this with <line> elements, then compare performance difference
const unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px
const uMulti = unit * zoom; // Calculate the main number interval var rawM = 100 / uMulti;
var multi = 1;
intervals.some(function (num) {
multi = num;
return rawM <= num;
});
var bigInt = multi * uMulti; // Set the canvas size to the width of the container
const rawM = 100 / uMulti; hcanvas.width = bigInt;
let multi = 1; hcanvas.height = bigInt;
intervals.some(num => { var ctx = hcanvas.getContext('2d');
multi = num; var curD = 0.5;
return rawM <= num; var part = bigInt / 10;
}); ctx.globalAlpha = 0.2;
const bigInt = multi * uMulti; // Set the canvas size to the width of the container ctx.strokeStyle = svgEditor.curConfig.gridColor;
hcanvas.width = bigInt; for (var i = 1; i < 10; i++) {
hcanvas.height = bigInt; var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10;
const ctx = hcanvas.getContext('2d');
const curD = 0.5;
const part = bigInt / 10;
ctx.globalAlpha = 0.2;
ctx.strokeStyle = svgEditor.curConfig.gridColor;
for (let i = 1; i < 10; i++) { var lineNum = 0;
const subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10; ctx.moveTo(subD, bigInt);
ctx.lineTo(subD, lineNum);
ctx.moveTo(bigInt, subD);
ctx.lineTo(lineNum, subD);
}
const lineNum = 0; ctx.stroke();
ctx.moveTo(subD, bigInt); ctx.beginPath();
ctx.lineTo(subD, lineNum); ctx.globalAlpha = 0.5;
ctx.moveTo(bigInt, subD); ctx.moveTo(curD, bigInt);
ctx.lineTo(lineNum, subD); ctx.lineTo(curD, 0);
} ctx.moveTo(bigInt, curD);
ctx.lineTo(0, curD);
ctx.stroke();
var datauri = hcanvas.toDataURL('image/png');
gridimg.setAttribute('width', bigInt);
gridimg.setAttribute('height', bigInt);
gridimg.parentNode.setAttribute('width', bigInt);
gridimg.parentNode.setAttribute('height', bigInt);
svgCanvas.setHref(gridimg, datauri);
};
ctx.stroke(); $ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
ctx.beginPath(); _context.next = 5;
ctx.globalAlpha = 0.5; return importLocale();
ctx.moveTo(curD, bigInt);
ctx.lineTo(curD, 0);
ctx.moveTo(bigInt, curD);
ctx.lineTo(0, curD);
ctx.stroke();
const datauri = hcanvas.toDataURL('image/png');
gridimg.setAttribute('width', bigInt);
gridimg.setAttribute('height', bigInt);
gridimg.parentNode.setAttribute('width', bigInt);
gridimg.parentNode.setAttribute('height', bigInt);
svgCanvas.setHref(gridimg, datauri);
}
/**
*
* @returns {void}
*/
case 5:
strings = _context.sent;
svgEditor = _this;
svgCanvas = svgEditor.canvas;
svgdoc = document.getElementById('svgcanvas').ownerDocument, assignAttributes = svgCanvas.assignAttributes, hcanvas = document.createElement('canvas'), canvBG = $('#canvasBackground'), units = getTypeMap(), intervals = [0.01, 0.1, 1, 10, 100, 1000];
showGrid = svgEditor.curConfig.showGrid || false;
$(hcanvas).hide().appendTo('body');
canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');
assignAttributes(canvasGrid, {
id: 'canvasGrid',
width: '100%',
height: '100%',
x: 0,
y: 0,
overflow: 'visible',
display: 'none'
});
canvBG.append(canvasGrid);
gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern
function gridUpdate() { gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern');
if (showGrid) { assignAttributes(gridPattern, {
updateGrid(svgCanvas.getZoom()); id: 'gridpattern',
} patternUnits: 'userSpaceOnUse',
x: 0,
// -(value.strokeWidth / 2), // position for strokewidth
y: 0,
// -(value.strokeWidth / 2), // position for strokewidth
width: 100,
height: 100
});
gridimg = svgdoc.createElementNS(NS.SVG, 'image');
assignAttributes(gridimg, {
x: 0,
y: 0,
width: 100,
height: 100
});
gridPattern.append(gridimg);
gridDefs.append(gridPattern);
$('#canvasGrid').append(gridDefs); // grid-box
$('#canvasGrid').toggle(showGrid); gridBox = svgdoc.createElementNS(NS.SVG, 'rect');
$('#view_grid').toggleClass('push_button_pressed tool_button'); assignAttributes(gridBox, {
} width: '100%',
height: '100%',
x: 0,
y: 0,
'stroke-width': 0,
stroke: 'none',
fill: 'url(#gridpattern)',
style: 'pointer-events: none; display:visible;'
});
$('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {void}
*/
const buttons = [{ buttons = [{
id: 'view_grid', id: 'view_grid',
icon: svgEditor.curConfig.extIconsPath + 'grid.png', icon: svgEditor.curConfig.extIconsPath + 'grid.png',
type: 'context', type: 'context',
panel: 'editor_panel', panel: 'editor_panel',
events: { events: {
click() { click: function click() {
svgEditor.curConfig.showGrid = showGrid = !showGrid; svgEditor.curConfig.showGrid = showGrid = !showGrid;
gridUpdate(); gridUpdate();
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',
zoomChanged: function zoomChanged(zoom) {
if (showGrid) {
updateGrid(zoom);
}
},
callback: function callback() {
if (showGrid) {
gridUpdate();
}
},
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
case 27:
case "end":
return _context.stop();
}
} }
}, _callee);
} }))();
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',
zoomChanged(zoom) {
if (showGrid) {
updateGrid(zoom);
}
},
callback() {
if (showGrid) {
gridUpdate();
}
},
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
})
};
} }
}; };
return extGrid; return extGrid;

View File

@ -1,6 +1,98 @@
var svgEditorExtension_helloworld = (function () { var svgEditorExtension_helloworld = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/** /**
* @file ext-helloworld.js * @file ext-helloworld.js
* *
@ -17,82 +109,95 @@ var svgEditorExtension_helloworld = (function () {
*/ */
var extHelloworld = { var extHelloworld = {
name: 'helloworld', name: 'helloworld',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
$, var $, importLocale, strings, svgEditor, svgCanvas;
importLocale return regeneratorRuntime.wrap(function _callee$(_context) {
}) { while (1) {
// See `/editor/extensions/ext-locale/helloworld/` switch (_context.prev = _context.next) {
const strings = await importLocale(); case 0:
const svgEditor = this; $ = _ref.$, importLocale = _ref.importLocale;
const svgCanvas = svgEditor.canvas; _context.next = 3;
return { return importLocale();
name: strings.name,
// For more notes on how to make an icon file, see the source of case 3:
// the helloworld-icon.xml strings = _context.sent;
svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml', svgEditor = _this;
// Multiple buttons can be added in this array svgCanvas = svgEditor.canvas;
buttons: [{ return _context.abrupt("return", {
// Must match the icon ID in helloworld-icon.xml name: strings.name,
id: 'hello_world', // For more notes on how to make an icon file, see the source of
// Fallback, e.g., for `file:///` access // the helloworld-icon.xml
icon: svgEditor.curConfig.extIconsPath + 'helloworld.png', svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml',
// This indicates that the button will be added to the "mode" // Multiple buttons can be added in this array
// button panel on the left side buttons: [{
type: 'mode', // Must match the icon ID in helloworld-icon.xml
// Tooltip text id: 'hello_world',
title: strings.buttons[0].title, // Fallback, e.g., for `file:///` access
// Events icon: svgEditor.curConfig.extIconsPath + 'helloworld.png',
events: { // This indicates that the button will be added to the "mode"
click() { // button panel on the left side
// The action taken when the button is clicked on. type: 'mode',
// For "mode" buttons, any other button will // Tooltip text
// automatically be de-pressed. title: strings.buttons[0].title,
svgCanvas.setMode('hello_world'); // Events
events: {
click: function click() {
// The action taken when the button is clicked on.
// For "mode" buttons, any other button will
// 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: function mouseDown() {
// Check the mode on mousedown
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 undefined;
},
// This is triggered from anywhere, but "started" must have been set
// to true (see above). Note that "opts" is an object with event info
mouseUp: function mouseUp(opts) {
// Check the mode on mouseup
if (svgCanvas.getMode() === 'hello_world') {
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom; // We do our own formatting
var text = strings.text;
[['x', x], ['y', y]].forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
prop = _ref3[0],
val = _ref3[1];
text = text.replace('{' + prop + '}', val);
}); // Show the text using the custom alert function
$.alert(text);
}
}
});
case 7:
case "end":
return _context.stop();
} }
} }
}], }, _callee);
}))();
// This is triggered when the main mouse button is pressed down
// on the editor canvas (not the tool panels)
mouseDown() {
// Check the mode on mousedown
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 undefined;
},
// This is triggered from anywhere, but "started" must have been set
// to true (see above). Note that "opts" is an object with event info
mouseUp(opts) {
// Check the mode on mouseup
if (svgCanvas.getMode() === 'hello_world') {
const zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
const x = opts.mouse_x / zoom;
const y = opts.mouse_y / zoom; // We do our own formatting
let {
text
} = strings;
[['x', x], ['y', y]].forEach(([prop, val]) => {
text = text.replace('{' + prop + '}', val);
}); // Show the text using the custom alert function
$.alert(text);
}
}
};
} }
}; };
return extHelloworld; return extHelloworld;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,42 @@
var svgEditorExtension_mathjax = (function () { var svgEditorExtension_mathjax = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* Add any of the whitelisted attributes to the script tag. * Add any of the whitelisted attributes to the script tag.
* @param {HTMLScriptElement} script * @param {HTMLScriptElement} script
@ -10,38 +46,32 @@ var svgEditorExtension_mathjax = (function () {
function addScriptAtts(script, atts) { function addScriptAtts(script, atts) {
['id', 'class', 'type'].forEach(prop => { ['id', 'class', 'type'].forEach(function (prop) {
if (prop in atts) { if (prop in atts) {
script[prop] = atts[prop]; script[prop] = atts[prop];
} }
}); });
} // Additions by Brett } // Additions by Brett
/**
*
* @author Brett Zamir (other items are from `dynamic-import-polyfill`)
* @param {string|string[]} url
* @param {PlainObject} [atts={}]
* @returns {Promise<void|Error>} Resolves to `undefined` or rejects with an `Error` upon a
* script loading error
*/
function importScript(url, atts = {}) { function importScript(url) {
var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (Array.isArray(url)) { if (Array.isArray(url)) {
return Promise.all(url.map(u => { return Promise.all(url.map(function (u) {
return importScript(u, atts); return importScript(u, atts);
})); }));
} }
return new Promise((resolve, reject) => { return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new // eslint-disable-line promise/avoid-new
const script = document.createElement('script'); var script = document.createElement('script');
/** /**
* *
* @returns {void} * @returns {void}
*/ */
function scriptOnError() { function scriptOnError() {
reject(new Error(`Failed to import: ${url}`)); reject(new Error("Failed to import: ".concat(url)));
destructor(); destructor();
} }
/** /**
@ -55,7 +85,7 @@ var svgEditorExtension_mathjax = (function () {
destructor(); destructor();
} }
const destructor = () => { var destructor = function destructor() {
script.removeEventListener('error', scriptOnError); script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad); script.removeEventListener('load', scriptOnLoad);
script.remove(); script.remove();
@ -71,232 +101,258 @@ var svgEditorExtension_mathjax = (function () {
}); });
} }
/* globals MathJax */
var extMathjax = { var extMathjax = {
name: 'mathjax', name: 'mathjax',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
$, var $, importLocale, strings, svgEditor, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
importLocale return regeneratorRuntime.wrap(function _callee2$(_context2) {
}) { while (1) {
const strings = await importLocale(); switch (_context2.prev = _context2.next) {
const svgEditor = this; case 0:
const svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention. saveMath = function _saveMath() {
// This will be added to the head tag before MathJax is loaded. var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
// less fancy!
const MathJax.Hub.queue.Push(['Text', math, '\\displaystyle{' + code + '}']);
/* mathjaxConfiguration = `<script type="text/x-mathjax-config"> /*
MathJax.Hub.Config({ * The MathJax library doesn't want to bloat your webpage so it creates
extensions: ['tex2jax.js'], * every symbol (glymph) you need only once. These are saved in a `<svg>` on
jax: ['input/TeX', 'output/SVG'], * the top of your html document, just under the body tag. Each glymph has
showProcessingMessages: true, * its unique id and is saved as a `<path>` in the `<defs>` tag of the `<svg>`
showMathMenu: false, *
showMathMenuMSIE: false, * Then when the symbols are needed in the rest of your html document they
errorSettings: { * are refferd to by a `<use>` tag.
message: ['[Math Processing Error]'], * Because of bug 1076 we can't just grab the defs tag on the top and add it
style: {color: '#CC0000', 'font-style': 'italic'} * to your formula's `<svg>` and copy the lot. So we have to replace each
}, * `<use>` tag by its `<path>`.
elements: [], */
tex2jax: {
ignoreClass: 'tex2jax_ignore2', processClass: 'tex2jax_process2',
},
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
},
SVG: {
}
});
</script>`, */
// 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
mathjaxSrcSecure = 'mathjax/MathJax.min.js?config=TeX-AMS-MML_SVG.js',
{
uiStrings
} = svgEditor;
let math,
locationX,
locationY,
mathjaxLoaded = false; // TODO: Implement language support. Move these uiStrings to the locale files and
// the code to the langReady callback. Also i18nize alert and HTML below
$.extend(uiStrings, { MathJax.Hub.queue.Push(function () {
mathjax: { var mathjaxMath = $('.MathJax_SVG');
embed_svg: 'Save as mathematics', var svg = $(mathjaxMath.html());
embed_mathml: 'Save as figure', svg.find('use').each(function () {
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. ', // TODO: find a less pragmatic and more elegant solution to this.
mathml_save_warning: 'Advised. The math will be saved as a figure.', var id = $(this).attr('href') ? $(this).attr('href').slice(1) // Works in Chrome.
title: 'Mathematics code editor' : $(this).attr('xlink:href').slice(1); // Works in Firefox.
}
});
/**
*
* @returns {void}
*/
function saveMath() { var glymph = $('#' + id).clone().removeAttr('id');
const code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is var x = $(this).attr('x');
// less fancy! var y = $(this).attr('y');
var transform = $(this).attr('transform');
MathJax.Hub.queue.Push(['Text', math, '\\displaystyle{' + code + '}']); if (transform && (x || y)) {
/* glymph.attr('transform', transform + ' translate(' + x + ',' + y + ')');
* The MathJax library doesn't want to bloat your webpage so it creates } else if (transform) {
* every symbol (glymph) you need only once. These are saved in a `<svg>` on glymph.attr('transform', transform);
* the top of your html document, just under the body tag. Each glymph has } else if (x || y) {
* its unique id and is saved as a `<path>` in the `<defs>` tag of the `<svg>` glymph.attr('transform', 'translate(' + x + ',' + y + ')');
* }
* Then when the symbols are needed in the rest of your html document they
* are refferd to by a `<use>` tag.
* Because of bug 1076 we can't just grab the defs tag on the top and add it
* to your formula's `<svg>` and copy the lot. So we have to replace each
* `<use>` tag by its `<path>`.
*/
MathJax.Hub.queue.Push(function () { $(this).replaceWith(glymph);
const mathjaxMath = $('.MathJax_SVG'); }); // Remove the style tag because it interferes with SVG-Edit.
const svg = $(mathjaxMath.html());
svg.find('use').each(function () {
// TODO: find a less pragmatic and more elegant solution to this.
const id = $(this).attr('href') ? $(this).attr('href').slice(1) // Works in Chrome.
: $(this).attr('xlink:href').slice(1); // Works in Firefox.
const glymph = $('#' + id).clone().removeAttr('id'); svg.removeAttr('style');
const x = $(this).attr('x'); svg.attr('xmlns', 'http://www.w3.org/2000/svg');
const y = $(this).attr('y'); svgCanvas.importSvgString($('<div>').append(svg.clone()).html(), true);
const transform = $(this).attr('transform'); svgCanvas.ungroupSelectedElement(); // TODO: To undo the adding of the Formula you now have to undo twice.
// This should only be once!
if (transform && (x || y)) { svgCanvas.moveSelectedElements(locationX, locationY, true);
glymph.attr('transform', transform + ' translate(' + x + ',' + y + ')'); });
} else if (transform) { };
glymph.attr('transform', transform);
} else if (x || y) {
glymph.attr('transform', 'translate(' + x + ',' + y + ')');
}
$(this).replaceWith(glymph); $ = _ref.$, importLocale = _ref.importLocale;
}); // Remove the style tag because it interferes with SVG-Edit. _context2.next = 4;
return importLocale();
svg.removeAttr('style'); case 4:
svg.attr('xmlns', 'http://www.w3.org/2000/svg'); strings = _context2.sent;
svgCanvas.importSvgString($('<div>').append(svg.clone()).html(), true); svgEditor = _this;
svgCanvas.ungroupSelectedElement(); // TODO: To undo the adding of the Formula you now have to undo twice. svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention.
// This should only be once! // This will be added to the head tag before MathJax is loaded.
svgCanvas.moveSelectedElements(locationX, locationY, true); /* mathjaxConfiguration = `<script type="text/x-mathjax-config">
}); MathJax.Hub.Config({
} extensions: ['tex2jax.js'],
jax: ['input/TeX', 'output/SVG'],
const buttons = [{ showProcessingMessages: true,
id: 'tool_mathjax', showMathMenu: false,
type: 'mode', showMathMenuMSIE: false,
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png', errorSettings: {
events: { message: ['[Math Processing Error]'],
async click() { style: {color: '#CC0000', 'font-style': 'italic'}
// Set the mode. },
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more. elements: [],
// From this point on it is very probable that it will be needed, so load it. tex2jax: {
ignoreClass: 'tex2jax_ignore2', processClass: 'tex2jax_process2',
if (mathjaxLoaded === false) { },
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable. TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
$('#mathjax_container').draggable({ },
cancel: 'button,fieldset', SVG: {
containment: 'window' }
}); // Add functionality and picture to cancel button.
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
$('#mathjax').hide();
}); // Add functionality and picture to the save button.
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
saveMath();
$('#mathjax').hide();
}); // MathJax preprocessing has to ignore most of the page.
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
// Todo: insert script with modules once widely supported
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
/*
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
// Add as second argument to `importScript`
{
type: modularVersion
? 'module' // Make this the default when widely supported
: 'text/javascript'
}
// If only using modules, just use this:
const {default: MathJax} = await importModule( // or `import()` when widely supported
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
);
*/
// We use `extIconsPath` here for now as it does not vary with
// the modular type as does `extPath`
try {
await importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure); // 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); // eslint-disable-line no-console
mathjaxLoaded = true;
console.log('MathJax Loaded'); // eslint-disable-line no-console
}); });
} catch (e) { </script>`, */
console.log('Failed loading MathJax.'); // eslint-disable-line no-console // 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
mathjaxSrcSecure = 'mathjax/MathJax.min.js?config=TeX-AMS-MML_SVG.js', uiStrings = svgEditor.uiStrings;
mathjaxLoaded = false; // TODO: Implement language support. Move these uiStrings to the locale files and
// the code to the langReady callback. Also i18nize alert and HTML below
$.alert('Failed loading MathJax. You will not be able to change the mathematics.'); $.extend(uiStrings, {
} 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. ',
mathml_save_warning: 'Advised. The math will be saved as a figure.',
title: 'Mathematics code editor'
}
});
/**
*
* @returns {void}
*/
buttons = [{
id: 'tool_mathjax',
type: 'mode',
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
events: {
click: function click() {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
// Set the mode.
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.
// From this point on it is very probable that it will be needed, so load it.
if (!(mathjaxLoaded === false)) {
_context.next = 17;
break;
}
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('#mathjax_container').draggable({
cancel: 'button,fieldset',
containment: 'window'
}); // Add functionality and picture to cancel button.
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
$('#mathjax').hide();
}); // Add functionality and picture to the save button.
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
saveMath();
$('#mathjax').hide();
}); // MathJax preprocessing has to ignore most of the page.
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
// Todo: insert script with modules once widely supported
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
/*
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
// Add as second argument to `importScript`
{
type: modularVersion
? 'module' // Make this the default when widely supported
: 'text/javascript'
}
// If only using modules, just use this:
const {default: MathJax} = await importModule( // or `import()` when widely supported
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
);
*/
// We use `extIconsPath` here for now as it does not vary with
// the modular type as does `extPath`
_context.prev = 7;
_context.next = 10;
return importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure);
case 10:
// 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); // eslint-disable-line no-console
mathjaxLoaded = true;
console.log('MathJax Loaded'); // eslint-disable-line no-console
});
_context.next = 17;
break;
case 13:
_context.prev = 13;
_context.t0 = _context["catch"](7);
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
case 17:
case "end":
return _context.stop();
}
}
}, _callee, null, [[7, 13]]);
}))();
}
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'mathjax') {
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() === 'mathjax') {
// Get the coordinates from your mouse.
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
locationX = opts.mouse_x / zoom;
locationY = opts.mouse_y / zoom;
$('#mathjax').show();
return {
started: false
}; // Otherwise the last selected object dissapears.
}
return undefined;
},
callback: function callback() {
$('<style>').text('#mathjax fieldset{' + 'padding: 5px;' + 'margin: 5px;' + 'border: 1px solid #DDD;' + '}' + '#mathjax label{' + 'display: block;' + 'margin: .5em;' + '}' + '#mathjax legend {' + 'max-width:195px;' + '}' + '#mathjax_overlay {' + 'position: absolute;' + 'top: 0;' + 'left: 0;' + 'right: 0;' + 'bottom: 0;' + 'background-color: black;' + 'opacity: 0.6;' + 'z-index: 20000;' + '}' + '#mathjax_container {' + 'position: absolute;' + 'top: 50px;' + 'padding: 10px;' + 'background-color: #B0B0B0;' + 'border: 1px outset #777;' + 'opacity: 1.0;' + 'font-family: Verdana, Helvetica, sans-serif;' + 'font-size: .8em;' + 'z-index: 20001;' + '}' + '#tool_mathjax_back {' + 'margin-left: 1em;' + 'overflow: auto;' + '}' + '#mathjax_legend{' + 'font-weight: bold;' + 'font-size:1.1em;' + '}' + '#mathjax_code_textarea {\\n' + 'margin: 5px .7em;' + 'overflow: hidden;' + 'width: 416px;' + 'display: block;' + 'height: 100px;' + '}').appendTo('head'); // Add the MathJax configuration.
// $(mathjaxConfiguration).appendTo('head');
}
});
case 12:
case "end":
return _context2.stop();
} }
} }
}, _callee2);
} }))();
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
mouseDown() {
if (svgCanvas.getMode() === 'mathjax') {
return {
started: true
};
}
return undefined;
},
mouseUp(opts) {
if (svgCanvas.getMode() === 'mathjax') {
// Get the coordinates from your mouse.
const zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
locationX = opts.mouse_x / zoom;
locationY = opts.mouse_y / zoom;
$('#mathjax').show();
return {
started: false
}; // Otherwise the last selected object dissapears.
}
return undefined;
},
callback() {
$('<style>').text('#mathjax fieldset{' + 'padding: 5px;' + 'margin: 5px;' + 'border: 1px solid #DDD;' + '}' + '#mathjax label{' + 'display: block;' + 'margin: .5em;' + '}' + '#mathjax legend {' + 'max-width:195px;' + '}' + '#mathjax_overlay {' + 'position: absolute;' + 'top: 0;' + 'left: 0;' + 'right: 0;' + 'bottom: 0;' + 'background-color: black;' + 'opacity: 0.6;' + 'z-index: 20000;' + '}' + '#mathjax_container {' + 'position: absolute;' + 'top: 50px;' + 'padding: 10px;' + 'background-color: #B0B0B0;' + 'border: 1px outset #777;' + 'opacity: 1.0;' + 'font-family: Verdana, Helvetica, sans-serif;' + 'font-size: .8em;' + 'z-index: 20001;' + '}' + '#tool_mathjax_back {' + 'margin-left: 1em;' + 'overflow: auto;' + '}' + '#mathjax_legend{' + 'font-weight: bold;' + 'font-size:1.1em;' + '}' + '#mathjax_code_textarea {\\n' + 'margin: 5px .7em;' + 'overflow: hidden;' + 'width: 416px;' + 'display: block;' + 'height: 100px;' + '}').appendTo('head'); // Add the MathJax configuration.
// $(mathjaxConfiguration).appendTo('head');
}
};
} }
}; };
return extMathjax; return extMathjax;

View File

@ -11,18 +11,16 @@ var svgEditorExtension_overview_window = (function () {
*/ */
var extOverview_window = { var extOverview_window = {
name: 'overview_window', name: 'overview_window',
init: function init(_ref) {
init({ var $ = _ref.$,
$, isChrome = _ref.isChrome,
isChrome, isIE = _ref.isIE;
isIE var overviewWindowGlobals = {}; // Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and
}) {
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. // https://code.google.com/p/chromium/issues/detail?id=565120.
if (isChrome()) { if (isChrome()) {
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7; var verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
const chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex)); var chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) { if (chromeVersion < 49) {
return undefined; return undefined;
@ -30,22 +28,22 @@ var svgEditorExtension_overview_window = (function () {
} // Define and insert the base html element. } // Define and insert the base html element.
const propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>'; var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
$('#sidepanels').append(propsWindowHtml); // Define dynamic animation of the view box. $('#sidepanels').append(propsWindowHtml); // Define dynamic animation of the view box.
const updateViewBox = function () { var updateViewBox = function updateViewBox() {
const portHeight = Number.parseFloat($('#workarea').css('height')); var portHeight = Number.parseFloat($('#workarea').css('height'));
const portWidth = Number.parseFloat($('#workarea').css('width')); var portWidth = Number.parseFloat($('#workarea').css('width'));
const portX = $('#workarea').scrollLeft(); var portX = $('#workarea').scrollLeft();
const portY = $('#workarea').scrollTop(); var portY = $('#workarea').scrollTop();
const windowWidth = Number.parseFloat($('#svgcanvas').css('width')); var windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height')); var windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width'); var overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); var overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = portX / windowWidth * overviewWidth; var viewBoxX = portX / windowWidth * overviewWidth;
const viewBoxY = portY / windowHeight * overviewHeight; var viewBoxY = portY / windowHeight * overviewHeight;
const viewBoxWidth = portWidth / windowWidth * overviewWidth; var viewBoxWidth = portWidth / windowWidth * overviewWidth;
const viewBoxHeight = portHeight / windowHeight * overviewHeight; var viewBoxHeight = portHeight / windowHeight * overviewHeight;
$('#overview_window_view_box').css('min-width', viewBoxWidth + 'px'); $('#overview_window_view_box').css('min-width', viewBoxWidth + 'px');
$('#overview_window_view_box').css('min-height', viewBoxHeight + 'px'); $('#overview_window_view_box').css('min-height', viewBoxHeight + 'px');
$('#overview_window_view_box').css('top', viewBoxY + 'px'); $('#overview_window_view_box').css('top', viewBoxY + 'px');
@ -60,11 +58,11 @@ var svgEditorExtension_overview_window = (function () {
$('#workarea').resize(updateViewBox); $('#workarea').resize(updateViewBox);
updateViewBox(); // Compensate for changes in zoom and canvas size. updateViewBox(); // Compensate for changes in zoom and canvas size.
const updateViewDimensions = function () { var updateViewDimensions = function updateViewDimensions() {
const viewWidth = $('#svgroot').attr('width'); var viewWidth = $('#svgroot').attr('width');
const viewHeight = $('#svgroot').attr('height'); var viewHeight = $('#svgroot').attr('height');
let viewX = 640; var viewX = 640;
let viewY = 480; var viewY = 480;
if (isIE()) { if (isIE()) {
// This has only been tested with Firefox 10 and IE 9 (without chrome frame). // This has only been tested with Firefox 10 and IE 9 (without chrome frame).
@ -77,8 +75,8 @@ var svgEditorExtension_overview_window = (function () {
viewY = 0; viewY = 0;
} }
const svgWidthOld = $('#overviewMiniView').attr('width'); var svgWidthOld = $('#overviewMiniView').attr('width');
const svgHeightNew = viewHeight / viewWidth * svgWidthOld; var svgHeightNew = viewHeight / viewWidth * svgWidthOld;
$('#overviewMiniView').attr('viewBox', viewX + ' ' + viewY + ' ' + viewWidth + ' ' + viewHeight); $('#overviewMiniView').attr('viewBox', viewX + ' ' + viewY + ' ' + viewWidth + ' ' + viewHeight);
$('#overviewMiniView').attr('height', svgHeightNew); $('#overviewMiniView').attr('height', svgHeightNew);
updateViewBox(); updateViewBox();
@ -88,15 +86,15 @@ var svgEditorExtension_overview_window = (function () {
overviewWindowGlobals.viewBoxDragging = false; overviewWindowGlobals.viewBoxDragging = false;
const updateViewPortFromViewBox = function () { var updateViewPortFromViewBox = function updateViewPortFromViewBox() {
const windowWidth = Number.parseFloat($('#svgcanvas').css('width')); var windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height')); var windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width'); var overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); var overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left')); var viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left'));
const viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top')); var viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top'));
const portX = viewBoxX / overviewWidth * windowWidth; var portX = viewBoxX / overviewWidth * windowWidth;
const portY = viewBoxY / overviewHeight * windowHeight; var portY = viewBoxY / overviewHeight * windowHeight;
$('#workarea').scrollLeft(portX); $('#workarea').scrollLeft(portX);
$('#workarea').scrollTop(portY); $('#workarea').scrollTop(portY);
}; };
@ -104,26 +102,23 @@ var svgEditorExtension_overview_window = (function () {
$('#overview_window_view_box').draggable({ $('#overview_window_view_box').draggable({
containment: 'parent', containment: 'parent',
drag: updateViewPortFromViewBox, drag: updateViewPortFromViewBox,
start: function start() {
start() {
overviewWindowGlobals.viewBoxDragging = true; overviewWindowGlobals.viewBoxDragging = true;
}, },
stop: function stop() {
stop() {
overviewWindowGlobals.viewBoxDragging = false; overviewWindowGlobals.viewBoxDragging = false;
} }
}); });
$('#overviewMiniView').click(function (evt) { $('#overviewMiniView').click(function (evt) {
// Firefox doesn't support evt.offsetX and evt.offsetY. // Firefox doesn't support evt.offsetX and evt.offsetY.
const mouseX = evt.offsetX || evt.originalEvent.layerX; var mouseX = evt.offsetX || evt.originalEvent.layerX;
const mouseY = evt.offsetY || evt.originalEvent.layerY; var mouseY = evt.offsetY || evt.originalEvent.layerY;
const overviewWidth = $('#overviewMiniView').attr('width'); var overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); var overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width')); var viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width'));
const viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height')); var viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height'));
let viewBoxX = mouseX - 0.5 * viewBoxWidth; var viewBoxX = mouseX - 0.5 * viewBoxWidth;
let viewBoxY = mouseY - 0.5 * viewBoxHeight; // deal with constraints var viewBoxY = mouseY - 0.5 * viewBoxHeight; // deal with constraints
if (viewBoxX < 0) { if (viewBoxX < 0) {
viewBoxX = 0; viewBoxX = 0;
@ -151,7 +146,6 @@ var svgEditorExtension_overview_window = (function () {
workareaResized: updateViewBox workareaResized: updateViewBox
}; };
} }
}; };
return extOverview_window; return extOverview_window;

View File

@ -1,6 +1,42 @@
var svgEditorExtension_panning = (function () { var svgEditorExtension_panning = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-panning.js * @file ext-panning.js
* *
@ -15,57 +51,70 @@ var svgEditorExtension_panning = (function () {
*/ */
var extPanning = { var extPanning = {
name: 'panning', name: 'panning',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
importLocale var importLocale, strings, svgEditor, svgCanvas, buttons;
}) { return regeneratorRuntime.wrap(function _callee$(_context) {
const strings = await importLocale(); while (1) {
const svgEditor = this; switch (_context.prev = _context.next) {
const svgCanvas = svgEditor.canvas; case 0:
const buttons = [{ importLocale = _ref.importLocale;
id: 'ext-panning', _context.next = 3;
icon: svgEditor.curConfig.extIconsPath + 'panning.png', return importLocale();
type: 'mode',
events: { case 3:
click() { strings = _context.sent;
svgCanvas.setMode('ext-panning'); svgEditor = _this;
svgCanvas = svgEditor.canvas;
buttons = [{
id: 'ext-panning',
icon: svgEditor.curConfig.extIconsPath + 'panning.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('ext-panning');
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(true);
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(false);
return {
keep: false,
element: null
};
}
return undefined;
}
});
case 8:
case "end":
return _context.stop();
}
} }
}, _callee);
} }))();
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
mouseDown() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(true);
return {
started: true
};
}
return undefined;
},
mouseUp() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(false);
return {
keep: false,
element: null
};
}
return undefined;
}
};
} }
}; };
return extPanning; return extPanning;

View File

@ -5,41 +5,33 @@ var svgEditorExtension_php_savefile = (function () {
// handler as in "ext-server_opensave.js" (and in savefile.php) // handler as in "ext-server_opensave.js" (and in savefile.php)
var extPhp_savefile = { var extPhp_savefile = {
name: 'php_savefile', name: 'php_savefile',
init: function init(_ref) {
init({ var $ = _ref.$;
$ var svgEditor = this;
}) { var extPath = svgEditor.curConfig.extPath,
const svgEditor = this; svgCanvas = svgEditor.canvas;
const {
curConfig: {
extPath
},
canvas: svgCanvas
} = svgEditor;
/** /**
* Get file name out of SVGEdit document title. * Get file name out of SVGEdit document title.
* @returns {string} * @returns {string}
*/ */
function getFileNameFromTitle() { function getFileNameFromTitle() {
const title = svgCanvas.getDocumentTitle(); var title = svgCanvas.getDocumentTitle();
return title.trim(); return title.trim();
} }
const saveSvgAction = extPath + 'savefile.php'; var saveSvgAction = extPath + 'savefile.php';
svgEditor.setCustomHandlers({ svgEditor.setCustomHandlers({
save(win, data) { save: function save(win, data) {
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data, var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
filename = getFileNameFromTitle(); filename = getFileNameFromTitle();
$.post(saveSvgAction, { $.post(saveSvgAction, {
output_svg: svg, output_svg: svg,
filename filename: filename
}); });
} }
}); });
} }
}; };
return extPhp_savefile; return extPhp_savefile;

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,42 @@
var svgEditorExtension_polygon = (function () { var svgEditorExtension_polygon = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-polygon.js * @file ext-polygon.js
* *
@ -10,305 +46,262 @@ var svgEditorExtension_polygon = (function () {
*/ */
var extPolygon = { var extPolygon = {
name: 'polygon', name: 'polygon',
init: function init(S) {
var _this = this;
async init(S) { return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
const svgEditor = this; var svgEditor, svgCanvas, $, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools;
const svgCanvas = svgEditor.canvas; return regeneratorRuntime.wrap(function _callee$(_context) {
const { while (1) {
$, switch (_context.prev = _context.next) {
importLocale case 0:
} = S; sec = function _sec(n) {
const strings = await importLocale(); return 1 / Math.cos(n);
let selElems, // svgdoc = S.svgroot.parentNode.ownerDocument, };
// newFOG, newFOGParent, newDef, newImageName, newMaskID, modeChangeG,
// edg = 0,
// undoCommand = 'Not image';
started, newFO; // const ccZoom;
// const wEl, hEl;
// const wOffset, hOffset;
// const ccRBG;
// const ccOpacity;
// const brushW, brushH;
// const ccDebug = document.getElementById('debugpanel');
/* const properlySourceSizeTextArea = function(){ cot = function _cot(n) {
// TODO: remove magic numbers here and get values from CSS return 1 / Math.tan(n);
const height = $('#svg_source_container').height() - 80; };
$('#svg_source_textarea').css('height', height);
}; */
/** setAttr = function _setAttr(attr, val) {
* @param {boolean} on svgCanvas.changeSelectedAttribute(attr, val);
* @returns {void} svgCanvas.call('changed', selElems);
*/ };
function showPanel(on) { showPanel = function _showPanel(on) {
let fcRules = $('#fc_rules'); var fcRules = $('#fc_rules');
if (!fcRules.length) { if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head'); fcRules = $('<style id="fc_rules"></style>').appendTo('head');
} }
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }'); fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#polygon_panel').toggle(on); $('#polygon_panel').toggle(on);
} };
/*
function toggleSourceButtons(on){
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#polygon_save, #polygon_cancel').toggle(on);
}
*/
/** svgEditor = _this;
* @param {string} attr svgCanvas = svgEditor.canvas;
* @param {string|Float} val $ = S.$, importLocale = S.importLocale, editingitex = false;
* @returns {void} _context.next = 9;
*/ return importLocale();
case 9:
strings = _context.sent;
/**
* Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3
* This function sets the content of of the currently-selected foreignObject element,
* based on the itex contained in string.
* @param {string} tex The itex text.
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
/*
function setItexString(tex) {
const mathns = 'http://www.w3.org/1998/Math/MathML',
xmlnsns = 'http://www.w3.org/2000/xmlns/',
ajaxEndpoint = '../../itex';
const elt = selElems[0];
try {
const math = svgdoc.createElementNS(mathns, 'math');
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
math.setAttribute('display', 'inline');
const semantics = document.createElementNS(mathns, 'semantics');
const annotation = document.createElementNS(mathns, 'annotation');
annotation.setAttribute('encoding', 'application/x-tex');
annotation.textContent = tex;
const mrow = document.createElementNS(mathns, 'mrow');
semantics.append(mrow, annotation);
math.append(semantics);
// make an AJAX request to the server, to get the MathML
$.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){
const children = data.documentElement.childNodes;
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
return false;
}
return true;
}
*/
buttons = [{
id: 'tool_polygon',
icon: svgEditor.curConfig.extIconsPath + 'polygon.png',
type: 'mode',
position: 11,
events: {
click: function click() {
svgCanvas.setMode('polygon');
showPanel(true);
}
}
}];
contextTools = [{
type: 'input',
panel: 'polygon_panel',
id: 'polySides',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('sides', this.value);
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'polygon-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#polygon_panel').hide();
function setAttr(attr, val) { setTimeout(function () {
svgCanvas.changeSelectedAttribute(attr, val); // Create source save/cancel buttons
svgCanvas.call('changed', selElems);
} /* const save = */
/** $('#tool_source_save').clone().hide().attr('id', 'polygon_save').unbind().appendTo('#tool_source_back').click(function () {
* @param {Float} n if (!editingitex) {
* @returns {Float} return;
*/ } // Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
// setSelectMode();
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () {
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
function cot(n) { var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
return 1 / Math.tan(n);
} var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
/**
* @param {Float} n var sWidth = svgCanvas.getStrokeWidth();
* @returns {Float} started = true;
*/ newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',
edge: 0,
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
if (!started || svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
function sec(n) { var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
return 1 / Math.cos(n); var x = opts.mouse_x;
} var y = opts.mouse_y;
/** var cx = c.cx,
* Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3 cy = c.cy,
* This function sets the content of of the currently-selected foreignObject element, fill = c.fill,
* based on the itex contained in string. strokecolor = c.strokecolor,
* @param {string} tex The itex text. strokeWidth = c.strokeWidth,
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. sides = c.sides,
*/ edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
newFO.setAttribute('edge', edg);
var inradius = edg / 2 * cot(Math.PI / sides);
var circumradius = inradius * sec(Math.PI / sides);
var points = '';
/* for (var s = 0; sides >= s; s++) {
function setItexString(tex) { var angle = 2.0 * Math.PI * s / sides;
const mathns = 'http://www.w3.org/1998/Math/MathML', x = circumradius * Math.cos(angle) + cx;
xmlnsns = 'http://www.w3.org/2000/xmlns/', y = circumradius * Math.sin(angle) + cy;
ajaxEndpoint = '../../itex'; points += x + ',' + y + ' ';
const elt = selElems[0]; } // const poly = newFO.createElementNS(NS.SVG, 'polygon');
try {
const math = svgdoc.createElementNS(mathns, 'math');
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
math.setAttribute('display', 'inline');
const semantics = document.createElementNS(mathns, 'semantics');
const annotation = document.createElementNS(mathns, 'annotation');
annotation.setAttribute('encoding', 'application/x-tex');
annotation.textContent = tex;
const mrow = document.createElementNS(mathns, 'mrow');
semantics.append(mrow, annotation);
math.append(semantics);
// make an AJAX request to the server, to get the MathML
$.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){
const children = data.documentElement.childNodes;
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
return false;
}
return true;
}
*/
const buttons = [{ newFO.setAttribute('points', points);
id: 'tool_polygon', newFO.setAttribute('fill', fill);
icon: svgEditor.curConfig.extIconsPath + 'polygon.png', newFO.setAttribute('stroke', strokecolor);
type: 'mode', newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
position: 11, // const shape = newFO.getAttribute('shape');
events: { // newFO.append(poly);
click() { // DrawPoly(cx, cy, sides, edg, orient);
svgCanvas.setMode('polygon');
showPanel(true);
}
} return {
}]; started: true
const contextTools = [{ };
type: 'input', },
panel: 'polygon_panel', mouseUp: function mouseUp(opts) {
id: 'polySides', if (svgCanvas.getMode() !== 'polygon') {
size: 3, return undefined;
defval: 5, }
events: {
change() {
setAttr('sides', this.value);
}
} var attrs = $(newFO).attr('edge');
}]; var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'polygon-icons.svg',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback() { return {
$('#polygon_panel').hide(); keep: keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
setTimeout(function () { if (elem && elem.getAttribute('shape') === 'regularPoly') {
// Create source save/cancel buttons if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
/* const save = */ case 13:
$('#tool_source_save').clone().hide().attr('id', 'polygon_save').unbind().appendTo('#tool_source_back').click(function () { case "end":
{ return _context.stop();
return;
} // Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
// setSelectMode();
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () {
});
}, 3000);
},
mouseDown(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
const rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
const sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
const sWidth = svgCanvas.getStrokeWidth();
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',
edge: 0,
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
},
mouseMove(opts) {
if (!started || svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
const c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
let x = opts.mouse_x;
let y = opts.mouse_y;
const {
cx,
cy,
fill,
strokecolor,
strokeWidth,
sides
} = c,
// {orient} = c,
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
newFO.setAttribute('edge', edg);
const inradius = edg / 2 * cot(Math.PI / sides);
const circumradius = inradius * sec(Math.PI / sides);
let points = '';
for (let s = 0; sides >= s; s++) {
const angle = 2.0 * Math.PI * s / sides;
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
points += x + ',' + y + ' ';
} // const poly = newFO.createElementNS(NS.SVG, 'polygon');
newFO.setAttribute('points', points);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
// const shape = newFO.getAttribute('shape');
// newFO.append(poly);
// DrawPoly(cx, cy, sides, edg, orient);
return {
started: true
};
},
mouseUp(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
}
const attrs = $(newFO).attr('edge');
const keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
keep,
element: newFO
};
},
selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
let i = selElems.length;
while (i--) {
const elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
} }
} }
}, }, _callee);
}))();
elementChanged(opts) {// const elem = opts.elems[0];
}
};
} }
}; };
return extPolygon; return extPolygon;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,98 @@
var svgEditorExtension_shapes = (function () { var svgEditorExtension_shapes = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/** /**
* @file ext-shapes.js * @file ext-shapes.js
* *
@ -11,365 +103,337 @@ var svgEditorExtension_shapes = (function () {
*/ */
var extShapes = { var extShapes = {
name: 'shapes', name: 'shapes',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
$, var $, importLocale, strings, svgEditor, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons;
importLocale return regeneratorRuntime.wrap(function _callee$(_context) {
}) { while (1) {
const strings = await importLocale(); switch (_context.prev = _context.next) {
const svgEditor = this; case 0:
const canv = svgEditor.canvas; loadLibrary = function _loadLibrary(catId) {
const svgroot = canv.getRootElem(); var lib = library[catId];
let lastBBox = {}; // This populates the category list
const { if (!lib) {
categories $('#shape_buttons').html(strings.loading);
} = strings; $.getJSON(svgEditor.curConfig.extIconsPath + 'shapelib/' + catId + '.json', function (result) {
const library = { curLib = library[catId] = {
basic: { data: result.data,
data: { size: result.size,
heart: 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z', fill: result.fill
frame: 'm0,0l300,0l0,300l-300,0zm35,-265l0,230l230,0l0,-230z', };
donut: 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z', makeButtons(catId, result);
triangle: 'm1,280.375l149,-260.75l149,260.75z', loadIcons();
right_triangle: 'm1,299l0,-298l298,298z', });
diamond: 'm1,150l149,-149l149,149l-149,149l-149,-149z', return;
pentagon: 'm1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z', }
hexagon: 'm1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z',
septagon1: 'm0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z',
heptagon: 'm1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z',
decagon: 'm1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z',
dodecagon: 'm1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z',
star_points_5: 'm1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z',
trapezoid: 'm1,299l55.875,-298l186.25001,0l55.87498,298z',
arrow_up: 'm1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z',
vertical_scrool: 'm37.375,261.625l0,-242.9375l0,0c0,-10.32083 8.36669,-18.6875 18.6875,-18.6875l224.25,0c10.32083,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36667,18.6875 -18.6875,18.6875l-18.6875,0l0,242.9375c0,10.32083 -8.36668,18.6875 -18.6875,18.6875l-224.25,0l0,0c-10.32083,0 -18.6875,-8.36667 -18.6875,-18.6875c0,-10.32083 8.36667,-18.6875 18.6875,-18.6875zm37.375,-261.625l0,0c10.32081,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36669,18.6875 -18.6875,18.6875c-5.1604,0 -9.34375,-4.18335 -9.34375,-9.34375c0,-5.16041 4.18335,-9.34375 9.34375,-9.34375l18.6875,0m186.875,18.6875l-205.5625,0m-37.375,224.25l0,0c5.1604,0 9.34375,4.18335 9.34375,9.34375c0,5.1604 -4.18335,9.34375 -9.34375,9.34375l18.6875,0m-18.6875,18.6875l0,0c10.32081,0 18.6875,-8.36667 18.6875,-18.6875l0,-18.6875',
smiley: 'm68.49886,214.78838q81.06408,55.67332 161.93891,0m-144.36983,-109.9558c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57948,6.97517 15.57948,15.57949c0,8.60431 -6.97517,15.57947 -15.57948,15.57947c-8.60431,0 -15.57948,-6.97516 -15.57948,-15.57947m95.83109,0c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57947,6.97517 15.57947,15.57949c0,8.60431 -6.97516,15.57947 -15.57947,15.57947c-8.60429,0 -15.57948,-6.97516 -15.57948,-15.57947m-181.89903,44.73038l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296zm0,0l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296z',
left_braket: 'm174.24565,298.5c-13.39009,0 -24.24489,-1.80908 -24.24489,-4.04065l0,-140.4187c0,-2.23158 -10.85481,-4.04065 -24.2449,-4.04065l0,0c13.39009,0 24.2449,-1.80907 24.2449,-4.04065l0,-140.4187l0,0c0,-2.23159 10.8548,-4.04066 24.24489,-4.04066',
uml_actor: 'm40.5,100l219,0m-108.99991,94.00006l107,105m-107.00009,-106.00006l-100,106m99.5,-231l0,125m33.24219,-158.75781c0,18.35916 -14.88303,33.24219 -33.24219,33.24219c-18.35916,0 -33.2422,-14.88303 -33.2422,-33.24219c0.00002,-18.35915 14.88304,-33.24219 33.2422,-33.24219c18.35916,0 33.24219,14.88304 33.24219,33.24219z',
dialog_balloon_1: 'm0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z',
cloud: 'm182.05086,34.31005c-0.64743,0.02048 -1.27309,0.07504 -1.92319,0.13979c-10.40161,1.03605 -19.58215,7.63722 -24.24597,17.4734l-2.47269,7.44367c0.53346,-2.57959 1.35258,-5.08134 2.47269,-7.44367c-8.31731,-8.61741 -19.99149,-12.59487 -31.52664,-10.72866c-11.53516,1.8662 -21.55294,9.3505 -27.02773,20.19925c-15.45544,-9.51897 -34.72095,-8.94245 -49.62526,1.50272c-14.90431,10.44516 -22.84828,28.93916 -20.43393,47.59753l1.57977,7.58346c-0.71388,-2.48442 -1.24701,-5.01186 -1.57977,-7.58346l-0.2404,0.69894c-12.95573,1.4119 -23.58103,11.46413 -26.34088,24.91708c-2.75985,13.45294 2.9789,27.25658 14.21789,34.21291l17.54914,4.26352c-6.1277,0.50439 -12.24542,-0.9808 -17.54914,-4.26352c-8.66903,9.71078 -10.6639,24.08736 -4.94535,35.96027c5.71854,11.87289 17.93128,18.70935 30.53069,17.15887l7.65843,-2.02692c-2.46413,1.0314 -5.02329,1.70264 -7.65843,2.02692c7.15259,13.16728 19.01251,22.77237 32.93468,26.5945c13.92217,3.82214 28.70987,1.56322 41.03957,-6.25546c10.05858,15.86252 27.91113,24.19412 45.81322,21.38742c17.90208,-2.8067 32.66954,-16.26563 37.91438,-34.52742l1.82016,-10.20447c-0.27254,3.46677 -0.86394,6.87508 -1.82016,10.20447c12.31329,8.07489 27.80199,8.52994 40.52443,1.18819c12.72244,-7.34175 20.6609,-21.34155 20.77736,-36.58929l-4.56108,-22.7823l-17.96776,-15.41455c13.89359,8.70317 22.6528,21.96329 22.52884,38.19685c16.5202,0.17313 30.55292,-13.98268 36.84976,-30.22897c6.29684,-16.24631 3.91486,-34.76801 -6.2504,-48.68089c4.21637,-10.35873 3.96622,-22.14172 -0.68683,-32.29084c-4.65308,-10.14912 -13.23602,-17.69244 -23.55914,-20.65356c-2.31018,-13.45141 -11.83276,-24.27162 -24.41768,-27.81765c-12.58492,-3.54603 -25.98557,0.82654 -34.41142,11.25287l-5.11707,8.63186c1.30753,-3.12148 3.01521,-6.03101 5.11707,-8.63186c-5.93959,-8.19432 -15.2556,-12.8181 -24.96718,-12.51096z',
cylinder: 'm299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z',
arrow_u_turn: 'm1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z',
arrow_left_up: 'm0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z',
maximize: 'm1.00037,150.34581l55.30305,-55.30267l0,27.65093l22.17356,0l0,-44.21833l44.21825,0l0,-22.17357l-27.65095,0l55.30267,-55.30292l55.3035,55.30292l-27.65175,0l0,22.17357l44.21835,0l0,44.21833l22.17357,0l0,-27.65093l55.30345,55.30267l-55.30345,55.3035l0,-27.65175l-22.17357,0l0,44.21834l-44.21835,0l0,22.17355l27.65175,0l-55.3035,55.30348l-55.30267,-55.30348l27.65095,0l0,-22.17355l-44.21825,0l0,-44.21834l-22.17356,0l0,27.65175l-55.30305,-55.3035z',
cross: 'm0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z',
plaque: 'm-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z',
page: 'm249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234'
},
buttons: []
}
};
const modeId = 'shapelib';
const startClientPos = {};
let currentD, curShapeId, curShape, startX, startY;
let curLib = library.basic;
/**
*
* @returns {void}
*/
function loadIcons() { curLib = lib;
$('#shape_buttons').empty().append(curLib.buttons);
}
/**
* @typedef {PlainObject} module:Extension.Shapes.Shapes
* @property {PlainObject<string, string>} data
* @property {Integer} [size]
* @property {boolean} [fill]
*/
/** if (!lib.buttons.length) {
* @param {string|"basic"} cat Category ID makeButtons(catId, lib);
* @param {module:Extension.Shapes.Shapes} shapes }
* @returns {void}
*/ loadIcons();
};
makeButtons = function _makeButtons(cat, shapes) {
var size = curLib.size || 300;
var fill = curLib.fill || false;
var off = size * 0.05;
var vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
var stroke = fill ? 0 : size / 30;
var shapeIcon = new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg">' + '<svg viewBox="' + vb + '">' + '<path fill="' + (fill ? '#333' : 'none') + '" stroke="#000" stroke-width="' + stroke + '" /></svg></svg>', 'text/xml');
var width = 24;
var height = 24;
shapeIcon.documentElement.setAttribute('width', width);
shapeIcon.documentElement.setAttribute('height', height);
var svgElem = $(document.importNode(shapeIcon.documentElement, true));
var data = shapes.data;
curLib.buttons = Object.entries(data).map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
id = _ref3[0],
pathD = _ref3[1];
var icon = svgElem.clone();
icon.find('path').attr('d', pathD);
var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
id: modeId + '_' + id,
title: id
}); // Store for later use
return iconBtn[0];
});
};
loadIcons = function _loadIcons() {
$('#shape_buttons').empty().append(curLib.buttons);
};
$ = _ref.$, importLocale = _ref.importLocale;
_context.next = 6;
return importLocale();
case 6:
strings = _context.sent;
svgEditor = _this;
canv = svgEditor.canvas;
svgroot = canv.getRootElem();
lastBBox = {}; // This populates the category list
categories = strings.categories;
/* eslint-disable max-len */
library = {
basic: {
data: {
heart: 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z',
frame: 'm0,0l300,0l0,300l-300,0zm35,-265l0,230l230,0l0,-230z',
donut: 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z',
triangle: 'm1,280.375l149,-260.75l149,260.75z',
right_triangle: 'm1,299l0,-298l298,298z',
diamond: 'm1,150l149,-149l149,149l-149,149l-149,-149z',
pentagon: 'm1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z',
hexagon: 'm1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z',
septagon1: 'm0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z',
heptagon: 'm1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z',
decagon: 'm1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z',
dodecagon: 'm1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z',
star_points_5: 'm1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z',
trapezoid: 'm1,299l55.875,-298l186.25001,0l55.87498,298z',
arrow_up: 'm1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z',
vertical_scrool: 'm37.375,261.625l0,-242.9375l0,0c0,-10.32083 8.36669,-18.6875 18.6875,-18.6875l224.25,0c10.32083,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36667,18.6875 -18.6875,18.6875l-18.6875,0l0,242.9375c0,10.32083 -8.36668,18.6875 -18.6875,18.6875l-224.25,0l0,0c-10.32083,0 -18.6875,-8.36667 -18.6875,-18.6875c0,-10.32083 8.36667,-18.6875 18.6875,-18.6875zm37.375,-261.625l0,0c10.32081,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36669,18.6875 -18.6875,18.6875c-5.1604,0 -9.34375,-4.18335 -9.34375,-9.34375c0,-5.16041 4.18335,-9.34375 9.34375,-9.34375l18.6875,0m186.875,18.6875l-205.5625,0m-37.375,224.25l0,0c5.1604,0 9.34375,4.18335 9.34375,9.34375c0,5.1604 -4.18335,9.34375 -9.34375,9.34375l18.6875,0m-18.6875,18.6875l0,0c10.32081,0 18.6875,-8.36667 18.6875,-18.6875l0,-18.6875',
smiley: 'm68.49886,214.78838q81.06408,55.67332 161.93891,0m-144.36983,-109.9558c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57948,6.97517 15.57948,15.57949c0,8.60431 -6.97517,15.57947 -15.57948,15.57947c-8.60431,0 -15.57948,-6.97516 -15.57948,-15.57947m95.83109,0c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57947,6.97517 15.57947,15.57949c0,8.60431 -6.97516,15.57947 -15.57947,15.57947c-8.60429,0 -15.57948,-6.97516 -15.57948,-15.57947m-181.89903,44.73038l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296zm0,0l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296z',
left_braket: 'm174.24565,298.5c-13.39009,0 -24.24489,-1.80908 -24.24489,-4.04065l0,-140.4187c0,-2.23158 -10.85481,-4.04065 -24.2449,-4.04065l0,0c13.39009,0 24.2449,-1.80907 24.2449,-4.04065l0,-140.4187l0,0c0,-2.23159 10.8548,-4.04066 24.24489,-4.04066',
uml_actor: 'm40.5,100l219,0m-108.99991,94.00006l107,105m-107.00009,-106.00006l-100,106m99.5,-231l0,125m33.24219,-158.75781c0,18.35916 -14.88303,33.24219 -33.24219,33.24219c-18.35916,0 -33.2422,-14.88303 -33.2422,-33.24219c0.00002,-18.35915 14.88304,-33.24219 33.2422,-33.24219c18.35916,0 33.24219,14.88304 33.24219,33.24219z',
dialog_balloon_1: 'm0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z',
cloud: 'm182.05086,34.31005c-0.64743,0.02048 -1.27309,0.07504 -1.92319,0.13979c-10.40161,1.03605 -19.58215,7.63722 -24.24597,17.4734l-2.47269,7.44367c0.53346,-2.57959 1.35258,-5.08134 2.47269,-7.44367c-8.31731,-8.61741 -19.99149,-12.59487 -31.52664,-10.72866c-11.53516,1.8662 -21.55294,9.3505 -27.02773,20.19925c-15.45544,-9.51897 -34.72095,-8.94245 -49.62526,1.50272c-14.90431,10.44516 -22.84828,28.93916 -20.43393,47.59753l1.57977,7.58346c-0.71388,-2.48442 -1.24701,-5.01186 -1.57977,-7.58346l-0.2404,0.69894c-12.95573,1.4119 -23.58103,11.46413 -26.34088,24.91708c-2.75985,13.45294 2.9789,27.25658 14.21789,34.21291l17.54914,4.26352c-6.1277,0.50439 -12.24542,-0.9808 -17.54914,-4.26352c-8.66903,9.71078 -10.6639,24.08736 -4.94535,35.96027c5.71854,11.87289 17.93128,18.70935 30.53069,17.15887l7.65843,-2.02692c-2.46413,1.0314 -5.02329,1.70264 -7.65843,2.02692c7.15259,13.16728 19.01251,22.77237 32.93468,26.5945c13.92217,3.82214 28.70987,1.56322 41.03957,-6.25546c10.05858,15.86252 27.91113,24.19412 45.81322,21.38742c17.90208,-2.8067 32.66954,-16.26563 37.91438,-34.52742l1.82016,-10.20447c-0.27254,3.46677 -0.86394,6.87508 -1.82016,10.20447c12.31329,8.07489 27.80199,8.52994 40.52443,1.18819c12.72244,-7.34175 20.6609,-21.34155 20.77736,-36.58929l-4.56108,-22.7823l-17.96776,-15.41455c13.89359,8.70317 22.6528,21.96329 22.52884,38.19685c16.5202,0.17313 30.55292,-13.98268 36.84976,-30.22897c6.29684,-16.24631 3.91486,-34.76801 -6.2504,-48.68089c4.21637,-10.35873 3.96622,-22.14172 -0.68683,-32.29084c-4.65308,-10.14912 -13.23602,-17.69244 -23.55914,-20.65356c-2.31018,-13.45141 -11.83276,-24.27162 -24.41768,-27.81765c-12.58492,-3.54603 -25.98557,0.82654 -34.41142,11.25287l-5.11707,8.63186c1.30753,-3.12148 3.01521,-6.03101 5.11707,-8.63186c-5.93959,-8.19432 -15.2556,-12.8181 -24.96718,-12.51096z',
cylinder: 'm299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z',
arrow_u_turn: 'm1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z',
arrow_left_up: 'm0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z',
maximize: 'm1.00037,150.34581l55.30305,-55.30267l0,27.65093l22.17356,0l0,-44.21833l44.21825,0l0,-22.17357l-27.65095,0l55.30267,-55.30292l55.3035,55.30292l-27.65175,0l0,22.17357l44.21835,0l0,44.21833l22.17357,0l0,-27.65093l55.30345,55.30267l-55.30345,55.3035l0,-27.65175l-22.17357,0l0,44.21834l-44.21835,0l0,22.17355l27.65175,0l-55.3035,55.30348l-55.30267,-55.30348l27.65095,0l0,-22.17355l-44.21825,0l0,-44.21834l-22.17356,0l0,27.65175l-55.30305,-55.3035z',
cross: 'm0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z',
plaque: 'm-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z',
page: 'm249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234'
},
buttons: []
}
};
/* eslint-enable max-len */
modeId = 'shapelib';
startClientPos = {};
curLib = library.basic;
/**
*
* @returns {void}
*/
buttons = [{
id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
type: 'mode_flyout',
// _flyout
position: 6,
events: {
click: function click() {
canv.setMode(modeId);
}
}
}];
return _context.abrupt("return", {
svgicons: svgEditor.curConfig.extIconsPath + 'ext-shapes.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('<style>').text("\n #shape_buttons {\n overflow: auto;\n width: 180px;\n max-height: 300px;\n display: table-cell;\n vertical-align: middle;\n }\n #shape_cats {\n min-width: 110px;\n display: table-cell;\n vertical-align: middle;\n height: 300px;\n }\n #shape_cats > div {\n line-height: 1em;\n padding: .5em;\n border:1px solid #B0B0B0;\n background: #E8E8E8;\n margin-bottom: -1px;\n }\n #shape_cats div:hover {\n background: #FFFFCC;\n }\n #shape_cats div.current {\n font-weight: bold;\n }\n ").appendTo('head');
var btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv);
var shower = $('#tools_shapelib_show');
loadLibrary('basic'); // Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function (evt) {
var btn = $(evt.target).closest('div.tool_button');
if (!btn.length) {
return;
}
var copy = btn.children().clone();
shower.children(':not(.flyout_arrow_horiz)').remove();
shower.append(copy).attr('data-curopt', '#' + btn[0].id) // This sets the current mode
.mouseup();
canv.setMode(modeId);
curShapeId = btn[0].id.substr((modeId + '_').length);
currentD = curLib.data[curShapeId];
$('.tools_flyout').fadeOut();
});
var shapeCats = $('<div id="shape_cats">');
var catStr = '';
$.each(categories, function (id, label) {
catStr += '<div data-cat=' + id + '>' + label + '</div>';
});
shapeCats.html(catStr).children().bind('mouseup', function () {
var catlink = $(this);
catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat')); // Get stuff
return false;
});
shapeCats.children().eq(0).addClass('current');
$('#tools_shapelib').append(shapeCats);
shower.mouseup(function () {
canv.setMode(currentD ? modeId : 'select');
});
$('#tool_shapelib').remove();
var h = $('#tools_shapelib').height();
$('#tools_shapelib').css({
'margin-top': -(h / 2 - 15),
'margin-left': 3
}); // Now add shape categories from locale
var cats = {};
Object.entries(categories).forEach(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
o = _ref5[0],
categoryName = _ref5[1];
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
});
this.setStrings('content', cats);
},
mouseDown: function mouseDown(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
startX = opts.start_x;
var x = startX;
startY = opts.start_y;
var y = startY;
var curStyle = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
curShape = canv.addSVGElementFromJson({
element: 'path',
curStyles: true,
attr: {
d: currentD,
id: canv.getNextId(),
opacity: curStyle.opacity / 2,
style: 'pointer-events:none'
}
}); // Make sure shape uses absolute values
if (/[a-z]/.test(currentD)) {
currentD = curLib.data[curShapeId] = canv.pathActions.convertPath(curShape);
curShape.setAttribute('d', currentD);
canv.pathActions.fixEnd(curShape);
}
curShape.setAttribute('transform', 'translate(' + x + ',' + y + ') scale(0.005) translate(' + -x + ',' + -y + ')');
canv.recalculateDimensions(curShape);
/* const tlist = */
canv.getTransformList(curShape);
lastBBox = curShape.getBBox();
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return;
}
var zoom = canv.getZoom();
var evt = opts.event;
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom;
var tlist = canv.getTransformList(curShape),
box = curShape.getBBox(),
left = box.x,
top = box.y; // {width, height} = box,
// const dx = (x - startX), dy = (y - startY);
var newbox = {
x: Math.min(startX, x),
y: Math.min(startY, y),
width: Math.abs(x - startX),
height: Math.abs(y - startY)
};
/*
// This is currently serving no purpose, so commenting out
let sy = height ? (height + dy) / height : 1,
sx = width ? (width + dx) / width : 1;
*/
var sx = newbox.width / lastBBox.width || 1;
var sy = newbox.height / lastBBox.height || 1; // Not perfect, but mostly works...
var tx = 0;
if (x < startX) {
tx = lastBBox.width;
}
var ty = 0;
if (y < startY) {
ty = lastBBox.height;
} // update the transform list with translate,scale,translate
function makeButtons(cat, shapes) { var translateOrigin = svgroot.createSVGTransform(),
const size = curLib.size || 300; scale = svgroot.createSVGTransform(),
const fill = curLib.fill || false; translateBack = svgroot.createSVGTransform();
const off = size * 0.05; translateOrigin.setTranslate(-(left + tx), -(top + ty));
const vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
const stroke = fill ? 0 : size / 30;
const shapeIcon = new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg">' + '<svg viewBox="' + vb + '">' + '<path fill="' + (fill ? '#333' : 'none') + '" stroke="#000" stroke-width="' + stroke + '" /></svg></svg>', 'text/xml');
const width = 24;
const height = 24;
shapeIcon.documentElement.setAttribute('width', width);
shapeIcon.documentElement.setAttribute('height', height);
const svgElem = $(document.importNode(shapeIcon.documentElement, true));
const {
data
} = shapes;
curLib.buttons = Object.entries(data).map(([id, pathD]) => {
const icon = svgElem.clone();
icon.find('path').attr('d', pathD);
const iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
id: modeId + '_' + id,
title: id
}); // Store for later use
return iconBtn[0]; if (!evt.shiftKey) {
}); var max = Math.min(Math.abs(sx), Math.abs(sy));
} sx = max * (sx < 0 ? -1 : 1);
/** sy = max * (sy < 0 ? -1 : 1);
* @param {string|"basic"} catId }
* @returns {void}
*/
scale.setScale(sx, sy);
translateBack.setTranslate(left + tx, top + ty);
tlist.appendItem(translateBack);
tlist.appendItem(scale);
tlist.appendItem(translateOrigin);
canv.recalculateDimensions(curShape);
lastBBox = curShape.getBBox();
},
mouseUp: function mouseUp(opts) {
var mode = canv.getMode();
function loadLibrary(catId) { if (mode !== modeId) {
const lib = library[catId]; return undefined;
}
if (!lib) { var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
$('#shape_buttons').html(strings.loading); return {
$.getJSON(svgEditor.curConfig.extIconsPath + 'shapelib/' + catId + '.json', function (result) { keep: keepObject,
curLib = library[catId] = { element: curShape,
data: result.data, started: false
size: result.size, };
fill: result.fill }
}; });
makeButtons(catId, result);
loadIcons();
});
return;
}
curLib = lib; case 18:
case "end":
if (!lib.buttons.length) { return _context.stop();
makeButtons(catId, lib);
}
loadIcons();
}
const buttons = [{
id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
type: 'mode_flyout',
// _flyout
position: 6,
events: {
click() {
canv.setMode(modeId);
}
}
}];
return {
svgicons: svgEditor.curConfig.extIconsPath + 'ext-shapes.xml',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
callback() {
$('<style>').text(`
#shape_buttons {
overflow: auto;
width: 180px;
max-height: 300px;
display: table-cell;
vertical-align: middle;
}
#shape_cats {
min-width: 110px;
display: table-cell;
vertical-align: middle;
height: 300px;
}
#shape_cats > div {
line-height: 1em;
padding: .5em;
border:1px solid #B0B0B0;
background: #E8E8E8;
margin-bottom: -1px;
}
#shape_cats div:hover {
background: #FFFFCC;
}
#shape_cats div.current {
font-weight: bold;
}
`).appendTo('head');
const btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv);
const shower = $('#tools_shapelib_show');
loadLibrary('basic'); // Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function (evt) {
const btn = $(evt.target).closest('div.tool_button');
if (!btn.length) {
return;
} }
const copy = btn.children().clone();
shower.children(':not(.flyout_arrow_horiz)').remove();
shower.append(copy).attr('data-curopt', '#' + btn[0].id) // This sets the current mode
.mouseup();
canv.setMode(modeId);
curShapeId = btn[0].id.substr((modeId + '_').length);
currentD = curLib.data[curShapeId];
$('.tools_flyout').fadeOut();
});
const shapeCats = $('<div id="shape_cats">');
let catStr = '';
$.each(categories, function (id, label) {
catStr += '<div data-cat=' + id + '>' + label + '</div>';
});
shapeCats.html(catStr).children().bind('mouseup', function () {
const catlink = $(this);
catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat')); // Get stuff
return false;
});
shapeCats.children().eq(0).addClass('current');
$('#tools_shapelib').append(shapeCats);
shower.mouseup(function () {
canv.setMode(currentD ? modeId : 'select');
});
$('#tool_shapelib').remove();
const h = $('#tools_shapelib').height();
$('#tools_shapelib').css({
'margin-top': -(h / 2 - 15),
'margin-left': 3
}); // Now add shape categories from locale
const cats = {};
Object.entries(categories).forEach(([o, categoryName]) => {
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
});
this.setStrings('content', cats);
},
mouseDown(opts) {
const mode = canv.getMode();
if (mode !== modeId) {
return undefined;
} }
}, _callee);
startX = opts.start_x; }))();
const x = startX;
startY = opts.start_y;
const y = startY;
const curStyle = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
curShape = canv.addSVGElementFromJson({
element: 'path',
curStyles: true,
attr: {
d: currentD,
id: canv.getNextId(),
opacity: curStyle.opacity / 2,
style: 'pointer-events:none'
}
}); // Make sure shape uses absolute values
if (/[a-z]/.test(currentD)) {
currentD = curLib.data[curShapeId] = canv.pathActions.convertPath(curShape);
curShape.setAttribute('d', currentD);
canv.pathActions.fixEnd(curShape);
}
curShape.setAttribute('transform', 'translate(' + x + ',' + y + ') scale(0.005) translate(' + -x + ',' + -y + ')');
canv.recalculateDimensions(curShape);
/* const tlist = */
canv.getTransformList(curShape);
lastBBox = curShape.getBBox();
return {
started: true
};
},
mouseMove(opts) {
const mode = canv.getMode();
if (mode !== modeId) {
return;
}
const zoom = canv.getZoom();
const evt = opts.event;
const x = opts.mouse_x / zoom;
const y = opts.mouse_y / zoom;
const tlist = canv.getTransformList(curShape),
box = curShape.getBBox(),
left = box.x,
top = box.y; // {width, height} = box,
// const dx = (x - startX), dy = (y - startY);
const newbox = {
x: Math.min(startX, x),
y: Math.min(startY, y),
width: Math.abs(x - startX),
height: Math.abs(y - startY)
};
/*
// This is currently serving no purpose, so commenting out
let sy = height ? (height + dy) / height : 1,
sx = width ? (width + dx) / width : 1;
*/
let sx = newbox.width / lastBBox.width || 1;
let sy = newbox.height / lastBBox.height || 1; // Not perfect, but mostly works...
let tx = 0;
if (x < startX) {
tx = lastBBox.width;
}
let ty = 0;
if (y < startY) {
ty = lastBBox.height;
} // update the transform list with translate,scale,translate
const translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(-(left + tx), -(top + ty));
if (!evt.shiftKey) {
const max = Math.min(Math.abs(sx), Math.abs(sy));
sx = max * (sx < 0 ? -1 : 1);
sy = max * (sy < 0 ? -1 : 1);
}
scale.setScale(sx, sy);
translateBack.setTranslate(left + tx, top + ty);
tlist.appendItem(translateBack);
tlist.appendItem(scale);
tlist.appendItem(translateOrigin);
canv.recalculateDimensions(curShape);
lastBBox = curShape.getBBox();
},
mouseUp(opts) {
const mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
const keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
return {
keep: keepObject,
element: curShape,
started: false
};
}
};
} }
}; };
return extShapes; return extShapes;

View File

@ -1,6 +1,42 @@
var svgEditorExtension_star = (function () { var svgEditorExtension_star = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* @file ext-star.js * @file ext-star.js
* *
@ -10,270 +46,247 @@ var svgEditorExtension_star = (function () {
*/ */
var extStar = { var extStar = {
name: 'star', name: 'star',
init: function init(S) {
var _this = this;
async init(S) { return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
const svgEditor = this; var svgEditor, svgCanvas, $, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools;
const svgCanvas = svgEditor.canvas; return regeneratorRuntime.wrap(function _callee$(_context) {
const { while (1) {
$, switch (_context.prev = _context.next) {
importLocale case 0:
} = S; // {svgcontent}, setAttr = function _setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
let selElems, // editingitex = false, showPanel = function _showPanel(on) {
// svgdoc = S.svgroot.parentNode.ownerDocument, var fcRules = $('#fc_rules');
started, newFO; // edg = 0,
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
// undoCommand = 'Not image',
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
const strings = await importLocale(); if (!fcRules.length) {
/** fcRules = $('<style id="fc_rules"></style>').appendTo('head');
* }
* @param {boolean} on
* @returns {void}
*/
function showPanel(on) { fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
let fcRules = $('#fc_rules'); $('#star_panel').toggle(on);
};
if (!fcRules.length) { svgEditor = _this;
fcRules = $('<style id="fc_rules"></style>').appendTo('head'); svgCanvas = svgEditor.canvas;
} $ = S.$, importLocale = S.importLocale; // {svgcontent},
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }'); _context.next = 7;
$('#star_panel').toggle(on); return importLocale();
}
/*
function toggleSourceButtons(on){
$('#star_save, #star_cancel').toggle(on);
}
*/
/** case 7:
* strings = _context.sent;
* @param {string} attr
* @param {string|Float} val
* @returns {void}
*/
/*
function setAttr(attr, val) { function cot(n){
svgCanvas.changeSelectedAttribute(attr, val); return 1 / Math.tan(n);
svgCanvas.call('changed', selElems);
}
/*
function cot(n){
return 1 / Math.tan(n);
}
function sec(n){
return 1 / Math.cos(n);
}
*/
const buttons = [{
id: 'tool_star',
icon: svgEditor.curConfig.extIconsPath + 'star.png',
type: 'mode',
position: 12,
events: {
click() {
showPanel(true);
svgCanvas.setMode('star');
}
}
}];
const contextTools = [{
type: 'input',
panel: 'star_panel',
id: 'starNumPoints',
size: 3,
defval: 5,
events: {
change() {
setAttr('point', this.value);
}
}
}, {
type: 'input',
panel: 'star_panel',
id: 'starRadiusMulitplier',
size: 3,
defval: 2.5
}, {
type: 'input',
panel: 'star_panel',
id: 'radialShift',
size: 3,
defval: 0,
events: {
change() {
setAttr('radialshift', this.value);
}
}
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'star-icons.svg',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback() {
$('#star_panel').hide(); // const endChanges = function(){};
},
mouseDown(opts) {
const rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
const sRgb = svgCanvas.getColor('stroke'); // const ccSRgbEl = sRgb.substring(1, rgb.length);
const sWidth = svgCanvas.getStrokeWidth();
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,
radialshift: document.getElementById('radialShift').value,
r2: 0,
orient: 'point',
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
}
return undefined;
},
mouseMove(opts) {
if (!started) {
return undefined;
}
if (svgCanvas.getMode() === 'star') {
const c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
let x = opts.mouse_x;
let y = opts.mouse_y;
const {
cx,
cy,
fill,
strokecolor,
strokeWidth,
radialshift,
point,
orient
} = c,
circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttribute('r', circumradius);
newFO.setAttribute('r2', inradius);
let polyPoints = '';
for (let s = 0; point >= s; s++) {
let angle = 2.0 * Math.PI * (s / point);
if (orient === 'point') {
angle -= Math.PI / 2;
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
}
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
polyPoints += x + ',' + y + ' ';
if (!isNaN(inradius)) {
angle = 2.0 * Math.PI * (s / point) + Math.PI / point;
if (orient === 'point') {
angle -= Math.PI / 2;
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
} }
function sec(n){
return 1 / Math.cos(n);
}
*/
buttons = [{
id: 'tool_star',
icon: svgEditor.curConfig.extIconsPath + 'star.png',
type: 'mode',
position: 12,
events: {
click: function click() {
showPanel(true);
svgCanvas.setMode('star');
}
}
}];
contextTools = [{
type: 'input',
panel: 'star_panel',
id: 'starNumPoints',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('point', this.value);
}
}
}, {
type: 'input',
panel: 'star_panel',
id: 'starRadiusMulitplier',
size: 3,
defval: 2.5
}, {
type: 'input',
panel: 'star_panel',
id: 'radialShift',
size: 3,
defval: 0,
events: {
change: function change() {
setAttr('radialshift', this.value);
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'star-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#star_panel').hide(); // const endChanges = function(){};
},
mouseDown: function mouseDown(opts) {
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
angle += radialshift; var sRgb = svgCanvas.getColor('stroke'); // const ccSRgbEl = sRgb.substring(1, rgb.length);
x = inradius * Math.cos(angle) + cx;
y = inradius * Math.sin(angle) + cy;
polyPoints += x + ',' + y + ' ';
}
}
newFO.setAttribute('points', polyPoints); var sWidth = svgCanvas.getStrokeWidth();
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */
newFO.getAttribute('shape'); if (svgCanvas.getMode() === 'star') {
return { started = true;
started: true newFO = svgCanvas.addSVGElementFromJson({
}; element: 'polygon',
} attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,
radialshift: document.getElementById('radialShift').value,
r2: 0,
orient: 'point',
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
}
return undefined; return undefined;
}, },
mouseMove: function mouseMove(opts) {
if (!started) {
return undefined;
}
mouseUp() { if (svgCanvas.getMode() === 'star') {
if (svgCanvas.getMode() === 'star') { var c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
const attrs = $(newFO).attr(['r']); // svgCanvas.addToSelection([newFO], true); var x = opts.mouse_x;
var y = opts.mouse_y;
var cx = c.cx,
cy = c.cy,
fill = c.fill,
strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
radialshift = c.radialshift,
point = c.point,
orient = c.orient,
circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttribute('r', circumradius);
newFO.setAttribute('r2', inradius);
var polyPoints = '';
return { for (var s = 0; point >= s; s++) {
keep: attrs.r !== '0', var angle = 2.0 * Math.PI * (s / point);
element: newFO
};
}
return undefined; if (orient === 'point') {
}, angle -= Math.PI / 2;
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
}
selectedChanged(opts) { x = circumradius * Math.cos(angle) + cx;
// Use this to update the current selected elements y = circumradius * Math.sin(angle) + cy;
selElems = opts.elems; polyPoints += x + ',' + y + ' ';
let i = selElems.length;
while (i--) { if (!isNaN(inradius)) {
const elem = selElems[i]; angle = 2.0 * Math.PI * (s / point) + Math.PI / point;
if (elem && elem.getAttribute('shape') === 'star') { if (orient === 'point') {
if (opts.selectedElement && !opts.multiselected) { angle -= Math.PI / 2;
// $('#starRadiusMulitplier').val(elem.getAttribute('r2')); } else if (orient === 'edge') {
$('#starNumPoints').val(elem.getAttribute('point')); angle = angle + Math.PI / point - Math.PI / 2;
$('#radialShift').val(elem.getAttribute('radialshift')); }
showPanel(true);
} else { angle += radialshift;
showPanel(false); x = inradius * Math.cos(angle) + cx;
} y = inradius * Math.sin(angle) + cy;
} else { polyPoints += x + ',' + y + ' ';
showPanel(false); }
}
newFO.setAttribute('points', polyPoints);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */
newFO.getAttribute('shape');
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'star') {
var attrs = $(newFO).attr(['r']); // svgCanvas.addToSelection([newFO], true);
return {
keep: attrs.r !== '0',
element: newFO
};
}
return undefined;
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
$('#starNumPoints').val(elem.getAttribute('point'));
$('#radialShift').val(elem.getAttribute('radialshift'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 11:
case "end":
return _context.stop();
} }
} }
}, }, _callee);
}))();
elementChanged(opts) {// const elem = opts.elems[0];
}
};
} }
}; };
return extStar; return extStar;

View File

@ -1,6 +1,98 @@
var svgEditorExtension_storage = (function () { var svgEditorExtension_storage = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/** /**
* @file ext-storage.js * @file ext-storage.js
* *
@ -23,35 +115,21 @@ var svgEditorExtension_storage = (function () {
*/ */
var extStorage = { var extStorage = {
name: 'storage', name: 'storage',
init: function init(_ref) {
init({ var $ = _ref.$;
$ var svgEditor = this;
}) { var svgCanvas = svgEditor.canvas; // We could empty any already-set data for users when they decline storage,
const svgEditor = this;
const svgCanvas = svgEditor.canvas; // 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 // but it would be a risk for users who wanted to store but accidentally
// said "no"; instead, we'll let those who already set it, delete it themselves; // said "no"; instead, we'll let those who already set it, delete it themselves;
// to change, set the "emptyStorageOnDecline" config setting to true // to change, set the "emptyStorageOnDecline" config setting to true
// in svgedit-config-iife.js/svgedit-config-es.js. // in svgedit-config-iife.js/svgedit-config-es.js.
const { var _svgEditor$curConfig = svgEditor.curConfig,
emptyStorageOnDecline, emptyStorageOnDecline = _svgEditor$curConfig.emptyStorageOnDecline,
// When the code in svg-editor.js prevents local storage on load per noStorageOnLoad = _svgEditor$curConfig.noStorageOnLoad,
// user request, we also prevent storing on unload here so as to forceStorage = _svgEditor$curConfig.forceStorage;
// avoid third-party sites making XSRF requests or providing links var storage = svgEditor.storage,
// which would cause the user's local storage not to load and then updateCanvas = svgEditor.updateCanvas;
// upon page unload (such as the user closing the window), the storage
// would thereby be set with an empty value, erasing any of the
// user's prior work. To change this behavior so that no use of storage
// or adding of new storage takes place regardless of settings, set
// the "noStorageOnLoad" config setting to true in svgedit-config-*.js.
noStorageOnLoad,
forceStorage
} = svgEditor.curConfig;
const {
storage,
updateCanvas
} = svgEditor;
/** /**
* Replace `storagePrompt` parameter within URL. * Replace `storagePrompt` parameter within URL.
* @param {string} val * @param {string} val
@ -61,7 +139,7 @@ var svgEditorExtension_storage = (function () {
function replaceStoragePrompt(val) { function replaceStoragePrompt(val) {
val = val ? 'storagePrompt=' + val : ''; val = val ? 'storagePrompt=' + val : '';
const loc = top.location; // Allow this to work with the embedded editor as well var loc = top.location; // Allow this to work with the embedded editor as well
if (loc.href.includes('storagePrompt=')) { if (loc.href.includes('storagePrompt=')) {
/* /*
@ -86,7 +164,7 @@ var svgEditorExtension_storage = (function () {
function setSVGContentStorage(val) { function setSVGContentStorage(val) {
if (storage) { if (storage) {
const name = 'svgedit-' + svgEditor.curConfig.canvasName; var name = 'svgedit-' + svgEditor.curConfig.canvasName;
if (!val) { if (!val) {
storage.removeItem(name); storage.removeItem(name);
@ -122,7 +200,7 @@ var svgEditorExtension_storage = (function () {
function emptyStorage() { function emptyStorage() {
setSVGContentStorage(''); setSVGContentStorage('');
Object.keys(svgEditor.curPrefs).forEach(name => { Object.keys(svgEditor.curPrefs).forEach(function (name) {
name = 'svg-edit-' + name; name = 'svg-edit-' + name;
if (storage) { if (storage) {
@ -160,11 +238,13 @@ var svgEditorExtension_storage = (function () {
}); // No need for explicit saving at all once storage is on }); // No need for explicit saving at all once storage is on
// svgEditor.showSaveWarning = false; // svgEditor.showSaveWarning = false;
const { var curPrefs = svgEditor.curPrefs;
curPrefs Object.entries(curPrefs).forEach(function (_ref2) {
} = svgEditor; var _ref3 = _slicedToArray(_ref2, 2),
Object.entries(curPrefs).forEach(([key, val]) => { key = _ref3[0],
const store = val !== undefined; val = _ref3[1];
var store = val !== undefined;
key = 'svg-edit-' + key; key = 'svg-edit-' + key;
if (!store) { if (!store) {
@ -183,147 +263,180 @@ var svgEditorExtension_storage = (function () {
}); });
} }
let loaded = false; var loaded = false;
return { return {
name: 'storage', name: 'storage',
langReady: function langReady(_ref4) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var importLocale, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _yield$$$select, pref, checked;
async langReady({ return regeneratorRuntime.wrap(function _callee$(_context) {
importLocale while (1) {
}) { switch (_context.prev = _context.next) {
const storagePrompt = new URL(top.location).searchParams.get('storagePrompt'); case 0:
const confirmSetStorage = await importLocale(); importLocale = _ref4.importLocale;
const { storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
message, _context.next = 4;
storagePrefsAndContent, return importLocale();
storagePrefsOnly,
storagePrefs,
storageNoPrefsOrContent,
storageNoPrefs,
rememberLabel,
rememberTooltip
} = confirmSetStorage; // No need to run this one-time dialog again just because the user
// changes the language
if (loaded) { case 4:
return; confirmSetStorage = _context.sent;
} message = confirmSetStorage.message, storagePrefsAndContent = confirmSetStorage.storagePrefsAndContent, storagePrefsOnly = confirmSetStorage.storagePrefsOnly, storagePrefs = confirmSetStorage.storagePrefs, storageNoPrefsOrContent = confirmSetStorage.storageNoPrefsOrContent, storageNoPrefs = confirmSetStorage.storageNoPrefs, rememberLabel = confirmSetStorage.rememberLabel, rememberTooltip = confirmSetStorage.rememberTooltip; // No need to run this one-time dialog again just because the user
// changes the language
loaded = true; // Note that the following can load even if "noStorageOnLoad" is if (!loaded) {
// set to false; to avoid any chance of storage, avoid this _context.next = 8;
// extension! (and to avoid using any prior storage, set the break;
// config option "noStorageOnLoad" to true). }
if (!forceStorage && ( // If the URL has been explicitly set to always prompt the return _context.abrupt("return");
// user (e.g., so one can be pointed to a URL where one
// can alter one's settings, say to prevent future storage)...
storagePrompt === 'true' || // ...or...if the URL at least doesn't explicitly prevent a
// storage prompt (as we use for users who
// don't want to set cookies at all but who don't want
// continual prompts about it)...
storagePrompt !== 'false' && // ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
)) {
const options = [];
if (storage) { case 8:
options.unshift({ loaded = true; // Note that the following can load even if "noStorageOnLoad" is
value: 'prefsAndContent', // set to false; to avoid any chance of storage, avoid this
text: storagePrefsAndContent // extension! (and to avoid using any prior storage, set the
}, { // config option "noStorageOnLoad" to true).
value: 'prefsOnly',
text: storagePrefsOnly if (!(!forceStorage && ( // If the URL has been explicitly set to always prompt the
}, { // user (e.g., so one can be pointed to a URL where one
value: 'noPrefsOrContent', // can alter one's settings, say to prevent future storage)...
text: storageNoPrefsOrContent storagePrompt === 'true' || // ...or...if the URL at least doesn't explicitly prevent a
}); // storage prompt (as we use for users who
} else { // don't want to set cookies at all but who don't want
options.unshift({ // continual prompts about it)...
value: 'prefsOnly', storagePrompt !== 'false' && // ...and this user hasn't previously indicated a desire for storage
text: storagePrefs !document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
}, { ))) {
value: 'noPrefsOrContent', _context.next = 44;
text: storageNoPrefs break;
}); }
} // Hack to temporarily provide a wide and high enough dialog
options = [];
if (storage) {
options.unshift({
value: 'prefsAndContent',
text: storagePrefsAndContent
}, {
value: 'prefsOnly',
text: storagePrefsOnly
}, {
value: 'noPrefsOrContent',
text: storageNoPrefsOrContent
});
} else {
options.unshift({
value: 'prefsOnly',
text: storagePrefs
}, {
value: 'noPrefsOrContent',
text: storageNoPrefs
});
} // Hack to temporarily provide a wide and high enough dialog
const oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height;
oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, $('#dialog_content')[0].style.height = '120px';
oldContentHeight = $('#dialog_content')[0].style.height, $('#dialog_container')[0].style.height = '170px';
oldContainerHeight = $('#dialog_container')[0].style.height; $('#dialog_container')[0].style.width = '800px';
$('#dialog_content')[0].style.height = '120px'; $('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
$('#dialog_container')[0].style.height = '170px'; // From svg-editor.js
$('#dialog_container')[0].style.width = '800px';
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
// From svg-editor.js
svgEditor.storagePromptState = 'waiting'; svgEditor.storagePromptState = 'waiting';
const { _context.next = 20;
response: pref, return $.select(message, options, null, null, {
checked label: rememberLabel,
} = await $.select(message, options, null, null, { checked: true,
label: rememberLabel, tooltip: rememberTooltip
checked: true, });
tooltip: rememberTooltip
});
if (pref && pref !== 'noPrefsOrContent') { case 20:
// Regardless of whether the user opted _yield$$$select = _context.sent;
// to remember the choice (and move to a URL which won't pref = _yield$$$select.response;
// ask them again), we have to assume the user checked = _yield$$$select.checked;
// doesn't even want to remember their not wanting
// storage, so we don't set the cookie or continue on with
// setting storage on beforeunload
document.cookie = 'svgeditstore=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
// If the URL was configured to always insist on a prompt, if
// the user does indicate a wish to store their info, we
// don't want ask them again upon page refresh so move
// them instead to a URL which does not always prompt
if (storagePrompt === 'true' && checked) { if (!(pref && pref !== 'noPrefsOrContent')) {
replaceStoragePrompt(); _context.next = 30;
return; break;
}
// Regardless of whether the user opted
// to remember the choice (and move to a URL which won't
// ask them again), we have to assume the user
// doesn't even want to remember their not wanting
// storage, so we don't set the cookie or continue on with
// setting storage on beforeunload
document.cookie = 'svgeditstore=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
// If the URL was configured to always insist on a prompt, if
// the user does indicate a wish to store their info, we
// don't want ask them again upon page refresh so move
// them instead to a URL which does not always prompt
if (!(storagePrompt === 'true' && checked)) {
_context.next = 28;
break;
}
replaceStoragePrompt();
return _context.abrupt("return");
case 28:
_context.next = 35;
break;
case 30:
// The user does not wish storage (or cancelled, which we treat equivalently)
removeStoragePrefCookie();
if (pref && // If the user explicitly expresses wish for no storage
emptyStorageOnDecline) {
emptyStorage();
}
if (!(pref && checked)) {
_context.next = 35;
break;
}
// Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false');
return _context.abrupt("return");
case 35:
// Reset width/height of dialog (e.g., for use by Export)
$('#dialog_container')[0].style.width = oldContainerWidth;
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
$('#dialog_content')[0].style.height = oldContentHeight;
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
// beforeunload, but if we wished to update immediately,
// we might wish to try setting:
// svgEditor.setConfig({noStorageOnLoad: true});
// and then call:
// svgEditor.loadContentAndPrefs();
// We don't check for noStorageOnLoad here because
// the prompt gives the user the option to store data
setupBeforeUnloadListener();
svgEditor.storagePromptState = 'closed';
updateCanvas(true);
_context.next = 45;
break;
case 44:
if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener();
}
case 45:
case "end":
return _context.stop();
}
} }
} else { }, _callee);
// The user does not wish storage (or cancelled, which we treat equivalently) }))();
removeStoragePrefCookie();
if (pref && // If the user explicitly expresses wish for no storage
emptyStorageOnDecline) {
emptyStorage();
}
if (pref && checked) {
// Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false');
return;
}
} // Reset width/height of dialog (e.g., for use by Export)
$('#dialog_container')[0].style.width = oldContainerWidth;
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
$('#dialog_content')[0].style.height = oldContentHeight;
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
// beforeunload, but if we wished to update immediately,
// we might wish to try setting:
// svgEditor.setConfig({noStorageOnLoad: true});
// and then call:
// svgEditor.loadContentAndPrefs();
// We don't check for noStorageOnLoad here because
// the prompt gives the user the option to store data
setupBeforeUnloadListener();
svgEditor.storagePromptState = 'closed';
updateCanvas(true);
} else if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener();
}
} }
}; };
} }
}; };
return extStorage; return extStorage;

View File

@ -1,6 +1,42 @@
var svgEditorExtension_webappfind = (function () { var svgEditorExtension_webappfind = (function () {
'use strict'; 'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/** /**
* Depends on Firefox add-on and executables from * Depends on Firefox add-on and executables from
* {@link https://github.com/brettz9/webappfind}. * {@link https://github.com/brettz9/webappfind}.
@ -10,118 +46,131 @@ var svgEditorExtension_webappfind = (function () {
*/ */
var extWebappfind = { var extWebappfind = {
name: 'webappfind', name: 'webappfind',
init: function init(_ref) {
var _this = this;
async init({ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
importLocale, var importLocale, $, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons;
$ return regeneratorRuntime.wrap(function _callee$(_context) {
}) { while (1) {
const strings = await importLocale(); switch (_context.prev = _context.next) {
const svgEditor = this; case 0:
const saveMessage = 'save', importLocale = _ref.importLocale, $ = _ref.$;
readMessage = 'read', _context.next = 3;
excludedMessages = [readMessage, saveMessage]; return importLocale();
let pathID;
this.canvas.bind('message',
/**
* @param {external:Window} win
* @param {PlainObject} info
* @param {module:svgcanvas.SvgCanvas#event:message} info.data
* @param {string} info.origin
* @listens module:svgcanvas.SvgCanvas#event:message
* @throws {Error} Unexpected event type
* @returns {void}
*/
(win, {
data,
origin
}) => {
// eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
let type, content;
try { case 3:
({ strings = _context.sent;
type, svgEditor = _this;
pathID, saveMessage = 'save', readMessage = 'read', excludedMessages = [readMessage, saveMessage];
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 _this.canvas.bind('message',
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) /**
) { * @param {external:Window} win
return; * @param {PlainObject} info
* @param {module:svgcanvas.SvgCanvas#event:message} info.data
* @param {string} info.origin
* @listens module:svgcanvas.SvgCanvas#event:message
* @throws {Error} Unexpected event type
* @returns {void}
*/
function (win, _ref2) {
var data = _ref2.data,
origin = _ref2.origin;
// eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
var type, content;
try {
var _data$webappfind = data.webappfind;
type = _data$webappfind.type;
pathID = _data$webappfind.pathID;
content = _data$webappfind.content;
// 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)
) {
return;
}
} catch (err) {
return;
}
switch (type) {
case 'view':
// Populate the contents
svgEditor.loadFromString(content);
/* if ($('#tool_save_file')) {
$('#tool_save_file').disabled = false;
} */
break;
case 'save-end':
$.alert("save complete for pathID ".concat(pathID, "!"));
break;
default:
throw new Error('Unexpected WebAppFind event type');
}
});
/*
window.postMessage({
webappfind: {
type: readMessage
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even though
// file protocol not currently supported by Firefox)
? '*'
: window.location.origin
);
*/
buttons = [{
id: 'webappfind_save',
//
icon: svgEditor.curConfig.extIconsPath + 'webappfind.png',
type: 'app_menu',
position: 4,
// Before 0-based index position 4 (after the regular "Save Image (S)")
events: {
click: function click() {
if (!pathID) {
// Not ready yet as haven't received first payload
return;
}
window.postMessage({
webappfind: {
type: saveMessage,
pathID: 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);
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'webappfind-icon.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
case 9:
case "end":
return _context.stop();
} }
} catch (err) {
return;
}
switch (type) {
case 'view':
// Populate the contents
svgEditor.loadFromString(content);
/* if ($('#tool_save_file')) {
$('#tool_save_file').disabled = false;
} */
break;
case 'save-end':
$.alert(`save complete for pathID ${pathID}!`);
break;
default:
throw new Error('Unexpected WebAppFind event type');
}
});
/*
window.postMessage({
webappfind: {
type: readMessage
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even though
// file protocol not currently supported by Firefox)
? '*'
: window.location.origin
);
*/
const buttons = [{
id: 'webappfind_save',
//
icon: svgEditor.curConfig.extIconsPath + 'webappfind.png',
type: 'app_menu',
position: 4,
// Before 0-based index position 4 (after the regular "Save Image (S)")
events: {
click() {
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);
} }
}, _callee);
} }))();
}];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'webappfind-icon.svg',
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
})
};
} }
}; };
return extWebappfind; return extWebappfind;

View File

@ -1,6 +1,55 @@
var svgEditorExtension_xdomain_messaging = (function () { var svgEditorExtension_xdomain_messaging = (function () {
'use strict'; 'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/** /**
* Should not be needed for same domain control (just call via child frame), * Should not be needed for same domain control (just call via child frame),
* but an API common for cross-domain and same domain use can be found * but an API common for cross-domain and same domain use can be found
@ -8,43 +57,38 @@ var svgEditorExtension_xdomain_messaging = (function () {
*/ */
var extXdomainMessaging = { var extXdomainMessaging = {
name: 'xdomain-messaging', name: 'xdomain-messaging',
init: function init() {
init() { var svgEditor = this;
const svgEditor = this; var svgCanvas = svgEditor.canvas;
const svgCanvas = svgEditor.canvas;
try { try {
window.addEventListener('message', function (e) { window.addEventListener('message', function (e) {
// We accept and post strings for the sake of IE9 support // 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; return;
} }
const data = typeof e.data === 'object' ? e.data : JSON.parse(e.data); var data = _typeof(e.data) === 'object' ? e.data : JSON.parse(e.data);
if (!data || typeof data !== 'object' || data.namespace !== 'svgCanvas') { if (!data || _typeof(data) !== 'object' || data.namespace !== 'svgCanvas') {
return; return;
} // The default is not to allow any origins, including even the same domain or } // 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 // if run on a `file:///` URL. See `svgedit-config-es.js` for an example of how
// to configure // to configure
const { var allowedOrigins = svgEditor.curConfig.allowedOrigins;
allowedOrigins
} = svgEditor.curConfig;
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) { if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`); // eslint-disable-line no-console console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
return; return;
} }
const cbid = data.id; var cbid = data.id;
const { var name = data.name,
name, args = data.args;
args var message = {
} = data;
const message = {
namespace: 'svg-edit', namespace: 'svg-edit',
id: cbid id: cbid
}; };
@ -52,7 +96,7 @@ var svgEditorExtension_xdomain_messaging = (function () {
try { try {
// Now that we know the origin is trusted, we perform otherwise // Now that we know the origin is trusted, we perform otherwise
// unsafe arbitrary canvas method execution // unsafe arbitrary canvas method execution
message.result = svgCanvas[name](...args); // lgtm [js/remote-property-injection] message.result = svgCanvas[name].apply(svgCanvas, _toConsumableArray(args)); // lgtm [js/remote-property-injection]
} catch (err) { } catch (err) {
message.error = err.message; message.error = err.message;
} }
@ -63,7 +107,6 @@ var svgEditorExtension_xdomain_messaging = (function () {
console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console
} }
} }
}; };
return extXdomainMessaging; return extXdomainMessaging;

View File

@ -20,14 +20,12 @@
} }
/* globals jQuery */ /* globals jQuery */
const $ = jQuery; var $ = jQuery;
$('a').click(function () { $('a').click(function () {
const { var href = this.href;
href var target = window.parent;
} = this;
const target = window.parent;
const post = message => { var post = function post(message) {
// Todo: Make origin customizable as set by opening window // Todo: Make origin customizable as set by opening window
// Todo: If dropping IE9, avoid stringifying // Todo: If dropping IE9, avoid stringifying
target.postMessage(JSON.stringify(_extends({ target.postMessage(JSON.stringify(_extends({
@ -44,15 +42,15 @@
}); });
if (!href.includes('.svg')) { if (!href.includes('.svg')) {
const img = new Image(); var img = new Image();
img.addEventListener('load', function () { img.addEventListener('load', function () {
const canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
canvas.width = this.width; canvas.width = this.width;
canvas.height = this.height; // load the raster image into the canvas canvas.height = this.height; // load the raster image into the canvas
canvas.getContext('2d').drawImage(this, 0, 0); // retrieve the data: URL canvas.getContext('2d').drawImage(this, 0, 0); // retrieve the data: URL
let data; var data;
try { try {
data = canvas.toDataURL(); data = canvas.toDataURL();
@ -65,8 +63,8 @@
} }
post({ post({
href, href: href,
data data: data
}); });
}); });
img.src = href; img.src = href;
@ -74,8 +72,8 @@
// Do ajax request for image's href value // Do ajax request for image's href value
$.get(href, function (data) { $.get(href, function (data) {
post({ post({
href, href: href,
data data: data
}); });
}, 'html'); // 'html' is necessary to keep returned data as a string }, 'html'); // 'html' is necessary to keep returned data as a string
} }

File diff suppressed because it is too large Load Diff

33382
dist/index-es.js vendored

File diff suppressed because one or more lines are too long

146
dist/index-es.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

33382
dist/index-umd.js vendored

File diff suppressed because one or more lines are too long

146
dist/index-umd.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,100 @@
(function () { (function () {
'use strict'; 'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/** /**
* For parsing color values. * For parsing color values.
* @module RGBColor * @module RGBColor
@ -8,7 +102,7 @@
* @see https://www.phpied.com/rgb-color-parser-in-javascript/ * @see https://www.phpied.com/rgb-color-parser-in-javascript/
* @license MIT * @license MIT
*/ */
const simpleColors = { var simpleColors = {
aliceblue: 'f0f8ff', aliceblue: 'f0f8ff',
antiquewhite: 'faebd7', antiquewhite: 'faebd7',
aqua: '00ffff', aqua: '00ffff',
@ -154,43 +248,59 @@
yellowgreen: '9acd32' yellowgreen: '9acd32'
}; // array of color definition objects }; // array of color definition objects
const colorDefs = [{ var colorDefs = [{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
// re: /^rgb\((?<r>\d{1,3}),\s*(?<g>\d{1,3}),\s*(?<b>\d{1,3})\)$/, // re: /^rgb\((?<r>\d{1,3}),\s*(?<g>\d{1,3}),\s*(?<b>\d{1,3})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process: function process(_) {
for (var _len = arguments.length, bits = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
bits[_key - 1] = arguments[_key];
}
process(_, ...bits) { return bits.map(function (b) {
return bits.map(b => Number.parseInt(b)); return Number.parseInt(b);
});
} }
}, { }, {
re: /^(\w{2})(\w{2})(\w{2})$/, re: /^(\w{2})(\w{2})(\w{2})$/,
// re: /^(?<r>\w{2})(?<g>\w{2})(?<b>\w{2})$/, // re: /^(?<r>\w{2})(?<g>\w{2})(?<b>\w{2})$/,
example: ['#00ff00', '336699'], example: ['#00ff00', '336699'],
process: function process(_) {
for (var _len2 = arguments.length, bits = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
bits[_key2 - 1] = arguments[_key2];
}
process(_, ...bits) { return bits.map(function (b) {
return bits.map(b => Number.parseInt(b, 16)); return Number.parseInt(b, 16);
});
} }
}, { }, {
re: /^(\w)(\w)(\w)$/, re: /^(\w)(\w)(\w)$/,
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/, // re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'], example: ['#fb0', 'f0f'],
process: function process(_) {
for (var _len3 = arguments.length, bits = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
bits[_key3 - 1] = arguments[_key3];
}
process(_, ...bits) { return bits.map(function (b) {
return bits.map(b => Number.parseInt(b + b, 16)); return Number.parseInt(b + b, 16);
});
} }
}]; }];
/** /**
* A class to parse color values. * A class to parse color values.
*/ */
class RGBColor { var RGBColor = /*#__PURE__*/function () {
/** /**
* @param {string} colorString * @param {string} colorString
*/ */
constructor(colorString) { function RGBColor(colorString) {
var _this = this;
_classCallCheck(this, RGBColor);
this.ok = false; // strip any leading # this.ok = false; // strip any leading #
if (colorString.charAt(0) === '#') { if (colorString.charAt(0) === '#') {
@ -208,20 +318,24 @@
// search through the definitions to find a match // search through the definitions to find a match
colorDefs.forEach(({ colorDefs.forEach(function (_ref) {
re, var re = _ref.re,
process: processor processor = _ref.process;
}) => { var bits = re.exec(colorString);
const bits = re.exec(colorString);
if (bits) { if (bits) {
const [r, g, b] = processor(...bits); var _processor = processor.apply(void 0, _toConsumableArray(bits)),
Object.assign(this, { _processor2 = _slicedToArray(_processor, 3),
r, r = _processor2[0],
g, g = _processor2[1],
b b = _processor2[2];
Object.assign(_this, {
r: r,
g: g,
b: b
}); });
this.ok = true; _this.ok = true;
} }
}); // validate/cleanup values }); // validate/cleanup values
@ -235,75 +349,73 @@
*/ */
toRGB() { _createClass(RGBColor, [{
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')'; key: "toRGB",
} value: function toRGB() {
/** return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
* @returns {string}
*/
toHex() {
let r = this.r.toString(16);
let g = this.g.toString(16);
let b = this.b.toString(16);
if (r.length === 1) {
r = '0' + r;
} }
/**
* @returns {string}
*/
if (g.length === 1) { }, {
g = '0' + g; key: "toHex",
} value: function toHex() {
var r = this.r.toString(16);
var g = this.g.toString(16);
var b = this.b.toString(16);
if (b.length === 1) { if (r.length === 1) {
b = '0' + b; r = '0' + r;
}
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
static getHelpXML() {
const examples = [// add regexps
...colorDefs.flatMap(({
example
}) => {
return example;
}), // add type-in colors
...Object.keys(simpleColors)];
const xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append(...examples.map(example => {
try {
const listItem = document.createElement('li');
const listColor = new RGBColor(example);
const exampleDiv = document.createElement('div');
exampleDiv.style.cssText = `
margin: 3px;
border: 1px solid black;
background: ${listColor.toHex()};
color: ${listColor.toHex()};`;
exampleDiv.append('test');
const listItemValue = ` ${example} -> ${listColor.toRGB()} -> ${listColor.toHex()}`;
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
} }
}));
return xml;
}
} if (g.length === 1) {
g = '0' + g;
}
/* globals jsPDF */ if (b.length === 1) {
const jsPDFAPI = jsPDF.API; b = '0' + b;
const pdfSvgAttr = { }
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
var jsPDFAPI = jsPDF.API;
var pdfSvgAttr = {
// allowed attributes. all others are removed from the preview. // allowed attributes. all others are removed from the preview.
g: ['stroke', 'fill', 'stroke-width'], g: ['stroke', 'fill', 'stroke-width'],
line: ['x1', 'y1', 'x2', 'y2', 'stroke', 'stroke-width'], line: ['x1', 'y1', 'x2', 'y2', 'stroke', 'stroke-width'],
@ -316,35 +428,37 @@
text: ['x', 'y', 'font-size', 'font-family', 'text-anchor', 'font-weight', 'font-style', 'fill'] text: ['x', 'y', 'font-size', 'font-family', 'text-anchor', 'font-weight', 'font-style', 'fill']
}; };
const attributeIsNotEmpty = function (node, attr) { var attributeIsNotEmpty = function attributeIsNotEmpty(node, attr) {
const attVal = attr ? node.getAttribute(attr) : node; var attVal = attr ? node.getAttribute(attr) : node;
return attVal !== '' && attVal !== null && attVal !== 'null'; return attVal !== '' && attVal !== null && attVal !== 'null';
}; };
const nodeIs = function (node, possible) { var nodeIs = function nodeIs(node, possible) {
return possible.includes(node.tagName.toLowerCase()); return possible.includes(node.tagName.toLowerCase());
}; };
const removeAttributes = function (node, attributes) { var removeAttributes = function removeAttributes(node, attributes) {
const toRemove = []; var toRemove = [];
[].forEach.call(node.attributes, function (a) { [].forEach.call(node.attributes, function (a) {
if (attributeIsNotEmpty(a) && !attributes.includes(a.name.toLowerCase())) { if (attributeIsNotEmpty(a) && !attributes.includes(a.name.toLowerCase())) {
toRemove.push(a.name); toRemove.push(a.name);
} }
}); });
toRemove.forEach(a => { toRemove.forEach(function (a) {
node.removeAttribute(a.name); node.removeAttribute(a.name);
}); });
}; };
const numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+|)/g; var numRgx = /[+-]?(?:\d+\.\d*|\d+|\.\d+)(?:[eE]\d+|[eE][+-]\d+|)/g;
const getLinesOptionsOfPoly = function (node) { var getLinesOptionsOfPoly = function getLinesOptionsOfPoly(node) {
let nums = node.getAttribute('points'); var nums = node.getAttribute('points');
nums = nums && nums.match(numRgx) || []; nums = nums && nums.match(numRgx) || [];
if (nums && nums.length) { if (nums && nums.length) {
nums = nums.map(n => Number(n)); nums = nums.map(function (n) {
return Number(n);
});
if (nums.length % 2) { if (nums.length % 2) {
nums.length--; nums.length--;
@ -357,40 +471,43 @@
return undefined; return undefined;
} }
const [x, y] = nums, var _nums = nums,
lines = []; _nums2 = _slicedToArray(_nums, 2),
x = _nums2[0],
y = _nums2[1],
lines = [];
for (let i = 2; i < nums.length; i += 2) { for (var i = 2; i < nums.length; i += 2) {
lines.push([nums[i] - nums[i - 2], nums[i + 1] - nums[i - 1]]); lines.push([nums[i] - nums[i - 2], nums[i + 1] - nums[i - 1]]);
} }
return { return {
x, x: x,
y, y: y,
lines lines: lines
}; };
}; };
const getLinesOptionsOfPath = function (node) { var getLinesOptionsOfPath = function getLinesOptionsOfPath(node) {
const segList = node.pathSegList, var segList = node.pathSegList,
n = segList.numberOfItems, n = segList.numberOfItems,
opsList = []; opsList = [];
let ops = { var ops = {
lines: [] lines: []
}; };
const curr = { var curr = {
x: 0, x: 0,
y: 0 y: 0
}; };
const reflectControl = { var reflectControl = {
x: 0, x: 0,
y: 0 y: 0
}; };
const toRelative = function (nums, relativeTo) { var toRelative = function toRelative(nums, relativeTo) {
const re = []; var re = [];
for (let i = 0; i < nums.length - 1; i += 2) { for (var i = 0; i < nums.length - 1; i += 2) {
re[i] = nums[i] - relativeTo.x; re[i] = nums[i] - relativeTo.x;
re[i + 1] = nums[i + 1] - relativeTo.y; re[i + 1] = nums[i + 1] - relativeTo.y;
} }
@ -398,24 +515,22 @@
return re; return re;
}; };
const curveQToC = function (nums) { var curveQToC = function curveQToC(nums) {
const a = 2 / 3; var a = 2 / 3;
const re = [nums[0] * a, nums[1] * a, nums[2] + (nums[0] - nums[2]) * a, nums[3] + (nums[1] - nums[3]) * a, nums[2], nums[3]]; var re = [nums[0] * a, nums[1] * a, nums[2] + (nums[0] - nums[2]) * a, nums[3] + (nums[1] - nums[3]) * a, nums[2], nums[3]];
return re; return re;
}; };
for (let i = 0, letterPrev; i < n; i++) { for (var i = 0, letterPrev; i < n; i++) {
const seg = segList.getItem(i); var seg = segList.getItem(i);
const { var x1 = seg.x1,
x1, y1 = seg.y1,
y1, x2 = seg.x2,
x2, y2 = seg.y2,
y2, x = seg.x,
x, y = seg.y,
y, letter = seg.pathSegTypeAsLetter;
pathSegTypeAsLetter: letter var isRelative = letter >= 'a'; // lowercase letter
} = seg;
const isRelative = letter >= 'a'; // lowercase letter
switch (letter) { switch (letter) {
case 'M': case 'M':
@ -489,7 +604,7 @@
case 'T': case 'T':
{ {
const p1 = letterPrev && 'QqTt'.includes(letterPrev) ? reflectControl : { var p1 = letterPrev && 'QqTt'.includes(letterPrev) ? reflectControl : {
x: 0, x: 0,
y: 0 y: 0
}; };
@ -501,13 +616,14 @@
case 't': case 't':
{ {
const p1 = letterPrev && 'QqTt'.includes(letterPrev) ? reflectControl : { var _p = letterPrev && 'QqTt'.includes(letterPrev) ? reflectControl : {
x: 0, x: 0,
y: 0 y: 0
}; };
ops.lines.push([p1.x, p1.y, x, y]);
reflectControl.x = x - p1.x; ops.lines.push([_p.x, _p.y, x, y]);
reflectControl.y = y - p1.y; reflectControl.x = x - _p.x;
reflectControl.y = y - _p.y;
break; break;
} }
@ -526,15 +642,15 @@
case 'S': case 'S':
case 's': case 's':
{ {
const p1 = letterPrev && 'CcSs'.includes(letterPrev) ? reflectControl : { var _p2 = letterPrev && 'CcSs'.includes(letterPrev) ? reflectControl : {
x: 0, x: 0,
y: 0 y: 0
}; };
if (isRelative) { if (isRelative) {
ops.lines.push([p1.x, p1.y, x2, y2, x, y]); ops.lines.push([_p2.x, _p2.y, x2, y2, x, y]);
} else { } else {
ops.lines.push([p1.x, p1.y].concat(toRelative([x2, y2, x, y], curr))); ops.lines.push([_p2.x, _p2.y].concat(toRelative([x2, y2, x, y], curr)));
} }
reflectControl.x = x - x2; reflectControl.x = x - x2;
@ -592,21 +708,21 @@
return opsList; return opsList;
}; };
const svgElementToPdf = function (element, pdf, options) { var svgElementToPdf = function svgElementToPdf(element, pdf, options) {
// pdf is a jsPDF object // pdf is a jsPDF object
// console.log('options =', options); // console.log('options =', options);
const remove = options.removeInvalid === undefined ? false : options.removeInvalid; var remove = options.removeInvalid === undefined ? false : options.removeInvalid;
const k = options.scale === undefined ? 1.0 : options.scale; var k = options.scale === undefined ? 1.0 : options.scale;
let colorMode = null; var colorMode = null;
[].forEach.call(element.children, function (node) { [].forEach.call(element.children, function (node) {
// console.log('passing: ', node); // console.log('passing: ', node);
// let hasStrokeColor = false; // let hasStrokeColor = false;
let hasFillColor = false; var hasFillColor = false;
let fillRGB; var fillRGB;
colorMode = null; colorMode = null;
if (nodeIs(node, ['g', 'line', 'rect', 'ellipse', 'circle', 'polygon', 'polyline', 'path', 'text'])) { if (nodeIs(node, ['g', 'line', 'rect', 'ellipse', 'circle', 'polygon', 'polyline', 'path', 'text'])) {
const fillColor = node.getAttribute('fill'); var fillColor = node.getAttribute('fill');
if (attributeIsNotEmpty(fillColor) && node.getAttribute('fill-opacity') !== '0') { if (attributeIsNotEmpty(fillColor) && node.getAttribute('fill-opacity') !== '0') {
fillRGB = new RGBColor(fillColor); fillRGB = new RGBColor(fillColor);
@ -629,10 +745,10 @@
pdf.setLineWidth(k * Number.parseInt(node.getAttribute('stroke-width'))); pdf.setLineWidth(k * Number.parseInt(node.getAttribute('stroke-width')));
} }
const strokeColor = node.getAttribute('stroke'); var 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); var strokeRGB = new RGBColor(strokeColor);
if (strokeRGB.ok) { if (strokeRGB.ok) {
// hasStrokeColor = true; // hasStrokeColor = true;
@ -649,7 +765,7 @@
} }
} }
const tag = node.tagName.toLowerCase(); var tag = node.tagName.toLowerCase();
switch (tag) { switch (tag) {
case 'svg': case 'svg':
@ -682,7 +798,7 @@
case 'polygon': case 'polygon':
case 'polyline': case 'polyline':
{ {
const linesOptions = getLinesOptionsOfPoly(node); var linesOptions = getLinesOptionsOfPoly(node);
if (linesOptions) { if (linesOptions) {
pdf.lines(linesOptions.lines, k * linesOptions.x, k * linesOptions.y, [k, k], colorMode, tag === 'polygon' // polygon is closed, polyline is not closed pdf.lines(linesOptions.lines, k * linesOptions.x, k * linesOptions.y, [k, k], colorMode, tag === 'polygon' // polygon is closed, polyline is not closed
@ -696,14 +812,14 @@
case 'path': case 'path':
{ {
if (colorMode) { if (colorMode) {
const linesOptionsList = getLinesOptionsOfPath(node); var linesOptionsList = getLinesOptionsOfPath(node);
if (linesOptionsList.length > 0) { if (linesOptionsList.length > 0) {
linesOptionsList.forEach(function (linesOptions) { linesOptionsList.forEach(function (linesOptions) {
pdf.lines(linesOptions.lines, k * linesOptions.x, k * linesOptions.y, [k, k], null, linesOptions.closed); pdf.lines(linesOptions.lines, k * linesOptions.x, k * linesOptions.y, [k, k], null, linesOptions.closed);
}); // svg fill rule default is nonzero }); // svg fill rule default is nonzero
const fillRule = node.getAttribute('fill-rule'); var fillRule = node.getAttribute('fill-rule');
if (fillRule === 'evenodd') { if (fillRule === 'evenodd') {
// f* : fill using even-odd rule // f* : fill using even-odd rule
@ -757,7 +873,7 @@
pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b); pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b);
} }
let fontType = ''; var fontType = '';
if (node.hasAttribute('font-weight')) { if (node.hasAttribute('font-weight')) {
if (node.getAttribute('font-weight') === 'bold') { if (node.getAttribute('font-weight') === 'bold') {
@ -776,22 +892,22 @@
} }
pdf.setFontType(fontType); pdf.setFontType(fontType);
const pdfFontSize = node.hasAttribute('font-size') ? Number.parseInt(node.getAttribute('font-size')) : 16; var pdfFontSize = node.hasAttribute('font-size') ? Number.parseInt(node.getAttribute('font-size')) : 16;
/** /**
* *
* @param {Element} elem * @param {Element} elem
* @returns {Float} * @returns {Float}
*/ */
const getWidth = elem => { var getWidth = function getWidth(elem) {
let box; var box;
try { try {
box = elem.getBBox(); // Firefox on MacOS will raise error here box = elem.getBBox(); // Firefox on MacOS will raise error here
} catch (err) { } catch (err) {
// copy and append to body so that getBBox is available // copy and append to body so that getBBox is available
const nodeCopy = elem.cloneNode(true); var nodeCopy = elem.cloneNode(true);
const svg = elem.ownerSVGElement.cloneNode(false); var svg = elem.ownerSVGElement.cloneNode(false);
svg.appendChild(nodeCopy); svg.appendChild(nodeCopy);
document.body.appendChild(svg); document.body.appendChild(svg);
@ -810,7 +926,7 @@
}; // TODO: use more accurate positioning!! }; // TODO: use more accurate positioning!!
let x, var x,
y, y,
xOffset = 0; xOffset = 0;

View File

@ -142,7 +142,7 @@ var svgEditorLang_af = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_af = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Verwyder Laag', del: 'Verwyder Laag',
move_down: 'Beweeg afbreek Down', move_down: 'Beweeg afbreek Down',
new: 'Nuwe Layer', "new": 'Nuwe Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Beweeg afbreek Up', move_up: 'Beweeg afbreek Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ar = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ar = (function () {
layers: 'Layers', layers: 'Layers',
del: 'حذف طبقة', del: 'حذف طبقة',
move_down: 'تحرك لأسفل طبقة', move_down: 'تحرك لأسفل طبقة',
new: 'طبقة جديدة', "new": 'طبقة جديدة',
rename: 'تسمية الطبقة', rename: 'تسمية الطبقة',
move_up: 'تحرك لأعلى طبقة', move_up: 'تحرك لأعلى طبقة',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_az = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_az = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_be = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_be = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Выдаліць слой', del: 'Выдаліць слой',
move_down: 'Перамясціць слой на', move_down: 'Перамясціць слой на',
new: 'Новы слой', "new": 'Новы слой',
rename: 'Перайменаваць Слой', rename: 'Перайменаваць Слой',
move_up: 'Перамяшчэнне слоя да', move_up: 'Перамяшчэнне слоя да',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_bg = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_bg = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Изтриване на слой', del: 'Изтриване на слой',
move_down: 'Move слой надолу', move_down: 'Move слой надолу',
new: 'Нов слой', "new": 'Нов слой',
rename: 'Преименуване Layer', rename: 'Преименуване Layer',
move_up: 'Move Up Layer', move_up: 'Move Up Layer',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ca = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ca = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Eliminar capa', del: 'Eliminar capa',
move_down: 'Mou la capa de Down', move_down: 'Mou la capa de Down',
new: 'Nova capa', "new": 'Nova capa',
rename: 'Canvieu el nom de la capa', rename: 'Canvieu el nom de la capa',
move_up: 'Mou la capa Up', move_up: 'Mou la capa Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_cs = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_cs = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Odstranit vrstvu', del: 'Odstranit vrstvu',
move_down: 'Přesunout vrstvu níž', move_down: 'Přesunout vrstvu níž',
new: 'Přidat vrstvu', "new": 'Přidat vrstvu',
rename: 'Přejmenovat vrstvu', rename: 'Přejmenovat vrstvu',
move_up: 'Přesunout vrstvu výš', move_up: 'Přesunout vrstvu výš',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_cy = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_cy = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Dileu Haen', del: 'Dileu Haen',
move_down: 'Symud Haen i Lawr', move_down: 'Symud Haen i Lawr',
new: 'Haen Newydd', "new": 'Haen Newydd',
rename: 'Ail-enwi Haen', rename: 'Ail-enwi Haen',
move_up: 'Symud Haen Up', move_up: 'Symud Haen Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_da = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_da = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Slet Layer', del: 'Slet Layer',
move_down: 'Flyt lag ned', move_down: 'Flyt lag ned',
new: 'New Layer', "new": 'New Layer',
rename: 'Omdøb Layer', rename: 'Omdøb Layer',
move_up: 'Flyt Layer Up', move_up: 'Flyt Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_de = (function () {
copy: 'Kopieren', copy: 'Kopieren',
paste: 'Einfügen', paste: 'Einfügen',
paste_in_place: 'Bei Originalposition einfügen', paste_in_place: 'Bei Originalposition einfügen',
delete: 'Löschen', "delete": 'Löschen',
group: 'Gruppieren', group: 'Gruppieren',
move_front: 'Nach ganz oben verschieben', move_front: 'Nach ganz oben verschieben',
move_up: 'Hochschieben', move_up: 'Hochschieben',
@ -154,7 +154,7 @@ var svgEditorLang_de = (function () {
layers: 'Ebenen', layers: 'Ebenen',
del: 'Ebene löschen', del: 'Ebene löschen',
move_down: 'Ebene nach unten verschieben', move_down: 'Ebene nach unten verschieben',
new: 'Neue Ebene', "new": 'Neue Ebene',
rename: 'Ebene umbenennen', rename: 'Ebene umbenennen',
move_up: 'Ebene nach oben verschieben', move_up: 'Ebene nach oben verschieben',
dupe: 'Ebene duplizieren', dupe: 'Ebene duplizieren',

View File

@ -142,7 +142,7 @@ var svgEditorLang_el = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_el = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Διαγραφήστρώματος', del: 'Διαγραφήστρώματος',
move_down: 'Μετακίνηση Layer Down', move_down: 'Μετακίνηση Layer Down',
new: 'Νέο Layer', "new": 'Νέο Layer',
rename: 'Μετονομασία Layer', rename: 'Μετονομασία Layer',
move_up: 'Μετακίνηση Layer Up', move_up: 'Μετακίνηση Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_en = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_en = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer...', dupe: 'Duplicate Layer...',

View File

@ -142,7 +142,7 @@ var svgEditorLang_es = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_es = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Suprimir capa', del: 'Suprimir capa',
move_down: 'Mover la capa hacia abajo', move_down: 'Mover la capa hacia abajo',
new: 'Nueva capa', "new": 'Nueva capa',
rename: 'Renombrar capa', rename: 'Renombrar capa',
move_up: 'Mover la capa hacia arriba', move_up: 'Mover la capa hacia arriba',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_et = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_et = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Kustuta Kiht', del: 'Kustuta Kiht',
move_down: 'Liiguta kiht alla', move_down: 'Liiguta kiht alla',
new: 'Uus kiht', "new": 'Uus kiht',
rename: 'Nimeta kiht', rename: 'Nimeta kiht',
move_up: 'Liiguta kiht üles', move_up: 'Liiguta kiht üles',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_fa = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'حذف', "delete": 'حذف',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_fa = (function () {
layers: 'Layers', layers: 'Layers',
del: '‫حذف لایه‬', del: '‫حذف لایه‬',
move_down: '‫انتقال لایه به پایین‬', move_down: '‫انتقال لایه به پایین‬',
new: '‫لایه جدید‬', "new": '‫لایه جدید‬',
rename: '‫تغییر نام لایه‬', rename: '‫تغییر نام لایه‬',
move_up: '‫انتقال لایه به بالا‬', move_up: '‫انتقال لایه به بالا‬',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_fi = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_fi = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Poista Layer', del: 'Poista Layer',
move_down: 'Siirrä Layer alas', move_down: 'Siirrä Layer alas',
new: 'New Layer', "new": 'New Layer',
rename: 'Nimeä Layer', rename: 'Nimeä Layer',
move_up: 'Siirrä Layer', move_up: 'Siirrä Layer',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_fr = (function () {
copy: 'Copier', copy: 'Copier',
paste: 'Coller', paste: 'Coller',
paste_in_place: 'Coller sur place', paste_in_place: 'Coller sur place',
delete: 'Supprimer', "delete": 'Supprimer',
group: 'Grouper', group: 'Grouper',
move_front: 'Placer au premier plan', move_front: 'Placer au premier plan',
move_up: "Avancer d'un plan", move_up: "Avancer d'un plan",
@ -154,7 +154,7 @@ var svgEditorLang_fr = (function () {
layers: 'Calques', layers: 'Calques',
del: 'Supprimer le calque', del: 'Supprimer le calque',
move_down: 'Descendre le calque', move_down: 'Descendre le calque',
new: 'Nouveau calque', "new": 'Nouveau calque',
rename: 'Renommer le calque', rename: 'Renommer le calque',
move_up: 'Monter le calque', move_up: 'Monter le calque',
dupe: 'Dupliquer le calque', dupe: 'Dupliquer le calque',

View File

@ -142,7 +142,7 @@ var svgEditorLang_fy = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_fy = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Laach fuortsmite', del: 'Laach fuortsmite',
move_down: 'Laach omleech bringe', move_down: 'Laach omleech bringe',
new: 'Nije laach', "new": 'Nije laach',
rename: 'Laach omneame', rename: 'Laach omneame',
move_up: 'Laach omheech bringe', move_up: 'Laach omheech bringe',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ga = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ga = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Scrios Sraith', del: 'Scrios Sraith',
move_down: 'Bog Sraith Síos', move_down: 'Bog Sraith Síos',
new: 'Sraith Nua', "new": 'Sraith Nua',
rename: 'Athainmnigh Sraith', rename: 'Athainmnigh Sraith',
move_up: 'Bog Sraith Suas', move_up: 'Bog Sraith Suas',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_gl = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_gl = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move capa inferior', move_down: 'Move capa inferior',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_he = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_he = (function () {
layers: 'Layers', layers: 'Layers',
del: 'מחיקת שכבה', del: 'מחיקת שכבה',
move_down: 'הזז למטה שכבה', move_down: 'הזז למטה שכבה',
new: 'שכבהחדשה', "new": 'שכבהחדשה',
rename: 'שינוי שם שכבה', rename: 'שינוי שם שכבה',
move_up: 'העבר שכבה Up', move_up: 'העבר שכבה Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_hi = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_hi = (function () {
layers: 'Layers', layers: 'Layers',
del: 'परत हटाएँ', del: 'परत हटाएँ',
move_down: 'परत नीचे ले जाएँ', move_down: 'परत नीचे ले जाएँ',
new: 'नई परत', "new": 'नई परत',
rename: 'परत का नाम बदलें', rename: 'परत का नाम बदलें',
move_up: 'परत ऊपर ले जाएँ', move_up: 'परत ऊपर ले जाएँ',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_hr = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_hr = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Brisanje sloja', del: 'Brisanje sloja',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Preimenuj Layer', rename: 'Preimenuj Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_hu = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_hu = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Réteg törlése', del: 'Réteg törlése',
move_down: 'Mozgatása lefelé', move_down: 'Mozgatása lefelé',
new: 'Új réteg', "new": 'Új réteg',
rename: 'Réteg átnevezése', rename: 'Réteg átnevezése',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_hy = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_hy = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_id = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_id = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Hapus Layer', del: 'Hapus Layer',
move_down: 'Pindahkan Layer Bawah', move_down: 'Pindahkan Layer Bawah',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Pindahkan Layer Up', move_up: 'Pindahkan Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_is = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_is = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Eyða Lag', del: 'Eyða Lag',
move_down: 'Færa Layer Down', move_down: 'Færa Layer Down',
new: 'Lag', "new": 'Lag',
rename: 'Endurnefna Lag', rename: 'Endurnefna Lag',
move_up: 'Færa Lag Up', move_up: 'Færa Lag Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_it = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_it = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Elimina il livello', del: 'Elimina il livello',
move_down: 'Sposta indietro il livello', move_down: 'Sposta indietro il livello',
new: 'Nuovo livello', "new": 'Nuovo livello',
rename: 'Rinomina il livello', rename: 'Rinomina il livello',
move_up: 'Sposta avanti il livello', move_up: 'Sposta avanti il livello',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ja = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ja = (function () {
layers: 'Layers', layers: 'Layers',
del: 'レイヤの削除', del: 'レイヤの削除',
move_down: 'レイヤを下へ移動', move_down: 'レイヤを下へ移動',
new: '新規レイヤ', "new": '新規レイヤ',
rename: 'レイヤの名前を変更', rename: 'レイヤの名前を変更',
move_up: 'レイヤを上へ移動', move_up: 'レイヤを上へ移動',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ko = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ko = (function () {
layers: 'Layers', layers: 'Layers',
del: '레이어 삭제', del: '레이어 삭제',
move_down: '레이어 아래로 이동', move_down: '레이어 아래로 이동',
new: '새 레이어', "new": '새 레이어',
rename: '레이어 이름 바꾸기', rename: '레이어 이름 바꾸기',
move_up: '레이어 위로 이동', move_up: '레이어 위로 이동',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_lt = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_lt = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Ištrinti Layer', del: 'Ištrinti Layer',
move_down: 'Perkelti sluoksnį Žemyn', move_down: 'Perkelti sluoksnį Žemyn',
new: 'New Layer', "new": 'New Layer',
rename: 'Pervadinti sluoksnį', rename: 'Pervadinti sluoksnį',
move_up: 'Perkelti sluoksnį Up', move_up: 'Perkelti sluoksnį Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_lv = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_lv = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Dzēst Layer', del: 'Dzēst Layer',
move_down: 'Pārvietot slāni uz leju', move_down: 'Pārvietot slāni uz leju',
new: 'New Layer', "new": 'New Layer',
rename: 'Pārdēvēt Layer', rename: 'Pārdēvēt Layer',
move_up: 'Pārvietot slāni uz augšu', move_up: 'Pārvietot slāni uz augšu',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_mk = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_mk = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Избриши Слој', del: 'Избриши Слој',
move_down: 'Премести слој долу', move_down: 'Премести слој долу',
new: 'Нов слој', "new": 'Нов слој',
rename: 'Преименувај слој', rename: 'Преименувај слој',
move_up: 'Премести слој горе', move_up: 'Премести слој горе',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ms = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_ms = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Padam Layer', del: 'Padam Layer',
move_down: 'Pindah Layer Bawah', move_down: 'Pindah Layer Bawah',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Pindah Layer Up', move_up: 'Pindah Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_mt = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_mt = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Ħassar Layer', del: 'Ħassar Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Semmi mill-ġdid Layer', rename: 'Semmi mill-ġdid Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_nl = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_nl = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete laag', del: 'Delete laag',
move_down: 'Beweeg laag omlaag', move_down: 'Beweeg laag omlaag',
new: 'Nieuwe laag', "new": 'Nieuwe laag',
rename: 'Hernoem laag', rename: 'Hernoem laag',
move_up: 'Beweeg laag omhoog', move_up: 'Beweeg laag omhoog',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_no = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_no = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Slett laget', del: 'Slett laget',
move_down: 'Flytt laget ned', move_down: 'Flytt laget ned',
new: 'Nytt lag', "new": 'Nytt lag',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Flytt Layer Up', move_up: 'Flytt Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -143,7 +143,7 @@ var svgEditorLang_pl = (function () {
copy: 'Kopiuj', copy: 'Kopiuj',
paste: 'Wklej', paste: 'Wklej',
paste_in_place: 'Wklej w miejscu', paste_in_place: 'Wklej w miejscu',
delete: 'Usuń', "delete": 'Usuń',
group: 'Grupuj', group: 'Grupuj',
move_front: 'Przenieś do przodu', move_front: 'Przenieś do przodu',
move_up: 'Przenieś warstwę w górę', move_up: 'Przenieś warstwę w górę',
@ -155,7 +155,7 @@ var svgEditorLang_pl = (function () {
layers: 'Warstwy', layers: 'Warstwy',
del: 'Usuń warstwę', del: 'Usuń warstwę',
move_down: 'Przenieś warstwę w dół', move_down: 'Przenieś warstwę w dół',
new: 'Nowa warstwa', "new": 'Nowa warstwa',
rename: 'Zmień nazwę warstwy', rename: 'Zmień nazwę warstwy',
move_up: 'Przenieś warstwę w górę', move_up: 'Przenieś warstwę w górę',
dupe: 'Duplikuj warstwę', dupe: 'Duplikuj warstwę',

View File

@ -142,7 +142,7 @@ var svgEditorLang_pt_BR = (function () {
copy: 'Copiar', copy: 'Copiar',
paste: 'Colar', paste: 'Colar',
paste_in_place: 'Colar no mesmo local', paste_in_place: 'Colar no mesmo local',
delete: 'Deletar', "delete": 'Deletar',
group: 'Agrupar', group: 'Agrupar',
move_front: 'Trazer para Frente', move_front: 'Trazer para Frente',
move_up: 'Avançar', move_up: 'Avançar',
@ -154,7 +154,7 @@ var svgEditorLang_pt_BR = (function () {
layers: 'Camadas', layers: 'Camadas',
del: 'Deletar Camada', del: 'Deletar Camada',
move_down: 'Enviar Camada para Trás', move_down: 'Enviar Camada para Trás',
new: 'Nova Camada', "new": 'Nova Camada',
rename: 'Renomear Camada', rename: 'Renomear Camada',
move_up: 'Trazer Camada para Frente', move_up: 'Trazer Camada para Frente',
dupe: 'Duplicar Camada', dupe: 'Duplicar Camada',

View File

@ -142,7 +142,7 @@ var svgEditorLang_pt_PT = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_pt_PT = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move camada para baixo', move_down: 'Move camada para baixo',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_ro = (function () {
copy: 'Copiere', copy: 'Copiere',
paste: 'Reproducere', paste: 'Reproducere',
paste_in_place: 'Reproducere pe loc', paste_in_place: 'Reproducere pe loc',
delete: 'Ştergere', "delete": 'Ştergere',
group: 'Group', group: 'Group',
move_front: 'Pune in faţa', move_front: 'Pune in faţa',
move_up: 'Pune in spate', move_up: 'Pune in spate',
@ -154,7 +154,7 @@ var svgEditorLang_ro = (function () {
layers: 'Straturi', layers: 'Straturi',
del: 'Ştergeţi Strat', del: 'Ştergeţi Strat',
move_down: 'Mutare Strat în Jos', move_down: 'Mutare Strat în Jos',
new: 'Strat Nou', "new": 'Strat Nou',
rename: 'Redenumiţi Stratul', rename: 'Redenumiţi Stratul',
move_up: 'Mutare Strat în Sus', move_up: 'Mutare Strat în Sus',
dupe: 'Duplicaţi Stratul', dupe: 'Duplicaţi Stratul',

View File

@ -154,7 +154,7 @@ var svgEditorLang_ru = (function () {
layers: 'Слои', layers: 'Слои',
del: 'Удалить слой', del: 'Удалить слой',
move_down: 'Опустить слой', move_down: 'Опустить слой',
new: 'Создать слой', "new": 'Создать слой',
rename: 'Переименовать Слой', rename: 'Переименовать Слой',
move_up: 'Поднять слой', move_up: 'Поднять слой',
dupe: 'Копировать слой', dupe: 'Копировать слой',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sk = (function () {
copy: 'Kópia', copy: 'Kópia',
paste: 'Vloženie', paste: 'Vloženie',
paste_in_place: 'Vloženie na pôvodnom mieste', paste_in_place: 'Vloženie na pôvodnom mieste',
delete: 'Zmazanie', "delete": 'Zmazanie',
group: 'Group', group: 'Group',
move_front: 'Vysuň navrch', move_front: 'Vysuň navrch',
move_up: 'Vysuň vpred', move_up: 'Vysuň vpred',
@ -154,7 +154,7 @@ var svgEditorLang_sk = (function () {
layers: 'Vrstvy', layers: 'Vrstvy',
del: 'Odstrániť vrstvu', del: 'Odstrániť vrstvu',
move_down: 'Presunúť vrstvu dole', move_down: 'Presunúť vrstvu dole',
new: 'Nová vrstva', "new": 'Nová vrstva',
rename: 'Premenovať vrstvu', rename: 'Premenovať vrstvu',
move_up: 'Presunúť vrstvu hore', move_up: 'Presunúť vrstvu hore',
dupe: 'Zduplikovať vrstvu', dupe: 'Zduplikovať vrstvu',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sl = (function () {
copy: 'Kopiraj', copy: 'Kopiraj',
paste: 'Prilepi', paste: 'Prilepi',
paste_in_place: 'Prilepi na mesto', paste_in_place: 'Prilepi na mesto',
delete: 'Izbriši', "delete": 'Izbriši',
group: 'Združi', group: 'Združi',
move_front: 'Postavi v ospredje', move_front: 'Postavi v ospredje',
move_up: 'Pomakni naporej', move_up: 'Pomakni naporej',
@ -154,7 +154,7 @@ var svgEditorLang_sl = (function () {
layers: 'Sloji', layers: 'Sloji',
del: 'Izbriši sloj', del: 'Izbriši sloj',
move_down: 'Premakni navzdol', move_down: 'Premakni navzdol',
new: 'Nov sloj', "new": 'Nov sloj',
rename: 'Preimenuj sloj', rename: 'Preimenuj sloj',
move_up: 'Premakni navzgor', move_up: 'Premakni navzgor',
dupe: 'Podvoji sloj', dupe: 'Podvoji sloj',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sq = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_sq = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Down Layer', move_down: 'Move Down Layer',
new: 'Re Shtresa', "new": 'Re Shtresa',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Up Layer', move_up: 'Move Up Layer',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sr = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_sr = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Избриши слој', del: 'Избриши слој',
move_down: 'Помери слој доле', move_down: 'Помери слој доле',
new: 'Нови слој', "new": 'Нови слој',
rename: 'Преименуј слој', rename: 'Преименуј слој',
move_up: 'Помери слој Горе', move_up: 'Помери слој Горе',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sv = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_sv = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Radera Layer', del: 'Radera Layer',
move_down: 'Flytta Layer Down', move_down: 'Flytta Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Byt namn på Layer', rename: 'Byt namn på Layer',
move_up: 'Flytta Layer Up', move_up: 'Flytta Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_sw = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_sw = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'Mpya Layer', "new": 'Mpya Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_test = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
@ -154,7 +154,7 @@ var svgEditorLang_test = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Rename Layer', rename: 'Rename Layer',
move_up: 'Move Layer Up', move_up: 'Move Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_th = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_th = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'ย้าย Layer ลง', move_down: 'ย้าย Layer ลง',
new: 'Layer ใหม่', "new": 'Layer ใหม่',
rename: 'Layer เปลี่ยนชื่อ', rename: 'Layer เปลี่ยนชื่อ',
move_up: 'ย้าย Layer Up', move_up: 'ย้าย Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_tl = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_tl = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Tanggalin Layer', del: 'Tanggalin Layer',
move_down: 'Ilipat Layer Down', move_down: 'Ilipat Layer Down',
new: 'Bagong Layer', "new": 'Bagong Layer',
rename: 'Palitan ang pangalan ng Layer', rename: 'Palitan ang pangalan ng Layer',
move_up: 'Ilipat Layer Up', move_up: 'Ilipat Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_tr = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_tr = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Delete Layer', del: 'Delete Layer',
move_down: 'Katman Aşağı Taşı', move_down: 'Katman Aşağı Taşı',
new: 'Yeni Katman', "new": 'Yeni Katman',
rename: 'Rename Katman', rename: 'Rename Katman',
move_up: 'Up Katman Taşı', move_up: 'Up Katman Taşı',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_uk = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_uk = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Видалити шар', del: 'Видалити шар',
move_down: 'Перемістити шар на', move_down: 'Перемістити шар на',
new: 'Новий шар', "new": 'Новий шар',
rename: 'Перейменувати Шар', rename: 'Перейменувати Шар',
move_up: 'Переміщення шару до', move_up: 'Переміщення шару до',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_vi = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_vi = (function () {
layers: 'Layers', layers: 'Layers',
del: 'Xoá Layer', del: 'Xoá Layer',
move_down: 'Move Layer Down', move_down: 'Move Layer Down',
new: 'New Layer', "new": 'New Layer',
rename: 'Đổi tên Layer', rename: 'Đổi tên Layer',
move_up: 'Di chuyển Layer Up', move_up: 'Di chuyển Layer Up',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_yi = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_yi = (function () {
layers: 'Layers', layers: 'Layers',
del: 'ויסמעקן לייַער', del: 'ויסמעקן לייַער',
move_down: 'קער לייַער דאָוון', move_down: 'קער לייַער דאָוון',
new: 'ניו לייַער', "new": 'ניו לייַער',
rename: 'רענאַמע לייַער', rename: 'רענאַמע לייַער',
move_up: 'באַוועגן לייַער אַרויף', move_up: 'באַוועגן לייַער אַרויף',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_zh_CN = (function () {
copy: '复制', copy: '复制',
paste: '粘贴', paste: '粘贴',
paste_in_place: '粘贴到原位置', paste_in_place: '粘贴到原位置',
delete: '删除', "delete": '删除',
group: '组合', group: '组合',
move_front: '移至顶部', move_front: '移至顶部',
move_up: '向上移动', move_up: '向上移动',
@ -154,7 +154,7 @@ var svgEditorLang_zh_CN = (function () {
layers: '图层', layers: '图层',
del: '删除图层', del: '删除图层',
move_down: '向下移动图层', move_down: '向下移动图层',
new: '新建图层', "new": '新建图层',
rename: '重命名图层', rename: '重命名图层',
move_up: '向上移动图层', move_up: '向上移动图层',
dupe: '复制图层', dupe: '复制图层',

View File

@ -142,7 +142,7 @@ var svgEditorLang_zh_HK = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_zh_HK = (function () {
layers: 'Layers', layers: 'Layers',
del: '删除层', del: '删除层',
move_down: '层向下移动', move_down: '层向下移动',
new: '新层', "new": '新层',
rename: '重命名层', rename: '重命名层',
move_up: '移动层最多', move_up: '移动层最多',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

View File

@ -142,7 +142,7 @@ var svgEditorLang_zh_TW = (function () {
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
paste_in_place: 'Paste in Place', paste_in_place: 'Paste in Place',
delete: 'Delete', "delete": 'Delete',
group: 'Group', group: 'Group',
move_front: 'Bring to Front', move_front: 'Bring to Front',
move_up: 'Bring Forward', move_up: 'Bring Forward',
@ -154,7 +154,7 @@ var svgEditorLang_zh_TW = (function () {
layers: 'Layers', layers: 'Layers',
del: '刪除圖層', del: '刪除圖層',
move_down: '向下移動圖層', move_down: '向下移動圖層',
new: '新增圖層', "new": '新增圖層',
rename: '重新命名圖層', rename: '重新命名圖層',
move_up: '向上移動圖層', move_up: '向上移動圖層',
dupe: 'Duplicate Layer', dupe: 'Duplicate Layer',

File diff suppressed because it is too large Load Diff

25764
dist/svgcanvas-iife.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
"test": "test" "test": "test"
}, },
"engines": { "engines": {
"node": ">=8.5.0" "node": ">=10"
}, },
"scripts": { "scripts": {
"add-release": "git submodule add --depth=1 -b \"release-v$npm_config_release\" -- https://github.com/SVG-Edit/svgedit.git \"releases/svg-edit-$npm_config_release\"", "add-release": "git submodule add --depth=1 -b \"release-v$npm_config_release\" -- https://github.com/SVG-Edit/svgedit.git \"releases/svg-edit-$npm_config_release\"",
@ -39,11 +39,6 @@
"open": "run-p start open-no-start", "open": "run-p start open-no-start",
"open-cov-no-start": "open-cli http://localhost:8000/coverage/", "open-cov-no-start": "open-cli http://localhost:8000/coverage/",
"open-cov": "run-p start open-cov-no-start", "open-cov": "run-p start open-cov-no-start",
"instrument:replace-html": "frs-replace \"../svgedit-config-es.js\" \"svgedit-config-es.js\" -i instrumented/svg-editor-es.html -o instrumented/svg-editor-es.html",
"instrument:replace-js": "frs-replace \"src/editor/svg-editor.js\" \"svg-editor.js\" -i svgedit-config-es.js -o instrumented/svgedit-config-es.js",
"instrument:copy-excluded": "node cypress/support/copy.js",
"copy-instrumented": "copyfiles -e \"**/*.js\" -u 1 \"src/editor/**/*\" instrumented && npm run instrument:replace-html && npm run instrument:replace-js && npm run instrument:copy-excluded",
"instrument": "rimraf instrumented && nyc instrument editor instrumented && npm run copy-instrumented",
"report": "run-s report-no-mochawesome mochawesome-cli", "report": "run-s report-no-mochawesome mochawesome-cli",
"report-summary": "run-s report-text-summary mochawesome-cli-dot", "report-summary": "run-s report-text-summary mochawesome-cli-dot",
"license-badge": "license-badger --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg", "license-badge": "license-badger --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
@ -54,17 +49,17 @@
"copy": "copyfiles -f node_modules/load-stylesheets/dist/index-es.js src/external/load-stylesheets && copyfiles -f node_modules/jamilih/dist/jml-es.js editor/external/jamilih && copyfiles -f node_modules/query-result/esm/index.js editor/external/query-result/esm && copyfiles -f node_modules/qr-manipulation/dist/index-es.js editor/external/qr-manipulation/dist && copyfiles -f node_modules/stackblur-canvas/dist/stackblur-es.js editor/external/stackblur-canvas/dist && copyfiles -f node_modules/regenerator-runtime/runtime.js editor/external/regenerator-runtime && copyfiles -f \"node_modules/core-js-bundle//minified*\" editor/external/core-js-bundle && copyfiles -f \"node_modules/underscore/underscore-*\" editor/jspdf && copyfiles -f \"node_modules/deparam/dist/deparam.esm.js\" editor/external/deparam", "copy": "copyfiles -f node_modules/load-stylesheets/dist/index-es.js src/external/load-stylesheets && copyfiles -f node_modules/jamilih/dist/jml-es.js editor/external/jamilih && copyfiles -f node_modules/query-result/esm/index.js editor/external/query-result/esm && copyfiles -f node_modules/qr-manipulation/dist/index-es.js editor/external/qr-manipulation/dist && copyfiles -f node_modules/stackblur-canvas/dist/stackblur-es.js editor/external/stackblur-canvas/dist && copyfiles -f node_modules/regenerator-runtime/runtime.js editor/external/regenerator-runtime && copyfiles -f \"node_modules/core-js-bundle//minified*\" editor/external/core-js-bundle && copyfiles -f \"node_modules/underscore/underscore-*\" editor/jspdf && copyfiles -f \"node_modules/deparam/dist/deparam.esm.js\" editor/external/deparam",
"remark": "remark -q -f .", "remark": "remark -q -f .",
"build-html": "babel-node --plugins @babel/plugin-transform-modules-commonjs build/build-html.js", "build-html": "babel-node --plugins @babel/plugin-transform-modules-commonjs build/build-html.js",
"eslint-fix": "eslint --cache --fix --ext js,md,html .", "eslint-fix": "eslint --fix --ext js,md,html src",
"eslint": "eslint --max-warnings 0 --cache --ext js,md,html .", "eslint": "eslint --ext js,html src",
"rollup": "rollup -c", "rollup": "rollup -c",
"build-by-config": "rollup -c rollup-config.config.js", "build-by-config": "rollup -c rollup-config.config.js",
"prep-no-core-rollup": "run-s eslint build-html build-by-config", "prep-no-core-rollup": "run-s eslint build-html build-by-config",
"prep": "run-s prep-no-core-rollup rollup", "prep": "run-s prep-no-core-rollup rollup",
"prepublishOnly": "run-s license-badges copy prep build-docs", "prepublishOnly": "run-s license-badges copy prep build-docs",
"cypress:open-no-start": "cypress open", "cypress:open-no-start": "cypress open",
"cy:instrument": "rimraf instrumented && cp -r src instrumented && nyc instrument --compact false src instrumented", "cypress:instrument": "rimraf instrumented && cp -r src instrumented && nyc instrument --compact false src instrumented",
"cypress:open": "run-p start cypress:open-no-start", "cypress:open": "run-p start cypress:open-no-start",
"open-tests": "run-s cy:instrument cypress:open", "open-tests": "run-s cypress:instrument cypress:open",
"cypress:merge": "mochawesome-merge \"cypress/results/mochaw*.json\" > mochawesome.json && marge mochawesome.json && mbg --file ./mochawesome.json --badge_output badges/tests-badge.svg", "cypress:merge": "mochawesome-merge \"cypress/results/mochaw*.json\" > mochawesome.json && marge mochawesome.json && mbg --file ./mochawesome.json --badge_output badges/tests-badge.svg",
"cypress:run-only": "rimraf \"cypress/results/mochaw*.json\" && rimraf \".nyc_output/*\" && cypress run", "cypress:run-only": "rimraf \"cypress/results/mochaw*.json\" && rimraf \".nyc_output/*\" && cypress run",
"cypress:run-no-badge": "run-s -c cypress:run-only cypress:merge", "cypress:run-no-badge": "run-s -c cypress:run-only cypress:merge",
@ -78,10 +73,14 @@
"test-only": "run-s -c test-only-no-report report", "test-only": "run-s -c test-only-no-report report",
"test-no-cov-no-core-rollup": "run-s prep-no-core-rollup test-only", "test-no-cov-no-core-rollup": "run-s prep-no-core-rollup test-only",
"test-no-cov": "run-s prep test-only", "test-no-cov": "run-s prep test-only",
"test-no-core-rollup": "run-s instrument test-no-cov-no-core-rollup", "test-no-core-rollup": "run-s cypress:instrument test-no-cov-no-core-rollup",
"test": "run-s cy:instrument test-no-cov" "test": "run-s cypress:instrument test-no-cov"
}, },
"nyc": { "nyc": {
"statements": 37.51,
"branches": 28.8,
"lines": 38.46,
"functions": 47.27,
"exclude": [ "exclude": [
"src/external/**", "src/external/**",
"src/editor/jquery.min.js", "src/editor/jquery.min.js",
@ -122,7 +121,13 @@
}, },
"homepage": "https://github.com/SVG-Edit/svgedit#readme", "homepage": "https://github.com/SVG-Edit/svgedit#readme",
"browserslist": [ "browserslist": [
"> 2%" ">0%",
"not Opera < 59",
"not IE < 12",
"not Chrome < 75",
"not FireFox < 68",
"not Safari < 10",
"not ios_saf < 10"
], ],
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {

View File

@ -1,4 +1,4 @@
/* eslint-disable import/unambiguous */ /* eslint-disable import/unambiguous, max-len */
/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, /* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs,
SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs,
SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs, SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs,
@ -596,7 +596,7 @@ if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.pro
return []; return [];
} }
const owningPathSegList = this; // eslint-disable-line consistent-this const owningPathSegList = this;
class Builder { class Builder {
constructor () { constructor () {

Some files were not shown because too many files have changed in this diff Show More