pptx-glimpse 3.1.1 → 3.2.0
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/browser.cjs +2123 -956
- package/dist/browser.d.cts +36 -4
- package/dist/browser.d.ts +36 -4
- package/dist/browser.js +410 -8
- package/dist/{chunk-AQ35JYTB.js → chunk-CX4ZDTKK.js} +1659 -884
- package/dist/{chunk-3UFL5U77.js → chunk-KELC7JQK.js} +1 -1
- package/dist/{chunk-5YFLSUKM.js → chunk-KY3SYR3V.js} +1 -1
- package/dist/cli.cjs +1617 -1584
- package/dist/cli.js +2 -2
- package/dist/index.cjs +1617 -1584
- package/dist/index.js +3 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -6629,1739 +6629,1754 @@ function parseEnumValue(value, allowed) {
|
|
|
6629
6629
|
function parseEnumValueWithDefault(value, allowed, fallback) {
|
|
6630
6630
|
return parseEnumValue(value, allowed) ?? fallback;
|
|
6631
6631
|
}
|
|
6632
|
-
var
|
|
6633
|
-
|
|
6634
|
-
"
|
|
6632
|
+
var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
|
|
6633
|
+
"tl",
|
|
6634
|
+
"t",
|
|
6635
|
+
"tr",
|
|
6636
|
+
"l",
|
|
6637
|
+
"ctr",
|
|
6635
6638
|
"r",
|
|
6636
|
-
"
|
|
6637
|
-
"
|
|
6638
|
-
"
|
|
6639
|
+
"bl",
|
|
6640
|
+
"b",
|
|
6641
|
+
"br"
|
|
6639
6642
|
]);
|
|
6640
|
-
var
|
|
6641
|
-
|
|
6642
|
-
"
|
|
6643
|
-
"
|
|
6644
|
-
"
|
|
6645
|
-
"
|
|
6643
|
+
var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
|
|
6644
|
+
"lumMod",
|
|
6645
|
+
"lumOff",
|
|
6646
|
+
"tint",
|
|
6647
|
+
"shade",
|
|
6648
|
+
"alpha"
|
|
6646
6649
|
]);
|
|
6647
|
-
var
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6650
|
+
var RAW_FILL_LOCAL_NAMES = ["grpFill"];
|
|
6651
|
+
var PRESET_COLOR_HEX = {
|
|
6652
|
+
black: "000000",
|
|
6653
|
+
white: "FFFFFF",
|
|
6654
|
+
red: "FF0000",
|
|
6655
|
+
green: "008000",
|
|
6656
|
+
blue: "0000FF",
|
|
6657
|
+
yellow: "FFFF00",
|
|
6658
|
+
cyan: "00FFFF",
|
|
6659
|
+
magenta: "FF00FF"
|
|
6657
6660
|
};
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
"
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
"
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
});
|
|
6687
|
-
const paragraphs = [];
|
|
6688
|
-
let logicalParagraphIndex = 0;
|
|
6689
|
-
getChildArray(txBody, "p").forEach((p, paragraphIndex) => {
|
|
6690
|
-
const orderedChildren = orderedParagraphs?.[paragraphIndex];
|
|
6691
|
-
if (orderedChildren !== void 0 && hasMultipleBulletPPr(p, orderedChildren)) {
|
|
6692
|
-
const split = splitInterleavedParagraph(
|
|
6693
|
-
p,
|
|
6694
|
-
orderedChildren,
|
|
6695
|
-
partPath,
|
|
6696
|
-
nextId,
|
|
6697
|
-
ownerNodeId,
|
|
6698
|
-
ownerOrderingSlot,
|
|
6699
|
-
logicalParagraphIndex
|
|
6661
|
+
function parseColorElement(parent) {
|
|
6662
|
+
if (!parent) return void 0;
|
|
6663
|
+
const srgb = getChild(parent, "srgbClr");
|
|
6664
|
+
if (srgb) {
|
|
6665
|
+
const hex = getAttr(srgb, "val");
|
|
6666
|
+
if (hex !== void 0) {
|
|
6667
|
+
return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
6670
|
+
const scheme = getChild(parent, "schemeClr");
|
|
6671
|
+
if (scheme) {
|
|
6672
|
+
const name = getAttr(scheme, "val");
|
|
6673
|
+
if (name !== void 0) {
|
|
6674
|
+
return withTransforms({ kind: "scheme", scheme: name }, scheme);
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
const sys = getChild(parent, "sysClr");
|
|
6678
|
+
if (sys) {
|
|
6679
|
+
const val = getAttr(sys, "val");
|
|
6680
|
+
if (val !== void 0) {
|
|
6681
|
+
const lastClr = getAttr(sys, "lastClr");
|
|
6682
|
+
return withTransforms(
|
|
6683
|
+
{
|
|
6684
|
+
kind: "system",
|
|
6685
|
+
value: val,
|
|
6686
|
+
...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
|
|
6687
|
+
},
|
|
6688
|
+
sys
|
|
6700
6689
|
);
|
|
6701
|
-
paragraphs.push(...split);
|
|
6702
|
-
logicalParagraphIndex += split.length;
|
|
6703
|
-
return;
|
|
6704
6690
|
}
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6691
|
+
}
|
|
6692
|
+
return void 0;
|
|
6693
|
+
}
|
|
6694
|
+
function parseEffectList(effectList) {
|
|
6695
|
+
if (effectList === void 0) return void 0;
|
|
6696
|
+
const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
|
|
6697
|
+
const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
|
|
6698
|
+
const glow = parseGlow(getChild(effectList, "glow"));
|
|
6699
|
+
const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
|
|
6700
|
+
const parsed = {
|
|
6701
|
+
...outerShadow !== void 0 ? { outerShadow } : {},
|
|
6702
|
+
...innerShadow !== void 0 ? { innerShadow } : {},
|
|
6703
|
+
...glow !== void 0 ? { glow } : {},
|
|
6704
|
+
...softEdge !== void 0 ? { softEdge } : {}
|
|
6705
|
+
};
|
|
6706
|
+
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
6707
|
+
}
|
|
6708
|
+
function parseBlipEffects(blip) {
|
|
6709
|
+
if (blip === void 0) return void 0;
|
|
6710
|
+
const grayscale = getChild(blip, "grayscl") !== void 0;
|
|
6711
|
+
const biLevel = parseBiLevel(getChild(blip, "biLevel"));
|
|
6712
|
+
const blur = parseBlurEffect(getChild(blip, "blur"));
|
|
6713
|
+
const lum = parseLumEffect(getChild(blip, "lum"));
|
|
6714
|
+
const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
|
|
6715
|
+
const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
|
|
6716
|
+
const parsed = {
|
|
6717
|
+
grayscale,
|
|
6718
|
+
...biLevel !== void 0 ? { biLevel } : {},
|
|
6719
|
+
...blur !== void 0 ? { blur } : {},
|
|
6720
|
+
...lum !== void 0 ? { lum } : {},
|
|
6721
|
+
...duotone !== void 0 ? { duotone } : {},
|
|
6722
|
+
...clrChange !== void 0 ? { clrChange } : {}
|
|
6723
|
+
};
|
|
6724
|
+
return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
|
|
6725
|
+
}
|
|
6726
|
+
function parseOuterShadow(node) {
|
|
6727
|
+
if (node === void 0) return void 0;
|
|
6728
|
+
const color = parseColorElement(node);
|
|
6729
|
+
if (color === void 0) return void 0;
|
|
6719
6730
|
return {
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6731
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
6732
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
6733
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
6734
|
+
color,
|
|
6735
|
+
alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
|
|
6736
|
+
rotateWithShape: getAttr(node, "rotWithShape") !== "0"
|
|
6725
6737
|
};
|
|
6726
6738
|
}
|
|
6727
|
-
function
|
|
6739
|
+
function parseInnerShadow(node) {
|
|
6728
6740
|
if (node === void 0) return void 0;
|
|
6729
|
-
const
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
}
|
|
6737
|
-
return { ...defaultParagraph !== void 0 ? { defaultParagraph } : {}, levels };
|
|
6741
|
+
const color = parseColorElement(node);
|
|
6742
|
+
if (color === void 0) return void 0;
|
|
6743
|
+
return {
|
|
6744
|
+
blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
|
|
6745
|
+
distance: asEmu2(numericAttr2(node, "dist") ?? 0),
|
|
6746
|
+
direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
|
|
6747
|
+
color
|
|
6748
|
+
};
|
|
6738
6749
|
}
|
|
6739
|
-
function
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
bulletPPrCount++;
|
|
6748
|
-
if (bulletPPrCount >= 2) return true;
|
|
6749
|
-
}
|
|
6750
|
-
pPrCounter++;
|
|
6751
|
-
}
|
|
6752
|
-
return false;
|
|
6750
|
+
function parseGlow(node) {
|
|
6751
|
+
if (node === void 0) return void 0;
|
|
6752
|
+
const color = parseColorElement(node);
|
|
6753
|
+
if (color === void 0) return void 0;
|
|
6754
|
+
return {
|
|
6755
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0),
|
|
6756
|
+
color
|
|
6757
|
+
};
|
|
6753
6758
|
}
|
|
6754
|
-
function
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
const brList = getChildArray(p, "br");
|
|
6759
|
-
const groups = [];
|
|
6760
|
-
let currentGroup;
|
|
6761
|
-
let pPrCounter = 0;
|
|
6762
|
-
let runCounter = 0;
|
|
6763
|
-
let fieldCounter = 0;
|
|
6764
|
-
let breakCounter = 0;
|
|
6765
|
-
for (const child of orderedChildren) {
|
|
6766
|
-
const tag = orderedLocalName(child);
|
|
6767
|
-
if (tag === "pPr") {
|
|
6768
|
-
const pPr = pPrList[pPrCounter];
|
|
6769
|
-
const hasBullet = pPr !== void 0 && (getChild(pPr, "buChar") !== void 0 || getChild(pPr, "buAutoNum") !== void 0);
|
|
6770
|
-
if (hasBullet || currentGroup === void 0) {
|
|
6771
|
-
if (currentGroup !== void 0) groups.push(currentGroup);
|
|
6772
|
-
currentGroup = {
|
|
6773
|
-
pPrIndex: pPrCounter,
|
|
6774
|
-
rNodes: [],
|
|
6775
|
-
fldNodes: [],
|
|
6776
|
-
brNodes: [],
|
|
6777
|
-
orderedChildren: [child]
|
|
6778
|
-
};
|
|
6779
|
-
} else {
|
|
6780
|
-
currentGroup.orderedChildren.push(child);
|
|
6781
|
-
}
|
|
6782
|
-
pPrCounter++;
|
|
6783
|
-
} else if (tag === "r") {
|
|
6784
|
-
currentGroup ??= {
|
|
6785
|
-
pPrIndex: -1,
|
|
6786
|
-
rNodes: [],
|
|
6787
|
-
fldNodes: [],
|
|
6788
|
-
brNodes: [],
|
|
6789
|
-
orderedChildren: []
|
|
6790
|
-
};
|
|
6791
|
-
currentGroup.orderedChildren.push(child);
|
|
6792
|
-
if (rList[runCounter] !== void 0) currentGroup.rNodes.push(rList[runCounter]);
|
|
6793
|
-
runCounter++;
|
|
6794
|
-
} else if (tag === "fld") {
|
|
6795
|
-
currentGroup ??= {
|
|
6796
|
-
pPrIndex: -1,
|
|
6797
|
-
rNodes: [],
|
|
6798
|
-
fldNodes: [],
|
|
6799
|
-
brNodes: [],
|
|
6800
|
-
orderedChildren: []
|
|
6801
|
-
};
|
|
6802
|
-
currentGroup.orderedChildren.push(child);
|
|
6803
|
-
if (fldList[fieldCounter] !== void 0) currentGroup.fldNodes.push(fldList[fieldCounter]);
|
|
6804
|
-
fieldCounter++;
|
|
6805
|
-
} else if (tag === "br") {
|
|
6806
|
-
currentGroup ??= {
|
|
6807
|
-
pPrIndex: -1,
|
|
6808
|
-
rNodes: [],
|
|
6809
|
-
fldNodes: [],
|
|
6810
|
-
brNodes: [],
|
|
6811
|
-
orderedChildren: []
|
|
6812
|
-
};
|
|
6813
|
-
currentGroup.orderedChildren.push(child);
|
|
6814
|
-
if (brList[breakCounter] !== void 0) currentGroup.brNodes.push(brList[breakCounter]);
|
|
6815
|
-
breakCounter++;
|
|
6816
|
-
}
|
|
6817
|
-
}
|
|
6818
|
-
if (currentGroup !== void 0) groups.push(currentGroup);
|
|
6819
|
-
return groups.map((group, groupIndex) => {
|
|
6820
|
-
const synthetic = {};
|
|
6821
|
-
if (group.pPrIndex >= 0) synthetic.pPr = pPrList[group.pPrIndex];
|
|
6822
|
-
synthetic.r = group.rNodes;
|
|
6823
|
-
synthetic.fld = group.fldNodes;
|
|
6824
|
-
synthetic.br = group.brNodes;
|
|
6825
|
-
if (groupIndex === groups.length - 1 && getChild(p, "endParaRPr") !== void 0) {
|
|
6826
|
-
synthetic.endParaRPr = getChild(p, "endParaRPr");
|
|
6827
|
-
}
|
|
6828
|
-
const paragraph = parseParagraph(
|
|
6829
|
-
synthetic,
|
|
6830
|
-
partPath,
|
|
6831
|
-
nextId,
|
|
6832
|
-
ownerNodeId,
|
|
6833
|
-
ownerOrderingSlot,
|
|
6834
|
-
paragraphIndex + groupIndex,
|
|
6835
|
-
group.orderedChildren
|
|
6836
|
-
);
|
|
6837
|
-
if (groupIndex < groups.length - 1 && paragraph.runs.length > 0) {
|
|
6838
|
-
const lastRun = paragraph.runs[paragraph.runs.length - 1];
|
|
6839
|
-
if (lastRun.text.endsWith("\n")) {
|
|
6840
|
-
const trimmed = lastRun.text.slice(0, -1);
|
|
6841
|
-
const precedingRuns = paragraph.runs.slice(0, -1);
|
|
6842
|
-
return {
|
|
6843
|
-
...paragraph,
|
|
6844
|
-
runs: trimmed === "" ? precedingRuns : [...precedingRuns, { ...lastRun, text: trimmed }]
|
|
6845
|
-
};
|
|
6846
|
-
}
|
|
6847
|
-
}
|
|
6848
|
-
return paragraph;
|
|
6849
|
-
});
|
|
6850
|
-
}
|
|
6851
|
-
function parseBodyProperties(bodyPr) {
|
|
6852
|
-
if (!bodyPr) return void 0;
|
|
6853
|
-
const marginLeft = numericAttr2(bodyPr, "lIns");
|
|
6854
|
-
const marginRight = numericAttr2(bodyPr, "rIns");
|
|
6855
|
-
const marginTop = numericAttr2(bodyPr, "tIns");
|
|
6856
|
-
const marginBottom = numericAttr2(bodyPr, "bIns");
|
|
6857
|
-
const anchorToken = getAttr(bodyPr, "anchor");
|
|
6858
|
-
const anchor = anchorToken !== void 0 ? ANCHOR_MAP[anchorToken] : void 0;
|
|
6859
|
-
const wrap = parseWrap(getAttr(bodyPr, "wrap"));
|
|
6860
|
-
const vert = parseVerticalType(getAttr(bodyPr, "vert"));
|
|
6861
|
-
const numCol = numericAttr2(bodyPr, "numCol");
|
|
6862
|
-
const normAutofit = getChild(bodyPr, "normAutofit");
|
|
6863
|
-
const hasSpAutofit = getChild(bodyPr, "spAutoFit") !== void 0;
|
|
6864
|
-
const hasNoAutofit = getChild(bodyPr, "noAutofit") !== void 0;
|
|
6865
|
-
const fontScale = numericAttr2(normAutofit, "fontScale");
|
|
6866
|
-
const lnSpcReduction = numericAttr2(normAutofit, "lnSpcReduction");
|
|
6867
|
-
const properties = {
|
|
6868
|
-
...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
|
|
6869
|
-
...marginRight !== void 0 ? { marginRight: emu(marginRight) } : {},
|
|
6870
|
-
...marginTop !== void 0 ? { marginTop: emu(marginTop) } : {},
|
|
6871
|
-
...marginBottom !== void 0 ? { marginBottom: emu(marginBottom) } : {},
|
|
6872
|
-
...anchor !== void 0 ? { anchor } : {},
|
|
6873
|
-
...wrap !== void 0 ? { wrap } : {},
|
|
6874
|
-
...normAutofit !== void 0 ? {
|
|
6875
|
-
autoFit: "normAutofit",
|
|
6876
|
-
fontScale: fontScale !== void 0 ? fontScale / 1e5 : 1,
|
|
6877
|
-
lnSpcReduction: lnSpcReduction !== void 0 ? lnSpcReduction / 1e5 : 0
|
|
6878
|
-
} : hasSpAutofit ? { autoFit: "spAutofit", fontScale: 1, lnSpcReduction: 0 } : hasNoAutofit ? { autoFit: "noAutofit", fontScale: 1, lnSpcReduction: 0 } : {},
|
|
6879
|
-
...numCol !== void 0 ? { numCol: Math.max(1, numCol) } : {},
|
|
6880
|
-
...vert !== void 0 ? { vert } : {}
|
|
6759
|
+
function parseSoftEdge(node) {
|
|
6760
|
+
if (node === void 0) return void 0;
|
|
6761
|
+
return {
|
|
6762
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0)
|
|
6881
6763
|
};
|
|
6882
|
-
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
6883
6764
|
}
|
|
6884
|
-
function
|
|
6885
|
-
|
|
6765
|
+
function parseBiLevel(node) {
|
|
6766
|
+
if (node === void 0) return void 0;
|
|
6767
|
+
return {
|
|
6768
|
+
threshold: (numericAttr2(node, "thresh") ?? 5e4) / 1e5
|
|
6769
|
+
};
|
|
6886
6770
|
}
|
|
6887
|
-
function
|
|
6888
|
-
|
|
6771
|
+
function parseBlurEffect(node) {
|
|
6772
|
+
if (node === void 0) return void 0;
|
|
6773
|
+
return {
|
|
6774
|
+
radius: asEmu2(numericAttr2(node, "rad") ?? 0),
|
|
6775
|
+
grow: getAttr(node, "grow") !== "0"
|
|
6776
|
+
};
|
|
6889
6777
|
}
|
|
6890
|
-
function
|
|
6891
|
-
|
|
6892
|
-
const runs = parseRunsInOrder(
|
|
6893
|
-
p,
|
|
6894
|
-
partPath,
|
|
6895
|
-
nextId,
|
|
6896
|
-
ownerNodeId,
|
|
6897
|
-
ownerOrderingSlot,
|
|
6898
|
-
paragraphIndex,
|
|
6899
|
-
orderedChildren
|
|
6900
|
-
);
|
|
6901
|
-
const rawSidecars = collectUnknownSidecars(p, KNOWN_PARAGRAPH_CHILDREN, nextId);
|
|
6778
|
+
function parseLumEffect(node) {
|
|
6779
|
+
if (node === void 0) return void 0;
|
|
6902
6780
|
return {
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
handle: {
|
|
6906
|
-
partPath,
|
|
6907
|
-
nodeId: textNodeId("paragraph", ownerNodeId, ownerOrderingSlot, paragraphIndex),
|
|
6908
|
-
orderingSlot: paragraphIndex
|
|
6909
|
-
},
|
|
6910
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
6781
|
+
brightness: (numericAttr2(node, "bright") ?? 0) / 1e5,
|
|
6782
|
+
contrast: (numericAttr2(node, "contrast") ?? 0) / 1e5
|
|
6911
6783
|
};
|
|
6912
6784
|
}
|
|
6913
|
-
function
|
|
6914
|
-
|
|
6915
|
-
const
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
)
|
|
6933
|
-
|
|
6934
|
-
(br, index) => parseBreakRun(
|
|
6935
|
-
br,
|
|
6936
|
-
partPath,
|
|
6937
|
-
nextId,
|
|
6938
|
-
ownerNodeId,
|
|
6939
|
-
ownerOrderingSlot,
|
|
6940
|
-
paragraphIndex,
|
|
6941
|
-
rList.length + fldList.length + index
|
|
6942
|
-
)
|
|
6943
|
-
)
|
|
6944
|
-
];
|
|
6945
|
-
}
|
|
6946
|
-
const counters = {};
|
|
6947
|
-
const runs = [];
|
|
6948
|
-
for (const child of orderedChildren) {
|
|
6949
|
-
const tag = orderedLocalName(child);
|
|
6950
|
-
if (tag !== "r" && tag !== "fld" && tag !== "br") continue;
|
|
6951
|
-
const index = counters[tag] ?? 0;
|
|
6952
|
-
counters[tag] = index + 1;
|
|
6953
|
-
const runIndex = runs.length;
|
|
6954
|
-
if (tag === "r" && rList[index] !== void 0) {
|
|
6955
|
-
runs.push(
|
|
6956
|
-
parseRun(
|
|
6957
|
-
rList[index],
|
|
6958
|
-
partPath,
|
|
6959
|
-
nextId,
|
|
6960
|
-
ownerNodeId,
|
|
6961
|
-
ownerOrderingSlot,
|
|
6962
|
-
paragraphIndex,
|
|
6963
|
-
runIndex
|
|
6964
|
-
)
|
|
6965
|
-
);
|
|
6966
|
-
} else if (tag === "fld" && fldList[index] !== void 0) {
|
|
6967
|
-
runs.push(
|
|
6968
|
-
parseRun(
|
|
6969
|
-
fldList[index],
|
|
6970
|
-
partPath,
|
|
6971
|
-
nextId,
|
|
6972
|
-
ownerNodeId,
|
|
6973
|
-
ownerOrderingSlot,
|
|
6974
|
-
paragraphIndex,
|
|
6975
|
-
runIndex
|
|
6976
|
-
)
|
|
6977
|
-
);
|
|
6978
|
-
} else if (tag === "br" && brList[index] !== void 0) {
|
|
6979
|
-
runs.push(
|
|
6980
|
-
parseBreakRun(
|
|
6981
|
-
brList[index],
|
|
6982
|
-
partPath,
|
|
6983
|
-
nextId,
|
|
6984
|
-
ownerNodeId,
|
|
6985
|
-
ownerOrderingSlot,
|
|
6986
|
-
paragraphIndex,
|
|
6987
|
-
runIndex
|
|
6988
|
-
)
|
|
6989
|
-
);
|
|
6785
|
+
function parseDuotoneEffect(node) {
|
|
6786
|
+
if (node === void 0) return void 0;
|
|
6787
|
+
const colors = collectColorChildren(node);
|
|
6788
|
+
if (colors.length < 2) return void 0;
|
|
6789
|
+
return { color1: colors[0], color2: colors[1] };
|
|
6790
|
+
}
|
|
6791
|
+
function parseColorChangeEffect(node) {
|
|
6792
|
+
if (node === void 0) return void 0;
|
|
6793
|
+
const from = firstColorChild(getChild(node, "clrFrom"));
|
|
6794
|
+
const to = firstColorChild(getChild(node, "clrTo"));
|
|
6795
|
+
return from !== void 0 && to !== void 0 ? { from, to } : void 0;
|
|
6796
|
+
}
|
|
6797
|
+
function collectColorChildren(parent) {
|
|
6798
|
+
const colors = [];
|
|
6799
|
+
for (const [key, value] of Object.entries(parent)) {
|
|
6800
|
+
if (key.startsWith("@_")) continue;
|
|
6801
|
+
const nodes = Array.isArray(value) ? value : [value];
|
|
6802
|
+
for (const node of nodes) {
|
|
6803
|
+
if (!isXmlNode(node)) continue;
|
|
6804
|
+
const color = parseColorChild(key, node);
|
|
6805
|
+
if (color !== void 0) colors.push(color);
|
|
6990
6806
|
}
|
|
6991
6807
|
}
|
|
6992
|
-
return
|
|
6808
|
+
return colors;
|
|
6993
6809
|
}
|
|
6994
|
-
function
|
|
6995
|
-
|
|
6996
|
-
const alignToken = getAttr(pPr, "algn");
|
|
6997
|
-
const align = alignToken !== void 0 ? ALIGN_MAP[alignToken] : void 0;
|
|
6998
|
-
const level = numericAttr2(pPr, "lvl");
|
|
6999
|
-
const lineSpacing = parseSpacing(getChild(pPr, "lnSpc"));
|
|
7000
|
-
const spaceBefore = parseSpacing(getChild(pPr, "spcBef"));
|
|
7001
|
-
const spaceAfter = parseSpacing(getChild(pPr, "spcAft"));
|
|
7002
|
-
const marginLeft = numericAttr2(pPr, "marL");
|
|
7003
|
-
const indent = numericAttr2(pPr, "indent");
|
|
7004
|
-
const bullet = parseBullet(pPr);
|
|
7005
|
-
const bulletFont = getAttr(getChild(pPr, "buFont"), "typeface");
|
|
7006
|
-
const bulletColor = parseColorElement(getChild(pPr, "buClr"));
|
|
7007
|
-
const bulletSizePct = numericAttr2(getChild(pPr, "buSzPct"), "val");
|
|
7008
|
-
const tabStops = parseTabStops(pPr);
|
|
7009
|
-
const defaultRunProperties = parseRunProperties(getChild(pPr, "defRPr"));
|
|
7010
|
-
const properties = {
|
|
7011
|
-
...align !== void 0 ? { align } : {},
|
|
7012
|
-
...level !== void 0 ? { level } : {},
|
|
7013
|
-
...lineSpacing !== void 0 ? { lineSpacing } : {},
|
|
7014
|
-
...spaceBefore !== void 0 ? { spaceBefore } : {},
|
|
7015
|
-
...spaceAfter !== void 0 ? { spaceAfter } : {},
|
|
7016
|
-
...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
|
|
7017
|
-
...indent !== void 0 ? { indent: emu(indent) } : {},
|
|
7018
|
-
...bullet !== void 0 ? { bullet } : {},
|
|
7019
|
-
...bulletFont !== void 0 ? { bulletFont } : {},
|
|
7020
|
-
...bulletColor !== void 0 ? { bulletColor } : {},
|
|
7021
|
-
...bulletSizePct !== void 0 ? { bulletSizePct } : {},
|
|
7022
|
-
...tabStops.length > 0 ? { tabStops } : {},
|
|
7023
|
-
...defaultRunProperties !== void 0 ? { defaultRunProperties } : {}
|
|
7024
|
-
};
|
|
7025
|
-
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
6810
|
+
function firstColorChild(parent) {
|
|
6811
|
+
return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
|
|
7026
6812
|
}
|
|
7027
|
-
function
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
|
|
7031
|
-
}));
|
|
6813
|
+
function parseColorChild(key, node) {
|
|
6814
|
+
const name = localName(key);
|
|
6815
|
+
return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
|
|
7032
6816
|
}
|
|
7033
|
-
function
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
6817
|
+
function isXmlNode(value) {
|
|
6818
|
+
return typeof value === "object" && value !== null;
|
|
6819
|
+
}
|
|
6820
|
+
function parsePresetColor(node) {
|
|
6821
|
+
const value = getAttr(node, "val");
|
|
6822
|
+
const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
|
|
6823
|
+
return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
|
|
6824
|
+
}
|
|
6825
|
+
function parseFill(parent, nextId) {
|
|
6826
|
+
if (!parent) return void 0;
|
|
6827
|
+
const solid = getChild(parent, "solidFill");
|
|
6828
|
+
if (solid) {
|
|
6829
|
+
const color = parseColorElement(solid);
|
|
6830
|
+
if (color) return { kind: "solid", color };
|
|
6831
|
+
return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
|
|
6832
|
+
}
|
|
6833
|
+
if (hasChild(parent, "noFill")) return { kind: "none" };
|
|
6834
|
+
const grad = getChild(parent, "gradFill");
|
|
6835
|
+
if (grad) {
|
|
6836
|
+
const fill = parseGradientFill(grad);
|
|
6837
|
+
return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
|
|
6838
|
+
}
|
|
6839
|
+
const blip = getChild(parent, "blipFill");
|
|
6840
|
+
if (blip) {
|
|
6841
|
+
return parseBlipFill(blip) ?? { kind: "raw", raw: makeSidecar("a:blipFill", blip, nextId) };
|
|
6842
|
+
}
|
|
6843
|
+
const pattern = getChild(parent, "pattFill");
|
|
6844
|
+
if (pattern) {
|
|
6845
|
+
const fill = parsePatternFill(pattern);
|
|
6846
|
+
return fill ?? { kind: "raw", raw: makeSidecar("a:pattFill", pattern, nextId) };
|
|
6847
|
+
}
|
|
6848
|
+
for (const name of RAW_FILL_LOCAL_NAMES) {
|
|
6849
|
+
if (hasChild(parent, name)) {
|
|
6850
|
+
return { kind: "raw", raw: makeSidecar(`a:${name}`, getChild(parent, name) ?? {}, nextId) };
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
7038
6853
|
return void 0;
|
|
7039
6854
|
}
|
|
7040
|
-
function
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
6855
|
+
function parseGradientFill(grad) {
|
|
6856
|
+
const stops = [];
|
|
6857
|
+
for (const gs of getChildArray(getChild(grad, "gsLst"), "gs")) {
|
|
6858
|
+
const color = parseColorElement(gs);
|
|
6859
|
+
if (color === void 0) continue;
|
|
6860
|
+
stops.push({
|
|
6861
|
+
position: (numericAttr2(gs, "pos") ?? 0) / 1e5,
|
|
6862
|
+
color
|
|
6863
|
+
});
|
|
7046
6864
|
}
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
6865
|
+
if (stops.length === 0) return void 0;
|
|
6866
|
+
const path = getChild(grad, "path");
|
|
6867
|
+
if (path !== void 0) {
|
|
6868
|
+
const fillToRect = getChild(path, "fillToRect");
|
|
6869
|
+
const l = numericAttr2(fillToRect, "l") ?? 0;
|
|
6870
|
+
const t = numericAttr2(fillToRect, "t") ?? 0;
|
|
6871
|
+
const r = numericAttr2(fillToRect, "r") ?? 0;
|
|
6872
|
+
const b = numericAttr2(fillToRect, "b") ?? 0;
|
|
7050
6873
|
return {
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
6874
|
+
kind: "gradient",
|
|
6875
|
+
gradientType: "radial",
|
|
6876
|
+
stops,
|
|
6877
|
+
centerX: (l + (1e5 - r)) / 2 / 1e5,
|
|
6878
|
+
centerY: (t + (1e5 - b)) / 2 / 1e5
|
|
7054
6879
|
};
|
|
7055
6880
|
}
|
|
7056
|
-
return void 0;
|
|
7057
|
-
}
|
|
7058
|
-
function decodeXmlCharRef(value) {
|
|
7059
|
-
return value.replace(
|
|
7060
|
-
/&#x([0-9a-fA-F]+);|&#([0-9]+);/g,
|
|
7061
|
-
(_match, hex, decimal) => String.fromCodePoint(parseInt(hex ?? decimal ?? "0", hex !== void 0 ? 16 : 10))
|
|
7062
|
-
);
|
|
7063
|
-
}
|
|
7064
|
-
function parseRun(r, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7065
|
-
const properties = parseRunProperties(getChild(r, "rPr"));
|
|
7066
|
-
const rawSidecars = collectRunSidecars(r, nextId);
|
|
7067
6881
|
return {
|
|
7068
|
-
kind: "
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
partPath,
|
|
7073
|
-
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7074
|
-
orderingSlot: runIndex
|
|
7075
|
-
},
|
|
7076
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
6882
|
+
kind: "gradient",
|
|
6883
|
+
gradientType: "linear",
|
|
6884
|
+
stops,
|
|
6885
|
+
angle: asOoxmlAngle(numericAttr2(getChild(grad, "lin"), "ang") ?? 0)
|
|
7077
6886
|
};
|
|
7078
6887
|
}
|
|
7079
|
-
function
|
|
7080
|
-
const
|
|
6888
|
+
function parseBlipFill(blipFill) {
|
|
6889
|
+
const blip = getChild(blipFill, "blip");
|
|
6890
|
+
const embed = getNamespacedAttr(blip, "embed");
|
|
6891
|
+
if (embed === void 0) return void 0;
|
|
6892
|
+
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
7081
6893
|
return {
|
|
7082
|
-
kind: "
|
|
7083
|
-
|
|
7084
|
-
...
|
|
7085
|
-
handle: {
|
|
7086
|
-
partPath,
|
|
7087
|
-
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7088
|
-
orderingSlot: runIndex
|
|
7089
|
-
}
|
|
6894
|
+
kind: "image",
|
|
6895
|
+
blipRelationshipId: asRelationshipId(embed),
|
|
6896
|
+
...tile !== void 0 ? { tile } : {}
|
|
7090
6897
|
};
|
|
7091
6898
|
}
|
|
7092
|
-
function
|
|
7093
|
-
if (
|
|
7094
|
-
const
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
|
|
7103
|
-
const hasHyperlink = getChild(rPr, "hlinkClick") !== void 0;
|
|
7104
|
-
const color = parseColorElement(getChild(rPr, "solidFill"));
|
|
7105
|
-
const properties = {
|
|
7106
|
-
...bold !== void 0 ? { bold: isTrue(bold) } : {},
|
|
7107
|
-
...italic !== void 0 ? { italic: isTrue(italic) } : {},
|
|
7108
|
-
...underline !== void 0 ? { underline: underline !== "none" } : hasHyperlink ? { underline: true } : {},
|
|
7109
|
-
...strike !== void 0 ? { strikethrough: strike !== "noStrike" } : {},
|
|
7110
|
-
...baseline !== void 0 ? { baseline: baseline / 1e3 } : {},
|
|
7111
|
-
// `a:rPr@sz` is in 1/100 pt unit. Convert to pt and save.
|
|
7112
|
-
...size !== void 0 ? { fontSize: asPt(size / 100) } : {},
|
|
7113
|
-
...typeface !== void 0 ? { typeface } : {},
|
|
7114
|
-
...typefaceEa !== void 0 ? { typefaceEa } : {},
|
|
7115
|
-
...typefaceCs !== void 0 ? { typefaceCs } : {},
|
|
7116
|
-
...color !== void 0 ? { color } : hasHyperlink ? { color: { kind: "scheme", scheme: "hlink" } } : {}
|
|
6899
|
+
function parseImageFillTile(tile) {
|
|
6900
|
+
if (tile === void 0) return void 0;
|
|
6901
|
+
const flip = getAttr(tile, "flip") ?? "none";
|
|
6902
|
+
return {
|
|
6903
|
+
tx: asEmu2(numericAttr2(tile, "tx") ?? 0),
|
|
6904
|
+
ty: asEmu2(numericAttr2(tile, "ty") ?? 0),
|
|
6905
|
+
sx: (numericAttr2(tile, "sx") ?? 1e5) / 1e5,
|
|
6906
|
+
sy: (numericAttr2(tile, "sy") ?? 1e5) / 1e5,
|
|
6907
|
+
flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
|
|
6908
|
+
align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
|
|
7117
6909
|
};
|
|
7118
|
-
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7119
6910
|
}
|
|
7120
|
-
function
|
|
7121
|
-
|
|
7122
|
-
const propLevel = collectUnknownSidecars(getChild(r, "rPr"), KNOWN_RUN_PROPERTY_CHILDREN, nextId);
|
|
7123
|
-
return [...runLevel, ...propLevel];
|
|
6911
|
+
function parseRectangleAlignment(value, fallback) {
|
|
6912
|
+
return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
|
|
7124
6913
|
}
|
|
7125
|
-
function
|
|
7126
|
-
|
|
6914
|
+
function parsePatternFill(pattern) {
|
|
6915
|
+
const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
|
|
6916
|
+
const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
|
|
6917
|
+
if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
|
|
6918
|
+
return {
|
|
6919
|
+
kind: "pattern",
|
|
6920
|
+
preset: getAttr(pattern, "prst") ?? "ltDnDiag",
|
|
6921
|
+
foregroundColor,
|
|
6922
|
+
backgroundColor
|
|
6923
|
+
};
|
|
7127
6924
|
}
|
|
7128
|
-
function
|
|
7129
|
-
const
|
|
7130
|
-
|
|
7131
|
-
return asSourceNodeId(`text:${owner}:${suffix}`);
|
|
6925
|
+
function parseOutline(spPr, nextId) {
|
|
6926
|
+
const ln = getChild(spPr, "ln");
|
|
6927
|
+
return parseLine(ln, nextId);
|
|
7132
6928
|
}
|
|
7133
|
-
function
|
|
7134
|
-
|
|
6929
|
+
function parseLine(ln, nextId) {
|
|
6930
|
+
if (!ln) return void 0;
|
|
6931
|
+
const width = numericAttr2(ln, "w");
|
|
6932
|
+
const fill = parseFill(ln, nextId);
|
|
6933
|
+
const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
|
|
6934
|
+
const customDash = parseCustomDash(ln);
|
|
6935
|
+
const lineCap = parseLineCap(getAttr(ln, "cap"));
|
|
6936
|
+
const lineJoin = parseLineJoin(ln);
|
|
6937
|
+
const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
|
|
6938
|
+
const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
|
|
6939
|
+
return {
|
|
6940
|
+
...width !== void 0 ? { width: asEmu2(width) } : {},
|
|
6941
|
+
...fill !== void 0 ? { fill } : {},
|
|
6942
|
+
...dashStyle !== void 0 ? { dashStyle } : {},
|
|
6943
|
+
...customDash !== void 0 ? { customDash } : {},
|
|
6944
|
+
...lineCap !== void 0 ? { lineCap } : {},
|
|
6945
|
+
...lineJoin !== void 0 ? { lineJoin } : {},
|
|
6946
|
+
...headEnd !== void 0 ? { headEnd } : {},
|
|
6947
|
+
...tailEnd !== void 0 ? { tailEnd } : {}
|
|
6948
|
+
};
|
|
7135
6949
|
}
|
|
7136
|
-
function
|
|
7137
|
-
const
|
|
7138
|
-
|
|
6950
|
+
function parseTransform(spPr) {
|
|
6951
|
+
const xfrm = getChild(spPr, "xfrm");
|
|
6952
|
+
if (!xfrm) return void 0;
|
|
6953
|
+
const off = getChild(xfrm, "off");
|
|
6954
|
+
const ext = getChild(xfrm, "ext");
|
|
6955
|
+
const offsetX = numericAttr2(off, "x");
|
|
6956
|
+
const offsetY = numericAttr2(off, "y");
|
|
6957
|
+
const width = numericAttr2(ext, "cx");
|
|
6958
|
+
const height = numericAttr2(ext, "cy");
|
|
6959
|
+
if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
|
|
6960
|
+
return void 0;
|
|
6961
|
+
}
|
|
6962
|
+
const rotation = numericAttr2(xfrm, "rot");
|
|
6963
|
+
const flipH = getAttr(xfrm, "flipH");
|
|
6964
|
+
const flipV = getAttr(xfrm, "flipV");
|
|
6965
|
+
return {
|
|
6966
|
+
offsetX: asEmu2(offsetX),
|
|
6967
|
+
offsetY: asEmu2(offsetY),
|
|
6968
|
+
width: asEmu2(width),
|
|
6969
|
+
height: asEmu2(height),
|
|
6970
|
+
...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
|
|
6971
|
+
...isTrue(flipH) ? { flipHorizontal: true } : {},
|
|
6972
|
+
...isTrue(flipV) ? { flipVertical: true } : {}
|
|
6973
|
+
};
|
|
7139
6974
|
}
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
var KNOWN_PICTURE_CHILDREN = /* @__PURE__ */ new Set(["nvPicPr", "blipFill", "spPr"]);
|
|
7144
|
-
var KNOWN_BLIP_FILL_CHILDREN = /* @__PURE__ */ new Set([
|
|
7145
|
-
"blip",
|
|
7146
|
-
"srcRect",
|
|
7147
|
-
"stretch",
|
|
7148
|
-
"tile"
|
|
7149
|
-
]);
|
|
7150
|
-
var KNOWN_BLIP_CHILDREN = /* @__PURE__ */ new Set([
|
|
7151
|
-
"grayscl",
|
|
7152
|
-
"biLevel",
|
|
7153
|
-
"blur",
|
|
7154
|
-
"lum",
|
|
7155
|
-
"duotone",
|
|
7156
|
-
"clrChange"
|
|
7157
|
-
]);
|
|
7158
|
-
var KNOWN_EFFECT_CHILDREN = /* @__PURE__ */ new Set([
|
|
7159
|
-
"outerShdw",
|
|
7160
|
-
"innerShdw",
|
|
7161
|
-
"glow",
|
|
7162
|
-
"softEdge"
|
|
7163
|
-
]);
|
|
7164
|
-
var KNOWN_GRAPHIC_FRAME_CHILDREN = /* @__PURE__ */ new Set([
|
|
7165
|
-
"nvGraphicFramePr",
|
|
7166
|
-
"xfrm",
|
|
7167
|
-
"graphic"
|
|
7168
|
-
]);
|
|
7169
|
-
var KNOWN_GRAPHIC_CHILDREN = /* @__PURE__ */ new Set(["graphicData"]);
|
|
7170
|
-
var KNOWN_GRAPHIC_DATA_CHILDREN = /* @__PURE__ */ new Set(["tbl"]);
|
|
7171
|
-
var KNOWN_TABLE_CHILDREN = /* @__PURE__ */ new Set(["tblPr", "tblGrid", "tr"]);
|
|
7172
|
-
var KNOWN_TABLE_CELL_CHILDREN = /* @__PURE__ */ new Set(["txBody", "tcPr"]);
|
|
7173
|
-
var KNOWN_TABLE_CELL_PROPERTIES_CHILDREN = /* @__PURE__ */ new Set([
|
|
7174
|
-
"lnL",
|
|
7175
|
-
"lnR",
|
|
7176
|
-
"lnT",
|
|
7177
|
-
"lnB",
|
|
7178
|
-
"solidFill",
|
|
7179
|
-
"noFill",
|
|
7180
|
-
"gradFill",
|
|
7181
|
-
"blipFill",
|
|
7182
|
-
"pattFill",
|
|
7183
|
-
"grpFill"
|
|
7184
|
-
]);
|
|
7185
|
-
var KNOWN_SP_PR_CHILDREN = /* @__PURE__ */ new Set([
|
|
7186
|
-
"xfrm",
|
|
7187
|
-
"prstGeom",
|
|
7188
|
-
"solidFill",
|
|
7189
|
-
"noFill",
|
|
7190
|
-
"gradFill",
|
|
7191
|
-
"blipFill",
|
|
7192
|
-
"pattFill",
|
|
7193
|
-
"grpFill",
|
|
7194
|
-
"ln",
|
|
7195
|
-
"effectLst"
|
|
7196
|
-
]);
|
|
7197
|
-
var SHAPE_TREE_NODE_TAGS = /* @__PURE__ */ new Set([
|
|
7198
|
-
"sp",
|
|
7199
|
-
"pic",
|
|
7200
|
-
"cxnSp",
|
|
7201
|
-
"grpSp",
|
|
7202
|
-
"graphicFrame"
|
|
7203
|
-
]);
|
|
7204
|
-
var CHART_GRAPHIC_DATA_URIS = /* @__PURE__ */ new Set([
|
|
7205
|
-
"http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
7206
|
-
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
7207
|
-
]);
|
|
7208
|
-
var SMARTART_DIAGRAM_URIS = /* @__PURE__ */ new Set([
|
|
7209
|
-
"http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
7210
|
-
"http://purl.oclc.org/ooxml/drawingml/diagram"
|
|
7211
|
-
]);
|
|
7212
|
-
function parseShapeTree(spTree, partPath, nextId, orderedChildren) {
|
|
7213
|
-
if (!spTree) return [];
|
|
7214
|
-
if (orderedChildren !== void 0) {
|
|
7215
|
-
return parseShapeTreeOrdered(spTree, partPath, nextId, orderedChildren);
|
|
7216
|
-
}
|
|
7217
|
-
const nodes = [];
|
|
7218
|
-
let orderingSlot = 0;
|
|
7219
|
-
for (const key of Object.keys(spTree)) {
|
|
6975
|
+
function withTransforms(base, colorNode) {
|
|
6976
|
+
const transforms = [];
|
|
6977
|
+
for (const key of Object.keys(colorNode)) {
|
|
7220
6978
|
if (key.startsWith("@_")) continue;
|
|
7221
|
-
|
|
7222
|
-
const
|
|
7223
|
-
if (
|
|
7224
|
-
const value =
|
|
6979
|
+
const kind = localName(key);
|
|
6980
|
+
const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
|
|
6981
|
+
if (transformKind === void 0) continue;
|
|
6982
|
+
const value = colorNode[key];
|
|
7225
6983
|
const items = Array.isArray(value) ? value : [value];
|
|
7226
6984
|
for (const item of items) {
|
|
7227
|
-
const
|
|
7228
|
-
if (
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
}
|
|
7235
|
-
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
7236
|
-
} else if (local === "graphicFrame") {
|
|
7237
|
-
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
7238
|
-
} else if (local === "AlternateContent") {
|
|
7239
|
-
const parsed = parseAlternateContent(node, partPath, nextId, orderingSlot);
|
|
7240
|
-
nodes.push(...parsed);
|
|
7241
|
-
} else {
|
|
7242
|
-
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
7243
|
-
}
|
|
7244
|
-
orderingSlot++;
|
|
6985
|
+
const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
|
|
6986
|
+
if (raw === void 0) continue;
|
|
6987
|
+
const numeric = Number(raw);
|
|
6988
|
+
if (!Number.isFinite(numeric)) continue;
|
|
6989
|
+
transforms.push({
|
|
6990
|
+
kind: transformKind,
|
|
6991
|
+
value: asOoxmlPercent(numeric)
|
|
6992
|
+
});
|
|
7245
6993
|
}
|
|
7246
6994
|
}
|
|
7247
|
-
return
|
|
6995
|
+
return transforms.length > 0 ? { ...base, transforms } : base;
|
|
7248
6996
|
}
|
|
7249
|
-
function
|
|
7250
|
-
const
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
7255
|
-
if (key === void 0) continue;
|
|
7256
|
-
const local = localName(key);
|
|
7257
|
-
if (local === "AlternateContent") {
|
|
7258
|
-
const index2 = tagCounters[local] ?? 0;
|
|
7259
|
-
tagCounters[local] = index2 + 1;
|
|
7260
|
-
const alternateContents = getChildArray(spTree, "AlternateContent");
|
|
7261
|
-
const alternateContent = alternateContents[index2];
|
|
7262
|
-
if (alternateContent !== void 0) {
|
|
7263
|
-
nodes.push(...parseAlternateContent(alternateContent, partPath, nextId, orderingSlot));
|
|
7264
|
-
orderingSlot++;
|
|
7265
|
-
}
|
|
7266
|
-
continue;
|
|
7267
|
-
}
|
|
7268
|
-
if (!SHAPE_TREE_NODE_TAGS.has(local)) continue;
|
|
7269
|
-
const index = tagCounters[local] ?? 0;
|
|
7270
|
-
tagCounters[local] = index + 1;
|
|
7271
|
-
const node = getChildArray(spTree, local)[index];
|
|
7272
|
-
if (node === void 0) continue;
|
|
7273
|
-
nodes.push(parseShapeTreeNode(local, node, child, partPath, nextId, orderingSlot));
|
|
7274
|
-
orderingSlot++;
|
|
7275
|
-
}
|
|
7276
|
-
return nodes;
|
|
6997
|
+
function numericAttr2(node, name) {
|
|
6998
|
+
const raw = getAttr(node, name);
|
|
6999
|
+
if (raw === void 0) return void 0;
|
|
7000
|
+
const value = Number(raw);
|
|
7001
|
+
return Number.isFinite(value) ? value : void 0;
|
|
7277
7002
|
}
|
|
7278
|
-
function
|
|
7279
|
-
|
|
7280
|
-
if (local === "pic") return parseImage(node, partPath, nextId, orderingSlot);
|
|
7281
|
-
if (local === "cxnSp") {
|
|
7282
|
-
return parseConnector(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7283
|
-
}
|
|
7284
|
-
if (local === "grpSp") {
|
|
7285
|
-
const orderedGroupChildren = unsafeOoxmlBoundaryAssertion(orderedNode?.[local]);
|
|
7286
|
-
return parseGroup(node, partPath, nextId, orderingSlot, orderedGroupChildren);
|
|
7287
|
-
}
|
|
7288
|
-
if (local === "graphicFrame") {
|
|
7289
|
-
return parseGraphicFrame(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7290
|
-
}
|
|
7291
|
-
return parseRawShapeNode(`p:${local}`, node, partPath, nextId, orderingSlot);
|
|
7003
|
+
function isTrue(value) {
|
|
7004
|
+
return value === "1" || value === "true";
|
|
7292
7005
|
}
|
|
7293
|
-
function
|
|
7294
|
-
const
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
const
|
|
7299
|
-
const
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7006
|
+
function parseDashStyle(prstDash) {
|
|
7007
|
+
const value = getAttr(prstDash, "val");
|
|
7008
|
+
return parseEnumValue(value, DASH_STYLES);
|
|
7009
|
+
}
|
|
7010
|
+
function parseCustomDash(ln) {
|
|
7011
|
+
const custDash = getChild(ln, "custDash");
|
|
7012
|
+
const segments = getChildArray(custDash, "ds");
|
|
7013
|
+
if (segments.length === 0) return void 0;
|
|
7014
|
+
return segments.flatMap((segment) => [
|
|
7015
|
+
(numericAttr2(segment, "d") ?? 1e5) / 1e5,
|
|
7016
|
+
(numericAttr2(segment, "sp") ?? 1e5) / 1e5
|
|
7017
|
+
]);
|
|
7018
|
+
}
|
|
7019
|
+
var LINE_CAP_MAP = {
|
|
7020
|
+
flat: "butt",
|
|
7021
|
+
sq: "square",
|
|
7022
|
+
rnd: "round"
|
|
7023
|
+
};
|
|
7024
|
+
function parseLineCap(value) {
|
|
7025
|
+
return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
|
|
7026
|
+
}
|
|
7027
|
+
function parseLineJoin(ln) {
|
|
7028
|
+
if (hasChild(ln, "round")) return "round";
|
|
7029
|
+
if (hasChild(ln, "bevel")) return "bevel";
|
|
7030
|
+
if (hasChild(ln, "miter")) return "miter";
|
|
7031
|
+
return void 0;
|
|
7032
|
+
}
|
|
7033
|
+
function parseArrowEndpoint(node) {
|
|
7034
|
+
if (!node) return void 0;
|
|
7035
|
+
const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES);
|
|
7036
|
+
if (type === void 0) return void 0;
|
|
7037
|
+
const width = getAttr(node, "w") ?? "med";
|
|
7038
|
+
const length = getAttr(node, "len") ?? "med";
|
|
7319
7039
|
return {
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
...transform !== void 0 ? { transform } : {},
|
|
7324
|
-
...geometry !== void 0 ? { geometry } : {},
|
|
7325
|
-
...fill !== void 0 ? { fill } : {},
|
|
7326
|
-
...outline !== void 0 ? { outline } : {},
|
|
7327
|
-
...effects !== void 0 ? { effects } : {},
|
|
7328
|
-
...style !== void 0 ? { style } : {},
|
|
7329
|
-
...textBody !== void 0 ? { textBody } : {},
|
|
7330
|
-
...placeholder !== void 0 ? { placeholder } : {},
|
|
7331
|
-
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7332
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7040
|
+
type,
|
|
7041
|
+
width: parseEnumValueWithDefault(width, ARROW_SIZES, "med"),
|
|
7042
|
+
length: parseEnumValueWithDefault(length, ARROW_SIZES, "med")
|
|
7333
7043
|
};
|
|
7334
7044
|
}
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
return
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
const
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
const
|
|
7440
|
-
const crop = parseCrop(getChild(blipFill, "srcRect"));
|
|
7441
|
-
const stretch = parseStretch(getChild(blipFill, "stretch"));
|
|
7442
|
-
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
7443
|
-
const blipEffects = parseBlipEffects(blip);
|
|
7444
|
-
const spPr = getChild(pic, "spPr");
|
|
7445
|
-
const transform = parseTransform(spPr);
|
|
7446
|
-
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7447
|
-
const rawSidecars = [
|
|
7448
|
-
...collectUnknownSidecars(pic, KNOWN_PICTURE_CHILDREN, nextId),
|
|
7449
|
-
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7450
|
-
...collectEffectSidecars(spPr, effects, nextId),
|
|
7451
|
-
// Retains fill mode such as `a:stretch` / `a:tile` and recolor operation under blip.
|
|
7452
|
-
...collectUnknownSidecars(blipFill, KNOWN_BLIP_FILL_CHILDREN, nextId),
|
|
7453
|
-
...collectBlipEffectSidecars(blip, blipEffects, nextId)
|
|
7454
|
-
];
|
|
7045
|
+
var DASH_STYLES = /* @__PURE__ */ new Set([
|
|
7046
|
+
"solid",
|
|
7047
|
+
"dash",
|
|
7048
|
+
"dot",
|
|
7049
|
+
"dashDot",
|
|
7050
|
+
"lgDash",
|
|
7051
|
+
"lgDashDot",
|
|
7052
|
+
"sysDash",
|
|
7053
|
+
"sysDot"
|
|
7054
|
+
]);
|
|
7055
|
+
var ARROW_TYPES = /* @__PURE__ */ new Set([
|
|
7056
|
+
"triangle",
|
|
7057
|
+
"stealth",
|
|
7058
|
+
"diamond",
|
|
7059
|
+
"oval",
|
|
7060
|
+
"arrow"
|
|
7061
|
+
]);
|
|
7062
|
+
var ARROW_SIZES = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
|
|
7063
|
+
var KNOWN_TXBODY_CHILDREN = /* @__PURE__ */ new Set(["bodyPr", "lstStyle", "p"]);
|
|
7064
|
+
var KNOWN_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
|
|
7065
|
+
"pPr",
|
|
7066
|
+
"r",
|
|
7067
|
+
"fld",
|
|
7068
|
+
"br",
|
|
7069
|
+
"endParaRPr"
|
|
7070
|
+
]);
|
|
7071
|
+
var KNOWN_RUN_CHILDREN = /* @__PURE__ */ new Set(["rPr", "t"]);
|
|
7072
|
+
var KNOWN_RUN_PROPERTY_CHILDREN = /* @__PURE__ */ new Set([
|
|
7073
|
+
"latin",
|
|
7074
|
+
"ea",
|
|
7075
|
+
"cs",
|
|
7076
|
+
"solidFill"
|
|
7077
|
+
]);
|
|
7078
|
+
var ALIGN_MAP = {
|
|
7079
|
+
l: "left",
|
|
7080
|
+
ctr: "center",
|
|
7081
|
+
r: "right",
|
|
7082
|
+
just: "justify"
|
|
7083
|
+
};
|
|
7084
|
+
var ANCHOR_MAP = {
|
|
7085
|
+
t: "top",
|
|
7086
|
+
ctr: "middle",
|
|
7087
|
+
b: "bottom"
|
|
7088
|
+
};
|
|
7089
|
+
var WRAP_VALUES = /* @__PURE__ */ new Set(["square", "none"]);
|
|
7090
|
+
var VERTICAL_VALUES = /* @__PURE__ */ new Set([
|
|
7091
|
+
"horz",
|
|
7092
|
+
"vert",
|
|
7093
|
+
"vert270",
|
|
7094
|
+
"eaVert",
|
|
7095
|
+
"wordArtVert",
|
|
7096
|
+
"mongolianVert"
|
|
7097
|
+
]);
|
|
7098
|
+
var VALID_AUTO_NUM_SCHEMES = /* @__PURE__ */ new Set([
|
|
7099
|
+
"arabicPeriod",
|
|
7100
|
+
"arabicParenR",
|
|
7101
|
+
"romanUcPeriod",
|
|
7102
|
+
"romanLcPeriod",
|
|
7103
|
+
"alphaUcPeriod",
|
|
7104
|
+
"alphaLcPeriod",
|
|
7105
|
+
"alphaLcParenR",
|
|
7106
|
+
"alphaUcParenR",
|
|
7107
|
+
"arabicPlain"
|
|
7108
|
+
]);
|
|
7109
|
+
function parseTextBody(txBody, partPath, nextId, ownerNodeId, ownerOrderingSlot, orderedTxBody) {
|
|
7110
|
+
if (!txBody) return void 0;
|
|
7111
|
+
const properties = parseBodyProperties(getChild(txBody, "bodyPr"));
|
|
7112
|
+
const listStyle = parseTextStyle(getChild(txBody, "lstStyle"));
|
|
7113
|
+
const orderedParagraphs = orderedTxBody?.filter((child) => orderedLocalName(child) === "p").map((child) => {
|
|
7114
|
+
const key = orderedKey(child);
|
|
7115
|
+
const value = key !== void 0 ? child[key] : void 0;
|
|
7116
|
+
return Array.isArray(value) ? value : void 0;
|
|
7117
|
+
});
|
|
7118
|
+
const paragraphs = [];
|
|
7119
|
+
let logicalParagraphIndex = 0;
|
|
7120
|
+
getChildArray(txBody, "p").forEach((p, paragraphIndex) => {
|
|
7121
|
+
const orderedChildren = orderedParagraphs?.[paragraphIndex];
|
|
7122
|
+
if (orderedChildren !== void 0 && hasMultipleBulletPPr(p, orderedChildren)) {
|
|
7123
|
+
const split = splitInterleavedParagraph(
|
|
7124
|
+
p,
|
|
7125
|
+
orderedChildren,
|
|
7126
|
+
partPath,
|
|
7127
|
+
nextId,
|
|
7128
|
+
ownerNodeId,
|
|
7129
|
+
ownerOrderingSlot,
|
|
7130
|
+
logicalParagraphIndex
|
|
7131
|
+
);
|
|
7132
|
+
paragraphs.push(...split);
|
|
7133
|
+
logicalParagraphIndex += split.length;
|
|
7134
|
+
return;
|
|
7135
|
+
}
|
|
7136
|
+
paragraphs.push(
|
|
7137
|
+
parseParagraph(
|
|
7138
|
+
p,
|
|
7139
|
+
partPath,
|
|
7140
|
+
nextId,
|
|
7141
|
+
ownerNodeId,
|
|
7142
|
+
ownerOrderingSlot,
|
|
7143
|
+
logicalParagraphIndex,
|
|
7144
|
+
orderedChildren
|
|
7145
|
+
)
|
|
7146
|
+
);
|
|
7147
|
+
logicalParagraphIndex++;
|
|
7148
|
+
});
|
|
7149
|
+
const rawSidecars = collectUnknownSidecars(txBody, KNOWN_TXBODY_CHILDREN, nextId);
|
|
7455
7150
|
return {
|
|
7456
|
-
|
|
7457
|
-
...
|
|
7458
|
-
...
|
|
7459
|
-
|
|
7460
|
-
...embed !== void 0 ? { blipRelationshipId: asRelationshipId(embed) } : {},
|
|
7461
|
-
...crop !== void 0 ? { crop } : {},
|
|
7462
|
-
...stretch !== void 0 ? { stretch } : {},
|
|
7463
|
-
...tile !== void 0 ? { tile } : {},
|
|
7464
|
-
...effects !== void 0 ? { effects } : {},
|
|
7465
|
-
...blipEffects !== void 0 ? { blipEffects } : {},
|
|
7466
|
-
handle: {
|
|
7467
|
-
partPath,
|
|
7468
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7469
|
-
...embed !== void 0 ? { relationshipId: asRelationshipId(embed) } : {},
|
|
7470
|
-
orderingSlot
|
|
7471
|
-
},
|
|
7151
|
+
paragraphs,
|
|
7152
|
+
...properties !== void 0 ? { properties } : {},
|
|
7153
|
+
...listStyle !== void 0 ? { listStyle } : {},
|
|
7154
|
+
handle: { partPath },
|
|
7472
7155
|
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7473
7156
|
};
|
|
7474
7157
|
}
|
|
7475
|
-
function
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
const
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
];
|
|
7485
|
-
for (const [name, parsed] of supportedChildren) {
|
|
7486
|
-
const node = getChild(effectList, name);
|
|
7487
|
-
if (node !== void 0 && parsed === void 0) {
|
|
7488
|
-
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7489
|
-
}
|
|
7490
|
-
}
|
|
7491
|
-
return sidecars;
|
|
7492
|
-
}
|
|
7493
|
-
function collectBlipEffectSidecars(blip, effects, nextId) {
|
|
7494
|
-
if (blip === void 0) return [];
|
|
7495
|
-
const sidecars = collectUnknownSidecars(blip, KNOWN_BLIP_CHILDREN, nextId);
|
|
7496
|
-
const supportedChildren = [
|
|
7497
|
-
["grayscl", effects?.grayscale === true],
|
|
7498
|
-
["biLevel", effects?.biLevel],
|
|
7499
|
-
["blur", effects?.blur],
|
|
7500
|
-
["lum", effects?.lum],
|
|
7501
|
-
["duotone", effects?.duotone],
|
|
7502
|
-
["clrChange", effects?.clrChange]
|
|
7503
|
-
];
|
|
7504
|
-
for (const [name, parsed] of supportedChildren) {
|
|
7505
|
-
const node = getChild(blip, name);
|
|
7506
|
-
if (node !== void 0 && (parsed === void 0 || parsed === false)) {
|
|
7507
|
-
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7508
|
-
}
|
|
7509
|
-
}
|
|
7510
|
-
return sidecars;
|
|
7511
|
-
}
|
|
7512
|
-
function parseGraphicFrame(graphicFrame, partPath, nextId, orderingSlot, orderedNode) {
|
|
7513
|
-
const graphic = getChild(graphicFrame, "graphic");
|
|
7514
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
7515
|
-
const uri = getAttr(graphicData, "uri");
|
|
7516
|
-
if (uri !== void 0 && CHART_GRAPHIC_DATA_URIS.has(uri)) {
|
|
7517
|
-
const parsedChart = parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7518
|
-
if (parsedChart !== void 0) return parsedChart;
|
|
7519
|
-
}
|
|
7520
|
-
if (uri !== void 0 && SMARTART_DIAGRAM_URIS.has(uri)) {
|
|
7521
|
-
const parsedSmartArt = parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7522
|
-
if (parsedSmartArt !== void 0) return parsedSmartArt;
|
|
7523
|
-
}
|
|
7524
|
-
const table = getChild(graphicData, "tbl");
|
|
7525
|
-
if (table === void 0) {
|
|
7526
|
-
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7527
|
-
}
|
|
7528
|
-
const orderedGraphicChildren = orderedNestedChildChildren(orderedNode, "graphicFrame", "graphic");
|
|
7529
|
-
const orderedGraphicDataChildren = orderedChildChildren2(orderedGraphicChildren, "graphicData");
|
|
7530
|
-
const orderedTableChildren = orderedChildChildren2(orderedGraphicDataChildren, "tbl");
|
|
7531
|
-
const parsedTable = parseTable(
|
|
7532
|
-
table,
|
|
7533
|
-
graphicFrame,
|
|
7534
|
-
partPath,
|
|
7535
|
-
nextId,
|
|
7536
|
-
orderingSlot,
|
|
7537
|
-
orderedTableChildren
|
|
7538
|
-
);
|
|
7539
|
-
if (parsedTable === void 0) {
|
|
7540
|
-
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
7541
|
-
}
|
|
7542
|
-
return parsedTable;
|
|
7543
|
-
}
|
|
7544
|
-
function parseAlternateContent(alternateContent, partPath, nextId, orderingSlot) {
|
|
7545
|
-
const branches = [
|
|
7546
|
-
...getChildArray(alternateContent, "Choice"),
|
|
7547
|
-
...getChildArray(alternateContent, "Fallback")
|
|
7548
|
-
];
|
|
7549
|
-
for (const branch of branches) {
|
|
7550
|
-
const parsed = parseAlternateContentBranch(branch, partPath, nextId, orderingSlot);
|
|
7551
|
-
if (parsed.length > 0) {
|
|
7552
|
-
if (parsed.every((node) => node.kind === "raw")) {
|
|
7553
|
-
continue;
|
|
7554
|
-
}
|
|
7555
|
-
return parsed.map(
|
|
7556
|
-
(node) => attachRawSidecar(node, makeSidecar("mc:AlternateContent", alternateContent, nextId))
|
|
7557
|
-
);
|
|
7558
|
-
}
|
|
7158
|
+
function parseTextStyle(node) {
|
|
7159
|
+
if (node === void 0) return void 0;
|
|
7160
|
+
const defaultParagraph = parseParagraphProperties(getChild(node, "defPPr"));
|
|
7161
|
+
const levels = Array.from(
|
|
7162
|
+
{ length: 9 },
|
|
7163
|
+
(_, index) => parseParagraphProperties(getChild(node, `lvl${index + 1}pPr`))
|
|
7164
|
+
);
|
|
7165
|
+
if (defaultParagraph === void 0 && levels.every((level) => level === void 0)) {
|
|
7166
|
+
return void 0;
|
|
7559
7167
|
}
|
|
7560
|
-
return
|
|
7561
|
-
parseRawShapeNode("mc:AlternateContent", alternateContent, partPath, nextId, orderingSlot)
|
|
7562
|
-
];
|
|
7168
|
+
return { ...defaultParagraph !== void 0 ? { defaultParagraph } : {}, levels };
|
|
7563
7169
|
}
|
|
7564
|
-
function
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7170
|
+
function hasMultipleBulletPPr(p, orderedChildren) {
|
|
7171
|
+
const pPrList = getChildArray(p, "pPr");
|
|
7172
|
+
let bulletPPrCount = 0;
|
|
7173
|
+
let pPrCounter = 0;
|
|
7174
|
+
for (const child of orderedChildren) {
|
|
7175
|
+
if (orderedLocalName(child) !== "pPr") continue;
|
|
7176
|
+
const pPr = pPrList[pPrCounter];
|
|
7177
|
+
if (pPr !== void 0 && (getChild(pPr, "buChar") !== void 0 || getChild(pPr, "buAutoNum") !== void 0)) {
|
|
7178
|
+
bulletPPrCount++;
|
|
7179
|
+
if (bulletPPrCount >= 2) return true;
|
|
7180
|
+
}
|
|
7181
|
+
pPrCounter++;
|
|
7182
|
+
}
|
|
7183
|
+
return false;
|
|
7570
7184
|
}
|
|
7571
|
-
function
|
|
7572
|
-
const
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7185
|
+
function splitInterleavedParagraph(p, orderedChildren, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex) {
|
|
7186
|
+
const pPrList = getChildArray(p, "pPr");
|
|
7187
|
+
const rList = getChildArray(p, "r");
|
|
7188
|
+
const fldList = getChildArray(p, "fld");
|
|
7189
|
+
const brList = getChildArray(p, "br");
|
|
7190
|
+
const groups = [];
|
|
7191
|
+
let currentGroup;
|
|
7192
|
+
let pPrCounter = 0;
|
|
7193
|
+
let runCounter = 0;
|
|
7194
|
+
let fieldCounter = 0;
|
|
7195
|
+
let breakCounter = 0;
|
|
7196
|
+
for (const child of orderedChildren) {
|
|
7197
|
+
const tag = orderedLocalName(child);
|
|
7198
|
+
if (tag === "pPr") {
|
|
7199
|
+
const pPr = pPrList[pPrCounter];
|
|
7200
|
+
const hasBullet = pPr !== void 0 && (getChild(pPr, "buChar") !== void 0 || getChild(pPr, "buAutoNum") !== void 0);
|
|
7201
|
+
if (hasBullet || currentGroup === void 0) {
|
|
7202
|
+
if (currentGroup !== void 0) groups.push(currentGroup);
|
|
7203
|
+
currentGroup = {
|
|
7204
|
+
pPrIndex: pPrCounter,
|
|
7205
|
+
rNodes: [],
|
|
7206
|
+
fldNodes: [],
|
|
7207
|
+
brNodes: [],
|
|
7208
|
+
orderedChildren: [child]
|
|
7209
|
+
};
|
|
7588
7210
|
} else {
|
|
7589
|
-
|
|
7211
|
+
currentGroup.orderedChildren.push(child);
|
|
7590
7212
|
}
|
|
7213
|
+
pPrCounter++;
|
|
7214
|
+
} else if (tag === "r") {
|
|
7215
|
+
currentGroup ??= {
|
|
7216
|
+
pPrIndex: -1,
|
|
7217
|
+
rNodes: [],
|
|
7218
|
+
fldNodes: [],
|
|
7219
|
+
brNodes: [],
|
|
7220
|
+
orderedChildren: []
|
|
7221
|
+
};
|
|
7222
|
+
currentGroup.orderedChildren.push(child);
|
|
7223
|
+
if (rList[runCounter] !== void 0) currentGroup.rNodes.push(rList[runCounter]);
|
|
7224
|
+
runCounter++;
|
|
7225
|
+
} else if (tag === "fld") {
|
|
7226
|
+
currentGroup ??= {
|
|
7227
|
+
pPrIndex: -1,
|
|
7228
|
+
rNodes: [],
|
|
7229
|
+
fldNodes: [],
|
|
7230
|
+
brNodes: [],
|
|
7231
|
+
orderedChildren: []
|
|
7232
|
+
};
|
|
7233
|
+
currentGroup.orderedChildren.push(child);
|
|
7234
|
+
if (fldList[fieldCounter] !== void 0) currentGroup.fldNodes.push(fldList[fieldCounter]);
|
|
7235
|
+
fieldCounter++;
|
|
7236
|
+
} else if (tag === "br") {
|
|
7237
|
+
currentGroup ??= {
|
|
7238
|
+
pPrIndex: -1,
|
|
7239
|
+
rNodes: [],
|
|
7240
|
+
fldNodes: [],
|
|
7241
|
+
brNodes: [],
|
|
7242
|
+
orderedChildren: []
|
|
7243
|
+
};
|
|
7244
|
+
currentGroup.orderedChildren.push(child);
|
|
7245
|
+
if (brList[breakCounter] !== void 0) currentGroup.brNodes.push(brList[breakCounter]);
|
|
7246
|
+
breakCounter++;
|
|
7591
7247
|
}
|
|
7592
7248
|
}
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
const transform = parseTransform(graphicFrame);
|
|
7606
|
-
const rawSidecars = [
|
|
7607
|
-
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
7608
|
-
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
7609
|
-
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
7610
|
-
];
|
|
7611
|
-
return {
|
|
7612
|
-
kind: "chart",
|
|
7613
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7614
|
-
...name !== void 0 ? { name } : {},
|
|
7615
|
-
...transform !== void 0 ? { transform } : {},
|
|
7616
|
-
chartRelationshipId: asRelationshipId(rId),
|
|
7617
|
-
handle: {
|
|
7618
|
-
partPath,
|
|
7619
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7620
|
-
relationshipId: asRelationshipId(rId),
|
|
7621
|
-
orderingSlot
|
|
7622
|
-
},
|
|
7623
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7624
|
-
};
|
|
7625
|
-
}
|
|
7626
|
-
function parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot) {
|
|
7627
|
-
const graphic = getChild(graphicFrame, "graphic");
|
|
7628
|
-
const graphicData = getChild(graphic, "graphicData");
|
|
7629
|
-
const relIds = getChild(graphicData, "relIds");
|
|
7630
|
-
const dmRId = getNamespacedAttr(relIds, "dm") ?? getAttr(relIds, "dm");
|
|
7631
|
-
if (dmRId === void 0) return void 0;
|
|
7632
|
-
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
7633
|
-
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
7634
|
-
const nodeId = sourceNodeId(cNvPr);
|
|
7635
|
-
const name = getAttr(cNvPr, "name");
|
|
7636
|
-
const transform = parseTransform(graphicFrame);
|
|
7637
|
-
const rawSidecars = [
|
|
7638
|
-
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
7639
|
-
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
7640
|
-
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
7641
|
-
];
|
|
7642
|
-
return {
|
|
7643
|
-
kind: "smartArt",
|
|
7644
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
7645
|
-
...name !== void 0 ? { name } : {},
|
|
7646
|
-
...transform !== void 0 ? { transform } : {},
|
|
7647
|
-
dataRelationshipId: asRelationshipId(dmRId),
|
|
7648
|
-
handle: {
|
|
7249
|
+
if (currentGroup !== void 0) groups.push(currentGroup);
|
|
7250
|
+
return groups.map((group, groupIndex) => {
|
|
7251
|
+
const synthetic = {};
|
|
7252
|
+
if (group.pPrIndex >= 0) synthetic.pPr = pPrList[group.pPrIndex];
|
|
7253
|
+
synthetic.r = group.rNodes;
|
|
7254
|
+
synthetic.fld = group.fldNodes;
|
|
7255
|
+
synthetic.br = group.brNodes;
|
|
7256
|
+
if (groupIndex === groups.length - 1 && getChild(p, "endParaRPr") !== void 0) {
|
|
7257
|
+
synthetic.endParaRPr = getChild(p, "endParaRPr");
|
|
7258
|
+
}
|
|
7259
|
+
const paragraph = parseParagraph(
|
|
7260
|
+
synthetic,
|
|
7649
7261
|
partPath,
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7262
|
+
nextId,
|
|
7263
|
+
ownerNodeId,
|
|
7264
|
+
ownerOrderingSlot,
|
|
7265
|
+
paragraphIndex + groupIndex,
|
|
7266
|
+
group.orderedChildren
|
|
7267
|
+
);
|
|
7268
|
+
if (groupIndex < groups.length - 1 && paragraph.runs.length > 0) {
|
|
7269
|
+
const lastRun = paragraph.runs[paragraph.runs.length - 1];
|
|
7270
|
+
if (lastRun.text.endsWith("\n")) {
|
|
7271
|
+
const trimmed = lastRun.text.slice(0, -1);
|
|
7272
|
+
const precedingRuns = paragraph.runs.slice(0, -1);
|
|
7273
|
+
return {
|
|
7274
|
+
...paragraph,
|
|
7275
|
+
runs: trimmed === "" ? precedingRuns : [...precedingRuns, { ...lastRun, text: trimmed }]
|
|
7276
|
+
};
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7279
|
+
return paragraph;
|
|
7280
|
+
});
|
|
7656
7281
|
}
|
|
7657
|
-
function
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
const
|
|
7661
|
-
const
|
|
7662
|
-
const
|
|
7663
|
-
const
|
|
7664
|
-
const
|
|
7665
|
-
const
|
|
7666
|
-
const
|
|
7667
|
-
const
|
|
7668
|
-
const
|
|
7669
|
-
const
|
|
7670
|
-
const
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
...
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
...
|
|
7679
|
-
...
|
|
7680
|
-
...
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
},
|
|
7686
|
-
|
|
7687
|
-
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7282
|
+
function parseBodyProperties(bodyPr) {
|
|
7283
|
+
if (!bodyPr) return void 0;
|
|
7284
|
+
const marginLeft = numericAttr2(bodyPr, "lIns");
|
|
7285
|
+
const marginRight = numericAttr2(bodyPr, "rIns");
|
|
7286
|
+
const marginTop = numericAttr2(bodyPr, "tIns");
|
|
7287
|
+
const marginBottom = numericAttr2(bodyPr, "bIns");
|
|
7288
|
+
const anchorToken = getAttr(bodyPr, "anchor");
|
|
7289
|
+
const anchor = anchorToken !== void 0 ? ANCHOR_MAP[anchorToken] : void 0;
|
|
7290
|
+
const wrap = parseWrap(getAttr(bodyPr, "wrap"));
|
|
7291
|
+
const vert = parseVerticalType(getAttr(bodyPr, "vert"));
|
|
7292
|
+
const numCol = numericAttr2(bodyPr, "numCol");
|
|
7293
|
+
const normAutofit = getChild(bodyPr, "normAutofit");
|
|
7294
|
+
const hasSpAutofit = getChild(bodyPr, "spAutoFit") !== void 0;
|
|
7295
|
+
const hasNoAutofit = getChild(bodyPr, "noAutofit") !== void 0;
|
|
7296
|
+
const fontScale = numericAttr2(normAutofit, "fontScale");
|
|
7297
|
+
const lnSpcReduction = numericAttr2(normAutofit, "lnSpcReduction");
|
|
7298
|
+
const properties = {
|
|
7299
|
+
...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
|
|
7300
|
+
...marginRight !== void 0 ? { marginRight: emu(marginRight) } : {},
|
|
7301
|
+
...marginTop !== void 0 ? { marginTop: emu(marginTop) } : {},
|
|
7302
|
+
...marginBottom !== void 0 ? { marginBottom: emu(marginBottom) } : {},
|
|
7303
|
+
...anchor !== void 0 ? { anchor } : {},
|
|
7304
|
+
...wrap !== void 0 ? { wrap } : {},
|
|
7305
|
+
...normAutofit !== void 0 ? {
|
|
7306
|
+
autoFit: "normAutofit",
|
|
7307
|
+
fontScale: fontScale !== void 0 ? fontScale / 1e5 : 1,
|
|
7308
|
+
lnSpcReduction: lnSpcReduction !== void 0 ? lnSpcReduction / 1e5 : 0
|
|
7309
|
+
} : hasSpAutofit ? { autoFit: "spAutofit", fontScale: 1, lnSpcReduction: 0 } : hasNoAutofit ? { autoFit: "noAutofit", fontScale: 1, lnSpcReduction: 0 } : {},
|
|
7310
|
+
...numCol !== void 0 ? { numCol: Math.max(1, numCol) } : {},
|
|
7311
|
+
...vert !== void 0 ? { vert } : {}
|
|
7688
7312
|
};
|
|
7313
|
+
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7689
7314
|
}
|
|
7690
|
-
function
|
|
7691
|
-
return
|
|
7315
|
+
function parseWrap(value) {
|
|
7316
|
+
return parseEnumValue(value, WRAP_VALUES);
|
|
7692
7317
|
}
|
|
7693
|
-
function
|
|
7694
|
-
|
|
7695
|
-
return getChildArray(tbl, "tr").map((tr, rowIndex) => ({
|
|
7696
|
-
height: emuAttr(tr, "h"),
|
|
7697
|
-
cells: getChildArray(tr, "tc").map((tc, cellIndex) => {
|
|
7698
|
-
const orderedCells = orderedChildChildrenList(orderedRows[rowIndex], "tc");
|
|
7699
|
-
return parseTableCell(
|
|
7700
|
-
tc,
|
|
7701
|
-
partPath,
|
|
7702
|
-
nextId,
|
|
7703
|
-
tableNodeId,
|
|
7704
|
-
tableOrderingSlot,
|
|
7705
|
-
rowIndex,
|
|
7706
|
-
cellIndex,
|
|
7707
|
-
orderedCells[cellIndex]
|
|
7708
|
-
);
|
|
7709
|
-
})
|
|
7710
|
-
}));
|
|
7318
|
+
function parseVerticalType(value) {
|
|
7319
|
+
return parseEnumValue(value, VERTICAL_VALUES);
|
|
7711
7320
|
}
|
|
7712
|
-
function
|
|
7713
|
-
const
|
|
7714
|
-
const
|
|
7715
|
-
|
|
7716
|
-
getChild(tc, "txBody"),
|
|
7321
|
+
function parseParagraph(p, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, orderedChildren) {
|
|
7322
|
+
const properties = parseParagraphProperties(getChild(p, "pPr"));
|
|
7323
|
+
const runs = parseRunsInOrder(
|
|
7324
|
+
p,
|
|
7717
7325
|
partPath,
|
|
7718
7326
|
nextId,
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7327
|
+
ownerNodeId,
|
|
7328
|
+
ownerOrderingSlot,
|
|
7329
|
+
paragraphIndex,
|
|
7330
|
+
orderedChildren
|
|
7722
7331
|
);
|
|
7723
|
-
const
|
|
7724
|
-
const borders = parseCellBorders(tcPr, nextId);
|
|
7725
|
-
const rawSidecars = [
|
|
7726
|
-
...collectUnknownSidecars(tc, KNOWN_TABLE_CELL_CHILDREN, nextId),
|
|
7727
|
-
...collectUnknownSidecars(tcPr, KNOWN_TABLE_CELL_PROPERTIES_CHILDREN, nextId)
|
|
7728
|
-
];
|
|
7332
|
+
const rawSidecars = collectUnknownSidecars(p, KNOWN_PARAGRAPH_CHILDREN, nextId);
|
|
7729
7333
|
return {
|
|
7730
|
-
|
|
7731
|
-
...
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7334
|
+
runs,
|
|
7335
|
+
...properties !== void 0 ? { properties } : {},
|
|
7336
|
+
handle: {
|
|
7337
|
+
partPath,
|
|
7338
|
+
nodeId: textNodeId("paragraph", ownerNodeId, ownerOrderingSlot, paragraphIndex),
|
|
7339
|
+
orderingSlot: paragraphIndex
|
|
7340
|
+
},
|
|
7737
7341
|
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7738
7342
|
};
|
|
7739
7343
|
}
|
|
7740
|
-
function
|
|
7741
|
-
const
|
|
7742
|
-
const
|
|
7743
|
-
const
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
};
|
|
7773
|
-
}
|
|
7774
|
-
function parseGeometry(spPr, orderedSpPr) {
|
|
7775
|
-
const prstGeom = getChild(spPr, "prstGeom");
|
|
7776
|
-
if (prstGeom) {
|
|
7777
|
-
const preset = getAttr(prstGeom, "prst");
|
|
7778
|
-
const adjustValues = parseAdjustValues(getChild(prstGeom, "avLst"));
|
|
7779
|
-
return preset !== void 0 ? {
|
|
7780
|
-
preset,
|
|
7781
|
-
...Object.keys(adjustValues).length > 0 ? { adjustValues } : {}
|
|
7782
|
-
} : void 0;
|
|
7344
|
+
function parseRunsInOrder(p, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, orderedChildren) {
|
|
7345
|
+
const rList = getChildArray(p, "r");
|
|
7346
|
+
const fldList = getChildArray(p, "fld");
|
|
7347
|
+
const brList = getChildArray(p, "br");
|
|
7348
|
+
if (orderedChildren === void 0) {
|
|
7349
|
+
return [
|
|
7350
|
+
...rList.map(
|
|
7351
|
+
(r, runIndex) => parseRun(r, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex)
|
|
7352
|
+
),
|
|
7353
|
+
...fldList.map(
|
|
7354
|
+
(fld, index) => parseRun(
|
|
7355
|
+
fld,
|
|
7356
|
+
partPath,
|
|
7357
|
+
nextId,
|
|
7358
|
+
ownerNodeId,
|
|
7359
|
+
ownerOrderingSlot,
|
|
7360
|
+
paragraphIndex,
|
|
7361
|
+
rList.length + index
|
|
7362
|
+
)
|
|
7363
|
+
),
|
|
7364
|
+
...brList.map(
|
|
7365
|
+
(br, index) => parseBreakRun(
|
|
7366
|
+
br,
|
|
7367
|
+
partPath,
|
|
7368
|
+
nextId,
|
|
7369
|
+
ownerNodeId,
|
|
7370
|
+
ownerOrderingSlot,
|
|
7371
|
+
paragraphIndex,
|
|
7372
|
+
rList.length + fldList.length + index
|
|
7373
|
+
)
|
|
7374
|
+
)
|
|
7375
|
+
];
|
|
7783
7376
|
}
|
|
7784
|
-
const
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7377
|
+
const counters = {};
|
|
7378
|
+
const runs = [];
|
|
7379
|
+
for (const child of orderedChildren) {
|
|
7380
|
+
const tag = orderedLocalName(child);
|
|
7381
|
+
if (tag !== "r" && tag !== "fld" && tag !== "br") continue;
|
|
7382
|
+
const index = counters[tag] ?? 0;
|
|
7383
|
+
counters[tag] = index + 1;
|
|
7384
|
+
const runIndex = runs.length;
|
|
7385
|
+
if (tag === "r" && rList[index] !== void 0) {
|
|
7386
|
+
runs.push(
|
|
7387
|
+
parseRun(
|
|
7388
|
+
rList[index],
|
|
7389
|
+
partPath,
|
|
7390
|
+
nextId,
|
|
7391
|
+
ownerNodeId,
|
|
7392
|
+
ownerOrderingSlot,
|
|
7393
|
+
paragraphIndex,
|
|
7394
|
+
runIndex
|
|
7395
|
+
)
|
|
7396
|
+
);
|
|
7397
|
+
} else if (tag === "fld" && fldList[index] !== void 0) {
|
|
7398
|
+
runs.push(
|
|
7399
|
+
parseRun(
|
|
7400
|
+
fldList[index],
|
|
7401
|
+
partPath,
|
|
7402
|
+
nextId,
|
|
7403
|
+
ownerNodeId,
|
|
7404
|
+
ownerOrderingSlot,
|
|
7405
|
+
paragraphIndex,
|
|
7406
|
+
runIndex
|
|
7407
|
+
)
|
|
7408
|
+
);
|
|
7409
|
+
} else if (tag === "br" && brList[index] !== void 0) {
|
|
7410
|
+
runs.push(
|
|
7411
|
+
parseBreakRun(
|
|
7412
|
+
brList[index],
|
|
7413
|
+
partPath,
|
|
7414
|
+
nextId,
|
|
7415
|
+
ownerNodeId,
|
|
7416
|
+
ownerOrderingSlot,
|
|
7417
|
+
paragraphIndex,
|
|
7418
|
+
runIndex
|
|
7419
|
+
)
|
|
7420
|
+
);
|
|
7799
7421
|
}
|
|
7800
7422
|
}
|
|
7801
|
-
return
|
|
7802
|
-
}
|
|
7803
|
-
function parseChildTransform(grpSpPr, fallback) {
|
|
7804
|
-
const xfrm = getChild(grpSpPr, "xfrm");
|
|
7805
|
-
const childOff = getChild(xfrm, "chOff");
|
|
7806
|
-
const childExt = getChild(xfrm, "chExt");
|
|
7807
|
-
const offsetX = numericAttr2(childOff, "x") ?? 0;
|
|
7808
|
-
const offsetY = numericAttr2(childOff, "y") ?? 0;
|
|
7809
|
-
const width = numericAttr2(childExt, "cx") ?? fallback?.width;
|
|
7810
|
-
const height = numericAttr2(childExt, "cy") ?? fallback?.height;
|
|
7811
|
-
if (width === void 0 || height === void 0) return void 0;
|
|
7812
|
-
return {
|
|
7813
|
-
offsetX: asEmu2(offsetX),
|
|
7814
|
-
offsetY: asEmu2(offsetY),
|
|
7815
|
-
width: asEmu2(Number(width)),
|
|
7816
|
-
height: asEmu2(Number(height))
|
|
7817
|
-
};
|
|
7423
|
+
return runs;
|
|
7818
7424
|
}
|
|
7819
|
-
function
|
|
7820
|
-
if (!
|
|
7821
|
-
const
|
|
7822
|
-
const
|
|
7823
|
-
const
|
|
7824
|
-
const
|
|
7825
|
-
const
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7425
|
+
function parseParagraphProperties(pPr) {
|
|
7426
|
+
if (!pPr) return void 0;
|
|
7427
|
+
const alignToken = getAttr(pPr, "algn");
|
|
7428
|
+
const align = alignToken !== void 0 ? ALIGN_MAP[alignToken] : void 0;
|
|
7429
|
+
const level = numericAttr2(pPr, "lvl");
|
|
7430
|
+
const lineSpacing = parseSpacing(getChild(pPr, "lnSpc"));
|
|
7431
|
+
const spaceBefore = parseSpacing(getChild(pPr, "spcBef"));
|
|
7432
|
+
const spaceAfter = parseSpacing(getChild(pPr, "spcAft"));
|
|
7433
|
+
const marginLeft = numericAttr2(pPr, "marL");
|
|
7434
|
+
const indent = numericAttr2(pPr, "indent");
|
|
7435
|
+
const bullet = parseBullet(pPr);
|
|
7436
|
+
const bulletFont = getAttr(getChild(pPr, "buFont"), "typeface");
|
|
7437
|
+
const bulletColor = parseColorElement(getChild(pPr, "buClr"));
|
|
7438
|
+
const bulletSizePct = numericAttr2(getChild(pPr, "buSzPct"), "val");
|
|
7439
|
+
const tabStops = parseTabStops(pPr);
|
|
7440
|
+
const defaultRunProperties = parseRunProperties(getChild(pPr, "defRPr"));
|
|
7441
|
+
const properties = {
|
|
7442
|
+
...align !== void 0 ? { align } : {},
|
|
7443
|
+
...level !== void 0 ? { level } : {},
|
|
7444
|
+
...lineSpacing !== void 0 ? { lineSpacing } : {},
|
|
7445
|
+
...spaceBefore !== void 0 ? { spaceBefore } : {},
|
|
7446
|
+
...spaceAfter !== void 0 ? { spaceAfter } : {},
|
|
7447
|
+
...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
|
|
7448
|
+
...indent !== void 0 ? { indent: emu(indent) } : {},
|
|
7449
|
+
...bullet !== void 0 ? { bullet } : {},
|
|
7450
|
+
...bulletFont !== void 0 ? { bulletFont } : {},
|
|
7451
|
+
...bulletColor !== void 0 ? { bulletColor } : {},
|
|
7452
|
+
...bulletSizePct !== void 0 ? { bulletSizePct } : {},
|
|
7453
|
+
...tabStops.length > 0 ? { tabStops } : {},
|
|
7454
|
+
...defaultRunProperties !== void 0 ? { defaultRunProperties } : {}
|
|
7830
7455
|
};
|
|
7831
|
-
return Object.keys(
|
|
7832
|
-
}
|
|
7833
|
-
function parseStretch(stretch) {
|
|
7834
|
-
const fillRect = getChild(stretch, "fillRect");
|
|
7835
|
-
if (fillRect === void 0) return void 0;
|
|
7836
|
-
const left = (numericAttr2(fillRect, "l") ?? 0) / 1e5;
|
|
7837
|
-
const top = (numericAttr2(fillRect, "t") ?? 0) / 1e5;
|
|
7838
|
-
const right = (numericAttr2(fillRect, "r") ?? 0) / 1e5;
|
|
7839
|
-
const bottom = (numericAttr2(fillRect, "b") ?? 0) / 1e5;
|
|
7840
|
-
if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
|
|
7841
|
-
return { left, top, right, bottom };
|
|
7842
|
-
}
|
|
7843
|
-
function sourceNodeId(cNvPr) {
|
|
7844
|
-
const id = getAttr(cNvPr, "id");
|
|
7845
|
-
return id !== void 0 ? asSourceNodeId(id) : void 0;
|
|
7456
|
+
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7846
7457
|
}
|
|
7847
|
-
function
|
|
7848
|
-
return
|
|
7458
|
+
function parseTabStops(pPr) {
|
|
7459
|
+
return getChildArray(getChild(pPr, "tabLst"), "tab").map((tab) => ({
|
|
7460
|
+
position: emu(numericAttr2(tab, "pos") ?? 0),
|
|
7461
|
+
alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
|
|
7462
|
+
}));
|
|
7849
7463
|
}
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
if (child === void 0) return void 0;
|
|
7857
|
-
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
7858
|
-
const value = key !== void 0 ? child[key] : void 0;
|
|
7859
|
-
return Array.isArray(value) ? value : void 0;
|
|
7464
|
+
function parseSpacing(node) {
|
|
7465
|
+
const points = numericAttr2(getChild(node, "spcPts"), "val");
|
|
7466
|
+
if (points !== void 0) return { type: "pts", value: asHundredthPt2(points) };
|
|
7467
|
+
const percent = numericAttr2(getChild(node, "spcPct"), "val");
|
|
7468
|
+
if (percent !== void 0) return { type: "pct", value: percent };
|
|
7469
|
+
return void 0;
|
|
7860
7470
|
}
|
|
7861
|
-
function
|
|
7862
|
-
if (
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7471
|
+
function parseBullet(pPr) {
|
|
7472
|
+
if (pPr === void 0) return void 0;
|
|
7473
|
+
if (getChild(pPr, "buNone") !== void 0) return { type: "none" };
|
|
7474
|
+
const buChar = getChild(pPr, "buChar");
|
|
7475
|
+
if (buChar !== void 0) {
|
|
7476
|
+
return { type: "char", char: decodeXmlCharRef(getAttr(buChar, "char") ?? "\u2022") };
|
|
7477
|
+
}
|
|
7478
|
+
const buAutoNum = getChild(pPr, "buAutoNum");
|
|
7479
|
+
if (buAutoNum !== void 0) {
|
|
7480
|
+
const scheme = getAttr(buAutoNum, "type") ?? "arabicPeriod";
|
|
7481
|
+
return {
|
|
7482
|
+
type: "autoNum",
|
|
7483
|
+
scheme: parseEnumValueWithDefault(scheme, VALID_AUTO_NUM_SCHEMES, "arabicPeriod"),
|
|
7484
|
+
startAt: numericAttr2(buAutoNum, "startAt") ?? 1
|
|
7485
|
+
};
|
|
7486
|
+
}
|
|
7487
|
+
return void 0;
|
|
7871
7488
|
}
|
|
7872
|
-
function
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
Array.isArray(parentChildren) ? parentChildren : void 0,
|
|
7877
|
-
childLocalName
|
|
7489
|
+
function decodeXmlCharRef(value) {
|
|
7490
|
+
return value.replace(
|
|
7491
|
+
/&#x([0-9a-fA-F]+);|&#([0-9]+);/g,
|
|
7492
|
+
(_match, hex, decimal) => String.fromCodePoint(parseInt(hex ?? decimal ?? "0", hex !== void 0 ? 16 : 10))
|
|
7878
7493
|
);
|
|
7879
7494
|
}
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
if (value !== void 0 && value.trim() === "") {
|
|
7906
|
-
throw new Error("updateTextRunProperties: typeface must be a non-empty string");
|
|
7495
|
+
function parseRun(r, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7496
|
+
const properties = parseRunProperties(getChild(r, "rPr"));
|
|
7497
|
+
const rawSidecars = collectRunSidecars(r, nextId);
|
|
7498
|
+
return {
|
|
7499
|
+
kind: "textRun",
|
|
7500
|
+
text: decodeXmlCharRef(getChildText(r, "t") ?? ""),
|
|
7501
|
+
...properties !== void 0 ? { properties } : {},
|
|
7502
|
+
handle: {
|
|
7503
|
+
partPath,
|
|
7504
|
+
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7505
|
+
orderingSlot: runIndex
|
|
7506
|
+
},
|
|
7507
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
7508
|
+
};
|
|
7509
|
+
}
|
|
7510
|
+
function parseBreakRun(br, partPath, nextId, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7511
|
+
const properties = parseRunProperties(getChild(br, "rPr"));
|
|
7512
|
+
return {
|
|
7513
|
+
kind: "textRun",
|
|
7514
|
+
text: "\n",
|
|
7515
|
+
...properties !== void 0 ? { properties } : {},
|
|
7516
|
+
handle: {
|
|
7517
|
+
partPath,
|
|
7518
|
+
nodeId: textNodeId("run", ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex),
|
|
7519
|
+
orderingSlot: runIndex
|
|
7907
7520
|
}
|
|
7908
|
-
}
|
|
7909
|
-
};
|
|
7910
|
-
var EDITABLE_TEXT_RUN_PROPERTIES = Object.keys(EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS).filter(
|
|
7911
|
-
(property) => property in EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS
|
|
7912
|
-
);
|
|
7913
|
-
var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
|
|
7914
|
-
function requireBooleanOrUndefined(value, fieldName) {
|
|
7915
|
-
if (value !== void 0 && typeof value !== "boolean") {
|
|
7916
|
-
throw new Error(`updateTextRunProperties: ${fieldName} must be a boolean value`);
|
|
7917
|
-
}
|
|
7521
|
+
};
|
|
7918
7522
|
}
|
|
7919
|
-
function
|
|
7920
|
-
|
|
7523
|
+
function parseRunProperties(rPr) {
|
|
7524
|
+
if (!rPr) return void 0;
|
|
7525
|
+
const bold = getAttr(rPr, "b");
|
|
7526
|
+
const italic = getAttr(rPr, "i");
|
|
7527
|
+
const underline = getAttr(rPr, "u");
|
|
7528
|
+
const strike = getAttr(rPr, "strike");
|
|
7529
|
+
const baseline = numericAttr2(rPr, "baseline");
|
|
7530
|
+
const size = numericAttr2(rPr, "sz");
|
|
7531
|
+
const typeface = getAttr(getChild(rPr, "latin"), "typeface");
|
|
7532
|
+
const typefaceEa = getAttr(getChild(rPr, "ea"), "typeface");
|
|
7533
|
+
const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
|
|
7534
|
+
const hasHyperlink = getChild(rPr, "hlinkClick") !== void 0;
|
|
7535
|
+
const color = parseColorElement(getChild(rPr, "solidFill"));
|
|
7536
|
+
const properties = {
|
|
7537
|
+
...bold !== void 0 ? { bold: isTrue(bold) } : {},
|
|
7538
|
+
...italic !== void 0 ? { italic: isTrue(italic) } : {},
|
|
7539
|
+
...underline !== void 0 ? { underline: underline !== "none" } : hasHyperlink ? { underline: true } : {},
|
|
7540
|
+
...strike !== void 0 ? { strikethrough: strike !== "noStrike" } : {},
|
|
7541
|
+
...baseline !== void 0 ? { baseline: baseline / 1e3 } : {},
|
|
7542
|
+
// `a:rPr@sz` is in 1/100 pt unit. Convert to pt and save.
|
|
7543
|
+
...size !== void 0 ? { fontSize: asPt(size / 100) } : {},
|
|
7544
|
+
...typeface !== void 0 ? { typeface } : {},
|
|
7545
|
+
...typefaceEa !== void 0 ? { typefaceEa } : {},
|
|
7546
|
+
...typefaceCs !== void 0 ? { typefaceCs } : {},
|
|
7547
|
+
...color !== void 0 ? { color } : hasHyperlink ? { color: { kind: "scheme", scheme: "hlink" } } : {}
|
|
7548
|
+
};
|
|
7549
|
+
return Object.keys(properties).length > 0 ? properties : void 0;
|
|
7921
7550
|
}
|
|
7922
|
-
function
|
|
7923
|
-
|
|
7551
|
+
function collectRunSidecars(r, nextId) {
|
|
7552
|
+
const runLevel = collectUnknownSidecars(r, KNOWN_RUN_CHILDREN, nextId);
|
|
7553
|
+
const propLevel = collectUnknownSidecars(getChild(r, "rPr"), KNOWN_RUN_PROPERTY_CHILDREN, nextId);
|
|
7554
|
+
return [...runLevel, ...propLevel];
|
|
7924
7555
|
}
|
|
7925
|
-
function
|
|
7926
|
-
return
|
|
7556
|
+
function emu(value) {
|
|
7557
|
+
return asEmu2(value);
|
|
7927
7558
|
}
|
|
7928
|
-
function
|
|
7929
|
-
|
|
7559
|
+
function textNodeId(kind, ownerNodeId, ownerOrderingSlot, paragraphIndex, runIndex) {
|
|
7560
|
+
const owner = ownerNodeId !== void 0 ? `shape:${ownerNodeId}` : `shapeSlot:${ownerOrderingSlot}`;
|
|
7561
|
+
const suffix = kind === "paragraph" ? `p:${paragraphIndex}` : `p:${paragraphIndex}:r:${runIndex}`;
|
|
7562
|
+
return asSourceNodeId(`text:${owner}:${suffix}`);
|
|
7930
7563
|
}
|
|
7931
|
-
function
|
|
7932
|
-
return
|
|
7564
|
+
function orderedKey(node) {
|
|
7565
|
+
return Object.keys(node).find((key) => key !== ":@");
|
|
7933
7566
|
}
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
"
|
|
7567
|
+
function orderedLocalName(node) {
|
|
7568
|
+
const key = orderedKey(node);
|
|
7569
|
+
return key !== void 0 ? localName(key) : void 0;
|
|
7570
|
+
}
|
|
7571
|
+
var KNOWN_SHAPE_CHILDREN = /* @__PURE__ */ new Set(["nvSpPr", "spPr", "style", "txBody"]);
|
|
7572
|
+
var KNOWN_CONNECTOR_CHILDREN = /* @__PURE__ */ new Set(["nvCxnSpPr", "spPr", "style"]);
|
|
7573
|
+
var KNOWN_GROUP_CHILDREN = /* @__PURE__ */ new Set(["nvGrpSpPr", "grpSpPr"]);
|
|
7574
|
+
var KNOWN_PICTURE_CHILDREN = /* @__PURE__ */ new Set(["nvPicPr", "blipFill", "spPr"]);
|
|
7575
|
+
var KNOWN_BLIP_FILL_CHILDREN = /* @__PURE__ */ new Set([
|
|
7576
|
+
"blip",
|
|
7577
|
+
"srcRect",
|
|
7578
|
+
"stretch",
|
|
7579
|
+
"tile"
|
|
7580
|
+
]);
|
|
7581
|
+
var KNOWN_BLIP_CHILDREN = /* @__PURE__ */ new Set([
|
|
7582
|
+
"grayscl",
|
|
7583
|
+
"biLevel",
|
|
7584
|
+
"blur",
|
|
7585
|
+
"lum",
|
|
7586
|
+
"duotone",
|
|
7587
|
+
"clrChange"
|
|
7588
|
+
]);
|
|
7589
|
+
var KNOWN_EFFECT_CHILDREN = /* @__PURE__ */ new Set([
|
|
7590
|
+
"outerShdw",
|
|
7591
|
+
"innerShdw",
|
|
7592
|
+
"glow",
|
|
7593
|
+
"softEdge"
|
|
7594
|
+
]);
|
|
7595
|
+
var KNOWN_GRAPHIC_FRAME_CHILDREN = /* @__PURE__ */ new Set([
|
|
7596
|
+
"nvGraphicFramePr",
|
|
7597
|
+
"xfrm",
|
|
7598
|
+
"graphic"
|
|
7599
|
+
]);
|
|
7600
|
+
var KNOWN_GRAPHIC_CHILDREN = /* @__PURE__ */ new Set(["graphicData"]);
|
|
7601
|
+
var KNOWN_GRAPHIC_DATA_CHILDREN = /* @__PURE__ */ new Set(["tbl"]);
|
|
7602
|
+
var KNOWN_TABLE_CHILDREN = /* @__PURE__ */ new Set(["tblPr", "tblGrid", "tr"]);
|
|
7603
|
+
var KNOWN_TABLE_CELL_CHILDREN = /* @__PURE__ */ new Set(["txBody", "tcPr"]);
|
|
7604
|
+
var KNOWN_TABLE_CELL_PROPERTIES_CHILDREN = /* @__PURE__ */ new Set([
|
|
7605
|
+
"lnL",
|
|
7606
|
+
"lnR",
|
|
7607
|
+
"lnT",
|
|
7608
|
+
"lnB",
|
|
7609
|
+
"solidFill",
|
|
7610
|
+
"noFill",
|
|
7611
|
+
"gradFill",
|
|
7612
|
+
"blipFill",
|
|
7613
|
+
"pattFill",
|
|
7614
|
+
"grpFill"
|
|
7615
|
+
]);
|
|
7616
|
+
var KNOWN_SP_PR_CHILDREN = /* @__PURE__ */ new Set([
|
|
7617
|
+
"xfrm",
|
|
7618
|
+
"prstGeom",
|
|
7619
|
+
"solidFill",
|
|
7620
|
+
"noFill",
|
|
7621
|
+
"gradFill",
|
|
7622
|
+
"blipFill",
|
|
7623
|
+
"pattFill",
|
|
7624
|
+
"grpFill",
|
|
7625
|
+
"ln",
|
|
7626
|
+
"effectLst"
|
|
7944
7627
|
]);
|
|
7945
|
-
var
|
|
7946
|
-
"
|
|
7947
|
-
"
|
|
7948
|
-
"
|
|
7949
|
-
"
|
|
7950
|
-
"
|
|
7628
|
+
var SHAPE_TREE_NODE_TAGS = /* @__PURE__ */ new Set([
|
|
7629
|
+
"sp",
|
|
7630
|
+
"pic",
|
|
7631
|
+
"cxnSp",
|
|
7632
|
+
"grpSp",
|
|
7633
|
+
"graphicFrame"
|
|
7951
7634
|
]);
|
|
7952
|
-
var
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
if (!parent) return void 0;
|
|
7965
|
-
const srgb = getChild(parent, "srgbClr");
|
|
7966
|
-
if (srgb) {
|
|
7967
|
-
const hex = getAttr(srgb, "val");
|
|
7968
|
-
if (hex !== void 0) {
|
|
7969
|
-
return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
|
|
7970
|
-
}
|
|
7635
|
+
var CHART_GRAPHIC_DATA_URIS = /* @__PURE__ */ new Set([
|
|
7636
|
+
"http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
7637
|
+
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
7638
|
+
]);
|
|
7639
|
+
var SMARTART_DIAGRAM_URIS = /* @__PURE__ */ new Set([
|
|
7640
|
+
"http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
7641
|
+
"http://purl.oclc.org/ooxml/drawingml/diagram"
|
|
7642
|
+
]);
|
|
7643
|
+
function parseShapeTree(spTree, partPath, nextId, orderedChildren) {
|
|
7644
|
+
if (!spTree) return [];
|
|
7645
|
+
if (orderedChildren !== void 0) {
|
|
7646
|
+
return parseShapeTreeOrdered(spTree, partPath, nextId, orderedChildren);
|
|
7971
7647
|
}
|
|
7972
|
-
const
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
if (
|
|
7976
|
-
|
|
7648
|
+
const nodes = [];
|
|
7649
|
+
let orderingSlot = 0;
|
|
7650
|
+
for (const key of Object.keys(spTree)) {
|
|
7651
|
+
if (key.startsWith("@_")) continue;
|
|
7652
|
+
if (key === "#text") continue;
|
|
7653
|
+
const local = localName(key);
|
|
7654
|
+
if (local === "nvGrpSpPr" || local === "grpSpPr") continue;
|
|
7655
|
+
const value = spTree[key];
|
|
7656
|
+
const items = Array.isArray(value) ? value : [value];
|
|
7657
|
+
for (const item of items) {
|
|
7658
|
+
const node = unsafeOoxmlBoundaryAssertion(item);
|
|
7659
|
+
if (local === "sp") {
|
|
7660
|
+
nodes.push(parseShape(node, partPath, nextId, orderingSlot));
|
|
7661
|
+
} else if (local === "pic") {
|
|
7662
|
+
nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
7663
|
+
} else if (local === "cxnSp") {
|
|
7664
|
+
nodes.push(parseConnector(node, partPath, nextId, orderingSlot));
|
|
7665
|
+
} else if (local === "grpSp") {
|
|
7666
|
+
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
7667
|
+
} else if (local === "graphicFrame") {
|
|
7668
|
+
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
7669
|
+
} else if (local === "AlternateContent") {
|
|
7670
|
+
const parsed = parseAlternateContent(node, partPath, nextId, orderingSlot);
|
|
7671
|
+
nodes.push(...parsed);
|
|
7672
|
+
} else {
|
|
7673
|
+
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
7674
|
+
}
|
|
7675
|
+
orderingSlot++;
|
|
7977
7676
|
}
|
|
7978
7677
|
}
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7678
|
+
return nodes;
|
|
7679
|
+
}
|
|
7680
|
+
function parseShapeTreeOrdered(spTree, partPath, nextId, orderedChildren) {
|
|
7681
|
+
const nodes = [];
|
|
7682
|
+
const tagCounters = {};
|
|
7683
|
+
let orderingSlot = 0;
|
|
7684
|
+
for (const child of orderedChildren) {
|
|
7685
|
+
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
7686
|
+
if (key === void 0) continue;
|
|
7687
|
+
const local = localName(key);
|
|
7688
|
+
if (local === "AlternateContent") {
|
|
7689
|
+
const index2 = tagCounters[local] ?? 0;
|
|
7690
|
+
tagCounters[local] = index2 + 1;
|
|
7691
|
+
const alternateContents = getChildArray(spTree, "AlternateContent");
|
|
7692
|
+
const alternateContent = alternateContents[index2];
|
|
7693
|
+
if (alternateContent !== void 0) {
|
|
7694
|
+
nodes.push(...parseAlternateContent(alternateContent, partPath, nextId, orderingSlot));
|
|
7695
|
+
orderingSlot++;
|
|
7696
|
+
}
|
|
7697
|
+
continue;
|
|
7992
7698
|
}
|
|
7699
|
+
if (!SHAPE_TREE_NODE_TAGS.has(local)) continue;
|
|
7700
|
+
const index = tagCounters[local] ?? 0;
|
|
7701
|
+
tagCounters[local] = index + 1;
|
|
7702
|
+
const node = getChildArray(spTree, local)[index];
|
|
7703
|
+
if (node === void 0) continue;
|
|
7704
|
+
nodes.push(parseShapeTreeNode(local, node, child, partPath, nextId, orderingSlot));
|
|
7705
|
+
orderingSlot++;
|
|
7993
7706
|
}
|
|
7994
|
-
return
|
|
7995
|
-
}
|
|
7996
|
-
function parseEffectList(effectList) {
|
|
7997
|
-
if (effectList === void 0) return void 0;
|
|
7998
|
-
const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
|
|
7999
|
-
const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
|
|
8000
|
-
const glow = parseGlow(getChild(effectList, "glow"));
|
|
8001
|
-
const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
|
|
8002
|
-
const parsed = {
|
|
8003
|
-
...outerShadow !== void 0 ? { outerShadow } : {},
|
|
8004
|
-
...innerShadow !== void 0 ? { innerShadow } : {},
|
|
8005
|
-
...glow !== void 0 ? { glow } : {},
|
|
8006
|
-
...softEdge !== void 0 ? { softEdge } : {}
|
|
8007
|
-
};
|
|
8008
|
-
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
7707
|
+
return nodes;
|
|
8009
7708
|
}
|
|
8010
|
-
function
|
|
8011
|
-
if (
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
...clrChange !== void 0 ? { clrChange } : {}
|
|
8025
|
-
};
|
|
8026
|
-
return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
|
|
7709
|
+
function parseShapeTreeNode(local, node, orderedNode, partPath, nextId, orderingSlot) {
|
|
7710
|
+
if (local === "sp") return parseShape(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7711
|
+
if (local === "pic") return parseImage(node, partPath, nextId, orderingSlot);
|
|
7712
|
+
if (local === "cxnSp") {
|
|
7713
|
+
return parseConnector(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7714
|
+
}
|
|
7715
|
+
if (local === "grpSp") {
|
|
7716
|
+
const orderedGroupChildren = unsafeOoxmlBoundaryAssertion(orderedNode?.[local]);
|
|
7717
|
+
return parseGroup(node, partPath, nextId, orderingSlot, orderedGroupChildren);
|
|
7718
|
+
}
|
|
7719
|
+
if (local === "graphicFrame") {
|
|
7720
|
+
return parseGraphicFrame(node, partPath, nextId, orderingSlot, orderedNode);
|
|
7721
|
+
}
|
|
7722
|
+
return parseRawShapeNode(`p:${local}`, node, partPath, nextId, orderingSlot);
|
|
8027
7723
|
}
|
|
8028
|
-
function
|
|
8029
|
-
|
|
8030
|
-
const
|
|
8031
|
-
|
|
7724
|
+
function parseShape(sp, partPath, nextId, orderingSlot, orderedNode) {
|
|
7725
|
+
const nvSpPr = getChild(sp, "nvSpPr");
|
|
7726
|
+
const cNvPr = getChild(nvSpPr, "cNvPr");
|
|
7727
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7728
|
+
const name = getAttr(cNvPr, "name");
|
|
7729
|
+
const placeholder = parsePlaceholder(getChild(getChild(nvSpPr, "nvPr"), "ph"));
|
|
7730
|
+
const spPr = getChild(sp, "spPr");
|
|
7731
|
+
const transform = parseTransform(spPr);
|
|
7732
|
+
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "sp", "spPr"));
|
|
7733
|
+
const fill = parseFill(spPr, nextId);
|
|
7734
|
+
const outline = parseOutline(spPr, nextId);
|
|
7735
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7736
|
+
const style = parseShapeStyle(getChild(sp, "style"));
|
|
7737
|
+
const textBody = parseTextBody(
|
|
7738
|
+
getChild(sp, "txBody"),
|
|
7739
|
+
partPath,
|
|
7740
|
+
nextId,
|
|
7741
|
+
nodeId,
|
|
7742
|
+
orderingSlot,
|
|
7743
|
+
orderedNestedChildChildren(orderedNode, "sp", "txBody")
|
|
7744
|
+
);
|
|
7745
|
+
const rawSidecars = [
|
|
7746
|
+
...collectUnknownSidecars(sp, KNOWN_SHAPE_CHILDREN, nextId),
|
|
7747
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7748
|
+
...collectEffectSidecars(spPr, effects, nextId)
|
|
7749
|
+
];
|
|
8032
7750
|
return {
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
7751
|
+
kind: "shape",
|
|
7752
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7753
|
+
...name !== void 0 ? { name } : {},
|
|
7754
|
+
...transform !== void 0 ? { transform } : {},
|
|
7755
|
+
...geometry !== void 0 ? { geometry } : {},
|
|
7756
|
+
...fill !== void 0 ? { fill } : {},
|
|
7757
|
+
...outline !== void 0 ? { outline } : {},
|
|
7758
|
+
...effects !== void 0 ? { effects } : {},
|
|
7759
|
+
...style !== void 0 ? { style } : {},
|
|
7760
|
+
...textBody !== void 0 ? { textBody } : {},
|
|
7761
|
+
...placeholder !== void 0 ? { placeholder } : {},
|
|
7762
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7763
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8039
7764
|
};
|
|
8040
7765
|
}
|
|
8041
|
-
function
|
|
8042
|
-
|
|
8043
|
-
const
|
|
8044
|
-
|
|
7766
|
+
function parseConnector(cxnSp, partPath, nextId, orderingSlot, orderedNode) {
|
|
7767
|
+
const nvCxnSpPr = getChild(cxnSp, "nvCxnSpPr");
|
|
7768
|
+
const cNvPr = getChild(nvCxnSpPr, "cNvPr");
|
|
7769
|
+
const cNvCxnSpPr = getChild(nvCxnSpPr, "cNvCxnSpPr");
|
|
7770
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7771
|
+
const name = getAttr(cNvPr, "name");
|
|
7772
|
+
const connection = parseConnectorConnection(cNvCxnSpPr);
|
|
7773
|
+
const spPr = getChild(cxnSp, "spPr");
|
|
7774
|
+
const transform = parseTransform(spPr);
|
|
7775
|
+
const geometry = parseGeometry(spPr, orderedNestedChildChildren(orderedNode, "cxnSp", "spPr"));
|
|
7776
|
+
const outline = parseOutline(spPr, nextId);
|
|
7777
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7778
|
+
const style = parseShapeStyle(getChild(cxnSp, "style"));
|
|
7779
|
+
const rawSidecars = [
|
|
7780
|
+
...collectUnknownSidecars(cxnSp, KNOWN_CONNECTOR_CHILDREN, nextId),
|
|
7781
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7782
|
+
...collectEffectSidecars(spPr, effects, nextId)
|
|
7783
|
+
];
|
|
8045
7784
|
return {
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
7785
|
+
kind: "connector",
|
|
7786
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7787
|
+
...name !== void 0 ? { name } : {},
|
|
7788
|
+
...connection !== void 0 ? { connection } : {},
|
|
7789
|
+
...transform !== void 0 ? { transform } : {},
|
|
7790
|
+
...geometry !== void 0 ? { geometry } : {},
|
|
7791
|
+
...outline !== void 0 ? { outline } : {},
|
|
7792
|
+
...effects !== void 0 ? { effects } : {},
|
|
7793
|
+
...style !== void 0 ? { style } : {},
|
|
7794
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7795
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8050
7796
|
};
|
|
8051
7797
|
}
|
|
8052
|
-
function
|
|
8053
|
-
|
|
8054
|
-
const
|
|
8055
|
-
|
|
7798
|
+
function parseConnectorConnection(cNvCxnSpPr) {
|
|
7799
|
+
const start = parseConnectorConnectionEndpoint(getChild(cNvCxnSpPr, "stCxn"));
|
|
7800
|
+
const end = parseConnectorConnectionEndpoint(getChild(cNvCxnSpPr, "endCxn"));
|
|
7801
|
+
return start !== void 0 || end !== void 0 ? {
|
|
7802
|
+
...start !== void 0 ? { start } : {},
|
|
7803
|
+
...end !== void 0 ? { end } : {}
|
|
7804
|
+
} : void 0;
|
|
7805
|
+
}
|
|
7806
|
+
function parseConnectorConnectionEndpoint(node) {
|
|
7807
|
+
const shapeId = getAttr(node, "id");
|
|
7808
|
+
const connectionSiteIndex = numericAttr2(node, "idx");
|
|
7809
|
+
if (shapeId === void 0 || connectionSiteIndex === void 0) return void 0;
|
|
8056
7810
|
return {
|
|
8057
|
-
|
|
8058
|
-
|
|
7811
|
+
shapeId: asSourceNodeId(shapeId),
|
|
7812
|
+
connectionSiteIndex
|
|
8059
7813
|
};
|
|
8060
7814
|
}
|
|
8061
|
-
function
|
|
8062
|
-
if (
|
|
8063
|
-
|
|
8064
|
-
|
|
7815
|
+
function parseShapeStyle(style) {
|
|
7816
|
+
if (style === void 0) return void 0;
|
|
7817
|
+
const fillRef = parseStyleReference(getChild(style, "fillRef"));
|
|
7818
|
+
const lineRef = parseStyleReference(getChild(style, "lnRef"));
|
|
7819
|
+
const effectRef = parseStyleReference(getChild(style, "effectRef"));
|
|
7820
|
+
const parsed = {
|
|
7821
|
+
...fillRef !== void 0 ? { fillRef } : {},
|
|
7822
|
+
...lineRef !== void 0 ? { lineRef } : {},
|
|
7823
|
+
...effectRef !== void 0 ? { effectRef } : {}
|
|
8065
7824
|
};
|
|
7825
|
+
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
8066
7826
|
}
|
|
8067
|
-
function
|
|
8068
|
-
if (
|
|
7827
|
+
function parseStyleReference(ref) {
|
|
7828
|
+
if (ref === void 0) return void 0;
|
|
7829
|
+
const index = numericAttr2(ref, "idx") ?? 0;
|
|
7830
|
+
const color = parseColorElement(ref);
|
|
8069
7831
|
return {
|
|
8070
|
-
|
|
7832
|
+
index,
|
|
7833
|
+
...color !== void 0 ? { color } : {}
|
|
8071
7834
|
};
|
|
8072
7835
|
}
|
|
8073
|
-
function
|
|
8074
|
-
|
|
7836
|
+
function parseGroup(grpSp, partPath, nextId, orderingSlot, orderedChildren) {
|
|
7837
|
+
const nvGrpSpPr = getChild(grpSp, "nvGrpSpPr");
|
|
7838
|
+
const cNvPr = getChild(nvGrpSpPr, "cNvPr");
|
|
7839
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7840
|
+
const name = getAttr(cNvPr, "name");
|
|
7841
|
+
const grpSpPr = getChild(grpSp, "grpSpPr");
|
|
7842
|
+
const transform = parseTransform(grpSpPr);
|
|
7843
|
+
const childTransform = parseChildTransform(grpSpPr, transform);
|
|
7844
|
+
const fill = parseFill(grpSpPr, nextId);
|
|
7845
|
+
const effects = parseEffectList(getChild(grpSpPr, "effectLst"));
|
|
7846
|
+
const rawSidecars = [
|
|
7847
|
+
...collectUnknownSidecars(grpSp, KNOWN_GROUP_CHILDREN, nextId),
|
|
7848
|
+
...collectUnknownSidecars(grpSpPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7849
|
+
...collectEffectSidecars(grpSpPr, effects, nextId)
|
|
7850
|
+
];
|
|
8075
7851
|
return {
|
|
8076
|
-
|
|
8077
|
-
|
|
7852
|
+
kind: "group",
|
|
7853
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7854
|
+
...name !== void 0 ? { name } : {},
|
|
7855
|
+
...transform !== void 0 ? { transform } : {},
|
|
7856
|
+
...childTransform !== void 0 ? { childTransform } : {},
|
|
7857
|
+
...fill !== void 0 ? { fill } : {},
|
|
7858
|
+
...effects !== void 0 ? { effects } : {},
|
|
7859
|
+
children: parseShapeTree(grpSp, partPath, nextId, orderedChildren),
|
|
7860
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
7861
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8078
7862
|
};
|
|
8079
7863
|
}
|
|
8080
|
-
function
|
|
8081
|
-
|
|
7864
|
+
function parseImage(pic, partPath, nextId, orderingSlot) {
|
|
7865
|
+
const cNvPr = getChild(getChild(pic, "nvPicPr"), "cNvPr");
|
|
7866
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
7867
|
+
const name = getAttr(cNvPr, "name");
|
|
7868
|
+
const blipFill = getChild(pic, "blipFill");
|
|
7869
|
+
const blip = getChild(blipFill, "blip");
|
|
7870
|
+
const embed = getNamespacedAttr(blip, "embed");
|
|
7871
|
+
const crop = parseCrop(getChild(blipFill, "srcRect"));
|
|
7872
|
+
const stretch = parseStretch(getChild(blipFill, "stretch"));
|
|
7873
|
+
const tile = parseImageFillTile(getChild(blipFill, "tile"));
|
|
7874
|
+
const blipEffects = parseBlipEffects(blip);
|
|
7875
|
+
const spPr = getChild(pic, "spPr");
|
|
7876
|
+
const transform = parseTransform(spPr);
|
|
7877
|
+
const effects = parseEffectList(getChild(spPr, "effectLst"));
|
|
7878
|
+
const rawSidecars = [
|
|
7879
|
+
...collectUnknownSidecars(pic, KNOWN_PICTURE_CHILDREN, nextId),
|
|
7880
|
+
...collectUnknownSidecars(spPr, KNOWN_SP_PR_CHILDREN, nextId),
|
|
7881
|
+
...collectEffectSidecars(spPr, effects, nextId),
|
|
7882
|
+
// Retains fill mode such as `a:stretch` / `a:tile` and recolor operation under blip.
|
|
7883
|
+
...collectUnknownSidecars(blipFill, KNOWN_BLIP_FILL_CHILDREN, nextId),
|
|
7884
|
+
...collectBlipEffectSidecars(blip, blipEffects, nextId)
|
|
7885
|
+
];
|
|
8082
7886
|
return {
|
|
8083
|
-
|
|
8084
|
-
|
|
7887
|
+
kind: "image",
|
|
7888
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7889
|
+
...name !== void 0 ? { name } : {},
|
|
7890
|
+
...transform !== void 0 ? { transform } : {},
|
|
7891
|
+
...embed !== void 0 ? { blipRelationshipId: asRelationshipId(embed) } : {},
|
|
7892
|
+
...crop !== void 0 ? { crop } : {},
|
|
7893
|
+
...stretch !== void 0 ? { stretch } : {},
|
|
7894
|
+
...tile !== void 0 ? { tile } : {},
|
|
7895
|
+
...effects !== void 0 ? { effects } : {},
|
|
7896
|
+
...blipEffects !== void 0 ? { blipEffects } : {},
|
|
7897
|
+
handle: {
|
|
7898
|
+
partPath,
|
|
7899
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
7900
|
+
...embed !== void 0 ? { relationshipId: asRelationshipId(embed) } : {},
|
|
7901
|
+
orderingSlot
|
|
7902
|
+
},
|
|
7903
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8085
7904
|
};
|
|
8086
7905
|
}
|
|
8087
|
-
function
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
for (const [key, value] of Object.entries(parent)) {
|
|
8102
|
-
if (key.startsWith("@_")) continue;
|
|
8103
|
-
const nodes = Array.isArray(value) ? value : [value];
|
|
8104
|
-
for (const node of nodes) {
|
|
8105
|
-
if (!isXmlNode(node)) continue;
|
|
8106
|
-
const color = parseColorChild(key, node);
|
|
8107
|
-
if (color !== void 0) colors.push(color);
|
|
7906
|
+
function collectEffectSidecars(spPr, effects, nextId) {
|
|
7907
|
+
const effectList = getChild(spPr, "effectLst");
|
|
7908
|
+
if (effectList === void 0) return [];
|
|
7909
|
+
const sidecars = collectUnknownSidecars(effectList, KNOWN_EFFECT_CHILDREN, nextId);
|
|
7910
|
+
const supportedChildren = [
|
|
7911
|
+
["outerShdw", effects?.outerShadow],
|
|
7912
|
+
["innerShdw", effects?.innerShadow],
|
|
7913
|
+
["glow", effects?.glow],
|
|
7914
|
+
["softEdge", effects?.softEdge]
|
|
7915
|
+
];
|
|
7916
|
+
for (const [name, parsed] of supportedChildren) {
|
|
7917
|
+
const node = getChild(effectList, name);
|
|
7918
|
+
if (node !== void 0 && parsed === void 0) {
|
|
7919
|
+
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
8108
7920
|
}
|
|
8109
7921
|
}
|
|
8110
|
-
return
|
|
8111
|
-
}
|
|
8112
|
-
function firstColorChild(parent) {
|
|
8113
|
-
return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
|
|
8114
|
-
}
|
|
8115
|
-
function parseColorChild(key, node) {
|
|
8116
|
-
const name = localName(key);
|
|
8117
|
-
return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
|
|
8118
|
-
}
|
|
8119
|
-
function isXmlNode(value) {
|
|
8120
|
-
return typeof value === "object" && value !== null;
|
|
7922
|
+
return sidecars;
|
|
8121
7923
|
}
|
|
8122
|
-
function
|
|
8123
|
-
|
|
8124
|
-
const
|
|
8125
|
-
|
|
7924
|
+
function collectBlipEffectSidecars(blip, effects, nextId) {
|
|
7925
|
+
if (blip === void 0) return [];
|
|
7926
|
+
const sidecars = collectUnknownSidecars(blip, KNOWN_BLIP_CHILDREN, nextId);
|
|
7927
|
+
const supportedChildren = [
|
|
7928
|
+
["grayscl", effects?.grayscale === true],
|
|
7929
|
+
["biLevel", effects?.biLevel],
|
|
7930
|
+
["blur", effects?.blur],
|
|
7931
|
+
["lum", effects?.lum],
|
|
7932
|
+
["duotone", effects?.duotone],
|
|
7933
|
+
["clrChange", effects?.clrChange]
|
|
7934
|
+
];
|
|
7935
|
+
for (const [name, parsed] of supportedChildren) {
|
|
7936
|
+
const node = getChild(blip, name);
|
|
7937
|
+
if (node !== void 0 && (parsed === void 0 || parsed === false)) {
|
|
7938
|
+
sidecars.push(makeSidecar(`a:${name}`, node, nextId));
|
|
7939
|
+
}
|
|
7940
|
+
}
|
|
7941
|
+
return sidecars;
|
|
8126
7942
|
}
|
|
8127
|
-
function
|
|
8128
|
-
|
|
8129
|
-
const
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
7943
|
+
function parseGraphicFrame(graphicFrame, partPath, nextId, orderingSlot, orderedNode) {
|
|
7944
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
7945
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
7946
|
+
const uri = getAttr(graphicData, "uri");
|
|
7947
|
+
if (uri !== void 0 && CHART_GRAPHIC_DATA_URIS.has(uri)) {
|
|
7948
|
+
const parsedChart = parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7949
|
+
if (parsedChart !== void 0) return parsedChart;
|
|
8134
7950
|
}
|
|
8135
|
-
if (
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
const fill = parseGradientFill(grad);
|
|
8139
|
-
return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
|
|
7951
|
+
if (uri !== void 0 && SMARTART_DIAGRAM_URIS.has(uri)) {
|
|
7952
|
+
const parsedSmartArt = parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot);
|
|
7953
|
+
if (parsedSmartArt !== void 0) return parsedSmartArt;
|
|
8140
7954
|
}
|
|
8141
|
-
const
|
|
8142
|
-
if (
|
|
8143
|
-
return
|
|
7955
|
+
const table = getChild(graphicData, "tbl");
|
|
7956
|
+
if (table === void 0) {
|
|
7957
|
+
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
8144
7958
|
}
|
|
8145
|
-
const
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
7959
|
+
const orderedGraphicChildren = orderedNestedChildChildren(orderedNode, "graphicFrame", "graphic");
|
|
7960
|
+
const orderedGraphicDataChildren = orderedChildChildren2(orderedGraphicChildren, "graphicData");
|
|
7961
|
+
const orderedTableChildren = orderedChildChildren2(orderedGraphicDataChildren, "tbl");
|
|
7962
|
+
const parsedTable = parseTable(
|
|
7963
|
+
table,
|
|
7964
|
+
graphicFrame,
|
|
7965
|
+
partPath,
|
|
7966
|
+
nextId,
|
|
7967
|
+
orderingSlot,
|
|
7968
|
+
orderedTableChildren
|
|
7969
|
+
);
|
|
7970
|
+
if (parsedTable === void 0) {
|
|
7971
|
+
return parseRawShapeNode("p:graphicFrame", graphicFrame, partPath, nextId, orderingSlot);
|
|
8149
7972
|
}
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
7973
|
+
return parsedTable;
|
|
7974
|
+
}
|
|
7975
|
+
function parseAlternateContent(alternateContent, partPath, nextId, orderingSlot) {
|
|
7976
|
+
const branches = [
|
|
7977
|
+
...getChildArray(alternateContent, "Choice"),
|
|
7978
|
+
...getChildArray(alternateContent, "Fallback")
|
|
7979
|
+
];
|
|
7980
|
+
for (const branch of branches) {
|
|
7981
|
+
const parsed = parseAlternateContentBranch(branch, partPath, nextId, orderingSlot);
|
|
7982
|
+
if (parsed.length > 0) {
|
|
7983
|
+
if (parsed.every((node) => node.kind === "raw")) {
|
|
7984
|
+
continue;
|
|
7985
|
+
}
|
|
7986
|
+
return parsed.map(
|
|
7987
|
+
(node) => attachRawSidecar(node, makeSidecar("mc:AlternateContent", alternateContent, nextId))
|
|
7988
|
+
);
|
|
7989
|
+
}
|
|
7990
|
+
}
|
|
7991
|
+
return [
|
|
7992
|
+
parseRawShapeNode("mc:AlternateContent", alternateContent, partPath, nextId, orderingSlot)
|
|
7993
|
+
];
|
|
7994
|
+
}
|
|
7995
|
+
function attachRawSidecar(node, sidecar) {
|
|
7996
|
+
if (node.kind === "raw") return node;
|
|
7997
|
+
return {
|
|
7998
|
+
...node,
|
|
7999
|
+
rawSidecars: [...node.rawSidecars ?? [], sidecar]
|
|
8000
|
+
};
|
|
8001
|
+
}
|
|
8002
|
+
function parseAlternateContentBranch(branch, partPath, nextId, orderingSlot) {
|
|
8003
|
+
const nodes = [];
|
|
8004
|
+
for (const key of Object.keys(branch)) {
|
|
8005
|
+
if (key.startsWith("@_") || key === "#text") continue;
|
|
8006
|
+
const local = localName(key);
|
|
8007
|
+
const value = branch[key];
|
|
8008
|
+
const items = Array.isArray(value) ? value : [value];
|
|
8009
|
+
for (const item of items) {
|
|
8010
|
+
const node = unsafeOoxmlBoundaryAssertion(item);
|
|
8011
|
+
if (local === "sp") nodes.push(parseShape(node, partPath, nextId, orderingSlot));
|
|
8012
|
+
else if (local === "pic") nodes.push(parseImage(node, partPath, nextId, orderingSlot));
|
|
8013
|
+
else if (local === "cxnSp") {
|
|
8014
|
+
nodes.push(parseConnector(node, partPath, nextId, orderingSlot));
|
|
8015
|
+
} else if (local === "grpSp") {
|
|
8016
|
+
nodes.push(parseGroup(node, partPath, nextId, orderingSlot));
|
|
8017
|
+
} else if (local === "graphicFrame") {
|
|
8018
|
+
nodes.push(parseGraphicFrame(node, partPath, nextId, orderingSlot));
|
|
8019
|
+
} else {
|
|
8020
|
+
nodes.push(parseRawShapeNode(key, node, partPath, nextId, orderingSlot));
|
|
8021
|
+
}
|
|
8153
8022
|
}
|
|
8154
8023
|
}
|
|
8155
|
-
return
|
|
8024
|
+
return nodes;
|
|
8156
8025
|
}
|
|
8157
|
-
function
|
|
8158
|
-
const
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
const
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
const r = numericAttr2(fillToRect, "r") ?? 0;
|
|
8174
|
-
const b = numericAttr2(fillToRect, "b") ?? 0;
|
|
8175
|
-
return {
|
|
8176
|
-
kind: "gradient",
|
|
8177
|
-
gradientType: "radial",
|
|
8178
|
-
stops,
|
|
8179
|
-
centerX: (l + (1e5 - r)) / 2 / 1e5,
|
|
8180
|
-
centerY: (t + (1e5 - b)) / 2 / 1e5
|
|
8181
|
-
};
|
|
8182
|
-
}
|
|
8026
|
+
function parseChartGraphicFrame(graphicFrame, partPath, nextId, orderingSlot) {
|
|
8027
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
8028
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
8029
|
+
const chart = getChild(graphicData, "chart");
|
|
8030
|
+
const rId = getNamespacedAttr(chart, "id") ?? getAttr(chart, "id");
|
|
8031
|
+
if (rId === void 0) return void 0;
|
|
8032
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8033
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8034
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
8035
|
+
const name = getAttr(cNvPr, "name");
|
|
8036
|
+
const transform = parseTransform(graphicFrame);
|
|
8037
|
+
const rawSidecars = [
|
|
8038
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8039
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8040
|
+
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
8041
|
+
];
|
|
8183
8042
|
return {
|
|
8184
|
-
kind: "
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8043
|
+
kind: "chart",
|
|
8044
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8045
|
+
...name !== void 0 ? { name } : {},
|
|
8046
|
+
...transform !== void 0 ? { transform } : {},
|
|
8047
|
+
chartRelationshipId: asRelationshipId(rId),
|
|
8048
|
+
handle: {
|
|
8049
|
+
partPath,
|
|
8050
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8051
|
+
relationshipId: asRelationshipId(rId),
|
|
8052
|
+
orderingSlot
|
|
8053
|
+
},
|
|
8054
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8188
8055
|
};
|
|
8189
8056
|
}
|
|
8190
|
-
function
|
|
8191
|
-
const
|
|
8192
|
-
const
|
|
8193
|
-
|
|
8194
|
-
const
|
|
8057
|
+
function parseSmartArtGraphicFrame(graphicFrame, partPath, nextId, orderingSlot) {
|
|
8058
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
8059
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
8060
|
+
const relIds = getChild(graphicData, "relIds");
|
|
8061
|
+
const dmRId = getNamespacedAttr(relIds, "dm") ?? getAttr(relIds, "dm");
|
|
8062
|
+
if (dmRId === void 0) return void 0;
|
|
8063
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8064
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8065
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
8066
|
+
const name = getAttr(cNvPr, "name");
|
|
8067
|
+
const transform = parseTransform(graphicFrame);
|
|
8068
|
+
const rawSidecars = [
|
|
8069
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8070
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8071
|
+
...collectUnknownSidecars(graphicData, EMPTY_KNOWN, nextId)
|
|
8072
|
+
];
|
|
8195
8073
|
return {
|
|
8196
|
-
kind: "
|
|
8197
|
-
|
|
8198
|
-
...
|
|
8074
|
+
kind: "smartArt",
|
|
8075
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8076
|
+
...name !== void 0 ? { name } : {},
|
|
8077
|
+
...transform !== void 0 ? { transform } : {},
|
|
8078
|
+
dataRelationshipId: asRelationshipId(dmRId),
|
|
8079
|
+
handle: {
|
|
8080
|
+
partPath,
|
|
8081
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8082
|
+
relationshipId: asRelationshipId(dmRId),
|
|
8083
|
+
orderingSlot
|
|
8084
|
+
},
|
|
8085
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8199
8086
|
};
|
|
8200
8087
|
}
|
|
8201
|
-
function
|
|
8202
|
-
|
|
8203
|
-
|
|
8088
|
+
function parseTable(tbl, graphicFrame, partPath, nextId, orderingSlot, orderedTableChildren) {
|
|
8089
|
+
const columns = parseTableColumns(getChild(tbl, "tblGrid"));
|
|
8090
|
+
if (columns.length === 0) return void 0;
|
|
8091
|
+
const nvGraphicFramePr = getChild(graphicFrame, "nvGraphicFramePr");
|
|
8092
|
+
const cNvPr = getChild(nvGraphicFramePr, "cNvPr");
|
|
8093
|
+
const nodeId = sourceNodeId(cNvPr);
|
|
8094
|
+
const name = getAttr(cNvPr, "name");
|
|
8095
|
+
const tblPr = getChild(tbl, "tblPr");
|
|
8096
|
+
const tableStyleId = getChildText(tblPr, "tableStyleId");
|
|
8097
|
+
const graphic = getChild(graphicFrame, "graphic");
|
|
8098
|
+
const graphicData = getChild(graphic, "graphicData");
|
|
8099
|
+
const transform = parseTransform(graphicFrame);
|
|
8100
|
+
const rows = parseTableRows(tbl, partPath, nextId, nodeId, orderingSlot, orderedTableChildren);
|
|
8101
|
+
const rawSidecars = [
|
|
8102
|
+
...collectUnknownSidecars(graphicFrame, KNOWN_GRAPHIC_FRAME_CHILDREN, nextId),
|
|
8103
|
+
...collectUnknownSidecars(graphic, KNOWN_GRAPHIC_CHILDREN, nextId),
|
|
8104
|
+
...collectUnknownSidecars(graphicData, KNOWN_GRAPHIC_DATA_CHILDREN, nextId),
|
|
8105
|
+
...collectUnknownSidecars(tbl, KNOWN_TABLE_CHILDREN, nextId)
|
|
8106
|
+
];
|
|
8204
8107
|
return {
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8108
|
+
kind: "table",
|
|
8109
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8110
|
+
...name !== void 0 ? { name } : {},
|
|
8111
|
+
...transform !== void 0 ? { transform } : {},
|
|
8112
|
+
table: {
|
|
8113
|
+
columns,
|
|
8114
|
+
rows,
|
|
8115
|
+
...tableStyleId !== void 0 ? { tableStyleId } : {}
|
|
8116
|
+
},
|
|
8117
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot },
|
|
8118
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8211
8119
|
};
|
|
8212
8120
|
}
|
|
8213
|
-
function
|
|
8214
|
-
return
|
|
8121
|
+
function parseTableColumns(tblGrid) {
|
|
8122
|
+
return getChildArray(tblGrid, "gridCol").map((col) => ({ width: emuAttr(col, "w") }));
|
|
8215
8123
|
}
|
|
8216
|
-
function
|
|
8217
|
-
const
|
|
8218
|
-
|
|
8219
|
-
|
|
8124
|
+
function parseTableRows(tbl, partPath, nextId, tableNodeId, tableOrderingSlot, orderedTableChildren) {
|
|
8125
|
+
const orderedRows = orderedChildChildrenList(orderedTableChildren, "tr");
|
|
8126
|
+
return getChildArray(tbl, "tr").map((tr, rowIndex) => ({
|
|
8127
|
+
height: emuAttr(tr, "h"),
|
|
8128
|
+
cells: getChildArray(tr, "tc").map((tc, cellIndex) => {
|
|
8129
|
+
const orderedCells = orderedChildChildrenList(orderedRows[rowIndex], "tc");
|
|
8130
|
+
return parseTableCell(
|
|
8131
|
+
tc,
|
|
8132
|
+
partPath,
|
|
8133
|
+
nextId,
|
|
8134
|
+
tableNodeId,
|
|
8135
|
+
tableOrderingSlot,
|
|
8136
|
+
rowIndex,
|
|
8137
|
+
cellIndex,
|
|
8138
|
+
orderedCells[cellIndex]
|
|
8139
|
+
);
|
|
8140
|
+
})
|
|
8141
|
+
}));
|
|
8142
|
+
}
|
|
8143
|
+
function parseTableCell(tc, partPath, nextId, tableNodeId, tableOrderingSlot, rowIndex, cellIndex, orderedCellChildren) {
|
|
8144
|
+
const tcPr = getChild(tc, "tcPr");
|
|
8145
|
+
const textOrderingSlot = tableOrderingSlot * 1e9 + rowIndex * 1e6 + cellIndex;
|
|
8146
|
+
const textBody = parseTextBody(
|
|
8147
|
+
getChild(tc, "txBody"),
|
|
8148
|
+
partPath,
|
|
8149
|
+
nextId,
|
|
8150
|
+
tableNodeId,
|
|
8151
|
+
textOrderingSlot,
|
|
8152
|
+
orderedChildChildren2(orderedCellChildren, "txBody")
|
|
8153
|
+
);
|
|
8154
|
+
const fill = parseFill(tcPr, nextId);
|
|
8155
|
+
const borders = parseCellBorders(tcPr, nextId);
|
|
8156
|
+
const rawSidecars = [
|
|
8157
|
+
...collectUnknownSidecars(tc, KNOWN_TABLE_CELL_CHILDREN, nextId),
|
|
8158
|
+
...collectUnknownSidecars(tcPr, KNOWN_TABLE_CELL_PROPERTIES_CHILDREN, nextId)
|
|
8159
|
+
];
|
|
8220
8160
|
return {
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8161
|
+
...textBody !== void 0 ? { textBody } : {},
|
|
8162
|
+
...fill !== void 0 ? { fill } : {},
|
|
8163
|
+
...borders !== void 0 ? { borders } : {},
|
|
8164
|
+
gridSpan: numericAttr2(tc, "gridSpan") ?? 1,
|
|
8165
|
+
rowSpan: numericAttr2(tc, "rowSpan") ?? 1,
|
|
8166
|
+
hMerge: isTrue(getAttr(tc, "hMerge") ?? getAttr(tcPr, "hMerge")),
|
|
8167
|
+
vMerge: isTrue(getAttr(tc, "vMerge") ?? getAttr(tcPr, "vMerge")),
|
|
8168
|
+
...rawSidecars.length > 0 ? { rawSidecars } : {}
|
|
8225
8169
|
};
|
|
8226
8170
|
}
|
|
8227
|
-
function
|
|
8228
|
-
const
|
|
8229
|
-
|
|
8171
|
+
function parseCellBorders(tcPr, nextId) {
|
|
8172
|
+
const left = parseLine(getChild(tcPr, "lnL"), nextId);
|
|
8173
|
+
const right = parseLine(getChild(tcPr, "lnR"), nextId);
|
|
8174
|
+
const top = parseLine(getChild(tcPr, "lnT"), nextId);
|
|
8175
|
+
const bottom = parseLine(getChild(tcPr, "lnB"), nextId);
|
|
8176
|
+
if (left === void 0 && right === void 0 && top === void 0 && bottom === void 0) {
|
|
8177
|
+
return void 0;
|
|
8178
|
+
}
|
|
8179
|
+
return {
|
|
8180
|
+
...top !== void 0 ? { top } : {},
|
|
8181
|
+
...bottom !== void 0 ? { bottom } : {},
|
|
8182
|
+
...left !== void 0 ? { left } : {},
|
|
8183
|
+
...right !== void 0 ? { right } : {}
|
|
8184
|
+
};
|
|
8230
8185
|
}
|
|
8231
|
-
function
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8186
|
+
function parseRawShapeNode(key, node, partPath, nextId, orderingSlot) {
|
|
8187
|
+
const nodeId = sourceNodeId(getChild(getChild(node, "nvSpPr"), "cNvPr"));
|
|
8188
|
+
return {
|
|
8189
|
+
kind: "raw",
|
|
8190
|
+
...nodeId !== void 0 ? { nodeId } : {},
|
|
8191
|
+
raw: makeSidecar(key, node, nextId),
|
|
8192
|
+
handle: { partPath, ...nodeId !== void 0 ? { nodeId } : {}, orderingSlot }
|
|
8193
|
+
};
|
|
8194
|
+
}
|
|
8195
|
+
function parsePlaceholder(ph) {
|
|
8196
|
+
if (!ph) return void 0;
|
|
8197
|
+
const type = getAttr(ph, "type");
|
|
8198
|
+
const index = numericAttr2(ph, "idx");
|
|
8199
|
+
if (type === void 0 && index === void 0) return void 0;
|
|
8241
8200
|
return {
|
|
8242
|
-
...
|
|
8243
|
-
...
|
|
8244
|
-
...dashStyle !== void 0 ? { dashStyle } : {},
|
|
8245
|
-
...customDash !== void 0 ? { customDash } : {},
|
|
8246
|
-
...lineCap !== void 0 ? { lineCap } : {},
|
|
8247
|
-
...lineJoin !== void 0 ? { lineJoin } : {},
|
|
8248
|
-
...headEnd !== void 0 ? { headEnd } : {},
|
|
8249
|
-
...tailEnd !== void 0 ? { tailEnd } : {}
|
|
8201
|
+
...type !== void 0 ? { type } : {},
|
|
8202
|
+
...index !== void 0 ? { index } : {}
|
|
8250
8203
|
};
|
|
8251
8204
|
}
|
|
8252
|
-
function
|
|
8253
|
-
const
|
|
8254
|
-
if (
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
|
|
8262
|
-
return void 0;
|
|
8205
|
+
function parseGeometry(spPr, orderedSpPr) {
|
|
8206
|
+
const prstGeom = getChild(spPr, "prstGeom");
|
|
8207
|
+
if (prstGeom) {
|
|
8208
|
+
const preset = getAttr(prstGeom, "prst");
|
|
8209
|
+
const adjustValues = parseAdjustValues(getChild(prstGeom, "avLst"));
|
|
8210
|
+
return preset !== void 0 ? {
|
|
8211
|
+
preset,
|
|
8212
|
+
...Object.keys(adjustValues).length > 0 ? { adjustValues } : {}
|
|
8213
|
+
} : void 0;
|
|
8263
8214
|
}
|
|
8264
|
-
const
|
|
8265
|
-
|
|
8266
|
-
|
|
8215
|
+
const customPaths = parseCustomGeometry(
|
|
8216
|
+
getChild(spPr, "custGeom"),
|
|
8217
|
+
orderedChildChildren2(orderedSpPr, "custGeom")
|
|
8218
|
+
);
|
|
8219
|
+
if (customPaths !== void 0) return { kind: "custom", paths: customPaths };
|
|
8220
|
+
return void 0;
|
|
8221
|
+
}
|
|
8222
|
+
function parseAdjustValues(avLst) {
|
|
8223
|
+
const adjustValues = {};
|
|
8224
|
+
for (const guide of getChildArray(avLst, "gd")) {
|
|
8225
|
+
const name = getAttr(guide, "name");
|
|
8226
|
+
const formula = getAttr(guide, "fmla");
|
|
8227
|
+
const match = formula?.match(/val\s+(-?\d+)/);
|
|
8228
|
+
if (name !== void 0 && match !== void 0 && match !== null) {
|
|
8229
|
+
adjustValues[name] = Number(match[1]);
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
return adjustValues;
|
|
8233
|
+
}
|
|
8234
|
+
function parseChildTransform(grpSpPr, fallback) {
|
|
8235
|
+
const xfrm = getChild(grpSpPr, "xfrm");
|
|
8236
|
+
const childOff = getChild(xfrm, "chOff");
|
|
8237
|
+
const childExt = getChild(xfrm, "chExt");
|
|
8238
|
+
const offsetX = numericAttr2(childOff, "x") ?? 0;
|
|
8239
|
+
const offsetY = numericAttr2(childOff, "y") ?? 0;
|
|
8240
|
+
const width = numericAttr2(childExt, "cx") ?? fallback?.width;
|
|
8241
|
+
const height = numericAttr2(childExt, "cy") ?? fallback?.height;
|
|
8242
|
+
if (width === void 0 || height === void 0) return void 0;
|
|
8267
8243
|
return {
|
|
8268
8244
|
offsetX: asEmu2(offsetX),
|
|
8269
8245
|
offsetY: asEmu2(offsetY),
|
|
8270
|
-
width: asEmu2(width),
|
|
8271
|
-
height: asEmu2(height)
|
|
8272
|
-
...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
|
|
8273
|
-
...isTrue(flipH) ? { flipHorizontal: true } : {},
|
|
8274
|
-
...isTrue(flipV) ? { flipVertical: true } : {}
|
|
8246
|
+
width: asEmu2(Number(width)),
|
|
8247
|
+
height: asEmu2(Number(height))
|
|
8275
8248
|
};
|
|
8276
8249
|
}
|
|
8277
|
-
function
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
if (!Number.isFinite(numeric)) continue;
|
|
8291
|
-
transforms.push({
|
|
8292
|
-
kind: transformKind,
|
|
8293
|
-
value: asOoxmlPercent(numeric)
|
|
8294
|
-
});
|
|
8295
|
-
}
|
|
8296
|
-
}
|
|
8297
|
-
return transforms.length > 0 ? { ...base, transforms } : base;
|
|
8250
|
+
function parseCrop(srcRect) {
|
|
8251
|
+
if (!srcRect) return void 0;
|
|
8252
|
+
const left = numericAttr2(srcRect, "l");
|
|
8253
|
+
const top = numericAttr2(srcRect, "t");
|
|
8254
|
+
const right = numericAttr2(srcRect, "r");
|
|
8255
|
+
const bottom = numericAttr2(srcRect, "b");
|
|
8256
|
+
const crop = {
|
|
8257
|
+
...left !== void 0 ? { left: asOoxmlPercent(left) } : {},
|
|
8258
|
+
...top !== void 0 ? { top: asOoxmlPercent(top) } : {},
|
|
8259
|
+
...right !== void 0 ? { right: asOoxmlPercent(right) } : {},
|
|
8260
|
+
...bottom !== void 0 ? { bottom: asOoxmlPercent(bottom) } : {}
|
|
8261
|
+
};
|
|
8262
|
+
return Object.keys(crop).length > 0 ? crop : void 0;
|
|
8298
8263
|
}
|
|
8299
|
-
function
|
|
8300
|
-
const
|
|
8301
|
-
if (
|
|
8302
|
-
const
|
|
8303
|
-
|
|
8264
|
+
function parseStretch(stretch) {
|
|
8265
|
+
const fillRect = getChild(stretch, "fillRect");
|
|
8266
|
+
if (fillRect === void 0) return void 0;
|
|
8267
|
+
const left = (numericAttr2(fillRect, "l") ?? 0) / 1e5;
|
|
8268
|
+
const top = (numericAttr2(fillRect, "t") ?? 0) / 1e5;
|
|
8269
|
+
const right = (numericAttr2(fillRect, "r") ?? 0) / 1e5;
|
|
8270
|
+
const bottom = (numericAttr2(fillRect, "b") ?? 0) / 1e5;
|
|
8271
|
+
if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
|
|
8272
|
+
return { left, top, right, bottom };
|
|
8304
8273
|
}
|
|
8305
|
-
function
|
|
8306
|
-
|
|
8274
|
+
function sourceNodeId(cNvPr) {
|
|
8275
|
+
const id = getAttr(cNvPr, "id");
|
|
8276
|
+
return id !== void 0 ? asSourceNodeId(id) : void 0;
|
|
8307
8277
|
}
|
|
8308
|
-
function
|
|
8309
|
-
|
|
8310
|
-
return parseEnumValue(value, DASH_STYLES);
|
|
8278
|
+
function emuAttr(node, attrName) {
|
|
8279
|
+
return asEmu2(numericAttr2(node, attrName) ?? 0);
|
|
8311
8280
|
}
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
const
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8281
|
+
var EMPTY_KNOWN = /* @__PURE__ */ new Set();
|
|
8282
|
+
function orderedChildChildren2(parent, childLocalName) {
|
|
8283
|
+
const child = parent?.find((entry) => {
|
|
8284
|
+
const key2 = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
8285
|
+
return key2 !== void 0 && localName(key2) === childLocalName;
|
|
8286
|
+
});
|
|
8287
|
+
if (child === void 0) return void 0;
|
|
8288
|
+
const key = Object.keys(child).find((candidate) => candidate !== ":@");
|
|
8289
|
+
const value = key !== void 0 ? child[key] : void 0;
|
|
8290
|
+
return Array.isArray(value) ? value : void 0;
|
|
8320
8291
|
}
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8292
|
+
function orderedChildChildrenList(parent, childLocalName) {
|
|
8293
|
+
if (parent === void 0) return [];
|
|
8294
|
+
return parent.filter((entry) => {
|
|
8295
|
+
const key = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
8296
|
+
return key !== void 0 && localName(key) === childLocalName;
|
|
8297
|
+
}).map((entry) => {
|
|
8298
|
+
const key = Object.keys(entry).find((candidate) => candidate !== ":@");
|
|
8299
|
+
const value = key !== void 0 ? entry[key] : void 0;
|
|
8300
|
+
return Array.isArray(value) ? value : void 0;
|
|
8301
|
+
});
|
|
8302
|
+
}
|
|
8303
|
+
function orderedNestedChildChildren(node, parentLocalName, childLocalName) {
|
|
8304
|
+
if (node === void 0) return void 0;
|
|
8305
|
+
const parentChildren = node[parentLocalName];
|
|
8306
|
+
return orderedChildChildren2(
|
|
8307
|
+
Array.isArray(parentChildren) ? parentChildren : void 0,
|
|
8308
|
+
childLocalName
|
|
8309
|
+
);
|
|
8310
|
+
}
|
|
8311
|
+
var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
|
|
8312
|
+
ignoreAttributes: false,
|
|
8313
|
+
attributeNamePrefix: "@_",
|
|
8314
|
+
format: false,
|
|
8315
|
+
suppressEmptyNode: true
|
|
8316
|
+
});
|
|
8317
|
+
var EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS = {
|
|
8318
|
+
bold: (value) => requireBooleanOrUndefined(value, "bold"),
|
|
8319
|
+
italic: (value) => requireBooleanOrUndefined(value, "italic"),
|
|
8320
|
+
underline: (value) => requireBooleanOrUndefined(value, "underline"),
|
|
8321
|
+
fontSize: (value) => {
|
|
8322
|
+
if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
|
|
8323
|
+
throw new Error("updateTextRunProperties: fontSize must be a finite positive pt value");
|
|
8324
|
+
}
|
|
8325
|
+
},
|
|
8326
|
+
color: (value) => {
|
|
8327
|
+
if (value === void 0) return;
|
|
8328
|
+
if (value.kind !== "srgb") {
|
|
8329
|
+
throw new Error("updateTextRunProperties: only srgb text run color is supported");
|
|
8330
|
+
}
|
|
8331
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(value.hex)) {
|
|
8332
|
+
throw new Error("updateTextRunProperties: srgb text run color must be a 6-digit hex value");
|
|
8333
|
+
}
|
|
8334
|
+
},
|
|
8335
|
+
typeface: (value) => {
|
|
8336
|
+
if (value !== void 0 && value.trim() === "") {
|
|
8337
|
+
throw new Error("updateTextRunProperties: typeface must be a non-empty string");
|
|
8338
|
+
}
|
|
8339
|
+
}
|
|
8325
8340
|
};
|
|
8326
|
-
|
|
8327
|
-
|
|
8341
|
+
var EDITABLE_TEXT_RUN_PROPERTIES = Object.keys(EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS).filter(
|
|
8342
|
+
(property) => property in EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS
|
|
8343
|
+
);
|
|
8344
|
+
var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
|
|
8345
|
+
var EDITABLE_PARAGRAPH_PROPERTIES = [
|
|
8346
|
+
"align",
|
|
8347
|
+
"level",
|
|
8348
|
+
"bullet"
|
|
8349
|
+
];
|
|
8350
|
+
var EDITABLE_PARAGRAPH_PROPERTY_SET = new Set(EDITABLE_PARAGRAPH_PROPERTIES);
|
|
8351
|
+
function requireBooleanOrUndefined(value, fieldName) {
|
|
8352
|
+
if (value !== void 0 && typeof value !== "boolean") {
|
|
8353
|
+
throw new Error(`updateTextRunProperties: ${fieldName} must be a boolean value`);
|
|
8354
|
+
}
|
|
8328
8355
|
}
|
|
8329
|
-
function
|
|
8330
|
-
|
|
8331
|
-
if (hasChild(ln, "bevel")) return "bevel";
|
|
8332
|
-
if (hasChild(ln, "miter")) return "miter";
|
|
8333
|
-
return void 0;
|
|
8356
|
+
function asEmu2(value) {
|
|
8357
|
+
return unsafeBrandAssertion2(value);
|
|
8334
8358
|
}
|
|
8335
|
-
function
|
|
8336
|
-
|
|
8337
|
-
const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES2);
|
|
8338
|
-
if (type === void 0) return void 0;
|
|
8339
|
-
const width = getAttr(node, "w") ?? "med";
|
|
8340
|
-
const length = getAttr(node, "len") ?? "med";
|
|
8341
|
-
return {
|
|
8342
|
-
type,
|
|
8343
|
-
width: parseEnumValueWithDefault(width, ARROW_SIZES2, "med"),
|
|
8344
|
-
length: parseEnumValueWithDefault(length, ARROW_SIZES2, "med")
|
|
8345
|
-
};
|
|
8359
|
+
function asPt(value) {
|
|
8360
|
+
return unsafeBrandAssertion2(value);
|
|
8346
8361
|
}
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
var
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
var
|
|
8362
|
+
function asHundredthPt2(value) {
|
|
8363
|
+
return unsafeBrandAssertion2(value);
|
|
8364
|
+
}
|
|
8365
|
+
function asOoxmlPercent(value) {
|
|
8366
|
+
return unsafeBrandAssertion2(value);
|
|
8367
|
+
}
|
|
8368
|
+
function asOoxmlAngle(value) {
|
|
8369
|
+
return unsafeBrandAssertion2(value);
|
|
8370
|
+
}
|
|
8371
|
+
var textEncoder = new TextEncoder();
|
|
8372
|
+
var ROOT_PART = asPartPath("");
|
|
8373
|
+
var PRESENTATION_PART = asPartPath("ppt/presentation.xml");
|
|
8374
|
+
var SLIDE_PART = asPartPath("ppt/slides/slide1.xml");
|
|
8375
|
+
var SLIDE_LAYOUT_PART = asPartPath("ppt/slideLayouts/slideLayout1.xml");
|
|
8376
|
+
var SLIDE_MASTER_PART = asPartPath("ppt/slideMasters/slideMaster1.xml");
|
|
8377
|
+
var THEME_PART = asPartPath("ppt/theme/theme1.xml");
|
|
8378
|
+
var APP_PROPS_PART = asPartPath("docProps/app.xml");
|
|
8379
|
+
var CORE_PROPS_PART = asPartPath("docProps/core.xml");
|
|
8365
8380
|
var DEFAULT_COLOR_MAP = {
|
|
8366
8381
|
bg1: "lt1",
|
|
8367
8382
|
tx1: "dk1",
|
|
@@ -8925,7 +8940,7 @@ function computeConnectorElement(context, connector, layer, partPath) {
|
|
|
8925
8940
|
sourceNode: connector,
|
|
8926
8941
|
...connector.transform !== void 0 ? { transform: connector.transform } : {},
|
|
8927
8942
|
...connector.geometry !== void 0 ? { geometry: connector.geometry } : {},
|
|
8928
|
-
...
|
|
8943
|
+
...computedOutlineProperty(context, connector.outline, connector.style?.lineRef, partPath),
|
|
8929
8944
|
...effects !== void 0 ? { effects } : {}
|
|
8930
8945
|
};
|
|
8931
8946
|
}
|
|
@@ -8969,7 +8984,7 @@ function computeShapeElement(context, shape, layer, partPath) {
|
|
|
8969
8984
|
...transform !== void 0 ? { transform } : {},
|
|
8970
8985
|
...geometry !== void 0 ? { geometry } : {},
|
|
8971
8986
|
...shape.fill !== void 0 ? { fill: computeFill(context, shape.fill, partPath) } : shape.style?.fillRef !== void 0 ? { fill: resolveFillReference(context, shape.style.fillRef, partPath) } : {},
|
|
8972
|
-
...
|
|
8987
|
+
...computedOutlineProperty(context, shape.outline, shape.style?.lineRef, partPath),
|
|
8973
8988
|
...effects !== void 0 ? { effects } : {},
|
|
8974
8989
|
...shape.textBody !== void 0 ? {
|
|
8975
8990
|
textBody: computeTextBody(
|
|
@@ -8984,7 +8999,7 @@ function computeShapeElement(context, shape, layer, partPath) {
|
|
|
8984
8999
|
}
|
|
8985
9000
|
function computeImageElement(context, image, layer, partPath) {
|
|
8986
9001
|
const relationship = resolveComputedRelationships(context.source, partPath).find(
|
|
8987
|
-
(
|
|
9002
|
+
(rel2) => rel2.id === image.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
|
|
8988
9003
|
);
|
|
8989
9004
|
const effects = image.effects !== void 0 ? computeEffectList(context, image.effects) : void 0;
|
|
8990
9005
|
const blipEffects = image.blipEffects !== void 0 ? computeBlipEffects(context, image.blipEffects) : void 0;
|
|
@@ -9015,7 +9030,7 @@ function computeTableElement(context, table, layer, partPath) {
|
|
|
9015
9030
|
}
|
|
9016
9031
|
function computeChartElement(context, chart, layer, partPath) {
|
|
9017
9032
|
const relationship = context.relationships.find(
|
|
9018
|
-
(
|
|
9033
|
+
(rel2) => rel2.id === chart.chartRelationshipId && CHART_REL_TYPES.has(rel2.type)
|
|
9019
9034
|
);
|
|
9020
9035
|
const chartXml = relationship?.targetPartPath !== void 0 ? readRawPackageText(context.source, relationship.targetPartPath) : void 0;
|
|
9021
9036
|
const chartData = chartXml !== void 0 ? parseComputedChartData(chartXml, context) : void 0;
|
|
@@ -9032,11 +9047,11 @@ function computeChartElement(context, chart, layer, partPath) {
|
|
|
9032
9047
|
}
|
|
9033
9048
|
function computeSmartArtElement(context, smartArt, layer, partPath) {
|
|
9034
9049
|
const dataRelationship = context.relationships.find(
|
|
9035
|
-
(
|
|
9050
|
+
(rel2) => rel2.id === smartArt.dataRelationshipId && DIAGRAM_DATA_REL_TYPES.has(rel2.type)
|
|
9036
9051
|
);
|
|
9037
9052
|
const dataRelationships = dataRelationship?.targetPartPath !== void 0 ? resolveComputedRelationships(context.source, dataRelationship.targetPartPath) : [];
|
|
9038
9053
|
const drawingRelationship = dataRelationships.find(
|
|
9039
|
-
(
|
|
9054
|
+
(rel2) => DIAGRAM_DRAWING_REL_TYPES.has(rel2.type)
|
|
9040
9055
|
);
|
|
9041
9056
|
const drawingPartPath = drawingRelationship?.targetPartPath;
|
|
9042
9057
|
const drawingXml = drawingPartPath !== void 0 ? readRawPackageText(context.source, drawingPartPath) : void 0;
|
|
@@ -9182,7 +9197,7 @@ function computeFill(context, fill, partPath) {
|
|
|
9182
9197
|
};
|
|
9183
9198
|
case "image": {
|
|
9184
9199
|
const relationship = resolveComputedRelationships(context.source, partPath).find(
|
|
9185
|
-
(
|
|
9200
|
+
(rel2) => rel2.id === fill.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
|
|
9186
9201
|
);
|
|
9187
9202
|
return {
|
|
9188
9203
|
kind: "image",
|
|
@@ -9207,6 +9222,24 @@ function computeOutline(context, outline, partPath) {
|
|
|
9207
9222
|
...outline.fill !== void 0 ? { fill: computeFill(context, outline.fill, partPath) } : {}
|
|
9208
9223
|
};
|
|
9209
9224
|
}
|
|
9225
|
+
function computedOutlineProperty(context, outline, lineRef, partPath) {
|
|
9226
|
+
const styleOutline = lineRef !== void 0 ? resolveLineReference(context, lineRef, partPath) : void 0;
|
|
9227
|
+
if (outline === void 0) {
|
|
9228
|
+
return styleOutline !== void 0 ? { outline: styleOutline } : {};
|
|
9229
|
+
}
|
|
9230
|
+
const computed = mergeComputedOutline(styleOutline, computeOutline(context, outline, partPath));
|
|
9231
|
+
return { outline: computed };
|
|
9232
|
+
}
|
|
9233
|
+
function mergeComputedOutline(base, override) {
|
|
9234
|
+
if (base === void 0) return override;
|
|
9235
|
+
const width = override.width ?? base.width;
|
|
9236
|
+
const fill = override.fill ?? base.fill;
|
|
9237
|
+
return {
|
|
9238
|
+
source: { ...base.source, ...override.source },
|
|
9239
|
+
...width !== void 0 ? { width } : {},
|
|
9240
|
+
...fill !== void 0 ? { fill } : {}
|
|
9241
|
+
};
|
|
9242
|
+
}
|
|
9210
9243
|
function resolveFillReference(context, ref, partPath) {
|
|
9211
9244
|
if (ref.index === 0) return void 0;
|
|
9212
9245
|
const list = ref.index >= 1e3 ? context.theme?.formatScheme?.backgroundFillStyles : context.theme?.formatScheme?.fillStyles;
|
|
@@ -9795,7 +9828,7 @@ var SLIDE_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/rel
|
|
|
9795
9828
|
var SLIDE_LAYOUT_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
|
9796
9829
|
var SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
|
9797
9830
|
var THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
9798
|
-
var
|
|
9831
|
+
var PRESENTATION_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
|
|
9799
9832
|
var textDecoder3 = new TextDecoder();
|
|
9800
9833
|
function readPptx(input) {
|
|
9801
9834
|
const entries = unzipPackage(input);
|
|
@@ -9962,15 +9995,15 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
|
|
|
9962
9995
|
return { root, orderedRoot };
|
|
9963
9996
|
}
|
|
9964
9997
|
function resolveSingleRel(relationships, sourcePart, relType) {
|
|
9965
|
-
const rels = relationships.find((
|
|
9966
|
-
const match = rels?.find((
|
|
9998
|
+
const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships;
|
|
9999
|
+
const match = rels?.find((rel2) => rel2.type === relType && rel2.targetMode !== "External");
|
|
9967
10000
|
if (match === void 0) return void 0;
|
|
9968
10001
|
return resolveInternalRelationshipTarget(sourcePart, match);
|
|
9969
10002
|
}
|
|
9970
10003
|
function resolveAllRels(relationships, sourcePart, relType) {
|
|
9971
|
-
const rels = relationships.find((
|
|
9972
|
-
return rels.filter((
|
|
9973
|
-
const target = resolveInternalRelationshipTarget(sourcePart,
|
|
10004
|
+
const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships ?? [];
|
|
10005
|
+
return rels.filter((rel2) => rel2.type === relType && rel2.targetMode !== "External").flatMap((rel2) => {
|
|
10006
|
+
const target = resolveInternalRelationshipTarget(sourcePart, rel2);
|
|
9974
10007
|
return target === void 0 ? [] : [target];
|
|
9975
10008
|
});
|
|
9976
10009
|
}
|
|
@@ -10059,7 +10092,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
|
|
|
10059
10092
|
const slideSize = readSlideSize(root);
|
|
10060
10093
|
const defaultTextStyle = parseTextStyle(getChild(root, "defaultTextStyle"));
|
|
10061
10094
|
const presentationRels = relationships.find(
|
|
10062
|
-
(
|
|
10095
|
+
(rel2) => rel2.sourcePartPath === presentationPath
|
|
10063
10096
|
)?.relationships;
|
|
10064
10097
|
const slidePartPaths = [];
|
|
10065
10098
|
const sldIdLst = getChild(root, "sldIdLst");
|
|
@@ -10067,7 +10100,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
|
|
|
10067
10100
|
const relId = getNamespacedAttr(sldId, "id");
|
|
10068
10101
|
if (relId === void 0) continue;
|
|
10069
10102
|
const handle = { partPath: presentationPartPath, relationshipId: asRelationshipId(relId) };
|
|
10070
|
-
const relationship = presentationRels?.find((
|
|
10103
|
+
const relationship = presentationRels?.find((rel2) => rel2.id === relId);
|
|
10071
10104
|
if (relationship === void 0) {
|
|
10072
10105
|
diagnostics.push({
|
|
10073
10106
|
severity: "warning",
|
|
@@ -10110,15 +10143,15 @@ function readSlideSize(presentationRoot) {
|
|
|
10110
10143
|
}
|
|
10111
10144
|
function locatePresentationPart(relationships, overrides) {
|
|
10112
10145
|
const rootRels = relationships.find(
|
|
10113
|
-
(
|
|
10146
|
+
(rel2) => rel2.sourcePartPath === PACKAGE_ROOT_PART
|
|
10114
10147
|
)?.relationships;
|
|
10115
10148
|
const officeDocumentRel = rootRels?.find(
|
|
10116
|
-
(
|
|
10149
|
+
(rel2) => rel2.type === OFFICE_DOCUMENT_REL_TYPE && rel2.targetMode !== "External"
|
|
10117
10150
|
);
|
|
10118
10151
|
if (officeDocumentRel !== void 0) {
|
|
10119
10152
|
return resolveRelationshipTarget(PACKAGE_ROOT_PART, officeDocumentRel.target);
|
|
10120
10153
|
}
|
|
10121
|
-
const override = overrides.find((entry) => entry.contentType ===
|
|
10154
|
+
const override = overrides.find((entry) => entry.contentType === PRESENTATION_CONTENT_TYPE2);
|
|
10122
10155
|
return override?.partName;
|
|
10123
10156
|
}
|
|
10124
10157
|
var MEDIA_CONTENT_TYPE_PREFIXES = ["image/", "audio/", "video/"];
|
|
@@ -10146,7 +10179,7 @@ function extensionOf(path) {
|
|
|
10146
10179
|
function stripLeadingSlash(path) {
|
|
10147
10180
|
return path.startsWith("/") ? path.slice(1) : path;
|
|
10148
10181
|
}
|
|
10149
|
-
var
|
|
10182
|
+
var textEncoder2 = new TextEncoder();
|
|
10150
10183
|
var textDecoder4 = new TextDecoder();
|
|
10151
10184
|
var xmlBuilder2 = new import_fast_xml_parser3.XMLBuilder({
|
|
10152
10185
|
ignoreAttributes: false,
|