@betteroffice/docx 0.0.1

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 (190) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
  4. package/dist/agent/index.d.mts +531 -0
  5. package/dist/agent/index.mjs +1 -0
  6. package/dist/chunk-34K66SY4.mjs +1 -0
  7. package/dist/chunk-3UBMCDME.mjs +1 -0
  8. package/dist/chunk-4RCISPPE.mjs +1 -0
  9. package/dist/chunk-4UD54UM5.mjs +1 -0
  10. package/dist/chunk-52GB3Y42.mjs +1 -0
  11. package/dist/chunk-6NEKRDXF.mjs +1 -0
  12. package/dist/chunk-6PW4CWUG.mjs +1 -0
  13. package/dist/chunk-7DEIW7FL.mjs +1 -0
  14. package/dist/chunk-7PCO5I2O.mjs +1 -0
  15. package/dist/chunk-BI3B33LI.mjs +1 -0
  16. package/dist/chunk-BIQWVK5P.mjs +2 -0
  17. package/dist/chunk-CIRN3LZA.mjs +1 -0
  18. package/dist/chunk-DXKG3HQ5.mjs +16 -0
  19. package/dist/chunk-EUUIJVM6.mjs +0 -0
  20. package/dist/chunk-FPZBTOD6.mjs +1 -0
  21. package/dist/chunk-FZIA7OFY.mjs +1 -0
  22. package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
  23. package/dist/chunk-H3JCIGWK.mjs +1 -0
  24. package/dist/chunk-HJGAQIU7.mjs +2 -0
  25. package/dist/chunk-I6KKMUUC.mjs +1 -0
  26. package/dist/chunk-IL5JZJT7.mjs +1 -0
  27. package/dist/chunk-JY6ILTNS.mjs +1 -0
  28. package/dist/chunk-KEE52TT5.mjs +1 -0
  29. package/dist/chunk-KVKLLTDP.mjs +58 -0
  30. package/dist/chunk-KXNZFTTK.mjs +1 -0
  31. package/dist/chunk-L5ISVQ3W.mjs +1 -0
  32. package/dist/chunk-LDUWIM7M.mjs +1 -0
  33. package/dist/chunk-N5Q3YN64.mjs +1 -0
  34. package/dist/chunk-NEWOMDTX.mjs +1 -0
  35. package/dist/chunk-O2QSE2I7.mjs +1 -0
  36. package/dist/chunk-OBQGPMPQ.mjs +1 -0
  37. package/dist/chunk-OJOHXQNQ.mjs +1 -0
  38. package/dist/chunk-OMR3TWCD.mjs +2 -0
  39. package/dist/chunk-P3KDV4M2.mjs +1 -0
  40. package/dist/chunk-Q7PO7V73.mjs +1 -0
  41. package/dist/chunk-QOUFE3VX.mjs +1 -0
  42. package/dist/chunk-SINEY6ZF.mjs +1 -0
  43. package/dist/chunk-T4EZMUXM.mjs +1 -0
  44. package/dist/chunk-TTRUPDAB.mjs +1 -0
  45. package/dist/chunk-TYHI7RAD.mjs +1 -0
  46. package/dist/chunk-UIEJWORW.mjs +1 -0
  47. package/dist/chunk-VAOUFAUH.mjs +1 -0
  48. package/dist/chunk-VBOTMRXV.mjs +1 -0
  49. package/dist/chunk-VCER63GQ.mjs +1 -0
  50. package/dist/chunk-WAUF2UC7.mjs +2 -0
  51. package/dist/chunk-WRWRCBLK.mjs +1 -0
  52. package/dist/chunk-X4XDO3LZ.mjs +1 -0
  53. package/dist/chunk-XQBCCJBO.mjs +9 -0
  54. package/dist/chunk-XWUOLYRQ.mjs +2 -0
  55. package/dist/chunk-XYH6XWP3.mjs +10 -0
  56. package/dist/chunk-YBIM6UJV.mjs +8 -0
  57. package/dist/chunk-YCIH2Q3E.mjs +1 -0
  58. package/dist/chunk-YUOKI2HB.mjs +1 -0
  59. package/dist/chunk-ZOV5KL7C.mjs +1 -0
  60. package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
  61. package/dist/content-sSHuWw49.d.mts +2202 -0
  62. package/dist/core-plugins.d.mts +37 -0
  63. package/dist/core-plugins.mjs +1 -0
  64. package/dist/core.d.mts +451 -0
  65. package/dist/core.mjs +1 -0
  66. package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
  67. package/dist/docx/index.d.mts +618 -0
  68. package/dist/docx/index.mjs +2 -0
  69. package/dist/docx/parser.d.mts +41 -0
  70. package/dist/docx/parser.mjs +1 -0
  71. package/dist/docx/rezip.d.mts +148 -0
  72. package/dist/docx/rezip.mjs +1 -0
  73. package/dist/docx/serializer/index.d.mts +42 -0
  74. package/dist/docx/serializer/index.mjs +1 -0
  75. package/dist/docx/wrapTypes.d.mts +19 -0
  76. package/dist/docx/wrapTypes.mjs +1 -0
  77. package/dist/docxInput-DTbCa48g.d.mts +21 -0
  78. package/dist/editor/index.d.mts +170 -0
  79. package/dist/editor/index.mjs +1 -0
  80. package/dist/editorTree-DO5PyDK8.d.mts +37 -0
  81. package/dist/executor-7O2RBJ2B.mjs +1 -0
  82. package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
  83. package/dist/formatting-DoL7KBSL.d.mts +823 -0
  84. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  85. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  86. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  87. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  88. package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
  89. package/dist/headless.d.mts +69 -0
  90. package/dist/headless.mjs +1 -0
  91. package/dist/layout/flow/index.d.mts +149 -0
  92. package/dist/layout/flow/index.mjs +1 -0
  93. package/dist/layout/index.d.mts +307 -0
  94. package/dist/layout/index.mjs +1 -0
  95. package/dist/layout/measure/index.d.mts +324 -0
  96. package/dist/layout/measure/index.mjs +1 -0
  97. package/dist/layout/pagination/index.d.mts +60 -0
  98. package/dist/layout/pagination/index.mjs +1 -0
  99. package/dist/layout/pagination/types.d.mts +4 -0
  100. package/dist/layout/pagination/types.mjs +1 -0
  101. package/dist/layout/render/index.d.mts +733 -0
  102. package/dist/layout/render/index.mjs +1 -0
  103. package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
  104. package/dist/managers/AutoSaveManager.d.mts +81 -0
  105. package/dist/managers/AutoSaveManager.mjs +1 -0
  106. package/dist/managers/TableSelectionManager.d.mts +74 -0
  107. package/dist/managers/TableSelectionManager.mjs +1 -0
  108. package/dist/managers/types.d.mts +113 -0
  109. package/dist/managers/types.mjs +0 -0
  110. package/dist/mcp-cli.mjs +142 -0
  111. package/dist/mcp.d.mts +162 -0
  112. package/dist/mcp.mjs +16 -0
  113. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
  114. package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
  115. package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
  116. package/dist/plugin-api/RenderedDomContext.mjs +1 -0
  117. package/dist/plugin-api/index.d.mts +7 -0
  118. package/dist/plugin-api/index.mjs +0 -0
  119. package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
  120. package/dist/plugin-api/resolveItemPositions.mjs +1 -0
  121. package/dist/plugin-api/types.d.mts +193 -0
  122. package/dist/plugin-api/types.mjs +0 -0
  123. package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
  124. package/dist/registry-DMM5VTdT.d.mts +165 -0
  125. package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
  126. package/dist/rustPagination-Bj2hq013.d.mts +106 -0
  127. package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
  128. package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
  129. package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
  130. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
  131. package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
  132. package/dist/styles/index.d.mts +162 -0
  133. package/dist/styles/index.mjs +1 -0
  134. package/dist/styles-VxNcXLdi.d.mts +189 -0
  135. package/dist/types/agentApi.d.mts +456 -0
  136. package/dist/types/agentApi.mjs +1 -0
  137. package/dist/types/content.d.mts +3 -0
  138. package/dist/types/content.mjs +1 -0
  139. package/dist/types/document.d.mts +117 -0
  140. package/dist/types/document.mjs +1 -0
  141. package/dist/types-DNrYr6yQ.d.mts +1754 -0
  142. package/dist/types-dYdjUZMo.d.mts +311 -0
  143. package/dist/units-O5Y02RKQ.d.mts +34 -0
  144. package/dist/utils/autoScroll.d.mts +24 -0
  145. package/dist/utils/autoScroll.mjs +1 -0
  146. package/dist/utils/cardStyles.d.mts +22 -0
  147. package/dist/utils/cardStyles.mjs +1 -0
  148. package/dist/utils/comments.d.mts +120 -0
  149. package/dist/utils/comments.mjs +4 -0
  150. package/dist/utils/findReplace.d.mts +114 -0
  151. package/dist/utils/findReplace.mjs +2 -0
  152. package/dist/utils/findVerticalScrollParent.d.mts +25 -0
  153. package/dist/utils/findVerticalScrollParent.mjs +1 -0
  154. package/dist/utils/fontOptions.d.mts +21 -0
  155. package/dist/utils/fontOptions.mjs +1 -0
  156. package/dist/utils/headingCollector.d.mts +28 -0
  157. package/dist/utils/headingCollector.mjs +1 -0
  158. package/dist/utils/highlightColors.d.mts +14 -0
  159. package/dist/utils/highlightColors.mjs +1 -0
  160. package/dist/utils/index.d.mts +956 -0
  161. package/dist/utils/index.mjs +84 -0
  162. package/dist/utils/listState.d.mts +27 -0
  163. package/dist/utils/listState.mjs +1 -0
  164. package/dist/utils/reportIssue.d.mts +23 -0
  165. package/dist/utils/reportIssue.mjs +2 -0
  166. package/dist/utils/sidebarConstants.d.mts +10 -0
  167. package/dist/utils/sidebarConstants.mjs +1 -0
  168. package/dist/utils/stylePreview.d.mts +70 -0
  169. package/dist/utils/stylePreview.mjs +1 -0
  170. package/dist/utils/textSelection.d.mts +92 -0
  171. package/dist/utils/textSelection.mjs +1 -0
  172. package/dist/utils/units.d.mts +78 -0
  173. package/dist/utils/units.mjs +1 -0
  174. package/dist/variableDetector-Borj29SF.d.mts +115 -0
  175. package/dist/wasm-FZQ5XB2Y.mjs +1 -0
  176. package/dist/wasm-SA237OSP.mjs +1 -0
  177. package/dist/wasm-edit.d.mts +473 -0
  178. package/dist/wasm-edit.mjs +1 -0
  179. package/dist/wasm-layout.d.mts +112 -0
  180. package/dist/wasm-layout.mjs +1 -0
  181. package/dist/wasm-opc.d.mts +16 -0
  182. package/dist/wasm-opc.mjs +1 -0
  183. package/dist/wasm-parse.d.mts +18 -0
  184. package/dist/wasm-parse.mjs +1 -0
  185. package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
  186. package/dist/yrs/index.d.mts +882 -0
  187. package/dist/yrs/index.mjs +1 -0
  188. package/dist/yrs/residentEngineWorker.d.mts +2 -0
  189. package/dist/yrs/residentEngineWorker.mjs +1 -0
  190. package/package.json +365 -0
@@ -0,0 +1,311 @@
1
+ import { Document } from './types/document.mjs';
2
+ import { Position, Range, AgentCommand } from './types/agentApi.mjs';
3
+
4
+ /**
5
+ * Core Plugin System Types
6
+ *
7
+ * Defines the interfaces for headless plugins that work in Node.js
8
+ * without React/DOM dependencies. These plugins extend DocumentAgent
9
+ * with additional commands and expose MCP tools for AI integration.
10
+ */
11
+
12
+ /**
13
+ * Core plugin interface - headless, works in Node.js
14
+ *
15
+ * Plugins can:
16
+ * - Register command handlers that DocumentAgent dispatches to
17
+ * - Declare MCP tools that the MCP server exposes to AI clients
18
+ * - Have optional initialization logic
19
+ * - Declare dependencies on other plugins
20
+ */
21
+ interface CorePlugin {
22
+ /** Unique plugin identifier */
23
+ id: string;
24
+ /** Human-readable plugin name */
25
+ name: string;
26
+ /** Plugin version (semver) */
27
+ version?: string;
28
+ /** Plugin description */
29
+ description?: string;
30
+ /**
31
+ * Command handlers this plugin provides.
32
+ * DocumentAgent dispatches commands to these handlers.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * commandHandlers: {
37
+ * 'insertTemplateVariable': (doc, cmd) => {
38
+ * // Transform document
39
+ * return modifiedDoc;
40
+ * },
41
+ * }
42
+ * ```
43
+ */
44
+ commandHandlers?: Record<string, CommandHandler>;
45
+ /**
46
+ * MCP tools this plugin exposes.
47
+ * MCP server collects these from all plugins.
48
+ */
49
+ mcpTools?: McpToolDefinition[];
50
+ /**
51
+ * Optional setup when plugin is registered.
52
+ * Called once during plugin registration.
53
+ */
54
+ initialize?: () => void | Promise<void>;
55
+ /**
56
+ * Optional cleanup when plugin is unregistered.
57
+ */
58
+ destroy?: () => void | Promise<void>;
59
+ /**
60
+ * Dependencies on other plugins (by ID).
61
+ * The registry ensures dependencies are loaded first.
62
+ */
63
+ dependencies?: string[];
64
+ }
65
+ /**
66
+ * Command handler function type
67
+ *
68
+ * Receives a document and a command, returns a modified document.
69
+ * Must be pure/immutable - always return a new document.
70
+ */
71
+ type CommandHandler = (doc: Document, command: PluginCommand) => Document;
72
+ /**
73
+ * Extended command type for plugins
74
+ *
75
+ * Plugins can define custom command types beyond the built-in AgentCommand types.
76
+ */
77
+ interface PluginCommand {
78
+ /** Command type identifier */
79
+ type: string;
80
+ /** Unique command ID (for undo tracking) */
81
+ id?: string;
82
+ /** Position for positional commands */
83
+ position?: Position;
84
+ /** Range for range-based commands */
85
+ range?: Range;
86
+ /** Additional command-specific data */
87
+ [key: string]: unknown;
88
+ }
89
+ /**
90
+ * Result of command execution
91
+ */
92
+ interface CommandResult {
93
+ /** The modified document */
94
+ document: Document;
95
+ /** Whether the command succeeded */
96
+ success: boolean;
97
+ /** Error message if failed */
98
+ error?: string;
99
+ /** Metadata about the operation */
100
+ metadata?: Record<string, unknown>;
101
+ }
102
+ /**
103
+ * MCP tool definition
104
+ *
105
+ * Describes a tool that can be called by AI clients through the MCP server.
106
+ */
107
+ interface McpToolDefinition {
108
+ /** Tool name (used in MCP protocol) */
109
+ name: string;
110
+ /** Human-readable description for AI */
111
+ description: string;
112
+ /**
113
+ * JSON Schema for tool input validation.
114
+ * Can be a Zod schema or plain JSON Schema object.
115
+ */
116
+ inputSchema: JsonSchema | ZodSchemaLike;
117
+ /**
118
+ * Handler function for the tool.
119
+ * Receives validated input and returns a result.
120
+ */
121
+ handler: McpToolHandler;
122
+ /**
123
+ * Optional annotations for the tool
124
+ */
125
+ annotations?: McpToolAnnotations;
126
+ }
127
+ /**
128
+ * MCP tool handler function
129
+ */
130
+ type McpToolHandler = (input: unknown, context: McpToolContext) => Promise<McpToolResult> | McpToolResult;
131
+ /**
132
+ * Context passed to MCP tool handlers
133
+ */
134
+ interface McpToolContext {
135
+ /** Current document (if loaded) */
136
+ document?: Document;
137
+ /** Document buffer (if loaded) */
138
+ documentBuffer?: ArrayBuffer;
139
+ /** Session state */
140
+ session: McpSession;
141
+ /** Logger for debugging */
142
+ log: (message: string, data?: unknown) => void;
143
+ }
144
+ /**
145
+ * MCP session state
146
+ *
147
+ * Maintains state across tool calls within a session.
148
+ */
149
+ interface McpSession {
150
+ /** Session ID */
151
+ id: string;
152
+ /** Loaded documents by ID */
153
+ documents: Map<string, LoadedDocument>;
154
+ /** Custom session data */
155
+ data: Map<string, unknown>;
156
+ }
157
+ /**
158
+ * A loaded document in the session
159
+ */
160
+ interface LoadedDocument {
161
+ /** Document ID */
162
+ id: string;
163
+ /** Parsed document */
164
+ document: Document;
165
+ /** Original buffer (for repacking) */
166
+ buffer?: ArrayBuffer;
167
+ /** Source filename or path */
168
+ source?: string;
169
+ /** Last modified timestamp */
170
+ lastModified: number;
171
+ }
172
+ /**
173
+ * MCP tool result
174
+ */
175
+ interface McpToolResult {
176
+ /** Result content */
177
+ content: McpToolContent[];
178
+ /** Whether this is an error result */
179
+ isError?: boolean;
180
+ }
181
+ /**
182
+ * MCP tool content types
183
+ */
184
+ type McpToolContent = {
185
+ type: 'text';
186
+ text: string;
187
+ } | {
188
+ type: 'image';
189
+ data: string;
190
+ mimeType: string;
191
+ } | {
192
+ type: 'resource';
193
+ uri: string;
194
+ mimeType?: string;
195
+ text?: string;
196
+ };
197
+ /**
198
+ * MCP tool annotations
199
+ */
200
+ interface McpToolAnnotations {
201
+ /** Tool category for organization */
202
+ category?: string;
203
+ /** Whether this tool modifies the document */
204
+ readOnly?: boolean;
205
+ /** Estimated cost/complexity */
206
+ complexity?: 'low' | 'medium' | 'high';
207
+ /** Example usage */
208
+ examples?: McpToolExample[];
209
+ }
210
+ /**
211
+ * MCP tool example
212
+ */
213
+ interface McpToolExample {
214
+ /** Example description */
215
+ description: string;
216
+ /** Example input */
217
+ input: unknown;
218
+ /** Expected output description */
219
+ output?: string;
220
+ }
221
+ /**
222
+ * JSON Schema definition (subset)
223
+ */
224
+ interface JsonSchema {
225
+ type?: string | string[];
226
+ properties?: Record<string, JsonSchema>;
227
+ items?: JsonSchema;
228
+ required?: string[];
229
+ description?: string;
230
+ enum?: unknown[];
231
+ default?: unknown;
232
+ minimum?: number;
233
+ maximum?: number;
234
+ minLength?: number;
235
+ maxLength?: number;
236
+ pattern?: string;
237
+ format?: string;
238
+ additionalProperties?: boolean | JsonSchema;
239
+ anyOf?: JsonSchema[];
240
+ oneOf?: JsonSchema[];
241
+ allOf?: JsonSchema[];
242
+ $ref?: string;
243
+ }
244
+ /**
245
+ * Zod-like schema interface for compatibility
246
+ */
247
+ interface ZodSchemaLike {
248
+ _def?: unknown;
249
+ parse?: (data: unknown) => unknown;
250
+ safeParse?: (data: unknown) => {
251
+ success: boolean;
252
+ data?: unknown;
253
+ error?: unknown;
254
+ };
255
+ }
256
+ /**
257
+ * Check if a schema is Zod-like
258
+ */
259
+ declare function isZodSchema(schema: unknown): schema is ZodSchemaLike;
260
+ /**
261
+ * Plugin lifecycle events
262
+ */
263
+ type PluginEvent = {
264
+ type: 'registered';
265
+ plugin: CorePlugin;
266
+ } | {
267
+ type: 'unregistered';
268
+ pluginId: string;
269
+ } | {
270
+ type: 'error';
271
+ pluginId: string;
272
+ error: Error;
273
+ };
274
+ /**
275
+ * Plugin event listener
276
+ */
277
+ type PluginEventListener = (event: PluginEvent) => void;
278
+ /**
279
+ * Extract command type from a union
280
+ */
281
+ type ExtractCommand<T extends AgentCommand, Type extends string> = T extends {
282
+ type: Type;
283
+ } ? T : never;
284
+ /**
285
+ * Create a typed command handler
286
+ */
287
+ type TypedCommandHandler<T extends PluginCommand> = (doc: Document, command: T) => Document;
288
+ /**
289
+ * Plugin configuration options
290
+ */
291
+ interface PluginOptions {
292
+ /** Enable debug logging */
293
+ debug?: boolean;
294
+ /** Custom configuration */
295
+ config?: Record<string, unknown>;
296
+ }
297
+ /**
298
+ * Result of plugin registration
299
+ */
300
+ interface PluginRegistrationResult {
301
+ /** Whether registration succeeded */
302
+ success: boolean;
303
+ /** Registered plugin (if successful) */
304
+ plugin?: CorePlugin;
305
+ /** Error message (if failed) */
306
+ error?: string;
307
+ /** Warning messages */
308
+ warnings?: string[];
309
+ }
310
+
311
+ export { type CommandHandler as C, type ExtractCommand as E, type JsonSchema as J, type LoadedDocument as L, type McpSession as M, type PluginCommand as P, type TypedCommandHandler as T, type ZodSchemaLike as Z, type CommandResult as a, type CorePlugin as b, type McpToolAnnotations as c, type McpToolContent as d, type McpToolContext as e, type McpToolDefinition as f, type McpToolHandler as g, type McpToolResult as h, type PluginEvent as i, type PluginEventListener as j, type PluginOptions as k, type PluginRegistrationResult as l, isZodSchema as m, type McpToolExample as n };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Pixels per inch at standard DPI
3
+ *
4
+ * @public
5
+ */
6
+ declare const PIXELS_PER_INCH = 96;
7
+ /**
8
+ * Convert EMUs to pixels (at 96 DPI)
9
+ *
10
+ * 1 inch = 914400 EMUs = 96 pixels
11
+ * Returns 0 for null/undefined/NaN inputs.
12
+ *
13
+ * @public
14
+ */
15
+ declare function emuToPixels(emu: number | undefined | null): number;
16
+ /**
17
+ * Convert pixels to EMUs.
18
+ * EMU coordinates in OOXML are integer-typed (xs:long); rounding here keeps
19
+ * floating-point drift (e.g. 52 px → 495299.99999999994) out of the document.
20
+ *
21
+ * @public
22
+ */
23
+ declare function pixelsToEmu(px: number): number;
24
+ /**
25
+ * Convert points to pixels (at 96 DPI)
26
+ *
27
+ * 1 inch = 72 points = 96 pixels
28
+ * → 1 point = 96/72 pixels = 4/3 pixels
29
+ *
30
+ * @public
31
+ */
32
+ declare function pointsToPixels(points: number): number;
33
+
34
+ export { PIXELS_PER_INCH as P, pointsToPixels as a, emuToPixels as e, pixelsToEmu as p };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Drag auto-scroll geometry shared by the React and Vue adapters.
3
+ *
4
+ * When the user drag-selects and the pointer nears the top/bottom edge of the
5
+ * scroll container, the container should auto-scroll at a speed proportional to
6
+ * how deep into the edge zone the pointer is. The per-frame loop and the
7
+ * framework wiring stay in each adapter's hook; this is just the pure delta.
8
+ */
9
+ /** Pixel distance from the container edge where auto-scroll activates. */
10
+ declare const AUTO_SCROLL_EDGE_ZONE = 40;
11
+ /** Maximum scroll speed in pixels per frame (~60fps). */
12
+ declare const AUTO_SCROLL_MAX_SPEED = 12;
13
+ /**
14
+ * Vertical scroll delta (px/frame) for a pointer at `mouseY` over a container
15
+ * whose viewport spans `rect.top`..`rect.bottom`. Negative scrolls up, positive
16
+ * down, 0 when the pointer is outside both edge zones. Speed ramps linearly
17
+ * from 0 at the edge-zone boundary to `AUTO_SCROLL_MAX_SPEED` at the edge.
18
+ */
19
+ declare function computeAutoScrollDelta(rect: {
20
+ top: number;
21
+ bottom: number;
22
+ }, mouseY: number): number;
23
+
24
+ export { AUTO_SCROLL_EDGE_ZONE, AUTO_SCROLL_MAX_SPEED, computeAutoScrollDelta };
@@ -0,0 +1 @@
1
+ import'../chunk-TTRUPDAB.mjs';var o=40,A=12;function S(_,E){if(E<_.top+40){let O=Math.max(0,_.top+40-E);return -Math.min(12,O/40*12)}if(E>_.bottom-40){let O=Math.max(0,E-(_.bottom-40));return Math.min(12,O/40*12)}return 0}export{o as AUTO_SCROLL_EDGE_ZONE,A as AUTO_SCROLL_MAX_SPEED,S as computeAutoScrollDelta};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tiny shared CSSProperties shape so framework-agnostic style
3
+ * objects in core don't need to import from React or Vue. Both
4
+ * adapters' `CSSProperties` types are structurally compatible
5
+ * with this looser shape (string | number values, camelCased keys).
6
+ */
7
+ type CSSProperties = Record<string, string | number | undefined>;
8
+
9
+ /**
10
+ * Sidebar card chrome — shared between React and Vue. Numeric
11
+ * pixel values rather than `'8px'` strings so both adapters'
12
+ * CSSProperties shapes accept them. Lifted from
13
+ * `packages/docx-react/src/components/sidebar/cardStyles.ts` and the
14
+ * Vue mirror so there's one canonical table.
15
+ * @packageDocumentation
16
+ * @public
17
+ */
18
+
19
+ declare const CARD_STYLE_COLLAPSED: CSSProperties;
20
+ declare const CARD_STYLE_EXPANDED: CSSProperties;
21
+
22
+ export { CARD_STYLE_COLLAPSED, CARD_STYLE_EXPANDED };
@@ -0,0 +1 @@
1
+ import'../chunk-TTRUPDAB.mjs';var d={padding:"8px 10px",borderRadius:8,backgroundColor:"var(--doc-card)",cursor:"pointer",boxShadow:"var(--doc-card-shadow)"},a={padding:"10px 12px",borderRadius:8,backgroundColor:"var(--doc-surface)",cursor:"pointer",boxShadow:"var(--doc-card-shadow-strong)"};export{d as CARD_STYLE_COLLAPSED,a as CARD_STYLE_EXPANDED};
@@ -0,0 +1,120 @@
1
+ import { P as Paragraph, B as BlockContent, C as Comment } from '../content-sSHuWw49.mjs';
2
+ import '../formatting-DoL7KBSL.mjs';
3
+ import '../docx/wrapTypes.mjs';
4
+
5
+ /**
6
+ * Framework-agnostic comment + tracked-change helpers shared by the
7
+ * React and Vue adapters. The data shapes and string-formatting rules
8
+ * here are part of the visible UI (avatar colors, date strings) so
9
+ * keep this file as the single source of truth — both adapters import
10
+ * from here. CSS-property factories live in adapter-specific files
11
+ * (sidebar/cardUtils.ts in React, sidebar/sidebarUtils.ts in Vue).
12
+ * @packageDocumentation
13
+ * @public
14
+ */
15
+
16
+ /** Extract plain text from a Comment's paragraph content. */
17
+ declare function getCommentText(paragraphs?: Paragraph[] | BlockContent[]): string;
18
+ /** Extract text from the richest available comment body projection. */
19
+ declare function getRichCommentText(comment: Pick<Comment, 'content' | 'blockContent'>): string;
20
+ declare function formatDate(dateStr?: string): string;
21
+ declare function getInitials(name: string): string;
22
+ declare function getAvatarColor(name: string): string;
23
+ /** Prefer an authored reviewer color/palette assignment over name hashing. */
24
+ declare function getReviewColor(reviewer: {
25
+ name?: string;
26
+ color?: string;
27
+ paletteIndex?: number;
28
+ } | undefined): string;
29
+ /** Stable id shared by mirror anchors and framework comment cards. */
30
+ declare function getCommentSemanticId(commentId: string | number): string;
31
+ declare function truncateText(text: string, maxLength?: number): string;
32
+ /**
33
+ * One tracked change surfaced by `extractTrackedChanges`. Each entry
34
+ * groups all sites of one revision into a single row that the sidebar
35
+ * renders as one card. Resolve via {@link acceptChangeById} /
36
+ * {@link rejectChangeById} for any type — the by-id resolver walks
37
+ * every site sharing the id so coalesced edits clear in one click.
38
+ *
39
+ * @public
40
+ */
41
+ interface TrackedChangeEntry {
42
+ /**
43
+ * Revision shape. Inline shapes (`insertion`, `deletion`, `replacement`)
44
+ * wrap text runs; the rest are structural revisions on node attrs.
45
+ *
46
+ * - `insertion` — text was added (`<w:ins>`).
47
+ * - `deletion` — text was struck through but not removed (`<w:del>`).
48
+ * - `replacement` — a deletion + insertion by the same author at the
49
+ * same position+time; sidebar shows one combined card. `deletedText`
50
+ * and `insertionRevisionId` are set on this variant.
51
+ * - `paragraphMarkInsertion` / `paragraphMarkDeletion` — Enter /
52
+ * Backspace produced a tracked paragraph break (`<w:pPr><w:rPr><w:ins/>` /
53
+ * `<w:del/>`).
54
+ * - `paragraphPropertiesChanged` — formatting (alignment, spacing,
55
+ * etc.) on the paragraph was changed (`<w:pPrChange>`).
56
+ * - `rowInserted` / `rowDeleted` / `rowPropertiesChanged` — table
57
+ * row authored / removed / formatted (`<w:trPr><w:ins/>` / `<w:del/>`
58
+ * / `<w:trPrChange>`).
59
+ * - `cellInserted` / `cellDeleted` / `cellMerged` /
60
+ * `cellPropertiesChanged` — per-cell revisions
61
+ * (`<w:cellIns>` / `<w:cellDel>` / `<w:cellMerge>` / `<w:tcPrChange>`).
62
+ * - `tablePropertiesChanged` — table-level formatting
63
+ * (`<w:tblPrChange>`).
64
+ */
65
+ type: 'insertion' | 'deletion' | 'replacement' | 'paragraphMarkInsertion' | 'paragraphMarkDeletion' | 'paragraphPropertiesChanged' | 'rowInserted' | 'rowDeleted' | 'rowPropertiesChanged' | 'cellInserted' | 'cellDeleted' | 'cellMerged' | 'cellPropertiesChanged' | 'tableInserted' | 'tableDeleted' | 'tablePropertiesChanged';
66
+ /**
67
+ * Affected text. For inline types this is the run's text; for
68
+ * structural types it's the surrounding paragraph / cell content
69
+ * (truncated by the sidebar before display).
70
+ */
71
+ text: string;
72
+ /**
73
+ * Only set when `type === 'replacement'` — the text the user removed.
74
+ * The inserted text lives in {@link TrackedChangeEntry.text}.
75
+ */
76
+ deletedText?: string;
77
+ /** Author that minted the revision (`w:author`). */
78
+ author: string;
79
+ /** ISO timestamp the revision was minted (`w:date`). May be undefined for legacy imports. */
80
+ date?: string;
81
+ /**
82
+ * Document position where the revision starts. For inline types this
83
+ * is the start of the marked text run; for structural types it's the
84
+ * containing paragraph / row / cell / table node's start position.
85
+ * Used by the sidebar to anchor the card at the correct vertical
86
+ * offset.
87
+ */
88
+ from: number;
89
+ /**
90
+ * Document position where the revision ends. For inline coalesced
91
+ * runs that span multiple paragraphs, this is the END position of the
92
+ * LAST run in the group; the intervening structural positions are not
93
+ * preserved.
94
+ */
95
+ to: number;
96
+ /**
97
+ * The `w:id` of the revision. Pass to
98
+ * {@link acceptChangeById} / {@link rejectChangeById} to resolve every
99
+ * site sharing this id — including pPrIns paragraph attrs and
100
+ * subsequent typed runs in the same editing session.
101
+ */
102
+ revisionId: number;
103
+ /**
104
+ * Only set when `type === 'replacement'` — the insertion half carries
105
+ * a DIFFERENT `w:id` from the deletion (sharing would trip the OOXML
106
+ * move-pair serializer). Card Accept handlers dispatch BOTH ids to
107
+ * clear the deletion and the insertion + any coalesced paragraph-marks.
108
+ */
109
+ insertionRevisionId?: number;
110
+ /**
111
+ * Extra `w:id`s that map to the same logical revision as this card.
112
+ * Populated when the extractor coalesces a burst of distinct ids by
113
+ * (author, date) — e.g. a foreign document where the source editor
114
+ * minted a fresh id per atomic edit. Accept/reject handlers must
115
+ * resolve every id in this list in addition to {@link revisionId}.
116
+ */
117
+ coalescedRevisionIds?: number[];
118
+ }
119
+
120
+ export { type TrackedChangeEntry, formatDate, getAvatarColor, getCommentSemanticId, getCommentText, getInitials, getReviewColor, getRichCommentText, truncateText };
@@ -0,0 +1,4 @@
1
+ import'../chunk-TTRUPDAB.mjs';function i(e){return n(e).trim()}function u(e){return i(e.blockContent?.length?e.blockContent:e.content)}function n(e){if(e==null)return "";if(Array.isArray(e))return e.map(n).join("");if(typeof e!="object")return "";let t=e;switch(t.type){case "text":return typeof t.text=="string"?t.text:"";case "tab":return " ";case "break":return `
2
+ `;case "softHyphen":return "\xAD";case "noBreakHyphen":return "\u2011";case "symbol":return typeof t.char=="string"?t.char:"";case "paragraph":return `${n(t.content)}
3
+ `;case "run":case "inlineSdt":case "blockSdt":return n(t.content);case "hyperlink":return n(t.structuredChildren??t.children);case "simpleField":{let r=t.structuredResult;return n(r?.inline??r?.blocks??t.content)}case "complexField":{let r=t.structuredResult;return n(r?.inline??r?.blocks??t.fieldResult)}case "table":return n(t.rows);case "tableRow":return `${t.cells?.map(n).join(" ")??""}
4
+ `;case "tableCell":return n(t.content).trimEnd();default:return ""}}function l(e){if(!e)return "";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}function d(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var o=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function s(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return o[Math.abs(t)%o.length]}function g(e){if(e?.color)return e.color;if(e?.paletteIndex!==void 0){let t=(e.paletteIndex%o.length+o.length)%o.length;return o[t]}return s(e?.name??"")}function p(e){return `oox-comment-${String(e).replace(/[^a-zA-Z0-9_-]/g,"-")}`}function h(e,t=50){return e.length>t?e.slice(0,t)+"...":e}export{l as formatDate,s as getAvatarColor,p as getCommentSemanticId,i as getCommentText,d as getInitials,g as getReviewColor,u as getRichCommentText,h as truncateText};
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Find & Replace Utility Functions
3
+ *
4
+ * Pure utility functions for text search, pattern matching, and
5
+ * document search. Lifted from packages/docx-react/src/components/dialogs/
6
+ * findReplaceUtils.ts so the React adapter and the Vue adapter share
7
+ * one implementation.
8
+ * @packageDocumentation
9
+ * @public
10
+ */
11
+ /**
12
+ * A single match result in the document
13
+ */
14
+ interface FindMatch {
15
+ /** Index of the paragraph containing the match */
16
+ paragraphIndex: number;
17
+ /** Index of the run/content within the paragraph */
18
+ contentIndex: number;
19
+ /** Character offset within the content */
20
+ startOffset: number;
21
+ /** Character offset for end of match */
22
+ endOffset: number;
23
+ /** The matched text */
24
+ text: string;
25
+ }
26
+ /**
27
+ * Find options for controlling search behavior
28
+ */
29
+ interface FindOptions {
30
+ /** Whether to match case */
31
+ matchCase: boolean;
32
+ /** Whether to match whole words only */
33
+ matchWholeWord: boolean;
34
+ /** Whether to use regular expressions (future) */
35
+ useRegex?: boolean;
36
+ }
37
+ /**
38
+ * Find result with all matches
39
+ */
40
+ interface FindResult {
41
+ /** All matches found */
42
+ matches: FindMatch[];
43
+ /** Total match count */
44
+ totalCount: number;
45
+ /** Current match index (0-based) */
46
+ currentIndex: number;
47
+ }
48
+ /**
49
+ * Highlight options for document rendering
50
+ */
51
+ interface HighlightOptions {
52
+ /** Background color for current match */
53
+ currentMatchColor: string;
54
+ /** Background color for other matches */
55
+ otherMatchColor: string;
56
+ }
57
+ /**
58
+ * Create default find options
59
+ */
60
+ declare function createDefaultFindOptions(): FindOptions;
61
+ /**
62
+ * Escape string for use in regex pattern
63
+ */
64
+ declare function escapeRegexString(str: string): string;
65
+ /**
66
+ * Create a regex pattern from search text and options
67
+ */
68
+ declare function createSearchPattern(searchText: string, options: FindOptions): RegExp | null;
69
+ /**
70
+ * Find all matches of search text in content
71
+ */
72
+ declare function findAllMatches(content: string, searchText: string, options: FindOptions): Array<{
73
+ start: number;
74
+ end: number;
75
+ }>;
76
+ /**
77
+ * Replace text in content
78
+ */
79
+ declare function replaceAllInContent(content: string, searchText: string, replaceText: string, options: FindOptions): string;
80
+ /**
81
+ * Replace first match in content
82
+ */
83
+ declare function replaceFirstInContent(content: string, searchText: string, replaceText: string, options: FindOptions, startIndex?: number): {
84
+ content: string;
85
+ replaced: boolean;
86
+ matchStart: number;
87
+ matchEnd: number;
88
+ };
89
+ /**
90
+ * Get match count for status display
91
+ */
92
+ declare function getMatchCountText(result: FindResult | null): string;
93
+ /**
94
+ * Check if search text is empty or whitespace-only
95
+ */
96
+ declare function isEmptySearch(searchText: string): boolean;
97
+ /**
98
+ * Get default highlight options
99
+ */
100
+ declare function getDefaultHighlightOptions(): HighlightOptions;
101
+ /**
102
+ * Find all matches in a document
103
+ */
104
+ declare function findInDocument(document: any, searchText: string, options: FindOptions): FindMatch[];
105
+ /**
106
+ * Find matches in a single paragraph
107
+ */
108
+ declare function findInParagraph(paragraph: any, searchText: string, options: FindOptions, paragraphIndex: number): FindMatch[];
109
+ /**
110
+ * Scroll to a match in the document
111
+ */
112
+ declare function scrollToMatch(containerElement: HTMLElement | null, match: FindMatch): void;
113
+
114
+ export { type FindMatch, type FindOptions, type FindResult, type HighlightOptions, createDefaultFindOptions, createSearchPattern, escapeRegexString, findAllMatches, findInDocument, findInParagraph, getDefaultHighlightOptions, getMatchCountText, isEmptySearch, replaceAllInContent, replaceFirstInContent, scrollToMatch };
@@ -0,0 +1,2 @@
1
+ import'../chunk-TTRUPDAB.mjs';function F(){return {matchCase:false,matchWholeWord:false,useRegex:false}}function g(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function p(t,e){if(!t)return null;try{let n;e.useRegex?n=t:n=g(t),e.matchWholeWord&&(n=`\\b${n}\\b`);let r=e.matchCase?"g":"gi";return new RegExp(n,r)}catch{return null}}function l(t,e,n){if(!t||!e)return [];let r=[],o=e;n.matchCase||(o=e.toLowerCase());let c=h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i;n.matchWholeWord?i=`\\b${c(o)}\\b`:i=c(o);let a=n.matchCase?"g":"gi",s=new RegExp(i,a),f;for(;(f=s.exec(t))!==null;)r.push({start:f.index,end:f.index+f[0].length}),f[0].length===0&&s.lastIndex++;return r}function y(t,e,n,r){let o=p(e,r);return o?t.replace(o,n):t}function C(t,e,n,r,o=0){let c=l(t,e,r),i=c.find(s=>s.start>=o)||c[0];return i?{content:t.substring(0,i.start)+n+t.substring(i.end),replaced:true,matchStart:i.start,matchEnd:i.start+n.length}:{content:t,replaced:false,matchStart:-1,matchEnd:-1}}function M(t){return t?t.totalCount===0?"No results":t.totalCount===1?"1 match":`${t.currentIndex+1} of ${t.totalCount} matches`:""}function O(t){return !t||t.trim()===""}function R(){return {currentMatchColor:"#FFFF00",otherMatchColor:"#FFFFAA"}}function u(t){if(!t||!t.content)return "";let e="";for(let n of t.content)n.type==="text"?e+=n.text||"":n.type==="tab"?e+=" ":n.type==="break"&&n.breakType==="textWrapping"&&(e+=`
2
+ `);return e}function d(t){if(!t||!t.content)return "";let e="";for(let n of t.content)if(n.type==="run")e+=u(n);else if(n.type==="hyperlink")for(let r of n.children||[])r.type==="run"&&(e+=u(r));return e}function E(t,e,n){if(!t||!e)return [];let r=[],o=t.package?.document||t.package?.document;if(!o||!o.content)return r;let c=0;for(let i of o.content)if(i.type==="paragraph"){let a=x(i,e,n,c);r.push(...a),c++;}else if(i.type==="table")for(let a of i.rows||[])for(let s of a.cells||[])for(let f of s.content||[])f.type;return r}function x(t,e,n,r){let o=[],c=d(t);if(!c)return o;let i=l(c,e,n);for(let a of i){let s=m(t,a.start);o.push({paragraphIndex:r,contentIndex:s.contentIndex,startOffset:s.offsetInContent,endOffset:s.offsetInContent+(a.end-a.start),text:c.substring(a.start,a.end)});}return o}function m(t,e){if(!t||!t.content)return {contentIndex:0,runIndex:0,offsetInContent:e};let n=0,r=0;for(let o of t.content){let c="";if(o.type==="run")c=u(o);else if(o.type==="hyperlink")for(let a of o.children||[])a.type==="run"&&(c+=u(a));let i=c.length;if(n+i>e)return {contentIndex:r,runIndex:r,offsetInContent:e-n};n+=i,r++;}return {contentIndex:Math.max(0,t.content.length-1),runIndex:Math.max(0,t.content.length-1),offsetInContent:0}}function w(t,e){if(!t||!e)return;let n=t.querySelector(`[data-paragraph-index="${e.paragraphIndex}"]`);n&&n.scrollIntoView({behavior:"smooth",block:"center"});}export{F as createDefaultFindOptions,p as createSearchPattern,g as escapeRegexString,l as findAllMatches,E as findInDocument,x as findInParagraph,R as getDefaultHighlightOptions,M as getMatchCountText,O as isEmptySearch,y as replaceAllInContent,C as replaceFirstInContent,w as scrollToMatch};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Pure DOM helpers — locate the element that vertically scrolls the
3
+ * paginated editor. Lifted from packages/docx-react/src/paged-editor/
4
+ * findVerticalScrollParent.ts so both adapters use the same logic
5
+ * for scroll-to-position, arrow-key line navigation, and drag
6
+ * auto-scroll.
7
+ * @packageDocumentation
8
+ * @public
9
+ */
10
+ /**
11
+ * First ancestor of `el` with `overflow-y: auto|scroll` and a scrollable
12
+ * overflow height. Walk starts at `el.parentElement` (does not treat
13
+ * `el` itself as the scroller).
14
+ *
15
+ * @returns `null` when no such ancestor exists before `document.documentElement`.
16
+ */
17
+ declare function findVerticalScrollParent(el: HTMLElement): HTMLElement | null;
18
+ /**
19
+ * Same as {@link findVerticalScrollParent} but falls back to
20
+ * `document.documentElement` so callers always get a valid scroll
21
+ * target (matches legacy `scrollIntoView` root).
22
+ */
23
+ declare function findVerticalScrollParentOrRoot(el: HTMLElement): HTMLElement;
24
+
25
+ export { findVerticalScrollParent, findVerticalScrollParentOrRoot };
@@ -0,0 +1 @@
1
+ import'../chunk-TTRUPDAB.mjs';function l(t){let e=t.parentElement;for(;e&&e!==document.documentElement;){let{overflowY:n}=getComputedStyle(e);if((n==="auto"||n==="scroll")&&e.scrollHeight>e.clientHeight+1)return e;e=e.parentElement;}return null}function c(t){return l(t)??document.documentElement}export{l as findVerticalScrollParent,c as findVerticalScrollParentOrRoot};