@betteroffice/docx 0.2.0 → 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 (69) hide show
  1. package/README.md +522 -3
  2. package/dist/{chunk-JHJLG4I6.mjs → chunk-5B4VMUXM.mjs} +1 -1
  3. package/dist/chunk-5JEQC76K.mjs +1 -0
  4. package/dist/chunk-7GJG6LLU.mjs +1 -0
  5. package/dist/chunk-FE6FWGBJ.mjs +1 -0
  6. package/dist/chunk-H5YYCN42.mjs +1 -0
  7. package/dist/chunk-NT2OYIJ4.mjs +57 -0
  8. package/dist/chunk-QE4ZDRKV.mjs +1 -0
  9. package/dist/chunk-VQXNED2P.mjs +2 -0
  10. package/dist/chunk-Z4HZIPBS.mjs +1 -0
  11. package/dist/collaboration/index.d.mts +8 -6
  12. package/dist/compareDocx-XXTZV4CG.mjs +1 -0
  13. package/dist/computeLayout-LWLAJWYA.mjs +1 -0
  14. package/dist/{content-CvEtPl0c.d.mts → content-BzoC6bSz.d.mts} +48 -8
  15. package/dist/core.d.mts +172 -9
  16. package/dist/core.mjs +1 -1
  17. package/dist/{displayListQueries-DF8F6fMl.d.mts → displayListQueries-BYFrBkw5.d.mts} +2 -2
  18. package/dist/docx/index.d.mts +5 -4
  19. package/dist/docx/index.mjs +1 -1
  20. package/dist/editor/index.d.mts +10 -8
  21. package/dist/editor/index.mjs +1 -1
  22. package/dist/{fontLoader-b8eicJKV.d.mts → fontLoader-CkXcPB1C.d.mts} +1 -1
  23. package/dist/{formatting-7zKCTu5a.d.mts → formatting-gqLFeJ9X.d.mts} +8 -0
  24. package/dist/{frameDelta-pA4jrQ1G.d.mts → frameDelta-CVt5FAXT.d.mts} +14 -3
  25. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  26. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  27. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  28. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  29. package/dist/{index-CHl2zLJ7.d.mts → index-BbZwdkPz.d.mts} +457 -29
  30. package/dist/layout/index.d.mts +6 -6
  31. package/dist/layout/index.mjs +1 -1
  32. package/dist/layout/pagination/index.d.mts +4 -4
  33. package/dist/layout/render/index.d.mts +12 -10
  34. package/dist/layout/render/index.mjs +1 -1
  35. package/dist/pagedExport-D3E4jZ-B.d.mts +907 -0
  36. package/dist/plugin-api/RenderedDomContext.d.mts +10 -9
  37. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  38. package/dist/plugin-api/index.d.mts +21 -4
  39. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  40. package/dist/rezip-Bxiq4Z_R.d.mts +24 -0
  41. package/dist/{rustDisplayList-BJqaN9tt.d.mts → rustDisplayList-CwOoUn3t.d.mts} +2 -2
  42. package/dist/{rustMeasureSource-C0EZB055.d.mts → rustMeasureSource-CyBMcy1x.d.mts} +12 -4
  43. package/dist/{selectiveSave-CRh-_Y_C.d.mts → selectiveSave-r-NMK6aI.d.mts} +1 -22
  44. package/dist/styles/index.d.mts +2 -2
  45. package/dist/{styles-7e-mq3c-.d.mts → styles-AryxLAhx.d.mts} +1 -1
  46. package/dist/types/content.d.mts +2 -2
  47. package/dist/types/document.d.mts +6 -6
  48. package/dist/{types-C4A8mWjU.d.mts → types-B4jD0rrc.d.mts} +19 -2
  49. package/dist/utils/comments.d.mts +2 -2
  50. package/dist/utils/index.d.mts +7 -4
  51. package/dist/utils/index.mjs +1 -1
  52. package/dist/utils/stylePreview.d.mts +2 -2
  53. package/dist/wasm-G62X4WRW.mjs +1 -0
  54. package/dist/wasm-US6R7SWN.mjs +1 -0
  55. package/dist/wasm-edit.d.mts +246 -13
  56. package/dist/wasm-edit.mjs +1 -1
  57. package/dist/wasm-layout.d.mts +8 -1
  58. package/dist/wasm-layout.mjs +1 -1
  59. package/dist/yrs/index.d.mts +7 -5
  60. package/dist/yrs/index.mjs +1 -1
  61. package/dist/yrs/residentEngineWorker.mjs +1 -1
  62. package/package.json +2 -2
  63. package/dist/chunk-6LQJAKOC.mjs +0 -1
  64. package/dist/chunk-AFMVSI4Z.mjs +0 -57
  65. package/dist/chunk-GD4VNJ64.mjs +0 -1
  66. package/dist/chunk-WRWRCBLK.mjs +0 -1
  67. package/dist/chunk-WTFRNX5K.mjs +0 -1
  68. package/dist/wasm-7SOSHNGP.mjs +0 -1
  69. package/dist/wasm-ZQAVP7P2.mjs +0 -1
package/dist/core.d.mts CHANGED
@@ -1,15 +1,18 @@
1
- export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from './selectiveSave-CRh-_Y_C.mjs';
1
+ export { a as attemptSelectiveSave, p as parseDocx } from './selectiveSave-r-NMK6aI.mjs';
2
2
  import { Document } from './types/document.mjs';
3
3
  export { DocxPackage } from './types/document.mjs';
4
- import { g as DocumentBody, f as SectionProperties, b4 as Table } from './content-CvEtPl0c.mjs';
5
- export { B as BlockContent, m as BookmarkEnd, n as BookmarkStart, e as Comment, J as CommentRangeEnd, K as CommentRangeStart, T as Deletion, j as Endnote, Y as Field, a1 as FooterReference, i as Footnote, H as HeaderFooter, a4 as HeaderReference, a6 as Hyperlink, a8 as Image, ak as Insertion, ao as ListLevel, ar as MoveFrom, au as MoveTo, h as NumberingDefinitions, P as Paragraph, aG as ParagraphContent, aK as Run, aL as RunContent, aV as Shape, b5 as TableCell, b8 as TableRow, bb as TextBox, bc as TextContent, be as TrackedChangeInfo, bf as TrackedRunChange } from './content-CvEtPl0c.mjs';
4
+ import { g as DocumentBody, f as SectionProperties, b4 as Table } from './content-BzoC6bSz.mjs';
5
+ export { B as BlockContent, m as BookmarkEnd, n as BookmarkStart, e as Comment, J as CommentRangeEnd, K as CommentRangeStart, T as Deletion, j as Endnote, Y as Field, a1 as FooterReference, i as Footnote, H as HeaderFooter, a4 as HeaderReference, a6 as Hyperlink, a8 as Image, ak as Insertion, ao as ListLevel, ar as MoveFrom, au as MoveTo, h as NumberingDefinitions, P as Paragraph, aG as ParagraphContent, aK as Run, aL as RunContent, aV as Shape, b5 as TableCell, b8 as TableRow, bb as TextBox, bc as TextContent, be as TrackedChangeInfo, bf as TrackedRunChange } from './content-BzoC6bSz.mjs';
6
+ export { c as createDocx, r as repackDocx, u as updateMultipleFiles } from './rezip-Bxiq4Z_R.mjs';
7
+ import { D as DocxExportFailure, a as DocxExportOptions, b as DocxMarkdownContent, c as DocxStructuredContent, d as DocxPageExportOptions, e as DocxHeadlessLayoutOptions, f as DocxPagedStructuredContent, g as DocxSnapshotLayoutMap, h as DocxMarkdownOptions, i as DocxLayoutMap, j as DocxPageMarkdownOptions, k as DocxContentControlReadFailure, l as DocxContentControlQuery, m as DocxContentControlsOptions, n as DocxContentControlsSnapshot } from './pagedExport-D3E4jZ-B.mjs';
8
+ export { o as DocxAnchor, p as DocxAnchorScope, q as DocxCachedResult, r as DocxCommentMetadata, s as DocxContentControl, t as DocxContentControlDiagnostic, u as DocxContentControlSelector, v as DocxContentControlValue, w as DocxContentControlsResult, x as DocxControlMetadata, y as DocxExportBlock, z as DocxExportCell, A as DocxExportDiagnostic, B as DocxExportDiagnosticCode, C as DocxExportFailureCode, E as DocxExportInline, F as DocxExportPage, G as DocxExportRefusal, H as DocxExportResult, I as DocxExportStory, J as DocxExportTable, K as DocxFormattingMark, L as DocxFragmentGeometry, M as DocxHeadingInfo, N as DocxHeadlessFont, O as DocxInlineRevision, P as DocxLayoutProvenance, Q as DocxListInfo, R as DocxPageDiagnostic, S as DocxPageFragment, T as DocxPageMapContent, U as DocxParagraphData, V as DocxParagraphHeading, W as DocxRevisionView, X as DocxSnapshotLayoutProvenance, Y as DocxStoryKind, Z as DocxStoryOccurrence, _ as DocxStorySelection, $ as DocxUnlocatedReason } from './pagedExport-D3E4jZ-B.mjs';
6
9
  export { emuToPixels, emuToTwips, formatPx, halfPointsToPixels, pixelsToEmu, pixelsToTwips, pointsToPixels, twipsToEmu, twipsToPixels } from './utils/units.mjs';
7
- export { T as ThemeMatrixCell, b as blendColors, c as canRenderFont, a as colorsEqual, d as createRgbColor, e as createThemeColor, f as darkenColor, g as ensureHexPrefix, h as generateThemeTintShadeMatrix, i as getContrastingColor, j as getLoadedFonts, k as getThemeTintShadeHex, l as isBlack, m as isFontLoaded, n as isFontsLoading, o as isGoogleFontsEnabled, p as isWhite, q as lightenColor, r as loadFont, s as loadFontFromBuffer, t as loadFonts, u as onFontsLoaded, v as parseColorString, w as preloadCommonFonts, x as resolveColor, y as resolveHighlightColor, z as resolveHighlightToCss, A as resolveShadingColor, B as setGoogleFontsEnabled } from './fontLoader-b8eicJKV.mjs';
10
+ export { T as ThemeMatrixCell, b as blendColors, c as canRenderFont, a as colorsEqual, d as createRgbColor, e as createThemeColor, f as darkenColor, g as ensureHexPrefix, h as generateThemeTintShadeMatrix, i as getContrastingColor, j as getLoadedFonts, k as getThemeTintShadeHex, l as isBlack, m as isFontLoaded, n as isFontsLoading, o as isGoogleFontsEnabled, p as isWhite, q as lightenColor, r as loadFont, s as loadFontFromBuffer, t as loadFonts, u as onFontsLoaded, v as parseColorString, w as preloadCommonFonts, x as resolveColor, y as resolveHighlightColor, z as resolveHighlightToCss, A as resolveShadingColor, B as setGoogleFontsEnabled } from './fontLoader-CkXcPB1C.mjs';
8
11
  export { D as DocxInput, t as toArrayBuffer } from './docxInput-DTbCa48g.mjs';
9
- export { EditorPluginCore, PanelConfig, PluginPanelProps, PositionCoordinates, RenderedDomContext } from './plugin-api/index.mjs';
10
- export { B as BlockExtent, F as FootnoteContent, L as Layout, b as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-C4A8mWjU.mjs';
11
- export { a as ParagraphFormatting, b as TextFormatting, f as Theme, x as ThemeColorScheme, z as ThemeFont, A as ThemeFontScheme } from './formatting-7zKCTu5a.mjs';
12
- export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-7e-mq3c-.mjs';
12
+ export { EditorPluginCore, PanelConfig, PluginPanelProps, PointPosition, PositionCoordinates, RenderedDomContext } from './plugin-api/index.mjs';
13
+ export { B as BlockExtent, F as FootnoteContent, L as Layout, b as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-B4jD0rrc.mjs';
14
+ export { a as ParagraphFormatting, b as TextFormatting, f as Theme, x as ThemeColorScheme, z as ThemeFont, A as ThemeFontScheme } from './formatting-gqLFeJ9X.mjs';
15
+ export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-AryxLAhx.mjs';
13
16
  import './docx/wrapTypes.mjs';
14
17
 
15
18
  /**
@@ -30,6 +33,166 @@ declare function serializeDocumentBody(body: DocumentBody): string;
30
33
  /** Serialize section properties. */
31
34
  declare function serializeSectionProperties(props: SectionProperties | undefined): string;
32
35
 
36
+ /**
37
+ * Headless structured export: DOCX bytes in, read-only structured content or Markdown out. The
38
+ * Rust engine does the reading and anchors address the returned snapshot only. Plain exports
39
+ * involve no session, editor, DOM or font; a paged export lays the bytes out in a private session
40
+ * with exactly the fonts it is given, in a font store no other session shares.
41
+ */
42
+
43
+ /** An export the engine refused as data: unusable options. */
44
+ declare class DocxExportError extends Error {
45
+ readonly failure: DocxExportFailure;
46
+ constructor(failure: DocxExportFailure);
47
+ }
48
+ /**
49
+ * Exports DOCX bytes as structured content. Throws {@link DocxExportError} for unusable options
50
+ * and an `Error` for bytes that are not a readable DOCX.
51
+ */
52
+ declare function exportDocxStructured(bytes: Uint8Array, options: DocxExportOptions): Promise<DocxStructuredContent>;
53
+ /** {@link exportDocxStructured} rendered as Markdown with source anchors. */
54
+ declare function exportDocxMarkdown(bytes: Uint8Array, options: DocxExportOptions): Promise<DocxMarkdownContent>;
55
+ /** Renders structured content (schema version 1) as Markdown. */
56
+ declare function renderDocxMarkdown(content: DocxStructuredContent, options?: DocxMarkdownOptions): Promise<DocxMarkdownContent>;
57
+ /**
58
+ * Exports DOCX bytes as structured content with a page map. A private session opens the bytes
59
+ * and lays every section, header, footer and note out with exactly `layout.fonts`, registered in
60
+ * a measurement font store of its own so no editor's fonts change, and exports from that one
61
+ * captured state. Anchors address the returned snapshot and the map is deterministic for the
62
+ * same bytes, fonts and options. Throws {@link DocxExportError} for a refusal, a `TypeError` for
63
+ * an unknown, repeated or undecodable font key and an `Error` for bytes that are not a readable
64
+ * DOCX or fonts the engine rejects.
65
+ */
66
+ declare function exportDocxStructuredWithPages(bytes: Uint8Array, options: DocxPageExportOptions, layout: DocxHeadlessLayoutOptions): Promise<DocxPagedStructuredContent<DocxSnapshotLayoutMap>>;
67
+ /**
68
+ * Renders a paged export as Markdown. With `pageMarkers`, each block marker is followed by
69
+ * `<!-- docx-pages: N=label ... -->`: the physical page indexes and percent-encoded displayed
70
+ * labels of every page showing the block. No page break is written into the text. Throws
71
+ * {@link DocxExportError} when the page map was not captured with the content.
72
+ */
73
+ declare function renderDocxMarkdownWithPages(content: DocxPagedStructuredContent<DocxLayoutMap | DocxSnapshotLayoutMap>, options?: DocxPageMarkdownOptions): Promise<DocxMarkdownContent>;
74
+
75
+ /**
76
+ * Compares the text of body paragraphs of unchanged structure in two DOCX packages into tracked
77
+ * changes; any other difference returns diagnostics, never a partial redline.
78
+ */
79
+ /** Bounds a comparison enforces. The defaults are the largest values allowed; callers may tighten them. */
80
+ interface DocxCompareLimits {
81
+ /** Bytes of each input package. Default 32 MiB. */
82
+ maxInputBytes: number;
83
+ /** Inflated bytes of each input package. Default 128 MiB. */
84
+ maxExpandedBytes: number;
85
+ /** Paragraphs of each input, every story counted. Default 10,000. */
86
+ maxParagraphs: number;
87
+ /** UTF-16 units of text in every story of both inputs combined. Default 1,048,576. */
88
+ maxTextUnits: number;
89
+ /** Paragraph-alignment table cells, cumulative. Default 250,000. */
90
+ maxAlignmentCells: number;
91
+ /** Text-diff table cells, cumulative, similarity checks included. Default 4,000,000. */
92
+ maxDiffCells: number;
93
+ /** Changes, which is also the number of batch steps. Default 128. */
94
+ maxChanges: number;
95
+ /** Diagnostics; one more ends inspection with `diagnostics-truncated`. Default 256. */
96
+ maxDiagnostics: number;
97
+ /** Bytes of the encoded editing state staged for the batch. Default 64 MiB. */
98
+ maxStagedBytes: number;
99
+ /** Bytes of the result as JSON, without the output package; at least 1,024. Default 8 MiB. */
100
+ maxResultBytes: number;
101
+ /** Bytes of the output package, the unchanged original included. Default 64 MiB. */
102
+ maxOutputBytes: number;
103
+ }
104
+ interface DocxCompareOptions {
105
+ /** The author of every revision. Must not be blank or contain control characters. */
106
+ author: string;
107
+ /** RFC 3339 timestamp with an explicit offset, recorded in UTC. The clock is never read. */
108
+ date: string;
109
+ /** Unicode words, keeping punctuation and whitespace tokens (default), or grapheme clusters. */
110
+ granularity?: 'word' | 'char';
111
+ /**
112
+ * `fail` (default) stops at the first blocking condition; `report` keeps inspecting and
113
+ * returns every diagnostic. Neither returns a document while a blocking condition exists.
114
+ */
115
+ unsupported?: 'fail' | 'report';
116
+ limits?: Partial<DocxCompareLimits>;
117
+ }
118
+ /**
119
+ * Half-open UTF-16 range in the projected text of one input's body paragraph (tabs are `\t`,
120
+ * other inline atoms one U+FFFC). `path` is the paragraph's element-child path from the root of
121
+ * `part`, whose SHA-256 is `partSha256`. Spans address the inputs, not the output.
122
+ */
123
+ interface DocxCompareTextSpan {
124
+ part: string;
125
+ partSha256: string;
126
+ path: number[];
127
+ start: number;
128
+ end: number;
129
+ text: string;
130
+ }
131
+ /**
132
+ * One tracked replacement, ordered by original then revised position. An insertion has an empty
133
+ * `original` span and a deletion an empty `revised` span. `id` (`change-0`, …) is local to this
134
+ * result: neither an OOXML revision id nor a durable anchor.
135
+ */
136
+ interface DocxComparedChange {
137
+ id: string;
138
+ kind: 'insertion' | 'deletion' | 'replacement';
139
+ original: DocxCompareTextSpan;
140
+ revised: DocxCompareTextSpan;
141
+ }
142
+ interface DocxCompareLocation {
143
+ input: 'original' | 'revised' | 'output';
144
+ part: string | null;
145
+ path: number[] | null;
146
+ start: number | null;
147
+ end: number | null;
148
+ }
149
+ type DocxCompareDiagnosticCode = 'invalid-options' | 'invalid-docx' | 'existing-revisions' | 'paragraph-insertion' | 'paragraph-deletion' | 'paragraph-move' | 'ambiguous-alignment' | 'table-change' | 'structure-change' | 'field-change' | 'object-change' | 'content-control-change' | 'formatting-change' | 'unsupported-content' | 'unsupported-formatting' | 'out-of-scope-change' | 'opaque-part-change' | 'provenance-unavailable' | 'ambiguous-identity' | 'metadata-difference' | 'limit-exceeded' | 'diagnostics-truncated' | 'batch-refused' | 'serialization-failed' | 'roundtrip-mismatch';
150
+ /** `error` diagnostics block the comparison; `info` and `warning` ones accompany a result. */
151
+ interface DocxCompareDiagnostic {
152
+ code: DocxCompareDiagnosticCode;
153
+ severity: 'info' | 'warning' | 'error';
154
+ message: string;
155
+ locations: DocxCompareLocation[];
156
+ }
157
+ /**
158
+ * A redline, or a refusal as data; with no differences `docx` is the original bytes. Malformed
159
+ * options and internal failures throw.
160
+ */
161
+ type DocxCompareResult = {
162
+ ok: true;
163
+ docx: Uint8Array;
164
+ changes: DocxComparedChange[];
165
+ diagnostics: DocxCompareDiagnostic[];
166
+ } | {
167
+ ok: false;
168
+ diagnostics: DocxCompareDiagnostic[];
169
+ };
170
+ /**
171
+ * Compares two DOCX packages and returns the original with the revised body text differences
172
+ * as tracked changes by `options.author` at `options.date`.
173
+ */
174
+ declare function compareDocx(original: Uint8Array, revised: Uint8Array, options: DocxCompareOptions): Promise<DocxCompareResult>;
175
+
176
+ /**
177
+ * Headless content-control discovery: DOCX bytes in, the document's content controls out. The Rust
178
+ * engine does the reading; no session, editor or DOM is involved, and control ids and anchors
179
+ * address the returned snapshot only.
180
+ */
181
+
182
+ /** A read the engine refused as data: unusable options or a limit. */
183
+ declare class DocxContentControlsError extends Error {
184
+ readonly failure: DocxContentControlReadFailure;
185
+ constructor(failure: DocxContentControlReadFailure);
186
+ }
187
+ /**
188
+ * Lists the content controls of DOCX bytes in document order. Throws
189
+ * {@link DocxContentControlsError} for unusable options or an exceeded limit and an `Error` for
190
+ * bytes that are not a readable DOCX.
191
+ */
192
+ declare function listDocxContentControls(bytes: Uint8Array, options?: DocxContentControlsOptions): Promise<DocxContentControlsSnapshot>;
193
+ /** The content controls of DOCX bytes that match `query` exactly; none or several. */
194
+ declare function findDocxContentControls(bytes: Uint8Array, query: DocxContentControlQuery, options?: DocxContentControlsOptions): Promise<DocxContentControlsSnapshot>;
195
+
33
196
  /**
34
197
  * Framework-agnostic print helpers shared by the React and Vue
35
198
  * adapters. Lifted from packages/docx-react/src/components/ui/PrintPreview.tsx
@@ -255,4 +418,4 @@ declare class ErrorManager extends Subscribable<ErrorManagerSnapshot> {
255
418
  */
256
419
  declare const VERSION: string;
257
420
 
258
- export { type CellCoordinates, Document, DocumentBody, ErrorManager, type ErrorManagerSnapshot, type ErrorNotification, type ErrorSeverity, type PrintOptions, SectionProperties, Subscribable, TABLE_DATA_ATTRIBUTES, Table, TableSelectionManager, type TableSelectionSnapshot, VERSION, deleteTableFromDocument, findTableFromClick, formatPageRange, getDefaultPrintOptions, getTableFromDocument, isPrintSupported, openPrintWindow, parsePageRange, serializeDocumentBody, serializeDocument as serializeDocx, serializeSectionProperties, triggerPrint, updateTableInDocument };
421
+ export { type CellCoordinates, Document, DocumentBody, type DocxCompareDiagnostic, type DocxCompareDiagnosticCode, type DocxCompareLimits, type DocxCompareLocation, type DocxCompareOptions, type DocxCompareResult, type DocxCompareTextSpan, type DocxComparedChange, DocxContentControlQuery, DocxContentControlReadFailure, DocxContentControlsError, DocxContentControlsOptions, DocxContentControlsSnapshot, DocxExportError, DocxExportFailure, DocxExportOptions, DocxHeadlessLayoutOptions, DocxLayoutMap, DocxMarkdownContent, DocxMarkdownOptions, DocxPageExportOptions, DocxPageMarkdownOptions, DocxPagedStructuredContent, DocxSnapshotLayoutMap, DocxStructuredContent, ErrorManager, type ErrorManagerSnapshot, type ErrorNotification, type ErrorSeverity, type PrintOptions, SectionProperties, Subscribable, TABLE_DATA_ATTRIBUTES, Table, TableSelectionManager, type TableSelectionSnapshot, VERSION, compareDocx, deleteTableFromDocument, exportDocxMarkdown, exportDocxStructured, exportDocxStructuredWithPages, findDocxContentControls, findTableFromClick, formatPageRange, getDefaultPrintOptions, getTableFromDocument, isPrintSupported, listDocxContentControls, openPrintWindow, parsePageRange, renderDocxMarkdown, renderDocxMarkdownWithPages, serializeDocumentBody, serializeDocument as serializeDocx, serializeSectionProperties, triggerPrint, updateTableInDocument };
package/dist/core.mjs CHANGED
@@ -1 +1 @@
1
- export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,g as updateMultipleFiles}from'./chunk-AFMVSI4Z.mjs';export{f as blendColors,r as colorsEqual,o as createRgbColor,n as createThemeColor,d as darkenColor,p as ensureHexPrefix,h as generateThemeTintShadeMatrix,c as getContrastingColor,g as getThemeTintShadeHex,k as isBlack,l as isWhite,e as lightenColor,m as parseColorString,a as resolveColor,i as resolveHighlightColor,q as resolveHighlightToCss,j as resolveShadingColor}from'./chunk-LTVVQMHB.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-CTBUQRYQ.mjs';export{n as canRenderFont,k as getLoadedFonts,g as isFontLoaded,j as isFontsLoading,i as isGoogleFontsEnabled,e as loadFont,o as loadFontFromBuffer,f as loadFonts,l as onFontsLoaded,v as preloadCommonFonts,h as setGoogleFontsEnabled,a as toArrayBuffer}from'./chunk-JHJLG4I6.mjs';import'./chunk-6LQJAKOC.mjs';import'./chunk-HLDJMU3R.mjs';import'./chunk-ACGKK7IB.mjs';import'./chunk-5F6DLQZP.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var g="0.2.0";var ct={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function ft(){return {...ct}}function gt(){typeof window<"u"&&window.print();}var yt="@media print { body { margin: 0; padding: 0; } @page { margin: 0; } }";function xt(e="Document",s){if(typeof window>"u")return null;let t=window.open("","_blank");if(!t)return null;t.opener=null;let i=t.document;i.title=e;let o=i.createElement("style");o.textContent=yt,i.head.appendChild(o);let n=new DOMParser().parseFromString(s,"text/html");for(let l of Array.from(n.body.childNodes))i.body.appendChild(i.importNode(l,true));return t}function ht(e,s){if(!e||!e.trim())return null;let t=e.trim();if(/^\d+$/.test(t)){let o=parseInt(t,10);return o>=1&&o<=s?{start:o,end:o}:null}let i=t.match(/^(\d+)-(\d+)$/);if(i){let o=parseInt(i[1],10),n=parseInt(i[2],10);if(o>=1&&n<=s&&o<=n)return {start:o,end:n}}return null}function bt(e,s){return e?e.start===e.end?`Page ${e.start}`:`Pages ${e.start}-${e.end}`:`All (${s} pages)`}function Tt(){return typeof window<"u"&&typeof window.print=="function"}var a=class{constructor(s){b$1(this,"listeners",new Set);b$1(this,"snapshot");b$1(this,"subscribe",s=>(this.listeners.add(s),()=>{this.listeners.delete(s);}));b$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=s;}setSnapshot(s){this.snapshot=s,this.notify();}notify(){for(let s of this.listeners)s();}};var m={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function y(e,s){if(!(e instanceof Element))return null;let t=e;for(;t&&t!==s;){if(t.tagName==="TD"||t.tagName==="TH"){let i=t.getAttribute(m.ROW_INDEX),o=t.getAttribute(m.COLUMN_INDEX);if(i!==null&&o!==null){let n=t;for(;n&&n!==s;){if(n.tagName==="TABLE"){let l=n.getAttribute(m.TABLE_INDEX);if(l!==null)return {tableIndex:parseInt(l,10),rowIndex:parseInt(i,10),columnIndex:parseInt(o,10)};break}n=n.parentElement;}}break}t=t.parentElement;}return null}function x(e,s){if(!e.package?.document?.content)return null;let t=0;for(let i of e.package.document.content)if(i.type==="table"){if(t===s)return i;t++;}return null}function h(e,s,t){if(!e.package?.document?.content)return e;let i=0,o=e.package.document.content.map(n=>{if(n.type==="table"){if(i===s)return i++,t;i++;}return n});return {...e,package:{...e.package,document:{...e.package.document,content:o}}}}function b(e,s){if(!e.package?.document?.content)return e;let t=0,i=e.package.document.content.filter(o=>{if(o.type==="table"){let n=t===s;return t++,!n}return true});return {...e,package:{...e.package,document:{...e.package.document,content:i}}}}var u=class extends a{constructor(){super({selectedCell:null});}selectCell(s){this.setSnapshot({selectedCell:s});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(s,t,i){let{selectedCell:o}=this.getSnapshot();return o?o.tableIndex===s&&o.rowIndex===t&&o.columnIndex===i:false}getSelectedCell(){return this.getSnapshot().selectedCell}};var c=class extends a{constructor(){super({notifications:[]});b$1(this,"notifications",[]);b$1(this,"idCounter",0);b$1(this,"timers",new Set);}showError(t,i){return this.addNotification(t,"error",i)}showWarning(t,i){return this.addNotification(t,"warning",i)}showInfo(t,i){return this.addNotification(t,"info",i)}dismiss(t){this.notifications=this.notifications.map(o=>o.id===t?{...o,dismissed:true}:o),this.emitSnapshot();let i=setTimeout(()=>{this.timers.delete(i),this.notifications=this.notifications.filter(o=>o.id!==t),this.emitSnapshot();},300);this.timers.add(i);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,i,o){let n=`error-${++this.idCounter}-${Date.now()}`,l={id:n,message:t,severity:i,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,l],this.emitSnapshot(),i!=="error"){let f=setTimeout(()=>{this.timers.delete(f),this.dismiss(n);},5e3);this.timers.add(f);}return n}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var Wt=g;export{c as ErrorManager,a as Subscribable,m as TABLE_DATA_ATTRIBUTES,u as TableSelectionManager,Wt as VERSION,b as deleteTableFromDocument,y as findTableFromClick,bt as formatPageRange,ft as getDefaultPrintOptions,x as getTableFromDocument,Tt as isPrintSupported,xt as openPrintWindow,ht as parsePageRange,gt as triggerPrint,h as updateTableInDocument};
1
+ export{h as attemptSelectiveSave,g as createDocx,a as parseDocx,e as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,f as updateMultipleFiles}from'./chunk-NT2OYIJ4.mjs';import'./chunk-VQXNED2P.mjs';export{f as blendColors,r as colorsEqual,o as createRgbColor,n as createThemeColor,d as darkenColor,p as ensureHexPrefix,h as generateThemeTintShadeMatrix,c as getContrastingColor,g as getThemeTintShadeHex,k as isBlack,l as isWhite,e as lightenColor,m as parseColorString,a as resolveColor,i as resolveHighlightColor,q as resolveHighlightToCss,j as resolveShadingColor}from'./chunk-LTVVQMHB.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-CTBUQRYQ.mjs';export{n as canRenderFont,k as getLoadedFonts,g as isFontLoaded,j as isFontsLoading,i as isGoogleFontsEnabled,e as loadFont,o as loadFontFromBuffer,f as loadFonts,l as onFontsLoaded,v as preloadCommonFonts,h as setGoogleFontsEnabled,a as toArrayBuffer}from'./chunk-5B4VMUXM.mjs';import'./chunk-QE4ZDRKV.mjs';import'./chunk-HLDJMU3R.mjs';import'./chunk-ACGKK7IB.mjs';import'./chunk-5F6DLQZP.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var v="0.3.0";var f=class extends Error{constructor(t){super(t.message);b$1(this,"failure");this.name="DocxExportError",this.failure=t;}};async function g(){let e=await import('./wasm-edit.mjs');return await e.preloadEditWasm(),e}function D(e){let o=JSON.parse(e);if(!o.ok)throw new f(o.failure);return o.content}async function Rt(e,o){let t=await g();return D(t.exportDocxStructuredJson(e,JSON.stringify(o)))}async function It(e,o){let t=await g();return D(t.exportDocxMarkdownJson(e,JSON.stringify(o)))}async function Ft(e,o={}){let t=await g();return D(t.renderDocxMarkdownJson(JSON.stringify(e),JSON.stringify(o)))}function Nt(e,o){let t={};for(let[n,r]of Object.entries(e.package.theme?.colorScheme??{}))typeof r=="string"&&(t[n]=r);return {themeColors:t,defaultTabStopTwips:o?.defaultTabStopTwips??e.package.settings?.defaultTabStop??null,numericIds:{},showHiddenText:o?.showHiddenText??false}}function At(e){let o;try{o=atob(e.data);}catch{throw new TypeError(`font ${JSON.stringify(e.key)} is not base64`)}let t=new Uint8Array(o.length);for(let n=0;n<o.length;n+=1)t[n]=o.charCodeAt(n);return t}async function Lt(e,o,t){await g();let[{createYrsSession:n},{buildResidentRegionLayoutRequest:r}]=await Promise.all([import('./yrs/index.mjs'),import('./computeLayout-LWLAJWYA.mjs')]),i=new Map,a=t.fonts.map((l,p)=>{if(i.has(l.key))throw new TypeError(`font key ${JSON.stringify(l.key)} is repeated`);return i.set(l.key,p),At(l)}),h=l=>l.map(p=>{let x=i.get(p);if(x===void 0)throw new TypeError(`font key ${JSON.stringify(p)} is not a font`);return x}),C=await n({clientId:1});try{let{document:l}=C.openDocx(e,!0),p=r(l,0,Nt(l,t.renderEnvironment)),x=l.package.settings?.compatibilityFlags,E={};p.measurement={fontChains:E,defaults:{fontSize:t.measurementDefaults?.fontSize??11,fontFamily:t.measurementDefaults?.fontFamily??"Calibri"},compat:{noLeading:t.compatibility?.noLeading??x?.noLeading??!1,doNotExpandShiftReturn:t.compatibility?.doNotExpandShiftReturn??x?.doNotExpandShiftReturn??!1},authoritativeShaping:!0};let L=JSON.parse(C.layoutFontRequirementsJson(JSON.stringify(p)));for(let d of L)E[d.key]=h(t.fontChains?.[d.key]??t.fontChains?.[d.family.toLowerCase()]??t.defaultChain);let P=new Uint8Array(a.reduce((d,M)=>d+M.length,0)),k=0;for(let d of a)P.set(d,k),k+=d.length;let T=C.exportSnapshotWithPrivateFonts(P,Uint32Array.from(a,d=>d.length),JSON.stringify(p),o);if(!T.ok)throw new f(T.failure);return T.content}finally{C.destroy();}}async function Mt(e,o={}){let t=await g();return D(t.renderDocxMarkdownWithPagesJson(JSON.stringify(e),JSON.stringify(o)))}async function jt(e,o,t){let{compareDocxInSession:n}=await import('./compareDocx-XXTZV4CG.mjs');return n(e,o,t)}var b=class extends Error{constructor(t){super(t.message);b$1(this,"failure");this.name="DocxContentControlsError",this.failure=t;}};async function O(){let e=await import('./wasm-edit.mjs');return await e.preloadEditWasm(),e}function R(e){let o=JSON.parse(e);if(!o.ok)throw new b(o.failure);return o.content}async function Bt(e,o={}){let t=await O();return R(t.listDocxContentControlsJson(e,JSON.stringify(o)))}async function Jt(e,o,t={}){let n=await O();return R(n.findDocxContentControlsJson(e,JSON.stringify(o),JSON.stringify(t)))}var Ut={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function Ht(){return {...Ut}}function Wt(){typeof window<"u"&&window.print();}var _t="@media print { body { margin: 0; padding: 0; } @page { margin: 0; } }";function $t(e="Document",o){if(typeof window>"u")return null;let t=window.open("","_blank");if(!t)return null;t.opener=null;let n=t.document;n.title=e;let r=n.createElement("style");r.textContent=_t,n.head.appendChild(r);let i=new DOMParser().parseFromString(o,"text/html");for(let a of Array.from(i.body.childNodes))n.body.appendChild(n.importNode(a,true));return t}function Xt(e,o){if(!e||!e.trim())return null;let t=e.trim();if(/^\d+$/.test(t)){let r=parseInt(t,10);return r>=1&&r<=o?{start:r,end:r}:null}let n=t.match(/^(\d+)-(\d+)$/);if(n){let r=parseInt(n[1],10),i=parseInt(n[2],10);if(r>=1&&i<=o&&r<=i)return {start:r,end:i}}return null}function zt(e,o){return e?e.start===e.end?`Page ${e.start}`:`Pages ${e.start}-${e.end}`:`All (${o} pages)`}function Vt(){return typeof window<"u"&&typeof window.print=="function"}var m=class{constructor(o){b$1(this,"listeners",new Set);b$1(this,"snapshot");b$1(this,"subscribe",o=>(this.listeners.add(o),()=>{this.listeners.delete(o);}));b$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=o;}setSnapshot(o){this.snapshot=o,this.notify();}notify(){for(let o of this.listeners)o();}};var y={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function I(e,o){if(!(e instanceof Element))return null;let t=e;for(;t&&t!==o;){if(t.tagName==="TD"||t.tagName==="TH"){let n=t.getAttribute(y.ROW_INDEX),r=t.getAttribute(y.COLUMN_INDEX);if(n!==null&&r!==null){let i=t;for(;i&&i!==o;){if(i.tagName==="TABLE"){let a=i.getAttribute(y.TABLE_INDEX);if(a!==null)return {tableIndex:parseInt(a,10),rowIndex:parseInt(n,10),columnIndex:parseInt(r,10)};break}i=i.parentElement;}}break}t=t.parentElement;}return null}function F(e,o){if(!e.package?.document?.content)return null;let t=0;for(let n of e.package.document.content)if(n.type==="table"){if(t===o)return n;t++;}return null}function N(e,o,t){if(!e.package?.document?.content)return e;let n=0,r=e.package.document.content.map(i=>{if(i.type==="table"){if(n===o)return n++,t;n++;}return i});return {...e,package:{...e.package,document:{...e.package.document,content:r}}}}function A(e,o){if(!e.package?.document?.content)return e;let t=0,n=e.package.document.content.filter(r=>{if(r.type==="table"){let i=t===o;return t++,!i}return true});return {...e,package:{...e.package,document:{...e.package.document,content:n}}}}var S=class extends m{constructor(){super({selectedCell:null});}selectCell(o){this.setSnapshot({selectedCell:o});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(o,t,n){let{selectedCell:r}=this.getSnapshot();return r?r.tableIndex===o&&r.rowIndex===t&&r.columnIndex===n:false}getSelectedCell(){return this.getSnapshot().selectedCell}};var w=class extends m{constructor(){super({notifications:[]});b$1(this,"notifications",[]);b$1(this,"idCounter",0);b$1(this,"timers",new Set);}showError(t,n){return this.addNotification(t,"error",n)}showWarning(t,n){return this.addNotification(t,"warning",n)}showInfo(t,n){return this.addNotification(t,"info",n)}dismiss(t){this.notifications=this.notifications.map(r=>r.id===t?{...r,dismissed:true}:r),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(r=>r.id!==t),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,n,r){let i=`error-${++this.idCounter}-${Date.now()}`,a={id:i,message:t,severity:n,details:r,timestamp:Date.now()};if(this.notifications=[...this.notifications,a],this.emitSnapshot(),n!=="error"){let h=setTimeout(()=>{this.timers.delete(h),this.dismiss(i);},5e3);this.timers.add(h);}return i}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var Se=v;export{b as DocxContentControlsError,f as DocxExportError,w as ErrorManager,m as Subscribable,y as TABLE_DATA_ATTRIBUTES,S as TableSelectionManager,Se as VERSION,jt as compareDocx,A as deleteTableFromDocument,It as exportDocxMarkdown,Rt as exportDocxStructured,Lt as exportDocxStructuredWithPages,Jt as findDocxContentControls,I as findTableFromClick,zt as formatPageRange,Ht as getDefaultPrintOptions,F as getTableFromDocument,Vt as isPrintSupported,Bt as listDocxContentControls,$t as openPrintWindow,Xt as parsePageRange,Ft as renderDocxMarkdown,Mt as renderDocxMarkdownWithPages,Wt as triggerPrint,N as updateTableInDocument};
@@ -1,5 +1,5 @@
1
- import { I as ImagePrimitive, D as DisplayList } from './frameDelta-pA4jrQ1G.mjs';
2
- import { R as RustDisplayListQueryEngine } from './rustDisplayList-BJqaN9tt.mjs';
1
+ import { I as ImagePrimitive, D as DisplayList } from './frameDelta-CVt5FAXT.mjs';
2
+ import { R as RustDisplayListQueryEngine } from './rustDisplayList-CwOoUn3t.mjs';
3
3
 
4
4
  /**
5
5
  * Locate an image primitive in a built DisplayList by its document position.
@@ -1,10 +1,11 @@
1
- export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from '../selectiveSave-CRh-_Y_C.mjs';
1
+ export { a as attemptSelectiveSave, p as parseDocx } from '../selectiveSave-r-NMK6aI.mjs';
2
+ export { c as createDocx, r as repackDocx, u as updateMultipleFiles } from '../rezip-Bxiq4Z_R.mjs';
2
3
  import { WrapType } from './wrapTypes.mjs';
3
- import { B as BlockContent, e as Comment, W as Watermark } from '../content-CvEtPl0c.mjs';
4
+ import { B as BlockContent, e as Comment, W as Watermark } from '../content-BzoC6bSz.mjs';
4
5
  import { Document } from '../types/document.mjs';
5
6
  import '../docxInput-DTbCa48g.mjs';
6
- import '../formatting-7zKCTu5a.mjs';
7
- import '../styles-7e-mq3c-.mjs';
7
+ import '../formatting-gqLFeJ9X.mjs';
8
+ import '../styles-AryxLAhx.mjs';
8
9
 
9
10
  type AnchorWrapType = Exclude<WrapType, 'inline'>;
10
11
  type ImageLayoutTarget = AnchorWrapType | 'squareLeft' | 'squareRight' | 'inline';
@@ -1,2 +1,2 @@
1
- import {e}from'../chunk-AFMVSI4Z.mjs';export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,g as updateMultipleFiles}from'../chunk-AFMVSI4Z.mjs';import'../chunk-JHJLG4I6.mjs';import'../chunk-6LQJAKOC.mjs';import'../chunk-HLDJMU3R.mjs';import'../chunk-ACGKK7IB.mjs';import'../chunk-5F6DLQZP.mjs';import'../chunk-TTRUPDAB.mjs';function E(e,t,o,r,i,p){let a=e.includes("w")||e.includes("e"),s=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,l=e.includes("n")?-1:1,m=a?r+t*u:r,f=s?i+o*l:i;if(a&&s&&p){let g=Math.max(m/r,f/i);m=r*g,f=i*g;}let d=g=>Math.max(20,Math.min(2e3,g));return {width:a?d(m):r,height:s?d(f):i}}function q(e,t,o){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:o?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:o.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:o.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let i=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let i=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function W(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var _=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function B(e,t){return true}function z(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}function K(e,t){let o=t.filter(p=>p.parentId!=null);if(o.length===0)return;let r=new Map;for(let p of o){let a=r.get(p.parentId);a?a.push(p.id):r.set(p.parentId,[p.id]);}function i(p){for(let a of p)if(a.type==="paragraph"){if(!a.content.some(u=>u.type==="commentRangeStart"||u.type==="commentRangeEnd"))continue;let s=[];for(let u of a.content)if(u.type==="commentRangeStart"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeStart",id:m});}else if(u.type==="commentRangeEnd"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeEnd",id:m});}else s.push(u);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let u of s.cells)i(u.content);}i(e);}function X(e,t){let o=new Set(t.map(a=>a.id)),r=t.filter(a=>a.parentId!=null&&!o.has(a.parentId));if(r.length===0)return;let i=new Map;for(let a of r){let s=i.get(a.parentId);s?s.push(a.id):i.set(a.parentId,[a.id]);}function p(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(f=>(f.type==="insertion"||f.type==="deletion")&&i.has(f.info.id)))continue;let l=[],m=s.content;for(let f=0;f<m.length;f++){let d=m[f];if((d.type==="insertion"||d.type==="deletion")&&i.has(d.info.id)){let g=i.get(d.info.id);for(let y of g)l.push({type:"commentRangeStart",id:y});l.push(d);let h=m[f+1];h&&(h.type==="insertion"||h.type==="deletion")&&h.type!==d.type&&h.info.author===d.info.author&&h.info.date===d.info.date&&(l.push(h),f++);for(let y of g)l.push({type:"commentRangeEnd",id:y});}else l.push(d);}s.content=l;}else if(s.type==="table")for(let u of s.rows)for(let l of u.cells)p(l.content);}p(e);}function $(e){let t=e?.package.headers;if(t){for(let o of t.values())if(o.watermark)return o.watermark}}function G(e){let t=e.package.headers;if(!t||t.size===0)return e;let o=false,r=new Map;for(let[i,p]of t)if(p.watermark){let{watermark:a,...s}=p;r.set(i,s),o=true;}else r.set(i,p);return o?{...e,package:{...e.package,headers:r}}:e}function N(e,t){let o=e.package.headers;if(!o||o.size===0)return e;let r=new Map;for(let[i,p]of o)r.set(i,{...p,watermark:{...t}});return {...e,package:{...e.package,headers:r}}}function j(e){let t=e.package.document,o=[];if(t.sections)for(let r of t.sections)r.properties&&o.push(r.properties);return t.finalSectionProperties&&o.push(t.finalSectionProperties),o}function U(e$1,t){let o=e$1.package,r=o.document,i=o.headers,p=j(e$1),a=new Set;if(i)for(let n of i.values())a.add(n.hdrFtrType);let s=!i||i.size===0,u=p.some(n=>n.titlePg),l=p.some(n=>n.evenAndOddHeaders),m=s,f=u&&!a.has("first"),d=l&&!a.has("even");if(!m&&!f&&!d)return e$1;let g=o.relationships?new Map(o.relationships):new Map,h=new Map(i??[]),y=new Set;for(let n of g.values())n.target&&y.add(n.target.replace(/^\/?word\//,"").toLowerCase());function P(){let n=1;for(;y.has(`header${n}.xml`);)n++;let c=`header${n}.xml`;return y.add(c.toLowerCase()),c}function v(n){let c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}`,I=1;for(;g.has(c);)c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}${I++}`;return g.set(c,{id:c,type:e.header,target:P()}),h.set(c,{type:"header",hdrFtrType:n,content:[],watermark:{...t}}),c}let T={};function F(n){return T[n]??(T[n]=v(n))}function L(n,c){let I=n?.headerReferences?[...n.headerReferences]:[];return I.some(S=>S.type===c)?n??{}:(I.push({type:c,rId:F(c)}),{...n??{},headerReferences:I})}function w(n){let c=n;return m&&(c=L(c,"default")),f&&c?.titlePg&&(c=L(c,"first")),d&&c?.evenAndOddHeaders&&(c=L(c,"even")),c}let M=w(r.finalSectionProperties),k=r.sections?.map(n=>({...n,properties:w(n.properties)??n.properties}));return {...e$1,package:{...o,relationships:g,headers:h,document:{...r,finalSectionProperties:M,...k?{sections:k}:{}}}}}function Y(e,t){if(!t)return G(e);let o=N(e,t);return U(o,t)}
1
+ export{h as attemptSelectiveSave,g as createDocx,a as parseDocx,e as repackDocx,f as updateMultipleFiles}from'../chunk-NT2OYIJ4.mjs';import {a}from'../chunk-VQXNED2P.mjs';import'../chunk-5B4VMUXM.mjs';import'../chunk-QE4ZDRKV.mjs';import'../chunk-HLDJMU3R.mjs';import'../chunk-ACGKK7IB.mjs';import'../chunk-5F6DLQZP.mjs';import'../chunk-TTRUPDAB.mjs';function E(e,t,o,r,i,p){let a=e.includes("w")||e.includes("e"),s=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,l=e.includes("n")?-1:1,m=a?r+t*u:r,f=s?i+o*l:i;if(a&&s&&p){let g=Math.max(m/r,f/i);m=r*g,f=i*g;}let d=g=>Math.max(20,Math.min(2e3,g));return {width:a?d(m):r,height:s?d(f):i}}function q(e,t,o){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:o?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:o.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:o.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let i=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let i=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:i,wrapText:i==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function W(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var _=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function B(e,t){return true}function z(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}function K(e,t){let o=t.filter(p=>p.parentId!=null);if(o.length===0)return;let r=new Map;for(let p of o){let a=r.get(p.parentId);a?a.push(p.id):r.set(p.parentId,[p.id]);}function i(p){for(let a of p)if(a.type==="paragraph"){if(!a.content.some(u=>u.type==="commentRangeStart"||u.type==="commentRangeEnd"))continue;let s=[];for(let u of a.content)if(u.type==="commentRangeStart"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeStart",id:m});}else if(u.type==="commentRangeEnd"){s.push(u);let l=r.get(u.id);if(l)for(let m of l)s.push({type:"commentRangeEnd",id:m});}else s.push(u);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let u of s.cells)i(u.content);}i(e);}function X(e,t){let o=new Set(t.map(a=>a.id)),r=t.filter(a=>a.parentId!=null&&!o.has(a.parentId));if(r.length===0)return;let i=new Map;for(let a of r){let s=i.get(a.parentId);s?s.push(a.id):i.set(a.parentId,[a.id]);}function p(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(f=>(f.type==="insertion"||f.type==="deletion")&&i.has(f.info.id)))continue;let l=[],m=s.content;for(let f=0;f<m.length;f++){let d=m[f];if((d.type==="insertion"||d.type==="deletion")&&i.has(d.info.id)){let g=i.get(d.info.id);for(let y of g)l.push({type:"commentRangeStart",id:y});l.push(d);let h=m[f+1];h&&(h.type==="insertion"||h.type==="deletion")&&h.type!==d.type&&h.info.author===d.info.author&&h.info.date===d.info.date&&(l.push(h),f++);for(let y of g)l.push({type:"commentRangeEnd",id:y});}else l.push(d);}s.content=l;}else if(s.type==="table")for(let u of s.rows)for(let l of u.cells)p(l.content);}p(e);}function $(e){let t=e?.package.headers;if(t){for(let o of t.values())if(o.watermark)return o.watermark}}function G(e){let t=e.package.headers;if(!t||t.size===0)return e;let o=false,r=new Map;for(let[i,p]of t)if(p.watermark){let{watermark:a,...s}=p;r.set(i,s),o=true;}else r.set(i,p);return o?{...e,package:{...e.package,headers:r}}:e}function N(e,t){let o=e.package.headers;if(!o||o.size===0)return e;let r=new Map;for(let[i,p]of o)r.set(i,{...p,watermark:{...t}});return {...e,package:{...e.package,headers:r}}}function j(e){let t=e.package.document,o=[];if(t.sections)for(let r of t.sections)r.properties&&o.push(r.properties);return t.finalSectionProperties&&o.push(t.finalSectionProperties),o}function U(e,t){let o=e.package,r=o.document,i=o.headers,p=j(e),a$1=new Set;if(i)for(let n of i.values())a$1.add(n.hdrFtrType);let s=!i||i.size===0,u=p.some(n=>n.titlePg),l=p.some(n=>n.evenAndOddHeaders),m=s,f=u&&!a$1.has("first"),d=l&&!a$1.has("even");if(!m&&!f&&!d)return e;let g=o.relationships?new Map(o.relationships):new Map,h=new Map(i??[]),y=new Set;for(let n of g.values())n.target&&y.add(n.target.replace(/^\/?word\//,"").toLowerCase());function P(){let n=1;for(;y.has(`header${n}.xml`);)n++;let c=`header${n}.xml`;return y.add(c.toLowerCase()),c}function v(n){let c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}`,I=1;for(;g.has(c);)c=`rIdWmHdr${n[0].toUpperCase()}${n.slice(1)}${I++}`;return g.set(c,{id:c,type:a.header,target:P()}),h.set(c,{type:"header",hdrFtrType:n,content:[],watermark:{...t}}),c}let T={};function F(n){return T[n]??(T[n]=v(n))}function L(n,c){let I=n?.headerReferences?[...n.headerReferences]:[];return I.some(S=>S.type===c)?n??{}:(I.push({type:c,rId:F(c)}),{...n??{},headerReferences:I})}function w(n){let c=n;return m&&(c=L(c,"default")),f&&c?.titlePg&&(c=L(c,"first")),d&&c?.evenAndOddHeaders&&(c=L(c,"even")),c}let M=w(r.finalSectionProperties),k=r.sections?.map(n=>({...n,properties:w(n.properties)??n.properties}));return {...e,package:{...o,relationships:g,headers:h,document:{...r,finalSectionProperties:M,...k?{sections:k}:{}}}}}function Y(e,t){if(!t)return G(e);let o=N(e,t);return U(o,t)}
2
2
  export{_ as IMAGE_LAYOUT_OPTIONS,E as calculateResizedImageDimensions,W as deriveLayoutChoice,$ as getDocumentWatermark,K as injectReplyRangeMarkers,X as injectTCReplyRangeMarkers,B as isImageLayoutOptionEnabled,q as resolveImageLayoutAttrs,Y as setDocumentWatermark,z as toolbarValueToLayoutTarget};
@@ -1,13 +1,15 @@
1
- import { R as ResidentMeasurementConfig } from '../rustMeasureSource-C0EZB055.mjs';
2
- import { L as Layout, a as LayoutOptions } from '../types-C4A8mWjU.mjs';
1
+ import { R as ResidentMeasurementConfig } from '../rustMeasureSource-CyBMcy1x.mjs';
2
+ import { L as Layout, a as LayoutOptions } from '../types-B4jD0rrc.mjs';
3
3
  import { MeasuredBlock } from '../layout/pagination/index.mjs';
4
- import { D as DisplayListHeadersFooters } from '../rustDisplayList-BJqaN9tt.mjs';
4
+ import { D as DisplayListHeadersFooters } from '../rustDisplayList-CwOoUn3t.mjs';
5
5
  import { Document } from '../types/document.mjs';
6
- import { Y as YrsSession, a as YrsRenderEnv } from '../index-CHl2zLJ7.mjs';
7
- import { f as SectionProperties, N as NoteKind, g as DocumentBody } from '../content-CvEtPl0c.mjs';
8
- import '../formatting-7zKCTu5a.mjs';
9
- import '../frameDelta-pA4jrQ1G.mjs';
10
- import '../styles-7e-mq3c-.mjs';
6
+ import { Y as YrsSession, a as YrsRenderEnv } from '../index-BbZwdkPz.mjs';
7
+ import { f as SectionProperties, N as NoteKind, g as DocumentBody } from '../content-BzoC6bSz.mjs';
8
+ import '../formatting-gqLFeJ9X.mjs';
9
+ import '../frameDelta-CVt5FAXT.mjs';
10
+ import '../styles-AryxLAhx.mjs';
11
+ import '../pagedExport-D3E4jZ-B.mjs';
12
+ import '../rezip-Bxiq4Z_R.mjs';
11
13
  import '../docx/wrapTypes.mjs';
12
14
 
13
15
  interface ResidentRegionLayoutRequest {
@@ -1 +1 @@
1
- import'../chunk-TTRUPDAB.mjs';function i(e){return e?.sections?.at(-1)?.properties??e?.finalSectionProperties}function l(e,r){let n=e.sections?.map((t,o,s)=>o===s.length-1?{...t,properties:r(t.properties)}:t);return {...e,...n?{sections:n}:{},finalSectionProperties:r(e.finalSectionProperties??{})}}var d=new WeakMap;function y(e){let r=e?.package.document;if(!r)return [{properties:{}}];let n=(r.sections??[]).map(t=>({sectionId:t.id??t.properties.sectionId,properties:t.properties}));return n.push({sectionId:n.at(-1)?.sectionId??r.finalSectionProperties?.sectionId,properties:i(r)??{}}),n}function c(e,r,n){let t=[];for(let o of e?.package.footnotes??[])o.noteType&&o.noteType!=="normal"||t.push({id:o.id,noteKind:"footnote",height:0});for(let o of e?.package.endnotes??[])o.noteType&&o.noteType!=="normal"||t.push({id:o.id,noteKind:"endnote",height:0});return {bodyStory:"body",options:{contractVersion:e?.package.contractVersion,pageGap:r},regions:{sections:y(e),settings:e?.package.settings,watermark:i(e?.package.document)?.watermark},notes:{contents:t},renderEnv:{...n,...m(e,n),tocStyleIds:[...new Set([...n.tocStyleIds??[],...(e?.package.styles?.styles??[]).filter(o=>o.type==="paragraph"&&typeof o.styleId=="string"&&o.styleId&&[o.styleId,o.name].some(s=>/^TOC\s*\d+$/i.test(s??""))).map(o=>o.styleId)])]}}}function m(e,r){if(r.defaultParagraphStyleId)return {};let n=e?.package.styles?.styles??[],t=n.find(s=>s.type==="paragraph"&&s.default&&s.styleId)?.styleId;return t?{defaultParagraphStyleId:t}:n.some(s=>s.type==="paragraph"&&s.styleId==="Normal")?{defaultParagraphStyleId:"Normal"}:{}}function g(e){return d.get(e)}function f(e){let r=c(e.document,e.pageGap,e.renderEnv);r.measurement=e.measurement;let n=e.session,t=JSON.parse(n.layoutDocumentWithRegionsRetainedJson(JSON.stringify(r))),o=n.residentWorkerProbe().layoutRevision,s=null,a=()=>s??(s=JSON.parse(n.retainedKernelInputsJson(o)));return d.set(t.layout,{get measured(){return a().measured},get options(){return a().options},...t.headersFooters?{headersFooters:t.headersFooters}:{}}),{layout:t.layout,notesConverged:t.notesConverged}}export{c as buildResidentRegionLayoutRequest,f as computeLayout,g as getLayoutKernelInputs,i as resolvedFinalSectionProperties,l as updateFinalSectionProperties};
1
+ export{c as buildResidentRegionLayoutRequest,e as computeLayout,d as getLayoutKernelInputs,a as resolvedFinalSectionProperties,b as updateFinalSectionProperties}from'../chunk-FE6FWGBJ.mjs';import'../chunk-TTRUPDAB.mjs';
@@ -1,4 +1,4 @@
1
- import { y as ThemeColorSlot, C as ColorValue, f as Theme, x as ThemeColorScheme } from './formatting-7zKCTu5a.mjs';
1
+ import { y as ThemeColorSlot, C as ColorValue, f as Theme, x as ThemeColorScheme } from './formatting-gqLFeJ9X.mjs';
2
2
 
3
3
  /**
4
4
  * Color primitives and math shared across OOXML formats.
@@ -331,6 +331,8 @@ interface TextFormatting {
331
331
  rtl?: boolean;
332
332
  /** Complex script formatting (w:cs) */
333
333
  cs?: boolean;
334
+ /** Snap to document grid (w:snapToGrid). Absent is the OOXML default (on). */
335
+ snapToGrid?: boolean;
334
336
  /** Character style ID (w:rStyle) */
335
337
  styleId?: string;
336
338
  }
@@ -443,6 +445,12 @@ interface ParagraphFormatting {
443
445
  pageBreakBefore?: boolean;
444
446
  /** Contextual spacing — suppress space between paragraphs of the same style (w:contextualSpacing) */
445
447
  contextualSpacing?: boolean;
448
+ /** Snap to document grid (w:snapToGrid on pPr). Absent is the OOXML default (on). */
449
+ snapToGrid?: boolean;
450
+ /** Space between East Asian and Latin text (w:autoSpaceDE). Absent is the OOXML default (on). */
451
+ autoSpaceDE?: boolean;
452
+ /** Space between East Asian text and numbers (w:autoSpaceDN). Absent is the OOXML default (on). */
453
+ autoSpaceDN?: boolean;
446
454
  /** Numbering properties (w:numPr) */
447
455
  numPr?: {
448
456
  /** Numbering definition ID (w:numId) */
@@ -1,5 +1,5 @@
1
- import { T as TextModernEffects } from './formatting-7zKCTu5a.mjs';
2
- import { D as DrawingScene, c as ShapeTextBodyProperties } from './content-CvEtPl0c.mjs';
1
+ import { T as TextModernEffects } from './formatting-gqLFeJ9X.mjs';
2
+ import { D as DrawingScene, c as ShapeTextBodyProperties } from './content-BzoC6bSz.mjs';
3
3
 
4
4
  interface DisplayList {
5
5
  /** Contract version. Undefined reads as legacy version 0. */
@@ -299,6 +299,8 @@ interface DocAttrs {
299
299
  clipGroup?: DisplayClipGroupMetadata;
300
300
  /** Enclosing table-fragment identity and accessibility semantics. */
301
301
  table?: DisplayTableMetadata;
302
+ /** Inline native-shape atom; true only for paragraph-inline shapes. */
303
+ inlineShapeAtom?: boolean;
302
304
  }
303
305
  interface TextRunPrimitive extends DocAttrs {
304
306
  kind: 'text';
@@ -769,5 +771,14 @@ declare function applyFrameDelta(previous: RetainedFrame | null, delta: DecodedF
769
771
  * geometry shifts from creating periodic multi-megabyte GC stalls.
770
772
  */
771
773
  declare function applyFrameDeltaOwned(previous: RetainedFrame | null, delta: DecodedFrameDelta): RetainedFrame;
774
+ /**
775
+ * Hidden in-place mutation counter for one display page. The owned delta path
776
+ * (`applyFrameDeltaOwned`) patches primitive positions through the SAME page
777
+ * object, so page identity alone cannot prove content equality; identity-based
778
+ * consumers (query-facade handle adoption) must compare this revision too. The
779
+ * property is non-enumerable, so serialization and structural reads never see
780
+ * it.
781
+ */
782
+ declare function displayPageRevision(page: DisplayPage): number;
772
783
 
773
- export { type DisplayList as D, FRAME_DELTA_HEADER_BYTES as F, type GlyphRunPrimitive as G, type HfRegion as H, type ImagePrimitive as I, type LinePrimitive as L, type PositionedGlyph as P, type RetainedFrame as R, type TextRunPrimitive as T, type DisplayPage as a, type DisplayPrimitive as b, type DecodedFrameDelta as c, type DecorationPrimitive as d, type DisplayBounds as e, type DocAttrs as f, FRAME_DELTA_PAGE_OP_BYTES as g, FRAME_DELTA_VERSION as h, FrameDeltaError as i, type FrameDeltaErrorCode as j, type FramePageOperation as k, type RectPrimitive as l, type RetainedFramePage as m, type TableCellRef as n, applyFrameDelta as o, applyFrameDeltaOwned as p, decodeFrameDelta as q };
784
+ export { type DisplayList as D, FRAME_DELTA_HEADER_BYTES as F, type GlyphRunPrimitive as G, type HfRegion as H, type ImagePrimitive as I, type LinePrimitive as L, type PositionedGlyph as P, type RetainedFrame as R, type TextRunPrimitive as T, type DisplayPage as a, type DisplayPrimitive as b, type DecodedFrameDelta as c, type DecorationPrimitive as d, type DisplayBounds as e, type DocAttrs as f, FRAME_DELTA_PAGE_OP_BYTES as g, FRAME_DELTA_VERSION as h, FrameDeltaError as i, type FrameDeltaErrorCode as j, type FramePageOperation as k, type RectPrimitive as l, type RetainedFramePage as m, type TableCellRef as n, applyFrameDelta as o, applyFrameDeltaOwned as p, decodeFrameDelta as q, displayPageRevision as r };