#546 feGaussianBlur element iterate from filter issue fixes
This commit is contained in:
@@ -12,7 +12,7 @@ import * as hstry from './history.js';
|
|||||||
import * as pathModule from './path.js';
|
import * as pathModule from './path.js';
|
||||||
import {
|
import {
|
||||||
isNullish, getStrokedBBoxDefaultVisible, setHref, getElem, getHref, getVisibleElements,
|
isNullish, getStrokedBBoxDefaultVisible, setHref, getElem, getHref, getVisibleElements,
|
||||||
findDefs, getRotationAngle, getRefElem, getBBox as utilsGetBBox, walkTreePost, assignAttributes
|
findDefs, getRotationAngle, getRefElem, getBBox as utilsGetBBox, walkTreePost, assignAttributes, getFeGaussianBlur
|
||||||
} from './utilities.js';
|
} from './utilities.js';
|
||||||
import {
|
import {
|
||||||
transformPoint, matrixMultiply, transformListToTransform
|
transformPoint, matrixMultiply, transformListToTransform
|
||||||
@@ -576,15 +576,16 @@ export const pushGroupProperty = function (g, undoable) {
|
|||||||
} else {
|
} else {
|
||||||
gfilter = getRefElem(elem.getAttribute('filter'));
|
gfilter = getRefElem(elem.getAttribute('filter'));
|
||||||
}
|
}
|
||||||
|
// const filterElem = getRefElem(gfilter);
|
||||||
|
const blurElem = getFeGaussianBlur(gfilter);
|
||||||
// Change this in future for different filters
|
// Change this in future for different filters
|
||||||
const suffix = (gfilter.firstChild.tagName === 'feGaussianBlur') ? 'blur' : 'filter';
|
const suffix = (blurElem?.tagName === 'feGaussianBlur') ? 'blur' : 'filter';
|
||||||
gfilter.id = elem.id + '_' + suffix;
|
gfilter.id = elem.id + '_' + suffix;
|
||||||
elementContext_.changeSelectedAttribute('filter', 'url(#' + gfilter.id + ')', [ elem ]);
|
elementContext_.changeSelectedAttribute('filter', 'url(#' + gfilter.id + ')', [ elem ]);
|
||||||
|
|
||||||
// Update blur value
|
// Update blur value
|
||||||
if (cblur) {
|
if (cblur) {
|
||||||
elementContext_.changeSelectedAttribute('stdDeviation', cblur, [ gfilter.firstChild ]);
|
elementContext_.changeSelectedAttribute('stdDeviation', cblur, [ blurElem ]);
|
||||||
elementContext_.getCanvas().setBlurOffsets(gfilter, cblur);
|
elementContext_.getCanvas().setBlurOffsets(gfilter, cblur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ import {
|
|||||||
preventClickDefault, walkTree, getBBoxOfElementAsPath, convertToPath, encode64, decode64,
|
preventClickDefault, walkTree, getBBoxOfElementAsPath, convertToPath, encode64, decode64,
|
||||||
getVisibleElements, dropXMLInternalSubset, init as utilsInit,
|
getVisibleElements, dropXMLInternalSubset, init as utilsInit,
|
||||||
getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible, isNullish, blankPageObjectURL,
|
getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible, isNullish, blankPageObjectURL,
|
||||||
$id, $qa, $qq
|
$id, $qa, $qq, getFeGaussianBlur
|
||||||
} from './utilities.js';
|
} from './utilities.js';
|
||||||
import {
|
import {
|
||||||
transformPoint, matrixMultiply, hasMatrixTransform, transformListToTransform,
|
transformPoint, matrixMultiply, hasMatrixTransform, transformListToTransform,
|
||||||
@@ -2177,6 +2177,12 @@ class SvgCanvas {
|
|||||||
const blur = getElem(elem.id + '_blur');
|
const blur = getElem(elem.id + '_blur');
|
||||||
if (blur) {
|
if (blur) {
|
||||||
val = blur.firstChild.getAttribute('stdDeviation');
|
val = blur.firstChild.getAttribute('stdDeviation');
|
||||||
|
} else {
|
||||||
|
const filterElem = getRefElem(filterUrl);
|
||||||
|
const blurElem = getFeGaussianBlur(filterElem);
|
||||||
|
if (blurElem !== null) {
|
||||||
|
val = blurElem.getAttribute('stdDeviation');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1203,6 +1203,26 @@ export let getRotationAngle = function (elem, toRad) {
|
|||||||
export const getRefElem = function (attrVal) {
|
export const getRefElem = function (attrVal) {
|
||||||
return getElem(getUrlFromAttr(attrVal).substr(1));
|
return getElem(getUrlFromAttr(attrVal).substr(1));
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Get the reference element associated with the given attribute value.
|
||||||
|
* @function module:utilities.getFeGaussianBlur
|
||||||
|
* @param {any} Element
|
||||||
|
* @returns {any} Reference element
|
||||||
|
*/
|
||||||
|
export const getFeGaussianBlur = function (ele) {
|
||||||
|
if (ele?.firstChild?.tagName === 'feGaussianBlur') {
|
||||||
|
return ele.firstChild;
|
||||||
|
} else {
|
||||||
|
const childrens = ele.children;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
for (const [ _, value ] of Object.entries(childrens)) {
|
||||||
|
if (value.tagName === 'feGaussianBlur') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a DOM element by ID within the SVG root element.
|
* Get a DOM element by ID within the SVG root element.
|
||||||
|
|||||||
Reference in New Issue
Block a user