diff options
Diffstat (limited to 'subprojects/frontend/src/graph/postProcessSVG.ts')
-rw-r--r-- | subprojects/frontend/src/graph/postProcessSVG.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/subprojects/frontend/src/graph/postProcessSVG.ts b/subprojects/frontend/src/graph/postProcessSVG.ts index a580f5c6..bf990f3a 100644 --- a/subprojects/frontend/src/graph/postProcessSVG.ts +++ b/subprojects/frontend/src/graph/postProcessSVG.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import { type BBox, parsePolygonBBox, parsePathBBox } from './parseBBox'; | 7 | import { type BBox, parsePolygonBBox, parsePathBBox } from './parseBBox'; |
8 | 8 | ||
9 | const SVG_NS = 'http://www.w3.org/2000/svg'; | 9 | export const SVG_NS = 'http://www.w3.org/2000/svg'; |
10 | const XLINK_NS = 'http://www.w3.org/1999/xlink'; | 10 | export const XLINK_NS = 'http://www.w3.org/1999/xlink'; |
11 | 11 | ||
12 | function modifyAttribute(element: Element, attribute: string, change: number) { | 12 | function modifyAttribute(element: Element, attribute: string, change: number) { |
13 | const valueString = element.getAttribute(attribute); | 13 | const valueString = element.getAttribute(attribute); |
@@ -166,6 +166,32 @@ function replaceImages(node: SVGGElement) { | |||
166 | }); | 166 | }); |
167 | } | 167 | } |
168 | 168 | ||
169 | function markerColorToClass(svg: SVGSVGElement) { | ||
170 | svg.querySelectorAll('.node [stroke="black"]').forEach((node) => { | ||
171 | node.removeAttribute('stroke'); | ||
172 | node.classList.add('node-outline'); | ||
173 | }); | ||
174 | svg.querySelectorAll('.node [fill="green"]').forEach((node) => { | ||
175 | node.removeAttribute('fill'); | ||
176 | node.classList.add('node-header'); | ||
177 | }); | ||
178 | svg.querySelectorAll('.node [fill="white"]').forEach((node) => { | ||
179 | node.removeAttribute('fill'); | ||
180 | node.classList.add('node-bg'); | ||
181 | }); | ||
182 | svg.querySelectorAll('.edge [stroke="black"]').forEach((node) => { | ||
183 | node.removeAttribute('stroke'); | ||
184 | node.classList.add('edge-line'); | ||
185 | }); | ||
186 | svg.querySelectorAll('.edge [fill="black"]').forEach((node) => { | ||
187 | node.removeAttribute('fill'); | ||
188 | node.classList.add('edge-arrow'); | ||
189 | }); | ||
190 | svg.querySelectorAll('[font-family]').forEach((node) => { | ||
191 | node.removeAttribute('font-family'); | ||
192 | }); | ||
193 | } | ||
194 | |||
169 | export default function postProcessSvg(svg: SVGSVGElement) { | 195 | export default function postProcessSvg(svg: SVGSVGElement) { |
170 | // svg | 196 | // svg |
171 | // .querySelectorAll<SVGTitleElement>('title') | 197 | // .querySelectorAll<SVGTitleElement>('title') |
@@ -183,4 +209,5 @@ export default function postProcessSvg(svg: SVGSVGElement) { | |||
183 | svg.viewBox.baseVal.height + 12, | 209 | svg.viewBox.baseVal.height + 12, |
184 | ]; | 210 | ]; |
185 | svg.setAttribute('viewBox', viewBox.join(' ')); | 211 | svg.setAttribute('viewBox', viewBox.join(' ')); |
212 | markerColorToClass(svg); | ||
186 | } | 213 | } |