Fix: avoid to select defs or title as parentElement (#840)
* Fix: avoid to select defs or title as parentElement
This commit is contained in:
@@ -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()
|
||||
]
|
||||
}]
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user