@docx4j/core-ts 0.1.0 → 0.1.2

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.
Files changed (172) hide show
  1. package/README.md +410 -10
  2. package/dist/model/content/Body.d.mts +109 -4
  3. package/dist/model/content/Body.mjs +300 -29
  4. package/dist/model/content/Comment.d.mts +78 -0
  5. package/dist/model/content/Comment.mjs +429 -0
  6. package/dist/model/content/ContentControl.d.mts +173 -0
  7. package/dist/model/content/ContentControl.mjs +638 -0
  8. package/dist/model/content/Font.d.mts +48 -8
  9. package/dist/model/content/Font.mjs +55 -13
  10. package/dist/model/content/InlinePicture.d.mts +103 -0
  11. package/dist/model/content/InlinePicture.mjs +361 -0
  12. package/dist/model/content/List.d.mts +253 -0
  13. package/dist/model/content/List.mjs +778 -0
  14. package/dist/model/content/Paragraph.d.mts +213 -16
  15. package/dist/model/content/Paragraph.mjs +611 -57
  16. package/dist/model/content/Range.d.mts +48 -4
  17. package/dist/model/content/Range.mjs +161 -4
  18. package/dist/model/content/Table.d.mts +130 -0
  19. package/dist/model/content/Table.mjs +429 -0
  20. package/dist/model/content/TrackedChange.d.mts +96 -0
  21. package/dist/model/content/TrackedChange.mjs +352 -0
  22. package/dist/model/content/comments.d.mts +122 -0
  23. package/dist/model/content/comments.mjs +248 -0
  24. package/dist/model/content/index.d.mts +13 -3
  25. package/dist/model/content/index.mjs +15 -3
  26. package/dist/model/content/ooxml.d.mts +17 -0
  27. package/dist/model/content/ooxml.mjs +214 -0
  28. package/dist/model/content/styles.d.mts +21 -0
  29. package/dist/model/content/styles.mjs +86 -0
  30. package/dist/model/content/tracking.d.mts +104 -0
  31. package/dist/model/content/tracking.mjs +313 -0
  32. package/dist/model/content/tree.d.mts +56 -9
  33. package/dist/model/content/tree.mjs +104 -31
  34. package/dist/model/customxml/CustomXmlPart.d.mts +158 -0
  35. package/dist/model/customxml/CustomXmlPart.mjs +415 -0
  36. package/dist/model/customxml/CustomXmlPartCollection.d.mts +68 -0
  37. package/dist/model/customxml/CustomXmlPartCollection.mjs +183 -0
  38. package/dist/model/customxml/XmlMapping.d.mts +46 -0
  39. package/dist/model/customxml/XmlMapping.mjs +98 -0
  40. package/dist/model/customxml/bindings.d.mts +41 -0
  41. package/dist/model/customxml/bindings.mjs +230 -0
  42. package/dist/model/customxml/index.d.mts +7 -0
  43. package/dist/model/customxml/index.mjs +9 -0
  44. package/dist/model/customxml/insert.d.mts +20 -0
  45. package/dist/model/customxml/insert.mjs +22 -0
  46. package/dist/model/customxml/kinds.d.mts +103 -0
  47. package/dist/model/customxml/kinds.mjs +267 -0
  48. package/dist/model/customxml/xpath.d.mts +52 -0
  49. package/dist/model/customxml/xpath.mjs +205 -0
  50. package/dist/model/fonts/CJKToEnglish.d.mts +2 -0
  51. package/dist/model/fonts/CJKToEnglish.mjs +16 -0
  52. package/dist/model/fonts/FontFallback.d.mts +58 -0
  53. package/dist/model/fonts/FontFallback.mjs +219 -0
  54. package/dist/model/fonts/IdentityPlusMapper.d.mts +7 -0
  55. package/dist/model/fonts/IdentityPlusMapper.mjs +19 -0
  56. package/dist/model/fonts/LanguageTagToScriptMapping.d.mts +7 -0
  57. package/dist/model/fonts/LanguageTagToScriptMapping.mjs +67 -0
  58. package/dist/model/fonts/Mapper.d.mts +190 -0
  59. package/dist/model/fonts/Mapper.mjs +481 -0
  60. package/dist/model/fonts/PhysicalFont.d.mts +34 -0
  61. package/dist/model/fonts/PhysicalFont.mjs +62 -0
  62. package/dist/model/fonts/RunFontSelector.d.mts +194 -0
  63. package/dist/model/fonts/RunFontSelector.mjs +441 -0
  64. package/dist/model/fonts/ThemeFonts.d.mts +17 -0
  65. package/dist/model/fonts/ThemeFonts.mjs +76 -0
  66. package/dist/model/fonts/defaultTheme.d.mts +37 -0
  67. package/dist/model/fonts/defaultTheme.mjs +57 -0
  68. package/dist/model/fonts/families.generated.d.mts +11 -0
  69. package/dist/model/fonts/families.generated.mjs +17 -0
  70. package/dist/model/fonts/fontsInUse.d.mts +39 -0
  71. package/dist/model/fonts/fontsInUse.mjs +183 -0
  72. package/dist/model/fonts/index.d.mts +14 -0
  73. package/dist/model/fonts/index.mjs +29 -0
  74. package/dist/model/fonts/lookup.d.mts +5 -0
  75. package/dist/model/fonts/lookup.mjs +12 -0
  76. package/dist/model/fonts/registry.d.mts +31 -0
  77. package/dist/model/fonts/registry.mjs +103 -0
  78. package/dist/model/fonts/scripts.d.mts +2 -0
  79. package/dist/model/fonts/scripts.mjs +78 -0
  80. package/dist/model/fonts/substitutions.generated.d.mts +30 -0
  81. package/dist/model/fonts/substitutions.generated.mjs +12 -0
  82. package/dist/model/fonts/themes.generated.d.mts +6 -0
  83. package/dist/model/fonts/themes.generated.mjs +11 -0
  84. package/dist/model/index.d.mts +5 -0
  85. package/dist/model/index.mjs +13 -1
  86. package/dist/model/listnumbering/Emulator.d.mts +187 -0
  87. package/dist/model/listnumbering/Emulator.mjs +332 -0
  88. package/dist/model/listnumbering/definitions.d.mts +251 -0
  89. package/dist/model/listnumbering/definitions.mjs +571 -0
  90. package/dist/model/listnumbering/formats.d.mts +25 -0
  91. package/dist/model/listnumbering/formats.mjs +320 -0
  92. package/dist/model/listnumbering/index.d.mts +4 -0
  93. package/dist/model/listnumbering/index.mjs +15 -0
  94. package/dist/model/listnumbering/state.d.mts +97 -0
  95. package/dist/model/listnumbering/state.mjs +179 -0
  96. package/dist/model/properties/PropertyResolver.d.mts +216 -0
  97. package/dist/model/properties/PropertyResolver.mjs +524 -0
  98. package/dist/model/properties/catalogue.d.mts +179 -0
  99. package/dist/model/properties/catalogue.mjs +860 -0
  100. package/dist/model/properties/index.d.mts +4 -0
  101. package/dist/model/properties/index.mjs +9 -0
  102. package/dist/model/properties/log.d.mts +7 -0
  103. package/dist/model/properties/log.mjs +25 -0
  104. package/dist/model/properties/styleUtil.d.mts +112 -0
  105. package/dist/model/properties/styleUtil.mjs +359 -0
  106. package/dist/node/index.d.mts +1 -0
  107. package/dist/node/index.mjs +12 -0
  108. package/dist/office-js/document.d.mts +111 -0
  109. package/dist/office-js/document.mjs +267 -0
  110. package/dist/office-js/enums.d.mts +187 -0
  111. package/dist/office-js/enums.mjs +176 -0
  112. package/dist/office-js/errors.d.mts +29 -0
  113. package/dist/office-js/errors.mjs +39 -0
  114. package/dist/office-js/extras.d.mts +5 -0
  115. package/dist/office-js/extras.mjs +29 -0
  116. package/dist/office-js/fragment.d.mts +10 -0
  117. package/dist/office-js/fragment.mjs +23 -0
  118. package/dist/office-js/index.d.mts +183 -0
  119. package/dist/office-js/index.mjs +54 -0
  120. package/dist/office-js/proxy.d.mts +72 -0
  121. package/dist/office-js/proxy.mjs +279 -0
  122. package/dist/office-js/run.d.mts +32 -0
  123. package/dist/office-js/run.mjs +66 -0
  124. package/dist/office-js/supported.d.mts +7 -0
  125. package/dist/office-js/supported.generated.d.mts +1 -0
  126. package/dist/office-js/supported.generated.mjs +235 -0
  127. package/dist/office-js/supported.mjs +53 -0
  128. package/dist/office-js/toApiScript.d.mts +25 -0
  129. package/dist/office-js/toApiScript.mjs +394 -0
  130. package/dist/opc/ContentTypes.d.mts +11 -0
  131. package/dist/opc/ContentTypes.mjs +14 -0
  132. package/dist/opc/DirectoryPartStore.d.mts +47 -0
  133. package/dist/opc/DirectoryPartStore.mjs +123 -0
  134. package/dist/opc/exceptions.d.mts +30 -0
  135. package/dist/opc/exceptions.mjs +38 -0
  136. package/dist/opc/index.d.mts +1 -1
  137. package/dist/opc/index.mjs +1 -1
  138. package/dist/packages/OpcPackage.d.mts +19 -1
  139. package/dist/packages/OpcPackage.mjs +29 -0
  140. package/dist/packages/PresentationMLPackage.d.mts +71 -1
  141. package/dist/packages/PresentationMLPackage.mjs +179 -0
  142. package/dist/packages/SpreadsheetMLPackage.d.mts +30 -1
  143. package/dist/packages/SpreadsheetMLPackage.mjs +78 -0
  144. package/dist/packages/WordprocessingMLPackage.d.mts +124 -2
  145. package/dist/packages/WordprocessingMLPackage.mjs +309 -2
  146. package/dist/packages/index.d.mts +1 -1
  147. package/dist/packages/index.mjs +1 -1
  148. package/dist/parts/DefaultXmlPart.d.mts +18 -0
  149. package/dist/parts/DefaultXmlPart.mjs +34 -5
  150. package/dist/parts/Namespaces.d.mts +18 -0
  151. package/dist/parts/Namespaces.mjs +20 -0
  152. package/dist/parts/Part.d.mts +6 -0
  153. package/dist/parts/Part.mjs +13 -0
  154. package/dist/parts/PartRegistry.mjs +13 -1
  155. package/dist/parts/XmlPart.d.mts +33 -0
  156. package/dist/parts/XmlPart.mjs +105 -2
  157. package/dist/parts/pml/defaults.d.mts +6 -0
  158. package/dist/parts/pml/defaults.mjs +53 -0
  159. package/dist/parts/pml/index.d.mts +66 -3
  160. package/dist/parts/pml/index.mjs +206 -7
  161. package/dist/parts/pml/placeholders.d.mts +71 -0
  162. package/dist/parts/pml/placeholders.mjs +141 -0
  163. package/dist/parts/sml/index.d.mts +80 -1
  164. package/dist/parts/sml/index.mjs +154 -1
  165. package/dist/parts/wml/comments.d.mts +1 -0
  166. package/dist/parts/wml/comments.mjs +179 -0
  167. package/dist/parts/wml/defaultNumbering.d.mts +1 -0
  168. package/dist/parts/wml/defaultNumbering.mjs +216 -0
  169. package/dist/parts/wml/index.d.mts +121 -0
  170. package/dist/parts/wml/index.mjs +291 -0
  171. package/dist/xml/dom.mjs +1 -2
  172. package/package.json +25 -4
@@ -0,0 +1,267 @@
1
+ // `context.document` and its properties (CR-002 section 3.10): Office JS's Document over a
2
+ // WordprocessingMLPackage. The class names are Office JS's, since `Word.run` callbacks are what
3
+ // this serves; the parts behind them keep docx4j's (DocPropsCorePart, DocumentSettingsPart).
4
+ import * as elDc from '@docx4j/generated-objects-ts/el/org_docx4j_docProps_core_dc_elements';
5
+ import { Docx4JException } from '../opc/exceptions.mjs';
6
+ import { NotSupportedError } from './errors.mjs';
7
+ function literalText(value) {
8
+ var _a, _b;
9
+ return (_b = (_a = value === null || value === void 0 ? void 0 : value.content) === null || _a === void 0 ? void 0 : _a.join('')) !== null && _b !== void 0 ? _b : '';
10
+ }
11
+ function literal(text) {
12
+ return { content: [text] };
13
+ }
14
+ /** dcterms:W3CDTF, as docx4j writes dcterms:created and dcterms:modified. */
15
+ function w3cdtf(date) {
16
+ return { TYPE_NAME: 'org_docx4j_docProps_core_dc_terms.W3CDTF', content: [date.toISOString().replace(/\.\d{3}Z$/, 'Z')] };
17
+ }
18
+ function dateOf(value) {
19
+ const text = literalText(value);
20
+ if (text === '')
21
+ return undefined;
22
+ const date = new Date(text);
23
+ return Number.isNaN(date.getTime()) ? undefined : date;
24
+ }
25
+ function dateOfCalendar(value) {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ if (!value || value.year === undefined)
28
+ return undefined;
29
+ const ms = Date.UTC(value.year, ((_a = value.month) !== null && _a !== void 0 ? _a : 1) - 1, (_b = value.day) !== null && _b !== void 0 ? _b : 1, (_c = value.hour) !== null && _c !== void 0 ? _c : 0, (_d = value.minute) !== null && _d !== void 0 ? _d : 0, (_e = value.second) !== null && _e !== void 0 ? _e : 0);
30
+ return new Date(ms - ((_f = value.timezone) !== null && _f !== void 0 ? _f : 0) * 60000);
31
+ }
32
+ function calendarOf(date) {
33
+ return {
34
+ year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate(),
35
+ hour: date.getUTCHours(), minute: date.getUTCMinutes(), second: date.getUTCSeconds(), timezone: 0,
36
+ };
37
+ }
38
+ /**
39
+ * A subset of Office JS `Word.DocumentProperties` over `docProps/core.xml` (docx4j
40
+ * DocPropsCorePart) and `docProps/app.xml` (DocPropsExtendedPart). Reads report '' or undefined
41
+ * when a property is absent; a write creates the part when the package has none.
42
+ */
43
+ export class DocumentProperties {
44
+ constructor(pkg) {
45
+ this.pkg = pkg;
46
+ }
47
+ coreProps(create) {
48
+ const part = create ? this.pkg.addDocPropsCorePart() : this.pkg.docPropsCorePart;
49
+ if (!part)
50
+ return undefined;
51
+ if (!part.isUnmarshalled) {
52
+ if (!create)
53
+ return undefined;
54
+ throw new Docx4JException(`${part.partName} is not unmarshalled; await its getContents() first (Word.run does that unless unmarshalSideParts is false)`);
55
+ }
56
+ return part.contents;
57
+ }
58
+ extendedProps(create) {
59
+ const part = create ? this.pkg.addDocPropsExtendedPart() : this.pkg.docPropsExtendedPart;
60
+ if (!part)
61
+ return undefined;
62
+ if (!part.isUnmarshalled) {
63
+ if (!create)
64
+ return undefined;
65
+ throw new Docx4JException(`${part.partName} is not unmarshalled; await its getContents() first (Word.run does that unless unmarshalSideParts is false)`);
66
+ }
67
+ return part.contents;
68
+ }
69
+ /** dc:title. */
70
+ get title() {
71
+ var _a, _b;
72
+ return literalText((_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.value);
73
+ }
74
+ set title(value) {
75
+ this.coreProps(true).title = elDc.title(literal(value));
76
+ }
77
+ /** dc:subject. */
78
+ get subject() {
79
+ var _a;
80
+ return literalText((_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.subject);
81
+ }
82
+ set subject(value) {
83
+ this.coreProps(true).subject = literal(value);
84
+ }
85
+ /** dc:creator (Office JS calls it the author). */
86
+ get author() {
87
+ var _a;
88
+ return literalText((_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.creator);
89
+ }
90
+ set author(value) {
91
+ this.coreProps(true).creator = literal(value);
92
+ }
93
+ /** dc:description (Office JS calls it comments). */
94
+ get comments() {
95
+ var _a, _b;
96
+ return literalText((_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.description) === null || _b === void 0 ? void 0 : _b.value);
97
+ }
98
+ set comments(value) {
99
+ this.coreProps(true).description = elDc.description(literal(value));
100
+ }
101
+ /** cp:keywords. */
102
+ get keywords() {
103
+ var _a, _b;
104
+ return (_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.keywords) !== null && _b !== void 0 ? _b : '';
105
+ }
106
+ set keywords(value) {
107
+ this.coreProps(true).keywords = value;
108
+ }
109
+ /** cp:category. */
110
+ get category() {
111
+ var _a, _b;
112
+ return (_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.category) !== null && _b !== void 0 ? _b : '';
113
+ }
114
+ set category(value) {
115
+ this.coreProps(true).category = value;
116
+ }
117
+ /** cp:lastModifiedBy. */
118
+ get lastAuthor() {
119
+ var _a, _b;
120
+ return (_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.lastModifiedBy) !== null && _b !== void 0 ? _b : '';
121
+ }
122
+ set lastAuthor(value) {
123
+ this.coreProps(true).lastModifiedBy = value;
124
+ }
125
+ /** cp:revision. */
126
+ get revisionNumber() {
127
+ var _a, _b;
128
+ return (_b = (_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.revision) !== null && _b !== void 0 ? _b : '';
129
+ }
130
+ set revisionNumber(value) {
131
+ this.coreProps(true).revision = value;
132
+ }
133
+ /** dcterms:created. */
134
+ get creationDate() {
135
+ var _a;
136
+ return dateOf((_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.created);
137
+ }
138
+ set creationDate(value) {
139
+ const props = this.coreProps(true);
140
+ if (value === undefined)
141
+ delete props.created;
142
+ else
143
+ props.created = w3cdtf(value);
144
+ }
145
+ /** dcterms:modified. */
146
+ get lastSaveTime() {
147
+ var _a;
148
+ return dateOf((_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.modified);
149
+ }
150
+ set lastSaveTime(value) {
151
+ const props = this.coreProps(true);
152
+ if (value === undefined)
153
+ delete props.modified;
154
+ else
155
+ props.modified = w3cdtf(value);
156
+ }
157
+ /** cp:lastPrinted. */
158
+ get lastPrintDate() {
159
+ var _a;
160
+ return dateOfCalendar((_a = this.coreProps(false)) === null || _a === void 0 ? void 0 : _a.lastPrinted);
161
+ }
162
+ set lastPrintDate(value) {
163
+ const props = this.coreProps(true);
164
+ if (value === undefined)
165
+ delete props.lastPrinted;
166
+ else
167
+ props.lastPrinted = calendarOf(value);
168
+ }
169
+ /** Manager (extended properties). */
170
+ get manager() {
171
+ var _a, _b;
172
+ return (_b = (_a = this.extendedProps(false)) === null || _a === void 0 ? void 0 : _a.manager) !== null && _b !== void 0 ? _b : '';
173
+ }
174
+ set manager(value) {
175
+ this.extendedProps(true).manager = value;
176
+ }
177
+ /** Company (extended properties). */
178
+ get company() {
179
+ var _a, _b;
180
+ return (_b = (_a = this.extendedProps(false)) === null || _a === void 0 ? void 0 : _a.company) !== null && _b !== void 0 ? _b : '';
181
+ }
182
+ set company(value) {
183
+ this.extendedProps(true).company = value;
184
+ }
185
+ /** Application (extended properties). */
186
+ get applicationName() {
187
+ var _a, _b;
188
+ return (_b = (_a = this.extendedProps(false)) === null || _a === void 0 ? void 0 : _a.application) !== null && _b !== void 0 ? _b : '';
189
+ }
190
+ set applicationName(value) {
191
+ this.extendedProps(true).application = value;
192
+ }
193
+ /** Template (extended properties). */
194
+ get template() {
195
+ var _a, _b;
196
+ return (_b = (_a = this.extendedProps(false)) === null || _a === void 0 ? void 0 : _a.template) !== null && _b !== void 0 ? _b : '';
197
+ }
198
+ set template(value) {
199
+ this.extendedProps(true).template = value;
200
+ }
201
+ /** DocSecurity (extended properties); read only, as Office JS. */
202
+ get security() {
203
+ var _a, _b;
204
+ return (_b = (_a = this.extendedProps(false)) === null || _a === void 0 ? void 0 : _a.docSecurity) !== null && _b !== void 0 ? _b : 0;
205
+ }
206
+ }
207
+ /**
208
+ * A subset of Office JS `Word.Document` over a package. `body` is the main document part's body;
209
+ * everything else is the document-level surface add-in code reaches for first.
210
+ */
211
+ export class Document {
212
+ constructor(
213
+ /** The package this document is (extension: Office JS has no package). */
214
+ package_, options = {}) {
215
+ this.package_ = package_;
216
+ this.options = options;
217
+ this.properties = new DocumentProperties(package_);
218
+ }
219
+ /** The main document part's body; `Word.run` unmarshalled the part before the callback. */
220
+ get body() {
221
+ return this.package_.body;
222
+ }
223
+ /** The caller's selection (`Word.run(pkg, fn, { selection })`); there is none in Node. */
224
+ getSelection() {
225
+ const selection = this.options.selection;
226
+ if (!selection) {
227
+ throw new NotSupportedError('Document', 'getSelection', 'there is no host selection; pass one as Word.run(pkg, fn, { selection })');
228
+ }
229
+ return selection;
230
+ }
231
+ /**
232
+ * Office JS `document.changeTrackingMode`: the package's, which is `w:trackRevisions` in the
233
+ * settings part and, while it is on, makes every edit through the content API write revision
234
+ * markup (CR-002 phase F). The shim adds nothing of its own; `Word.run` has unmarshalled the
235
+ * settings part, so both directions are synchronous here.
236
+ */
237
+ get changeTrackingMode() {
238
+ return this.package_.changeTrackingMode;
239
+ }
240
+ set changeTrackingMode(mode) {
241
+ const settings = this.package_.getMainDocumentPart().documentSettingsPart;
242
+ if (settings && !settings.isUnmarshalled) {
243
+ throw new Docx4JException(`${settings.partName} is not unmarshalled; await its getContents() first (Word.run does that unless unmarshalSideParts is false)`);
244
+ }
245
+ this.package_.changeTrackingMode = mode;
246
+ }
247
+ /** Office JS `document.getTrackedChanges()`: the body's, in document order (CR-002 phase F). */
248
+ getTrackedChanges() {
249
+ return this.body.getTrackedChanges();
250
+ }
251
+ /**
252
+ * The comments of the document. CR-002 phase G puts `getComments()` on `Body`; until it lands
253
+ * this reports none, so add-in code that lists comments runs either way.
254
+ */
255
+ getComments() {
256
+ const body = this.body;
257
+ return typeof body.getComments === 'function' ? body.getComments() : [];
258
+ }
259
+ /** The whole document as a flat OPC `pkg:package` string, as Office JS's `body.getOoxml()`. */
260
+ getOoxml() {
261
+ return this.package_.saveFlatOpc();
262
+ }
263
+ /** The document as a docx (extension; Office JS's `save()` saves in the host). */
264
+ save() {
265
+ return this.package_.save();
266
+ }
267
+ }
@@ -0,0 +1,187 @@
1
+ import type { Alignment as AlignmentValue } from '../model/content/Paragraph.mjs';
2
+ import type { UnderlineType as UnderlineTypeValue } from '../model/content/Font.mjs';
3
+ export type { AlignmentValue, UnderlineTypeValue };
4
+ /** Where an insertion goes, as Office JS Word.InsertLocation; a member takes the subset it supports. */
5
+ export declare const InsertLocation: Readonly<{
6
+ readonly before: "Before";
7
+ readonly after: "After";
8
+ readonly start: "Start";
9
+ readonly end: "End";
10
+ readonly replace: "Replace";
11
+ }>;
12
+ export type InsertLocationValue = (typeof InsertLocation)[keyof typeof InsertLocation];
13
+ /** Word.Alignment; 'Unknown' is what a paragraph without w:jc reports. */
14
+ export declare const Alignment: Readonly<{
15
+ readonly unknown: "Unknown";
16
+ readonly left: "Left";
17
+ readonly centered: "Centered";
18
+ readonly right: "Right";
19
+ readonly justified: "Justified";
20
+ }>;
21
+ /** Word.UnderlineType, the subset w:u expresses (the objects package's UNDERLINE_TO_WML). */
22
+ export declare const UnderlineType: Readonly<{
23
+ readonly mixed: "Mixed";
24
+ readonly none: "None";
25
+ readonly single: "Single";
26
+ readonly word: "Word";
27
+ readonly double: "Double";
28
+ readonly thick: "Thick";
29
+ readonly dotted: "Dotted";
30
+ readonly dottedHeavy: "DottedHeavy";
31
+ readonly dashLine: "DashLine";
32
+ readonly dashLineHeavy: "DashLineHeavy";
33
+ readonly dashLineLong: "DashLineLong";
34
+ readonly dashLineLongHeavy: "DashLineLongHeavy";
35
+ readonly dotDashLine: "DotDashLine";
36
+ readonly dotDashLineHeavy: "DotDashLineHeavy";
37
+ readonly twoDotDashLine: "TwoDotDashLine";
38
+ readonly twoDotDashLineHeavy: "TwoDotDashLineHeavy";
39
+ readonly wave: "Wave";
40
+ readonly waveHeavy: "WaveHeavy";
41
+ readonly waveDouble: "WaveDouble";
42
+ }>;
43
+ /** Word.ChangeTrackingMode; the tracking itself is CR-002 phase F, the setting is read and written here. */
44
+ export declare const ChangeTrackingMode: Readonly<{
45
+ readonly off: "Off";
46
+ readonly trackAll: "TrackAll";
47
+ readonly trackMineOnly: "TrackMineOnly";
48
+ }>;
49
+ export type ChangeTrackingModeValue = (typeof ChangeTrackingMode)[keyof typeof ChangeTrackingMode];
50
+ /** Word.BreakType; `insertBreak` here takes 'Page' and 'Line' (CR-002 phase B). */
51
+ export declare const BreakType: Readonly<{
52
+ readonly page: "Page";
53
+ readonly next: "Next";
54
+ readonly sectionNext: "SectionNext";
55
+ readonly sectionContinuous: "SectionContinuous";
56
+ readonly sectionEven: "SectionEven";
57
+ readonly sectionOdd: "SectionOdd";
58
+ readonly line: "Line";
59
+ }>;
60
+ export type BreakTypeValue = (typeof BreakType)[keyof typeof BreakType];
61
+ /** Word.ListLevelType: what a list level paints in front of its paragraphs (CR-002 phase H). */
62
+ export declare const ListLevelType: Readonly<{
63
+ readonly bullet: "Bullet";
64
+ readonly number: "Number";
65
+ readonly picture: "Picture";
66
+ }>;
67
+ export type ListLevelTypeValue = (typeof ListLevelType)[keyof typeof ListLevelType];
68
+ /** Word.ListNumbering: the number formats `list.setLevelNumbering` takes. */
69
+ export declare const ListNumbering: Readonly<{
70
+ readonly none: "None";
71
+ readonly arabic: "Arabic";
72
+ readonly upperRoman: "UpperRoman";
73
+ readonly lowerRoman: "LowerRoman";
74
+ readonly upperLetter: "UpperLetter";
75
+ readonly lowerLetter: "LowerLetter";
76
+ }>;
77
+ export type ListNumberingValue = (typeof ListNumbering)[keyof typeof ListNumbering];
78
+ /** Word.ListBullet: the bullets `list.setLevelBullet` takes. */
79
+ export declare const ListBullet: Readonly<{
80
+ readonly custom: "Custom";
81
+ readonly solid: "Solid";
82
+ readonly hollow: "Hollow";
83
+ readonly square: "Square";
84
+ readonly diamonds: "Diamonds";
85
+ readonly arrow: "Arrow";
86
+ readonly checkmark: "Checkmark";
87
+ }>;
88
+ export type ListBulletValue = (typeof ListBullet)[keyof typeof ListBullet];
89
+ /** Word.ContentControlType: the kinds w:sdtPr types (CR-002 section 3.5; the views are phase C/E). */
90
+ export declare const ContentControlType: Readonly<{
91
+ readonly unknown: "Unknown";
92
+ readonly richText: "RichText";
93
+ readonly plainText: "PlainText";
94
+ readonly picture: "Picture";
95
+ readonly datePicker: "DatePicker";
96
+ readonly comboBox: "ComboBox";
97
+ readonly dropDownList: "DropDownList";
98
+ readonly checkBox: "CheckBox";
99
+ readonly repeatingSection: "RepeatingSection";
100
+ readonly repeatingSectionItem: "RepeatingSectionItem";
101
+ readonly group: "Group";
102
+ readonly buildingBlockGallery: "BuildingBlockGallery";
103
+ readonly citation: "Citation";
104
+ readonly bibliography: "Bibliography";
105
+ readonly equation: "Equation";
106
+ }>;
107
+ export type ContentControlTypeValue = (typeof ContentControlType)[keyof typeof ContentControlType];
108
+ /**
109
+ * Word.Style: the values `styleBuiltIn` reads and accepts ('Heading1'; 'Other' is read for a style
110
+ * that is not built in and cannot be set). `style` is the display name ('Heading 1'); the id is the
111
+ * views' `styleId` extension. The list agrees with the content API's `BUILT_IN_STYLES` (tested).
112
+ */
113
+ export declare const Style: Readonly<{
114
+ readonly other: "Other";
115
+ readonly normal: "Normal";
116
+ readonly heading1: "Heading1";
117
+ readonly heading2: "Heading2";
118
+ readonly heading3: "Heading3";
119
+ readonly heading4: "Heading4";
120
+ readonly heading5: "Heading5";
121
+ readonly heading6: "Heading6";
122
+ readonly heading7: "Heading7";
123
+ readonly heading8: "Heading8";
124
+ readonly heading9: "Heading9";
125
+ readonly toc1: "Toc1";
126
+ readonly toc2: "Toc2";
127
+ readonly toc3: "Toc3";
128
+ readonly toc4: "Toc4";
129
+ readonly toc5: "Toc5";
130
+ readonly toc6: "Toc6";
131
+ readonly toc7: "Toc7";
132
+ readonly toc8: "Toc8";
133
+ readonly toc9: "Toc9";
134
+ readonly footnoteText: "FootnoteText";
135
+ readonly header: "Header";
136
+ readonly footer: "Footer";
137
+ readonly caption: "Caption";
138
+ readonly footnoteReference: "FootnoteReference";
139
+ readonly endnoteReference: "EndnoteReference";
140
+ readonly endnoteText: "EndnoteText";
141
+ readonly title: "Title";
142
+ readonly subtitle: "Subtitle";
143
+ readonly hyperlink: "Hyperlink";
144
+ readonly strong: "Strong";
145
+ readonly emphasis: "Emphasis";
146
+ readonly noSpacing: "NoSpacing";
147
+ readonly listParagraph: "ListParagraph";
148
+ readonly quote: "Quote";
149
+ readonly intenseQuote: "IntenseQuote";
150
+ readonly subtleEmphasis: "SubtleEmphasis";
151
+ readonly intenseEmphasis: "IntenseEmphasis";
152
+ readonly subtleReference: "SubtleReference";
153
+ readonly intenseReference: "IntenseReference";
154
+ readonly bookTitle: "BookTitle";
155
+ readonly bibliography: "Bibliography";
156
+ readonly tocHeading: "TocHeading";
157
+ readonly tableGrid: "TableGrid";
158
+ readonly plainTable1: "PlainTable1";
159
+ readonly plainTable2: "PlainTable2";
160
+ readonly plainTable3: "PlainTable3";
161
+ readonly plainTable4: "PlainTable4";
162
+ readonly plainTable5: "PlainTable5";
163
+ readonly gridTable1Light: "GridTable1Light";
164
+ readonly listTable1Light: "ListTable1Light";
165
+ }>;
166
+ export type StyleValue = (typeof Style)[keyof typeof Style];
167
+ /** Word.ErrorCodes, the `code` an error carries. */
168
+ export declare const ErrorCodes: Readonly<{
169
+ readonly accessDenied: "AccessDenied";
170
+ readonly generalException: "GeneralException";
171
+ readonly invalidArgument: "InvalidArgument";
172
+ readonly itemNotFound: "ItemNotFound";
173
+ readonly notAllowed: "NotAllowed";
174
+ readonly notImplemented: "NotImplemented";
175
+ readonly searchDialogIsOpen: "SearchDialogIsOpen";
176
+ readonly searchStringInvalidOrTooLong: "SearchStringInvalidOrTooLong";
177
+ }>;
178
+ /** Word.SearchOptions: the options `search` takes (the content API's `SearchOptions`). */
179
+ export interface SearchOptions {
180
+ matchCase?: boolean;
181
+ matchWholeWord?: boolean;
182
+ matchWildcards?: boolean;
183
+ }
184
+ /** Word.SearchOptions.newObject(): a fresh options bag, as add-in code builds one. */
185
+ export declare const SearchOptions: Readonly<{
186
+ newObject(): SearchOptions;
187
+ }>;
@@ -0,0 +1,176 @@
1
+ // The Word enums as objects of the string values this API accepts (CR-002 section 3.10), so that
2
+ // add-in code written as `paragraph.alignment = Word.Alignment.centered` runs unchanged. Office JS
3
+ // declares them as TypeScript enums whose values are the strings; a frozen object of the same
4
+ // keys and values is the JavaScript half of that, and the value types below are the API's.
5
+ /** Where an insertion goes, as Office JS Word.InsertLocation; a member takes the subset it supports. */
6
+ export const InsertLocation = Object.freeze({
7
+ before: 'Before',
8
+ after: 'After',
9
+ start: 'Start',
10
+ end: 'End',
11
+ replace: 'Replace',
12
+ });
13
+ /** Word.Alignment; 'Unknown' is what a paragraph without w:jc reports. */
14
+ export const Alignment = Object.freeze({
15
+ unknown: 'Unknown',
16
+ left: 'Left',
17
+ centered: 'Centered',
18
+ right: 'Right',
19
+ justified: 'Justified',
20
+ });
21
+ /** Word.UnderlineType, the subset w:u expresses (the objects package's UNDERLINE_TO_WML). */
22
+ export const UnderlineType = Object.freeze({
23
+ mixed: 'Mixed',
24
+ none: 'None',
25
+ single: 'Single',
26
+ word: 'Word',
27
+ double: 'Double',
28
+ thick: 'Thick',
29
+ dotted: 'Dotted',
30
+ dottedHeavy: 'DottedHeavy',
31
+ dashLine: 'DashLine',
32
+ dashLineHeavy: 'DashLineHeavy',
33
+ dashLineLong: 'DashLineLong',
34
+ dashLineLongHeavy: 'DashLineLongHeavy',
35
+ dotDashLine: 'DotDashLine',
36
+ dotDashLineHeavy: 'DotDashLineHeavy',
37
+ twoDotDashLine: 'TwoDotDashLine',
38
+ twoDotDashLineHeavy: 'TwoDotDashLineHeavy',
39
+ wave: 'Wave',
40
+ waveHeavy: 'WaveHeavy',
41
+ waveDouble: 'WaveDouble',
42
+ });
43
+ /** Word.ChangeTrackingMode; the tracking itself is CR-002 phase F, the setting is read and written here. */
44
+ export const ChangeTrackingMode = Object.freeze({
45
+ off: 'Off',
46
+ trackAll: 'TrackAll',
47
+ trackMineOnly: 'TrackMineOnly',
48
+ });
49
+ /** Word.BreakType; `insertBreak` here takes 'Page' and 'Line' (CR-002 phase B). */
50
+ export const BreakType = Object.freeze({
51
+ page: 'Page',
52
+ next: 'Next',
53
+ sectionNext: 'SectionNext',
54
+ sectionContinuous: 'SectionContinuous',
55
+ sectionEven: 'SectionEven',
56
+ sectionOdd: 'SectionOdd',
57
+ line: 'Line',
58
+ });
59
+ /** Word.ListLevelType: what a list level paints in front of its paragraphs (CR-002 phase H). */
60
+ export const ListLevelType = Object.freeze({
61
+ bullet: 'Bullet',
62
+ number: 'Number',
63
+ picture: 'Picture',
64
+ });
65
+ /** Word.ListNumbering: the number formats `list.setLevelNumbering` takes. */
66
+ export const ListNumbering = Object.freeze({
67
+ none: 'None',
68
+ arabic: 'Arabic',
69
+ upperRoman: 'UpperRoman',
70
+ lowerRoman: 'LowerRoman',
71
+ upperLetter: 'UpperLetter',
72
+ lowerLetter: 'LowerLetter',
73
+ });
74
+ /** Word.ListBullet: the bullets `list.setLevelBullet` takes. */
75
+ export const ListBullet = Object.freeze({
76
+ custom: 'Custom',
77
+ solid: 'Solid',
78
+ hollow: 'Hollow',
79
+ square: 'Square',
80
+ diamonds: 'Diamonds',
81
+ arrow: 'Arrow',
82
+ checkmark: 'Checkmark',
83
+ });
84
+ /** Word.ContentControlType: the kinds w:sdtPr types (CR-002 section 3.5; the views are phase C/E). */
85
+ export const ContentControlType = Object.freeze({
86
+ unknown: 'Unknown',
87
+ richText: 'RichText',
88
+ plainText: 'PlainText',
89
+ picture: 'Picture',
90
+ datePicker: 'DatePicker',
91
+ comboBox: 'ComboBox',
92
+ dropDownList: 'DropDownList',
93
+ checkBox: 'CheckBox',
94
+ repeatingSection: 'RepeatingSection',
95
+ repeatingSectionItem: 'RepeatingSectionItem',
96
+ group: 'Group',
97
+ buildingBlockGallery: 'BuildingBlockGallery',
98
+ citation: 'Citation',
99
+ bibliography: 'Bibliography',
100
+ equation: 'Equation',
101
+ });
102
+ /**
103
+ * Word.Style: the values `styleBuiltIn` reads and accepts ('Heading1'; 'Other' is read for a style
104
+ * that is not built in and cannot be set). `style` is the display name ('Heading 1'); the id is the
105
+ * views' `styleId` extension. The list agrees with the content API's `BUILT_IN_STYLES` (tested).
106
+ */
107
+ export const Style = Object.freeze({
108
+ other: 'Other',
109
+ normal: 'Normal',
110
+ heading1: 'Heading1',
111
+ heading2: 'Heading2',
112
+ heading3: 'Heading3',
113
+ heading4: 'Heading4',
114
+ heading5: 'Heading5',
115
+ heading6: 'Heading6',
116
+ heading7: 'Heading7',
117
+ heading8: 'Heading8',
118
+ heading9: 'Heading9',
119
+ toc1: 'Toc1',
120
+ toc2: 'Toc2',
121
+ toc3: 'Toc3',
122
+ toc4: 'Toc4',
123
+ toc5: 'Toc5',
124
+ toc6: 'Toc6',
125
+ toc7: 'Toc7',
126
+ toc8: 'Toc8',
127
+ toc9: 'Toc9',
128
+ footnoteText: 'FootnoteText',
129
+ header: 'Header',
130
+ footer: 'Footer',
131
+ caption: 'Caption',
132
+ footnoteReference: 'FootnoteReference',
133
+ endnoteReference: 'EndnoteReference',
134
+ endnoteText: 'EndnoteText',
135
+ title: 'Title',
136
+ subtitle: 'Subtitle',
137
+ hyperlink: 'Hyperlink',
138
+ strong: 'Strong',
139
+ emphasis: 'Emphasis',
140
+ noSpacing: 'NoSpacing',
141
+ listParagraph: 'ListParagraph',
142
+ quote: 'Quote',
143
+ intenseQuote: 'IntenseQuote',
144
+ subtleEmphasis: 'SubtleEmphasis',
145
+ intenseEmphasis: 'IntenseEmphasis',
146
+ subtleReference: 'SubtleReference',
147
+ intenseReference: 'IntenseReference',
148
+ bookTitle: 'BookTitle',
149
+ bibliography: 'Bibliography',
150
+ tocHeading: 'TocHeading',
151
+ tableGrid: 'TableGrid',
152
+ plainTable1: 'PlainTable1',
153
+ plainTable2: 'PlainTable2',
154
+ plainTable3: 'PlainTable3',
155
+ plainTable4: 'PlainTable4',
156
+ plainTable5: 'PlainTable5',
157
+ gridTable1Light: 'GridTable1Light',
158
+ listTable1Light: 'ListTable1Light',
159
+ });
160
+ /** Word.ErrorCodes, the `code` an error carries. */
161
+ export const ErrorCodes = Object.freeze({
162
+ accessDenied: 'AccessDenied',
163
+ generalException: 'GeneralException',
164
+ invalidArgument: 'InvalidArgument',
165
+ itemNotFound: 'ItemNotFound',
166
+ notAllowed: 'NotAllowed',
167
+ notImplemented: 'NotImplemented',
168
+ searchDialogIsOpen: 'SearchDialogIsOpen',
169
+ searchStringInvalidOrTooLong: 'SearchStringInvalidOrTooLong',
170
+ });
171
+ /** Word.SearchOptions.newObject(): a fresh options bag, as add-in code builds one. */
172
+ export const SearchOptions = Object.freeze({
173
+ newObject() {
174
+ return { matchCase: false, matchWholeWord: false, matchWildcards: false };
175
+ },
176
+ });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A member of the Word API that this package does not implement. The message names the class and
3
+ * the member, so an add-in's unsupported call fails at the call with something actionable:
4
+ * `Word.Paragraph.getNextOrNullObject is not supported by @docx4j/core-ts`.
5
+ */
6
+ export declare class NotSupportedError extends Error {
7
+ /** The Word class, as Office JS names it ('Paragraph', 'Body', 'RequestContext'). */
8
+ readonly className: string;
9
+ /** The member that was read, written or called. */
10
+ readonly member: string;
11
+ /** Word.ErrorCodes.notImplemented. */
12
+ readonly code = "NotImplemented";
13
+ constructor(
14
+ /** The Word class, as Office JS names it ('Paragraph', 'Body', 'RequestContext'). */
15
+ className: string,
16
+ /** The member that was read, written or called. */
17
+ member: string, detail?: string);
18
+ }
19
+ /** Nothing matched: `getFirst()` on an empty collection, or a member of a null object. */
20
+ export declare class ItemNotFoundError extends Error {
21
+ /** Word.ErrorCodes.itemNotFound. */
22
+ readonly code = "ItemNotFound";
23
+ constructor(message: string);
24
+ }
25
+ /** A result read before `context.sync()` resolved it (Office JS: ValueNotLoaded). */
26
+ export declare class ValueNotLoadedError extends Error {
27
+ readonly code = "ValueNotLoaded";
28
+ constructor(message?: string);
29
+ }