docxkeun 0.1.3 → 0.3.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.
Files changed (199) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +166 -16
  3. package/dist/api/editor.d.ts +231 -7
  4. package/dist/api/editor.js +1125 -26
  5. package/dist/api/headers.d.ts +51 -0
  6. package/dist/api/headers.js +133 -0
  7. package/dist/api/index.d.ts +6 -1
  8. package/dist/api/index.js +4 -1
  9. package/dist/api/lists.d.ts +37 -0
  10. package/dist/api/lists.js +132 -0
  11. package/dist/api/parts.js +1 -0
  12. package/dist/api/positions.js +1 -0
  13. package/dist/api/revisions.d.ts +61 -0
  14. package/dist/api/revisions.js +401 -0
  15. package/dist/api/selection.d.ts +57 -0
  16. package/dist/api/selection.js +91 -0
  17. package/dist/api/tables.d.ts +60 -0
  18. package/dist/api/tables.js +138 -0
  19. package/dist/charts/color.d.ts +45 -0
  20. package/dist/charts/color.js +322 -0
  21. package/dist/charts/format.d.ts +12 -0
  22. package/dist/charts/format.js +459 -0
  23. package/dist/charts/index.d.ts +11 -0
  24. package/dist/charts/index.js +8 -0
  25. package/dist/charts/model.d.ts +225 -0
  26. package/dist/charts/model.js +758 -0
  27. package/dist/charts/outline.d.ts +17 -0
  28. package/dist/charts/outline.js +214 -0
  29. package/dist/charts/render.d.ts +20 -0
  30. package/dist/charts/render.js +1772 -0
  31. package/dist/drawing/arrows.d.ts +37 -0
  32. package/dist/drawing/arrows.js +99 -0
  33. package/dist/drawing/formula.d.ts +40 -0
  34. package/dist/drawing/formula.js +159 -0
  35. package/dist/drawing/geometry.d.ts +61 -0
  36. package/dist/drawing/geometry.js +286 -0
  37. package/dist/drawing/index.d.ts +12 -0
  38. package/dist/drawing/index.js +8 -0
  39. package/dist/drawing/presets.d.ts +72 -0
  40. package/dist/drawing/presets.js +2874 -0
  41. package/dist/fonts/shaping/apply.d.ts +94 -0
  42. package/dist/fonts/shaping/apply.js +349 -0
  43. package/dist/fonts/shaping/arabic.d.ts +28 -0
  44. package/dist/fonts/shaping/arabic.js +235 -0
  45. package/dist/fonts/shaping/buffer.d.ts +53 -0
  46. package/dist/fonts/shaping/buffer.js +95 -0
  47. package/dist/fonts/shaping/gdef.d.ts +30 -0
  48. package/dist/fonts/shaping/gdef.js +66 -0
  49. package/dist/fonts/shaping/gpos.d.ts +86 -0
  50. package/dist/fonts/shaping/gpos.js +428 -0
  51. package/dist/fonts/shaping/gsub.d.ts +65 -0
  52. package/dist/fonts/shaping/gsub.js +313 -0
  53. package/dist/fonts/shaping/index.d.ts +32 -0
  54. package/dist/fonts/shaping/index.js +402 -0
  55. package/dist/fonts/shaping/indic.d.ts +6 -0
  56. package/dist/fonts/shaping/indic.js +805 -0
  57. package/dist/fonts/shaping/layout-common.d.ts +124 -0
  58. package/dist/fonts/shaping/layout-common.js +349 -0
  59. package/dist/fonts/shaping/plan.d.ts +87 -0
  60. package/dist/fonts/shaping/plan.js +152 -0
  61. package/dist/fonts/shaping/scripts.d.ts +26 -0
  62. package/dist/fonts/shaping/scripts.js +160 -0
  63. package/dist/fonts/shaping/shaper.d.ts +23 -0
  64. package/dist/fonts/shaping/shaper.js +5 -0
  65. package/dist/fonts/shaping/unicode.d.ts +34 -0
  66. package/dist/fonts/shaping/unicode.js +138 -0
  67. package/dist/images/bmp.d.ts +9 -0
  68. package/dist/images/bmp.js +234 -0
  69. package/dist/images/gif.d.ts +9 -0
  70. package/dist/images/gif.js +215 -0
  71. package/dist/images/index.d.ts +18 -0
  72. package/dist/images/index.js +63 -0
  73. package/dist/images/png-encode.d.ts +4 -0
  74. package/dist/images/png-encode.js +73 -0
  75. package/dist/images/size.d.ts +10 -0
  76. package/dist/images/size.js +83 -0
  77. package/dist/images/tiff.d.ts +14 -0
  78. package/dist/images/tiff.js +407 -0
  79. package/dist/index.d.ts +7 -2
  80. package/dist/index.js +5 -0
  81. package/dist/layout/bidi.d.ts +18 -0
  82. package/dist/layout/bidi.js +71 -0
  83. package/dist/layout/blocks.d.ts +20 -3
  84. package/dist/layout/blocks.js +88 -58
  85. package/dist/layout/cache.d.ts +31 -0
  86. package/dist/layout/cache.js +38 -0
  87. package/dist/layout/drawing.d.ts +30 -0
  88. package/dist/layout/drawing.js +120 -0
  89. package/dist/layout/engine.d.ts +3 -0
  90. package/dist/layout/engine.js +218 -11
  91. package/dist/layout/index.d.ts +1 -0
  92. package/dist/layout/index.js +1 -0
  93. package/dist/layout/lines.d.ts +63 -5
  94. package/dist/layout/lines.js +245 -20
  95. package/dist/layout/paint.d.ts +25 -3
  96. package/dist/layout/paint.js +26 -10
  97. package/dist/layout/shapes.d.ts +7 -0
  98. package/dist/layout/shapes.js +338 -0
  99. package/dist/layout/style.d.ts +4 -0
  100. package/dist/layout/style.js +2 -0
  101. package/dist/layout/types.d.ts +89 -2
  102. package/dist/math/boxes.d.ts +88 -0
  103. package/dist/math/boxes.js +166 -0
  104. package/dist/math/index.d.ts +29 -0
  105. package/dist/math/index.js +44 -0
  106. package/dist/math/layout.d.ts +13 -0
  107. package/dist/math/layout.js +771 -0
  108. package/dist/math/linear.d.ts +3 -0
  109. package/dist/math/linear.js +152 -0
  110. package/dist/math/omml.d.ts +15 -0
  111. package/dist/math/omml.js +57 -0
  112. package/dist/math/paths.d.ts +61 -0
  113. package/dist/math/paths.js +450 -0
  114. package/dist/math/symbols.d.ts +49 -0
  115. package/dist/math/symbols.js +269 -0
  116. package/dist/math/text.d.ts +53 -0
  117. package/dist/math/text.js +316 -0
  118. package/dist/metafile/canvas.d.ts +80 -0
  119. package/dist/metafile/canvas.js +515 -0
  120. package/dist/metafile/dib.d.ts +27 -0
  121. package/dist/metafile/dib.js +300 -0
  122. package/dist/metafile/emf.d.ts +31 -0
  123. package/dist/metafile/emf.js +591 -0
  124. package/dist/metafile/geometry.d.ts +49 -0
  125. package/dist/metafile/geometry.js +85 -0
  126. package/dist/metafile/index.d.ts +27 -0
  127. package/dist/metafile/index.js +34 -0
  128. package/dist/metafile/reader.d.ts +28 -0
  129. package/dist/metafile/reader.js +59 -0
  130. package/dist/metafile/state.d.ts +118 -0
  131. package/dist/metafile/state.js +172 -0
  132. package/dist/metafile/text.d.ts +17 -0
  133. package/dist/metafile/text.js +130 -0
  134. package/dist/metafile/wmf.d.ts +33 -0
  135. package/dist/metafile/wmf.js +395 -0
  136. package/dist/model/content.d.ts +92 -7
  137. package/dist/model/content.js +251 -17
  138. package/dist/model/document.d.ts +34 -1
  139. package/dist/model/document.js +80 -1
  140. package/dist/model/fields.d.ts +4 -0
  141. package/dist/model/fields.js +10 -0
  142. package/dist/model/numbering.d.ts +2 -0
  143. package/dist/model/numbering.js +22 -0
  144. package/dist/model/props.d.ts +2 -0
  145. package/dist/model/props.js +3 -0
  146. package/dist/opc/index.d.ts +1 -1
  147. package/dist/opc/package.d.ts +34 -0
  148. package/dist/opc/package.js +58 -4
  149. package/dist/pdf/export.js +97 -6
  150. package/dist/pdf/images.d.ts +7 -0
  151. package/dist/pdf/images.js +39 -2
  152. package/dist/render/activity.d.ts +179 -0
  153. package/dist/render/activity.js +1003 -0
  154. package/dist/render/clipboard.d.ts +29 -0
  155. package/dist/render/clipboard.js +401 -0
  156. package/dist/render/comments.d.ts +166 -0
  157. package/dist/render/comments.js +779 -0
  158. package/dist/render/context-menu.d.ts +124 -0
  159. package/dist/render/context-menu.js +525 -0
  160. package/dist/render/editing.d.ts +146 -5
  161. package/dist/render/editing.js +678 -53
  162. package/dist/render/index.d.ts +12 -0
  163. package/dist/render/index.js +11 -0
  164. package/dist/render/navigation-panel.d.ts +76 -0
  165. package/dist/render/navigation-panel.js +431 -0
  166. package/dist/render/selection.js +5 -0
  167. package/dist/render/svg.d.ts +4 -6
  168. package/dist/render/svg.js +69 -7
  169. package/dist/render/toolbar.d.ts +83 -0
  170. package/dist/render/toolbar.js +505 -0
  171. package/dist/render/ui/comment-layout.d.ts +39 -0
  172. package/dist/render/ui/comment-layout.js +79 -0
  173. package/dist/render/ui/icons.d.ts +6 -0
  174. package/dist/render/ui/icons.js +38 -0
  175. package/dist/render/ui/menu.d.ts +38 -0
  176. package/dist/render/ui/menu.js +274 -0
  177. package/dist/render/ui/nav-model.d.ts +11 -0
  178. package/dist/render/ui/nav-model.js +34 -0
  179. package/dist/render/ui/overflow.d.ts +5 -0
  180. package/dist/render/ui/overflow.js +18 -0
  181. package/dist/render/ui/popover.d.ts +18 -0
  182. package/dist/render/ui/popover.js +109 -0
  183. package/dist/render/ui/theme.d.ts +2 -0
  184. package/dist/render/ui/theme.js +29 -0
  185. package/dist/render/undo.d.ts +76 -0
  186. package/dist/render/undo.js +144 -0
  187. package/dist/render/viewer.d.ts +100 -7
  188. package/dist/render/viewer.js +304 -92
  189. package/dist/security/policy.d.ts +3 -0
  190. package/dist/security/policy.js +6 -2
  191. package/dist/security/protection.d.ts +1 -0
  192. package/dist/security/protection.js +1 -1
  193. package/dist/text/bidi-data.d.ts +53 -0
  194. package/dist/text/bidi-data.js +318 -0
  195. package/dist/text/bidi.d.ts +37 -0
  196. package/dist/text/bidi.js +508 -0
  197. package/dist/xml/ns.d.ts +5 -0
  198. package/dist/xml/ns.js +7 -0
  199. package/package.json +9 -2
@@ -1,8 +1,12 @@
1
+ import { type HeaderFooterInfo, type HeaderFooterKind, type HeaderFooterOptions, type HeaderFooterType } from './headers.js';
1
2
  import type { DocParagraph, Block } from '../model/content.js';
2
3
  import type { DocxDocument } from '../model/document.js';
3
4
  import { type XmlElement } from '../xml/index.js';
5
+ import { type ListFormat, type ListItem } from './lists.js';
6
+ import { type CopyDropped, type TableOptions } from './tables.js';
7
+ import { type Revision, type RevisionFilter } from './revisions.js';
4
8
  import { EditError, type DocPosition, type DocRange } from './positions.js';
5
- export type EditAction = 'edit' | 'format' | 'comment' | 'reply' | 'resolveComment' | 'editComment' | 'deleteComment' | 'link' | 'bookmark' | 'fillForm' | 'protect';
9
+ export type EditAction = 'edit' | 'format' | 'comment' | 'reply' | 'resolveComment' | 'editComment' | 'deleteComment' | 'link' | 'bookmark' | 'fillForm' | 'protect' | 'review';
6
10
  /**
7
11
  * How a locked region is locked (Word's content-control locking, w:sdtPr/w:lock):
8
12
  * 'content' = the text cannot be edited; 'contentAndControl' = and the region cannot be deleted;
@@ -32,10 +36,25 @@ export declare class LockedRegionError extends EditError {
32
36
  export declare function lockModeOf(sdt: XmlElement): LockMode | undefined;
33
37
  /** Checks every edit (see docxkeun/security's AccessPolicy). Throw to refuse. */
34
38
  export interface EditGuard {
39
+ /** `detail.tracked` is set when the edit is recorded as a tracked change. */
35
40
  assert(action: EditAction, range?: DocRange, detail?: {
36
41
  commentAuthor?: string;
42
+ tracked?: boolean;
37
43
  }): void;
38
44
  }
45
+ export interface EditorOptions {
46
+ /** Record edits as tracked changes. Default: the document's own Track Changes setting. */
47
+ trackChanges?: boolean;
48
+ /** Author of tracked changes (default: the guard's user name, else "docxkeun"). */
49
+ author?: string;
50
+ /**
51
+ * Edit another story: a header or footer part, or the footnotes or endnotes part (see
52
+ * `DocxDocument.storyParts()`). Default: the main document (body and text boxes).
53
+ */
54
+ part?: string;
55
+ }
56
+ /** Whether Word would record changes in this document: Track Changes on, or protected for tracked changes. */
57
+ export declare function documentTracksChanges(doc: DocxDocument): boolean;
39
58
  export interface TextFormat {
40
59
  bold?: boolean;
41
60
  italic?: boolean;
@@ -52,6 +71,40 @@ export interface TextFormat {
52
71
  smallCaps?: boolean;
53
72
  hidden?: boolean;
54
73
  }
74
+ /** A piece of new text for `replaceRange`: formatted like the run `like` (default: the range's first run), then `format`. */
75
+ export interface TextPiece {
76
+ text: string;
77
+ /** A w:r element whose formatting the piece copies. */
78
+ like?: XmlElement;
79
+ format?: TextFormat;
80
+ }
81
+ /** Paragraph formatting for `formatParagraph` (lengths in points; undefined leaves a property alone). */
82
+ export interface ParagraphFormat {
83
+ align?: 'left' | 'center' | 'right' | 'justify';
84
+ /** Right-to-left paragraph (Arabic, Hebrew): w:bidi. */
85
+ direction?: 'ltr' | 'rtl';
86
+ indentLeft?: number;
87
+ indentRight?: number;
88
+ /** Positive: first-line indent; negative: hanging indent. */
89
+ indentFirstLine?: number;
90
+ spaceBefore?: number;
91
+ spaceAfter?: number;
92
+ /** Line spacing as a multiple of single spacing (1, 1.15, 1.5, 2). */
93
+ lineSpacing?: number;
94
+ keepWithNext?: boolean;
95
+ keepLinesTogether?: boolean;
96
+ pageBreakBefore?: boolean;
97
+ }
98
+ export interface SetListOptions {
99
+ /** A list format, or 'none' to take the paragraphs out of their list. */
100
+ format?: ListFormat | 'none';
101
+ /** List level, 0–8. */
102
+ level?: number;
103
+ /** First number of the list. */
104
+ start?: number;
105
+ /** Join this paragraph's list instead of starting a new one. */
106
+ sameListAs?: XmlElement;
107
+ }
55
108
  export interface CommentInput {
56
109
  author: string;
57
110
  text: string;
@@ -78,7 +131,16 @@ export interface ParagraphText {
78
131
  }
79
132
  /** Every paragraph of a block list (including table cells), in document order. */
80
133
  export declare function paragraphsOf(blocks: Block[], out?: DocParagraph[]): DocParagraph[];
81
- export declare function paragraphText(para: DocParagraph): ParagraphText;
134
+ export declare function paragraphText(para: DocParagraph, options?: {
135
+ objects?: boolean;
136
+ }): ParagraphText;
137
+ /** Stands for an inline picture, shape or chart in `paragraphText(p, { objects: true })`. */
138
+ export declare const OBJECT_CHAR = "\uFFFC";
139
+ /** The run child (w:drawing, w:pict, mc:AlternateContent) holding an inline object. */
140
+ export declare function objectNode(inline: {
141
+ run: XmlElement;
142
+ drawing: XmlElement;
143
+ }): XmlElement | undefined;
82
144
  /**
83
145
  * XML position of character offset `k` in a paragraph. With side 'start' the position is at the
84
146
  * start of the segment holding character k; with 'end' it is at the end of the segment holding
@@ -92,7 +154,39 @@ export declare function applyFormat(run: XmlElement, format: TextFormat): void;
92
154
  export declare class DocxEditor {
93
155
  readonly doc: DocxDocument;
94
156
  readonly guard?: EditGuard | undefined;
95
- constructor(doc: DocxDocument, guard?: EditGuard | undefined);
157
+ private trackOverride;
158
+ private readonly authorName;
159
+ /** The part being edited. */
160
+ readonly part: string;
161
+ constructor(doc: DocxDocument, guard?: EditGuard | undefined, options?: EditorOptions);
162
+ /** Whether this editor works on a header, footer or notes part rather than the main document. */
163
+ private get isStory();
164
+ /** Whether edits are recorded as tracked changes (default: the document's Track Changes setting). */
165
+ get trackChanges(): boolean;
166
+ set trackChanges(on: boolean);
167
+ /** The author tracked changes are recorded under. */
168
+ get author(): string;
169
+ /** Revision stamp and id source for one edit, or undefined when not tracking. */
170
+ private tracking;
171
+ /** Turn Word's own Track Changes setting (settings.xml w:trackRevisions) on or off. */
172
+ setTrackChangesSetting(on: boolean): Promise<void>;
173
+ /** Tracked changes in the main document, in document order. */
174
+ revisions(): Revision[];
175
+ /** Accept tracked changes (all, or those matching ids / author). Returns how many. */
176
+ acceptRevisions(filter?: RevisionFilter): number;
177
+ /** Reject tracked changes (all, or those matching ids / author). Returns how many. */
178
+ rejectRevisions(filter?: RevisionFilter): number;
179
+ /** The new run as it goes into the document: wrapped in a w:ins when tracking. */
180
+ private placed;
181
+ /** Whether a run sits in an insertion by the current author (edits to it need no new revision). */
182
+ private inOwnInsertion;
183
+ /**
184
+ * A sentinel inside someone else's w:ins cannot take a nested w:ins: split that insertion at the
185
+ * sentinel so the new one goes between its two halves.
186
+ */
187
+ private liftOutOfInsertion;
188
+ /** Mark the runs of a range as deleted (and the paragraph marks inside it), keeping the text. */
189
+ private trackedCut;
96
190
  private get root();
97
191
  private get body();
98
192
  private index;
@@ -121,7 +215,7 @@ export declare class DocxEditor {
121
215
  offset: number;
122
216
  };
123
217
  }): DocRange;
124
- /** Every paragraph of the body, including those in tables, in document order. */
218
+ /** Every paragraph of the story (the body by default), including those in tables, in document order. */
125
219
  paragraphs(): DocParagraph[];
126
220
  /** Range covering a paragraph's text (undefined for paragraphs without text). */
127
221
  paragraphRange(paragraph: XmlElement | DocParagraph): DocRange | undefined;
@@ -135,6 +229,57 @@ export declare class DocxEditor {
135
229
  * "inside this (empty) paragraph".
136
230
  */
137
231
  insertText(at: DocPosition, text: string, format?: TextFormat): DocPosition;
232
+ /** Insert a run holding `content` (a drawing, a note reference) at a position; returns the run. */
233
+ private insertRunContent;
234
+ /**
235
+ * Insert a picture (PNG, JPEG, GIF, BMP, TIFF, EMF or WMF) inline at a position. Without a size it
236
+ * gets its natural size, shrunk to `maxWidth` (default 468pt, a Letter page's text width).
237
+ */
238
+ insertImage(at: DocPosition, bytes: Uint8Array, options?: {
239
+ width?: number;
240
+ height?: number;
241
+ alt?: string;
242
+ name?: string;
243
+ maxWidth?: number;
244
+ }): Promise<XmlElement>;
245
+ /** Add a footnote whose reference mark goes at a position. Returns the note's id. */
246
+ addFootnote(at: DocPosition, text: string): Promise<string>;
247
+ /** Headers and footers by section and page type, with their text ({PAGE} for page fields). */
248
+ headersAndFooters(): HeaderFooterInfo[];
249
+ /** Give the document's sections a header (see `setHeaderFooter`). Returns the part name. */
250
+ setHeader(text: string, options?: HeaderFooterOptions): Promise<string>;
251
+ /** Give the document's sections a footer (see `setHeaderFooter`). Returns the part name. */
252
+ setFooter(text: string, options?: HeaderFooterOptions): Promise<string>;
253
+ /**
254
+ * Create or replace a header or footer. `text`: lines become paragraphs, tabs split it into
255
+ * left / centre / right parts, and {PAGE}, {NUMPAGES}, {SECTIONPAGES} become page number fields
256
+ * ("Page {PAGE} of {NUMPAGES}"). Every section by default, or one (`section`, from 1); all pages,
257
+ * the first page or even pages (`type`). A part used only by these sections is rewritten in place,
258
+ * otherwise a new part is made, so other sections keep theirs. With Track Changes on, the text
259
+ * changes are recorded.
260
+ */
261
+ setHeaderFooter(kind: HeaderFooterKind, text: string, options?: HeaderFooterOptions): Promise<string>;
262
+ /** Remove headers (see `removeHeaderFooter`). Returns how many references were removed. */
263
+ removeHeader(options?: Omit<HeaderFooterOptions, 'type' | 'align'> & {
264
+ type?: HeaderFooterType | 'all';
265
+ }): Promise<number>;
266
+ /** Remove footers (see `removeHeaderFooter`). Returns how many references were removed. */
267
+ removeFooter(options?: Omit<HeaderFooterOptions, 'type' | 'align'> & {
268
+ type?: HeaderFooterType | 'all';
269
+ }): Promise<number>;
270
+ /**
271
+ * Remove headers or footers: of every type unless `type` says which, from every section unless
272
+ * `section` says which (a later section without its own then shows the previous section's). Parts
273
+ * nothing uses any more are deleted. Not recorded as a tracked change.
274
+ */
275
+ removeHeaderFooter(kind: HeaderFooterKind, options?: Omit<HeaderFooterOptions, 'type' | 'align'> & {
276
+ type?: HeaderFooterType | 'all';
277
+ }): Promise<number>;
278
+ private mainBody;
279
+ private sectionTargets;
280
+ /** Delete header/footer parts (and their relationships) that no section refers to any more. */
281
+ private dropUnusedParts;
282
+ private setEvenAndOdd;
138
283
  /** Join a paragraph with the one right after it (Backspace at the start of the second). */
139
284
  mergeParagraphs(first: XmlElement, second: XmlElement): void;
140
285
  /** Split a paragraph at a position (Enter). Returns the new, second paragraph. */
@@ -143,8 +288,12 @@ export declare class DocxEditor {
143
288
  appendText(paragraph: XmlElement, text: string, format?: TextFormat): XmlElement;
144
289
  /** Delete a range (it may span paragraphs, but not table cells). */
145
290
  deleteRange(range: DocRange): void;
146
- /** Replace a range with text formatted like the range's first run. */
147
- replaceRange(range: DocRange, text: string, format?: TextFormat): void;
291
+ /**
292
+ * Replace a range with text formatted like the range's first run, or with pieces of text that are
293
+ * each formatted like their own `like` run (for example to rewrite a sentence and keep which words
294
+ * were bold). `format` is applied on top.
295
+ */
296
+ replaceRange(range: DocRange, text: string | TextPiece[], format?: TextFormat): void;
148
297
  /** Replace every match; returns how many were replaced. */
149
298
  replaceAll(query: string | RegExp, replacement: string | ((m: Match) => string)): number;
150
299
  /**
@@ -161,6 +310,8 @@ export declare class DocxEditor {
161
310
  }): string[];
162
311
  /** Apply character formatting to a range. */
163
312
  formatRange(range: DocRange, format: TextFormat): void;
313
+ /** Remove direct character formatting (and character styles, except Hyperlink) from a range. */
314
+ clearFormatting(range: DocRange): void;
164
315
  /** Remove the content of a range, returning the sentinels at its (now adjacent) ends. */
165
316
  private cut;
166
317
  private removeRange;
@@ -173,15 +324,88 @@ export declare class DocxEditor {
173
324
  format?: TextFormat;
174
325
  }): XmlElement;
175
326
  deleteParagraph(paragraph: XmlElement): void;
327
+ /** The block (paragraph, table or content control) of the body that holds `node`. */
328
+ private topBlock;
329
+ /** Put new blocks into the body before/after the block holding `ref`, or at the start or end. */
330
+ private placeBlocks;
331
+ /** Permission to add content next to `where`. */
332
+ private checkPlace;
333
+ /**
334
+ * Copy the body's blocks from the one holding `from` to the one holding `to` (a table is copied
335
+ * whole) and put the copies at `where`, with their formatting, lists, tables and pictures. Lists
336
+ * in the copy number from the start again unless `restartLists` is false, and `pageBreak` starts
337
+ * the copy on a new page. What may exist only once (bookmarks, comment anchors, note references)
338
+ * is left out of the copy and counted in `dropped`.
339
+ */
340
+ copyBlocks(from: XmlElement, to: XmlElement, where: {
341
+ before?: XmlElement;
342
+ after?: XmlElement;
343
+ } | 'start' | 'end', options?: {
344
+ pageBreak?: boolean;
345
+ restartLists?: boolean;
346
+ }): Promise<{
347
+ blocks: XmlElement[];
348
+ dropped: CopyDropped;
349
+ }>;
350
+ /**
351
+ * Insert a table of text (`rows` of cell texts; "\n" in a cell starts a new paragraph) before or
352
+ * after the block holding a paragraph, or at the start or end. It spans the text width.
353
+ */
354
+ insertTable(where: {
355
+ before?: XmlElement;
356
+ after?: XmlElement;
357
+ } | 'start' | 'end', rows: string[][], options?: TableOptions): XmlElement;
358
+ /** The table holding a paragraph (the innermost one). */
359
+ tableOf(paragraph: XmlElement): XmlElement;
360
+ /** Permission to change a table: its whole text. */
361
+ private checkTable;
362
+ /**
363
+ * Insert rows into a table before row `at` (0-based; the row count appends). Each new row copies
364
+ * the formatting of the row next to it and gets the texts of one entry of `rows`.
365
+ */
366
+ insertTableRows(table: XmlElement, at: number, rows: string[][]): XmlElement[];
367
+ /** Delete rows `from` to `to` (0-based, inclusive) of a table; deleting them all deletes the table. */
368
+ deleteTableRows(table: XmlElement, from: number, to?: number): void;
369
+ /** Delete a whole table. */
370
+ deleteTable(table: XmlElement): void;
371
+ private markRowDeleted;
176
372
  setParagraphStyle(paragraph: XmlElement, styleId: string): void;
373
+ /** Change paragraph formatting: alignment, direction, indents, spacing and keep rules. */
374
+ formatParagraph(paragraph: XmlElement, format: ParagraphFormat): void;
375
+ /** The list paragraphs of the body with their labels ("1.", "a)", "•"), keyed by w:p. */
376
+ listItems(): Map<XmlElement, ListItem>;
377
+ /**
378
+ * Change list formatting of paragraphs:
379
+ * - `format`: make them one list in that format ('bullet', 'decimal' 1., 'decimalParen' 1),
380
+ * 'lowerLetter' a., 'upperLetter' A., 'lowerRoman' i., 'upperRoman' I.), numbered from `start`
381
+ * (default 1). Paragraphs already in a list keep its indentation and their level. 'none' takes
382
+ * them out of their list.
383
+ * - `start` alone: restart the numbering, keeping the format.
384
+ * - `level` (0–8): the list level (indent); alone, only the level changes.
385
+ * - `sameListAs`: join the list of that paragraph, continuing its numbering.
386
+ * Returns the numId the paragraphs now use (undefined after 'none').
387
+ */
388
+ setList(paragraphs: XmlElement[], options: SetListOptions): Promise<string | undefined>;
389
+ /** Set or clear a paragraph's w:numPr (clearing style-given numbering with numId 0). */
390
+ private writeNumPr;
177
391
  /** Turn a range (within one paragraph) into a hyperlink to a URL or a bookmark. */
178
392
  addHyperlink(range: DocRange, target: {
179
393
  url: string;
180
394
  } | {
181
395
  bookmark: string;
182
396
  }, tooltip?: string): Promise<XmlElement>;
397
+ /** Point an existing w:hyperlink at another URL or a bookmark (same scheme rules as `addHyperlink`). */
398
+ setHyperlinkTarget(hyperlink: XmlElement, target: {
399
+ url: string;
400
+ } | {
401
+ bookmark: string;
402
+ }): Promise<void>;
403
+ /** Remove a hyperlink relationship that nothing in this part refers to any more. */
404
+ private dropHyperlinkRel;
405
+ /** Set the alt text (wp:docPr/@descr) of a picture or drawing. */
406
+ setImageAlt(drawing: XmlElement, text: string): void;
183
407
  /** Unwrap a w:hyperlink, keeping its text. */
184
- removeHyperlink(link: XmlElement): void;
408
+ removeHyperlink(link: XmlElement): Promise<void>;
185
409
  /** Every w:hyperlink in the body with its target. */
186
410
  hyperlinks(): Array<{
187
411
  el: XmlElement;