sync: convert-browser.js 同步 SVG 图标相关改动
- collectSlideChildren 保留 RECTANGLE+backgroundImages - imageRects 包含 RECTANGLE+backgroundImages - 图片处理:data URL 直接使用
This commit is contained in:
@@ -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 } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user