docxkeun 0.3.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to docxkeun and docxkeun-fonts. Versions follow [semantic versioning](https://semver.org); while the version is 0.x, minor versions may contain breaking changes.
4
4
 
5
+ ## 0.4.0 (2026-11-24)
6
+
7
+ ### docxkeun
8
+
9
+ - The `words` effect style now colours only the letters. Its shimmer and the marks it leaves are drawn on the text itself, so shaded table cells, highlighted text and pictures in the paragraph keep their own colours, and the changed words no longer sit in a tinted glow. Before, the shimmer was a coloured band blended over the line, which tinted anything that was not white, and the marks added a blurred box behind the words. With `marks: false`, the changed letters now light up for a moment instead of a tinted band passing over them.
10
+
11
+ - **Charts:** `DocxEditor.insertChart()` adds a column, bar, line, area, pie, doughnut or scatter chart (stacked and 100% stacked for column, bar and area), with a title, axis titles and legend. It looks like a chart Word has just inserted (theme colours, a white chart area without a border, 9 pt grey text), and its numbers are written into an embedded workbook, so "Edit Data" in Word shows them. `chartInfo()` reads a chart's data back as a table, and `updateChart()` changes its title, legend or data while keeping its look, and rewrites the workbook; an added series is styled like the last one in the next accent colour (keeping transparency, but not the last one's single-point formatting, trendline or error bars). A chart linked to an outside file only has its cached numbers changed. Word does not track chart changes, so neither does this. Number formats carry through: a series' `formatCode` (such as `0%`) and a chart's `categoryFormat` (such as `mmm-yy` for dates) are written to the chart and to the workbook's cells, `chartInfo()` reads them back, an update keeps each series' format by position, and numeric or date categories stay numbers instead of turning into text. So `categories` in `insertChart()`, `chartInfo()` and `updateChart()` holds strings, numbers (dates as Excel serial numbers) or `null` for a missing one; TypeScript code reading `chartInfo().categories` should allow for all three. The chart types and `ChartDataError` are exported from `docxkeun/editor`.
12
+ - **Objects:** `objects()` lists pictures, charts, diagrams, shapes, text boxes and groups with numbers. `resizeObject()`, `setObjectAlt()`, `deleteObject()`, `moveObject()` and `placeObject()` change them; resizing, alt text and floating position are applied directly, since Word does not track them, while creating, deleting, moving and switching between inline and floating are tracked. Before, only pictures could be inserted and given alt text. For an object that already floats, `placeObject()` keeps what the placement leaves out (x, y, `from`, `wrap`), so its wrap or reference can change on its own; making an inline object float still needs x and y.
13
+ - **Shapes and text boxes:** `insertShape()` adds a text box or a shape (rectangle, rounded rectangle, oval, triangle, diamond, arrows, chevron, pentagon, star, callouts, line), inline or floating (square wrap, above and below, in front of or behind the text), with text, fill and outline colours. As in Word, only pictures go inside a text box: `insertShape()`, `insertChart()` and `moveObject()` refuse shapes, text boxes, charts, SmartArt and other graphics there.
14
+ - **Breaking:** `paragraphs()` now also lists the paragraphs inside text boxes, right after the paragraph that holds the box. `find()`, `replaceAll()` and `fillTemplate()` reach text in boxes too. Code that indexes `paragraphs()` by position will see its numbers shift in documents with text boxes. Before, text in boxes could only be changed through `storyParts()`.
15
+ - Copied content (`copyBlocks()`) now gives a copied chart its own chart part and workbook (Word 2016 charts such as waterfalls too), so changing one copy no longer changes the other. `updateChart()` first gives a chart its own part when copies made by docxkeun 0.3.0 or older still share it.
16
+ - `replaceRange()` takes `{ keepObjects: true }`: pictures, charts, shapes and text boxes inside the replaced range then stay, right after the new text in their original order, and are not marked deleted with Track Changes on. It returns how many objects it kept. Without the option, objects in the range go with the old text, as when someone selects and types over them.
17
+ - The AI's marks (`aiActivity`) also notice changed charts and objects, not only text, and text changed inside a text box or shape (marked on the paragraph holding it).
18
+
19
+ ### docxkeun chat
20
+
21
+ - Claude can now insert charts (column, bar, line, area, pie, doughnut, scatter), read and update their data, insert shapes and text boxes, and resize, move, describe or delete pictures, charts, shapes and text boxes. Text box paragraphs are numbered in line, so Claude edits them like any other paragraph. Before, it could only read these.
22
+
23
+ ### docxkeun-mcp 0.3.0
24
+
25
+ - New tools: `insert_chart`, `read_chart`, `update_chart`, `insert_shape`, `edit_object` and `delete_object`. `read_document` and `list_objects` give every picture, chart, shape and text box an object number that these tools use. `read_chart` names number formats other than General (and says when the categories are dates), and `update_chart` keeps them.
26
+ - Text box paragraphs are now numbered in line, right after the paragraph holding the box, so `edit_paragraph`, `replace_text`, `format_text` and the other paragraph tools work on them. Paragraph numbers after a text box shift when a box with text is added, moved or deleted; read the document again after those tools. `replace_story_text` still works.
27
+ - `edit_object` changes a floating object's wrap or reference on its own: x and y left out keep its position. `list_objects` says where a floating object sits and how text wraps around it ("floating, 36 pt right and 12 pt down from the margin, square wrap").
28
+ - `edit_paragraph` and `replace_text` keep the pictures, charts and text boxes that sat in the middle of the text they rewrite, right after the new text, and say how many they kept. Before, rewriting such a paragraph deleted them, text box and all.
29
+ - The live preview shows tracked changes as Word's All Markup view does: inserted text underlined and deleted text struck through, in a colour per author. Before, it always showed documents as if every change were accepted, so an AI's tracked edits looked like plain edits. A **Tracked changes** checkbox switches back to that view, and the browser remembers it. The AI's effects and the selection chip find the right paragraphs in both views, and `get_selection` reads a selection made where deleted text shows, saying when the text includes deleted words. Activity events now also carry read_document's paragraph numbers (`read`).
30
+
5
31
  ## 0.3.0 (2026-11-23)
6
32
 
7
33
  ### docxkeun
package/README.md CHANGED
@@ -130,7 +130,7 @@ Effect styles: `aiActivity: { style: 'words' }` (or `viewer.activity.style = 'wo
130
130
  | Style | While the AI works | After the change |
131
131
  |---|---|---|
132
132
  | `highlight` (default) | a tinted band sweeps over the lines | the paragraph keeps a soft tint |
133
- | `words` | the letters themselves shimmer | the changed words glow |
133
+ | `words` | the letters themselves shimmer; nothing behind them changes | the changed words' letters keep the colours |
134
134
  | `underline` | a streak runs under each line | the changed words stay underlined |
135
135
  | `edge` | a soft glow breathes around the paragraph | the ✦ bar in the margin |
136
136
  | `spotlight` | the rest of the page dims | the ✦ bar in the margin |
@@ -195,7 +195,7 @@ await editor.resolveComment(id);
195
195
  const bytes = await viewer.document!.save();
196
196
  ```
197
197
 
198
- Also available: `insertText`, `appendText`, `replaceRange` (text, or pieces each formatted like a given run: `[{ text, like: boldRun }, { text, like: plainRun }]`), `replaceAll`, `deleteRange` (across paragraphs), `insertParagraph`, `deleteParagraph`, `setParagraphStyle`, `formatParagraph` (alignment, right-to-left, indents, spacing, keep rules), `insertImage`, `addFootnote`, `setHeader` / `setFooter` / `removeHeader` / `removeFooter` / `headersAndFooters()`, `await removeHyperlink` (async since it also drops the link's relationship when unused), `setHyperlinkTarget`, `setImageAlt`, `clearFormatting`, `hyperlinks()`, `bookmarks()`, `removeBookmark`, `editComment`, `deleteComment`, `addEditableRange`, `removeEditableRange`.
198
+ Also available: `insertText`, `appendText`, `replaceRange` (text, or pieces each formatted like a given run: `[{ text, like: boldRun }, { text, like: plainRun }]`; with `{ keepObjects: true }` pictures, charts and text boxes in the range stay, after the new text), `replaceAll`, `deleteRange` (across paragraphs), `insertParagraph`, `deleteParagraph`, `setParagraphStyle`, `formatParagraph` (alignment, right-to-left, indents, spacing, keep rules), `insertImage`, `addFootnote`, `setHeader` / `setFooter` / `removeHeader` / `removeFooter` / `headersAndFooters()`, `await removeHyperlink` (async since it also drops the link's relationship when unused), `setHyperlinkTarget`, `setImageAlt`, `clearFormatting`, `hyperlinks()`, `bookmarks()`, `removeBookmark`, `editComment`, `deleteComment`, `addEditableRange`, `removeEditableRange`.
199
199
 
200
200
  ```ts
201
201
  // Tracked changes: record edits as Word revisions, then review them.
@@ -249,6 +249,47 @@ editor.insertTableRows(table, 2, [['2', 'Admin fee', 'Rp 500.000']]); // copies
249
249
  editor.deleteTableRows(table, 2); // 0-based; deleting every row deletes the table
250
250
  ```
251
251
 
252
+ Charts, shapes and objects: `insertChart` writes a chart with its data in an embedded workbook (Word's "Edit Data" opens it), `updateChart` changes it, and `insertShape` adds a text box or shape. `objects()` lists pictures, charts, shapes and text boxes in document order. A text box's paragraphs appear in `paragraphs()` right after the paragraph holding it, so `find` and `replaceAll` reach them too. As in Word, only pictures go inside a text box. Number formats (`formatCode` on a series, `categoryFormat` for numbers or dates) go into the chart and its workbook and survive updates. `placeObject` on an object that already floats keeps what you leave out, so `{ wrap: 'behind' }` alone re-wraps it.
253
+
254
+ ```ts
255
+ const at = editor.find('Quarterly sales')[0]!.end;
256
+ await editor.insertChart(at, {
257
+ type: 'column', title: 'Sales by quarter',
258
+ categories: ['Q1', 'Q2', 'Q3'],
259
+ series: [{ name: '2026', values: [120, 150, 170] }],
260
+ });
261
+ await editor.insertShape(at, { shape: 'textBox', text: 'Draft\nfigures', width: 150, place: { x: 300, y: 0, from: 'paragraph', wrap: 'square' } });
262
+
263
+ const chart = editor.objects().find((o) => o.kind === 'chart')!; // pictures, charts, diagrams, shapes, text boxes, groups
264
+ const table = editor.chartInfo(chart); // { kind, title, categories, series, legend, … }
265
+ await editor.updateChart(chart, { series: [...table.series, { name: '2027', values: [130, 160, 190] }] }); // replaces the whole table
266
+ editor.resizeObject(chart, { width: 400 }); // points; the height keeps the proportions
267
+ ```
268
+
269
+ ### Creating a document
270
+
271
+ `createDocx()` starts a blank document: A4 with 2.54 cm margins, Calibri 11 pt, and Word's Normal, Heading 1, Heading 2, Hyperlink and Table Grid styles. Every editing call above works on it, in Node or the browser, with no viewer needed.
272
+
273
+ ```ts
274
+ import { writeFile } from 'node:fs/promises';
275
+ import { createDocx } from 'docxkeun';
276
+ import { DocxEditor } from 'docxkeun/editor';
277
+
278
+ const doc = await createDocx();
279
+ const editor = new DocxEditor(doc);
280
+
281
+ const title = editor.paragraphs()[0]!.el; // a new document starts with one empty paragraph
282
+ editor.appendText(title, 'Quarterly report');
283
+ editor.setParagraphStyle(title, 'Heading1');
284
+
285
+ editor.insertParagraph('end', 'Sales grew in every quarter, helped by:');
286
+ const reasons = ['A new distributor in Surabaya', 'The online store'].map((text) => editor.insertParagraph('end', text));
287
+ await editor.setList(reasons, { format: 'bullet' });
288
+ editor.insertTable('end', [['Quarter', 'Sales'], ['Q1', '120'], ['Q2', '150']], { header: true, widths: [1, 2] });
289
+
290
+ await writeFile('report.docx', await doc.save());
291
+ ```
292
+
252
293
  ### PDF
253
294
 
254
295
  ```ts
@@ -331,6 +372,15 @@ const DocxView = createDocxViewerComponent(React); // no React dependency in do
331
372
 
332
373
  [`docxkeun-mcp`](packages/mcp#readme) is an [MCP](https://modelcontextprotocol.io) server built on docxkeun. It gives Claude Code, Claude Desktop and other MCP clients tools to read documents (including pictures, charts, equations, headers, footers and notes), find and replace text, fill templates, format paragraphs, insert pictures and footnotes, comment, record and review tracked changes, lock regions, set protection and passwords, and export PDFs, limited to the folders you choose and to a role (viewer, commenter, editor or owner).
333
374
 
375
+ ![An AI assistant edits a Word document through docxkeun-mcp while the live preview shows each change: it rewrites a summary, adds a column chart from a table, makes tracked edits, comments on a table cell and exports a PDF](https://raw.githubusercontent.com/kevinkjs/docxkeun/main/.github/assets/docxkeun-mcp-demo.gif)
376
+
377
+ <details>
378
+ <summary>The same demo as a 1080p video</summary>
379
+
380
+ https://github.com/user-attachments/assets/22feb021-8290-4024-ae5d-2ae4b8d345eb
381
+
382
+ </details>
383
+
334
384
  ```bash
335
385
  claude mcp add docxkeun -- npx -y docxkeun-mcp ~/Documents/contracts
336
386
  ```
@@ -389,7 +439,7 @@ Known limits:
389
439
  - **Pictures:** only the first frame of a GIF and the first page of a TIFF; JPEG-compressed and CMYK TIFFs are not decoded. EMF+-only pictures (some Office 2007+ charts pasted as pictures) and clipping inside metafiles are not supported.
390
440
  - **Equations:** no line breaks inside an equation and no equation numbers. Math symbols missing from your fonts fall back to other fonts (the bundled fonts have no math font such as Cambria Math).
391
441
  - **Right-to-left and complex scripts:** the bundled fonts have no Arabic or Indic letters; register a font that has them (for example Arial, Times New Roman or Noto) for PDF export. The viewer leaves shaping these scripts to the browser.
392
- - **Editing:** creating or changing shapes, charts and equations, moving or resizing pictures, and changing a table's columns or merged cells are not supported. Rows can be added and deleted from code, not yet on the page. A keystroke still paginates the whole document, re-using the measured lines of unchanged paragraphs.
442
+ - **Editing:** creating or changing equations and SmartArt, and changing a table's columns or merged cells, are not supported. Charts, shapes, text boxes and pictures can be inserted, changed, resized and moved from code (`DocxEditor`), but not yet on the page. Rows can be added and deleted from code, not yet on the page. A keystroke still paginates the whole document, re-using the measured lines of unchanged paragraphs.
393
443
 
394
444
  ## Development
395
445
 
@@ -400,7 +450,7 @@ pnpm dev # playground at http://localhost:5199
400
450
  pnpm build # dist/
401
451
  ```
402
452
 
403
- Tests and the playground use the fonts in `packages/fonts`. Two optional checks compare them with Arial and Times New Roman when those are installed. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute and release, and [SECURITY.md](SECURITY.md) to report a vulnerability.
453
+ Tests and the playground use the fonts in `packages/fonts`. Two optional checks compare them with Arial and Times New Roman when those are installed. After `pnpm build` and `pnpm build:mcp`, `node packages/mcp/demo/record.mjs` records the docxkeun-mcp demo again (it needs Google Chrome and writes `docxkeun-mcp-demo.mp4` and `.gif` to `packages/mcp/demo/out/`; the README GIF is a copy in `.github/assets`). See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute and release, and [SECURITY.md](SECURITY.md) to report a vulnerability.
404
454
 
405
455
  ## License
406
456
 
@@ -1,3 +1,4 @@
1
+ import { type ChartChanges, type NewChart } from '../charts/write.js';
1
2
  import { type HeaderFooterInfo, type HeaderFooterKind, type HeaderFooterOptions, type HeaderFooterType } from './headers.js';
2
3
  import type { DocParagraph, Block } from '../model/content.js';
3
4
  import type { DocxDocument } from '../model/document.js';
@@ -5,6 +6,7 @@ import { type XmlElement } from '../xml/index.js';
5
6
  import { type ListFormat, type ListItem } from './lists.js';
6
7
  import { type CopyDropped, type TableOptions } from './tables.js';
7
8
  import { type Revision, type RevisionFilter } from './revisions.js';
9
+ import { type ChartInfo, type ChartUpdate, type DocObject, type NewShape, type ObjectPlacement } from './objects.js';
8
10
  import { EditError, type DocPosition, type DocRange } from './positions.js';
9
11
  export type EditAction = 'edit' | 'format' | 'comment' | 'reply' | 'resolveComment' | 'editComment' | 'deleteComment' | 'link' | 'bookmark' | 'fillForm' | 'protect' | 'review';
10
12
  /**
@@ -129,8 +131,13 @@ export interface ParagraphText {
129
131
  text: string;
130
132
  segments: TextSegment[];
131
133
  }
132
- /** Every paragraph of a block list (including table cells), in document order. */
133
- export declare function paragraphsOf(blocks: Block[], out?: DocParagraph[]): DocParagraph[];
134
+ /**
135
+ * Every paragraph of a block list (including table cells), in document order. With `textBoxes`,
136
+ * the paragraphs of the text boxes in a paragraph follow it (a group's boxes depth first).
137
+ */
138
+ export declare function paragraphsOf(blocks: Block[], out?: DocParagraph[], options?: {
139
+ textBoxes?: boolean;
140
+ }): DocParagraph[];
134
141
  export declare function paragraphText(para: DocParagraph, options?: {
135
142
  objects?: boolean;
136
143
  }): ParagraphText;
@@ -192,6 +199,17 @@ export declare class DocxEditor {
192
199
  private index;
193
200
  private changed;
194
201
  private check;
202
+ /**
203
+ * Permission for a change Word can't track (an object's size, a floating object's position or
204
+ * wrap, alt text, chart data): it applies directly even with Track Changes on, so it is refused
205
+ * where only tracked changes are allowed. Locks hold as for any edit.
206
+ */
207
+ private checkUntracked;
208
+ /**
209
+ * Word stores a text box twice: DrawingML in mc:Choice and an old VML copy in mc:Fallback. A
210
+ * change inside the box (at any of `nodes`) leaves the copy stale, so it goes.
211
+ */
212
+ private dropStaleFallbacks;
195
213
  /** The locked content control around a node, if any. */
196
214
  private lockAround;
197
215
  /** Throw LockedRegionError when a range touches a locked region (or would delete one). */
@@ -215,7 +233,10 @@ export declare class DocxEditor {
215
233
  offset: number;
216
234
  };
217
235
  }): DocRange;
218
- /** Every paragraph of the story (the body by default), including those in tables, in document order. */
236
+ /**
237
+ * Every paragraph of the story (the body by default), including those in tables, in document
238
+ * order. In the body, a text box's paragraphs come right after the paragraph holding the box.
239
+ */
219
240
  paragraphs(): DocParagraph[];
220
241
  /** Range covering a paragraph's text (undefined for paragraphs without text). */
221
242
  paragraphRange(paragraph: XmlElement | DocParagraph): DocRange | undefined;
@@ -242,6 +263,100 @@ export declare class DocxEditor {
242
263
  name?: string;
243
264
  maxWidth?: number;
244
265
  }): Promise<XmlElement>;
266
+ /** Declare namespace prefixes on the story's root element where they are missing. */
267
+ private declare;
268
+ /** An id for a new drawing (wp:docPr ids must be unique in the document); the root gets the prefixes drawings use. */
269
+ private newDrawingId;
270
+ /** Fresh ids for copied content (see `cleanCopy`): tracked changes, drawings and content controls stay unique. */
271
+ private copyIds;
272
+ /** Pictures, charts, SmartArt, shapes, text boxes and groups, numbered from 1 in document order. */
273
+ objects(): DocObject[];
274
+ /**
275
+ * The run's child holding an object (its w:drawing or w:pict, or the mc:AlternateContent around
276
+ * it), found in the tree as it is now; EditError when the object is no longer in the document or
277
+ * is marked deleted (as the original of a tracked move is).
278
+ */
279
+ private objectNodeOf;
280
+ /** The child of the nearest run that holds `node` (or is it). */
281
+ private runChildHolding;
282
+ /** The range of an object, for access and lock checks. */
283
+ private objectRange;
284
+ /**
285
+ * Insert a chart inline at a position, with its data in an embedded workbook (so Word's "Edit
286
+ * Data" shows it). Without a size it gets Word's 432 × 252 pt, shrunk to the section's text width;
287
+ * with one side, the other keeps those proportions. Not inside a text box (Word puts only pictures
288
+ * there). Returns the w:drawing.
289
+ */
290
+ insertChart(at: DocPosition, chart: NewChart & {
291
+ width?: number;
292
+ height?: number;
293
+ alt?: string;
294
+ }): Promise<XmlElement>;
295
+ /**
296
+ * Insert a text box or a preset shape at a position, with optional text (each line a paragraph,
297
+ * listed by `paragraphs()` right after the paragraph holding it). By default it floats at the top
298
+ * left of the paragraph with square wrap; see `NewShape` for sizes and colours. Not inside a
299
+ * text box (Word doesn't nest them). Returns the w:drawing.
300
+ */
301
+ insertShape(at: DocPosition, shape: NewShape): Promise<XmlElement>;
302
+ /** A chart's data (type, titles, legend, categories, series) and where it comes from. */
303
+ chartInfo(obj: DocObject): ChartInfo;
304
+ /**
305
+ * Change a chart's titles, legend or data, keeping its formatting (see `patchChartSpace`). New
306
+ * data must suit the chart's type, and rewrites the embedded workbook; a chart with an old embedded
307
+ * object or no workbook gets a new one. A chart linked to an outside file only has its cached data
308
+ * changed: the file is not, and Word's refresh brings its numbers back. A chart part other charts
309
+ * share is copied for this chart first (see `ownChart`). Word does not track chart changes, so
310
+ * neither does this.
311
+ */
312
+ updateChart(obj: DocObject, changes: ChartChanges): Promise<ChartUpdate>;
313
+ /**
314
+ * The chart part behind a chart object, for this chart alone: a part that other charts point at
315
+ * too (as copies made by docxkeun 0.3.0 and older do) is copied first, with its workbook, and this
316
+ * chart (and `obj.chartPart`) moves to the copy, so changing it leaves the others alone.
317
+ */
318
+ private ownChart;
319
+ /**
320
+ * Give every chart under `nodes` (c:chart, and Word 2016's cx:chart) its own copy of its chart part
321
+ * (and workbook), so copies change independently.
322
+ */
323
+ private copyChartParts;
324
+ /**
325
+ * Resize an object (points). With one side given, the other keeps the object's proportions. A
326
+ * group's shapes scale with it; a chart redraws to fit. Word doesn't track size, so this applies
327
+ * directly, and is refused where only tracked changes are allowed.
328
+ */
329
+ resizeObject(obj: DocObject, size: {
330
+ width?: number;
331
+ height?: number;
332
+ }): void;
333
+ /** Set an object's alt text (empty removes it). Not tracked, as in Word (see `resizeObject`). */
334
+ setObjectAlt(obj: DocObject, alt: string): void;
335
+ /** Delete an object. With Track Changes on the deletion is tracked: its run (and any text in it) is marked deleted. */
336
+ deleteObject(obj: DocObject): void;
337
+ /**
338
+ * Move an object to `at`, keeping its size and placement (a floating object is anchored there
339
+ * instead). With Track Changes on this is tracked as Word tracks a cut and paste: the original is
340
+ * marked deleted and a copy inserted (a chart's copy gets its own chart part and workbook). Only
341
+ * pictures can go inside a text box, and an object there can only be inline.
342
+ */
343
+ moveObject(obj: DocObject, at: DocPosition): Promise<void>;
344
+ /**
345
+ * Place an object inline, or floating at a position with a wrap style. Moving or re-wrapping a
346
+ * floating object (what `place` leaves out of x, y, `from` and `wrap`, it keeps) isn't tracked by Word, so it applies
347
+ * directly and is refused where only tracked changes are allowed. Switching between inline and
348
+ * floating is tracked like a move when Track Changes is on: the original is marked deleted and a
349
+ * copy inserted right after it.
350
+ */
351
+ placeObject(obj: DocObject, place: ObjectPlacement): Promise<void>;
352
+ /** A new, empty run at `at` (a tracked insertion when tracking) formatted like `like`, for an object. */
353
+ private objectRun;
354
+ /**
355
+ * A tracked move: a copy of the object (`node` is the run's child holding it), changed by
356
+ * `change`, goes in at `at` as an insertion, with its own drawing id and chart part; the original
357
+ * is marked deleted.
358
+ */
359
+ private replaceTracked;
245
360
  /** Add a footnote whose reference mark goes at a position. Returns the note's id. */
246
361
  addFootnote(at: DocPosition, text: string): Promise<string>;
247
362
  /** Headers and footers by section and page type, with their text ({PAGE} for page fields). */
@@ -291,9 +406,22 @@ export declare class DocxEditor {
291
406
  /**
292
407
  * Replace a range with text formatted like the range's first run, or with pieces of text that are
293
408
  * 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.
409
+ * were bold). `format` is applied on top. Objects in the range (pictures, charts, shapes, text
410
+ * boxes) go with the old text, as when a user selects and types over them; with `keepObjects` they
411
+ * stay, right after the new text in their original order (not marked deleted when tracking).
412
+ * Returns how many objects were kept.
413
+ */
414
+ replaceRange(range: DocRange, text: string | TextPiece[], format?: TextFormat, options?: {
415
+ keepObjects?: boolean;
416
+ }): number;
417
+ /**
418
+ * Take the objects (see OBJECT_NODES) between two marks out of their runs, for `replaceRange`
419
+ * with keepObjects: they come back in `keep.runs`, in a run like the one they were in, and still in
420
+ * a tracked insertion when they were in one. Objects already marked deleted, and anything inside an
421
+ * object in the range (a text box's own runs), are left alone. A range inside a text box keeps the
422
+ * objects of its own runs: those share the range's holding run.
295
423
  */
296
- replaceRange(range: DocRange, text: string | TextPiece[], format?: TextFormat): void;
424
+ private takeObjects;
297
425
  /** Replace every match; returns how many were replaced. */
298
426
  replaceAll(query: string | RegExp, replacement: string | ((m: Match) => string)): number;
299
427
  /**
@@ -402,7 +530,7 @@ export declare class DocxEditor {
402
530
  }): Promise<void>;
403
531
  /** Remove a hyperlink relationship that nothing in this part refers to any more. */
404
532
  private dropHyperlinkRel;
405
- /** Set the alt text (wp:docPr/@descr) of a picture or drawing. */
533
+ /** Set the alt text (wp:docPr/@descr) of a picture or drawing. Not tracked, as in Word (see `setObjectAlt`). */
406
534
  setImageAlt(drawing: XmlElement, text: string): void;
407
535
  /** Unwrap a w:hyperlink, keeping its text. */
408
536
  removeHyperlink(link: XmlElement): Promise<void>;