diff --git a/web-to-ppt/capture.js b/web-to-ppt/capture.js index a09d913..77043c5 100644 --- a/web-to-ppt/capture.js +++ b/web-to-ppt/capture.js @@ -984,6 +984,18 @@ const afterNode = pseudoElementToCaptureNode(element, "::after", clientRect, assetUrls, ownClip, childContext); pushCaptureChild(children, afterNode); + // SVG → 序列化为 data URL 图片 + if (element.tagName === "SVG" && !backgroundUrls.length) { + try { + const svgClone = element.cloneNode(true); + // 确保有 xmlns + if (!svgClone.getAttribute('xmlns')) svgClone.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); + const svgStr = new XMLSerializer().serializeToString(svgClone); + const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgStr))); + backgroundUrls = [svgDataUrl]; + } catch (e) { /* 静默失败 */ } + } + const type = element.tagName === "IMG" || backgroundUrls.length ? "RECTANGLE" : "FRAME"; return { id: `node-${++nodeCounter}`,