From a0337ebf9d954d5172beb0859589b12a42b5c7ba Mon Sep 17 00:00:00 2001 From: agriyadev5 Date: Thu, 10 Jun 2021 16:16:46 +0530 Subject: [PATCH] #374 slide increase issue fixed --- .../extensions/ext-polystar/ext-polystar.js | 46 ++++++++++--------- src/svgcanvas/sanitize.js | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/editor/extensions/ext-polystar/ext-polystar.js b/src/editor/extensions/ext-polystar/ext-polystar.js index b20179c3..3a3560f9 100644 --- a/src/editor/extensions/ext-polystar/ext-polystar.js +++ b/src/editor/extensions/ext-polystar/ext-polystar.js @@ -149,29 +149,31 @@ export default { let i = selElems.length; while (i--) { const elem = selElems[i]; - let xpos = 0; - let ypos = 0; - if (elem.points) { - const list = elem.points; - const len = list.numberOfItems; - for (let i = 0; i < len; ++i) { - const pt = list.getItem(i); - xpos += parseFloat(pt.x); - ypos += parseFloat(pt.y); + if (elem.hasAttribute('edge')) { + let xpos = 0; + let ypos = 0; + if (elem.points) { + const list = elem.points; + const len = list.numberOfItems; + for (let i = 0; i < len; ++i) { + const pt = list.getItem(i); + xpos += parseFloat(pt.x); + ypos += parseFloat(pt.y); + } + const cx = xpos / len; + const cy = ypos / len; + const edg = elem.getAttribute('edge'); + const inradius = (edg / 2) * cot(Math.PI / sides); + const circumradius = inradius * sec(Math.PI / sides); + let points = ""; + for (let s = 0; sides >= s; s++) { + const angle = (2.0 * Math.PI * s) / sides; + const x = circumradius * Math.cos(angle) + cx; + const y = circumradius * Math.sin(angle) + cy; + points += x + "," + y + " "; + } + elem.setAttribute("points", points); } - const cx = xpos / len; - const cy = ypos / len; - const edg = elem.getAttribute('edge'); - const inradius = (edg / 2) * cot(Math.PI / sides); - const circumradius = inradius * sec(Math.PI / sides); - let points = ""; - for (let s = 0; sides >= s; s++) { - const angle = (2.0 * Math.PI * s) / sides; - const x = circumradius * Math.cos(angle) + cx; - const y = circumradius * Math.sin(angle) + cy; - points += x + "," + y + " "; - } - elem.setAttribute("points", points); } } }); diff --git a/src/svgcanvas/sanitize.js b/src/svgcanvas/sanitize.js index c93fd890..5c53fbfe 100644 --- a/src/svgcanvas/sanitize.js +++ b/src/svgcanvas/sanitize.js @@ -49,7 +49,7 @@ const svgWhiteList_ = { metadata: [ 'class', 'id' ], path: [ 'class', 'clip-path', 'clip-rule', 'd', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform' ], pattern: [ 'class', 'height', 'id', 'patternContentUnits', 'patternTransform', 'patternUnits', 'requiredFeatures', 'style', 'systemLanguage', 'viewBox', 'width', 'x', 'xlink:href', 'y' ], - polygon: [ 'class', 'clip-path', 'clip-rule', 'id', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'class', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'points', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'sides', 'shape' ], + polygon: [ 'class', 'clip-path', 'clip-rule', 'id', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'id', 'class', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'points', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'sides', 'shape', 'edge' ], polyline: [ 'class', 'clip-path', 'clip-rule', 'id', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'points', 'requiredFeatures', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'se:connector' ], radialGradient: [ 'class', 'cx', 'cy', 'fx', 'fy', 'gradientTransform', 'gradientUnits', 'id', 'r', 'requiredFeatures', 'spreadMethod', 'systemLanguage', 'xlink:href' ], rect: [ 'class', 'clip-path', 'clip-rule', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'height', 'id', 'mask', 'opacity', 'requiredFeatures', 'rx', 'ry', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'style', 'systemLanguage', 'transform', 'width', 'x', 'y' ],