Merge pull request #426 from SVG-Edit/refactor-folders

Refactor folders
master
JFH 2020-08-04 19:59:21 +02:00 committed by GitHub
commit 2c70c408fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
503 changed files with 17087 additions and 14389 deletions

View File

@ -5,30 +5,32 @@ coverage
instrumented
dist
docs/jsdoc
archive
svgedit-config-es.js
svgedit-config-iife.js
src/svgedit-config-es.js
src/svgedit-config-iife.js
svgedit-custom.css
editor/xdomain-svgedit-config-iife.js
src/xdomain-svgedit-config-iife.js
# Vendor/minified files
editor/jquery.min.js
editor/jquery-ui
src/editor/jquery.min.js
src/editor/jquery-ui
# Previously minified though exporting
editor/js-hotkeys
src/editor/js-hotkeys
editor/jspdf/jspdf.min.js
editor/jspdf/underscore-min.js
src/editor/jspdf/jspdf.min.js
src/editor/jspdf/underscore-min.js
editor/extensions/mathjax
src/editor/extensions/mathjax
# Todo: We should at least check `compat/compat` in our other files, however
editor/external/*
!editor/external/dom-polyfill
editor/external/dom-polyfill/*
!editor/external/dom-polyfill/dom-polyfill.js
!editor/external/dynamic-import-polyfill
## Two "external" items are modified locally, so we undo their ignoring
src/external/*
!src/external/dom-polyfill
src/external/dom-polyfill/*
!src/external/dom-polyfill/dom-polyfill.js
!src/external/dynamic-import-polyfill
mochawesome-report
releases

View File

@ -3,49 +3,149 @@
module.exports = {
extends: ['ash-nazg/sauron-node'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
env: {
browser: true
browser: true,
es6: true
},
settings: {
polyfills: [
],
jsdoc: {
additionalTagNames: {
// In case we need to extend
customTags: []
},
augmentsExtendsReplacesDocs: true
// Todo: Figure out why this is not working and why seem to have to
// disable for all Markdown:
/*
baseConfig: {
rules: {
'no-multi-spaces': 'off'
// These are the primary polyfills needed by regular users if
// not present, e.g., with core-js-bundle; also those under
// extensions
// 'Array.isArray',
// 'Blob',
// 'console',
// 'CustomEvent',
// 'document.body',
// 'document.createElementNS',
// 'document.evaluate',
// 'document.head',
// 'document.importNode',
// 'document.querySelector',
// 'document.querySelectorAll',
// 'DOMParser',
// 'Error',
'fetch',
// 'FileReader',
// 'JSON',
// 'KeyboardEvent',
// 'location.href',
// 'location.origin',
// 'MouseEvent',
// 'MutationObserver',
// 'navigator',
// 'Number.isNaN',
// 'Number.parseFloat',
// 'Number.parseInt',
// 'Object.assign',
// 'Object.defineProperty',
// 'Object.defineProperties',
// 'Object.entries',
// 'Object.getOwnPropertyDescriptor',
// 'Object.keys',
// 'Object.values',
'Promise',
'Promise.all',
// 'Set',
'Uint8Array',
'URL'
// 'URL.createObjectURL',
// 'XMLSerializer',
// 'XMLHttpRequest',
// 'window.getComputedStyle',
// 'window.parent',
// 'window.scrollX',
// 'window.scrollY'
]
},
rules: {
// check-examples is not picking up eslint config properly in some
// environments; see also discussion above
// `mocha-cleanup/no-assertions-outside-it`
'jsdoc/check-examples': ['warn', {
rejectExampleCodeRegex: '^`'
}],
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453
'unicorn/regex-shorthand': 0,
// The Babel transform seems to have a problem converting these
'prefer-named-capture-group': 'off',
'jsdoc/require-file-overview': ['error', {
tags: {
file: {
initialCommentsOnly: true,
preventDuplicates: true
},
license: {
initialCommentsOnly: true,
preventDuplicates: true
},
copyright: {
initialCommentsOnly: true,
preventDuplicates: true
},
author: {
initialCommentsOnly: true,
preventDuplicates: true
},
module: {
initialCommentsOnly: true,
preventDuplicates: true
},
exports: {
initialCommentsOnly: true,
preventDuplicates: true
}
}
*/
}
}],
// Warning or Off for now but should be reviewed
// Override these rules which are difficult for us
// to apply at this time
'unicorn/prefer-string-slice': 'off',
'default-case': 'off',
'require-unicode-regexp': 'off',
'max-len':
[
'warn',
{ignoreComments: true, code: 130}
], // 130 is too much but too many occurences
'unicorn/prefer-query-selector': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/prefer-node-append': 'off',
'unicorn/no-zero-fractions': 'off',
'unicorn/prefer-number-properties': 'off',
'eslint-comments/require-description': 'off',
'compat/compat': 'error',
'consistent-this': 'off',
'import/no-anonymous-default-export': 'off',
'node/no-unsupported-features/node-builtins': 'warn',
'prefer-exponentiation-operator': 'warn'
},
overrides: [
// Locales have no need for importing outside of SVG-Edit
// and translations may need a longer line length
{
files: [
'editor/locale/lang.*.js', 'editor/extensions/ext-locale/**',
'src/editor/locale/lang.*.js', 'src/editor/extensions/ext-locale/**',
'docs/tutorials/ExtensionDocs.md'
],
rules: {
'import/no-anonymous-default-export': ['off']
'import/no-anonymous-default-export': 'off',
'max-len': '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',
'src/editor/svgpathseg.js',
'src/editor/touch.js',
'src/editor/typedefs.js',
'src/editor/redirect-on-no-module-support.js',
'src/editor/extensions/imagelib/index.js',
'src/external/dom-polyfill/dom-polyfill.js',
'screencasts/svgopen2010/script.js'
],
rules: {
@ -97,7 +197,6 @@ module.exports = {
// Used in examples of assert-close.js plugin
'mocha-cleanup/no-assertions-outside-it': 'off',
'eslint-comments/no-unused-disable': 'warn',
'eol-last': ['off'],
'no-console': ['off'],
'no-undef': ['off'],
@ -116,118 +215,6 @@ module.exports = {
indent: 'off'
}
},
// Dis-apply Node rules mistakenly giving errors with browser files,
// and treating Node global `root` as being present for shadowing
{
files: ['editor/**'],
globals: {
root: 'off'
},
settings: {
polyfills: [
// These are the primary polyfills needed by regular users if
// not present, e.g., with core-js-bundle; also those under
// extensions
'Array.isArray',
'Blob',
'console',
'CustomEvent',
'document.body',
'document.createElementNS',
'document.evaluate',
'document.head',
'document.importNode',
'document.querySelector',
'document.querySelectorAll',
'DOMParser',
'Error',
'FileReader',
'JSON',
'KeyboardEvent',
'location.href',
'location.origin',
'MouseEvent',
'MutationObserver',
'navigator',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'Object.assign',
'Object.defineProperty',
'Object.defineProperties',
'Object.entries',
'Object.getOwnPropertyDescriptor',
'Object.keys',
'Object.values',
'Promise',
'Promise.all',
'Set',
'Uint8Array',
'URL',
'URL.createObjectURL',
'XMLSerializer',
'XMLHttpRequest',
'window.getComputedStyle',
'window.parent',
'window.scrollX',
'window.scrollY'
]
},
rules: {
// Should probably add this rule to ash-nazg as facilitates tree-shaking
'import/no-namespace': ['error'],
'node/no-unsupported-features/node-builtins': 'off'
}
},
// For extensions, `this` is generally assigned to be the more
// descriptive `svgEditor`; they also have no need for importing outside
// of SVG-Edit
{
files: ['editor/extensions/**'],
settings: {
polyfills: [
'console',
'fetch',
'location.origin',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'window.postMessage'
]
},
rules: {
'consistent-this': ['error', 'svgEditor'],
'import/no-anonymous-default-export': ['off']
}
},
{
// Node files
files: [
'docs/jsdoc-config.js',
'build/build-html.js',
'rollup.config.js', 'rollup-config.config.js'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Promise.resolve'
]
},
globals: {
require: true
},
rules: {
// We can't put Rollup in npmignore or user can't get access,
// and we have too many modules to add to `peerDependencies`
// so this rule can know them to be available, so we instead
// disable
'node/no-unpublished-import': 'off'
}
},
{
// As consumed by jsdoc, cannot be expressed as ESM
files: ['docs/jsdoc-config.js'],
@ -242,18 +229,6 @@ module.exports = {
strict: 'off'
}
},
{
// Should probably have as external, but should still check
files: ['canvg/rgbcolor.js'],
settings: {
polyfills: [
'Number.isNaN',
'Number.parseInt',
'Object.assign',
'Object.keys'
]
}
},
{
files: ['cypress/plugins/index.js'],
extends: [
@ -294,7 +269,7 @@ module.exports = {
// instrument separately from nyc mocha
'import/no-unresolved': ['error', {ignore: ['/instrumented/']}],
'node/no-missing-import': 'off',
'jsdoc/check-examples': 'off',
'chai-expect-keywords/no-unsupported-keywords': [
'error', {
allowChaiDOM: true
@ -334,63 +309,33 @@ module.exports = {
'no-console': 0,
'import/unambiguous': 0
}
}
],
rules: {
// check-examples is not picking up eslint config properly in some
// environments; see also discussion above
// `mocha-cleanup/no-assertions-outside-it`
'jsdoc/check-examples': ['warn', {
rejectExampleCodeRegex: '^`'
}],
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453
'unicorn/regex-shorthand': 0,
// The Babel transform seems to have a problem converting these
'prefer-named-capture-group': 'off',
// Override these `ash-nazg/sauron` rules which are difficult for us
// to apply at this time
'unicorn/prefer-string-slice': 'off',
'default-case': 'off',
'require-unicode-regexp': 'off',
'max-len': 'off', /* , {
ignoreUrls: true,
ignoreRegExpLiterals: true
} */
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-node-append': 'off',
'unicorn/no-zero-fractions': 'off',
'unicorn/prefer-number-properties': 'off',
'jsdoc/require-file-overview': ['error', {
tags: {
file: {
initialCommentsOnly: true,
preventDuplicates: true
},
license: {
initialCommentsOnly: true,
preventDuplicates: true
},
copyright: {
initialCommentsOnly: true,
preventDuplicates: true
},
author: {
initialCommentsOnly: true,
preventDuplicates: true
},
module: {
initialCommentsOnly: true,
preventDuplicates: true
},
exports: {
initialCommentsOnly: true,
preventDuplicates: true
}
},
{
// Node files
files: [
'docs/jsdoc-config.js',
'build/build-html.js',
'rollup.config.js', 'rollup-config.config.js'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Promise.resolve'
]
},
globals: {
require: true
},
rules: {
// We can't put Rollup in npmignore or user can't get access,
// and we have too many modules to add to `peerDependencies`
// so this rule can know them to be available, so we instead
// disable
'node/no-unpublished-import': 'off'
}
}],
// Disable for now
'eslint-comments/require-description': 0
}
}
]
};

View File

@ -72,6 +72,7 @@
- Refactoring: Move `build-html` to `build` directory
- Refactoring: Add favicon no-op to suppress favicon 404s until
loaded dynamically (might make configurable in future)
- Refactoring: create a src folder and subfolders for svgcanvas, editor, common and externals.
- Linting (ESLint): Simplify regexes
- Linting (ESLint): Replace `innerHTML` with `textContent` from old demo
- Linting (ESLint): Update as per latest ash-nazg

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

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="orange" 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 44.92%</text><text class="high" x="5" y="14">Statements 44.92%</text><text class="shadow" x="125.5" y="15">Branches 33.59%</text><text class="high" x="125" y="14">Branches 33.59%</text><text class="shadow" x="234.5" y="15">Lines 46.07%</text><text class="high" x="234" y="14">Lines 46.07%</text><text class="shadow" x="321.5" y="15">Functions 51.19%</text><text class="high" x="321" y="14">Functions 51.19%</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 45.57%</text><text class="high" x="5" y="14">Statements 45.57%</text><text class="shadow" x="125.5" y="15">Branches 34.06%</text><text class="high" x="125" y="14">Branches 34.06%</text><text class="shadow" x="234.5" y="15">Lines 46.73%</text><text class="high" x="234" y="14">Lines 46.73%</text><text class="shadow" x="321.5" y="15">Functions 51.69%</text><text class="high" x="321" y="14">Functions 51.69%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="97" 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="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">130/131</text><text class="high" x="46" y="14">130/131</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="97" 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="#696969" d="M0 0h41v20H0z"/><path fill="#4c1" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">132/132</text><text class="high" x="46" y="14">132/132</text></g></svg>

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 820 B

View File

@ -3,8 +3,8 @@ import fs from 'promise-fs';
const filesAndReplacements = [
{
input: 'editor/svg-editor-es.html',
output: 'editor/xdomain-svg-editor-es.html',
input: 'src/editor/svg-editor-es.html',
output: 'src/editor/xdomain-svg-editor-es.html',
replacements: [
[
'<script type="module" src="../svgedit-config-es.js"></script>',
@ -13,8 +13,8 @@ const filesAndReplacements = [
]
},
{
input: 'editor/xdomain-svg-editor-es.html',
output: 'editor/xdomain-svg-editor.html',
input: 'src/editor/xdomain-svg-editor-es.html',
output: 'src/editor/xdomain-svg-editor.html',
replacements: [
[
'<!DOCTYPE html>',
@ -23,15 +23,15 @@ const filesAndReplacements = [
],
[
'<script type="module" src="redirect-on-lacking-support.js"></script>',
'<script defer="defer" src="../dist/redirect-on-lacking-support.js"></script>'
'<script defer="defer" src="../../dist/redirect-on-lacking-support.js"></script>'
],
[
'<script type="module" src="xdomain-svgedit-config-es.js"></script>',
'<script defer="defer" src="xdomain-svgedit-config-iife.js"></script>'
],
[
'<script src="external/dom-polyfill/dom-polyfill.js"></script>',
'<script src="../dist/dom-polyfill.js"></script>'
'<script src="../external/dom-polyfill/dom-polyfill.js"></script>',
'<script src="../../dist/dom-polyfill.js"></script>'
],
[
'<script nomodule="" src="redirect-on-no-module-support.js"></script>',
@ -41,8 +41,8 @@ const filesAndReplacements = [
},
// Now that file has copied, we can replace the DOCTYPE in xdomain
{
input: 'editor/xdomain-svg-editor-es.html',
output: 'editor/xdomain-svg-editor-es.html',
input: 'src/editor/xdomain-svg-editor-es.html',
output: 'src/editor/xdomain-svg-editor-es.html',
replacements: [
[
'<!DOCTYPE html>',
@ -52,8 +52,8 @@ const filesAndReplacements = [
]
},
{
input: 'editor/svg-editor-es.html',
output: 'editor/svg-editor.html',
input: 'src/editor/svg-editor-es.html',
output: 'src/editor/svg-editor.html',
replacements: [
[
'<!DOCTYPE html>',
@ -62,15 +62,15 @@ const filesAndReplacements = [
],
[
'<script type="module" src="redirect-on-lacking-support.js"></script>',
'<script defer="defer" src="../dist/redirect-on-lacking-support.js"></script>'
'<script defer="defer" src="../../dist/redirect-on-lacking-support.js"></script>'
],
[
'<script type="module" src="../svgedit-config-es.js"></script>',
'<script defer="defer" src="../svgedit-config-iife.js"></script>'
],
[
'<script src="external/dom-polyfill/dom-polyfill.js"></script>',
'<script src="../dist/dom-polyfill.js"></script>'
'<script src="../external/dom-polyfill/dom-polyfill.js"></script>',
'<script src="../../dist/dom-polyfill.js"></script>'
],
[
'<script nomodule="" src="redirect-on-no-module-support.js"></script>',
@ -79,8 +79,8 @@ const filesAndReplacements = [
]
},
{
input: 'editor/extensions/imagelib/openclipart-es.html',
output: 'editor/extensions/imagelib/openclipart.html',
input: 'src/editor/extensions/imagelib/openclipart-es.html',
output: 'src/editor/extensions/imagelib/openclipart.html',
replacements: [
[
'<!DOCTYPE html>',
@ -89,11 +89,11 @@ const filesAndReplacements = [
],
[
'<script src="../../external/dom-polyfill/dom-polyfill.js"></script>',
'<script src="../../../dist/dom-polyfill.js"></script>'
'<script src="../../../../dist/dom-polyfill.js"></script>'
],
[
'<script type="module" src="openclipart.js"></script>',
'<script defer="defer" src="../../../dist/extensions/imagelib/openclipart.js"></script>'
'<script defer="defer" src="../../../../dist/extensions/imagelib/openclipart.js"></script>'
],
[
'<script nomodule="" src="redirect-on-no-module-support.js"></script>',
@ -102,8 +102,8 @@ const filesAndReplacements = [
]
},
{
input: 'editor/extensions/imagelib/index-es.html',
output: 'editor/extensions/imagelib/index.html',
input: 'src/editor/extensions/imagelib/index-es.html',
output: 'src/editor/extensions/imagelib/index.html',
replacements: [
[
'<!DOCTYPE html>',
@ -112,7 +112,7 @@ const filesAndReplacements = [
],
[
'<script type="module" src="index.js"></script>',
'<script defer="defer" src="../../../dist/extensions/imagelib/index.js"></script>'
'<script defer="defer" src="../../../../dist/extensions/imagelib/index.js"></script>'
],
[
'<script nomodule="" src="redirect-on-no-module-support.js"></script>',

View File

@ -1,6 +1,7 @@
{
"baseUrl": "http://localhost:8000",
"reporter": "cypress-multi-reporters",
"video": false,
"reporterOptions": {
"configFile": "mocha-multi-reporters.json"
}

View File

@ -1,6 +1,6 @@
describe('UI - Accessibility', function () {
beforeEach(() => {
cy.visit('/instrumented/svg-editor-es.html');
cy.visit('/instrumented/editor/svg-editor-es.html');
cy.injectAxe();
});
@ -25,6 +25,16 @@ describe('UI - Accessibility', function () {
locale: Object
*/
});
cy.checkA11y();
cy.checkA11y(
{},
{
rules: {
'label-title-only': {enabled: false},
'page-has-heading-one': {enabled: false},
region: {enabled: false},
'scrollable-region-focusable': {enabled: false}
}
}
);
});
});

View File

@ -1,5 +1,5 @@
import '../../../instrumented/jquery.min.js';
import * as contextmenu from '../../../instrumented/contextmenu.js';
import '../../../instrumented/editor/jquery.min.js';
import * as contextmenu from '../../../instrumented/editor/contextmenu.js';
describe('contextmenu', function () {
/**

View File

@ -1,8 +1,8 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as coords from '../../../instrumented/coords.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as coords from '../../../instrumented/svgcanvas/coords.js';
describe('coords', function () {
let elemId = 1;

View File

@ -1,8 +1,8 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as draw from '../../../instrumented/draw.js';
import * as units from '../../../instrumented/units.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as draw from '../../../instrumented/svgcanvas/draw.js';
import * as units from '../../../instrumented/common/units.js';
describe('draw.Drawing', function () {
const addOwnSpies = (obj) => {
@ -20,6 +20,7 @@ describe('draw.Drawing', function () {
const PATH_ATTR = {
// clone will convert relative to absolute, so the test for equality fails.
// d: 'm7.38867,57.38867c0,-27.62431 22.37569,-50 50,-50c27.62431,0 50,22.37569 50,50c0,27.62431 -22.37569,50 -50,50c-27.62431,0 -50,-22.37569 -50,-50z',
// eslint-disable-next-line max-len
d: 'M7.389,57.389C7.389,29.764 29.764,7.389 57.389,7.389C85.013,7.389 107.389,29.764 107.389,57.389C107.389,85.013 85.013,107.389 57.389,107.389C29.764,107.389 7.389,85.013 7.389,57.389z',
transform: 'rotate(45 57.388671875000036,57.388671874999986) ',
'stroke-width': '5',

View File

@ -1,9 +1,9 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as transformlist from '../../../instrumented/svgtransformlist.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as hstory from '../../../instrumented/history.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as hstory from '../../../instrumented/svgcanvas/history.js';
describe('history', function () {
// TODO(codedread): Write tests for handling history events.
@ -20,11 +20,17 @@ describe('history', function () {
// const svg = document.createElementNS(NS.SVG, 'svg');
let undoMgr = null;
class MockCommand {
constructor (optText) { this.text_ = optText; }
apply () { /* */ } // eslint-disable-line class-methods-use-this
unapply () { /* */ } // eslint-disable-line class-methods-use-this
getText () { return this.text_; }
class MockCommand extends hstory.Command {
constructor (optText) {
super();
this.text = optText;
}
apply (handler) {
super.apply(handler, () => { /* */ });
}
unapply (handler) {
super.unapply(handler, () => { /* */ });
}
elements () { return []; } // eslint-disable-line class-methods-use-this
}
@ -482,17 +488,17 @@ describe('history', function () {
it('Test BatchCommand', function () {
let concatResult = '';
MockCommand.prototype.apply = function () { concatResult += this.text_; };
MockCommand.prototype.apply = function (handler) { concatResult += this.text; };
const batch = new hstory.BatchCommand();
assert.ok(batch.unapply);
assert.ok(batch.apply);
assert.ok(batch.addSubCommand);
assert.ok(batch.isEmpty);
assert.equal(typeof batch.unapply, typeof function () { /* */ });
assert.equal(typeof batch.apply, typeof function () { /* */ });
assert.equal(typeof batch.addSubCommand, typeof function () { /* */ });
assert.equal(typeof batch.isEmpty, typeof function () { /* */ });
assert.equal(typeof batch.unapply, 'function');
assert.equal(typeof batch.apply, 'function');
assert.equal(typeof batch.addSubCommand, 'function');
assert.equal(typeof batch.isEmpty, 'function');
assert.ok(batch.isEmpty());
@ -506,8 +512,9 @@ describe('history', function () {
assert.equal(concatResult, 'abc');
MockCommand.prototype.apply = function () { /* */ };
MockCommand.prototype.unapply = function () { concatResult += this.text_; };
MockCommand.prototype.unapply = function () { concatResult += this.text; };
concatResult = '';
assert.ok(!concatResult);
batch.unapply();
assert.equal(concatResult, 'cba');

View File

@ -1,7 +1,7 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as math from '../../../instrumented/math.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as math from '../../../instrumented/common/math.js';
describe('math', function () {
const svg = document.createElementNS(NS.SVG, 'svg');

View File

@ -1,11 +1,11 @@
/* globals SVGPathSeg */
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/svgpathseg.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as pathModule from '../../../instrumented/path.js';
import {init as unitsInit} from '../../../instrumented/units.js';
import '../../../instrumented/common/svgpathseg.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as pathModule from '../../../instrumented/svgcanvas/path.js';
import {init as unitsInit} from '../../../instrumented/common/units.js';
describe('path', function () {
/**

View File

@ -1,9 +1,9 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as coords from '../../../instrumented/coords.js';
import * as recalculate from '../../../instrumented/recalculate.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as coords from '../../../instrumented/svgcanvas/coords.js';
import * as recalculate from '../../../instrumented/svgcanvas/recalculate.js';
describe('recalculate', function () {
// eslint-disable-next-line no-shadow

View File

@ -1,7 +1,7 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as sanitize from '../../../instrumented/sanitize.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as sanitize from '../../../instrumented/svgcanvas/sanitize.js';
describe('sanitize', function () {
const svg = document.createElementNS(NS.SVG, 'svg');

View File

@ -1,7 +1,7 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import * as select from '../../../instrumented/select.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as select from '../../../instrumented/svgcanvas/select.js';
import {NS} from '../../../instrumented/common/namespaces.js';
describe('select', function () {
const sandbox = document.createElement('div');

View File

@ -1,8 +1,8 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as transformlist from '../../../instrumented/svgtransformlist.js';
import {disableSupportsNativeTransformLists} from '../../../instrumented/browser.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js';
import {disableSupportsNativeTransformLists} from '../../../instrumented/common/browser.js';
import almostEqualsPlugin from '../../support/assert-almostEquals.js';
import expectOutOfBoundsExceptionPlugin from '../../support/assert-expectOutOfBoundsException.js';

View File

@ -1,8 +1,9 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/jquery-ui/jquery-ui-1.8.17.custom.min.js';
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js';
import '../../../instrumented/svgpathseg.js';
import SvgCanvas from '../../../instrumented/svgcanvas.js';
import '../../../instrumented/common/svgpathseg.js';
import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js';
describe('Basic Module', function () {
// helper functions

View File

@ -1,6 +1,6 @@
import '../../../instrumented/jquery.min.js';
import '../../../instrumented/editor/jquery.min.js';
import * as units from '../../../instrumented/units.js';
import * as units from '../../../instrumented/common/units.js';
describe('units', function () {
/**

View File

@ -1,11 +1,12 @@
import '../../../instrumented/jquery.min.js';
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/svgpathseg.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as transformlist from '../../../instrumented/svgtransformlist.js';
import * as math from '../../../instrumented/math.js';
import * as path from '../../../instrumented/path.js';
import '../../../instrumented/common/svgpathseg.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js';
import * as math from '../../../instrumented/common/math.js';
import * as path from '../../../instrumented/svgcanvas/path.js';
import setAssertionMethods from '../../support/assert-close.js';
chai.use(setAssertionMethods);

View File

@ -1,10 +1,11 @@
import '../../../instrumented/jquery.min.js';
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/svgpathseg.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as utilities from '../../../instrumented/utilities.js';
import * as transformlist from '../../../instrumented/svgtransformlist.js';
import * as math from '../../../instrumented/math.js';
import '../../../instrumented/common/svgpathseg.js';
import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js';
import * as math from '../../../instrumented/common/math.js';
describe('utilities performance', function () {
let currentLayer, groupWithMatrixTransform, textWithMatrixTransform;

View File

@ -1,8 +1,9 @@
import '../../../instrumented/jquery.min.js';
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import * as browser from '../../../instrumented/browser.js';
import * as utilities from '../../../instrumented/utilities.js';
import {NS} from '../../../instrumented/namespaces.js';
import * as browser from '../../../instrumented/common/browser.js';
import * as utilities from '../../../instrumented/common/utilities.js';
import {NS} from '../../../instrumented/common/namespaces.js';
describe('utilities', function () {
/**

View File

@ -3,7 +3,6 @@
import codeCoverageTask from '@cypress/code-coverage/task.js';
// eslint-disable-next-line import/no-anonymous-default-export
export default (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

View File

@ -1,4 +1,4 @@
/* eslint-disable jsdoc/check-examples */
/* eslint-disable max-len */
import assertionWrapper from './assertion-wrapper.js';
/**

View File

@ -1,14 +0,0 @@
/* globals require */
/* eslint-disable import/no-commonjs */
const copyfiles = require('copyfiles');
const pkg = require('../../package.json');
copyfiles([
...pkg.nyc.exclude,
'instrumented'
], {
up: 1
}, () => {
console.log('Done');
});

View File

@ -4,7 +4,7 @@ export const approveStorage = () => {
};
export const visitAndApproveStorage = () => {
cy.visit('/instrumented/svg-editor-es.html');
cy.visit('/instrumented/editor/svg-editor-es.html');
approveStorage();
};

View File

@ -3,10 +3,10 @@
<head>
<meta charset="utf-8" />
<title>Minimal demo of SvgCanvas</title>
<script src="../editor/jquery.min.js"></script>
<script src="../editor/jquery-ui/jquery-ui-1.8.17.custom.min.js"></script>
<script src="../src/editor/jquery.min.js"></script>
<script src="../src/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js"></script>
<style> #svgroot { overflow: hidden; } </style>
<link rel="shortcut icon" type="image/x-icon" href="../editor/images/logo.png" />
<link rel="shortcut icon" type="image/x-icon" href="../src/editor/images/logo.png" />
</head>
<body>
@ -26,7 +26,7 @@
<script type="module">
/* globals canvas */
import SvgCanvas from '../editor/svgcanvas.js';
import SvgCanvas from '../src/svgcanvas/svgcanvas.js';
const container = document.querySelector('#editorContainer');
const {width, height} = {width: 500, height: 300};

39
dist/canvg.js vendored
View File

@ -1799,10 +1799,21 @@ var canvg = (function (exports) {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
}
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width - desiredWidth, 0);
}
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height - desiredHeight);
}
} // scale
@ -3022,7 +3033,11 @@ var canvg = (function (exports) {
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') {
ctx.rotate(-angle);
}
ctx.translate(-point.x, -point.y);
}
}]);
@ -4156,7 +4171,8 @@ var canvg = (function (exports) {
var tempSvg = element;
if (element.type === 'symbol') {
// render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement)
// render me using a temporary svg element in symbol cases
// (https://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value);
@ -4167,8 +4183,13 @@ var canvg = (function (exports) {
if (tempSvg.type === 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
if (this.attribute('width').hasValue()) {
tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
}
if (this.attribute('height').hasValue()) {
tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
}
}
var oldParent = tempSvg.parent;
@ -4783,9 +4804,9 @@ var canvg = (function (exports) {
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility?
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);

View File

@ -63,6 +63,7 @@
var node = document.createDocumentFragment();
nodes.forEach(function (n) {
// // eslint-disable-next-line unicorn/prefer-node-append
node.appendChild(n);
});
return node;
@ -82,7 +83,8 @@
nodes[_key2] = arguments[_key2];
}
nodes = convertNodesIntoANode(nodes);
nodes = convertNodesIntoANode(nodes); // // eslint-disable-next-line unicorn/prefer-node-append
this.appendChild(nodes);
}
};

View File

@ -82,7 +82,7 @@ var svgEditorExtension_arrows = (function () {
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this; // eslint-disable-line consistent-this
newMarker = this;
}
});
@ -98,8 +98,7 @@ var svgEditorExtension_arrows = (function () {
var remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
var element = this; // eslint-disable-line consistent-this
var element = this;
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;

File diff suppressed because it is too large Load Diff

View File

@ -37,8 +37,6 @@ var svgEditorExtension_connector = (function () {
};
}
/* eslint-disable unicorn/no-fn-reference-in-iterator */
/**
* @file ext-connector.js
*

View File

@ -207,7 +207,7 @@ var svgEditorExtension_mathjax = (function () {
mathjax: {
embed_svg: 'Save as mathematics',
embed_mathml: 'Save as figure',
svg_save_warning: 'The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore. ',
svg_save_warning: 'The math will be transformed into a figure is ' + 'manipulatable like everything else. You will not be able to ' + 'manipulate the TeX-code anymore.',
mathml_save_warning: 'Advised. The math will be saved as a figure.',
title: 'Mathematics code editor'
}
@ -237,7 +237,7 @@ var svgEditorExtension_mathjax = (function () {
break;
}
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:' + 'Displaying_a_formula" target="_blank">TeX</a> code.' + '</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('#mathjax_container').draggable({
cancel: 'button,fieldset',

View File

@ -28,7 +28,7 @@ var svgEditorExtension_overview_window = (function () {
} // Define and insert the base html element.
var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; ' + 'word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; ' + 'left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; ' + 'overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" ' + 'y="0" viewBox="0 0 4800 3600" ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; ' + 'min-height:50px; position:absolute; top:30px; left:30px; ' + 'z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
$('#sidepanels').append(propsWindowHtml); // Define dynamic animation of the view box.
var updateViewBox = function updateViewBox() {

View File

@ -1799,10 +1799,21 @@ var svgEditorExtension_server_moinsave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
}
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width - desiredWidth, 0);
}
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height - desiredHeight);
}
} // scale
@ -3022,7 +3033,11 @@ var svgEditorExtension_server_moinsave = (function () {
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') {
ctx.rotate(-angle);
}
ctx.translate(-point.x, -point.y);
}
}]);
@ -4156,7 +4171,8 @@ var svgEditorExtension_server_moinsave = (function () {
var tempSvg = element;
if (element.type === 'symbol') {
// render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement)
// render me using a temporary svg element in symbol cases
// (https://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value);
@ -4167,8 +4183,13 @@ var svgEditorExtension_server_moinsave = (function () {
if (tempSvg.type === 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
if (this.attribute('width').hasValue()) {
tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
}
if (this.attribute('height').hasValue()) {
tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
}
}
var oldParent = tempSvg.parent;
@ -4783,9 +4804,9 @@ var svgEditorExtension_server_moinsave = (function () {
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility?
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);

View File

@ -1799,10 +1799,21 @@ var svgEditorExtension_server_opensave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
}
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width - desiredWidth, 0);
}
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height - desiredHeight);
}
} // scale
@ -3022,7 +3033,11 @@ var svgEditorExtension_server_opensave = (function () {
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') {
ctx.rotate(-angle);
}
ctx.translate(-point.x, -point.y);
}
}]);
@ -4156,7 +4171,8 @@ var svgEditorExtension_server_opensave = (function () {
var tempSvg = element;
if (element.type === 'symbol') {
// render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement)
// render me using a temporary svg element in symbol cases
// (https://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value);
@ -4167,8 +4183,13 @@ var svgEditorExtension_server_opensave = (function () {
if (tempSvg.type === 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
if (this.attribute('width').hasValue()) {
tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
}
if (this.attribute('height').hasValue()) {
tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
}
}
var oldParent = tempSvg.parent;
@ -4783,9 +4804,9 @@ var svgEditorExtension_server_opensave = (function () {
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility?
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);

View File

@ -183,6 +183,8 @@ var svgEditorExtension_shapes = (function () {
lastBBox = {}; // This populates the category list
categories = strings.categories;
/* eslint-disable max-len */
library = {
basic: {
data: {
@ -218,6 +220,8 @@ var svgEditorExtension_shapes = (function () {
buttons: []
}
};
/* eslint-enable max-len */
modeId = 'shapelib';
startClientPos = {};
curLib = library.basic;

View File

@ -1132,8 +1132,7 @@
while (_node2.childNodes[j]) {
var cn = _node2.childNodes[j];
cn.remove(); // `j` should stay the same as removing will cause node to be present
} // eslint-disable-next-line unicorn/no-fn-reference-in-iterator
}
attVal.childNodes.forEach(_childrenToJML(_node2));
} else {
@ -1160,13 +1159,11 @@
}
if (attVal.head) {
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
attVal.head.forEach(_appendJML(head));
}
}
if (attVal.body) {
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
attVal.body.forEach(_appendJMLOrText(_body));
}
}
@ -1453,7 +1450,7 @@
// Todo: Fix to allow application of stylesheets of style tags within fragments?
return nodes.length <= 1 ? nodes[0] // eslint-disable-next-line unicorn/no-fn-reference-in-iterator
return nodes.length <= 1 ? nodes[0] // eslint-disable-next-line
: nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes;
}

6205
dist/index-es.js vendored

File diff suppressed because it is too large Load Diff

96
dist/index-es.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6207
dist/index-umd.js vendored

File diff suppressed because it is too large Load Diff

98
dist/index-umd.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -118,6 +118,8 @@
};
}
/* eslint-disable import/unambiguous, max-len */
/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs,
SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs,
SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs,
@ -1893,7 +1895,7 @@
return [];
}
var owningPathSegList = this; // eslint-disable-line consistent-this
var owningPathSegList = this;
var Builder = /*#__PURE__*/function () {
function Builder() {

973
dist/svgcanvas-iife.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -61,10 +61,11 @@ module.exports = {
'cypress',
'node_modules',
'dist',
'editor/external',
'external',
'screencasts',
'test'
],
// eslint-disable-next-line max-len
excludePattern: 'svgedit-config-*|build-html.js|rollup*|external/babel-polyfill|extensions/mathjax|imagelib/jquery.min.js|jspdf/jspdf.min.js|jspdf/underscore-min.js|jquery-ui|jquery.min.js|js-hotkeys'
},
sourceType: 'module',

View File

@ -9,7 +9,7 @@ SVG-Edit extensions are standalone JavaScript files that can be either
included in the HTML file, loaded using `setConfig`, or indicated through
the URL (see [ConfigOptions]{@tutorial ConfigOptions} for usage).
`svgedit-config-iife.js` in the project root directory (if
`svgedit-config-iife.js` in the `src` directory (if
through Git clone, by running `npm run build-by-config`) is the file used
by `svg-editor.html` to execute commands before extensions are loaded,
e.g., if you wish to make configuration changes which affect extension

View File

@ -2,7 +2,7 @@ extraction:
javascript:
index:
filters:
- exclude: "editor/xdomain-svgedit-config-iife.js"
- exclude: "editor/redirect-on-no-module-support.js"
- exclude: "svgedit-config-iife.js"
- exclude: "src/editor/xdomain-svgedit-config-iife.js"
- exclude: "src/editor/redirect-on-no-module-support.js"
- exclude: "src/svgedit-config-iife.js"
- exclude: "dist"

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