Skip to content

Commit 458d1b9

Browse files
authored
Merge pull request carbon-app#5 from TomTom2028/bugfix-transparent-bg-black-in-ppt
Supported complete tranparancy in powerpoint
2 parents 6a2cf9c + 5b94419 commit 458d1b9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/svg.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,21 @@ export async function nodeToSvg(node, config) {
139139
svg.appendChild(rectClone)
140140

141141
}
142-
svg.appendChild(rect)
142+
// if the rect color is transparent, we remove the rect
143+
let isTransparent = false
144+
if (rectStyle.backgroundColor === "transparent") {
145+
isTransparent
146+
}
147+
if (rectStyle.backgroundColor.startsWith('rgba')) {
148+
const colorParts = rectStyle.backgroundColor.split(',')
149+
const alphaPart = colorParts[3].replace(')', '').trim()
150+
if (alphaPart === '0') {
151+
isTransparent = true
152+
}
153+
}
154+
if (!isTransparent) {
155+
svg.appendChild(rect)
156+
}
143157
//console.log(rect)
144158
} else if (currentNode.tagName === "svg") {
145159
const svgElement = currentNode.cloneNode(true)

0 commit comments

Comments
 (0)