docgen-utils 1.0.31 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +88 -239
- package/dist/bundle.min.js +107 -107
- package/dist/cli.js +6165 -82
- package/dist/packages/cli/commands/export-slides.d.ts +4 -9
- package/dist/packages/cli/commands/export-slides.d.ts.map +1 -1
- package/dist/packages/cli/commands/export-slides.js +233 -100
- package/dist/packages/cli/commands/export-slides.js.map +1 -1
- package/dist/packages/slides/convert.d.ts +2 -0
- package/dist/packages/slides/convert.d.ts.map +1 -1
- package/dist/packages/slides/convert.js +36 -28
- package/dist/packages/slides/convert.js.map +1 -1
- package/dist/packages/slides/createPresentation.d.ts.map +1 -1
- package/dist/packages/slides/createPresentation.js +18 -18
- package/dist/packages/slides/createPresentation.js.map +1 -1
- package/dist/packages/slides/parse.d.ts.map +1 -1
- package/dist/packages/slides/parse.js +8 -211
- package/dist/packages/slides/parse.js.map +1 -1
- package/package.json +1 -1
|
@@ -85,39 +85,6 @@ function extractZIndex(computed) {
|
|
|
85
85
|
return undefined;
|
|
86
86
|
return parsed;
|
|
87
87
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Get the effective z-index for an element, considering stacking context inheritance.
|
|
90
|
-
*
|
|
91
|
-
* In CSS, z-index only applies to positioned elements (absolute, relative, fixed, sticky).
|
|
92
|
-
* Child elements participate in their ancestor's stacking context. This function walks
|
|
93
|
-
* up the DOM tree to find the nearest stacking context (positioned element with z-index)
|
|
94
|
-
* and returns that z-index value.
|
|
95
|
-
*
|
|
96
|
-
* This is needed because when parsing individual elements, a text element inside a
|
|
97
|
-
* z-index:10 container doesn't have its own z-index, but visually appears at z-index:10.
|
|
98
|
-
*
|
|
99
|
-
* @param element - The element to check
|
|
100
|
-
* @param win - The window object for getComputedStyle
|
|
101
|
-
* @returns The effective z-index from the nearest stacking context, or undefined if none
|
|
102
|
-
*/
|
|
103
|
-
function getEffectiveZIndex(element, win) {
|
|
104
|
-
let current = element;
|
|
105
|
-
while (current && current !== win.document.body && current !== win.document.documentElement) {
|
|
106
|
-
const computed = win.getComputedStyle(current);
|
|
107
|
-
const position = computed.position;
|
|
108
|
-
// Check if this element creates a stacking context (positioned with z-index)
|
|
109
|
-
const isPositioned = position === 'absolute' || position === 'relative' ||
|
|
110
|
-
position === 'fixed' || position === 'sticky';
|
|
111
|
-
if (isPositioned) {
|
|
112
|
-
const zIndex = extractZIndex(computed);
|
|
113
|
-
if (zIndex !== undefined) {
|
|
114
|
-
return zIndex;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
current = current.parentElement;
|
|
118
|
-
}
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
88
|
/**
|
|
122
89
|
* Compute the effective (accumulated) opacity for an element by multiplying
|
|
123
90
|
* the element's own opacity with all ancestor opacities.
|
|
@@ -2656,7 +2623,7 @@ export function parseSlideHtml(doc) {
|
|
|
2656
2623
|
cssTriangle: null,
|
|
2657
2624
|
customGeometry: null,
|
|
2658
2625
|
},
|
|
2659
|
-
zIndex:
|
|
2626
|
+
zIndex: extractZIndex(computed),
|
|
2660
2627
|
};
|
|
2661
2628
|
elements.push(shapeElement);
|
|
2662
2629
|
// Handle accent borders (border-left/border-right) that are thicker than the base
|
|
@@ -2756,7 +2723,6 @@ export function parseSlideHtml(doc) {
|
|
|
2756
2723
|
cssTriangle: null,
|
|
2757
2724
|
customGeometry: points,
|
|
2758
2725
|
},
|
|
2759
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
2760
2726
|
};
|
|
2761
2727
|
elements.push(borderLeftShape);
|
|
2762
2728
|
}
|
|
@@ -2787,7 +2753,6 @@ export function parseSlideHtml(doc) {
|
|
|
2787
2753
|
cssTriangle: null,
|
|
2788
2754
|
customGeometry: null,
|
|
2789
2755
|
},
|
|
2790
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
2791
2756
|
};
|
|
2792
2757
|
elements.push(borderLeftShape);
|
|
2793
2758
|
}
|
|
@@ -2865,7 +2830,6 @@ export function parseSlideHtml(doc) {
|
|
|
2865
2830
|
cssTriangle: null,
|
|
2866
2831
|
customGeometry: points,
|
|
2867
2832
|
},
|
|
2868
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
2869
2833
|
};
|
|
2870
2834
|
elements.push(borderRightShape);
|
|
2871
2835
|
}
|
|
@@ -2895,7 +2859,6 @@ export function parseSlideHtml(doc) {
|
|
|
2895
2859
|
cssTriangle: null,
|
|
2896
2860
|
customGeometry: null,
|
|
2897
2861
|
},
|
|
2898
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
2899
2862
|
};
|
|
2900
2863
|
elements.push(borderRightShape);
|
|
2901
2864
|
}
|
|
@@ -2977,7 +2940,6 @@ export function parseSlideHtml(doc) {
|
|
|
2977
2940
|
cssTriangle: null,
|
|
2978
2941
|
customGeometry: points,
|
|
2979
2942
|
},
|
|
2980
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
2981
2943
|
};
|
|
2982
2944
|
elements.push(borderTopShape);
|
|
2983
2945
|
}
|
|
@@ -3007,7 +2969,6 @@ export function parseSlideHtml(doc) {
|
|
|
3007
2969
|
cssTriangle: null,
|
|
3008
2970
|
customGeometry: null,
|
|
3009
2971
|
},
|
|
3010
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3011
2972
|
};
|
|
3012
2973
|
elements.push(borderTopShape);
|
|
3013
2974
|
}
|
|
@@ -3082,7 +3043,6 @@ export function parseSlideHtml(doc) {
|
|
|
3082
3043
|
cssTriangle: null,
|
|
3083
3044
|
customGeometry: points,
|
|
3084
3045
|
},
|
|
3085
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3086
3046
|
};
|
|
3087
3047
|
elements.push(borderBottomShape);
|
|
3088
3048
|
}
|
|
@@ -3112,7 +3072,6 @@ export function parseSlideHtml(doc) {
|
|
|
3112
3072
|
cssTriangle: null,
|
|
3113
3073
|
customGeometry: null,
|
|
3114
3074
|
},
|
|
3115
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3116
3075
|
};
|
|
3117
3076
|
elements.push(borderBottomShape);
|
|
3118
3077
|
}
|
|
@@ -3253,7 +3212,7 @@ export function parseSlideHtml(doc) {
|
|
|
3253
3212
|
cssTriangle: null,
|
|
3254
3213
|
customGeometry: null,
|
|
3255
3214
|
},
|
|
3256
|
-
zIndex:
|
|
3215
|
+
zIndex: extractZIndex(computed),
|
|
3257
3216
|
};
|
|
3258
3217
|
elements.push(shapeElement);
|
|
3259
3218
|
// Handle accent borders (border-left/border-right) that are thicker than the base
|
|
@@ -3353,7 +3312,6 @@ export function parseSlideHtml(doc) {
|
|
|
3353
3312
|
cssTriangle: null,
|
|
3354
3313
|
customGeometry: points,
|
|
3355
3314
|
},
|
|
3356
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3357
3315
|
};
|
|
3358
3316
|
elements.push(borderLeftShape);
|
|
3359
3317
|
}
|
|
@@ -3384,7 +3342,6 @@ export function parseSlideHtml(doc) {
|
|
|
3384
3342
|
cssTriangle: null,
|
|
3385
3343
|
customGeometry: null,
|
|
3386
3344
|
},
|
|
3387
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3388
3345
|
};
|
|
3389
3346
|
elements.push(borderLeftShape);
|
|
3390
3347
|
}
|
|
@@ -3462,7 +3419,6 @@ export function parseSlideHtml(doc) {
|
|
|
3462
3419
|
cssTriangle: null,
|
|
3463
3420
|
customGeometry: points,
|
|
3464
3421
|
},
|
|
3465
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3466
3422
|
};
|
|
3467
3423
|
elements.push(borderRightShape);
|
|
3468
3424
|
}
|
|
@@ -3492,7 +3448,6 @@ export function parseSlideHtml(doc) {
|
|
|
3492
3448
|
cssTriangle: null,
|
|
3493
3449
|
customGeometry: null,
|
|
3494
3450
|
},
|
|
3495
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3496
3451
|
};
|
|
3497
3452
|
elements.push(borderRightShape);
|
|
3498
3453
|
}
|
|
@@ -3574,7 +3529,6 @@ export function parseSlideHtml(doc) {
|
|
|
3574
3529
|
cssTriangle: null,
|
|
3575
3530
|
customGeometry: points,
|
|
3576
3531
|
},
|
|
3577
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3578
3532
|
};
|
|
3579
3533
|
elements.push(borderTopShape);
|
|
3580
3534
|
}
|
|
@@ -3604,7 +3558,6 @@ export function parseSlideHtml(doc) {
|
|
|
3604
3558
|
cssTriangle: null,
|
|
3605
3559
|
customGeometry: null,
|
|
3606
3560
|
},
|
|
3607
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3608
3561
|
};
|
|
3609
3562
|
elements.push(borderTopShape);
|
|
3610
3563
|
}
|
|
@@ -3771,7 +3724,6 @@ export function parseSlideHtml(doc) {
|
|
|
3771
3724
|
fontFill: spanFontFill,
|
|
3772
3725
|
...(extractAlpha(computed2.color) !== null ? { transparency: extractAlpha(computed2.color) } : {}),
|
|
3773
3726
|
},
|
|
3774
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
3775
3727
|
};
|
|
3776
3728
|
elements.push(textElement);
|
|
3777
3729
|
processed.add(el);
|
|
@@ -3971,11 +3923,6 @@ export function parseSlideHtml(doc) {
|
|
|
3971
3923
|
if (hasOpacity && !maskApplied) {
|
|
3972
3924
|
imageElement.transparency = Math.round((1 - imgOpacity) * 100);
|
|
3973
3925
|
}
|
|
3974
|
-
// Add z-index for stacking order
|
|
3975
|
-
const imgZIndex = getEffectiveZIndex(el, win);
|
|
3976
|
-
if (imgZIndex !== undefined) {
|
|
3977
|
-
imageElement.zIndex = imgZIndex;
|
|
3978
|
-
}
|
|
3979
3926
|
elements.push(imageElement);
|
|
3980
3927
|
processed.add(el);
|
|
3981
3928
|
return;
|
|
@@ -4190,7 +4137,6 @@ export function parseSlideHtml(doc) {
|
|
|
4190
4137
|
},
|
|
4191
4138
|
sizing: null,
|
|
4192
4139
|
transparency: svgEffectiveOpacity < 1 ? Math.round((1 - svgEffectiveOpacity) * 100) : undefined,
|
|
4193
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4194
4140
|
};
|
|
4195
4141
|
elements.push(imageElement);
|
|
4196
4142
|
processed.add(el);
|
|
@@ -4282,7 +4228,6 @@ export function parseSlideHtml(doc) {
|
|
|
4282
4228
|
h: pxToInch(rect.height),
|
|
4283
4229
|
},
|
|
4284
4230
|
sizing: null,
|
|
4285
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4286
4231
|
};
|
|
4287
4232
|
elements.push(imageElement);
|
|
4288
4233
|
}
|
|
@@ -4325,7 +4270,6 @@ export function parseSlideHtml(doc) {
|
|
|
4325
4270
|
},
|
|
4326
4271
|
sizing: null,
|
|
4327
4272
|
rectRadius: 0,
|
|
4328
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4329
4273
|
};
|
|
4330
4274
|
elements.push(imgElement);
|
|
4331
4275
|
processed.add(el);
|
|
@@ -4360,7 +4304,6 @@ export function parseSlideHtml(doc) {
|
|
|
4360
4304
|
},
|
|
4361
4305
|
sizing: null,
|
|
4362
4306
|
rectRadius: 0,
|
|
4363
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4364
4307
|
};
|
|
4365
4308
|
elements.push(imgElement);
|
|
4366
4309
|
hasConicGradientImage = true;
|
|
@@ -4457,7 +4400,6 @@ export function parseSlideHtml(doc) {
|
|
|
4457
4400
|
cssTriangle: { direction: triangleDirection },
|
|
4458
4401
|
customGeometry: null,
|
|
4459
4402
|
},
|
|
4460
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4461
4403
|
};
|
|
4462
4404
|
elements.push(triangleShape);
|
|
4463
4405
|
processed.add(el);
|
|
@@ -4508,7 +4450,6 @@ export function parseSlideHtml(doc) {
|
|
|
4508
4450
|
sizing: null,
|
|
4509
4451
|
rectRadius: 0,
|
|
4510
4452
|
transparency: effOp < 1 ? Math.round((1 - effOp) * 100) : undefined,
|
|
4511
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4512
4453
|
};
|
|
4513
4454
|
elements.push(imgElement);
|
|
4514
4455
|
}
|
|
@@ -4650,7 +4591,6 @@ export function parseSlideHtml(doc) {
|
|
|
4650
4591
|
cssTriangle: null,
|
|
4651
4592
|
customGeometry: points,
|
|
4652
4593
|
},
|
|
4653
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4654
4594
|
});
|
|
4655
4595
|
}
|
|
4656
4596
|
else {
|
|
@@ -4680,7 +4620,6 @@ export function parseSlideHtml(doc) {
|
|
|
4680
4620
|
cssTriangle: null,
|
|
4681
4621
|
customGeometry: null,
|
|
4682
4622
|
},
|
|
4683
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4684
4623
|
});
|
|
4685
4624
|
}
|
|
4686
4625
|
}
|
|
@@ -4771,7 +4710,6 @@ export function parseSlideHtml(doc) {
|
|
|
4771
4710
|
cssTriangle: null,
|
|
4772
4711
|
customGeometry: points,
|
|
4773
4712
|
},
|
|
4774
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4775
4713
|
});
|
|
4776
4714
|
}
|
|
4777
4715
|
else {
|
|
@@ -4800,7 +4738,6 @@ export function parseSlideHtml(doc) {
|
|
|
4800
4738
|
cssTriangle: null,
|
|
4801
4739
|
customGeometry: null,
|
|
4802
4740
|
},
|
|
4803
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4804
4741
|
});
|
|
4805
4742
|
}
|
|
4806
4743
|
}
|
|
@@ -4888,7 +4825,6 @@ export function parseSlideHtml(doc) {
|
|
|
4888
4825
|
cssTriangle: null,
|
|
4889
4826
|
customGeometry: points,
|
|
4890
4827
|
},
|
|
4891
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4892
4828
|
});
|
|
4893
4829
|
}
|
|
4894
4830
|
else {
|
|
@@ -4917,7 +4853,6 @@ export function parseSlideHtml(doc) {
|
|
|
4917
4853
|
cssTriangle: null,
|
|
4918
4854
|
customGeometry: null,
|
|
4919
4855
|
},
|
|
4920
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
4921
4856
|
});
|
|
4922
4857
|
}
|
|
4923
4858
|
}
|
|
@@ -5001,7 +4936,6 @@ export function parseSlideHtml(doc) {
|
|
|
5001
4936
|
cssTriangle: null,
|
|
5002
4937
|
customGeometry: points,
|
|
5003
4938
|
},
|
|
5004
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
5005
4939
|
});
|
|
5006
4940
|
}
|
|
5007
4941
|
else {
|
|
@@ -5030,7 +4964,6 @@ export function parseSlideHtml(doc) {
|
|
|
5030
4964
|
cssTriangle: null,
|
|
5031
4965
|
customGeometry: null,
|
|
5032
4966
|
},
|
|
5033
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
5034
4967
|
});
|
|
5035
4968
|
}
|
|
5036
4969
|
}
|
|
@@ -5058,7 +4991,6 @@ export function parseSlideHtml(doc) {
|
|
|
5058
4991
|
: 'cover',
|
|
5059
4992
|
position: bgImagePosition,
|
|
5060
4993
|
},
|
|
5061
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
5062
4994
|
};
|
|
5063
4995
|
elements.push(bgImgElement);
|
|
5064
4996
|
}
|
|
@@ -6320,7 +6252,7 @@ export function parseSlideHtml(doc) {
|
|
|
6320
6252
|
return points;
|
|
6321
6253
|
})() : null),
|
|
6322
6254
|
},
|
|
6323
|
-
zIndex:
|
|
6255
|
+
zIndex: extractZIndex(computed),
|
|
6324
6256
|
};
|
|
6325
6257
|
// Apply CSS padding as text body insets when shape has text content
|
|
6326
6258
|
if (hasPadding && shapeElement.style && (shapeText || (shapeTextRuns && shapeTextRuns.length > 0))) {
|
|
@@ -6364,67 +6296,6 @@ export function parseSlideHtml(doc) {
|
|
|
6364
6296
|
tc.querySelectorAll('*').forEach(desc => processed.delete(desc));
|
|
6365
6297
|
});
|
|
6366
6298
|
}
|
|
6367
|
-
// When a flex container has direct text nodes that weren't merged into the shape,
|
|
6368
|
-
// extract them as separate text elements. This handles cases like:
|
|
6369
|
-
// <div class="flex"><svg>...</svg>Label Text<span>...</span></div>
|
|
6370
|
-
// where "Label Text" is a direct text node between other elements.
|
|
6371
|
-
if (!shouldMergeText && hasDirectText && directTextContent) {
|
|
6372
|
-
// Calculate approximate position for the direct text
|
|
6373
|
-
// For flex-row, text appears after any preceding elements
|
|
6374
|
-
// We use a Range to get the exact bounding box of the text nodes
|
|
6375
|
-
const range = win.document.createRange();
|
|
6376
|
-
let foundTextNode = false;
|
|
6377
|
-
// Find the text nodes and calculate their bounding rect
|
|
6378
|
-
for (const node of Array.from(el.childNodes)) {
|
|
6379
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
6380
|
-
const text = (node.textContent || '').trim();
|
|
6381
|
-
if (text) {
|
|
6382
|
-
if (!foundTextNode) {
|
|
6383
|
-
range.setStart(node, 0);
|
|
6384
|
-
foundTextNode = true;
|
|
6385
|
-
}
|
|
6386
|
-
range.setEnd(node, node.textContent?.length || 0);
|
|
6387
|
-
}
|
|
6388
|
-
}
|
|
6389
|
-
}
|
|
6390
|
-
if (foundTextNode) {
|
|
6391
|
-
const textRect = range.getBoundingClientRect();
|
|
6392
|
-
if (textRect.width > 0 && textRect.height > 0) {
|
|
6393
|
-
const isBold = parseInt(computed.fontWeight) >= 600;
|
|
6394
|
-
const isItalic = computed.fontStyle === 'italic';
|
|
6395
|
-
const isUnderline = computed.textDecoration && computed.textDecoration.includes('underline');
|
|
6396
|
-
// Apply text-transform
|
|
6397
|
-
let displayText = directTextContent;
|
|
6398
|
-
if (computed.textTransform && computed.textTransform !== 'none') {
|
|
6399
|
-
displayText = applyTextTransform(displayText, computed.textTransform);
|
|
6400
|
-
}
|
|
6401
|
-
const directTextElement = {
|
|
6402
|
-
type: 'p',
|
|
6403
|
-
text: displayText,
|
|
6404
|
-
position: {
|
|
6405
|
-
x: pxToInch(textRect.left),
|
|
6406
|
-
y: pxToInch(textRect.top),
|
|
6407
|
-
w: pxToInch(textRect.width),
|
|
6408
|
-
h: pxToInch(textRect.height),
|
|
6409
|
-
},
|
|
6410
|
-
style: {
|
|
6411
|
-
fontSize: pxToPoints(computed.fontSize),
|
|
6412
|
-
fontFace: extractFontFace(computed.fontFamily),
|
|
6413
|
-
color: rgbToHex(computed.color),
|
|
6414
|
-
bold: isBold,
|
|
6415
|
-
italic: isItalic,
|
|
6416
|
-
underline: isUnderline ? true : undefined,
|
|
6417
|
-
valign: 'middle',
|
|
6418
|
-
align: 'left',
|
|
6419
|
-
...(extractLetterSpacing(computed) !== null ? { charSpacing: extractLetterSpacing(computed) } : {}),
|
|
6420
|
-
...(extractAlpha(computed.color) !== null ? { transparency: extractAlpha(computed.color) } : {}),
|
|
6421
|
-
},
|
|
6422
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
6423
|
-
};
|
|
6424
|
-
elements.push(directTextElement);
|
|
6425
|
-
}
|
|
6426
|
-
}
|
|
6427
|
-
}
|
|
6428
6299
|
// If we split text from a clipped shape, create a separate text-only shape
|
|
6429
6300
|
// Note: PPTX does NOT clip text to custom geometry paths - text is rendered
|
|
6430
6301
|
// within the bounding box regardless of the path shape. So we DON'T apply
|
|
@@ -6474,7 +6345,6 @@ export function parseSlideHtml(doc) {
|
|
|
6474
6345
|
cssTriangle: null,
|
|
6475
6346
|
customGeometry: null, // NO custom geometry - PPTX doesn't clip text to paths
|
|
6476
6347
|
},
|
|
6477
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
6478
6348
|
};
|
|
6479
6349
|
// Apply CSS padding as text body insets
|
|
6480
6350
|
if (hasPadding && clippedTextShape.style) {
|
|
@@ -6517,7 +6387,6 @@ export function parseSlideHtml(doc) {
|
|
|
6517
6387
|
cssTriangle: null,
|
|
6518
6388
|
customGeometry: null,
|
|
6519
6389
|
},
|
|
6520
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
6521
6390
|
};
|
|
6522
6391
|
elements.push(extraShape);
|
|
6523
6392
|
}
|
|
@@ -6703,66 +6572,6 @@ export function parseSlideHtml(doc) {
|
|
|
6703
6572
|
// Fallback to direct text only if there are structural children
|
|
6704
6573
|
extractedText = directText;
|
|
6705
6574
|
}
|
|
6706
|
-
// Handle flex-row containers with direct text nodes AND structural children
|
|
6707
|
-
// (e.g., <div class="flex"><svg>...</svg>Label Text<span>...</span></div>)
|
|
6708
|
-
// In this case, extract the direct text nodes as a separate element
|
|
6709
|
-
// using Range API to get precise positioning
|
|
6710
|
-
if (isPlainDivFlexRow && directText && hasStructuralChildren) {
|
|
6711
|
-
// Use Range API to get the bounding box of direct text nodes
|
|
6712
|
-
const range = win.document.createRange();
|
|
6713
|
-
let foundTextNode = false;
|
|
6714
|
-
for (const node of Array.from(el.childNodes)) {
|
|
6715
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
6716
|
-
const text = (node.textContent || '').trim();
|
|
6717
|
-
if (text) {
|
|
6718
|
-
if (!foundTextNode) {
|
|
6719
|
-
range.setStart(node, 0);
|
|
6720
|
-
foundTextNode = true;
|
|
6721
|
-
}
|
|
6722
|
-
range.setEnd(node, node.textContent?.length || 0);
|
|
6723
|
-
}
|
|
6724
|
-
}
|
|
6725
|
-
}
|
|
6726
|
-
if (foundTextNode) {
|
|
6727
|
-
const textRect = range.getBoundingClientRect();
|
|
6728
|
-
if (textRect.width > 0 && textRect.height > 0) {
|
|
6729
|
-
const computed2 = win.getComputedStyle(el);
|
|
6730
|
-
const isBold = parseInt(computed2.fontWeight) >= 600;
|
|
6731
|
-
const isItalic = computed2.fontStyle === 'italic';
|
|
6732
|
-
const isUnderline = computed2.textDecoration && computed2.textDecoration.includes('underline');
|
|
6733
|
-
// Apply text-transform
|
|
6734
|
-
let displayText = directText;
|
|
6735
|
-
if (computed2.textTransform && computed2.textTransform !== 'none') {
|
|
6736
|
-
displayText = applyTextTransform(displayText, computed2.textTransform);
|
|
6737
|
-
}
|
|
6738
|
-
const flexDirectTextElement = {
|
|
6739
|
-
type: 'p',
|
|
6740
|
-
text: displayText,
|
|
6741
|
-
position: {
|
|
6742
|
-
x: pxToInch(textRect.left),
|
|
6743
|
-
y: pxToInch(textRect.top),
|
|
6744
|
-
w: pxToInch(textRect.width),
|
|
6745
|
-
h: pxToInch(textRect.height),
|
|
6746
|
-
},
|
|
6747
|
-
style: {
|
|
6748
|
-
fontSize: pxToPoints(computed2.fontSize),
|
|
6749
|
-
fontFace: extractFontFace(computed2.fontFamily),
|
|
6750
|
-
color: rgbToHex(computed2.color),
|
|
6751
|
-
bold: isBold,
|
|
6752
|
-
italic: isItalic,
|
|
6753
|
-
underline: isUnderline ? true : undefined,
|
|
6754
|
-
valign: 'middle',
|
|
6755
|
-
align: 'left',
|
|
6756
|
-
...(extractLetterSpacing(computed2) !== null ? { charSpacing: extractLetterSpacing(computed2) } : {}),
|
|
6757
|
-
...(extractAlpha(computed2.color) !== null ? { transparency: extractAlpha(computed2.color) } : {}),
|
|
6758
|
-
},
|
|
6759
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
6760
|
-
};
|
|
6761
|
-
elements.push(flexDirectTextElement);
|
|
6762
|
-
// Don't mark as processed - structural children still need extraction
|
|
6763
|
-
}
|
|
6764
|
-
}
|
|
6765
|
-
}
|
|
6766
6575
|
if (extractedText && !hasStructuralChildren) {
|
|
6767
6576
|
const computed2 = win.getComputedStyle(el);
|
|
6768
6577
|
const fontSizePx = parseFloat(computed2.fontSize);
|
|
@@ -6943,7 +6752,6 @@ export function parseSlideHtml(doc) {
|
|
|
6943
6752
|
? [paddingLeft * PT_PER_PX, paddingRight * PT_PER_PX, paddingBottom * PT_PER_PX, paddingTop * PT_PER_PX]
|
|
6944
6753
|
: undefined,
|
|
6945
6754
|
},
|
|
6946
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
6947
6755
|
};
|
|
6948
6756
|
// Set element-level transparency (computed from color alpha + CSS opacity)
|
|
6949
6757
|
// This mirrors what we set in baseRunOptions.transparency but also
|
|
@@ -7054,7 +6862,6 @@ export function parseSlideHtml(doc) {
|
|
|
7054
6862
|
valign: 'top',
|
|
7055
6863
|
lineSpacing: pxToPoints(liComputed.lineHeight),
|
|
7056
6864
|
},
|
|
7057
|
-
zIndex: getEffectiveZIndex(liEl, win),
|
|
7058
6865
|
};
|
|
7059
6866
|
elements.push(textElement);
|
|
7060
6867
|
processed.add(liEl);
|
|
@@ -7108,7 +6915,6 @@ export function parseSlideHtml(doc) {
|
|
|
7108
6915
|
paraSpaceAfter: pxToPoints(liComputed.marginBottom),
|
|
7109
6916
|
margin: [marginLeft, 0, 0, 0],
|
|
7110
6917
|
},
|
|
7111
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
7112
6918
|
};
|
|
7113
6919
|
elements.push(listElement);
|
|
7114
6920
|
liElements.forEach((li) => processed.add(li));
|
|
@@ -7434,7 +7240,6 @@ export function parseSlideHtml(doc) {
|
|
|
7434
7240
|
text: runs,
|
|
7435
7241
|
position: { x: pxToInch(x), y: pxToInch(y), w: pxToInch(w), h: pxToInch(h) },
|
|
7436
7242
|
style: baseStyle,
|
|
7437
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
7438
7243
|
};
|
|
7439
7244
|
elements.push(textElement);
|
|
7440
7245
|
}
|
|
@@ -7452,7 +7257,6 @@ export function parseSlideHtml(doc) {
|
|
|
7452
7257
|
italic: computed.fontStyle === 'italic',
|
|
7453
7258
|
underline: computed.textDecoration.includes('underline'),
|
|
7454
7259
|
},
|
|
7455
|
-
zIndex: getEffectiveZIndex(el, win),
|
|
7456
7260
|
};
|
|
7457
7261
|
elements.push(textElement);
|
|
7458
7262
|
}
|
|
@@ -7494,18 +7298,11 @@ export function parseSlideHtml(doc) {
|
|
|
7494
7298
|
// PPTX renders shapes in XML order (later = on top), so we sort by z-index
|
|
7495
7299
|
// to ensure elements with higher z-index appear later in the array.
|
|
7496
7300
|
// Elements without z-index (undefined) are treated as z-index: 0.
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
const zIndexB = ('zIndex' in b.el && b.el.zIndex !== undefined) ? b.el.zIndex : 0;
|
|
7502
|
-
if (zIndexA !== zIndexB) {
|
|
7503
|
-
return zIndexA - zIndexB;
|
|
7504
|
-
}
|
|
7505
|
-
// When z-indexes are equal, preserve DOM order
|
|
7506
|
-
return a.originalIndex - b.originalIndex;
|
|
7301
|
+
elements.sort((a, b) => {
|
|
7302
|
+
const zIndexA = ('zIndex' in a && a.zIndex !== undefined) ? a.zIndex : 0;
|
|
7303
|
+
const zIndexB = ('zIndex' in b && b.zIndex !== undefined) ? b.zIndex : 0;
|
|
7304
|
+
return zIndexA - zIndexB;
|
|
7507
7305
|
});
|
|
7508
|
-
|
|
7509
|
-
return { background, elements: sortedElements, placeholders, errors };
|
|
7306
|
+
return { background, elements, placeholders, errors };
|
|
7510
7307
|
}
|
|
7511
7308
|
//# sourceMappingURL=parse.js.map
|