@docx-editor.dev/editor-api 2.24.0 → 2.25.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/OFFICE_JS_GUIDE.md +57 -1
- package/dist/browser.d.mts +4 -3
- package/dist/browser.d.ts +4 -3
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{server-mLIW1Y6U.d.mts → server-Csjpe214.d.mts} +308 -202
- package/dist/{server-mLIW1Y6U.d.ts → server-Csjpe214.d.ts} +308 -202
- package/package.json +4 -3
package/OFFICE_JS_GUIDE.md
CHANGED
|
@@ -62,6 +62,29 @@ Supported read-derived proxies can share one `sync()` with their edits. For exam
|
|
|
62
62
|
|
|
63
63
|
Proxies returned by insertions require a completed `sync()` before dependent operations. Do not configure a newly inserted table, image, list, or text range before that sync. If a prerequisite fails, the runtime commits no queued writes. Completed prerequisite reads can remain loaded after a later command fails.
|
|
64
64
|
|
|
65
|
+
## Keep writes within one story
|
|
66
|
+
|
|
67
|
+
A story is the main body, a header, a footer, or another document text container. One `context.sync()` can write only one story. Writes across stories fail with `ConflictingChanges`. Reads from different stories can share a sync.
|
|
68
|
+
|
|
69
|
+
If the document has a primary header and footer, resolve both objects before formatting them. Then commit each story's writes separately:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
await runtime.run(async (context) => {
|
|
73
|
+
const section = context.document.sections.getFirst();
|
|
74
|
+
await context.sync();
|
|
75
|
+
const stories = [section.getHeader('Primary'), section.getFooter('Primary')];
|
|
76
|
+
await context.sync();
|
|
77
|
+
|
|
78
|
+
for (const story of stories) {
|
|
79
|
+
story.font.name = 'Calibri';
|
|
80
|
+
story.font.size = 10;
|
|
81
|
+
await context.sync();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Each write sync creates a separate transaction. Earlier successful transactions remain if a later transaction fails. Linked headers or footers can share content. Re-read that content before making a dependent edit through another section.
|
|
87
|
+
|
|
65
88
|
## Preserve Office.js enum property types
|
|
66
89
|
|
|
67
90
|
Like Office.js, `Document.changeTrackingMode` and `PageSetup.orientation` use unions of the enum and its string literals for both reads and writes. Enum constants and the corresponding string literals are accepted by the type system. This matches Microsoft's [change-tracking declaration](https://learn.microsoft.com/en-us/javascript/api/word/word.document#word-word-document-changetrackingmode-member) and [page-orientation declaration](https://learn.microsoft.com/en-us/javascript/api/word/word.pagesetup#word-word-pagesetup-orientation-member).
|
|
@@ -119,14 +142,37 @@ Use `isDocxEditorError(error)` and branch on `error.code`. `error.target` identi
|
|
|
119
142
|
| Read the current mode | `document.load('changeTrackingMode')`, then sync and read the property |
|
|
120
143
|
| Make an intentional permanent edit | Explicitly set `changeTrackingMode = 'Off'` |
|
|
121
144
|
|
|
122
|
-
`Off` is the initial runtime mode.
|
|
145
|
+
`Off` is the initial runtime mode. `TrackMineOnly` needs a configured author and persists for that runtime. It does not change peers' editing modes or save a document-wide policy. Browser tracked writes require the review module. The tracking property does not change the editor UI mode. `TrackAll` fails with `NotSupported`.
|
|
146
|
+
|
|
147
|
+
| Tracked edit | Supported behavior |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| Range text | Insert, replace, or delete text; adjacent sibling paragraphs work outside collaboration |
|
|
150
|
+
| Font and paragraphs | Track font, paragraph-format, and paragraph-style edits as property revisions |
|
|
151
|
+
| Paragraph insertion | Track inserted text and paragraph marks |
|
|
152
|
+
| Lists | Track creation, membership, and level changes; configure newly proposed definitions |
|
|
153
|
+
| Tables | Track complete insertion, cell values, row additions, and partial row deletions |
|
|
154
|
+
| Content controls | Wrap nonempty ordinary text in `PlainText`, `RichText`, or `DatePicker` controls outside collaboration |
|
|
155
|
+
|
|
156
|
+
Tracked range edits refuse table and wrapper boundaries. Collaborative tracked range edits must remain within one paragraph. Targets that touch foreign pending revisions refuse. Continuation can extend the runtime author's text and paragraph proposals. Simple fields with nested fields or other result containers refuse tracked deletion and replacement. Direct result runs remain supported.
|
|
157
|
+
|
|
158
|
+
An author can configure a complete proposed table while it has no foreign revisions. Existing table properties and columns require permanent edits. Tracked table and cell value replacement refuse in collaboration. Row deletion suggestions must leave a row without a pending deletion. Pending row or cell structure revisions refuse tracked row deletion with `NotImplemented`.
|
|
159
|
+
|
|
160
|
+
Accept keeps a proposed content control. Reject restores the original formatted text. The author can set the pending control's `tag` and `title`. Empty ranges, existing review markup, and other control structure changes refuse.
|
|
161
|
+
|
|
162
|
+
Established list definitions and page setup refuse tracked writes. Comments and revision decisions remain available. Never silently fall back to `Off` when an edit cannot be tracked.
|
|
123
163
|
|
|
124
164
|
Standard `insertText('', 'Replace')` means deletion, and an empty insertion is a no-op. Agent tools should require nonempty insertion/replacement text and expose deletion as an explicit model decision. The shipped worker does this. The [compatibility manifest](https://github.com/eigenpal/docx-editor/blob/main/packages/editor-api/compat/manifest.json) records measured members and behavioral differences.
|
|
125
165
|
|
|
166
|
+
## Insert table rows
|
|
167
|
+
|
|
168
|
+
`TableRow.insertRows('Before', count, values)` and `'After'` support ordinary source rows beside unrelated merged headers. Merged source rows and crossing vertical merges refuse. Keep each row insertion as the only write in its sync. Sync before editing returned rows. For more information, see [Tables and cells](https://docx-editor.dev/docs/2.x/editor-api/tables).
|
|
169
|
+
|
|
126
170
|
## Pictures and page fields
|
|
127
171
|
|
|
128
172
|
Insert PNG or JPEG images with `range.insertInlinePictureFromBase64(data, 'After')`. Sync before setting properties on the returned picture. Width and height use points. New pictures lock the aspect ratio. Set `lockAspectRatio = false` before setting independent dimensions. Set `altTextDescription` to describe the image. Deletion preserves shared media relationships.
|
|
129
173
|
|
|
174
|
+
Use `range.insertField('Before', 'TOC', '\\o "1-3" \\h')` to insert an inert TOC instruction. This call saves no calculated entries. TOC evaluation and code writes refuse.
|
|
175
|
+
|
|
130
176
|
Insert a page field with `range.insertField('After', 'Page')` or `'NumPages'`. Sync before using the returned field. `field.code = 'NUMPAGES'` changes its instruction; `field.updateResult()` computes and stores its result. These calls use separate syncs. Field updates can share a sync with other field updates. They cannot share a sync with layout-changing writes.
|
|
131
177
|
|
|
132
178
|
Headless field calculation requires an explicit `pagination.measurer` when creating the server runtime. Use measurements from the document's fonts. Browser runtimes use the editor's measured layout. Without pagination, `updateResult()` fails with `NotSupported`. Other field instructions remain inert. The authoring subset refuses unsupported field codes and formatting switches.
|
|
@@ -134,3 +180,13 @@ Headless field calculation requires an explicit `pagination.measurer` when creat
|
|
|
134
180
|
Character formatting also supports underline, strikethrough, exact Word-palette highlighting, subscript, and superscript. `font.underline = 'None'` removes an underline. Setting one script mode to `true` clears the other mode. The highlight setter keeps Office's pinned `string` type, although Microsoft documents runtime `null` for clearing. The runtime accepts this clearing value. The runtime rejects unsupported highlight colors.
|
|
135
181
|
|
|
136
182
|
The workflow tests cover both hosts and save/reopen: `model-font-editing.test.ts`, `model-pictures.test.ts`, `model-fields.test.ts`, and `model-picture-field-parity.test.ts`. The final test includes primary footer creation and a saved `NUMPAGES` result.
|
|
183
|
+
|
|
184
|
+
## Set document metadata
|
|
185
|
+
|
|
186
|
+
Use `context.document.properties` for core metadata. The supported string properties are `author`, `title`, `subject`, `keywords`, `comments`, and `category`. Batch independent assignments, then call `context.sync()`. Load explicit property names before reading them. Metadata writes require tracking mode `Off`.
|
|
187
|
+
|
|
188
|
+
Do not substitute revision author settings for document author metadata. Other document information and custom properties remain unchanged.
|
|
189
|
+
|
|
190
|
+
Collaborative writes require an existing core-properties part. If the input omits this part, set properties before joining collaboration. Concurrent creation of this package part cannot merge safely.
|
|
191
|
+
|
|
192
|
+
Load `properties.lastAuthor` to read the last saved author. This property has no setter. To remove all standard property parts, call `document.removeDocumentInformation('DocumentProperties')`, then `context.sync()`. Run this command alone. It removes core, extended, and custom properties, including the last author. It preserves document text, comments, revisions, and media. It does not anonymize their content. Other removal modes, tracked removal, and removal during collaboration refuse with `NotSupported`.
|
package/dist/browser.d.mts
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
25
|
-
export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as
|
|
24
|
+
import { ad as RevisionTextView, H as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-Csjpe214.mjs';
|
|
25
|
+
export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentProperties, y as DocumentXmlLimits, z as DocumentZipLimits, E as DocxEditorError, F as DocxEditorErrorCode, G as DocxEditorErrorInit, I as EditorModule, J as Field, K as FieldCollection, L as FieldType, M as FieldTypeLiteral, N as Font, O as HeaderFooterType, P as InlinePicture, Q as InlinePictureCollection, R as InsertLocation, S as List, T as ListBullet, U as ListCollection, V as ListItem, W as ListNumbering, X as LoadOption, Y as LoadQueryOptions, Z as NoteItem, _ as NoteItemCollection, $ as NoteItemType, a0 as PageOrientation, a1 as PageSetup, a2 as Paragraph, a3 as ParagraphAlignment, a4 as ParagraphCollection, a5 as ParagraphInsertTextLocation, a6 as Range, a7 as RangeCollection, a8 as RangeInsertTextLocation, a9 as RemoveDocInfoType, aa as RequestContext, ab as Revision, ac as RevisionCollection, ae as RevisionType, af as RunCallback, ag as SearchOptions, ah as Section, ai as SectionCollection, aj as SelectionMode, ak as ServerPaginationOptions, al as Table, am as TableCell, an as TableCellCollection, ao as TableCollection, ap as TableRow, aq as TableRowCollection, ar as TrackedObjects, as as UnderlineType, at as VerticalAlignment, au as isDocxEditorError } from './server-Csjpe214.mjs';
|
|
26
26
|
import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
27
27
|
import { DocxEditorInstance } from '@docx-editor.dev/core/editor';
|
|
28
28
|
export { RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
|
|
@@ -116,4 +116,5 @@ interface DocxEditorNamespace {
|
|
|
116
116
|
*/
|
|
117
117
|
declare const DocxEditor: DocxEditorNamespace;
|
|
118
118
|
|
|
119
|
-
export {
|
|
119
|
+
export { CreateCollaborativeOptions, CreateServerOptions, DocxEditor, DocxEditorRuntime, DocxEditorServerRuntime, RevisionTextView };
|
|
120
|
+
export type { CreateBrowserOptions, DocxEditorNamespace };
|
package/dist/browser.d.ts
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
25
|
-
export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as
|
|
24
|
+
import { ad as RevisionTextView, H as DocxEditorRuntime, C as CreateServerOptions, D as DocxEditorServerRuntime, a as CreateCollaborativeOptions } from './server-Csjpe214.js';
|
|
25
|
+
export { A as Alignment, B as BesideLocation, b as Body, c as BodyInsertParagraphLocation, d as BodyInsertTextLocation, e as Bookmark, f as BookmarkCollection, g as BreakType, h as ChangeTrackingMode, i as ClientObject, j as ClientResult, k as Comment, l as CommentCollection, m as CommentReply, n as CommentReplyCollection, o as ContentControl, p as ContentControlCollection, q as ContentControlLockState, r as ContentControlSubtype, s as ContentControlType, t as ContentControlValue, u as Document, v as DocumentCapabilities, w as DocumentLimits, x as DocumentProperties, y as DocumentXmlLimits, z as DocumentZipLimits, E as DocxEditorError, F as DocxEditorErrorCode, G as DocxEditorErrorInit, I as EditorModule, J as Field, K as FieldCollection, L as FieldType, M as FieldTypeLiteral, N as Font, O as HeaderFooterType, P as InlinePicture, Q as InlinePictureCollection, R as InsertLocation, S as List, T as ListBullet, U as ListCollection, V as ListItem, W as ListNumbering, X as LoadOption, Y as LoadQueryOptions, Z as NoteItem, _ as NoteItemCollection, $ as NoteItemType, a0 as PageOrientation, a1 as PageSetup, a2 as Paragraph, a3 as ParagraphAlignment, a4 as ParagraphCollection, a5 as ParagraphInsertTextLocation, a6 as Range, a7 as RangeCollection, a8 as RangeInsertTextLocation, a9 as RemoveDocInfoType, aa as RequestContext, ab as Revision, ac as RevisionCollection, ae as RevisionType, af as RunCallback, ag as SearchOptions, ah as Section, ai as SectionCollection, aj as SelectionMode, ak as ServerPaginationOptions, al as Table, am as TableCell, an as TableCellCollection, ao as TableCollection, ap as TableRow, aq as TableRowCollection, ar as TrackedObjects, as as UnderlineType, at as VerticalAlignment, au as isDocxEditorError } from './server-Csjpe214.js';
|
|
26
26
|
import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
27
27
|
import { DocxEditorInstance } from '@docx-editor.dev/core/editor';
|
|
28
28
|
export { RevisionBatchEntry, RevisionBatchResult, RevisionBatchSkipReason } from '@docx-editor.dev/core/automation';
|
|
@@ -116,4 +116,5 @@ interface DocxEditorNamespace {
|
|
|
116
116
|
*/
|
|
117
117
|
declare const DocxEditor: DocxEditorNamespace;
|
|
118
118
|
|
|
119
|
-
export {
|
|
119
|
+
export { CreateCollaborativeOptions, CreateServerOptions, DocxEditor, DocxEditorRuntime, DocxEditorServerRuntime, RevisionTextView };
|
|
120
|
+
export type { CreateBrowserOptions, DocxEditorNamespace };
|