- Breaking change: `loadSvgString` now returns a `Promise` rather than accepting a callback

- Breaking change: Treat callbacks to `editor.ready` as Promises, only resolving after all resolve
- Breaking change: Make `editor.runCallbacks` return a `Promise` which resolves upon all callbacks resolving
- Breaking change: Require `npx` (used with `babel-node`) to allow Node files
  for HTML building and JSDoc type checking to be expressed as ESM.
- Breaking change: `addExtension` now throws upon a repeated attempt to add an already-added extension
- Breaking change (storage preference cookies): Namespace the cookie as "svgeditstore" instead of just "store"
- Breaking change (API): Remove `svgCanvas.rasterExport` fourth (callback) argument, collapsing fifth (options) to fourth
- Breaking change (API): Remove `svgCanvas.exportPDF` third (callback) argument
- Breaking change (API): `editor/contextmenu.js` `add` now throws instead of giving a console error only upon detecting a bad menuitem or preexisting context menu
- Breaking change (API): Remove `svgCanvas.embedImage` second (callback) argument
- Breaking change (API): Make `getHelpXML` a class instead of instance method of `RGBColor`
- Breaking change (internal API): Refactor `dbox` (and `alert`/`confirm`/`process`/`prompt`/`select`) to avoid a callback argument in favor of return a Promise
- Fix: Avoid running in extension `langReady` multiple times or serially
- Enhancement (API): Add svgCanvas.runExtension to run just one extension and add `nameFilter` callback to `runExtensions`
- Enhancement (API): Supply `$` (our wrapped jQuery) to extensions so can use its plugins, e.g., dbox with its `alert`
- Enhancement: Use alert dialog in place of `alert` in webappfind
- Enhancement: `editor.ready` now returns a Promise resolving when all callbacks have resolved
- Enhancement: Allow `noAlert` option as part of second argument to `loadSvgString` (and `loadFromURL` and `loadFromDataURI`) to avoid UI alert (and trigger promise rejection)
- Enhancement: Make `dbox` as a separate module for alert, prompt, etc. dialogs
- Refactoring: Internal `PaintBox` as class; other misc. tweaks; no bitwise in canvg
- Linting (ESLint): Further linting changes (for editor); rename `.eslintrc` -> `.eslintrc.json` per recommendation
- Optimization: Recompress images (imageoptim-cli updated)
- npm: Update devDeps
- npm: Bump to 4.0.0
master
Brett Zamir 2018-11-08 14:48:01 +08:00
parent 7c470e9909
commit 2e5c7557a9
159 changed files with 25502 additions and 15658 deletions

368
.eslintrc
View File

@ -1,368 +0,0 @@
{
"extends": [
"standard", "plugin:compat/recommended",
"plugin:qunit/recommended", "plugin:testcafe/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"plugins": ["compat", "qunit", "testcafe", "jsdoc", "markdown", "import", "node", "promise"],
"env": {
"node": false,
"browser": true
},
"settings": {
"polyfills": ["url", "promises", "fetch", "queryselector"],
"jsdoc": {
"additionalTagNames": {
"customTags": []
},
"tagNamePreference": {
"arg": "param",
"return": "returns"
},
"allowOverrideWithoutParam": true,
"allowImplementsWithoutParam": true,
"allowAugmentsExtendsWithoutParam": true
}
},
"overrides": [
{
"files": ["editor/locale/lang.*.js"],
"rules": {
"import/no-anonymous-default-export": ["off"]
}
},
{
"files": ["editor/extensions/ext-locale/**"],
"rules": {
"import/no-anonymous-default-export": ["off"]
}
},
{
"files": ["editor/extensions/**/ext-*.js"],
"rules": {
"consistent-this": ["error", "svgEditor"],
"import/no-anonymous-default-export": ["off"]
}
},
{
"files": [
"editor/svgpathseg.js", "editor/touch.js", "editor/typedefs.js",
"editor/redirect-on-no-module-support.js",
"test/all_tests.js", "screencasts/svgopen2010/script.js",
"opera-widget/handlers.js",
"firefox-extension/handlers.js",
"firefox-extension/content/svg-edit-overlay.js"
],
"rules": {
"import/unambiguous": ["off"]
}
},
{
"files": ["**/*.md"],
"rules": {
"no-undef": ["off"],
"no-unused-vars": ["warn"],
"padded-blocks": ["off"],
"import/unambiguous": ["off"]
}
},
{
"files": ["test/**"],
"rules": {
"no-console": ["off"]
}
},
{
"files": [
"docs/jsdoc-config.js", "build-html.js", "jsdoc-check-overly-generic-types.js",
"rollup.config.js", "rollup-config.config.js"
],
"rules": {
"node/no-extraneous-import": ["error"],
"node/no-extraneous-require": ["error"],
"node/no-missing-import": ["error"],
"node/no-missing-require": ["error"],
"node/no-unpublished-bin": ["error"],
"node/no-unpublished-import": ["error"],
"node/no-unpublished-require": ["error"],
"node/no-unsupported-features/es-builtins": ["error"],
"node/no-unsupported-features/es-syntax": ["error"],
"node/no-unsupported-features/node-builtins": ["error"],
"node/process-exit-as-throw": ["error"],
"node/shebang": ["error"],
"node/exports-style": ["error", "module.exports"],
"node/prefer-global/buffer": ["error", "always"],
"node/prefer-global/console": ["error", "always"],
"node/prefer-global/process": ["error", "always"],
"node/prefer-global/text-decoder": ["error", "always"],
"node/prefer-global/text-encoder": ["error", "always"],
"node/prefer-global/url-search-params": ["error", "always"],
"node/prefer-global/url": ["error", "always"]
}
},
{
"files": ["rollup.config.js", "rollup-config.config.js"],
"rules": {
"node/no-unsupported-features/es-syntax": "off",
"node/no-unpublished-import": "off"
}
},
{
"files": ["jsdoc-check-overly-generic-types.js", "build-html.js"],
"rules": {
"import/unambiguous": "off",
"import/no-commonjs": "off"
}
}
],
"rules": {
"array-bracket-newline": ["error", "consistent"],
"array-bracket-spacing": ["error"],
"array-callback-return": ["error"],
"array-element-newline": ["off"],
"arrow-body-style": ["off"],
"arrow-parens": ["error"],
"block-scoped-var": ["error"],
"callback-return": ["error"],
"class-methods-use-this": ["warn"],
"computed-property-spacing": ["error"],
"consistent-return": ["error"],
"consistent-this": ["warn"],
"dot-notation": ["error"],
"for-direction": ["error"],
"func-name-matching": ["error"],
"func-names": ["off"],
"func-style": ["off"],
"function-paren-newline": ["error", "consistent"],
"getter-return": ["error"],
"global-require": ["error"],
"guard-for-in": ["error"],
"id-blacklist": ["off"],
"id-length": ["off"],
"id-match": ["off"],
"implicit-arrow-linebreak": ["error"],
"init-declarations": ["off"],
"jsx-quotes": ["error"],
"line-comment-position": ["off"],
"linebreak-style": ["error"],
"lines-around-comment": ["off"],
"lines-between-class-members": ["off"],
"max-classes-per-file": ["off"],
"max-depth": ["off"],
"max-lines-per-function": ["off"],
"max-lines": ["off"],
"max-nested-callbacks": ["error"],
"max-params": ["off"],
"max-statements-per-line": ["off"],
"max-statements": ["off"],
"multiline-comment-style": ["off"],
"multiline-ternary": ["error", "always-multiline"],
"newline-after-var": ["off"],
"newline-before-return": ["off"],
"newline-per-chained-call": ["off"],
"no-alert": ["warn"],
"no-async-promise-executor": ["error"],
"no-await-in-loop": ["error"],
"no-bitwise": ["error"],
"no-buffer-constructor": ["error"],
"no-case-declarations": ["error"],
"no-confusing-arrow": ["error"],
"no-console": ["warn"],
"no-continue": ["off"],
"no-div-regex": ["error"],
"no-duplicate-imports": ["error"],
"no-else-return": ["error"],
"no-empty-function": ["warn"],
"no-empty": ["error", {"allowEmptyCatch": true}],
"no-eq-null": ["error"],
"no-extra-label": ["error"],
"no-extra-semi": ["error"],
"no-implicit-coercion": ["error"],
"no-implicit-globals": ["error"],
"no-inline-comments": ["off"],
"no-invalid-this": ["off"],
"no-lonely-if": ["error"],
"no-loop-func": ["error"],
"no-misleading-character-class": ["error"],
"no-mixed-requires": ["error", {"grouping": true, "allowCall": true}],
"no-multi-assign": ["off"],
"no-negated-condition": ["off"],
"no-nested-ternary": ["off"],
"no-param-reassign": ["off"],
"no-plusplus": ["off"],
"no-process-env": ["error"],
"no-process-exit": ["error"],
"no-prototype-builtins": ["error"],
"no-restricted-globals": ["error", {
"name": "event",
"message": "Use local event parameter instead (preferably as \"e\" or \"ev\")."
}, {
"name": "fdescribe",
"message": "Do not commit fdescribe. Use describe instead."
}],
"no-restricted-imports": ["off"],
"no-restricted-modules": ["off"],
"no-restricted-properties": ["error", {
"property": "__defineGetter__",
"message": "Please use `Object.defineProperty` instead."
}],
"no-restricted-syntax": ["off"],
"no-script-url": ["error"],
"no-shadow": ["error", {"builtinGlobals": true, "hoist": "functions", "allow": ["parent", "top", "open", "name", "closed", "start"]}],
"no-spaced-func": ["error"],
"no-sync": ["error"],
"no-ternary": ["off"],
"no-undefined": ["off"],
"no-underscore-dangle": ["off"],
"no-unused-labels": ["error"],
"no-useless-concat": ["off"],
"no-var": ["error"],
"no-void": ["error"],
"nonblock-statement-body-position": ["error"],
"object-curly-newline": ["off"],
"object-shorthand": ["error", "always", {"avoidExplicitReturnArrows": true}],
"one-var-declaration-per-line": ["off"],
"operator-assignment": ["error"],
"padding-line-between-statements": ["off"],
"prefer-arrow-callback": ["off"],
"prefer-const": ["error"],
"prefer-destructuring": ["error", {"object": true}],
"prefer-numeric-literals": ["warn"],
"prefer-object-spread": ["error"],
"prefer-rest-params": ["error"],
"prefer-spread": ["error"],
"prefer-template": ["off"],
"quote-props": ["error", "as-needed"],
"radix": ["error", "as-needed"],
"require-atomic-updates": ["error"],
"require-await": ["error"],
"require-jsdoc": ["warn"],
"require-yield": ["error"],
"semi-style": ["error"],
"sort-imports": ["off"],
"sort-keys": ["off"],
"sort-vars": ["off"],
"strict": ["error"],
"switch-colon-spacing": ["error"],
"vars-on-top": ["warn"],
"wrap-regex": ["error"],
"semi": ["error", "always"],
"indent": ["error", 2, {"outerIIFEBody": 0}],
"object-property-newline": ["off"],
"one-var": ["off"],
"object-curly-spacing": ["error", "never"],
"promise/catch-or-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/always-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/avoid-new": "warn",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "warn",
"promise/valid-params": "warn",
"promise/prefer-await-to-then": "error",
"promise/prefer-await-to-callbacks": "warn",
"import/no-unresolved": "error",
"import/named": "error",
"import/default": "error",
"import/namespace": "error",
"import/no-restricted-paths": "off",
"import/no-absolute-path": "error",
"import/no-dynamic-require": "error",
"import/no-internal-modules": "off",
"import/no-webpack-loader-syntax": "error",
"import/no-self-import": "error",
"import/no-cycle": "off",
"import/no-useless-path-segments": "error",
"import/no-relative-parent-imports": "off",
"import/export": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": "error",
"import/no-mutable-exports": "error",
"import/unambiguous": "warn",
"import/no-commonjs": "error",
"import/no-amd": "error",
"import/no-nodejs-modules": "off",
"import/first": "error",
"import/exports-last": "off",
"import/no-duplicates": "error",
"import/no-namespace": "off",
"import/extensions": ["error", "always", {"ignorePackages": true}],
"import/order": ["error", {"groups": [
"builtin",
"external",
"internal",
["parent", "sibling", "index"]
]}],
"import/newline-after-import": "error",
"import/prefer-default-export": "off",
"import/max-dependencies": "off",
"import/no-unassigned-import": "off",
"import/no-named-default": "error",
"import/no-default-export": "off",
"import/no-named-export": "off",
"import/no-anonymous-default-export": "error",
"import/group-exports": "off",
"import/dynamic-import-chunkname": "off",
"jsdoc/check-param-names": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/newline-after-description": 0,
"jsdoc/require-description": 0,
"jsdoc/require-description-complete-sentence": 0,
"jsdoc/require-example": 0,
"jsdoc/require-hyphen-before-param-description": 0,
"jsdoc/require-param-description": 0,
"jsdoc/require-param": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns-description": 0,
"jsdoc/require-returns-type": 1,
"jsdoc/no-undefined-types": ["off"],
"jsdoc/valid-types": ["error"],
"valid-jsdoc": ["error", {
"prefer": {
"arg": "param",
"argument": "param",
"return": "returns",
"virtual": "abstract"
},
"preferType": {
"Boolean": "boolean",
"Number": "number",
"String": "string",
"object": "Object",
"array": "Array"
},
"requireReturn": true,
"requireReturnType": true,
"requireParamType": true,
"matchDescription": "^([A-Z][\\s\\S]*[.`?!])?$",
"requireParamDescription": false,
"requireReturnDescription": false
}],
"no-warning-comments": ["off"],
"default-case": ["off"],
"complexity": ["off"],
"require-unicode-regexp": ["off"],
"capitalized-comments": ["off"],
"no-magic-numbers": ["off"],
"max-len": ["off", {
"ignoreUrls": true,
"ignoreRegExpLiterals": true
}]
}
}

154
.eslintrc.js Normal file
View File

@ -0,0 +1,154 @@
module.exports = {
"extends": [
"ash-nazg/sauron-node",
"plugin:qunit/recommended", "plugin:testcafe/recommended"
],
"parserOptions": {
"sourceType": "module"
},
// Need to make explicit here for processing by jsdoc/check-examples
"plugins": ["qunit"],
"env": {
"browser": true
},
"settings": {
"polyfills": ["url", "promises", "fetch", "queryselector"],
"jsdoc": {
"additionalTagNames": {
// In case we need to extend
"customTags": []
},
"tagNamePreference": {
"arg": "param",
"return": "returns"
},
"allowOverrideWithoutParam": true,
"allowImplementsWithoutParam": true,
"allowAugmentsExtendsWithoutParam": true,
// For `jsdoc/check-examples` in `ash-nazg`
"matchingFileName": "dummy.md",
"rejectExampleCodeRegex": "^`",
}
},
"overrides": [
// These would otherwise currently break because of these issues:
// 1. `event:` https://github.com/eslint/doctrine/issues/221 and https://github.com/Kuniwak/jsdoctypeparser/pull/49 with https://github.com/Kuniwak/jsdoctypeparser/issues/47
// 1. `@implements`/`@augments`/`@extends`/`@override`: https://github.com/eslint/doctrine/issues/222
{
"files": [
"test/utilities_test.js", "editor/svg-editor.js", "editor/svgcanvas.js",
"editor/coords.js",
"editor/extensions/ext-eyedropper.js", "editor/extensions/ext-webappfind.js"
],
"rules": {
"jsdoc/valid-types": "off",
"valid-jsdoc": "off"
}
},
// Locales have no need for importing outside of SVG-Edit
{
"files": [
"editor/locale/lang.*.js", "editor/extensions/ext-locale/**",
"docs/tutorials/ExtensionDocs.md"
],
"rules": {
"import/no-anonymous-default-export": ["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": ["editor/extensions/**/ext-*.js"],
"rules": {
"consistent-this": ["error", "svgEditor"],
"import/no-anonymous-default-export": ["off"]
}
},
// These browser files don't do importing or requiring
{
"files": [
"editor/svgpathseg.js", "editor/touch.js", "editor/typedefs.js",
"editor/redirect-on-no-module-support.js",
"editor/extensions/imagelib/index.js",
"editor/external/dom-polyfill/dom-polyfill.js",
"test/all_tests.js", "screencasts/svgopen2010/script.js",
"opera-widget/handlers.js",
"firefox-extension/handlers.js",
"firefox-extension/content/svg-edit-overlay.js"
],
"rules": {
"import/unambiguous": ["off"]
}
},
// Our Markdown rules (and used for JSDoc examples as well, by way of
// our use of `matchingFileName` in conjunction with
// `jsdoc/check-examples` within `ash-nazg`)
{
"files": ["**/*.md"],
"rules": {
"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"]
}
},
// Dis-apply Node rules mistakenly giving errors with browser files
{
"files": ["editor/**", "test/**"],
"rules": {
"node/no-unsupported-features/node-builtins": ["off"]
}
},
// We want console in tests!
{
"files": ["test/**"],
"rules": {
"no-console": ["off"]
}
},
{
// Node files
"files": [
"docs/jsdoc-config.js",
"build-html.js", "jsdoc-check-overly-generic-types.js",
"rollup.config.js", "rollup-config.config.js"
],
"env": {
"node": true,
},
"rules": {
"node/no-unpublished-import": ["off"],
"node/no-unsupported-features/es-syntax": ["off"]
}
},
{
// As consumed by jsdoc, cannot be expressed as ESM
"files": ["docs/jsdoc-config.js"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"import/no-commonjs": "off"
}
}
],
"rules": {
// Override these `ash-nazg/sauron` rules which are difficult for us
// to apply at this time
"capitalized-comments": ["off"],
"complexity": ["off"],
"default-case": ["off"],
"require-unicode-regexp": ["off"],
"no-magic-numbers": ["off"],
"no-warning-comments": ["off"],
"max-len": ["off", {
"ignoreUrls": true,
"ignoreRegExpLiterals": true
}]
}
};

View File

@ -1,5 +1,62 @@
# SVG-Edit CHANGES # SVG-Edit CHANGES
# 4.0.0
- Breaking change (storage preference cookies): Namespace the cookie as
"svgeditstore" instead of just "store"
- Breaking change: `loadSvgString` now returns a `Promise` rather than
accepting a callback.
- Breaking change: Treat callbacks to `editor.ready` as Promises, only
resolving after all resolve. May require no changes unless for timing.
- Breaking change: Make `editor.runCallbacks` return a `Promise` which
resolves upon all callbacks resolving.
- Breaking change: Require `npx` (used with `babel-node`) to allow Node files
for HTML building and JSDoc type checking to be expressed as ESM.
- Breaking change: `addExtension` now throws upon a repeated attempt to
add an already-added extension
- Breaking change (API): Remove `svgCanvas.rasterExport` fourth (callback)
argument, collapsing fifth (options) to fourth
- Breaking change (API): Remove `svgCanvas.exportPDF` third (callback)
argument
- Breaking change (API): `editor/contextmenu.js` `add` now throws instead
of giving a console error only upon detecting a bad menuitem or
preexisting context menu
- Breaking change (API): Remove `svgCanvas.embedImage` second (callback)
argument
- Breaking change (API): Make `getHelpXML` a class instead of instance method
of `RGBColor`
- Breaking change (internal API): Refactor `dbox` (and
`alert`/`confirm`/`process`/`prompt`/`select`) to avoid a callback argument
in favor of returning a Promise
- Breaking internal API change: `updateGripCursor` moved to be class method
of Selector rather than instance method
- Breaking internal API change: `subpathIsClosed` moved to be class method
of `Path` rather than instance method
- Fix: Avoid running in extension `langReady` multiple times or serially
- Enhancement (API): Add `svgCanvas.runExtension` to run just one extension and
add `nameFilter` callback to `runExtensions`
- Enhancement (API): Supply `$` (our wrapped jQuery) to extensions so can use
its plugins, e.g., dbox with its `alert`
- Enhancement: Use alert dialog in place of `alert` in webappfind
- Enhancement: `editor.ready` now returns a Promise resolving when all
callbacks have resolved
- Enhancement: Allow `noAlert` option as part of second argument to
`loadSvgString` (and `loadFromURL` and `loadFromDataURI`) to avoid UI
alert (and trigger promise rejection)
- Enhancement: Make `dbox` as a separate module for alert, prompt, etc. dialogs
- Optimization: Recompress images (imageoptim-cli updated)
- Refactoring: Internal `PaintBox` as class; other misc. tweaks; no bitwise
in canvg
- Refactoring: Reuse utilities base64 encoder for SVG icons plugin
- Linting (ESLint): Further linting changes (for editor); rename
`.eslintrc` -> `.eslintrc.js` per recommendation and to more transparently
allow comments; apply new strict `eslint-config-ash-nazg` rules.
- Linting (ESLint): Stricter rules (or switch to warning)
- Docs (JSDoc): Fix return of the `mouseUp` (can also be an object) and
`mouseDown` (may also be a boolean) of `pathActions`; other JSDoc
additions/improvements
- npm: Update devDeps
## 3.2.0 ## 3.2.0
- Refactoring: Avoid unnecessary `addEventListener` `false`; change internal - Refactoring: Avoid unnecessary `addEventListener` `false`; change internal
@ -21,7 +78,9 @@
<https://github.com/eslint/eslint-plugin-markdown/issues/109>, <https://github.com/eslint/eslint-plugin-markdown/issues/109>,
<https://github.com/gajus/eslint-plugin-jsdoc/issues/101>, <https://github.com/gajus/eslint-plugin-jsdoc/issues/101>,
<https://github.com/gajus/eslint-plugin-jsdoc/issues/99>, <https://github.com/gajus/eslint-plugin-jsdoc/issues/99>,
<https://github.com/eslint/eslint/issues/11043> <https://github.com/eslint/eslint/issues/11043>; NOTE:
if we need to tap into Markdown within JSDoc, see <https://github.com/jsdoc3/jsdoc#b21427343c7294bbf1f14c718a390f3e955e37cb>
for commit not present in npm.
- Docs (README): Indicate minimal polyfills needed for older browsers - Docs (README): Indicate minimal polyfills needed for older browsers
(IE <= 11, IE Mobile, Opera Mini, Blackberry Browser <= 10, (IE <= 11, IE Mobile, Opera Mini, Blackberry Browser <= 10,
Android Browser 4.4.3-4.4.4) Android Browser 4.4.3-4.4.4)

View File

@ -107,6 +107,7 @@ incorporating SVGEdit.
## Recent news ## Recent news
- 2018-11-16 Published 4.0.0 (Move to Promise-based APIs)
- 2018-11-01 Published 3.2.0 (Update qunit to resolve security vulnerability of a dependency) - 2018-11-01 Published 3.2.0 (Update qunit to resolve security vulnerability of a dependency)
- 2018-10-25 Published 3.1.1 (Fix for saving SVG on Firefox) - 2018-10-25 Published 3.1.1 (Fix for saving SVG on Firefox)
- 2018-10-24 Published 3.1.0 (Redirect on modular page for non-module-support; - 2018-10-24 Published 3.1.0 (Redirect on modular page for non-module-support;

View File

@ -1,5 +1,5 @@
/* eslint-env node */ /* eslint-env node */
const fs = require('promise-fs'); import fs from 'promise-fs';
const filesAndReplacements = [ const filesAndReplacements = [
{ {
@ -122,26 +122,27 @@ const filesAndReplacements = [
} }
]; ];
filesAndReplacements.reduce(async (p, {input, output, replacements}) => { (async () => {
await filesAndReplacements.reduce(async (p, {input, output, replacements}) => {
await p; await p;
let data; let data;
try { try {
data = await fs.readFile(input, 'utf8'); data = await fs.readFile(input, 'utf8');
} catch (err) { } catch (err) {
console.log(`Error reading ${input} file`, err); console.log(`Error reading ${input} file`, err); // eslint-disable-line no-console
} }
data = replacements.reduce((s, [find, replacement]) => { data = replacements.reduce((s, [fnd, replacement]) => {
return s.replace(find, replacement); return s.replace(fnd, replacement);
}, data); }, data);
try { try {
await fs.writeFile(output, data); await fs.writeFile(output, data);
} catch (err) { } catch (err) {
console.log(`Error writing file: ${err}`, err); console.log(`Error writing file: ${err}`, err); // eslint-disable-line no-console
return; return;
} }
console.log(`Completed file ${input} rewriting!`); console.log(`Completed file ${input} rewriting!`); // eslint-disable-line no-console
}, Promise.resolve()).then(() => { }, Promise.resolve());
console.log('Finished!'); console.log('Finished!'); // eslint-disable-line no-console
}); })();

656
dist/canvg.js vendored

File diff suppressed because it is too large Load Diff

17
dist/dom-polyfill.js vendored
View File

@ -2,6 +2,17 @@
'use strict'; 'use strict';
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js // From https://github.com/inexorabletash/polyfill/blob/master/dom.js
/**
* @module DOMPolyfill
*/
/**
*
* @param {Node} o
* @param {module:DOMPolyfill~ParentNode|module:DOMPolyfill~ChildNode} ps
* @returns {undefined}
*/
function mixin(o, ps) { function mixin(o, ps) {
if (!o) return; if (!o) return;
Object.keys(ps).forEach(function (p) { Object.keys(ps).forEach(function (p) {
@ -17,6 +28,12 @@
} }
}); });
} }
/**
*
* @param {Node[]} nodes
* @returns {Node}
*/
function convertNodesIntoANode(nodes) { function convertNodesIntoANode(nodes) {
nodes = nodes.map(function (node) { nodes = nodes.map(function (node) {

View File

@ -37,8 +37,6 @@ var svgEditorExtension_arrows = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-arrows.js * ext-arrows.js
* *
@ -53,12 +51,12 @@ var svgEditorExtension_arrows = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(S) { regeneratorRuntime.mark(function _callee2(S) {
var strings, svgEditor, svgCanvas, $, addElem, nonce, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools; var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
colorChanged = function _ref9(elem) { colorChanged = function _ref10(elem) {
var color = elem.getAttribute('stroke'); var color = elem.getAttribute('stroke');
var mtypes = ['start', 'mid', 'end']; var mtypes = ['start', 'mid', 'end'];
var defs = svgCanvas.findDefs(); var defs = svgCanvas.findDefs();
@ -84,7 +82,7 @@ var svgEditorExtension_arrows = (function () {
if (attrs.fill === color && attrs.d === curD) { if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path // Found another marker with this color and this path
newMarker = this; newMarker = this; // eslint-disable-line consistent-this
} }
}); });
@ -100,17 +98,22 @@ var svgEditorExtension_arrows = (function () {
var remove = true; var remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () { $(S.svgcontent).find('line, polyline, path, polygon').each(function () {
var elem = this; var element = this; // eslint-disable-line consistent-this
$.each(mtypes, function (j, mtype) { $.each(mtypes, function (j, mtype) {
if ($(elem).attr('marker-' + mtype) === 'url(#' + marker.id + ')') { if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false; remove = false;
return remove; return remove;
} }
return undefined;
}); });
if (!remove) { if (!remove) {
return false; return false;
} }
return undefined;
}); // Not found, so can safely remove }); // Not found, so can safely remove
if (remove) { if (remove) {
@ -119,7 +122,7 @@ var svgEditorExtension_arrows = (function () {
}); });
}; };
setArrow = function _ref8() { setArrow = function _ref9() {
resetMarker(); resetMarker();
var type = this.value; var type = this.value;
@ -147,7 +150,7 @@ var svgEditorExtension_arrows = (function () {
svgCanvas.call('changed', selElems); svgCanvas.call('changed', selElems);
}; };
addMarker = function _ref7(dir, type, id) { addMarker = function _ref8(dir, type, id) {
// TODO: Make marker (or use?) per arrow type, since refX can be different // TODO: Make marker (or use?) per arrow type, since refX can be different
id = id || arrowprefix + dir; id = id || arrowprefix + dir;
var data = pathdata[dir]; var data = pathdata[dir];
@ -188,14 +191,14 @@ var svgEditorExtension_arrows = (function () {
return marker; return marker;
}; };
resetMarker = function _ref6() { resetMarker = function _ref7() {
var el = selElems[0]; var el = selElems[0];
el.removeAttribute('marker-start'); el.removeAttribute('marker-start');
el.removeAttribute('marker-mid'); el.removeAttribute('marker-mid');
el.removeAttribute('marker-end'); el.removeAttribute('marker-end');
}; };
showPanel = function _ref5(on) { showPanel = function _ref6(on) {
$('#arrow_panel').toggle(on); $('#arrow_panel').toggle(on);
if (on) { if (on) {
@ -227,7 +230,7 @@ var svgEditorExtension_arrows = (function () {
} }
}; };
getLinked = function _ref4(elem, attr) { getLinked = function _ref5(elem, attr) {
var str = elem.getAttribute(attr); var str = elem.getAttribute(attr);
if (!str) { if (!str) {
@ -243,14 +246,14 @@ var svgEditorExtension_arrows = (function () {
return svgCanvas.getElem(m[1]); return svgCanvas.getElem(m[1]);
}; };
unsetArrowNonce = function _ref3(window) { unsetArrowNonce = function _ref4(win) {
randomizeIds = false; randomizeIds = false;
arrowprefix = prefix; arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw'; pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk'; pathdata.bk.id = arrowprefix + 'bk';
}; };
setArrowNonce = function _ref2(window, n) { setArrowNonce = function _ref3(win, n) {
randomizeIds = true; randomizeIds = true;
arrowprefix = prefix + n + '_'; arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw'; pathdata.fw.id = arrowprefix + 'fw';
@ -264,10 +267,15 @@ var svgEditorExtension_arrows = (function () {
strings = _context2.sent; strings = _context2.sent;
svgEditor = this; svgEditor = this;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
$ = jQuery;
// {svgcontent} = S, // {svgcontent} = S,
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, prefix = 'se_arrow_'; addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_';
randomizeIds = S.randomize_ids; randomizeIds = S.randomize_ids;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {undefined}
*/
svgCanvas.bind('setnonce', setArrowNonce); svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce); svgCanvas.bind('unsetnonce', unsetArrowNonce);
@ -289,6 +297,13 @@ var svgEditorExtension_arrows = (function () {
id: arrowprefix + 'bk' id: arrowprefix + 'bk'
} }
}; };
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
contextTools = [{ contextTools = [{
type: 'select', type: 'select',
panel: 'arrow_panel', panel: 'arrow_panel',
@ -312,7 +327,8 @@ var svgEditorExtension_arrows = (function () {
var _addLangData = _asyncToGenerator( var _addLangData = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var lang, importLocale, strings; var lang, importLocale, _ref2, langList;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -322,12 +338,13 @@ var svgEditorExtension_arrows = (function () {
return importLocale(); return importLocale();
case 3: case 3:
strings = _context.sent; _ref2 = _context.sent;
langList = _ref2.langList;
return _context.abrupt("return", { return _context.abrupt("return", {
data: strings.langList data: langList
}); });
case 5: case 6:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@ -372,7 +389,7 @@ var svgEditorExtension_arrows = (function () {
} }
}); });
case 22: case 21:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }

View File

@ -37,8 +37,6 @@ var svgEditorExtension_closepath = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-closepath.js * ext-closepath.js
* *
@ -55,18 +53,17 @@ var svgEditorExtension_closepath = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, strings, $, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons; var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
importLocale = _ref.importLocale; importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3; _context.next = 3;
return importLocale(); return importLocale();
case 3: case 3:
strings = _context.sent; strings = _context.sent;
$ = jQuery;
svgEditor = this; svgEditor = this;
updateButton = function updateButton(path) { updateButton = function updateButton(path) {
@ -157,7 +154,7 @@ var svgEditorExtension_closepath = (function () {
} }
}); });
case 11: case 10:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -37,8 +37,6 @@ var svgEditorExtension_connector = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-connector.js * ext-connector.js
* *
@ -52,11 +50,11 @@ var svgEditorExtension_connector = (function () {
init: function () { init: function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(S) { regeneratorRuntime.mark(function _callee(S) {
var $, svgEditor, svgCanvas, getElem, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons; var svgEditor, svgCanvas, getElem, $, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context.prev = _context.next) {
case 0: case 0:
init = function _ref9() { init = function _ref9() {
// Make sure all connectors have data set // Make sure all connectors have data set
@ -133,6 +131,10 @@ var svgEditorExtension_connector = (function () {
connectors.each(function () { connectors.each(function () {
var addThis; var addThis;
/**
*
* @returns {undefined}
*/
function add() { function add() {
if (elems.includes(this)) { if (elems.includes(this)) {
@ -147,14 +149,15 @@ var svgEditorExtension_connector = (function () {
var key = 'c_' + pos; var key = 'c_' + pos;
var part = elData(this, key); var part = elData(this, key);
if (part == null) { if (part === null || part === undefined) {
// Does this ever return nullish values?
part = document.getElementById(this.attributes['se:connector'].value.split(' ')[i]); part = document.getElementById(this.attributes['se:connector'].value.split(' ')[i]);
elData(this, 'c_' + pos, part.id); elData(this, 'c_' + pos, part.id);
elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part])); elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part]));
} else part = document.getElementById(part); } else part = document.getElementById(part);
parts.push(part); parts.push(part);
}.bind(this)); }, this);
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
var cElem = parts[i]; var cElem = parts[i];
@ -257,7 +260,7 @@ var svgEditorExtension_connector = (function () {
}; };
getOffset = function _ref3(side, line) { getOffset = function _ref3(side, line) {
var giveOffset = !!line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off'); var giveOffset = line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off');
// TODO: Make this number (5) be based on marker width/height // TODO: Make this number (5) be based on marker width/height
var size = line.getAttribute('stroke-width') * 5; var size = line.getAttribute('stroke-width') * 5;
@ -293,17 +296,24 @@ var svgEditorExtension_connector = (function () {
}; };
}; };
$ = jQuery;
svgEditor = this; svgEditor = this;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
getElem = svgCanvas.getElem; getElem = svgCanvas.getElem;
svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data; $ = S.$, svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data;
_context2.next = 15; _context.next = 14;
return importLocale(); return importLocale();
case 15: case 14:
strings = _context2.sent; strings = _context.sent;
svgcontent = S.svgcontent, started = false, connections = [], selElems = []; svgcontent = S.svgcontent, started = false, connections = [], selElems = [];
/**
*
* @param {Float} x
* @param {Float} y
* @param {module:utilities.BBoxObject} bb
* @param {Float} offset
* @returns {module:math.XYObject}
*/
// Do once // Do once
(function () { (function () {
@ -311,19 +321,32 @@ var svgEditorExtension_connector = (function () {
svgCanvas.groupSelectedElements = function () { svgCanvas.groupSelectedElements = function () {
svgCanvas.removeFromSelection($(connSel).toArray()); svgCanvas.removeFromSelection($(connSel).toArray());
return gse.apply(this, arguments);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return gse.apply(this, args);
}; };
var mse = svgCanvas.moveSelectedElements; var mse = svgCanvas.moveSelectedElements;
svgCanvas.moveSelectedElements = function () { svgCanvas.moveSelectedElements = function () {
var cmd = mse.apply(this, arguments); for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var cmd = mse.apply(this, args);
updateConnectors(); updateConnectors();
return cmd; return cmd;
}; };
seNs = svgCanvas.getEditorNS(); seNs = svgCanvas.getEditorNS();
})(); // Do on reset })();
/**
* Do on reset.
* @returns {undefined}
*/
// $(svgroot).parent().mousemove(function (e) { // $(svgroot).parent().mousemove(function (e) {
@ -351,38 +374,21 @@ var svgEditorExtension_connector = (function () {
} }
} }
}]; }];
return _context2.abrupt("return", { return _context.abrupt("return", {
name: strings.name, name: strings.name,
svgicons: svgEditor.curConfig.imgPath + 'conn.svg', svgicons: svgEditor.curConfig.imgPath + 'conn.svg',
buttons: strings.buttons.map(function (button, i) { buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button); return Object.assign(buttons[i], button);
}), }),
addLangData: function () {
var _addLangData = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var lang, importLocale;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
lang = _ref.lang, importLocale = _ref.importLocale;
return _context.abrupt("return", {
data: strings.langList
});
case 2: /* async */
case "end": addLangData: function addLangData(_ref) {
return _context.stop(); var lang = _ref.lang;
} // , importLocale: importLoc
} return {
}, _callee, this); data: strings.langList
}));
return function addLangData(_x2) {
return _addLangData.apply(this, arguments);
}; };
}(), },
mouseDown: function mouseDown(opts) { mouseDown: function mouseDown(opts) {
var e = opts.event; var e = opts.event;
startX = opts.start_x; startX = opts.start_x;
@ -392,7 +398,7 @@ var svgEditorExtension_connector = (function () {
if (mode === 'connector') { if (mode === 'connector') {
if (started) { if (started) {
return; return undefined;
} }
var mouseTarget = e.target; var mouseTarget = e.target;
@ -431,6 +437,8 @@ var svgEditorExtension_connector = (function () {
if (mode === 'select') { if (mode === 'select') {
findConnectors(); findConnectors();
} }
return undefined;
}, },
mouseMove: function mouseMove(opts) { mouseMove: function mouseMove(opts) {
var zoom = svgCanvas.getZoom(); // const e = opts.event; var zoom = svgCanvas.getZoom(); // const e = opts.event;
@ -476,7 +484,7 @@ var svgEditorExtension_connector = (function () {
var mouseTarget = e.target; var mouseTarget = e.target;
if (svgCanvas.getMode() !== 'connector') { if (svgCanvas.getMode() !== 'connector') {
return; return undefined;
} }
var fo = $(mouseTarget).closest('foreignObject'); var fo = $(mouseTarget).closest('foreignObject');
@ -521,6 +529,8 @@ var svgEditorExtension_connector = (function () {
if (conn === connStr || conn === altStr) { if (conn === connStr || conn === altStr) {
return true; return true;
} }
return false;
}); });
if (dupe.length) { if (dupe.length) {
@ -598,7 +608,7 @@ var svgEditorExtension_connector = (function () {
var mid = elem.getAttribute('marker-mid'); var mid = elem.getAttribute('marker-mid');
var end = elem.getAttribute('marker-end'); var end = elem.getAttribute('marker-end');
curLine = elem; curLine = elem;
$(elem).data('start_off', !!start).data('end_off', !!end); $(elem).data('start_off', Boolean(start)).data('end_off', Boolean(end));
if (elem.tagName === 'line' && mid) { if (elem.tagName === 'line' && mid) {
// Convert to polyline to accept mid-arrow // Convert to polyline to accept mid-arrow
@ -666,12 +676,12 @@ var svgEditorExtension_connector = (function () {
} }
}); });
case 20: case 19:
case "end": case "end":
return _context2.stop(); return _context.stop();
} }
} }
}, _callee2, this); }, _callee, this);
})); }));
return function init(_x) { return function init(_x) {

View File

@ -37,8 +37,6 @@ var svgEditorExtension_eyedropper = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-eyedropper.js * ext-eyedropper.js
* *
@ -94,8 +92,7 @@ var svgEditorExtension_eyedropper = (function () {
case 3: case 3:
strings = _context.sent; strings = _context.sent;
svgEditor = this; svgEditor = this;
$ = jQuery; $ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
svgCanvas.undoMgr.addCommandToHistory(cmd); svgCanvas.undoMgr.addCommandToHistory(cmd);
}, currentStyle = { }, currentStyle = {
fillPaint: 'red', fillPaint: 'red',
@ -108,6 +105,12 @@ var svgEditorExtension_eyedropper = (function () {
strokeLinecap: 'butt', strokeLinecap: 'butt',
strokeLinejoin: 'miter' strokeLinejoin: 'miter'
}; };
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext-selectedChanged|module:svgcanvas.SvgCanvas#event:ext-elementChanged} opts
* @returns {undefined}
*/
buttons = [{ buttons = [{
id: 'tool_eyedropper', id: 'tool_eyedropper',
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png', icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
@ -184,7 +187,7 @@ var svgEditorExtension_eyedropper = (function () {
} }
}); });
case 9: case 8:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -37,8 +37,6 @@ var svgEditorExtension_foreignobject = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-foreignobject.js * ext-foreignobject.js
* *
@ -52,18 +50,18 @@ var svgEditorExtension_foreignobject = (function () {
init: function () { init: function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) { regeneratorRuntime.mark(function _callee2(S) {
var svgEditor, text2xml, NS, importLocale, $, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools; var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
setAttr = function _ref5(attr, val) { setAttr = function _ref6(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val); svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems); svgCanvas.call('changed', selElems);
}; };
showForeignEditor = function _ref4() { showForeignEditor = function _ref5() {
var elt = selElems[0]; var elt = selElems[0];
if (!elt || editingforeign) { if (!elt || editingforeign) {
@ -80,8 +78,8 @@ var svgEditorExtension_foreignobject = (function () {
$('#svg_source_textarea').focus(); $('#svg_source_textarea').focus();
}; };
setForeignString = function _ref3(xmlString) { setForeignString = function _ref4(xmlString) {
var elt = selElems[0]; var elt = selElems[0]; // The parent `Element` to append to
try { try {
// convert string into XML document // convert string into XML document
@ -92,19 +90,21 @@ var svgEditorExtension_foreignobject = (function () {
svgCanvas.call('changed', [elt]); svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection(); svgCanvas.clearSelection();
} catch (e) { } catch (e) {
console.log(e); // Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false; return false;
} }
return true; return true;
}; };
toggleSourceButtons = function _ref2(on) { toggleSourceButtons = function _ref3(on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on); $('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on); $('#foreign_save, #foreign_cancel').toggle(on);
}; };
showPanel = function _ref(on) { showPanel = function _ref2(on) {
var fcRules = $('#fc_rules'); var fcRules = $('#fc_rules');
if (!fcRules.length) { if (!fcRules.length) {
@ -116,27 +116,30 @@ var svgEditorExtension_foreignobject = (function () {
}; };
svgEditor = this; svgEditor = this;
text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale; $ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
$ = jQuery;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
svgdoc = S.svgroot.parentNode.ownerDocument; svgdoc = S.svgroot.parentNode.ownerDocument;
_context.next = 12; _context2.next = 11;
return importLocale(); return importLocale();
case 12: case 11:
strings = _context.sent; strings = _context2.sent;
properlySourceSizeTextArea = function properlySourceSizeTextArea() { properlySourceSizeTextArea = function properlySourceSizeTextArea() {
// TODO: remove magic numbers here and get values from CSS // TODO: remove magic numbers here and get values from CSS
var height = $('#svg_source_container').height() - 80; var height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height); $('#svg_source_textarea').css('height', height);
}; };
/**
* @param {boolean} on
* @returns {undefined}
*/
editingforeign = false; editingforeign = false;
/** /**
* This function sets the content of element elt to the input XML. * This function sets the content of element elt to the input XML.
* @param {string} xmlString - The XML text * @param {string} xmlString - The XML text
* @param {Element} elt - the parent element to append to
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/ */
@ -191,7 +194,7 @@ var svgEditorExtension_foreignobject = (function () {
} }
} }
}]; }];
return _context.abrupt("return", { return _context2.abrupt("return", {
name: strings.name, name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml', svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map(function (button, i) { buttons: strings.buttons.map(function (button, i) {
@ -215,24 +218,57 @@ var svgEditorExtension_foreignobject = (function () {
// Create source save/cancel buttons // Create source save/cancel buttons
/* const save = */ /* const save = */
$('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click(function () { $('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click(
if (!editingforeign) { /*#__PURE__*/
return; _asyncToGenerator(
} /*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var ok;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (editingforeign) {
_context.next = 2;
break;
}
if (!setForeignString($('#svg_source_textarea').val())) { return _context.abrupt("return");
$.confirm('Errors found. Revert to original?', function (ok) {
if (!ok) { case 2:
return false; if (setForeignString($('#svg_source_textarea').val())) {
_context.next = 11;
break;
}
_context.next = 5;
return $.confirm('Errors found. Revert to original?');
case 5:
ok = _context.sent;
if (ok) {
_context.next = 8;
break;
}
return _context.abrupt("return");
case 8:
endChanges();
_context.next = 12;
break;
case 11:
endChanges();
case 12:
case "end":
return _context.stop();
} }
}
endChanges(); }, _callee, this);
}); })));
} else {
endChanges();
} // setSelectMode();
});
/* const cancel = */ /* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () { $('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
@ -242,49 +278,53 @@ var svgEditorExtension_foreignobject = (function () {
}, },
mouseDown: function mouseDown(opts) { mouseDown: function mouseDown(opts) {
// const e = opts.event; // const e = opts.event;
if (svgCanvas.getMode() === 'foreign') { if (svgCanvas.getMode() !== 'foreign') {
started = true; return undefined;
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'
}
});
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
};
} }
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'
}
});
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) { mouseUp: function mouseUp(opts) {
// const e = opts.event; // const e = opts.event;
if (svgCanvas.getMode() === 'foreign' && started) { if (svgCanvas.getMode() !== 'foreign' || !started) {
var attrs = $(newFO).attr(['width', 'height']); return undefined;
var keep = attrs.width !== '0' || attrs.height !== '0';
svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
} }
var attrs = $(newFO).attr(['width', 'height']);
var keep = attrs.width !== '0' || attrs.height !== '0';
svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
}, },
selectedChanged: function selectedChanged(opts) { selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements // Use this to update the current selected elements
@ -311,12 +351,12 @@ var svgEditorExtension_foreignobject = (function () {
elementChanged: function elementChanged(opts) {} elementChanged: function elementChanged(opts) {}
}); });
case 18: case 17:
case "end": case "end":
return _context.stop(); return _context2.stop();
} }
} }
}, _callee, this); }, _callee2, this);
})); }));
return function init(_x) { return function init(_x) {

View File

@ -37,8 +37,6 @@ var svgEditorExtension_grid = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-grid.js * ext-grid.js
* *
@ -53,7 +51,7 @@ var svgEditorExtension_grid = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var NS, getTypeMap, importLocale, strings, svgEditor, $, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons; var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -121,14 +119,13 @@ var svgEditorExtension_grid = (function () {
svgCanvas.setHref(gridimg, datauri); svgCanvas.setHref(gridimg, datauri);
}; };
NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale; $ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
_context.next = 5; _context.next = 5;
return importLocale(); return importLocale();
case 5: case 5:
strings = _context.sent; strings = _context.sent;
svgEditor = this; svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas; 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]; 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; showGrid = svgEditor.curConfig.showGrid || false;
@ -178,6 +175,12 @@ var svgEditorExtension_grid = (function () {
style: 'pointer-events: none; display:visible;' style: 'pointer-events: none; display:visible;'
}); });
$('#canvasGrid').append(gridBox); $('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {undefined}
*/
buttons = [{ buttons = [{
id: 'view_grid', id: 'view_grid',
icon: svgEditor.curConfig.extIconsPath + 'grid.png', icon: svgEditor.curConfig.extIconsPath + 'grid.png',
@ -208,7 +211,7 @@ var svgEditorExtension_grid = (function () {
}) })
}); });
case 26: case 25:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -75,8 +75,6 @@ var svgEditorExtension_helloworld = (function () {
throw new TypeError("Invalid attempt to destructure non-iterable instance"); throw new TypeError("Invalid attempt to destructure non-iterable instance");
} }
/* globals jQuery */
/** /**
* ext-helloworld.js * ext-helloworld.js
* *
@ -97,19 +95,18 @@ var svgEditorExtension_helloworld = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, strings, svgEditor, $, svgCanvas; var $, importLocale, strings, svgEditor, svgCanvas;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
importLocale = _ref.importLocale; $ = _ref.$, importLocale = _ref.importLocale;
_context.next = 3; _context.next = 3;
return importLocale(); return importLocale();
case 3: case 3:
strings = _context.sent; strings = _context.sent;
svgEditor = this; svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
return _context.abrupt("return", { return _context.abrupt("return", {
name: strings.name, name: strings.name,
@ -148,6 +145,8 @@ var svgEditorExtension_helloworld = (function () {
started: true started: true
}; };
} }
return undefined;
}, },
// This is triggered from anywhere, but "started" must have been set // This is triggered from anywhere, but "started" must have been set
// to true (see above). Note that "opts" is an object with event info // to true (see above). Note that "opts" is an object with event info
@ -173,7 +172,7 @@ var svgEditorExtension_helloworld = (function () {
} }
}); });
case 8: case 7:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -51,8 +51,6 @@ var svgEditorExtension_imagelib = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-imagelib.js * ext-imagelib.js
* *
@ -66,13 +64,13 @@ var svgEditorExtension_imagelib = (function () {
init: function () { init: function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee2(_ref) {
var decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, $, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons; var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
showBrowser = function _ref9() { showBrowser = function _ref10() {
var browser = $('#imgbrowse'); var browser = $('#imgbrowse');
if (!browser.length) { if (!browser.length) {
@ -128,10 +126,10 @@ var svgEditorExtension_imagelib = (function () {
}); });
cancel.prepend($.getSvgIcon('cancel', true)); cancel.prepend($.getSvgIcon('cancel', true));
back.prepend($.getSvgIcon('tool_imagelib', true)); back.prepend($.getSvgIcon('tool_imagelib', true));
imagelibStrings.imgLibs.forEach(function (_ref5) { imagelibStrings.imgLibs.forEach(function (_ref6) {
var name = _ref5.name, var name = _ref6.name,
url = _ref5.url, url = _ref6.url,
description = _ref5.description; description = _ref6.description;
$('<li>').appendTo(libOpts).text(name).on('click touchend', function () { $('<li>').appendTo(libOpts).text(name).on('click touchend', function () {
frame.attr('src', url).show(); frame.attr('src', url).show();
header.text(name); header.text(name);
@ -144,7 +142,7 @@ var svgEditorExtension_imagelib = (function () {
} }
}; };
toggleMulti = function _ref8(show) { toggleMulti = function _ref9(show) {
$('#lib_framewrap, #imglib_opts').css({ $('#lib_framewrap, #imglib_opts').css({
right: show ? 200 : 10 right: show ? 200 : 10
}); });
@ -186,7 +184,7 @@ var svgEditorExtension_imagelib = (function () {
submit.toggle(show); submit.toggle(show);
}; };
importImage = function _ref7(url) { importImage = function _ref8(url) {
var newImage = svgCanvas.addSVGElementFromJson({ var newImage = svgCanvas.addSVGElementFromJson({
element: 'image', element: 'image',
attr: { attr: {
@ -203,19 +201,18 @@ var svgEditorExtension_imagelib = (function () {
svgCanvas.setImageURL(url); svgCanvas.setImageURL(url);
}; };
closeBrowser = function _ref6() { closeBrowser = function _ref7() {
$('#imgbrowse_holder').hide(); $('#imgbrowse_holder').hide();
}; };
decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset; $ = _ref.$, decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
_context.next = 7; _context2.next = 7;
return importLocale(); return importLocale();
case 7: case 7:
imagelibStrings = _context.sent; imagelibStrings = _context2.sent;
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
svgEditor = this; svgEditor = this;
$ = jQuery;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath; uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) { imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) {
var name = _ref2.name, var name = _ref2.name,
@ -238,233 +235,316 @@ var svgEditorExtension_imagelib = (function () {
return location.origin; return location.origin;
} }
}); });
/**
*
* @returns {undefined}
*/
pending = {}; pending = {};
mode = 's'; mode = 's';
multiArr = []; multiArr = [];
transferStopped = false; transferStopped = false;
// Receive `postMessage` data // Receive `postMessage` data
window.addEventListener('message', function (_ref4) { window.addEventListener('message',
var origin = _ref4.origin, /*#__PURE__*/
response = _ref4.data; function () {
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref4) {
var origin, response, id, type, hasName, hasHref, char1, secondpos, entry, curMeta, svgStr, imgStr, name, message, pre, src, title, xml, ok;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
origin = _ref4.origin, response = _ref4.data;
if (!response || !['string', 'object'].includes(_typeof(response))) { if (!(!response || !['string', 'object'].includes(_typeof(response)))) {
// Do nothing _context.next = 3;
return; break;
} }
var id; return _context.abrupt("return");
var type;
try { case 3:
// Todo: This block can be removed (and the above check changed to _context.prev = 3;
// insist on an object) if embedAPI moves away from a string to // Todo: This block can be removed (and the above check changed to
// an object (if IE9 support not needed) // insist on an object) if embedAPI moves away from a string to
response = _typeof(response) === 'object' ? response : JSON.parse(response); // an object (if IE9 support not needed)
response = _typeof(response) === 'object' ? response : JSON.parse(response);
if (response.namespace !== 'imagelib') { if (!(response.namespace !== 'imagelib')) {
return; _context.next = 7;
} break;
}
if (!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin)) { return _context.abrupt("return");
console.log("Origin ".concat(origin, " not whitelisted for posting to ").concat(window.origin));
return;
}
var hasName = 'name' in response; case 7:
var hasHref = 'href' in response; if (!(!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin))) {
_context.next = 10;
break;
}
if (!hasName && transferStopped) { // Todo: Surface this error to user?
transferStopped = false; console.log("Origin ".concat(origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
return;
}
if (hasHref) { return _context.abrupt("return");
id = response.href;
response = response.data; case 10:
} // Hide possible transfer dialog box hasName = 'name' in response;
hasHref = 'href' in response;
if (!(!hasName && transferStopped)) {
_context.next = 15;
break;
}
transferStopped = false;
return _context.abrupt("return");
case 15:
if (hasHref) {
id = response.href;
response = response.data;
} // Hide possible transfer dialog box
$('#dialog_box').hide(); $('#dialog_box').hide();
type = hasName ? 'meta' : response.charAt(0); type = hasName ? 'meta' : response.charAt(0);
} catch (e) { _context.next = 28;
// This block is for backward compatibility (for IAN and Openclipart); break;
// should otherwise return
if (typeof response === 'string') {
var char1 = response.charAt(0);
if (char1 !== '{' && transferStopped) { case 20:
transferStopped = false; _context.prev = 20;
return; _context.t0 = _context["catch"](3);
}
if (char1 === '|') { if (!(typeof response === 'string')) {
var secondpos = response.indexOf('|', 1); _context.next = 28;
id = response.substr(1, secondpos - 1); break;
response = response.substr(secondpos + 1); }
type = response.charAt(0);
}
}
}
var entry, curMeta, svgStr, imgStr; char1 = response.charAt(0);
switch (type) { if (!(char1 !== '{' && transferStopped)) {
case 'meta': _context.next = 27;
{ break;
// Metadata }
transferStopped = false;
curMeta = response; // Should be safe to add dynamic property as passed metadata
pending[curMeta.id] = curMeta; // lgtm [js/remote-property-injection] transferStopped = false;
return _context.abrupt("return");
var name = curMeta.name || 'file'; case 27:
var message = uiStrings.notification.retrieving.replace('%s', name); if (char1 === '|') {
secondpos = response.indexOf('|', 1);
id = response.substr(1, secondpos - 1);
response = response.substr(secondpos + 1);
type = response.charAt(0);
}
if (mode !== 'm') { case 28:
$.process_cancel(message, function () { _context.t1 = type;
_context.next = _context.t1 === 'meta' ? 31 : _context.t1 === '<' ? 47 : _context.t1 === 'd' ? 49 : 60;
break;
case 31:
// Metadata
transferStopped = false;
curMeta = response; // Should be safe to add dynamic property as passed metadata
pending[curMeta.id] = curMeta; // lgtm [js/remote-property-injection]
name = curMeta.name || 'file';
message = uiStrings.notification.retrieving.replace('%s', name);
if (!(mode !== 'm')) {
_context.next = 43;
break;
}
_context.next = 39;
return $.process_cancel(message);
case 39:
transferStopped = true; // Should a message be sent back to the frame? transferStopped = true; // Should a message be sent back to the frame?
$('#dialog_box').hide(); $('#dialog_box').hide();
}); _context.next = 46;
} else { break;
entry = $('<div>').text(message).data('id', curMeta.id);
preview.append(entry);
curMeta.entry = entry;
}
return; case 43:
} entry = $('<div>').text(message).data('id', curMeta.id);
preview.append(entry);
curMeta.entry = entry;
case '<': case 46:
svgStr = true; return _context.abrupt("return");
break;
case 'd': case 47:
{ svgStr = true;
if (response.startsWith('data:image/svg+xml')) { return _context.abrupt("break", 62);
var pre = 'data:image/svg+xml;base64,';
var src = response.substring(pre.length);
response = decode64(src);
svgStr = true;
break;
} else if (response.startsWith('data:image/')) {
imgStr = true;
break;
}
}
// Else fall through
default: case 49:
// TODO: See if there's a way to base64 encode the binary data stream if (!response.startsWith('data:image/svg+xml')) {
// const str = 'data:;base64,' + svgedit.utilities.encode64(response, true); _context.next = 57;
// Assume it's raw image data break;
// importImage(str); }
// Don't give warning as postMessage may have been used by something else
if (mode !== 'm') { pre = 'data:image/svg+xml;base64,';
closeBrowser(); src = response.substring(pre.length);
} else { response = decode64(src);
pending[id].entry.remove(); svgStr = true;
} // $.alert('Unexpected data was returned: ' + response, function() { return _context.abrupt("break", 62);
// if (mode !== 'm') {
// closeBrowser(); case 57:
// } else { if (!response.startsWith('data:image/')) {
// pending[id].entry.remove(); _context.next = 60;
// } break;
// }); }
imgStr = true;
return _context.abrupt("break", 62);
case 60:
// TODO: See if there's a way to base64 encode the binary data stream
// const str = 'data:;base64,' + svgedit.utilities.encode64(response, true);
// Assume it's raw image data
// importImage(str);
// Don't give warning as postMessage may have been used by something else
if (mode !== 'm') {
closeBrowser();
} else {
pending[id].entry.remove();
} // await $.alert('Unexpected data was returned: ' + response, function() {
// if (mode !== 'm') {
// closeBrowser();
// } else {
// pending[id].entry.remove();
// }
// });
return; return _context.abrupt("return");
}
switch (mode) { case 62:
case 's': _context.t2 = mode;
// Import one _context.next = _context.t2 === 's' ? 65 : _context.t2 === 'm' ? 68 : _context.t2 === 'o' ? 72 : 83;
if (svgStr) { break;
svgCanvas.importSvgString(response);
} else if (imgStr) {
importImage(response);
}
closeBrowser(); case 65:
break; // Import one
if (svgStr) {
svgCanvas.importSvgString(response);
} else if (imgStr) {
importImage(response);
}
case 'm': closeBrowser();
// Import multiple return _context.abrupt("break", 83);
multiArr.push([svgStr ? 'svg' : 'img', response]);
curMeta = pending[id];
var title;
if (svgStr) { case 68:
if (curMeta && curMeta.name) { // Import multiple
title = curMeta.name; multiArr.push([svgStr ? 'svg' : 'img', response]);
} else { curMeta = pending[id];
// Try to find a title
// `dropXMLInternalSubset` is to help prevent the billion laughs attack
var xml = new DOMParser().parseFromString(dropXMLInternalSubset(response), 'text/xml').documentElement; // lgtm [js/xml-bomb]
title = $(xml).children('title').first().text() || '(SVG #' + response.length + ')'; if (svgStr) {
} if (curMeta && curMeta.name) {
title = curMeta.name;
if (curMeta) {
preview.children().each(function () {
if ($(this).data('id') === id) {
if (curMeta.preview_url) {
$(this).html($('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title)));
} else { } else {
$(this).text(title); // Try to find a title
// `dropXMLInternalSubset` is to help prevent the billion laughs attack
xml = new DOMParser().parseFromString(dropXMLInternalSubset(response), 'text/xml').documentElement; // lgtm [js/xml-bomb]
title = $(xml).children('title').first().text() || '(SVG #' + response.length + ')';
} }
submit.removeAttr('disabled'); if (curMeta) {
} preview.children().each(function () {
}); if ($(this).data('id') === id) {
} else { if (curMeta.preview_url) {
preview.append($('<div>').text(title)); $(this).html($('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title)));
submit.removeAttr('disabled'); } else {
} $(this).text(title);
} else { }
if (curMeta && curMeta.preview_url) {
title = curMeta.name || '';
}
if (curMeta && curMeta.preview_url) { submit.removeAttr('disabled');
entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title)); }
} else { });
entry = $('<img>').attr('src', response); } else {
} preview.append($('<div>').text(title));
submit.removeAttr('disabled');
}
} else {
if (curMeta && curMeta.preview_url) {
title = curMeta.name || '';
}
if (curMeta) { if (curMeta && curMeta.preview_url) {
preview.children().each(function () { entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title));
if ($(this).data('id') === id) { } else {
$(this).html(entry); entry = $('<img>').attr('src', response);
submit.removeAttr('disabled'); }
if (curMeta) {
preview.children().each(function () {
if ($(this).data('id') === id) {
$(this).html(entry);
submit.removeAttr('disabled');
}
});
} else {
preview.append($('<div>').append(entry));
submit.removeAttr('disabled');
}
} }
});
} else { return _context.abrupt("break", 83);
preview.append($('<div>').append(entry));
submit.removeAttr('disabled'); case 72:
if (svgStr) {
_context.next = 74;
break;
}
return _context.abrupt("break", 83);
case 74:
closeBrowser();
_context.next = 77;
return svgEditor.openPrep();
case 77:
ok = _context.sent;
if (ok) {
_context.next = 80;
break;
}
return _context.abrupt("return");
case 80:
svgCanvas.clear();
svgCanvas.setSvgString(response); // updateCanvas();
return _context.abrupt("break", 83);
case 83:
case "end":
return _context.stop();
} }
} }
}, _callee, this, [[3, 20]]);
}));
break; return function (_x2) {
return _ref5.apply(this, arguments);
};
}(), true);
/**
* @param {boolean} show
* @returns {undefined}
*/
case 'o':
// Open
if (!svgStr) {
break;
}
svgEditor.openPrep(function (ok) {
if (!ok) {
return;
}
svgCanvas.clear();
svgCanvas.setSvgString(response); // updateCanvas();
});
closeBrowser();
break;
}
}, true);
buttons = [{ buttons = [{
id: 'tool_imagelib', id: 'tool_imagelib',
type: 'app_menu', type: 'app_menu',
@ -475,7 +555,7 @@ var svgEditorExtension_imagelib = (function () {
mouseup: showBrowser mouseup: showBrowser
} }
}]; }];
return _context.abrupt("return", { return _context2.abrupt("return", {
svgicons: extIconsPath + 'ext-imagelib.xml', svgicons: extIconsPath + 'ext-imagelib.xml',
buttons: imagelibStrings.buttons.map(function (button, i) { buttons: imagelibStrings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button); return Object.assign(buttons[i], button);
@ -485,12 +565,12 @@ var svgEditorExtension_imagelib = (function () {
} }
}); });
case 21: case 20:
case "end": case "end":
return _context.stop(); return _context2.stop();
} }
} }
}, _callee, this); }, _callee2, this);
})); }));
return function init(_x) { return function init(_x) {

View File

@ -37,8 +37,6 @@ var svgEditorExtension_markers = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-markers.js * ext-markers.js
* *
@ -74,13 +72,14 @@ var svgEditorExtension_markers = (function () {
init: function () { init: function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(S) { regeneratorRuntime.mark(function _callee3(S) {
var strings, svgEditor, $, svgCanvas, addElem, mtypes, markerPrefix, idPrefix, markerTypes, getLinked, setIcon, selElems, showPanel, addMarker, convertline, setMarker, colorChanged, updateReferences, triggerTextEntry, showTextPrompt, setArrowFromButton, getTitle, buildButtonList, contextTools; var strings, svgEditor, $, svgCanvas, addElem, mtypes, markerPrefix, idPrefix, markerTypes, getLinked, setIcon, selElems, showPanel, addMarker, convertline, setMarker, colorChanged, updateReferences, triggerTextEntry, showTextPrompt, _showTextPrompt, setArrowFromButton, _setArrowFromButton, getTitle, buildButtonList, contextTools;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context3.prev = _context3.next) {
case 0: case 0:
buildButtonList = function _ref14(lang) { buildButtonList = function _ref16() {
var buttons = []; // const i = 0; var buttons = []; // const i = 0;
/* /*
@ -131,42 +130,95 @@ var svgEditorExtension_markers = (function () {
return buttons; return buttons;
}; };
getTitle = function _ref13(id) { getTitle = function _ref15(id) {
var langList = strings.langList; var langList = strings.langList;
var item = langList.find(function (item) { var item = langList.find(function (itm) {
return item.id === id; return itm.id === id;
}); });
return item ? item.title : id; return item ? item.title : id;
}; };
setArrowFromButton = function _ref12(obj) { _setArrowFromButton = function _ref14() {
var parts = this.id.split('_'); _setArrowFromButton = _asyncToGenerator(
var pos = parts[1]; /*#__PURE__*/
var val = parts[2]; regeneratorRuntime.mark(function _callee2(ev) {
var parts, pos, val;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
parts = this.id.split('_');
pos = parts[1];
val = parts[2];
if (parts[3]) { if (parts[3]) {
val += '_' + parts[3]; val += '_' + parts[3];
} }
if (val !== 'textmarker') { if (!(val !== 'textmarker')) {
triggerTextEntry(pos, '\\' + val); _context2.next = 8;
} else { break;
showTextPrompt(pos); }
}
triggerTextEntry(pos, '\\' + val);
_context2.next = 10;
break;
case 8:
_context2.next = 10;
return showTextPrompt(pos);
case 10:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
return _setArrowFromButton.apply(this, arguments);
}; };
showTextPrompt = function _ref11(pos) { setArrowFromButton = function _ref13(_x3) {
var def = $('#' + pos + '_marker').val(); return _setArrowFromButton.apply(this, arguments);
};
if (def.substr(0, 1) === '\\') { _showTextPrompt = function _ref12() {
def = ''; _showTextPrompt = _asyncToGenerator(
} /*#__PURE__*/
regeneratorRuntime.mark(function _callee(pos) {
var def, txt;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
def = $('#' + pos + '_marker').val();
$.prompt('Enter text for ' + pos + ' marker', def, function (txt) { if (def.substr(0, 1) === '\\') {
if (txt) { def = '';
triggerTextEntry(pos, txt); }
}
}); _context.next = 4;
return $.prompt('Enter text for ' + pos + ' marker', def);
case 4:
txt = _context.sent;
if (txt) {
triggerTextEntry(pos, txt);
}
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return _showTextPrompt.apply(this, arguments);
};
showTextPrompt = function _ref11(_x2) {
return _showTextPrompt.apply(this, arguments);
}; };
triggerTextEntry = function _ref10(pos, val) { triggerTextEntry = function _ref10(pos, val) {
@ -333,11 +385,11 @@ var svgEditorExtension_markers = (function () {
var marker = svgCanvas.getElem(id); var marker = svgCanvas.getElem(id);
if (marker) { if (marker) {
return; return undefined;
} }
if (val === '' || val === '\\nomarker') { if (val === '' || val === '\\nomarker') {
return; return undefined;
} }
var el = selElems[0]; var el = selElems[0];
@ -360,7 +412,7 @@ var svgEditorExtension_markers = (function () {
} }
if (!markerTypes[seType]) { if (!markerTypes[seType]) {
return; return undefined;
} // an unknown type! } // an unknown type!
// create a generic marker // create a generic marker
@ -492,13 +544,13 @@ var svgEditorExtension_markers = (function () {
return svgCanvas.getElem(m[1]); return svgCanvas.getElem(m[1]);
}; };
_context2.next = 15; _context3.next = 17;
return S.importLocale(); return S.importLocale();
case 15: case 17:
strings = _context2.sent; strings = _context3.sent;
svgEditor = this; svgEditor = this;
$ = jQuery; $ = S.$;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
addElem = svgCanvas.addSVGElementFromJson; addElem = svgCanvas.addSVGElementFromJson;
mtypes = ['start', 'mid', 'end']; mtypes = ['start', 'mid', 'end'];
@ -647,38 +699,21 @@ var svgEditorExtension_markers = (function () {
change: setArrowFromButton change: setArrowFromButton
} }
}]; }];
return _context2.abrupt("return", { return _context3.abrupt("return", {
name: strings.name, name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'markers-icons.xml', svgicons: svgEditor.curConfig.extIconsPath + 'markers-icons.xml',
callback: function callback() { callback: function callback() {
$('#marker_panel').addClass('toolset').hide(); $('#marker_panel').addClass('toolset').hide();
}, },
addLangData: function () {
var _addLangData = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, lang;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, lang = _ref.lang;
return _context.abrupt("return", {
data: strings.langList
});
case 2: /* async */
case "end": addLangData: function addLangData(_ref) {
return _context.stop(); var importLocale = _ref.importLocale,
} lang = _ref.lang;
} return {
}, _callee, this); data: strings.langList
}));
return function addLangData(_x2) {
return _addLangData.apply(this, arguments);
}; };
}(), },
selectedChanged: function selectedChanged(opts) { selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements // Use this to update the current selected elements
// console.log('selectChanged',opts); // console.log('selectChanged',opts);
@ -716,12 +751,12 @@ var svgEditorExtension_markers = (function () {
}) })
}); });
case 27: case 29:
case "end": case "end":
return _context2.stop(); return _context3.stop();
} }
} }
}, _callee2, this); }, _callee3, this);
})); }));
return function init(_x) { return function init(_x) {

View File

@ -37,6 +37,14 @@ var svgEditorExtension_mathjax = (function () {
}; };
} }
/**
* Add any of the whitelisted attributes to the script tag.
* @param {HTMLScriptElement} script
* @param {PlainObject.<string, string>} atts
* @returns {undefined}
*/
function addScriptAtts(script, atts) { function addScriptAtts(script, atts) {
['id', 'class', 'type'].forEach(function (prop) { ['id', 'class', 'type'].forEach(function (prop) {
if (prop in atts) { if (prop in atts) {
@ -55,6 +63,7 @@ var svgEditorExtension_mathjax = (function () {
} }
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script'); var script = document.createElement('script');
var destructor = function destructor() { var destructor = function destructor() {
@ -87,11 +96,11 @@ var svgEditorExtension_mathjax = (function () {
init: function () { init: function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee2(_ref) {
var importLocale, strings, svgEditor, $, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons; var $, importLocale, strings, svgEditor, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
saveMath = function _ref2() { saveMath = function _ref2() {
var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
@ -145,14 +154,13 @@ var svgEditorExtension_mathjax = (function () {
}); });
}; };
importLocale = _ref.importLocale; $ = _ref.$, importLocale = _ref.importLocale;
_context.next = 4; _context2.next = 4;
return importLocale(); return importLocale();
case 4: case 4:
strings = _context.sent; strings = _context2.sent;
svgEditor = this; svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention. svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention.
// This will be added to the head tag before MathJax is loaded. // This will be added to the head tag before MathJax is loaded.
@ -182,7 +190,8 @@ var svgEditorExtension_mathjax = (function () {
// Had been on https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG.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 // 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; 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. 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, { $.extend(uiStrings, {
mathjax: { mathjax: {
@ -193,74 +202,110 @@ var svgEditorExtension_mathjax = (function () {
title: 'Mathematics code editor' title: 'Mathematics code editor'
} }
}); });
/**
*
* @returns {undefined}
*/
buttons = [{ buttons = [{
id: 'tool_mathjax', id: 'tool_mathjax',
type: 'mode', type: 'mode',
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png', icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
events: { events: {
click: function click() { click: function () {
// Only load Mathjax when needed, we don't want to strain Svg-Edit any more. var _click = _asyncToGenerator(
// From this point on it is very probable that it will be needed, so load it. /*#__PURE__*/
if (mathjaxLoaded === false) { regeneratorRuntime.mark(function _callee() {
$('<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. 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.
$('#mathjax_container').draggable({ if (!(mathjaxLoaded === false)) {
cancel: 'button,fieldset', _context.next = 17;
containment: 'window' break;
}); // Add functionality and picture to cancel button. }
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () { $('<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').hide();
}); // Add functionality and picture to the save button.
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () { $('#mathjax_container').draggable({
saveMath(); cancel: 'button,fieldset',
$('#mathjax').hide(); containment: 'window'
}); // MathJax preprocessing has to ignore most of the page. }); // Add functionality and picture to cancel button.
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library. $('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
// Todo: insert script with modules once widely supported $('#mathjax').hide();
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up }); // Add functionality and picture to the save button.
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
/* $('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
const modularVersion = !('svgEditor' in window) || saveMath();
!window.svgEditor || $('#mathjax').hide();
window.svgEditor.modules !== false; }); // MathJax preprocessing has to ignore most of the page.
// 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`
importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure).then(function () { $('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
// When MathJax is loaded get the div where the math will be rendered. // Todo: insert script with modules once widely supported
MathJax.Hub.queue.Push(function () { // and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
math = MathJax.Hub.getAllJax('#mathjax_creator')[0]; // providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
console.log(math);
mathjaxLoaded = true;
console.log('MathJax Loaded');
});
}).catch(function () {
console.log('Failed loadeing MathJax.');
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
});
} // Set the mode.
/*
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`
svgCanvas.setMode('mathjax'); _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, this, [[7, 13]]);
}));
return function click() {
return _click.apply(this, arguments);
};
}()
} }
}]; }];
return _context.abrupt("return", { return _context2.abrupt("return", {
name: strings.name, name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml', svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map(function (button, i) { buttons: strings.buttons.map(function (button, i) {
@ -272,6 +317,8 @@ var svgEditorExtension_mathjax = (function () {
started: true started: true
}; };
} }
return undefined;
}, },
mouseUp: function mouseUp(opts) { mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() === 'mathjax') { if (svgCanvas.getMode() === 'mathjax') {
@ -285,6 +332,8 @@ var svgEditorExtension_mathjax = (function () {
started: false started: false
}; // Otherwise the last selected object dissapears. }; // Otherwise the last selected object dissapears.
} }
return undefined;
}, },
callback: function callback() { 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. $('<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.
@ -292,12 +341,12 @@ var svgEditorExtension_mathjax = (function () {
} }
}); });
case 13: case 12:
case "end": case "end":
return _context.stop(); return _context2.stop();
} }
} }
}, _callee, this); }, _callee2, this);
})); }));
return function init(_x) { return function init(_x) {

View File

@ -1,8 +1,6 @@
var svgEditorExtension_overview_window = (function () { var svgEditorExtension_overview_window = (function () {
'use strict'; 'use strict';
/* globals jQuery */
/** /**
* ext-overview_window.js * ext-overview_window.js
* *
@ -14,18 +12,18 @@ var svgEditorExtension_overview_window = (function () {
var extOverview_window = { var extOverview_window = {
name: 'overview_window', name: 'overview_window',
init: function init(_ref) { init: function init(_ref) {
var isChrome = _ref.isChrome, var $ = _ref.$,
isChrome = _ref.isChrome,
isIE = _ref.isIE; isIE = _ref.isIE;
var $ = jQuery;
var overviewWindowGlobals = {}; // Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and var 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()) {
var verIndex = navigator.userAgent.indexOf('Chrome/') + 7; var verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
var chromeVersion = parseInt(navigator.userAgent.substring(verIndex), 10); var chromeVersion = parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) { if (chromeVersion < 49) {
return; return undefined;
} }
} // Define and insert the base html element. } // Define and insert the base html element.

View File

@ -91,6 +91,8 @@ var svgEditorExtension_panning = (function () {
started: true started: true
}; };
} }
return undefined;
}, },
mouseUp: function mouseUp() { mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'ext-panning') { if (svgCanvas.getMode() === 'ext-panning') {
@ -100,6 +102,8 @@ var svgEditorExtension_panning = (function () {
element: null element: null
}; };
} }
return undefined;
} }
}); });

View File

@ -1,15 +1,18 @@
var svgEditorExtension_php_savefile = (function () { var svgEditorExtension_php_savefile = (function () {
'use strict'; 'use strict';
/* globals jQuery */
// TODO: Might add support for "exportImage" custom // TODO: Might add support for "exportImage" custom
// 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() { init: function init(_ref) {
var $ = _ref.$;
var svgEditor = this; var svgEditor = this;
var $ = jQuery;
var svgCanvas = svgEditor.canvas; var svgCanvas = svgEditor.canvas;
/**
* Get file name out of SVGEdit document title.
* @returns {string}
*/
function getFileNameFromTitle() { function getFileNameFromTitle() {
var title = svgCanvas.getDocumentTitle(); var title = svgCanvas.getDocumentTitle();

View File

@ -37,8 +37,6 @@ var svgEditorExtension_polygon = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-polygon.js * ext-polygon.js
* *
@ -52,7 +50,7 @@ var svgEditorExtension_polygon = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) { regeneratorRuntime.mark(function _callee(S) {
var svgEditor, $, svgCanvas, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools; var svgEditor, svgCanvas, $, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -82,13 +80,12 @@ var svgEditorExtension_polygon = (function () {
}; };
svgEditor = this; svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
importLocale = S.importLocale, editingitex = false; $ = S.$, importLocale = S.importLocale, editingitex = false;
_context.next = 10; _context.next = 9;
return importLocale(); return importLocale();
case 10: case 9:
strings = _context.sent; strings = _context.sent;
/** /**
@ -189,88 +186,89 @@ var svgEditorExtension_polygon = (function () {
}, 3000); }, 3000);
}, },
mouseDown: function mouseDown(opts) { mouseDown: function mouseDown(opts) {
// const e = opts.event; if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length); var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length); var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
var sWidth = svgCanvas.getStrokeWidth(); var sWidth = svgCanvas.getStrokeWidth();
started = true;
if (svgCanvas.getMode() === 'polygon') { newFO = svgCanvas.addSVGElementFromJson({
started = true; element: 'polygon',
newFO = svgCanvas.addSVGElementFromJson({ attr: {
element: 'polygon', cx: opts.start_x,
attr: { cy: opts.start_y,
cx: opts.start_x, id: svgCanvas.getNextId(),
cy: opts.start_y, shape: 'regularPoly',
id: svgCanvas.getNextId(), sides: document.getElementById('polySides').value,
shape: 'regularPoly', orient: 'x',
sides: document.getElementById('polySides').value, edge: 0,
orient: 'x', fill: rgb,
edge: 0, strokecolor: sRgb,
fill: rgb, strokeWidth: sWidth
strokecolor: sRgb, }
strokeWidth: sWidth });
} return {
}); started: true
return { };
started: true
};
}
}, },
mouseMove: function mouseMove(opts) { mouseMove: function mouseMove(opts) {
if (!started) { if (!started || svgCanvas.getMode() !== 'polygon') {
return; return undefined;
} } // const e = opts.event;
if (svgCanvas.getMode() === 'polygon') {
// const e = opts.event;
var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
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,
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++) {
var 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); var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
newFO.setAttribute('fill', fill); var x = opts.mouse_x;
newFO.setAttribute('stroke', strokecolor); var y = opts.mouse_y;
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)'); var cx = c.cx,
// const shape = newFO.getAttribute('shape'); cy = c.cy,
// newFO.append(poly); fill = c.fill,
// DrawPoly(cx, cy, sides, edg, orient); strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
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 = '';
return { for (var s = 0; sides >= s; s++) {
started: true var 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: function mouseUp(opts) { mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() === 'polygon') { if (svgCanvas.getMode() !== 'polygon') {
var attrs = $(newFO).attr('edge'); return undefined;
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
} }
var attrs = $(newFO).attr('edge');
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
}, },
selectedChanged: function selectedChanged(opts) { selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements // Use this to update the current selected elements
@ -295,7 +293,7 @@ var svgEditorExtension_polygon = (function () {
elementChanged: function elementChanged(opts) {} elementChanged: function elementChanged(opts) {}
}); });
case 14: case 13:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,43 @@ var svgEditorExtension_shapes = (function () {
}; };
} }
/* globals jQuery */ function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
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 _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
/** /**
* ext-shapes.js * ext-shapes.js
@ -53,12 +89,12 @@ var svgEditorExtension_shapes = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, strings, svgEditor, $, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons; var $, importLocale, strings, svgEditor, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
loadLibrary = function _ref4(catId) { loadLibrary = function _ref8(catId) {
var lib = library[catId]; var lib = library[catId];
if (!lib) { if (!lib) {
@ -84,7 +120,7 @@ var svgEditorExtension_shapes = (function () {
loadIcons(); loadIcons();
}; };
makeButtons = function _ref3(cat, shapes) { makeButtons = function _ref7(cat, shapes) {
var size = curLib.size || 300; var size = curLib.size || 300;
var fill = curLib.fill || false; var fill = curLib.fill || false;
var off = size * 0.05; var off = size * 0.05;
@ -97,10 +133,11 @@ var svgEditorExtension_shapes = (function () {
shapeIcon.documentElement.setAttribute('height', height); shapeIcon.documentElement.setAttribute('height', height);
var svgElem = $(document.importNode(shapeIcon.documentElement, true)); var svgElem = $(document.importNode(shapeIcon.documentElement, true));
var data = shapes.data; var data = shapes.data;
curLib.buttons = []; curLib.buttons = Object.entries(data).map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
id = _ref3[0],
pathD = _ref3[1];
for (var id in data) {
var pathD = data[id];
var icon = svgElem.clone(); var icon = svgElem.clone();
icon.find('path').attr('d', pathD); icon.find('path').attr('d', pathD);
var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({ var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
@ -108,22 +145,21 @@ var svgEditorExtension_shapes = (function () {
title: id title: id
}); // Store for later use }); // Store for later use
curLib.buttons.push(iconBtn[0]); return iconBtn[0];
} });
}; };
loadIcons = function _ref2() { loadIcons = function _ref6() {
$('#shape_buttons').empty().append(curLib.buttons); $('#shape_buttons').empty().append(curLib.buttons);
}; };
importLocale = _ref.importLocale; $ = _ref.$, importLocale = _ref.importLocale;
_context.next = 6; _context.next = 6;
return importLocale(); return importLocale();
case 6: case 6:
strings = _context.sent; strings = _context.sent;
svgEditor = this; svgEditor = this;
$ = jQuery;
canv = svgEditor.canvas; canv = svgEditor.canvas;
svgroot = canv.getRootElem(); svgroot = canv.getRootElem();
lastBBox = {}; // This populates the category list lastBBox = {}; // This populates the category list
@ -167,6 +203,11 @@ var svgEditorExtension_shapes = (function () {
modeId = 'shapelib'; modeId = 'shapelib';
startClientPos = {}; startClientPos = {};
curLib = library.basic; curLib = library.basic;
/**
*
* @returns {undefined}
*/
buttons = [{ buttons = [{
id: 'tool_shapelib', id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png', icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
@ -185,7 +226,7 @@ var svgEditorExtension_shapes = (function () {
return Object.assign(buttons[i], button); return Object.assign(buttons[i], button);
}), }),
callback: function callback() { callback: function 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'); $('<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">'); var btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv); $('#tools_shapelib > *').wrapAll(btnDiv);
var shower = $('#tools_shapelib_show'); var shower = $('#tools_shapelib_show');
@ -233,18 +274,20 @@ var svgEditorExtension_shapes = (function () {
}); // Now add shape categories from locale }); // Now add shape categories from locale
var cats = {}; var cats = {};
Object.entries(categories).forEach(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
o = _ref5[0],
categoryName = _ref5[1];
for (var o in categories) { cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
cats['#shape_cats [data-cat="' + o + '"]'] = categories[o]; });
}
this.setStrings('content', cats); this.setStrings('content', cats);
}, },
mouseDown: function mouseDown(opts) { mouseDown: function mouseDown(opts) {
var mode = canv.getMode(); var mode = canv.getMode();
if (mode !== modeId) { if (mode !== modeId) {
return; return undefined;
} }
startX = opts.start_x; startX = opts.start_x;
@ -349,7 +392,7 @@ var svgEditorExtension_shapes = (function () {
var mode = canv.getMode(); var mode = canv.getMode();
if (mode !== modeId) { if (mode !== modeId) {
return; return undefined;
} }
var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y; var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
@ -361,7 +404,7 @@ var svgEditorExtension_shapes = (function () {
} }
}); });
case 19: case 18:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -37,8 +37,6 @@ var svgEditorExtension_star = (function () {
}; };
} }
/* globals jQuery */
/** /**
* ext-star.js * ext-star.js
* *
@ -52,7 +50,7 @@ var svgEditorExtension_star = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) { regeneratorRuntime.mark(function _callee(S) {
var svgEditor, $, svgCanvas, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools; var svgEditor, svgCanvas, $, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -74,14 +72,13 @@ var svgEditorExtension_star = (function () {
}; };
svgEditor = this; svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas; svgCanvas = svgEditor.canvas;
importLocale = S.importLocale; // {svgcontent}, $ = S.$, importLocale = S.importLocale; // {svgcontent},
_context.next = 8; _context.next = 7;
return importLocale(); return importLocale();
case 8: case 7:
strings = _context.sent; strings = _context.sent;
/* /*
@ -175,10 +172,12 @@ var svgEditorExtension_star = (function () {
started: true started: true
}; };
} }
return undefined;
}, },
mouseMove: function mouseMove(opts) { mouseMove: function mouseMove(opts) {
if (!started) { if (!started) {
return; return undefined;
} }
if (svgCanvas.getMode() === 'star') { if (svgCanvas.getMode() === 'star') {
@ -239,6 +238,8 @@ var svgEditorExtension_star = (function () {
started: true started: true
}; };
} }
return undefined;
}, },
mouseUp: function mouseUp() { mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'star') { if (svgCanvas.getMode() === 'star') {
@ -249,6 +250,8 @@ var svgEditorExtension_star = (function () {
element: newFO element: newFO
}; };
} }
return undefined;
}, },
selectedChanged: function selectedChanged(opts) { selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements // Use this to update the current selected elements
@ -275,7 +278,7 @@ var svgEditorExtension_star = (function () {
elementChanged: function elementChanged(opts) {} elementChanged: function elementChanged(opts) {}
}); });
case 12: case 11:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -37,7 +37,43 @@ var svgEditorExtension_storage = (function () {
}; };
} }
/* globals jQuery */ function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
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 _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
/** /**
* ext-storage.js * ext-storage.js
@ -63,9 +99,9 @@ var svgEditorExtension_storage = (function () {
*/ */
var extStorage = { var extStorage = {
name: 'storage', name: 'storage',
init: function init() { init: function init(_ref) {
var $ = _ref.$;
var svgEditor = this; var svgEditor = this;
var $ = jQuery;
var svgCanvas = svgEditor.canvas; // We could empty any already-set data for users when they decline storage, var 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;
@ -78,6 +114,11 @@ var svgEditorExtension_storage = (function () {
forceStorage = _svgEditor$curConfig.forceStorage; forceStorage = _svgEditor$curConfig.forceStorage;
var storage = svgEditor.storage, var storage = svgEditor.storage,
updateCanvas = svgEditor.updateCanvas; updateCanvas = svgEditor.updateCanvas;
/**
* Replace `storagePrompt` parameter within URL.
* @param {string} val
* @returns {undefined}
*/
function replaceStoragePrompt(val) { function replaceStoragePrompt(val) {
val = val ? 'storagePrompt=' + val : ''; val = val ? 'storagePrompt=' + val : '';
@ -91,6 +132,13 @@ var svgEditorExtension_storage = (function () {
loc.href += (loc.href.includes('?') ? '&' : '?') + val; loc.href += (loc.href.includes('?') ? '&' : '?') + val;
} }
} }
/**
* Sets SVG content as a string with "svgedit-" and the current
* canvas name as namespace.
* @param {string} val
* @returns {undefined}
*/
function setSVGContentStorage(val) { function setSVGContentStorage(val) {
if (storage) { if (storage) {
@ -103,29 +151,42 @@ var svgEditorExtension_storage = (function () {
} }
} }
} }
/**
* Set the cookie to expire.
* @param {string} cookie
* @returns {undefined}
*/
function expireCookie(cookie) { function expireCookie(cookie) {
document.cookie = encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT'; document.cookie = encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
} }
/**
* Expire the storage cookie.
* @returns {undefined}
*/
function removeStoragePrefCookie() { function removeStoragePrefCookie() {
expireCookie('store'); expireCookie('svgeditstore');
} }
/**
* Empties storage for each of the current preferences.
* @returns {undefined}
*/
function emptyStorage() { function emptyStorage() {
setSVGContentStorage(''); setSVGContentStorage('');
Object.keys(svgEditor.curPrefs).forEach(function (name) {
name = 'svg-edit-' + name;
for (var name in svgEditor.curPrefs) { if (storage) {
if (svgEditor.curPrefs.hasOwnProperty(name)) { storage.removeItem(name);
name = 'svg-edit-' + name;
if (storage) {
storage.removeItem(name);
}
expireCookie(name);
} }
}
expireCookie(name);
});
} // emptyStorage(); } // emptyStorage();
/** /**
@ -142,11 +203,11 @@ var svgEditorExtension_storage = (function () {
function setupBeforeUnloadListener() { function setupBeforeUnloadListener() {
window.addEventListener('beforeunload', function (e) { window.addEventListener('beforeunload', function (e) {
// Don't save anything unless the user opted in to storage // Don't save anything unless the user opted in to storage
if (!document.cookie.match(/(?:^|;\s*)store=(?:prefsAndContent|prefsOnly)/)) { if (!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)) {
return; return;
} }
if (document.cookie.match(/(?:^|;\s*)store=prefsAndContent/)) { if (document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/)) {
setSVGContentStorage(svgCanvas.getSvgString()); setSVGContentStorage(svgCanvas.getSvgString());
} }
@ -156,28 +217,27 @@ var svgEditorExtension_storage = (function () {
// svgEditor.showSaveWarning = false; // svgEditor.showSaveWarning = false;
var curPrefs = svgEditor.curPrefs; var curPrefs = svgEditor.curPrefs;
Object.entries(curPrefs).forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
key = _ref3[0],
val = _ref3[1];
for (var key in curPrefs) { var store = val !== undefined;
if (curPrefs.hasOwnProperty(key)) { key = 'svg-edit-' + key;
// It's our own config, so we don't need to iterate up the prototype chain
var val = curPrefs[key];
var store = val !== undefined;
key = 'svg-edit-' + key;
if (!store) { if (!store) {
continue; return;
}
if (storage) {
storage.setItem(key, val);
} else if (window.widget) {
window.widget.setPreferenceForKey(val, key);
} else {
val = encodeURIComponent(val);
document.cookie = encodeURIComponent(key) + '=' + val + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
}
} }
}
if (storage) {
storage.setItem(key, val);
} else if (window.widget) {
window.widget.setPreferenceForKey(val, key);
} else {
val = encodeURIComponent(val);
document.cookie = encodeURIComponent(key) + '=' + val + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
}
});
}); });
} }
@ -187,14 +247,14 @@ var svgEditorExtension_storage = (function () {
langReady: function () { langReady: function () {
var _langReady = _asyncToGenerator( var _langReady = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref4) {
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight; var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
importLocale = _ref.importLocale; importLocale = _ref4.importLocale;
_$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt; _$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt;
_context.next = 4; _context.next = 4;
return importLocale(); return importLocale();
@ -217,7 +277,7 @@ var svgEditorExtension_storage = (function () {
// extension! (and to avoid using any prior storage, set the // extension! (and to avoid using any prior storage, set the
// config option "noStorageOnLoad" to true). // config option "noStorageOnLoad" to true).
if (!forceStorage && ( // If the URL has been explicitly set to always prompt the 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 // user (e.g., so one can be pointed to a URL where one
// can alter one's settings, say to prevent future storage)... // can alter one's settings, say to prevent future storage)...
storagePrompt === true || // ...or...if the URL at least doesn't explicitly prevent a storagePrompt === true || // ...or...if the URL at least doesn't explicitly prevent a
@ -225,100 +285,129 @@ var svgEditorExtension_storage = (function () {
// don't want to set cookies at all but who don't want // don't want to set cookies at all but who don't want
// continual prompts about it)... // continual prompts about it)...
storagePrompt !== false && // ...and this user hasn't previously indicated a desire for storage storagePrompt !== false && // ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)store=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt. !document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
)) { ))) {
options = []; _context.next = 44;
break;
}
if (storage) { options = [];
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
if (storage) {
oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height; options.unshift({
$('#dialog_content')[0].style.height = '120px'; value: 'prefsAndContent',
$('#dialog_container')[0].style.height = '170px'; text: storagePrefsAndContent
$('#dialog_container')[0].style.width = '800px'; }, {
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog value: 'prefsOnly',
// From svg-editor.js text: storagePrefsOnly
}, {
$.select(message, options, function (pref, checked) { value: 'noPrefsOrContent',
if (pref && pref !== 'noPrefsOrContent') { text: storageNoPrefsOrContent
// 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 = 'store=' + 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) {
replaceStoragePrompt();
return;
}
} else {
// 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);
}, null, null, {
label: rememberLabel,
checked: true,
tooltip: rememberTooltip
}); });
svgEditor.storagePromptState = 'waiting'; } else {
} else if (!noStorageOnLoad || forceStorage) { options.unshift({
value: 'prefsOnly',
text: storagePrefs
}, {
value: 'noPrefsOrContent',
text: storageNoPrefs
});
} // Hack to temporarily provide a wide and high enough dialog
oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height;
$('#dialog_content')[0].style.height = '120px';
$('#dialog_container')[0].style.height = '170px';
$('#dialog_container')[0].style.width = '800px';
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
// From svg-editor.js
svgEditor.storagePromptState = 'waiting';
_context.next = 20;
return $.select(message, options, null, null, {
label: rememberLabel,
checked: true,
tooltip: rememberTooltip
});
case 20:
_ref5 = _context.sent;
pref = _ref5.response;
checked = _ref5.checked;
if (!(pref && pref !== 'noPrefsOrContent')) {
_context.next = 30;
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(); setupBeforeUnloadListener();
} }
case 10: case 45:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -49,12 +49,12 @@ var svgEditorExtension_webappfind = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) { regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons; var importLocale, $, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
importLocale = _ref.importLocale; importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3; _context.next = 3;
return importLocale(); return importLocale();
@ -73,6 +73,7 @@ var svgEditorExtension_webappfind = (function () {
function (win, _ref2) { function (win, _ref2) {
var data = _ref2.data, var data = _ref2.data,
origin = _ref2.origin; origin = _ref2.origin;
// eslint-disable-line no-shadow
// console.log('data, origin', data, origin); // console.log('data, origin', data, origin);
var type, content; var type, content;
@ -103,7 +104,7 @@ var svgEditorExtension_webappfind = (function () {
break; break;
case 'save-end': case 'save-end':
alert("save complete for pathID ".concat(pathID, "!")); $.alert("save complete for pathID ".concat(pathID, "!"));
break; break;
default: default:

View File

@ -65,7 +65,8 @@ var svgEditorExtension_xdomain_messaging = (function () {
var allowedOrigins = svgEditor.curConfig.allowedOrigins; var allowedOrigins = svgEditor.curConfig.allowedOrigins;
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) { if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin)); console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
return; return;
} }
@ -88,7 +89,7 @@ var svgEditorExtension_xdomain_messaging = (function () {
e.source.postMessage(JSON.stringify(message), '*'); e.source.postMessage(JSON.stringify(message), '*');
}); });
} catch (err) { } catch (err) {
console.log('Error with xdomain message listener: ' + err); console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console
} }
} }
}; };

View File

@ -57,7 +57,9 @@
data = canvas.toDataURL(); data = canvas.toDataURL();
} catch (err) { } catch (err) {
// This fails in Firefox with `file:///` URLs :( // This fails in Firefox with `file:///` URLs :(
alert('Data URL conversion failed: ' + err); // Todo: This could use a generic alert library instead
alert('Data URL conversion failed: ' + err); // eslint-disable-line no-alert
data = ''; data = '';
} }

View File

@ -3004,6 +3004,13 @@
manipulation($$1, jml); manipulation($$1, jml);
var baseAPIURL = 'https://openclipart.org/search/json/'; var baseAPIURL = 'https://openclipart.org/search/json/';
var jsVoid = 'javascript: void(0);'; // eslint-disable-line no-script-url
/**
* Shows results after query submission.
* @param {string} url
* @returns {undefined}
*/
function processResults(_x) { function processResults(_x) {
return _processResults.apply(this, arguments); return _processResults.apply(this, arguments);
@ -3021,7 +3028,7 @@
case 0: case 0:
queryLink = function _ref4(query) { queryLink = function _ref4(query) {
return ['a', { return ['a', {
href: 'javascript: void(0);', href: jsVoid,
dataset: { dataset: {
value: query value: query
}, },
@ -3046,17 +3053,18 @@
case 6: case 6:
json = _context3.sent; json = _context3.sent;
console.log('json', json);
if (!(!json || json.msg !== 'success')) { if (!(!json || json.msg !== 'success')) {
_context3.next = 11; _context3.next = 10;
break; break;
} }
alert('There was a problem downloading the results'); // Todo: This could use a generic alert library instead
alert('There was a problem downloading the results'); // eslint-disable-line no-alert
return _context3.abrupt("return"); return _context3.abrupt("return");
case 11: case 10:
payload = json.payload, _json$info = json.info, numResults = _json$info.results, pages = _json$info.pages, currentPage = _json$info.current_page; // $('#page')[0].value = currentPage; payload = json.payload, _json$info = json.info, numResults = _json$info.results, pages = _json$info.pages, currentPage = _json$info.current_page; // $('#page')[0].value = currentPage;
// $('#page')[0].max = pages; // $('#page')[0].max = pages;
// Unused properties: // Unused properties:
@ -3093,15 +3101,13 @@
var _click = _asyncToGenerator( var _click = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(e) { regeneratorRuntime.mark(function _callee2(e) {
var _this$dataset, svgURL, id, post, result, svg; var svgurl, post, result, svg;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
e.preventDefault(); e.preventDefault();
_this$dataset = this.dataset, svgURL = _this$dataset.value, id = _this$dataset.id; svgurl = this.dataset.value; // console.log('this', id, svgurl);
console.log('this', id, svgURL);
post = function post(message) { post = function post(message) {
// Todo: Make origin customizable as set by opening window // Todo: Make origin customizable as set by opening window
@ -3114,25 +3120,25 @@
post({ post({
name: title, name: title,
id: svgURL id: svgurl
}); });
_context2.next = 7; _context2.next = 6;
return fetch(svgURL); return fetch(svgurl);
case 7: case 6:
result = _context2.sent; result = _context2.sent;
_context2.next = 10; _context2.next = 9;
return result.text(); return result.text();
case 10: case 9:
svg = _context2.sent; svg = _context2.sent;
console.log('h', svgURL, svg); // console.log('url and svg', svgurl, svg);
post({ post({
href: svgURL, href: svgurl,
data: svg data: svg
}); });
case 13: case 11:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }
@ -3151,7 +3157,7 @@
src: svgURL, src: svgURL,
style: "width: ".concat(imgHW, "; height: ").concat(imgHW, ";") style: "width: ".concat(imgHW, "; height: ").concat(imgHW, ";")
}]]], ['b', [title]], ' ', ['i', [description]], ' ', ['span', ['(ID: ', ['a', { }]]], ['b', [title]], ' ', ['i', [description]], ' ', ['span', ['(ID: ', ['a', {
href: 'javascript: void(0);', href: jsVoid,
dataset: { dataset: {
value: id value: id
}, },
@ -3170,7 +3176,7 @@
return ['span', [' ', queryLink(tag)]]; return ['span', [' ', queryLink(tag)]];
})))]; })))];
})), [['br'], ['br'], currentPage === 1 || pages <= 2 ? '' : ['span', [['a', { })), [['br'], ['br'], currentPage === 1 || pages <= 2 ? '' : ['span', [['a', {
href: 'javascript: void(0);', href: jsVoid,
$on: { $on: {
click: function click(e) { click: function click(e) {
e.preventDefault(); e.preventDefault();
@ -3179,7 +3185,7 @@
} }
} }
}, ['First']], ' ']], currentPage === 1 ? '' : ['span', [['a', { }, ['First']], ' ']], currentPage === 1 ? '' : ['span', [['a', {
href: 'javascript: void(0);', href: jsVoid,
$on: { $on: {
click: function click(e) { click: function click(e) {
e.preventDefault(); e.preventDefault();
@ -3188,7 +3194,7 @@
} }
} }
}, ['Prev']], ' ']], currentPage === pages ? '' : ['span', [['a', { }, ['Prev']], ' ']], currentPage === pages ? '' : ['span', [['a', {
href: 'javascript: void(0);', href: jsVoid,
$on: { $on: {
click: function click(e) { click: function click(e) {
e.preventDefault(); e.preventDefault();
@ -3197,7 +3203,7 @@
} }
} }
}, ['Next']], ' ']], currentPage === pages || pages <= 2 ? '' : ['span', [['a', { }, ['Next']], ' ']], currentPage === pages || pages <= 2 ? '' : ['span', [['a', {
href: 'javascript: void(0);', href: jsVoid,
$on: { $on: {
click: function click(e) { click: function click(e) {
e.preventDefault(); e.preventDefault();
@ -3207,7 +3213,7 @@
} }
}, ['Last']], ' ']]])); }, ['Last']], ' ']]]));
case 14: case 13:
case "end": case "end":
return _context3.stop(); return _context3.stop();
} }

7557
dist/index-es.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7557
dist/index-umd.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -237,20 +237,38 @@
var 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})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process: function process(bits) { process: function process(_) {
return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10)]; for (var _len = arguments.length, bits = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
bits[_key - 1] = arguments[_key];
}
return bits.map(function (b) {
return parseInt(b);
});
} }
}, { }, {
re: /^(\w{2})(\w{2})(\w{2})$/, re: /^(\w{2})(\w{2})(\w{2})$/,
example: ['#00ff00', '336699'], example: ['#00ff00', '336699'],
process: function process(bits) { process: function process(_) {
return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16)]; for (var _len2 = arguments.length, bits = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
bits[_key2 - 1] = arguments[_key2];
}
return bits.map(function (b) {
return parseInt(b, 16);
});
} }
}, { }, {
re: /^(\w{1})(\w{1})(\w{1})$/, re: /^(\w{1})(\w{1})(\w{1})$/,
example: ['#fb0', 'f0f'], example: ['#fb0', 'f0f'],
process: function process(bits) { process: function process(_) {
return [parseInt(bits[1] + bits[1], 16), parseInt(bits[2] + bits[2], 16), parseInt(bits[3] + bits[3], 16)]; for (var _len3 = arguments.length, bits = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
bits[_key3 - 1] = arguments[_key3];
}
return bits.map(function (b) {
return parseInt(b + b, 16);
});
} }
}]; }];
/** /**
@ -264,6 +282,8 @@
* @param {string} colorString * @param {string} colorString
*/ */
function RGBColor(colorString) { function RGBColor(colorString) {
var _this = this;
_classCallCheck(this, RGBColor); _classCallCheck(this, RGBColor);
this.ok = false; // strip any leading # this.ok = false; // strip any leading #
@ -283,9 +303,9 @@
// search through the definitions to find a match // search through the definitions to find a match
for (var i = 0; i < colorDefs.length; i++) { colorDefs.forEach(function (_ref) {
var re = colorDefs[i].re; var re = _ref.re,
var processor = colorDefs[i].process; processor = _ref.process;
var bits = re.exec(colorString); var bits = re.exec(colorString);
if (bits) { if (bits) {
@ -295,15 +315,14 @@
g = _processor2[1], g = _processor2[1],
b = _processor2[2]; b = _processor2[2];
Object.assign(this, { Object.assign(_this, {
r: r, r: r,
g: g, g: g,
b: b b: b
}); });
this.ok = true; _this.ok = true;
} }
} // validate/cleanup values }, this); // validate/cleanup values
this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r; this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r;
this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g; this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g;
@ -345,49 +364,36 @@
return '#' + r + g + b; return '#' + r + g + b;
} }
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}, {
key: "getHelpXML",
value: function getHelpXML() {
var examples = []; // add regexps
for (var i = 0; i < colorDefs.length; i++) {
var example = colorDefs[i].example;
for (var j = 0; j < example.length; j++) {
examples[examples.length] = example[j];
}
} // add type-in colors
examples.push.apply(examples, _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
for (var _i = 0; _i < examples.length; _i++) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(examples[_i]);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(examples[_i], " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
xml.append(listItem);
} catch (e) {}
}
return xml;
}
}]); }]);
return RGBColor; return RGBColor;
}(); }();
RGBColor.getHelpXML = function () {
var examples = _toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})).concat(_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 = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").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;
};
var jsPDFAPI = jsPDF.API; var jsPDFAPI = jsPDF.API;
var pdfSvgAttr = { var pdfSvgAttr = {
// allowed attributes. all others are removed from the preview. // allowed attributes. all others are removed from the preview.
@ -437,8 +443,9 @@
} }
if (nums.length < 4) { if (nums.length < 4) {
console.log('invalid points attribute:', node); console.log('invalid points attribute:', node); // eslint-disable-line no-console
return;
return undefined;
} }
var _nums = nums, var _nums = nums,
@ -491,7 +498,7 @@
} }
if (attributeIsNotEmpty(node, 'stroke-width')) { if (attributeIsNotEmpty(node, 'stroke-width')) {
pdf.setLineWidth(k * parseInt(node.getAttribute('stroke-width'), 10)); pdf.setLineWidth(k * parseInt(node.getAttribute('stroke-width')));
} }
var strokeColor = node.getAttribute('stroke'); var strokeColor = node.getAttribute('stroke');
@ -525,142 +532,150 @@
break; break;
case 'line': case 'line':
pdf.line(k * parseInt(node.getAttribute('x1'), 10), k * parseInt(node.getAttribute('y1'), 10), k * parseInt(node.getAttribute('x2'), 10), k * parseInt(node.getAttribute('y2'), 10)); pdf.line(k * parseInt(node.getAttribute('x1')), k * parseInt(node.getAttribute('y1')), k * parseInt(node.getAttribute('x2')), k * parseInt(node.getAttribute('y2')));
removeAttributes(node, pdfSvgAttr.line); removeAttributes(node, pdfSvgAttr.line);
break; break;
case 'rect': case 'rect':
pdf.rect(k * parseInt(node.getAttribute('x'), 10), k * parseInt(node.getAttribute('y'), 10), k * parseInt(node.getAttribute('width'), 10), k * parseInt(node.getAttribute('height'), 10), colorMode); pdf.rect(k * parseInt(node.getAttribute('x')), k * parseInt(node.getAttribute('y')), k * parseInt(node.getAttribute('width')), k * parseInt(node.getAttribute('height')), colorMode);
removeAttributes(node, pdfSvgAttr.rect); removeAttributes(node, pdfSvgAttr.rect);
break; break;
case 'ellipse': case 'ellipse':
pdf.ellipse(k * parseInt(node.getAttribute('cx'), 10), k * parseInt(node.getAttribute('cy'), 10), k * parseInt(node.getAttribute('rx'), 10), k * parseInt(node.getAttribute('ry'), 10), colorMode); pdf.ellipse(k * parseInt(node.getAttribute('cx')), k * parseInt(node.getAttribute('cy')), k * parseInt(node.getAttribute('rx')), k * parseInt(node.getAttribute('ry')), colorMode);
removeAttributes(node, pdfSvgAttr.ellipse); removeAttributes(node, pdfSvgAttr.ellipse);
break; break;
case 'circle': case 'circle':
pdf.circle(k * parseInt(node.getAttribute('cx'), 10), k * parseInt(node.getAttribute('cy'), 10), k * parseInt(node.getAttribute('r'), 10), colorMode); pdf.circle(k * parseInt(node.getAttribute('cx')), k * parseInt(node.getAttribute('cy')), k * parseInt(node.getAttribute('r')), colorMode);
removeAttributes(node, pdfSvgAttr.circle); removeAttributes(node, pdfSvgAttr.circle);
break; break;
case 'polygon': case 'polygon':
case 'polyline': case 'polyline':
var 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
); );
}
removeAttributes(node, pdfSvgAttr.polygon);
break; // TODO: path
} }
removeAttributes(node, pdfSvgAttr.polygon);
break;
// TODO: path
case 'text': case 'text':
if (node.hasAttribute('font-family')) { {
switch ((node.getAttribute('font-family') || '').toLowerCase()) { if (node.hasAttribute('font-family')) {
case 'serif': switch ((node.getAttribute('font-family') || '').toLowerCase()) {
pdf.setFont('times'); case 'serif':
break; pdf.setFont('times');
break;
case 'monospace': case 'monospace':
pdf.setFont('courier'); pdf.setFont('courier');
break; break;
default: default:
node.setAttribute('font-family', 'sans-serif'); node.setAttribute('font-family', 'sans-serif');
pdf.setFont('helvetica'); pdf.setFont('helvetica');
}
} }
}
if (hasFillColor) { if (hasFillColor) {
pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b); pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b);
}
var fontType = '';
if (node.hasAttribute('font-weight')) {
if (node.getAttribute('font-weight') === 'bold') {
fontType = 'bold';
} else {
node.removeAttribute('font-weight');
} }
}
if (node.hasAttribute('font-style')) { var fontType = '';
if (node.getAttribute('font-style') === 'italic') {
fontType += 'italic'; if (node.hasAttribute('font-weight')) {
} else { if (node.getAttribute('font-weight') === 'bold') {
node.removeAttribute('font-style'); fontType = 'bold';
} else {
node.removeAttribute('font-weight');
}
} }
}
pdf.setFontType(fontType); if (node.hasAttribute('font-style')) {
var pdfFontSize = node.hasAttribute('font-size') ? parseInt(node.getAttribute('font-size'), 10) : 16; if (node.getAttribute('font-style') === 'italic') {
fontType += 'italic';
} else {
node.removeAttribute('font-style');
}
}
var getWidth = function getWidth(node) { pdf.setFontType(fontType);
var box; var pdfFontSize = node.hasAttribute('font-size') ? parseInt(node.getAttribute('font-size')) : 16;
/**
*
* @param {Element} elem
* @returns {Float}
*/
try { var getWidth = function getWidth(elem) {
box = node.getBBox(); // Firefox on MacOS will raise error here var box;
} catch (err) {
// copy and append to body so that getBBox is available
var nodeCopy = node.cloneNode(true);
var svg = node.ownerSVGElement.cloneNode(false);
svg.appendChild(nodeCopy);
document.body.appendChild(svg);
try { try {
box = nodeCopy.getBBox(); box = elem.getBBox(); // Firefox on MacOS will raise error here
} catch (err) { } catch (err) {
box = { // copy and append to body so that getBBox is available
width: 0 var nodeCopy = elem.cloneNode(true);
}; var svg = elem.ownerSVGElement.cloneNode(false);
svg.appendChild(nodeCopy);
document.body.appendChild(svg);
try {
box = nodeCopy.getBBox();
} catch (error) {
box = {
width: 0
};
}
document.body.removeChild(svg);
} }
document.body.removeChild(svg); return box.width;
} }; // FIXME: use more accurate positioning!!
return box.width;
}; // FIXME: use more accurate positioning!!
var x, var x,
y, y,
xOffset = 0; xOffset = 0;
if (node.hasAttribute('text-anchor')) { if (node.hasAttribute('text-anchor')) {
switch (node.getAttribute('text-anchor')) { switch (node.getAttribute('text-anchor')) {
case 'end': case 'end':
xOffset = getWidth(node); xOffset = getWidth(node);
break; break;
case 'middle': case 'middle':
xOffset = getWidth(node) / 2; xOffset = getWidth(node) / 2;
break; break;
case 'start': case 'start':
break; break;
case 'default': case 'default':
node.setAttribute('text-anchor', 'start'); node.setAttribute('text-anchor', 'start');
break; break;
} }
x = parseInt(node.getAttribute('x'), 10) - xOffset; x = parseInt(node.getAttribute('x')) - xOffset;
y = parseInt(node.getAttribute('y'), 10); y = parseInt(node.getAttribute('y'));
} // console.log('fontSize:', pdfFontSize, 'text:', node.textContent); } // console.log('fontSize:', pdfFontSize, 'text:', node.textContent);
pdf.setFontSize(pdfFontSize).text(k * x, k * y, node.textContent); pdf.setFontSize(pdfFontSize).text(k * x, k * y, node.textContent);
removeAttributes(node, pdfSvgAttr.text); removeAttributes(node, pdfSvgAttr.text);
break; break; // TODO: image
// TODO: image }
default: default:
if (remove) { if (remove) {
console.log("can't translate to pdf:", node); console.log("can't translate to pdf:", node); // eslint-disable-line no-console
node.remove(); node.remove();
} }

View File

@ -209,7 +209,7 @@ var svgEditorLang_af = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ar = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_az = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_be = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_bg = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ca = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_cs = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_cy = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_da = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_de = (function () {
unsavedChanges: 'Es sind nicht-gespeicherte Änderungen vorhanden.', unsavedChanges: 'Es sind nicht-gespeicherte Änderungen vorhanden.',
enterNewLinkURL: 'Geben Sie die neue URL ein', enterNewLinkURL: 'Geben Sie die neue URL ein',
errorLoadingSVG: 'Fehler: Kann SVG-Daten nicht laden', errorLoadingSVG: 'Fehler: Kann SVG-Daten nicht laden',
URLloadFail: 'Kann von dieser URL nicht laden', URLLoadFail: 'Kann von dieser URL nicht laden',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_el = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_en = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_es = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_et = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_fa = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_fi = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: "Retrieving '%s' ...", retrieving: "Retrieving '%s' ...",
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_fr = (function () {
unsavedChanges: 'Il y a des changements non sauvegardés.', unsavedChanges: 'Il y a des changements non sauvegardés.',
enterNewLinkURL: "Entrez la nouvelle URL de l'hyperlien", enterNewLinkURL: "Entrez la nouvelle URL de l'hyperlien",
errorLoadingSVG: 'Erreur : Impossible de charger les données SVG', errorLoadingSVG: 'Erreur : Impossible de charger les données SVG',
URLloadFail: "Impossible de charger l'URL", URLLoadFail: "Impossible de charger l'URL",
retrieving: 'Récupération de « %s »…', retrieving: 'Récupération de « %s »…',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_fy = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\'...', retrieving: 'Retrieving \'%s\'...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ga = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_gl = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_he = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_hi = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_hr = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_hu = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_hy = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_id = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_is = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_it = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ja = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ko = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_lt = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_lv = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_mk = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ms = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_mt = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_nl = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_no = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -210,7 +210,7 @@ var svgEditorLang_pl = (function () {
unsavedChanges: 'Wykryto niezapisane zmiany.', unsavedChanges: 'Wykryto niezapisane zmiany.',
enterNewLinkURL: 'Wpisz nowy adres URL hiperłącza', enterNewLinkURL: 'Wpisz nowy adres URL hiperłącza',
errorLoadingSVG: 'Błąd: Nie można załadować danych SVG', errorLoadingSVG: 'Błąd: Nie można załadować danych SVG',
URLloadFail: 'Nie można załadować z adresu URL', URLLoadFail: 'Nie można załadować z adresu URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -208,7 +208,7 @@ var svgEditorLang_pt_BR = (function () {
unsavedChanges: 'Existem alterações não salvas.', unsavedChanges: 'Existem alterações não salvas.',
enterNewLinkURL: 'Insira novo URL do hyperlink', enterNewLinkURL: 'Insira novo URL do hyperlink',
errorLoadingSVG: 'Erro: Impossível carregar dados SVG', errorLoadingSVG: 'Erro: Impossível carregar dados SVG',
URLloadFail: 'Impossível carregar deste URL', URLLoadFail: 'Impossível carregar deste URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_pt_PT = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -208,7 +208,7 @@ var svgEditorLang_ro = (function () {
unsavedChanges: 'Sunt schimbări nesalvate.', unsavedChanges: 'Sunt schimbări nesalvate.',
enterNewLinkURL: 'IntroduAliniere în raport cu ...sceţi noul URL', enterNewLinkURL: 'IntroduAliniere în raport cu ...sceţi noul URL',
errorLoadingSVG: 'Eroare: Nu se pot încărca datele SVG', errorLoadingSVG: 'Eroare: Nu se pot încărca datele SVG',
URLloadFail: 'Nu se poate încărca de la URL', URLLoadFail: 'Nu se poate încărca de la URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_ru = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_sk = (function () {
unsavedChanges: 'Sú tu neuložené zmeny.', unsavedChanges: 'Sú tu neuložené zmeny.',
enterNewLinkURL: 'Zadajte nové URL odkazu (hyperlink)', enterNewLinkURL: 'Zadajte nové URL odkazu (hyperlink)',
errorLoadingSVG: 'Chyba: Nedajú sa načítať SVG data', errorLoadingSVG: 'Chyba: Nedajú sa načítať SVG data',
URLloadFail: 'Nemožno čítať z URL', URLLoadFail: 'Nemožno čítať z URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -208,7 +208,7 @@ var svgEditorLang_sl = (function () {
unsavedChanges: 'Obstajajo neshranjene spremembe.', unsavedChanges: 'Obstajajo neshranjene spremembe.',
enterNewLinkURL: 'Vnesite novo URL povezavo', enterNewLinkURL: 'Vnesite novo URL povezavo',
errorLoadingSVG: 'Napaka: Ne morem naložiti SVG podatkov', errorLoadingSVG: 'Napaka: Ne morem naložiti SVG podatkov',
URLloadFail: 'Ne morem naložiti z URL', URLLoadFail: 'Ne morem naložiti z URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_sq = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_sr = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_sv = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_sw = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_test = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_th = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_tl = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_tr = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_uk = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_vi = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_yi = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_zh_CN = (function () {
unsavedChanges: '存在未保存的修改.', unsavedChanges: '存在未保存的修改.',
enterNewLinkURL: '输入新建链接的URL地址', enterNewLinkURL: '输入新建链接的URL地址',
errorLoadingSVG: '错误: 无法加载SVG数据', errorLoadingSVG: '错误: 无法加载SVG数据',
URLloadFail: '无法从URL中加载', URLLoadFail: '无法从URL中加载',
retrieving: '检索 \'%s\'...', retrieving: '检索 \'%s\'...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_zh_HK = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -209,7 +209,7 @@ var svgEditorLang_zh_TW = (function () {
unsavedChanges: 'There are unsaved changes.', unsavedChanges: 'There are unsaved changes.',
enterNewLinkURL: 'Enter the new hyperlink URL', enterNewLinkURL: 'Enter the new hyperlink URL',
errorLoadingSVG: 'Error: Unable to load SVG data', errorLoadingSVG: 'Error: Unable to load SVG data',
URLloadFail: 'Unable to load from URL', URLLoadFail: 'Unable to load from URL',
retrieving: 'Retrieving \'%s\' ...', retrieving: 'Retrieving \'%s\' ...',
popupWindowBlocked: 'Popup window may be blocked by browser', popupWindowBlocked: 'Popup window may be blocked by browser',
exportNoBlur: 'Blurred elements will appear as un-blurred', exportNoBlur: 'Blurred elements will appear as un-blurred',

View File

@ -89,6 +89,11 @@
* including the latest spec changes which were implemented in Firefox 43 and * including the latest spec changes which were implemented in Firefox 43 and
* Chrome 46. * Chrome 46.
*/ */
/* eslint-disable no-shadow, class-methods-use-this */
// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals
// Linting: We avoid `class-methods-use-this` as this is a polyfill that must
// follow the conventions
(function () { (function () {
if (!('SVGPathSeg' in window)) { if (!('SVGPathSeg' in window)) {
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg
@ -1844,7 +1849,7 @@
return []; return [];
} }
var owningPathSegList = this; var owningPathSegList = this; // eslint-disable-line consistent-this
var Builder = var Builder =
/*#__PURE__*/ /*#__PURE__*/
@ -2194,6 +2199,19 @@
return new SVGPathSegClosePath(owningPathSegList); return new SVGPathSegClosePath(owningPathSegList);
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
{
var points = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
{ {
var _points = { var _points = {
x1: this._parseNumber(), x1: this._parseNumber(),
@ -2203,23 +2221,21 @@
x: this._parseNumber(), x: this._parseNumber(),
y: this._parseNumber() y: this._parseNumber()
}; };
return new SVGPathSegCurvetoCubicRel(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2); return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2);
} }
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
{ {
var _points2 = { var _points2 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x2: this._parseNumber(), x2: this._parseNumber(),
y2: this._parseNumber(), y2: this._parseNumber(),
x: this._parseNumber(), x: this._parseNumber(),
y: this._parseNumber() y: this._parseNumber()
}; };
return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points2.x, _points2.y, _points2.x1, _points2.y1, _points2.x2, _points2.y2); return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points2.x, _points2.y, _points2.x2, _points2.y2);
} }
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
{ {
var _points3 = { var _points3 = {
x2: this._parseNumber(), x2: this._parseNumber(),
@ -2227,21 +2243,21 @@
x: this._parseNumber(), x: this._parseNumber(),
y: this._parseNumber() y: this._parseNumber()
}; };
return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2); return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
{
var _points4 = {
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points4.x, _points4.y, _points4.x2, _points4.y2);
} }
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
{
var _points4 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points4.x, _points4.y, _points4.x1, _points4.y1);
}
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
{ {
var _points5 = { var _points5 = {
x1: this._parseNumber(), x1: this._parseNumber(),
@ -2249,18 +2265,9 @@
x: this._parseNumber(), x: this._parseNumber(),
y: this._parseNumber() y: this._parseNumber()
}; };
return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1); return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1);
} }
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
var points = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1);
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber());
@ -2416,7 +2423,7 @@
var $ = jQuery; var $ = jQuery;
var supportsSVG_ = function () { var supportsSVG_ = function () {
return !!document.createElementNS && !!document.createElementNS(NS.SVG, 'svg').createSVGRect; return Boolean(document.createElementNS && document.createElementNS(NS.SVG, 'svg').createSVGRect);
}(); }();
/** /**
* @function module:browser.supportsSvg * @function module:browser.supportsSvg
@ -2431,7 +2438,7 @@
userAgent = _navigator.userAgent; userAgent = _navigator.userAgent;
var svg = document.createElementNS(NS.SVG, 'svg'); // Note: Browser sniffing should only be used if no other detection method is possible var svg = document.createElementNS(NS.SVG, 'svg'); // Note: Browser sniffing should only be used if no other detection method is possible
var isOpera_ = !!window.opera; var isOpera_ = Boolean(window.opera);
var isWebkit_ = userAgent.includes('AppleWebKit'); var isWebkit_ = userAgent.includes('AppleWebKit');
var isGecko_ = userAgent.includes('Gecko/'); var isGecko_ = userAgent.includes('Gecko/');
var isIE_ = userAgent.includes('MSIE'); var isIE_ = userAgent.includes('MSIE');
@ -2440,11 +2447,11 @@
var isMac_ = userAgent.includes('Macintosh'); var isMac_ = userAgent.includes('Macintosh');
var supportsSelectors_ = function () { var supportsSelectors_ = function () {
return !!svg.querySelector; return Boolean(svg.querySelector);
}(); }();
var supportsXpath_ = function () { var supportsXpath_ = function () {
return !!document.evaluate; return Boolean(document.evaluate);
}(); // segList functions (for FF1.5 and 2.0) }(); // segList functions (for FF1.5 and 2.0)

View File

@ -81,7 +81,7 @@ module.exports = {
opts: { opts: {
recurse: true, recurse: true,
verbose: true, verbose: true,
// destination: 'docs/jsdoc', destination: 'docs/jsdoc',
tutorials: 'docs/tutorials' tutorials: 'docs/tutorials'
} }
}; };

51
docs/versions/4.0.0.md Normal file
View File

@ -0,0 +1,51 @@
# Version 4.0.0
This version introduces a number of breaking changes, a number being
required to move to a more Promise-based API and one where problems are
detected early at run-time by throwing rather than logging.
Some API changes also involve switching to class methods over instance
methods, though these were private/internally used APIs.
Please see the CHANGES file (or the Git history or Github tracker) for
fixes and enhancements.
## Breaking changes
- The cookie to track storage preferences is now namespaced as
"svgeditstore" instead of just "store".
- Require `npx` (used with `babel-node`) to allow Node files for HTML
building and JSDoc type checking to be expressed as ESM.
### Breaking changes (public API)
#### Callback-to-Promise changes
- `loadSvgString` now returns a `Promise` rather than accepting a callback.
- Callbacks to `editor.ready` are treated as Promises, only resolving after
all resolve. May require no changes unless for timing.
- `editor.runCallbacks` now returns a `Promise` which resolves upon all
callbacks resolving.
- Removed `svgCanvas.rasterExport` fourth (callback) argument, collapsing
fifth (options) to fourth
- Removed `svgCanvas.exportPDF` third (callback) argument
- Removed `svgCanvas.embedImage` second (callback) argument
- Made `getHelpXML` a class instead of instance method of `RGBColor`.
#### Throwing bad arguments instead of mere logging
- `editor/contextmenu.js` `add` now throws instead
of giving a console error only upon detecting a bad menuitem or
preexisting context menu
- `addExtension` now throws upon a repeated attempt to add an
already-added extension
### Breaking changes (internal API)
- Refactor `dbox` (and
`alert`/`confirm`/`process`/`prompt`/`select`) to avoid a callback argument
in favor of returning a Promise
- `updateGripCursor` moved to be class method
of Selector rather than instance method
- `subpathIsClosed` moved to be class method
of `Path` rather than instance method

View File

@ -1,4 +1,4 @@
/* eslint-disable new-cap */ /* eslint-disable new-cap, class-methods-use-this */
// Todo: Compare with latest canvg (add any improvements of ours) and add full JSDocs (denoting links to standard APIs and which are custom): https://github.com/canvg/canvg // Todo: Compare with latest canvg (add any improvements of ours) and add full JSDocs (denoting links to standard APIs and which are custom): https://github.com/canvg/canvg
/** /**
* canvg.js - Javascript SVG parser and renderer on Canvas * canvg.js - Javascript SVG parser and renderer on Canvas
@ -20,32 +20,11 @@ const isNullish = (val) => {
return val === null || val === undefined; return val === null || val === undefined;
}; };
let canvasRGBA_ = canvasRGBA;
/**
* @callback module:canvg.StackBlurCanvasRGBA
* @param {string} id
* @param {Float} x
* @param {Float} y
* @param {Float} width
* @param {Float} height
* @param {Float} blurRadius
*/
/** /**
* @callback module:canvg.ForceRedraw * @callback module:canvg.ForceRedraw
* @returns {boolean} * @returns {boolean}
*/ */
/**
* @function module:canvg.setStackBlurCanvasRGBA
* @param {module:canvg.StackBlurCanvasRGBA} cb Will be passed the canvas ID, x, y, width, height, blurRadius
* @returns {undefined}
*/
export const setStackBlurCanvasRGBA = (cb) => {
canvasRGBA_ = cb;
};
/** /**
* @typedef {PlainObject} module:canvg.CanvgOptions * @typedef {PlainObject} module:canvg.CanvgOptions
* @property {boolean} opts.ignoreMouse true => ignore mouse events * @property {boolean} opts.ignoreMouse true => ignore mouse events
@ -175,12 +154,13 @@ function build (opts) {
}; };
// ajax // ajax
// Todo: Replace with `fetch` and polyfill
svg.ajax = function (url, asynch) { svg.ajax = function (url, asynch) {
const AJAX = window.XMLHttpRequest const AJAX = window.XMLHttpRequest
? new XMLHttpRequest() ? new XMLHttpRequest()
: new window.ActiveXObject('Microsoft.XMLHTTP'); : new window.ActiveXObject('Microsoft.XMLHTTP');
if (asynch) { if (asynch) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
const req = AJAX.open('GET', url, true); const req = AJAX.open('GET', url, true);
req.addEventListener('load', () => { req.addEventListener('load', () => {
resolve(AJAX.responseText); resolve(AJAX.responseText);
@ -393,12 +373,12 @@ function build (opts) {
Parse (s) { Parse (s) {
const f = {}; const f = {};
const d = svg.trim(svg.compressSpaces(s || '')).split(' '); const ds = svg.trim(svg.compressSpaces(s || '')).split(' ');
const set = { const set = {
fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false
}; };
let ff = ''; let ff = '';
d.forEach((d) => { ds.forEach((d) => {
if (!set.fontStyle && this.Styles.includes(d)) { if (!set.fontStyle && this.Styles.includes(d)) {
if (d !== 'inherit') { if (d !== 'inherit') {
f.fontStyle = d; f.fontStyle = d;
@ -419,8 +399,8 @@ function build (opts) {
f.fontSize = d.split('/')[0]; f.fontSize = d.split('/')[0];
} }
set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true;
} else { } else if (d !== 'inherit') {
if (d !== 'inherit') { ff += d; } ff += d;
} }
}); });
if (ff !== '') { f.fontFamily = ff; } if (ff !== '') { f.fontFamily = ff; }
@ -431,7 +411,7 @@ function build (opts) {
// points and paths // points and paths
svg.ToNumberArray = function (s) { svg.ToNumberArray = function (s) {
const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' '); const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
return a.map((a) => parseFloat(a)); return a.map((_a) => parseFloat(_a));
}; };
svg.Point = class { svg.Point = class {
constructor (x, y) { constructor (x, y) {
@ -598,9 +578,9 @@ function build (opts) {
ctx.translate(-this.cx, -this.cy); ctx.translate(-this.cx, -this.cy);
}; };
this.applyToPoint = function (p) { this.applyToPoint = function (p) {
const a = this.angle.toRadians(); const _a = this.angle.toRadians();
p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]); p.applyTransform([Math.cos(_a), Math.sin(_a), -Math.sin(_a), Math.cos(_a), 0, 0]);
p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]); p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]);
}; };
} }
@ -727,7 +707,8 @@ function build (opts) {
svg.Element.ElementBase = class { svg.Element.ElementBase = class {
constructor (node) { constructor (node) {
this.captureTextNodes = arguments[1]; // Argument from inheriting class // Argument from inheriting class
this.captureTextNodes = arguments[1]; // eslint-disable-line prefer-rest-params
this.attributes = {}; this.attributes = {};
this.styles = {}; this.styles = {};
this.children = []; this.children = [];
@ -757,9 +738,9 @@ function build (opts) {
// add tag styles // add tag styles
let styles = svg.Styles[node.nodeName]; let styles = svg.Styles[node.nodeName];
if (!isNullish(styles)) { if (!isNullish(styles)) {
for (const name in styles) { Object.entries(styles).forEach(([name, styleValue]) => {
this.styles[name] = styles[name]; this.styles[name] = styleValue;
} });
} }
// add class styles // add class styles
@ -768,33 +749,33 @@ function build (opts) {
classes.forEach((clss) => { classes.forEach((clss) => {
styles = svg.Styles['.' + clss]; styles = svg.Styles['.' + clss];
if (!isNullish(styles)) { if (!isNullish(styles)) {
for (const name in styles) { Object.entries(styles).forEach(([name, styleValue]) => {
this.styles[name] = styles[name]; this.styles[name] = styleValue;
} });
} }
styles = svg.Styles[node.nodeName + '.' + clss]; styles = svg.Styles[node.nodeName + '.' + clss];
if (!isNullish(styles)) { if (!isNullish(styles)) {
for (const name in styles) { Object.entries(styles).forEach(([name, styleValue]) => {
this.styles[name] = styles[name]; this.styles[name] = styleValue;
} });
} }
}); });
} }
// add id styles // add id styles
if (this.attribute('id').hasValue()) { if (this.attribute('id').hasValue()) {
const styles = svg.Styles['#' + this.attribute('id').value]; const _styles = svg.Styles['#' + this.attribute('id').value];
if (!isNullish(styles)) { if (!isNullish(_styles)) {
for (const name in styles) { Object.entries(_styles).forEach(([name, styleValue]) => {
this.styles[name] = styles[name]; this.styles[name] = styleValue;
} });
} }
} }
// add inline styles // add inline styles
if (this.attribute('style').hasValue()) { if (this.attribute('style').hasValue()) {
const styles = this.attribute('style').value.split(';'); const _styles = this.attribute('style').value.split(';');
styles.forEach((style) => { _styles.forEach((style) => {
if (svg.trim(style) !== '') { if (svg.trim(style) !== '') {
let {name, value} = style.split(':'); let {name, value} = style.split(':');
name = svg.trim(name); name = svg.trim(name);
@ -1232,9 +1213,9 @@ function build (opts) {
ctx.moveTo(x, y); ctx.moveTo(x, y);
} }
for (let i = 1; i < this.points.length; i++) { for (let i = 1; i < this.points.length; i++) {
const {x, y} = this.points[i]; const {x: _x, y: _y} = this.points[i];
bb.addPoint(x, y); bb.addPoint(_x, _y);
if (!isNullish(ctx)) ctx.lineTo(x, y); if (!isNullish(ctx)) ctx.lineTo(_x, _y);
} }
return bb; return bb;
} }
@ -1410,20 +1391,20 @@ function build (opts) {
pp.nextCommand(); pp.nextCommand();
switch (pp.command) { switch (pp.command) {
case 'M': case 'M':
case 'm': case 'm': {
const p = pp.getAsCurrentPoint(); const p = pp.getAsCurrentPoint();
pp.addMarker(p); pp.addMarker(p);
bb.addPoint(p.x, p.y); bb.addPoint(p.x, p.y);
if (!isNullish(ctx)) ctx.moveTo(p.x, p.y); if (!isNullish(ctx)) ctx.moveTo(p.x, p.y);
pp.start = pp.current; pp.start = pp.current;
while (!pp.isCommandOrEnd()) { while (!pp.isCommandOrEnd()) {
const p = pp.getAsCurrentPoint(); const _p = pp.getAsCurrentPoint();
pp.addMarker(p, pp.start); pp.addMarker(_p, pp.start);
bb.addPoint(p.x, p.y); bb.addPoint(_p.x, _p.y);
if (!isNullish(ctx)) ctx.lineTo(p.x, p.y); if (!isNullish(ctx)) ctx.lineTo(_p.x, _p.y);
} }
break; break;
case 'L': } case 'L':
case 'l': case 'l':
while (!pp.isCommandOrEnd()) { while (!pp.isCommandOrEnd()) {
const c = pp.current; const c = pp.current;
@ -1570,14 +1551,14 @@ function build (opts) {
bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better
if (!isNullish(ctx)) { if (!isNullish(ctx)) {
const r = rx > ry ? rx : ry; const _r = rx > ry ? rx : ry;
const sx = rx > ry ? 1 : rx / ry; const sx = rx > ry ? 1 : rx / ry;
const sy = rx > ry ? ry / rx : 1; const sy = rx > ry ? ry / rx : 1;
ctx.translate(centp.x, centp.y); ctx.translate(centp.x, centp.y);
ctx.rotate(xAxisRotation); ctx.rotate(xAxisRotation);
ctx.scale(sx, sy); ctx.scale(sx, sy);
ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag); ctx.arc(0, 0, _r, a1, a1 + ad, 1 - sweepFlag);
ctx.scale(1 / sx, 1 / sy); ctx.scale(1 / sx, 1 / sy);
ctx.rotate(-xAxisRotation); ctx.rotate(-xAxisRotation);
ctx.translate(-centp.x, -centp.y); ctx.translate(-centp.x, -centp.y);
@ -2115,8 +2096,8 @@ function build (opts) {
child.render(ctx); child.render(ctx);
for (let i = 0; i < child.children.length; i++) { for (let j = 0; j < child.children.length; j++) {
this.renderChild(ctx, child, i); this.renderChild(ctx, child, j);
} }
} }
}; };
@ -2309,9 +2290,12 @@ function build (opts) {
}; };
this.img.src = href; this.img.src = href;
} else { } else {
svg.ajax(href, true).then((img) => { svg.ajax(href, true).then((img) => { // eslint-disable-line promise/prefer-await-to-then, promise/always-return
this.img = img; this.img = img;
this.loaded = true; this.loaded = true;
}).catch((err) => { // eslint-disable-line promise/prefer-await-to-callbacks
this.erred = true;
console.error('Ajax error for canvg', err); // eslint-disable-line no-console
}); });
} }
} }
@ -2448,6 +2432,7 @@ function build (opts) {
getBoundingBox () { getBoundingBox () {
const {_el: element} = this; const {_el: element} = this;
if (!isNullish(element)) return element.getBoundingBox(); if (!isNullish(element)) return element.getBoundingBox();
return undefined;
} }
renderChildren (ctx) { renderChildren (ctx) {
@ -2605,10 +2590,29 @@ function build (opts) {
} }
}; };
/**
* @param {Uint8ClampedArray} img
* @param {Integer} x
* @param {Integer} y
* @param {Float} width
* @param {Float} height
* @param {Integer} rgba
* @returns {undefined}
*/
function imGet (img, x, y, width, height, rgba) { function imGet (img, x, y, width, height, rgba) {
return img[y * width * 4 + x * 4 + rgba]; return img[y * width * 4 + x * 4 + rgba];
} }
/**
* @param {Uint8ClampedArray} img
* @param {Integer} x
* @param {Integer} y
* @param {Float} width
* @param {Float} height
* @param {Integer} rgba
* @param {Float} val
* @returns {undefined}
*/
function imSet (img, x, y, width, height, rgba, val) { function imSet (img, x, y, width, height, rgba, val) {
img[y * width * 4 + x * 4 + rgba] = val; img[y * width * 4 + x * 4 + rgba] = val;
} }
@ -2619,7 +2623,7 @@ function build (opts) {
let matrix = svg.ToNumberArray(this.attribute('values').value); let matrix = svg.ToNumberArray(this.attribute('values').value);
switch (this.attribute('type').valueOrDefault('matrix')) { // https://www.w3.org/TR/SVG/filters.html#feColorMatrixElement switch (this.attribute('type').valueOrDefault('matrix')) { // https://www.w3.org/TR/SVG/filters.html#feColorMatrixElement
case 'saturate': case 'saturate': {
const s = matrix[0]; const s = matrix[0];
matrix = [ matrix = [
0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0, 0, 0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0, 0,
@ -2629,7 +2633,7 @@ function build (opts) {
0, 0, 0, 0, 1 0, 0, 0, 0, 1
]; ];
break; break;
case 'hueRotate': } case 'hueRotate': {
const a = matrix[0] * Math.PI / 180.0; const a = matrix[0] * Math.PI / 180.0;
const c = function (m1, m2, m3) { const c = function (m1, m2, m3) {
return m1 + Math.cos(a) * m2 + Math.sin(a) * m3; return m1 + Math.cos(a) * m2 + Math.sin(a) * m3;
@ -2642,7 +2646,7 @@ function build (opts) {
0, 0, 0, 0, 1 0, 0, 0, 0, 1
]; ];
break; break;
case 'luminanceToAlpha': } case 'luminanceToAlpha':
matrix = [ matrix = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -2663,16 +2667,16 @@ function build (opts) {
const {_m: m} = this; const {_m: m} = this;
// assuming x==0 && y==0 for now // assuming x==0 && y==0 for now
const srcData = ctx.getImageData(0, 0, width, height); const srcData = ctx.getImageData(0, 0, width, height);
for (let y = 0; y < height; y++) { for (let _y = 0; _y < height; _y++) {
for (let x = 0; x < width; x++) { for (let _x = 0; _x < width; _x++) {
const r = imGet(srcData.data, x, y, width, height, 0); const r = imGet(srcData.data, _x, _y, width, height, 0);
const g = imGet(srcData.data, x, y, width, height, 1); const g = imGet(srcData.data, _x, _y, width, height, 1);
const b = imGet(srcData.data, x, y, width, height, 2); const b = imGet(srcData.data, _x, _y, width, height, 2);
const a = imGet(srcData.data, x, y, width, height, 3); const a = imGet(srcData.data, _x, _y, width, height, 3);
imSet(srcData.data, x, y, width, height, 0, m(0, r) + m(1, g) + m(2, b) + m(3, a) + m(4, 1)); imSet(srcData.data, _x, _y, width, height, 0, m(0, r) + m(1, g) + m(2, b) + m(3, a) + m(4, 1));
imSet(srcData.data, x, y, width, height, 1, m(5, r) + m(6, g) + m(7, b) + m(8, a) + m(9, 1)); imSet(srcData.data, _x, _y, width, height, 1, m(5, r) + m(6, g) + m(7, b) + m(8, a) + m(9, 1));
imSet(srcData.data, x, y, width, height, 2, m(10, r) + m(11, g) + m(12, b) + m(13, a) + m(14, 1)); imSet(srcData.data, _x, _y, width, height, 2, m(10, r) + m(11, g) + m(12, b) + m(13, a) + m(14, 1));
imSet(srcData.data, x, y, width, height, 3, m(15, r) + m(16, g) + m(17, b) + m(18, a) + m(19, 1)); imSet(srcData.data, _x, _y, width, height, 3, m(15, r) + m(16, g) + m(17, b) + m(18, a) + m(19, 1));
} }
} }
ctx.clearRect(0, 0, width, height); ctx.clearRect(0, 0, width, height);
@ -2689,17 +2693,12 @@ function build (opts) {
} }
apply (ctx, x, y, width, height) { apply (ctx, x, y, width, height) {
if (typeof canvasRGBA_ !== 'function') {
svg.log('ERROR: The function `setStackBlurCanvasRGBA` must be present for blur to work');
return;
}
// Todo: This might not be a problem anymore with out `instanceof` fix // Todo: This might not be a problem anymore with out `instanceof` fix
// StackBlur requires canvas be on document // StackBlur requires canvas be on document
ctx.canvas.id = svg.UniqueId(); ctx.canvas.id = svg.UniqueId();
ctx.canvas.style.display = 'none'; ctx.canvas.style.display = 'none';
document.body.append(ctx.canvas); document.body.append(ctx.canvas);
canvasRGBA_(ctx.canvas, x, y, width, height, this.blurRadius); canvasRGBA(ctx.canvas, x, y, width, height, this.blurRadius);
ctx.canvas.remove(); ctx.canvas.remove();
} }
}; };
@ -2773,14 +2772,14 @@ function build (opts) {
ctx.canvas.onclick = function (e) { ctx.canvas.onclick = function (e) {
const args = !isNullish(e) const args = !isNullish(e)
? [e.clientX, e.clientY] ? [e.clientX, e.clientY]
: [event.clientX, event.clientY]; : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
const {x, y} = mapXY(new svg.Point(...args)); const {x, y} = mapXY(new svg.Point(...args));
svg.Mouse.onclick(x, y); svg.Mouse.onclick(x, y);
}; };
ctx.canvas.onmousemove = function (e) { ctx.canvas.onmousemove = function (e) {
const args = !isNullish(e) const args = !isNullish(e)
? [e.clientX, e.clientY] ? [e.clientX, e.clientY]
: [event.clientX, event.clientY]; : [event.clientX, event.clientY]; // eslint-disable-line no-restricted-globals
const {x, y} = mapXY(new svg.Point(...args)); const {x, y} = mapXY(new svg.Point(...args));
svg.Mouse.onmousemove(x, y); svg.Mouse.onmousemove(x, y);
}; };
@ -2878,13 +2877,14 @@ function build (opts) {
// need update from mouse events? // need update from mouse events?
if (svg.opts.ignoreMouse !== true) { if (svg.opts.ignoreMouse !== true) {
needUpdate = needUpdate | svg.Mouse.hasEvents(); needUpdate = needUpdate || svg.Mouse.hasEvents();
} }
// need update from animations? // need update from animations?
if (svg.opts.ignoreAnimation !== true) { if (svg.opts.ignoreAnimation !== true) {
svg.Animations.forEach((animation) => { svg.Animations.forEach((animation) => {
needUpdate = needUpdate | animation.update(1000 / svg.FRAMERATE); const needAnimationUpdate = animation.update(1000 / svg.FRAMERATE);
needUpdate = needUpdate || needAnimationUpdate;
}); });
} }
@ -2901,7 +2901,8 @@ function build (opts) {
svg.Mouse.runEvents(); // run and clear our events svg.Mouse.runEvents(); // run and clear our events
} }
}, 1000 / svg.FRAMERATE); }, 1000 / svg.FRAMERATE);
return new Promise((resolve, reject) => { // Todo: Replace with an image loading Promise utility?
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) { if (svg.ImagesLoaded()) {
waitingForImages = false; waitingForImages = false;
draw(resolve); draw(resolve);

View File

@ -156,34 +156,22 @@ const 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})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process (bits) { process (_, ...bits) {
return [ return bits.map((b) => parseInt(b));
parseInt(bits[1]),
parseInt(bits[2]),
parseInt(bits[3])
];
} }
}, },
{ {
re: /^(\w{2})(\w{2})(\w{2})$/, re: /^(\w{2})(\w{2})(\w{2})$/,
example: ['#00ff00', '336699'], example: ['#00ff00', '336699'],
process (bits) { process (_, ...bits) {
return [ return bits.map((b) => parseInt(b, 16));
parseInt(bits[1], 16),
parseInt(bits[2], 16),
parseInt(bits[3], 16)
];
} }
}, },
{ {
re: /^(\w{1})(\w{1})(\w{1})$/, re: /^(\w{1})(\w{1})(\w{1})$/,
example: ['#fb0', 'f0f'], example: ['#fb0', 'f0f'],
process (bits) { process (_, ...bits) {
return [ return bits.map((b) => parseInt(b + b, 16));
parseInt(bits[1] + bits[1], 16),
parseInt(bits[2] + bits[2], 16),
parseInt(bits[3] + bits[3], 16)
];
} }
} }
]; ];
@ -214,16 +202,15 @@ export default class RGBColor {
// end of simple type-in colors // end of simple type-in colors
// search through the definitions to find a match // search through the definitions to find a match
for (let i = 0; i < colorDefs.length; i++) {
const {re} = colorDefs[i]; colorDefs.forEach(({re, process: processor}) => {
const processor = colorDefs[i].process;
const bits = re.exec(colorString); const bits = re.exec(colorString);
if (bits) { if (bits) {
const [r, g, b] = processor(bits); const [r, g, b] = processor(bits);
Object.assign(this, {r, g, b}); Object.assign(this, {r, g, b});
this.ok = true; this.ok = true;
} }
} }, this);
// validate/cleanup values // validate/cleanup values
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r); this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
@ -251,41 +238,42 @@ export default class RGBColor {
if (b.length === 1) { b = '0' + b; } if (b.length === 1) { b = '0' + b; }
return '#' + r + g + b; return '#' + r + g + b;
} }
}
/** /**
* Offers a bulleted list of help. * Offers a bulleted list of help.
* @returns {HTMLUListElement} * @returns {HTMLUListElement}
*/ */
getHelpXML () { RGBColor.getHelpXML = function () {
const examples = []; const examples = [
// add regexps // add regexps
for (let i = 0; i < colorDefs.length; i++) { ...colorDefs.flatMap(({example}) => {
const {example} = colorDefs[i]; return example;
for (let j = 0; j < example.length; j++) { }),
examples[examples.length] = example[j];
}
}
// add type-in colors // add type-in colors
examples.push(...Object.keys(simpleColors)); ...Object.keys(simpleColors)
];
const xml = document.createElement('ul'); const xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples'); xml.setAttribute('id', 'rgbcolor-examples');
for (let i = 0; i < examples.length; i++) {
try { xml.append(...examples.map((example) => {
const listItem = document.createElement('li'); try {
const listColor = new RGBColor(examples[i]); const listItem = document.createElement('li');
const exampleDiv = document.createElement('div'); const listColor = new RGBColor(example);
exampleDiv.style.cssText = ` const exampleDiv = document.createElement('div');
exampleDiv.style.cssText = `
margin: 3px; margin: 3px;
border: 1px solid black; border: 1px solid black;
background: ${listColor.toHex()}; background: ${listColor.toHex()};
color: ${listColor.toHex()};`; color: ${listColor.toHex()};`;
exampleDiv.append('test'); exampleDiv.append('test');
const listItemValue = ` ${examples[i]} -> ${listColor.toRGB()} -> ${listColor.toHex()}`; const listItemValue = ` ${example} -> ${listColor.toRGB()} -> ${listColor.toHex()}`;
listItem.append(exampleDiv, listItemValue); listItem.append(exampleDiv, listItemValue);
xml.append(listItem); return listItem;
} catch (e) {} } catch (e) {
return '';
} }
return xml; }));
} return xml;
} };

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