Fix: avoid to select defs or title as parentElement (#840)

* Fix: avoid to select defs or title as parentElement
master
cg-scorpio 2022-10-15 17:21:14 +02:00 committed by GitHub
parent e2ad8211a5
commit aabd593123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1345 additions and 1497 deletions

2790
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -82,55 +82,54 @@
},
"dependencies": {
"@svgedit/svgcanvas": "7.1.6",
"browser-fs-access": "0.31.0",
"core-js": "3.24.1",
"browser-fs-access": "0.31.1",
"core-js": "3.25.5",
"elix": "15.0.1",
"html2canvas": "1.4.1",
"i18next": "21.9.0",
"i18next": "21.10.0",
"jspdf": "2.5.1",
"pathseg": "1.2.1",
"regenerator-runtime": "0.13.9",
"regenerator-runtime": "0.13.10",
"replace-in-file": "^6.3.5",
"svg2pdf.js": "2.2.1"
},
"devDependencies": {
"@babel/core": "7.18.10",
"@babel/preset-env": "7.18.10",
"@babel/core": "7.19.3",
"@babel/preset-env": "7.19.4",
"@babel/register": "7.18.9",
"@babel/runtime-corejs3": "7.18.9",
"@babel/runtime-corejs3": "7.19.4",
"@cypress/code-coverage": "3.10.0",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-babel": "6.0.0",
"@rollup/plugin-commonjs": "^21",
"@rollup/plugin-dynamic-import-vars": "1.4.4",
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-replace": "4.0.0",
"@rollup/plugin-url": "7.0.0",
"@web/dev-server": "0.1.33",
"@rollup/plugin-dynamic-import-vars": "2.0.0",
"@rollup/plugin-node-resolve": "15.0.0",
"@rollup/plugin-replace": "5.0.0",
"@rollup/plugin-url": "8.0.0",
"@web/dev-server": "0.1.34",
"@web/dev-server-rollup": "0.3.19",
"babel-plugin-transform-object-rest-spread": "7.0.0-beta.3",
"core-js-bundle": "3.24.1",
"core-js-bundle": "3.25.5",
"cp-cli": "2.0.0",
"cypress": "10.4.0",
"cypress": "10.10.0",
"cypress-multi-reporters": "1.6.1",
"jamilih": "0.54.0",
"jsdoc": "3.6.11",
"node-static": "0.7.11",
"npm-run-all": "4.1.5",
"nyc": "15.1.0",
"open-cli": "7.0.1",
"open-cli": "7.1.0",
"promise-fs": "2.1.1",
"qr-manipulation": "0.7.0",
"query-result": "1.0.5",
"remark-cli": "11.0.0",
"remark-lint-ordered-list-marker-value": "3.1.1",
"rimraf": "3.0.2",
"rollup": "2.78.0",
"rollup": "^2",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-filesize": "9.1.2",
"rollup-plugin-html": "0.2.1",
"rollup-plugin-progress": "1.1.2",
"rollup-plugin-re": "1.0.7",
"rollup-plugin-terser": "7.0.2",
"standard": "17.0.0",
"start-server-and-test": "1.14.0"
}

View File

@ -6,7 +6,6 @@ import rimraf from 'rimraf'
import babel from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
// import progress from 'rollup-plugin-progress';
import filesize from 'rollup-plugin-filesize'
@ -31,7 +30,6 @@ const config = [{
}),
commonjs(),
babel({ babelHelpers: 'bundled', exclude: [/\/core-js\//] }), // exclude core-js to avoid circular dependencies.
terser({ keep_fnames: true }), // keep_fnames is needed to avoid an error when calling extensions.
filesize()
]
}]

View File

@ -962,7 +962,15 @@ export const getStrokedBBox = (elems, addSVGElementsFromJson, pathActions) => {
export const getVisibleElements = (parentElement) => {
if (!parentElement) {
const svgContent = svgCanvas.getSvgContent()
parentElement = svgContent.children[0] // Prevent layers from being included
for (let i = 0; i < svgContent.children.length; i++) {
if (svgContent.children[i].getBBox) {
const bbox = svgContent.children[i].getBBox()
if (bbox.width !== 0 && bbox.height !== 0 && bbox.width !== 0 && bbox.height !== 0) {
parentElement = svgContent.children[i]
break
}
}
}
}
const contentElems = []

View File

@ -13,7 +13,6 @@ import url from '@rollup/plugin-url' // for XML/SVG files
import html from 'rollup-plugin-html'
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'
import { terser } from 'rollup-plugin-terser'
// import progress from 'rollup-plugin-progress';
import filesize from 'rollup-plugin-filesize'
@ -105,7 +104,6 @@ const config = [{
commonjs(),
dynamicImportVars({ include: 'src/editor/locale.js' }),
babel({ babelHelpers: 'bundled', exclude: [/\/core-js\//] }), // exclude core-js to avoid circular dependencies.
terser({ keep_fnames: true }), // keep_fnames is needed to avoid an error when calling extensions.
filesize()
]
}]
@ -141,8 +139,7 @@ extensionDirs.forEach((extensionDir) => {
}),
commonjs({ exclude: `src/editor/extensions/${extensionName}/${extensionName}.js` }),
dynamicImportVars({ include: `src/editor/extensions/${extensionName}/${extensionName}.js` }),
babel({ babelHelpers: 'bundled', exclude: [/\/core-js\//] }),
terser({ keep_fnames: true })
babel({ babelHelpers: 'bundled', exclude: [/\/core-js\//] })
]
}
)