#546 ungrouping issue fixed

master
agriyadev5 2021-07-06 13:00:55 +05:30
parent 1897e2e0ff
commit 638df11ec2
2 changed files with 29 additions and 4 deletions

View File

@ -571,16 +571,19 @@ export const pushGroupProperty = function (g, undoable) {
// Clone the group's filter
gfilter = drawing.copyElem(gfilter);
findDefs().append(gfilter);
// const filterElem = getRefElem(gfilter);
const blurElem = getFeGaussianBlur(gfilter);
// Change this in future for different filters
const suffix = (blurElem?.tagName === 'feGaussianBlur') ? 'blur' : 'filter';
gfilter.id = elem.id + '_' + suffix;
elementContext_.changeSelectedAttribute('filter', 'url(#' + gfilter.id + ')', [ elem ]);
}
} else {
gfilter = getRefElem(elem.getAttribute('filter'));
}
// const filterElem = getRefElem(gfilter);
const blurElem = getFeGaussianBlur(gfilter);
// Change this in future for different filters
const suffix = (blurElem?.tagName === 'feGaussianBlur') ? 'blur' : 'filter';
gfilter.id = elem.id + '_' + suffix;
elementContext_.changeSelectedAttribute('filter', 'url(#' + gfilter.id + ')', [ elem ]);
// Update blur value
if (cblur) {

View File

@ -368,6 +368,28 @@ export const setSvgString = function (xmlString, preventUndo) {
svgCanvas.embedImage(val);
}
});
// Duplicate id replace changes
const nodes = content.querySelectorAll('[id]');
const ids = {};
const totalNodes = nodes.length;
for(let i=0; i<totalNodes; i++) {
const currentId = nodes[i].id ? nodes[i].id : "undefined";
if(isNaN(ids[currentId])) {
ids[currentId] = 0;
}
ids[currentId]++;
}
Object.entries(ids).forEach(([ key, value ]) => {
if (value > 1) {
const nodes = content.querySelectorAll('[id="'+key+'"]');
for(let i=1; i<nodes.length; i++) {
nodes[i].setAttribute('id', svgCanvas.getNextId());
}
}
});
// Wrap child SVGs in group elements
const svgElements = content.querySelectorAll('svg');