@office-open/core 0.9.8 → 0.10.1
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/descriptor/index.mjs +1 -1
- package/dist/{descriptor-TtMXoZgS.mjs → descriptor-BdWTH1vv.mjs} +4 -3
- package/dist/drawingml/index.d.mts +1 -1
- package/dist/drawingml/index.mjs +1 -1
- package/dist/{index-CeVhA1an.d.mts → index-Bpw3LFuI.d.mts} +253 -209
- package/dist/index-DEeO4sOq.d.mts +239 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +2 -2
- package/dist/{patch-ilNZTQmG.mjs → patch-DocIv0Sn.mjs} +125 -3
- package/dist/{src-CSka9ln4.mjs → src-DaZbVB3f.mjs} +265 -154
- package/package.json +2 -2
- package/dist/index-DYy8l709.d.mts +0 -127
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Element } from "@office-open/xml";
|
|
2
|
-
|
|
3
|
-
//#region src/patch/xml-namespace.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Namespace configuration for XML patch operations.
|
|
6
|
-
*
|
|
7
|
-
* Parameterises element names so the same patch algorithm works for both
|
|
8
|
-
* DOCX (`w:*`) and PPTX (`a:*`) documents.
|
|
9
|
-
*/
|
|
10
|
-
interface XmlNamespaceConfig {
|
|
11
|
-
paragraph: string;
|
|
12
|
-
run: string;
|
|
13
|
-
text: string;
|
|
14
|
-
runProperties: string;
|
|
15
|
-
}
|
|
16
|
-
declare const DOCX_NS: XmlNamespaceConfig;
|
|
17
|
-
declare const PPTX_NS: XmlNamespaceConfig;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/patch/xml-replacer.d.ts
|
|
20
|
-
interface ReplacerConfig {
|
|
21
|
-
ns: XmlNamespaceConfig;
|
|
22
|
-
formatChild: (child: unknown, context: unknown) => Element[];
|
|
23
|
-
preserveSpace?: boolean;
|
|
24
|
-
}
|
|
25
|
-
interface ReplacerResult {
|
|
26
|
-
element: Element;
|
|
27
|
-
didFindOccurrence: boolean;
|
|
28
|
-
}
|
|
29
|
-
declare function createReplacer(config: ReplacerConfig): ({
|
|
30
|
-
json,
|
|
31
|
-
patch,
|
|
32
|
-
patchText,
|
|
33
|
-
context,
|
|
34
|
-
keepOriginalStyles
|
|
35
|
-
}: {
|
|
36
|
-
json: Element;
|
|
37
|
-
patch: {
|
|
38
|
-
type: string;
|
|
39
|
-
children: readonly unknown[];
|
|
40
|
-
};
|
|
41
|
-
patchText: string;
|
|
42
|
-
context: unknown;
|
|
43
|
-
keepOriginalStyles?: boolean;
|
|
44
|
-
}) => ReplacerResult;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/patch/run-renderer.d.ts
|
|
47
|
-
interface ElementWrapper {
|
|
48
|
-
element: Element;
|
|
49
|
-
index: number;
|
|
50
|
-
parent: ElementWrapper | undefined;
|
|
51
|
-
}
|
|
52
|
-
interface RenderedParagraphNode {
|
|
53
|
-
text: string;
|
|
54
|
-
runs: readonly RenderedRunNode[];
|
|
55
|
-
index: number;
|
|
56
|
-
pathToParagraph: readonly number[];
|
|
57
|
-
}
|
|
58
|
-
interface StartAndEnd {
|
|
59
|
-
start: number;
|
|
60
|
-
end: number;
|
|
61
|
-
}
|
|
62
|
-
type IParts = {
|
|
63
|
-
text: string;
|
|
64
|
-
index: number;
|
|
65
|
-
} & StartAndEnd;
|
|
66
|
-
type RenderedRunNode = {
|
|
67
|
-
text: string;
|
|
68
|
-
parts: readonly IParts[];
|
|
69
|
-
index: number;
|
|
70
|
-
} & StartAndEnd;
|
|
71
|
-
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/patch/xml-traverser.d.ts
|
|
74
|
-
declare function createTraverser(ns: XmlNamespaceConfig): {
|
|
75
|
-
traverse: (node: Element) => readonly RenderedParagraphNode[];
|
|
76
|
-
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
|
|
77
|
-
};
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/patch/paragraph-token-replacer.d.ts
|
|
80
|
-
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
|
|
81
|
-
readonly preserveSpace?: boolean;
|
|
82
|
-
}): ({
|
|
83
|
-
paragraphElement,
|
|
84
|
-
renderedParagraph,
|
|
85
|
-
originalText,
|
|
86
|
-
replacementText
|
|
87
|
-
}: {
|
|
88
|
-
paragraphElement: Element;
|
|
89
|
-
renderedParagraph: RenderedParagraphNode;
|
|
90
|
-
originalText: string;
|
|
91
|
-
replacementText: string;
|
|
92
|
-
}) => Element;
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/patch/paragraph-split-inject.d.ts
|
|
95
|
-
declare class TokenNotFoundError extends Error {
|
|
96
|
-
constructor(token: string);
|
|
97
|
-
}
|
|
98
|
-
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
|
|
99
|
-
readonly preserveSpace?: boolean;
|
|
100
|
-
}): {
|
|
101
|
-
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
|
|
102
|
-
splitRunElement: (runElement: Element, token: string) => {
|
|
103
|
-
readonly left: Element;
|
|
104
|
-
readonly right: Element;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/patch/xml-patch-utils.d.ts
|
|
109
|
-
declare const toJson: (xmlData: string) => Element;
|
|
110
|
-
/**
|
|
111
|
-
* Creates the inner content of a text element (`w:t` / `a:t`).
|
|
112
|
-
*
|
|
113
|
-
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
|
|
114
|
-
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
|
|
115
|
-
*/
|
|
116
|
-
declare const createTextElementContents: (text: string) => Element[];
|
|
117
|
-
declare const patchSpaceAttribute: (element: Element) => Element;
|
|
118
|
-
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/patch/content-types-manager.d.ts
|
|
121
|
-
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/patch/relationship-manager.d.ts
|
|
124
|
-
declare const getNextRelationshipIndex: (relationships: Element) => number;
|
|
125
|
-
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
|
|
126
|
-
//#endregion
|
|
127
|
-
export { PPTX_NS as _, getFirstLevelElements as a, TokenNotFoundError as c, createTraverser as d, RenderedParagraphNode as f, DOCX_NS as g, createReplacer as h, createTextElementContents as i, createSplitInject as l, ReplacerConfig as m, getNextRelationshipIndex as n, patchSpaceAttribute as o, createRunRenderer as p, appendContentType as r, toJson as s, appendRelationship as t, createTokenReplacer as u, XmlNamespaceConfig as v };
|