Merge pull request #6 from SVG-Edit/master

update from original repo
master
JFH 2020-10-25 13:18:40 +01:00 committed by GitHub
commit 53832328a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1453 additions and 862 deletions

View File

@ -66,7 +66,10 @@ module.exports = {
// environments; see also discussion above
// `mocha-cleanup/no-assertions-outside-it`
'jsdoc/check-examples': ['warn', {
rejectExampleCodeRegex: '^`'
rejectExampleCodeRegex: '^`',
checkDefaults: true,
checkParams: true,
checkProperties: true
}],
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 51.09%</text><text class="high" x="5" y="14">Statements 51.09%</text><text class="shadow" x="125.5" y="15">Branches 40.83%</text><text class="high" x="125" y="14">Branches 40.83%</text><text class="shadow" x="234.5" y="15">Lines 51.81%</text><text class="high" x="234" y="14">Lines 51.81%</text><text class="shadow" x="321.5" y="15">Functions 58.54%</text><text class="high" x="321" y="14">Functions 58.54%</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 51.11%</text><text class="high" x="5" y="14">Statements 51.11%</text><text class="shadow" x="125.5" y="15">Branches 40.85%</text><text class="high" x="125" y="14">Branches 40.85%</text><text class="shadow" x="234.5" y="15">Lines 51.82%</text><text class="high" x="234" y="14">Lines 51.82%</text><text class="shadow" x="321.5" y="15">Functions 58.62%</text><text class="high" x="321" y="14">Functions 58.62%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1077" height="116"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="navy" d="M0 0h227v116H0z"/><path fill="green" d="M227 0h265v116H227z"/><path fill="#cc0" d="M492 0h128v116H492z"/><path fill="#a9a9a9" d="M620 0h243v116H620z"/><path fill="#d3d3d3" d="M863 0h214v116H863z"/><path fill="url(#smooth)" d="M0 0h1077v116H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">License types</text><text class="high" x="5" y="14">License types</text><text class="shadow" x="5.5" y="27">(project, deps, and bundled devDeps)</text><text class="high" x="5" y="26">(project, deps, and bundled devDeps)</text><text class="shadow" x="232.5" y="15">Permissive</text><text class="high" x="232" y="14">Permissive</text><text class="shadow" x="232.5" y="39">1. (MIT OR Apache-2.0)</text><text class="high" x="232" y="38">1. (MIT OR Apache-2.0)</text><text class="shadow" x="232.5" y="51">2. (MPL-2.0 OR Apache-2.0)</text><text class="high" x="232" y="50">2. (MPL-2.0 OR Apache-2.0)</text><text class="shadow" x="232.5" y="63">3. Apache-2.0</text><text class="high" x="232" y="62">3. Apache-2.0</text><text class="shadow" x="232.5" y="75">4. ISC</text><text class="high" x="232" y="74">4. ISC</text><text class="shadow" x="232.5" y="87">5. MIT</text><text class="high" x="232" y="86">5. MIT</text><text class="shadow" x="232.5" y="99">6. MIT OR SEE LICENSE IN FEEL-FREE.md</text><text class="high" x="232" y="98">6. MIT OR SEE LICENSE IN FEEL-FREE.md</text><text class="shadow" x="232.5" y="111">7. X11</text><text class="high" x="232" y="110">7. X11</text><text class="shadow" x="497.5" y="15">Weakly</text><text class="high" x="497" y="14">Weakly</text><text class="shadow" x="497.5" y="27">protective</text><text class="high" x="497" y="26">protective</text><text class="shadow" x="497.5" y="51">1. LGPL-3.0-or-later</text><text class="high" x="497" y="50">1. LGPL-3.0-or-later</text><text class="shadow" x="625.5" y="15">Uncategorized</text><text class="high" x="625" y="14">Uncategorized</text><text class="shadow" x="625.5" y="39">1. Chromium&apos;s License (pathseg (1.2.0))</text><text class="high" x="625" y="38">1. Chromium&apos;s License (pathseg (1.2.0))</text><text class="shadow" x="868.5" y="15">Missing</text><text class="high" x="868" y="14">Missing</text><text class="shadow" x="868.5" y="39">1. null (base64-arraybuffer (0.2.0))</text><text class="high" x="868" y="38">1. null (base64-arraybuffer (0.2.0))</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="863" height="116"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="navy" d="M0 0h227v116H0z"/><path fill="green" d="M227 0h265v116H227z"/><path fill="#cc0" d="M492 0h128v116H492z"/><path fill="#a9a9a9" d="M620 0h243v116H620z"/><path fill="url(#smooth)" d="M0 0h863v116H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">License types</text><text class="high" x="5" y="14">License types</text><text class="shadow" x="5.5" y="27">(project, deps, and bundled devDeps)</text><text class="high" x="5" y="26">(project, deps, and bundled devDeps)</text><text class="shadow" x="232.5" y="15">Permissive</text><text class="high" x="232" y="14">Permissive</text><text class="shadow" x="232.5" y="39">1. (MIT OR Apache-2.0)</text><text class="high" x="232" y="38">1. (MIT OR Apache-2.0)</text><text class="shadow" x="232.5" y="51">2. (MPL-2.0 OR Apache-2.0)</text><text class="high" x="232" y="50">2. (MPL-2.0 OR Apache-2.0)</text><text class="shadow" x="232.5" y="63">3. Apache-2.0</text><text class="high" x="232" y="62">3. Apache-2.0</text><text class="shadow" x="232.5" y="75">4. ISC</text><text class="high" x="232" y="74">4. ISC</text><text class="shadow" x="232.5" y="87">5. MIT</text><text class="high" x="232" y="86">5. MIT</text><text class="shadow" x="232.5" y="99">6. MIT OR SEE LICENSE IN FEEL-FREE.md</text><text class="high" x="232" y="98">6. MIT OR SEE LICENSE IN FEEL-FREE.md</text><text class="shadow" x="232.5" y="111">7. X11</text><text class="high" x="232" y="110">7. X11</text><text class="shadow" x="497.5" y="15">Weakly</text><text class="high" x="497" y="14">Weakly</text><text class="shadow" x="497.5" y="27">protective</text><text class="high" x="497" y="26">protective</text><text class="shadow" x="497.5" y="51">1. LGPL-3.0-or-later</text><text class="high" x="497" y="50">1. LGPL-3.0-or-later</text><text class="shadow" x="625.5" y="15">Uncategorized</text><text class="high" x="625" y="14">Uncategorized</text><text class="shadow" x="625.5" y="39">1. Chromium&apos;s License (pathseg (1.2.0))</text><text class="high" x="625" y="38">1. Chromium&apos;s License (pathseg (1.2.0))</text></g></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -10,8 +10,8 @@ exports[`use various parts of svg-edit > check tool_source #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -21,7 +21,6 @@ exports[`use various parts of svg-edit > check tool_source #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
></rect>
</g>
</svg>
@ -70,8 +69,8 @@ exports[`use various parts of svg-edit > check tool_text #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -81,7 +80,6 @@ exports[`use various parts of svg-edit > check tool_text #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
fill-opacity="1"
stroke-opacity="1"
></rect>
@ -89,7 +87,6 @@ exports[`use various parts of svg-edit > check tool_text #0`] = `
fill="#000000"
stroke="#000000"
stroke-width="0"
style="pointer-events: inherit; cursor: text;"
x="116"
y="87"
id="svg_1"
@ -118,8 +115,8 @@ exports[`use various parts of svg-edit > check tool_clone #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -129,7 +126,6 @@ exports[`use various parts of svg-edit > check tool_clone #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
fill-opacity="1"
stroke-opacity="1"
></rect>
@ -181,8 +177,8 @@ exports[`use various parts of svg-edit > check tool_italic #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -192,7 +188,6 @@ exports[`use various parts of svg-edit > check tool_italic #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
fill-opacity="1"
stroke-opacity="1"
></rect>
@ -209,7 +204,7 @@ exports[`use various parts of svg-edit > check tool_italic #0`] = `
xml:space="preserve"
fill-opacity="1"
stroke-opacity="1"
font-style="italic"
font-=""
>
B
</text>
@ -245,8 +240,8 @@ exports[`use various parts of svg-edit > check tool_bold #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -256,7 +251,6 @@ exports[`use various parts of svg-edit > check tool_bold #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
fill-opacity="1"
stroke-opacity="1"
></rect>
@ -273,7 +267,7 @@ exports[`use various parts of svg-edit > check tool_bold #0`] = `
xml:space="preserve"
fill-opacity="1"
stroke-opacity="1"
font-style="italic"
font-=""
font-weight="bold"
>
B
@ -310,8 +304,8 @@ exports[`use various parts of svg-edit > check change color #0`] = `
y="480"
viewBox="0 0 640 480"
>
<g class="layer" style="pointer-events:all">
<title style="pointer-events:inherit">Layer 1</title>
<g class="layer">
<title>Layer 1</title>
<rect
id="rect"
fill="#FF0000"
@ -321,7 +315,6 @@ exports[`use various parts of svg-edit > check change color #0`] = `
width="94"
x="69.5"
y="51.5"
style="pointer-events:inherit"
fill-opacity="1"
stroke-opacity="1"
></rect>
@ -338,7 +331,7 @@ exports[`use various parts of svg-edit > check change color #0`] = `
xml:space="preserve"
fill-opacity="1"
stroke-opacity="1"
font-style="italic"
font-=""
font-weight="bold"
>
B

View File

@ -3,10 +3,7 @@ import {
} from '../../support/ui-test-helper.js';
const testSnapshot = () => {
// cy.get('#tool_source').click({force: true});
// cy.get('#svg_source_textarea').invoke('val').toMatchSnapshot();
// cy.get('#tool_source_save').click({force: true});
cy.get('#svgcontent').toMatchSnapshot();
cy.get('#svgcontent').cleanSnapshot();
};
describe('use various parts of svg-edit', function () {

View File

@ -8,9 +8,11 @@ describe('UI - Tool selection', function () {
});
it('should set rectangle selection by click', function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.get('#tools_rect_show')
.trigger('mousedown', {force: true})
.trigger('mouseup', {force: true, timeout: 10000})
.wait(100) // this delay seems necessary
.trigger('mouseup', {force: true})
.should((button) => {
expect(button).to.have.class('tool_button_current');
});

View File

@ -4,8 +4,6 @@ import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js';
import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js';
// import '../../../instrumented/'
describe('Basic Module', function () {
// helper functions
/*

View File

@ -23,3 +23,26 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// remove the style attributes that is causing differences in snapshots
const ngAttributes = ['style'];
Cypress.Commands.add(
'cleanSnapshot',
{
prevSubject: true
},
(subject, snapshotOptions) => {
let html = subject[0].outerHTML;
for (const attribute of ngAttributes) {
const expression = new RegExp(`${attribute}[^= ]*="[^"]*"`, 'g');
html = html.replace(expression, '');
}
html = html.replace(/<!--[\s\S]*?-->/g, '');
const sanitisedBody = new DOMParser().parseFromString(html, 'text/html').querySelector('body');
return cy.wrap(sanitisedBody.firstChild).toMatchSnapshot();
}
);

30
dist/editor/index.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

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

File diff suppressed because one or more lines are too long

2031
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@
"open-cov": "run-p start open-cov-no-start",
"report": "run-s report-no-mochawesome mochawesome-cli",
"report-summary": "run-s report-text-summary mochawesome-cli-dot",
"license-badge": "license-badger --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
"license-badge": "license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
"license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg",
"license-badges": "run-s license-badge license-badge-dev",
"coverage-badge": "coveradge badges/coverage-badge",
@ -134,7 +134,7 @@
"not ios_saf < 10"
],
"dependencies": {
"@babel/polyfill": "^7.11.5",
"@babel/polyfill": "^7.12.1",
"canvg": "^3.0.6",
"core-js": "^3.6.5",
"jspdf": "^2.1.1",
@ -143,12 +143,12 @@
"svg2pdf.js": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@babel/register": "^7.11.5",
"@babel/runtime-corejs3": "^7.11.2",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/register": "^7.12.1",
"@babel/runtime-corejs3": "^7.12.1",
"@cypress/code-coverage": "^3.8.1",
"@cypress/fiddle": "^1.18.2",
"@cypress/fiddle": "^1.18.3",
"@fintechstudios/eslint-plugin-chai-as-promised": "^3.0.2",
"@hkdobrev/run-if-changed": "^0.3.1",
"@mysticatea/eslint-plugin": "^13.0.0",
@ -164,15 +164,15 @@
"coveradge": "^0.6.0",
"cp-cli": "^2.0.0",
"cross-var": "^1.1.0",
"cypress": "^5.3.0",
"cypress": "^5.4.0",
"cypress-axe": "^0.8.1",
"cypress-multi-reporters": "^1.4.0",
"cypress-plugin-snapshots": "^1.4.4",
"deparam": "git+https://github.com/brettz9/deparam.git#updates",
"es-dev-commonjs-transformer": "^0.2.0",
"es-dev-server": "^1.57.7",
"es-dev-server": "^1.57.8",
"es-dev-server-rollup": "0.0.8",
"eslint": "^7.10.0",
"eslint": "^7.11.0",
"eslint-config-ash-nazg": "^22.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-array-func": "^3.1.7",
@ -184,7 +184,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^6.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.6.3",
"eslint-plugin-jsdoc": "^30.7.3",
"eslint-plugin-markdown": "^1.0.2",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-mocha-cleanup": "^1.8.0",
@ -200,8 +200,8 @@
"jamilih": "^0.53.2",
"jsdoc": "^3.6.6",
"license-badger": "^0.18.0",
"lint-staged": "^10.4.0",
"mocha": "^8.1.3",
"lint-staged": "^10.4.1",
"mocha": "^8.2.0",
"mocha-badge-generator": "^0.8.0",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.2.0",
@ -213,11 +213,11 @@
"promise-fs": "^2.1.1",
"qr-manipulation": "git+https://github.com/brettz9/qr-manipulation.git",
"query-result": "git+https://github.com/WebReflection/query-result.git",
"remark-cli": "^8.0.1",
"remark-cli": "^9.0.0",
"remark-lint-ordered-list-marker-value": "^2.0.1",
"requirejs": "^2.3.6",
"rimraf": "^3.0.2",
"rollup": "2.28.2",
"rollup": "2.32.0",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-node-polyfills": "^0.2.1",
@ -225,7 +225,7 @@
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^7.0.2",
"stackblur-canvas": "^2.4.0",
"systemjs": "^6.6.1",
"systemjs": "^6.7.1",
"typescript": "^4.0.3",
"underscore": "^1.11.0"
}

View File

@ -53,7 +53,7 @@ export default {
/**
*
* @param {string} [filename='image']
* @param {string} [filename="image"]
* @param {string} suffix To add to file name
* @param {string} uri
* @returns {boolean}

View File

@ -244,9 +244,9 @@ export default function jQueryPluginJGraduate ($) {
* @typedef {PlainObject} module:jGraduate.Options
* @property {module:jGraduate~Paint} [paint] A Paint object object describing the paint to display initially; defaults to a new instance without options (defaults to opaque white)
* @property {external:Window} [window]
* @property {string} [window.pickerTitle='Drag markers to pick a paint']
* @property {string} [window.pickerTitle="Drag markers to pick a paint"]
* @property {PlainObject} [images]
* @property {string} [images.clientPath='images/']
* @property {string} [images.clientPath="images/"]
* @property {"same"|"inverse"|"black"|"white"|module:jGraduate.ColorOpac} [newstop="inverse"]
*/

View File

@ -91,7 +91,7 @@ const callbacks = [],
* Preferences.
* @interface module:SVGEditor.Prefs
* @property {string} [lang="en"] Two-letter language code. The language must exist in the Editor Preferences language list. Defaults to "en" if `locale.js` detection does not detect another language.
* @property {module:SVGEditor.IconSize} [iconsize="s"|"m"] Size of the toolbar icons. Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise.
* @property {module:SVGEditor.IconSize} [iconsize="s" || "m"] Size of the toolbar icons. Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise.
* @property {string} [bkgd_color="#FFF"] Color hex for canvas background color. Defaults to white.
* @property {string} [bkgd_url=""] Background raster image URL. This image will fill the background of the document; useful for tracing purposes.
* @property {"embed"|"ref"} [img_save="embed"] Defines whether included raster images should be saved as Data URIs when possible, or as URL references. Settable in the Document Properties dialog.
@ -167,7 +167,7 @@ const callbacks = [],
* @property {boolean} [avoidClientSide=false] DEPRECATED (use `avoidClientSideDownload` instead); Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking
* @property {boolean} [avoidClientSideDownload=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking
* @property {boolean} [avoidClientSideOpen=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always open from the server and not only as fallback when FileReader client support is lacking
* @property {string[]} [extensions=module:SVGEditor~defaultExtensions] Extensions to load on startup. Use an array in `setConfig` and comma separated file names in the URL. Extension names must begin with "ext-". Note that as of version 2.7, paths containing "/", "\", or ":", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included.
* @property {string[]} [extensions=[]] Extensions to load on startup. Use an array in `setConfig` and comma separated file names in the URL. Extension names must begin with "ext-". Note that as of version 2.7, paths containing "/", "\", or ":", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included. See {@link module:SVGEditor~defaultExtensions}.
* @property {string[]} [allowedOrigins=[]] Used by `ext-xdomain-messaging.js` to indicate which origins are permitted for cross-domain messaging (e.g., between the embedded editor and main editor code). Besides explicit domains, one might add '*' to allow all domains (not recommended for privacy/data integrity of your user's content!), `window.location.origin` for allowing the same origin (should be safe if you trust all apps on your domain), 'null' to allow `file:///` URL usage
* @property {null|PlainObject} [colorPickerCSS=null] Object of CSS properties mapped to values (for jQuery) to apply to the color picker. See {@link http://api.jquery.com/css/#css-properties}. A `null` value (the default) will cause the CSS to default to `left` with a position equal to that of the `fill_color` or `stroke_color` element minus 140, and a `bottom` equal to 40
* @property {string} [paramurl] This was available via URL only. Allowed an un-encoded URL within the query string (use "url" or "source" with a data: URI instead)
@ -301,22 +301,14 @@ let svgCanvas, urldata = {},
* @param {PlainObject} [opts={}]
* @param {boolean} [opts.noAlert]
* @throws {Error} Upon failure to load SVG
* @returns {Promise<void>} Resolves to undefined upon success (or if `noAlert` is
* falsey, though only until after the `alert` is closed); rejects if SVG
* loading fails and `noAlert` is truthy.
*/
async function loadSvgString (str, {noAlert} = {}) {
const loadSvgString = (str, {noAlert} = {}) => {
const success = svgCanvas.setSvgString(str) !== false;
if (success) {
return;
}
if (!noAlert) {
await $.alert(uiStrings.notification.errorLoadingSVG);
return;
}
if (success) return;
// eslint-disable-next-line no-alert
if (!noAlert) window.alert(uiStrings.notification.errorLoadingSVG);
throw new Error('Error loading SVG');
}
};
/**
* EXPORTS.
@ -593,7 +585,7 @@ editor.setCustomHandlers = function (opts) {
* @param {boolean} arg
* @returns {void}
*/
editor.randomizeIds = function (arg) {
editor.randomizeIds = (arg) => {
svgCanvas.randomizeIds(arg);
};
@ -602,7 +594,7 @@ editor.randomizeIds = function (arg) {
* @function module:SVGEditor.init
* @returns {void}
*/
editor.init = function () {
editor.init = () => {
// const host = location.hostname,
// onWeb = host && host.includes('.');
// Some FF versions throw security errors here when directly accessing
@ -621,18 +613,15 @@ editor.init = function () {
}
} catch (err) {}
// Todo: Avoid const-defined functions and group functions together, etc. where possible
const goodLangs = [];
$('#lang_select option').each(function () {
goodLangs.push(this.value);
});
// get list of languages from options in the HTML
const goodLangs = [...document.querySelectorAll('#lang_select option')].map((option) => option.value);
/**
* Sets up current preferences based on defaults.
* @returns {void}
*/
function setupCurPrefs () {
curPrefs = $.extend(true, {}, defaultPrefs, curPrefs); // Now safe to merge with priority for curPrefs in the event any are already set
curPrefs = {...defaultPrefs, ...curPrefs}; // Now safe to merge with priority for curPrefs in the event any are already set
// Export updated prefs
editor.curPrefs = curPrefs;
}
@ -642,7 +631,7 @@ editor.init = function () {
* @returns {void}
*/
function setupCurConfig () {
curConfig = $.extend(true, {}, defaultConfig, curConfig); // Now safe to merge with priority for curConfig in the event any are already set
curConfig = {...defaultConfig, ...curConfig}; // Now safe to merge with priority for curConfig in the event any are already set
// Now deal with extensions and other array config
if (!curConfig.noDefaultExtensions) {
@ -1697,7 +1686,7 @@ editor.init = function () {
/**
* @param {PlainObject} [opts={}]
* @param {boolean} [opts.cancelDeletes=false}]
* @param {boolean} [opts.cancelDeletes=false]
* @returns {Promise<void>} Resolves to `undefined`
*/
async function promptImgURL ({cancelDeletes = false} = {}) {
@ -5677,19 +5666,20 @@ editor.init = function () {
// Select given tool
editor.ready(function () {
let tool;
const itool = curConfig.initTool,
container = $('#tools_left, #svg_editor .tools_flyout'),
preTool = container.find('#tool_' + itool),
regTool = container.find('#' + itool);
if (preTool.length) {
tool = preTool;
} else if (regTool.length) {
tool = regTool;
const preTool = document.getElementById(`tool_${curConfig.initTool}`);
const regTool = document.getElementById(curConfig.initTool);
const selectTool = document.getElementById('tool_select');
const mouseupEvent = new Event('mouseup');
if (preTool) {
preTool.click();
preTool.dispatchEvent(mouseupEvent);
} else if (regTool) {
regTool.click();
regTool.dispatchEvent(mouseupEvent);
} else {
tool = $('#tool_select');
selectTool.click();
selectTool.dispatchEvent(mouseupEvent);
}
tool.click().mouseup();
if (curConfig.wireframe) {
$('#tool_wireframe').click();
@ -6222,11 +6212,11 @@ editor.loadFromURL = function (url, {cache, noAlert} = {}) {
$.process_cancel(uiStrings.notification.loadingImage);
},
success (str) {
resolve(loadSvgString(str, {noAlert}));
loadSvgString(str, {noAlert});
},
error (xhr, stat, err) {
if (xhr.status !== 404 && xhr.responseText) {
resolve(loadSvgString(xhr.responseText, {noAlert}));
loadSvgString(xhr.responseText, {noAlert});
return;
}
if (noAlert) {

View File

@ -165,7 +165,7 @@ export default function jQueryPluginDBox ($, {
};
/**
* @param {string} msg Message to accompany the prompt
* @param {string} [defaultText=''] The default text to show for the prompt
* @param {string} [defaultText=""] The default text to show for the prompt
* @returns {jQueryPluginDBox.ResultPromise}
*/
$.prompt = function (msg, defaultText = '') {