@betteroffice/docx 0.0.1 → 0.0.3

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 (165) hide show
  1. package/README.md +19 -0
  2. package/dist/chunk-AEQOEQJ7.mjs +57 -0
  3. package/dist/chunk-AZ52IWB6.mjs +16 -0
  4. package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
  5. package/dist/chunk-GGEGIQRK.mjs +1 -0
  6. package/dist/chunk-IFT6DUJX.mjs +1 -0
  7. package/dist/chunk-J7LNO6SM.mjs +1 -0
  8. package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
  9. package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
  10. package/dist/chunk-WON6K4FY.mjs +1 -0
  11. package/dist/chunk-Y7RUNRU2.mjs +1 -0
  12. package/dist/collaboration/index.d.mts +65 -0
  13. package/dist/collaboration/index.mjs +1 -0
  14. package/dist/{content-sSHuWw49.d.mts → content-MOZ6hKP4.d.mts} +357 -357
  15. package/dist/core.d.mts +148 -341
  16. package/dist/core.mjs +1 -1
  17. package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-BJlo7Jkz.d.mts} +24 -6
  18. package/dist/docx/index.d.mts +40 -520
  19. package/dist/docx/index.mjs +2 -2
  20. package/dist/editor/index.d.mts +36 -151
  21. package/dist/editor/index.mjs +1 -1
  22. package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
  23. package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
  24. package/dist/{rustDisplayList-dqunvwxH.d.mts → frameDelta-D965X8yK.d.mts} +3 -274
  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-Dx4Z3lkz.d.mts +1010 -0
  30. package/dist/layout/index.d.mts +19 -240
  31. package/dist/layout/index.mjs +1 -1
  32. package/dist/layout/pagination/index.d.mts +10 -58
  33. package/dist/layout/pagination/index.mjs +1 -1
  34. package/dist/layout/render/index.d.mts +11 -11
  35. package/dist/layout/render/index.mjs +1 -1
  36. package/dist/plugin-api/RenderedDomContext.d.mts +9 -9
  37. package/dist/plugin-api/index.d.mts +191 -6
  38. package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
  39. package/dist/rustDisplayList-BRuZBqdL.d.mts +278 -0
  40. package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
  41. package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
  42. package/dist/styles/index.d.mts +4 -39
  43. package/dist/styles/index.mjs +1 -1
  44. package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
  45. package/dist/types/content.d.mts +2 -2
  46. package/dist/types/document.d.mts +40 -14
  47. package/dist/{types-DNrYr6yQ.d.mts → types-BfqUl2h_.d.mts} +3 -71
  48. package/dist/utils/comments.d.mts +2 -2
  49. package/dist/utils/index.d.mts +110 -576
  50. package/dist/utils/index.mjs +1 -84
  51. package/dist/utils/stylePreview.d.mts +2 -2
  52. package/dist/utils/units.d.mts +33 -2
  53. package/dist/wasm-DO3BUV7C.mjs +1 -0
  54. package/dist/wasm-NWXX4H5G.mjs +1 -0
  55. package/dist/wasm-edit.d.mts +14 -5
  56. package/dist/wasm-edit.mjs +1 -1
  57. package/dist/wasm-layout.d.mts +10 -1
  58. package/dist/wasm-layout.mjs +1 -1
  59. package/dist/wasm-opc.mjs +1 -1
  60. package/dist/wasm-parse.mjs +1 -1
  61. package/dist/yrs/index.d.mts +6 -881
  62. package/dist/yrs/index.mjs +1 -1
  63. package/dist/yrs/residentEngineWorker.mjs +1 -1
  64. package/package.json +16 -139
  65. package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
  66. package/dist/agent/index.d.mts +0 -531
  67. package/dist/agent/index.mjs +0 -1
  68. package/dist/chunk-34K66SY4.mjs +0 -1
  69. package/dist/chunk-4RCISPPE.mjs +0 -1
  70. package/dist/chunk-52GB3Y42.mjs +0 -1
  71. package/dist/chunk-6NEKRDXF.mjs +0 -1
  72. package/dist/chunk-6PW4CWUG.mjs +0 -1
  73. package/dist/chunk-7DEIW7FL.mjs +0 -1
  74. package/dist/chunk-7PCO5I2O.mjs +0 -1
  75. package/dist/chunk-BI3B33LI.mjs +0 -1
  76. package/dist/chunk-BIQWVK5P.mjs +0 -2
  77. package/dist/chunk-CIRN3LZA.mjs +0 -1
  78. package/dist/chunk-DXKG3HQ5.mjs +0 -16
  79. package/dist/chunk-FPZBTOD6.mjs +0 -1
  80. package/dist/chunk-FZIA7OFY.mjs +0 -1
  81. package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
  82. package/dist/chunk-HJGAQIU7.mjs +0 -2
  83. package/dist/chunk-I6KKMUUC.mjs +0 -1
  84. package/dist/chunk-IL5JZJT7.mjs +0 -1
  85. package/dist/chunk-JY6ILTNS.mjs +0 -1
  86. package/dist/chunk-KEE52TT5.mjs +0 -1
  87. package/dist/chunk-KVKLLTDP.mjs +0 -58
  88. package/dist/chunk-L5ISVQ3W.mjs +0 -1
  89. package/dist/chunk-LDUWIM7M.mjs +0 -1
  90. package/dist/chunk-N5Q3YN64.mjs +0 -1
  91. package/dist/chunk-NEWOMDTX.mjs +0 -1
  92. package/dist/chunk-O2QSE2I7.mjs +0 -1
  93. package/dist/chunk-OJOHXQNQ.mjs +0 -1
  94. package/dist/chunk-OMR3TWCD.mjs +0 -2
  95. package/dist/chunk-P3KDV4M2.mjs +0 -1
  96. package/dist/chunk-Q7PO7V73.mjs +0 -1
  97. package/dist/chunk-QOUFE3VX.mjs +0 -1
  98. package/dist/chunk-TYHI7RAD.mjs +0 -1
  99. package/dist/chunk-UIEJWORW.mjs +0 -1
  100. package/dist/chunk-VAOUFAUH.mjs +0 -1
  101. package/dist/chunk-VBOTMRXV.mjs +0 -1
  102. package/dist/chunk-VCER63GQ.mjs +0 -1
  103. package/dist/chunk-WAUF2UC7.mjs +0 -2
  104. package/dist/chunk-X4XDO3LZ.mjs +0 -1
  105. package/dist/chunk-XQBCCJBO.mjs +0 -9
  106. package/dist/chunk-XWUOLYRQ.mjs +0 -2
  107. package/dist/chunk-XYH6XWP3.mjs +0 -10
  108. package/dist/chunk-YBIM6UJV.mjs +0 -8
  109. package/dist/chunk-YCIH2Q3E.mjs +0 -1
  110. package/dist/chunk-ZOV5KL7C.mjs +0 -1
  111. package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
  112. package/dist/core-plugins.d.mts +0 -37
  113. package/dist/core-plugins.mjs +0 -1
  114. package/dist/docx/parser.d.mts +0 -41
  115. package/dist/docx/parser.mjs +0 -1
  116. package/dist/docx/rezip.d.mts +0 -148
  117. package/dist/docx/rezip.mjs +0 -1
  118. package/dist/docx/serializer/index.d.mts +0 -42
  119. package/dist/docx/serializer/index.mjs +0 -1
  120. package/dist/editorTree-DO5PyDK8.d.mts +0 -37
  121. package/dist/executor-7O2RBJ2B.mjs +0 -1
  122. package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
  123. package/dist/headless.d.mts +0 -69
  124. package/dist/headless.mjs +0 -1
  125. package/dist/layout/flow/index.d.mts +0 -149
  126. package/dist/layout/flow/index.mjs +0 -1
  127. package/dist/layout/measure/index.d.mts +0 -324
  128. package/dist/layout/measure/index.mjs +0 -1
  129. package/dist/layout/pagination/types.d.mts +0 -4
  130. package/dist/layout/pagination/types.mjs +0 -1
  131. package/dist/managers/AutoSaveManager.d.mts +0 -81
  132. package/dist/managers/AutoSaveManager.mjs +0 -1
  133. package/dist/managers/TableSelectionManager.d.mts +0 -74
  134. package/dist/managers/TableSelectionManager.mjs +0 -1
  135. package/dist/managers/types.d.mts +0 -113
  136. package/dist/managers/types.mjs +0 -0
  137. package/dist/mcp-cli.mjs +0 -142
  138. package/dist/mcp.d.mts +0 -162
  139. package/dist/mcp.mjs +0 -16
  140. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
  141. package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
  142. package/dist/plugin-api/types.d.mts +0 -193
  143. package/dist/plugin-api/types.mjs +0 -0
  144. package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
  145. package/dist/registry-DMM5VTdT.d.mts +0 -165
  146. package/dist/rustPagination-Bj2hq013.d.mts +0 -106
  147. package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
  148. package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
  149. package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
  150. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
  151. package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
  152. package/dist/types/agentApi.d.mts +0 -456
  153. package/dist/types/agentApi.mjs +0 -1
  154. package/dist/types-dYdjUZMo.d.mts +0 -311
  155. package/dist/units-O5Y02RKQ.d.mts +0 -34
  156. package/dist/utils/headingCollector.d.mts +0 -28
  157. package/dist/utils/headingCollector.mjs +0 -1
  158. package/dist/utils/highlightColors.d.mts +0 -14
  159. package/dist/utils/highlightColors.mjs +0 -1
  160. package/dist/utils/textSelection.d.mts +0 -92
  161. package/dist/utils/textSelection.mjs +0 -1
  162. package/dist/variableDetector-Borj29SF.d.mts +0 -115
  163. package/dist/wasm-FZQ5XB2Y.mjs +0 -1
  164. package/dist/wasm-SA237OSP.mjs +0 -1
  165. package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
@@ -1,109 +0,0 @@
1
- import { W as WrapTextDirection, i as PageGeometry, e as LayoutBlock, B as BlockExtent } from './types-DNrYr6yQ.mjs';
2
-
3
- /**
4
- * Clamp floating-wrap margins so at least a usable strip of the line
5
- * remains. Unchecked margins from near-full-width tables/images can exceed
6
- * contentWidth and collapse every line to ~1 glyph (the "single character
7
- * per line after a wide floating table" bug).
8
- *
9
- * Returned margins are zeroed when:
10
- * - either side alone is >= contentWidth (no strip on that side at all), or
11
- * - their sum is >= contentWidth (no strip exists between the two sides).
12
- */
13
- declare function clampFloatingWrapMargins(leftMargin: number, rightMargin: number, contentWidth: number): {
14
- leftMargin: number;
15
- rightMargin: number;
16
- };
17
- interface FloatingExclusionRect {
18
- /** which margin absorbs the exclusion when wrapText alone doesn't pick a side. */
19
- side: 'left' | 'right';
20
- /** object's left edge in content-area px. */
21
- x: number;
22
- /** object's top edge in content-area px. */
23
- y: number;
24
- width: number;
25
- height: number;
26
- distTop: number;
27
- distBottom: number;
28
- distLeft: number;
29
- distRight: number;
30
- wrapText?: WrapTextDirection;
31
- wrapType?: string;
32
- }
33
- interface FloatingImageZone {
34
- leftMargin: number;
35
- rightMargin: number;
36
- topY: number;
37
- bottomY: number;
38
- segments?: FloatingLineSegmentZone[];
39
- /**
40
- * Full-width vertical band (OOXML `topAndBottom` wrap): no text fits beside
41
- * it, so any line overlapping `[topY, bottomY]` is pushed below the band.
42
- */
43
- fullWidthBlock?: boolean;
44
- }
45
- interface FloatingLineSegmentZone {
46
- leftOffset: number;
47
- availableWidth: number;
48
- }
49
- interface FloatingLineMargins {
50
- leftMargin: number;
51
- rightMargin: number;
52
- segments?: FloatingLineSegmentZone[];
53
- }
54
- declare function rectsToFloatingZones(rects: FloatingExclusionRect[], contentWidth: number): FloatingImageZone[];
55
- declare function getFloatingMargins(lineY: number, lineHeight: number, zones: FloatingImageZone[] | undefined, paragraphYOffset: number): FloatingLineMargins;
56
-
57
- /**
58
- * Floating-aware block measurement pipeline.
59
- *
60
- * Pre-scans a block list to extract exclusion zones from anchored images,
61
- * floating tables, and floating text boxes; groups co-located floats so
62
- * their combined exclusion applies starting from the earliest anchor; then
63
- * walks the blocks calling the caller-supplied `measureBlock` with the
64
- * active zones and cumulative Y at each step.
65
- *
66
- * Adapters (React, Vue) provide their own `measureBlock` so they can
67
- * decide e.g. whether to cache paragraph measures. The orchestration,
68
- * extraction, and grouping live here so both adapters stay in lockstep.
69
- *
70
- * @packageDocumentation
71
- * @public
72
- */
73
-
74
- /**
75
- * Block-measurement callback shape passed to {@link measureBlocksWithFloats}.
76
- * Adapters (React, Vue) supply this so they can decide platform-specific
77
- * concerns (e.g. paragraph-measure caching, per-section width) while
78
- * sharing the floating-zone orchestration. This is adapter-author API,
79
- * not end-consumer API.
80
- *
81
- * @public
82
- */
83
- type MeasureBlockFn = (block: LayoutBlock, contentWidth: number, floatingZones?: FloatingImageZone[], cumulativeY?: number) => BlockExtent;
84
- /**
85
- * Page geometry (CSS px) used to resolve page/margin-relative anchored objects
86
- * into content-area coordinates — currently the vertical anchor of a top-pinned
87
- * `topAndBottom` band. Same shape the painter uses (see `pageGeometryFromPage`),
88
- * so both paths resolve to identical positions.
89
- *
90
- * @public
91
- */
92
- type FloatPageGeometry = PageGeometry;
93
- /**
94
- * Walk `blocks` and produce one `BlockExtent` per block. Before measuring, this
95
- * extracts floating exclusion zones (images / floating tables / floating
96
- * textboxes), groups overlapping co-located floats, and threads the active
97
- * zones plus cumulative Y into each `measureBlock` call.
98
- *
99
- * Pass `pageGeometry` whenever the document may contain page/margin-anchored
100
- * `topAndBottom` text boxes (e.g. a title banner pinned to the page top):
101
- * without it their reserved band falls back to flow-relative Y and the band
102
- * won't line up with where the painter places the box. Build it with the
103
- * shared `pageGeometryFromPage` helper.
104
- *
105
- * @public
106
- */
107
- declare function measureBlocksWithFloats(blocks: LayoutBlock[], contentWidth: number | number[], measureBlock: MeasureBlockFn, pageGeometry?: FloatPageGeometry): BlockExtent[];
108
-
109
- export { type FloatPageGeometry as F, type MeasureBlockFn as M, type FloatingExclusionRect as a, type FloatingImageZone as b, type FloatingLineSegmentZone as c, clampFloatingWrapMargins as d, getFloatingMargins as g, measureBlocksWithFloats as m, rectsToFloatingZones as r };
@@ -1,26 +0,0 @@
1
- import { e as LayoutBlock, B as BlockExtent } from './types-DNrYr6yQ.mjs';
2
-
3
- /**
4
- * The colocated block+measure unit consumed by the paginator.
5
- */
6
-
7
- /**
8
- * A flow block paired with its measurement. The paginator consumes
9
- * `MeasuredBlock[]` instead of two parallel `LayoutBlock[]` + `BlockExtent[]`
10
- * arrays kept in lockstep by index — colocating the pair makes a misaligned
11
- * block/measure unrepresentable.
12
- * @public
13
- */
14
- type MeasuredBlock = {
15
- block: LayoutBlock;
16
- measure: BlockExtent;
17
- };
18
- /**
19
- * Zip aligned `blocks` and `measures` into `MeasuredBlock[]`. This is the one
20
- * place a length assumption is localized — the pervasive per-index coupling it
21
- * replaces is what the measured-block model removes.
22
- * @public
23
- */
24
- declare function toMeasuredBlocks(blocks: LayoutBlock[], measures: BlockExtent[]): MeasuredBlock[];
25
-
26
- export { type MeasuredBlock as M, toMeasuredBlocks as t };
@@ -1,193 +0,0 @@
1
- import { Document } from '../types/document.mjs';
2
- import '../content-sSHuWw49.mjs';
3
- import '../formatting-DoL7KBSL.mjs';
4
- import '../docx/wrapTypes.mjs';
5
- import '../styles-VxNcXLdi.mjs';
6
- import '../settingsParser-CcGvtmCK.mjs';
7
-
8
- /**
9
- * Framework-Agnostic Plugin Interface for the DOCX Editor
10
- *
11
- * Core plugin types that can be used by any framework (React, Vue, etc.).
12
- * Framework-specific adapters extend EditorPluginCore with their own
13
- * UI rendering capabilities (e.g., ReactEditorPlugin, VueEditorPlugin).
14
- * @packageDocumentation
15
- * @public
16
- */
17
-
18
- /**
19
- * Coordinates returned by position lookup in the rendered DOM.
20
- */
21
- interface PositionCoordinates {
22
- x: number;
23
- y: number;
24
- height: number;
25
- }
26
- /**
27
- * Context for accessing rendered-page geometry in the paged editor.
28
- *
29
- * Provides position mapping over the canvas renderer's output (Rust
30
- * display-list queries, with the accessibility mirror's DOM as fallback).
31
- * Use this for rendering overlays, annotations, and other visual elements
32
- * positioned relative to rendered content.
33
- *
34
- * The mirror DOM uses data-doc-start/data-doc-end attributes on spans
35
- * to map between display positions and DOM elements.
36
- */
37
- interface RenderedDomContext {
38
- /** The container element holding all rendered pages. */
39
- pagesContainer: HTMLElement;
40
- /**
41
- * Get pixel coordinates for a display position in the rendered DOM.
42
- * Returns null if the position cannot be found.
43
- */
44
- getCoordinatesForPosition(position: number): PositionCoordinates | null;
45
- /**
46
- * Find DOM elements that overlap with a display-position range.
47
- */
48
- findElementsForRange(from: number, to: number): Element[];
49
- /**
50
- * Get bounding rectangles for a range of text, accounting for line wraps.
51
- * Returns rects relative to the pages container.
52
- */
53
- getRectsForRange(from: number, to: number): Array<{
54
- x: number;
55
- y: number;
56
- width: number;
57
- height: number;
58
- }>;
59
- /** Query-backed caret coordinates for one explicit header/footer page. */
60
- getCoordinatesForHfPosition(region: 'header' | 'footer', rId: string, position: number, pageIndex: number): PositionCoordinates | null;
61
- /** Query-backed range rectangles for one explicit header/footer page. */
62
- getRectsForHfRange(region: 'header' | 'footer', rId: string, from: number, to: number, pageIndex: number): Array<{
63
- x: number;
64
- y: number;
65
- width: number;
66
- height: number;
67
- }>;
68
- /** Bounds of one rendered page relative to the pages container. */
69
- getPageBounds(pageIndex: number): {
70
- x: number;
71
- y: number;
72
- width: number;
73
- height: number;
74
- } | null;
75
- /** Current zoom level (1 = 100%). */
76
- zoom: number;
77
- /**
78
- * Offset of the pages container from its parent viewport.
79
- */
80
- getContainerOffset(): {
81
- x: number;
82
- y: number;
83
- };
84
- }
85
- /**
86
- * Props passed to plugin panel components (framework-agnostic base).
87
- */
88
- interface PluginPanelProps<TState = unknown> {
89
- /** Current serializer-facing document snapshot. */
90
- document: Document | null;
91
- /** Scroll editor to a specific position */
92
- scrollToPosition: (pos: number) => void;
93
- /** Select a range in the editor */
94
- selectRange: (from: number, to: number) => void;
95
- /** Plugin-specific state (managed by the plugin) */
96
- pluginState: TState;
97
- /** Width of the panel in pixels */
98
- panelWidth: number;
99
- /**
100
- * Context for the rendered pages (canvas renderer output).
101
- * May be null if layout hasn't completed yet.
102
- */
103
- renderedDomContext: RenderedDomContext | null;
104
- }
105
- /**
106
- * Configuration for plugin panel rendering.
107
- */
108
- interface PanelConfig {
109
- /** Where to render the panel */
110
- position: 'left' | 'right' | 'bottom';
111
- /** Default width/height of the panel */
112
- defaultSize: number;
113
- /** Minimum size */
114
- minSize?: number;
115
- /** Maximum size */
116
- maxSize?: number;
117
- /** Whether the panel is resizable */
118
- resizable?: boolean;
119
- /** Whether the panel can be collapsed */
120
- collapsible?: boolean;
121
- /** Initial collapsed state */
122
- defaultCollapsed?: boolean;
123
- }
124
- /**
125
- * Framework-agnostic core plugin interface.
126
- *
127
- * Contains all non-UI plugin capabilities:
128
- * - State management (initialize, onStateChange, destroy)
129
- * - CSS injection
130
- * - Panel configuration
131
- *
132
- * Framework adapters (ReactEditorPlugin, VueEditorPlugin) extend this
133
- * with their own Panel component type and renderOverlay function.
134
- */
135
- interface EditorPluginCore<TState = any> {
136
- /** Unique plugin identifier */
137
- id: string;
138
- /** Display name for the plugin */
139
- name: string;
140
- /**
141
- * Configuration for the panel (position, size, etc.)
142
- */
143
- panelConfig?: PanelConfig;
144
- /**
145
- * Called when the projected document changes.
146
- * Use this to update plugin-specific state based on document changes.
147
- */
148
- onStateChange?: (document: Document) => TState | undefined;
149
- /**
150
- * Initialize plugin state when the plugin is first loaded.
151
- */
152
- initialize?: (document: Document | null) => TState;
153
- /**
154
- * Called when the plugin is being destroyed.
155
- * Use this for cleanup (subscriptions, timers, etc.)
156
- */
157
- destroy?: () => void;
158
- /**
159
- * CSS styles to inject for this plugin.
160
- * Can be a string of CSS or a URL to a stylesheet.
161
- */
162
- styles?: string;
163
- }
164
- /**
165
- * A sidebar item anchored to a document position.
166
- * Framework adapters extend this with rendering capabilities.
167
- */
168
- interface SidebarItem {
169
- /** Unique ID for this item (used as React key and for overlap resolution). */
170
- id: string;
171
- /** Display position this item anchors to. */
172
- anchorPos: number;
173
- /** Optional key into the anchorPositions Map (e.g. "comment-42", "revision-7"). */
174
- anchorKey?: string;
175
- /** Sort priority within items at the same anchor Y. Lower = first. Default: 0. */
176
- priority?: number;
177
- /** Temporary items (e.g. "add comment" input) skip entrance animation. */
178
- isTemporary?: boolean;
179
- /** Pre-computed Y position (scroll-container coords, pre-zoom). Overrides anchor resolution. */
180
- fixedY?: number;
181
- }
182
- /**
183
- * Context provided to plugins when computing sidebar items.
184
- */
185
- interface SidebarItemContext {
186
- document: Document | null;
187
- renderedDomContext: RenderedDomContext | null;
188
- /** Pre-computed Y positions from layout engine (keys like "comment-{id}"). */
189
- anchorPositions: Map<string, number>;
190
- zoom: number;
191
- }
192
-
193
- export type { EditorPluginCore, PanelConfig, PluginPanelProps, PositionCoordinates, RenderedDomContext, SidebarItem, SidebarItemContext };
File without changes
@@ -1 +0,0 @@
1
- export{j as createTemplateProcessor,k as default,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,d as processTemplateAndDownload,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-O2QSE2I7.mjs';import'./chunk-TTRUPDAB.mjs';
@@ -1,165 +0,0 @@
1
- import { b as CorePlugin, k as PluginOptions, l as PluginRegistrationResult, C as CommandHandler, f as McpToolDefinition, j as PluginEventListener } from './types-dYdjUZMo.mjs';
2
-
3
- /**
4
- * Plugin Registry
5
- *
6
- * Central registry for core plugins. Manages plugin lifecycle,
7
- * collects command handlers from all plugins, and aggregates
8
- * MCP tool definitions for the MCP server.
9
- */
10
-
11
- /**
12
- * Plugin Registry - manages core plugins
13
- *
14
- * @example
15
- * ```ts
16
- * import { pluginRegistry, docxtemplaterPlugin } from '@betteroffice/docx/core-plugins';
17
- *
18
- * // Register plugins
19
- * pluginRegistry.register(docxtemplaterPlugin);
20
- *
21
- * // Get all MCP tools for MCP server
22
- * const tools = pluginRegistry.getMcpTools();
23
- *
24
- * // Get command handler for executor
25
- * const handler = pluginRegistry.getCommandHandler('insertTemplateVariable');
26
- * ```
27
- */
28
- declare class PluginRegistry {
29
- private plugins;
30
- private commandHandlers;
31
- private eventListeners;
32
- private initialized;
33
- /**
34
- * Register a plugin
35
- *
36
- * @param plugin - The plugin to register
37
- * @param options - Optional configuration
38
- * @returns Registration result
39
- */
40
- register(plugin: CorePlugin, options?: PluginOptions): PluginRegistrationResult;
41
- /**
42
- * Unregister a plugin
43
- *
44
- * @param pluginId - ID of the plugin to unregister
45
- * @returns Whether unregistration succeeded
46
- */
47
- unregister(pluginId: string): boolean;
48
- /**
49
- * Get a registered plugin by ID
50
- *
51
- * @param id - Plugin ID
52
- * @returns The plugin or undefined
53
- */
54
- get(id: string): CorePlugin | undefined;
55
- /**
56
- * Get all registered plugins
57
- *
58
- * @returns Array of all plugins
59
- */
60
- getAll(): CorePlugin[];
61
- /**
62
- * Check if a plugin is registered
63
- *
64
- * @param id - Plugin ID
65
- * @returns Whether the plugin is registered
66
- */
67
- has(id: string): boolean;
68
- /**
69
- * Get number of registered plugins
70
- */
71
- get size(): number;
72
- /**
73
- * Get a command handler for a command type
74
- *
75
- * @param commandType - The command type
76
- * @returns The handler or undefined
77
- */
78
- getCommandHandler(commandType: string): CommandHandler | undefined;
79
- /**
80
- * Get all registered command types
81
- *
82
- * @returns Array of command type strings
83
- */
84
- getCommandTypes(): string[];
85
- /**
86
- * Check if a command type has a handler
87
- *
88
- * @param commandType - The command type
89
- * @returns Whether a handler exists
90
- */
91
- hasCommandHandler(commandType: string): boolean;
92
- /**
93
- * Get all MCP tools from all registered plugins
94
- *
95
- * @returns Array of MCP tool definitions
96
- */
97
- getMcpTools(): McpToolDefinition[];
98
- /**
99
- * Get MCP tools from a specific plugin
100
- *
101
- * @param pluginId - Plugin ID
102
- * @returns Array of MCP tool definitions
103
- */
104
- getMcpToolsForPlugin(pluginId: string): McpToolDefinition[];
105
- /**
106
- * Get an MCP tool by name
107
- *
108
- * @param toolName - Tool name
109
- * @returns The tool definition or undefined
110
- */
111
- getMcpTool(toolName: string): McpToolDefinition | undefined;
112
- /**
113
- * Add an event listener
114
- *
115
- * @param listener - Event listener function
116
- */
117
- addEventListener(listener: PluginEventListener): void;
118
- /**
119
- * Remove an event listener
120
- *
121
- * @param listener - Event listener function
122
- */
123
- removeEventListener(listener: PluginEventListener): void;
124
- /**
125
- * Emit an event to all listeners
126
- */
127
- private emit;
128
- /**
129
- * Clear all registered plugins
130
- *
131
- * Useful for testing or resetting state.
132
- */
133
- clear(): void;
134
- /**
135
- * Get registry state for debugging
136
- */
137
- getDebugInfo(): {
138
- plugins: string[];
139
- commandTypes: string[];
140
- mcpTools: string[];
141
- initialized: string[];
142
- };
143
- }
144
- /**
145
- * Global plugin registry instance
146
- *
147
- * Use this for registering plugins and accessing their capabilities.
148
- */
149
- declare const pluginRegistry: PluginRegistry;
150
- /**
151
- * Register multiple plugins at once
152
- *
153
- * @param plugins - Array of plugins to register
154
- * @returns Array of registration results
155
- */
156
- declare function registerPlugins(plugins: CorePlugin[], options?: PluginOptions): PluginRegistrationResult[];
157
- /**
158
- * Create a plugin registration helper with options pre-configured
159
- *
160
- * @param options - Default options for plugin registration
161
- * @returns Registration function
162
- */
163
- declare function createPluginRegistrar(options: PluginOptions): (plugin: CorePlugin) => PluginRegistrationResult;
164
-
165
- export { PluginRegistry as P, createPluginRegistrar as c, pluginRegistry as p, registerPlugins as r };
@@ -1,106 +0,0 @@
1
- import { L as LayoutOptions, a as Layout } from './types-DNrYr6yQ.mjs';
2
- import { M as MeasuredBlock } from './measuredBlock-DZwz8zhD.mjs';
3
-
4
- /**
5
- * The mandatory Rust pagination source — the seam through which EVERY
6
- * pagination pass (full, incremental-trigger, footnote pass 1, and each
7
- * footnote-stabilization iteration in `layout/regions/footnoteLayout.ts`)
8
- * runs the wasm `docx-layout` engine. There is no TypeScript pagination
9
- * kernel anymore; this seam is the only way a `Layout` is produced.
10
- *
11
- * Contract (pinned by the golden corpus — `__golden__/rustParity.test.ts`
12
- * proves the engine reproduces every golden byte-for-byte, and
13
- * `__golden__/rustPaginationSeam.test.ts` proves this seam adds zero drift
14
- * on top):
15
- * - Input marshaling is exactly the golden convention:
16
- * `JSON.stringify({ measured, options }, mapReplacer)` where the replacer
17
- * turns `Map`s (`options.footnoteReservedHeights`) into plain objects
18
- * keyed by decimal page number — the shape the Rust `LayoutOptions`
19
- * deserializer expects.
20
- * - `layout_document_json` in, `Layout` JSON out. Engine failures THROW —
21
- * the layout pipeline surfaces the error (`onError` / console) and keeps
22
- * the previous committed layout; nothing falls back to a hidden kernel.
23
- * - The wasm engine is synchronous once loaded. Adapters gate layout passes
24
- * on {@link RustPaginationSource.isReady} / `whenReady()` (the same
25
- * defer-and-rerun pattern as the Rust measurement readiness gate), so
26
- * `paginate` never runs against an unloaded engine. The wasm module is
27
- * shared with the measurement engine, so in practice it is already
28
- * resolved by the time the first measured pass reaches pagination.
29
- *
30
- * @packageDocumentation
31
- * @public
32
- */
33
-
34
- /**
35
- * The narrow seam `editor/computeLayout.ts` consumes: a synchronous
36
- * pagination call over the measured blocks + options, plus the readiness
37
- * surface adapters use to defer layout passes until the wasm engine has
38
- * loaded. `paginate` throws if called before readiness or when the engine
39
- * rejects the input — there is no fallback engine.
40
- *
41
- * @public
42
- */
43
- interface LayoutPaginationSource {
44
- /** Paginate through the loaded Rust engine. Throws when not ready or on engine failure. */
45
- paginate(measured: MeasuredBlock[], options: LayoutOptions): Layout;
46
- /** Whether the wasm engine has finished its lazy load. */
47
- isReady(): boolean;
48
- /** Resolves when the engine is loaded; rejects if the load failed. */
49
- whenReady(): Promise<void>;
50
- }
51
- /**
52
- * Thin sync facade over the wasm pagination export (`layout_document_json`).
53
- * Injectable so unit tests can script responses without loading wasm — the
54
- * same pattern as the measurement seam's `RustTextEngine`.
55
- *
56
- * @public
57
- */
58
- interface RustLayoutEngine {
59
- /** `{ measured, options }` JSON in, `Layout` JSON out. Throws on any input the engine rejects. */
60
- layoutDocumentJson(input: string): string;
61
- }
62
- /**
63
- * Lazily load the embedded wasm module and expose its pagination surface as
64
- * a {@link RustLayoutEngine}. The dynamic `import()` keeps the ~800KB base64
65
- * module out of the synchronous require graph; the module — and therefore
66
- * the wasm instantiation — is shared with the measurement seam
67
- * (`getRustTextEngine`), so only one load happens per session.
68
- *
69
- * @public
70
- */
71
- declare function getRustLayoutEngine(): Promise<RustLayoutEngine>;
72
- /** Counters for observability (passes paginated / engine errors). @public */
73
- interface RustPaginationStats {
74
- /** Layout passes paginated by the Rust engine. */
75
- rustPaginated: number;
76
- /** Passes where the engine threw (the pass produced no layout). */
77
- engineErrors: number;
78
- }
79
- /** Options for {@link createRustPaginationSource}. @public */
80
- interface RustPaginationSourceOptions {
81
- /** Pre-loaded engine (tests). When set, the source is ready immediately. */
82
- engine?: RustLayoutEngine;
83
- /** Engine loader override (tests). Defaults to {@link getRustLayoutEngine}. */
84
- loadEngine?: () => Promise<RustLayoutEngine>;
85
- }
86
- /**
87
- * The mandatory pagination source. Create with
88
- * {@link createRustPaginationSource}; see the module doc for the contract.
89
- *
90
- * @public
91
- */
92
- interface RustPaginationSource extends LayoutPaginationSource {
93
- /** Snapshot of the pagination counters (never reset implicitly). */
94
- getStats(): RustPaginationStats;
95
- }
96
- /**
97
- * Build a {@link RustPaginationSource}. The wasm load starts immediately at
98
- * construction; adapters defer layout passes until `isReady()` and re-run
99
- * the pipeline off `whenReady()` — mirroring the Rust measurement readiness
100
- * gate, and sharing the same underlying wasm module load.
101
- *
102
- * @public
103
- */
104
- declare function createRustPaginationSource(opts?: RustPaginationSourceOptions): RustPaginationSource;
105
-
106
- export { type LayoutPaginationSource as L, type RustLayoutEngine as R, type RustPaginationSource as a, type RustPaginationSourceOptions as b, type RustPaginationStats as c, createRustPaginationSource as d, getRustLayoutEngine as g };
@@ -1,55 +0,0 @@
1
- import { P as PageMargins, C as ColumnLayout, b as PageHeaderFooterRefs, c as PageNumberingContract, d as PageBorderContract, S as SectionBreakBlock, N as NoteSettingsContract, e as LayoutBlock, L as LayoutOptions } from './types-DNrYr6yQ.mjs';
2
-
3
- /**
4
- * Per-section geometry collection.
5
- *
6
- * Walks a block list once and resolves the effective page geometry of every
7
- * section (size, margins, columns, header/footer refs, numbering, borders,
8
- * …), inheriting from the previous section where a break leaves a property
9
- * unset and applying any upstream section contracts. The live consumer is
10
- * `layout/regions/sectionGeometry.ts` (per-section measurement widths); the
11
- * Rust engine mirrors the same resolution natively.
12
- */
13
-
14
- /**
15
- * Page-flow geometry resolved from a single section's properties.
16
- * Exported so the React paged editor can reuse the same shape when
17
- * measuring blocks per section width — keeping pagination and
18
- * measurement consistent.
19
- */
20
- type SectionLayoutConfig = {
21
- pageSize: {
22
- w: number;
23
- h: number;
24
- };
25
- margins: PageMargins;
26
- /** Optional. Sections without explicit columns inherit `{ count: 1 }`. */
27
- columns?: ColumnLayout;
28
- /** Stable section/page state copied onto every page created in this section. */
29
- sectionIndex?: number;
30
- sectionId?: string;
31
- orientation?: 'portrait' | 'landscape';
32
- headerFooterRefs?: PageHeaderFooterRefs;
33
- pageNumbering?: PageNumberingContract;
34
- pageBorders?: PageBorderContract;
35
- watermark?: SectionBreakBlock['watermark'];
36
- verticalAlign?: SectionBreakBlock['verticalAlign'];
37
- noteSettings?: NoteSettingsContract;
38
- /** Versioned page metadata is emitted only when an upstream contract opts in. */
39
- emitPageMetadata?: boolean;
40
- };
41
- /**
42
- * Walk `blocks` once and collect per-section geometry. `configs` has one
43
- * entry per section break plus a trailing `finalConfig`. `breakIndices` is
44
- * 1-to-1 with the inner break entries (same length as `configs.length - 1`).
45
- * Callers that need the break `type` can read it from
46
- * `(blocks[breakIndices[i]] as SectionBreakBlock).type`.
47
- *
48
- * @internal
49
- */
50
- declare function collectSectionConfigs(blocks: LayoutBlock[], initialConfig: SectionLayoutConfig, finalConfig: SectionLayoutConfig, sectionContracts?: LayoutOptions['sections']): {
51
- configs: SectionLayoutConfig[];
52
- breakIndices: number[];
53
- };
54
-
55
- export { type SectionLayoutConfig as S, collectSectionConfigs as c };