@office-open/core 0.10.2 → 0.10.3
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/chart/index.d.mts +1 -1
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +2 -2
- package/dist/{descriptor-BdWTH1vv.mjs → descriptor-DAER86Rt.mjs} +1 -26
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{index-vEeWkbm5.d.mts → index-3STznXzZ.d.mts} +1 -1
- package/dist/{index-DEeO4sOq.d.mts → index-BkEFbS8B.d.mts} +40 -26
- package/dist/{index-BEQ12eyX.d.mts → index-CN0YjNSx.d.mts} +1 -1
- package/dist/{index-L82O3q6V.d.mts → index-CpNwAcem.d.mts} +22 -23
- package/dist/{index-Bpw3LFuI.d.mts → index-Dl4z-M1N.d.mts} +187 -125
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +2 -2
- package/dist/{patch-DocIv0Sn.mjs → patch-DEPPafeB.mjs} +49 -4
- package/dist/{src-DaZbVB3f.mjs → src-BPRAxccL.mjs} +1359 -1257
- package/dist/theme/index.d.mts +1 -1
- package/package.json +2 -2
|
@@ -152,6 +152,22 @@ const patchSpaceAttribute = (element) => ({
|
|
|
152
152
|
attributes: { "xml:space": "preserve" }
|
|
153
153
|
});
|
|
154
154
|
const getFirstLevelElements = (relationships, id) => relationships.elements?.find((e) => e.name === id)?.elements ?? [];
|
|
155
|
+
/**
|
|
156
|
+
* Next sequential numeric id: the largest `attr` value among direct children
|
|
157
|
+
* named `childName`, plus one. `seed` is the floor — e.g. PPTX `<p:sldId>`
|
|
158
|
+
* values start at 255, so the first appended id is at least 256.
|
|
159
|
+
*
|
|
160
|
+
* Unifies the per-package `maxCommentId` / `maxSldId` / `maxSheetId` helpers.
|
|
161
|
+
*/
|
|
162
|
+
const nextNumericId = (parent, childName, attr, seed = 0) => {
|
|
163
|
+
let maxId = seed;
|
|
164
|
+
for (const child of parent?.elements ?? []) {
|
|
165
|
+
if (child.name !== childName) continue;
|
|
166
|
+
const id = Number(child.attributes?.[attr]);
|
|
167
|
+
if (Number.isFinite(id)) maxId = Math.max(maxId, id);
|
|
168
|
+
}
|
|
169
|
+
return maxId + 1;
|
|
170
|
+
};
|
|
155
171
|
//#endregion
|
|
156
172
|
//#region src/patch/paragraph-split-inject.ts
|
|
157
173
|
var TokenNotFoundError = class extends Error {
|
|
@@ -437,10 +453,21 @@ const goToParentElementFromPath = (json, path) => goToElementFromPath(json, path
|
|
|
437
453
|
const getLastElementIndexFromPath = (path) => path[path.length - 1];
|
|
438
454
|
//#endregion
|
|
439
455
|
//#region src/patch/content-types-manager.ts
|
|
456
|
+
/**
|
|
457
|
+
* The `<Types>` child array, initialized in place when absent (so a `<Default>`
|
|
458
|
+
* or `<Override>` can always be appended). Returns `undefined` if `element` has
|
|
459
|
+
* no `<Types>` child (malformed `[Content_Types].xml`).
|
|
460
|
+
*/
|
|
461
|
+
const typesChildren = (element) => {
|
|
462
|
+
const types = element.elements?.find((e) => e.name === "Types");
|
|
463
|
+
if (!types) return void 0;
|
|
464
|
+
return types.elements ?? (types.elements = []);
|
|
465
|
+
};
|
|
440
466
|
const appendContentType = (element, contentType, extension) => {
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
|
|
467
|
+
const els = typesChildren(element);
|
|
468
|
+
if (!els) return;
|
|
469
|
+
if (els.some((el) => el.type === "element" && el.name === "Default" && el?.attributes?.ContentType === contentType && el?.attributes?.Extension === extension)) return;
|
|
470
|
+
els.push({
|
|
444
471
|
attributes: {
|
|
445
472
|
ContentType: contentType,
|
|
446
473
|
Extension: extension
|
|
@@ -449,6 +476,24 @@ const appendContentType = (element, contentType, extension) => {
|
|
|
449
476
|
type: "element"
|
|
450
477
|
});
|
|
451
478
|
};
|
|
479
|
+
/**
|
|
480
|
+
* Append an `<Override>` element to a `[Content_Types].xml` root, deduped by
|
|
481
|
+
* `PartName`. Sibling to {@link appendContentType} (which handles `<Default>`):
|
|
482
|
+
* unifies the per-package Override-dedup blocks in docx/pptx/xlsx patchers.
|
|
483
|
+
*/
|
|
484
|
+
const appendOverride = (element, partName, contentType) => {
|
|
485
|
+
const els = typesChildren(element);
|
|
486
|
+
if (!els) return;
|
|
487
|
+
if (els.some((el) => el.type === "element" && el.name === "Override" && el?.attributes?.PartName === partName)) return;
|
|
488
|
+
els.push({
|
|
489
|
+
attributes: {
|
|
490
|
+
PartName: partName,
|
|
491
|
+
ContentType: contentType
|
|
492
|
+
},
|
|
493
|
+
name: "Override",
|
|
494
|
+
type: "element"
|
|
495
|
+
});
|
|
496
|
+
};
|
|
452
497
|
//#endregion
|
|
453
498
|
//#region src/patch/relationship-manager.ts
|
|
454
499
|
const getIdFromRelationshipId = (relationshipId) => {
|
|
@@ -481,4 +526,4 @@ function applyCorePropertiesOverride(corePropsDoc, overrides) {
|
|
|
481
526
|
});
|
|
482
527
|
}
|
|
483
528
|
//#endregion
|
|
484
|
-
export {
|
|
529
|
+
export { DOCX_NS as _, appendOverride as a, buildCorePropertiesXmlString as b, createRunRenderer as c, createSplitInject as d, createTextElementContents as f, toJson as g, patchSpaceAttribute as h, appendContentType as i, createTokenReplacer as l, nextNumericId as m, appendRelationship as n, createReplacer as o, getFirstLevelElements as p, getNextRelationshipIndex as r, createTraverser as s, applyCorePropertiesOverride as t, TokenNotFoundError as u, PPTX_NS as v, parseCorePropsElement as x, buildCorePropertiesXml as y };
|