From f0e82341b8afbaadc9965d51714afd84f363d24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=9B?= Date: Mon, 27 Jul 2026 16:50:54 +0800 Subject: [PATCH] =?UTF-8?q?sync:=20convert-browser.js=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=20SVG=20=E5=9B=BE=E6=A0=87=E7=9B=B8=E5=85=B3=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - collectSlideChildren 保留 RECTANGLE+backgroundImages - imageRects 包含 RECTANGLE+backgroundImages - 图片处理:data URL 直接使用 --- web-to-ppt/convert-browser.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web-to-ppt/convert-browser.js b/web-to-ppt/convert-browser.js index 2bf7868..95faac9 100644 --- a/web-to-ppt/convert-browser.js +++ b/web-to-ppt/convert-browser.js @@ -76,7 +76,7 @@ function collectSlideChildren(node, slideX, slideY, parentW, depth) { const nr = node.rect; const rw = nr.width ?? nr.w; const rh = nr.height ?? nr.h; - if (node.type !== 'RECTANGLE' && node.layerGroup !== 'comparison') { + if ((node.type !== 'RECTANGLE' || (node.backgroundImages && node.backgroundImages.length > 0)) && node.layerGroup !== 'comparison') { results.push({ id: node.id, type: node.type, name: node.name, tag: node.tag, rect: { x: nr.x - slideX, y: nr.y - slideY, w: rw, h: rh }, @@ -232,7 +232,7 @@ async function convertToPptx(input, onProgress) { sg.children.sort((a, b) => (parseInt(a.styles?.zIndex) || 0) - (parseInt(b.styles?.zIndex) || 0)); // 重叠去重 - const imageRects = sg.children.filter(c => c.type === 'IMAGE' && c.rect).map(c => ({ + const imageRects = sg.children.filter(c => (c.type === 'IMAGE' || (c.type === 'RECTANGLE' && c.backgroundImages?.length > 0)) && c.rect).map(c => ({ x: Math.round(c.rect.x), y: Math.round(c.rect.y), w: Math.round(c.rect.w), h: Math.round(c.rect.h), z: parseInt(c.styles?.zIndex) || 0 @@ -398,8 +398,14 @@ async function convertToPptx(input, onProgress) { if ((n.type === 'IMAGE' || n.type === 'RECTANGLE') && n.backgroundImages?.length > 0) { var imgKey = n.backgroundImages[0]; var asset = assets[imgKey]; - if (asset?.data) { - objects.push({ type: 'image', options: { x: opts.x, y: opts.y, w: opts.w, h: opts.h, data: asset.data } }); + var imgData; + if (imgKey.startsWith('data:')) { + imgData = imgKey; + } else if (asset?.data) { + imgData = asset.data; + } + if (imgData) { + objects.push({ type: 'image', options: { x: opts.x, y: opts.y, w: opts.w, h: opts.h, data: imgData } }); } }