@zeke-02/docx-editor 0.5.2 → 0.5.4

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 (223) hide show
  1. package/LICENSE +204 -0
  2. package/dist/FindReplaceDialog-7SQOVQWH.js +1 -0
  3. package/dist/FindReplaceDialog-RK3A7MSK.mjs +1 -0
  4. package/dist/{FootnotePropertiesDialog-XQ7NIFIU.js → FootnotePropertiesDialog-2Q2SHVMR.js} +1 -1
  5. package/dist/{FootnotePropertiesDialog-TNVJJCY6.mjs → FootnotePropertiesDialog-ZKQXW3YO.mjs} +1 -1
  6. package/dist/{HyperlinkDialog-FR4IZZ7E.mjs → HyperlinkDialog-QV3CVFQU.mjs} +1 -1
  7. package/dist/HyperlinkDialog-XVAF7FVN.js +1 -0
  8. package/dist/{ImagePositionDialog-JSZSIKF5.mjs → ImagePositionDialog-EGRH3HPP.mjs} +1 -1
  9. package/dist/{ImagePositionDialog-2YXRAGZS.js → ImagePositionDialog-HIVHUTBT.js} +1 -1
  10. package/dist/ImagePropertiesDialog-67WLFIIZ.mjs +1 -0
  11. package/dist/ImagePropertiesDialog-HSM3JJ22.js +1 -0
  12. package/dist/KeyboardShortcutsDialog-B0UFuR4w.d.ts +395 -0
  13. package/dist/KeyboardShortcutsDialog-t6JKL4Aj.d.mts +395 -0
  14. package/dist/PageSetupDialog-642IAVG2.js +1 -0
  15. package/dist/PageSetupDialog-ERUQDHAY.mjs +1 -0
  16. package/dist/PluginHost-HS31VIuo.d.mts +16 -0
  17. package/dist/PluginHost-zILZO7zX.d.ts +16 -0
  18. package/dist/{SplitCellDialog-NP3JJYHD.mjs → SplitCellDialog-GFWCFCTD.mjs} +1 -1
  19. package/dist/{SplitCellDialog-JIAC3RYV.js → SplitCellDialog-M7WF7ANE.js} +1 -1
  20. package/dist/{TablePropertiesDialog-TIK4AA5M.mjs → TablePropertiesDialog-TZ7VCL6V.mjs} +1 -1
  21. package/dist/{TablePropertiesDialog-T7D4HSVP.js → TablePropertiesDialog-ZKU2FTUX.js} +1 -1
  22. package/dist/agentApi-B2Y7kexW.d.ts +486 -0
  23. package/dist/agentApi-BzUJ_kao.d.mts +486 -0
  24. package/dist/chunk-2XXILKEQ.js +1 -0
  25. package/dist/chunk-35DG3R42.js +2 -0
  26. package/dist/chunk-5UX5CD4C.js +1 -0
  27. package/dist/chunk-7QQSDIWK.mjs +2 -0
  28. package/dist/chunk-AW5TISUL.js +3 -0
  29. package/dist/chunk-B45ECEGY.js +18 -0
  30. package/dist/chunk-B7CCL7SL.mjs +2 -0
  31. package/dist/chunk-BRMTZRLJ.js +2 -0
  32. package/dist/chunk-D47GTKGU.js +2 -0
  33. package/dist/chunk-F5SERL7X.mjs +2 -0
  34. package/dist/chunk-FWPVBFKQ.mjs +1 -0
  35. package/dist/chunk-GGQK26JO.js +2 -0
  36. package/dist/chunk-GM2S2WMT.mjs +1 -0
  37. package/dist/chunk-HXDMASAR.js +1 -0
  38. package/dist/chunk-ILYKDR3C.js +1 -0
  39. package/dist/chunk-JFRDFK7V.mjs +260 -0
  40. package/dist/chunk-JPF5R2ZM.mjs +1 -0
  41. package/dist/chunk-KOXCF3CL.mjs +1 -0
  42. package/dist/chunk-KRLNX56Y.mjs +2 -0
  43. package/dist/chunk-LWOHVYKW.mjs +1 -0
  44. package/dist/chunk-MDTA25AN.mjs +60 -0
  45. package/dist/chunk-MKNSJOCN.js +70 -0
  46. package/dist/chunk-NIBCC7WQ.js +1 -0
  47. package/dist/chunk-NLFXR2VH.js +2 -0
  48. package/dist/chunk-NOLMVQNN.mjs +40 -0
  49. package/dist/chunk-ONIYA2FU.mjs +2 -0
  50. package/dist/chunk-RCIZ7OM3.mjs +70 -0
  51. package/dist/chunk-SGTUE33R.js +260 -0
  52. package/dist/{chunk-EHFEG3TX.js → chunk-SNZ57XBI.js} +1 -1
  53. package/dist/chunk-SOTWG3KJ.mjs +1 -0
  54. package/dist/chunk-TYPGB4KF.js +1 -0
  55. package/dist/chunk-U7ZW2DOO.mjs +2 -0
  56. package/dist/chunk-WO3FIV4B.js +40 -0
  57. package/dist/{chunk-PKEOQIQO.mjs → chunk-WPI3YRFO.mjs} +1 -1
  58. package/dist/chunk-XGJ2EORY.mjs +1 -0
  59. package/dist/chunk-XQZTWWRF.mjs +18 -0
  60. package/dist/chunk-Y3SEHWZ2.js +1 -0
  61. package/dist/chunk-YBEVHQCT.js +60 -0
  62. package/dist/chunk-ZVAFVHWR.mjs +3 -0
  63. package/dist/chunk-ZXPCJWVY.js +2 -0
  64. package/dist/{agentApi-DLt94vXk.d.mts → content-REFGFfEH.d.mts} +8 -755
  65. package/dist/{agentApi-DLt94vXk.d.ts → content-REFGFfEH.d.ts} +8 -755
  66. package/dist/dialogs.d.mts +25 -0
  67. package/dist/dialogs.d.ts +25 -0
  68. package/dist/dialogs.js +1 -0
  69. package/dist/dialogs.mjs +1 -0
  70. package/dist/document-Cu2vq_wS.d.mts +294 -0
  71. package/dist/document-CxOagoLQ.d.ts +294 -0
  72. package/dist/executor-WBHID2RK.mjs +1 -0
  73. package/dist/executor-Y5VUOAHY.js +1 -0
  74. package/dist/findReplace-Bue0JaXh.d.ts +138 -0
  75. package/dist/findReplace-shXbOjFQ.d.mts +138 -0
  76. package/dist/fork.d.mts +535 -0
  77. package/dist/fork.d.ts +535 -0
  78. package/dist/fork.js +1 -0
  79. package/dist/fork.mjs +1 -0
  80. package/dist/hooks.d.mts +598 -0
  81. package/dist/hooks.d.ts +598 -0
  82. package/dist/hooks.js +1 -0
  83. package/dist/hooks.mjs +1 -0
  84. package/dist/index-B5A-J9GC.d.ts +1119 -0
  85. package/dist/index-bw-PaozF.d.mts +1119 -0
  86. package/dist/index.d.mts +12 -591
  87. package/dist/index.d.ts +12 -591
  88. package/dist/index.js +1 -120
  89. package/dist/index.mjs +1 -120
  90. package/dist/layout-bridge-5GYGYKM5.mjs +1 -0
  91. package/dist/layout-bridge-QQDA7ELH.js +1 -0
  92. package/dist/plugin-api.d.mts +165 -0
  93. package/dist/plugin-api.d.ts +165 -0
  94. package/dist/plugin-api.js +1 -0
  95. package/dist/plugin-api.mjs +1 -0
  96. package/dist/processTemplate-BTBTR7AM.js +1 -0
  97. package/dist/{processTemplate-W2C5PXZB.mjs → processTemplate-MBX2KDLE.mjs} +1 -1
  98. package/dist/styles.css +1 -1
  99. package/dist/styles.d.mts +18 -0
  100. package/dist/styles.d.ts +18 -0
  101. package/dist/styles.js +1 -0
  102. package/dist/styles.mjs +1 -0
  103. package/dist/types-BF48VxkC.d.mts +18 -0
  104. package/dist/types-BF48VxkC.d.ts +18 -0
  105. package/dist/types-BnIs4sE7.d.mts +281 -0
  106. package/dist/types-BnIs4sE7.d.ts +281 -0
  107. package/dist/types-CW6HFAX6.d.ts +39 -0
  108. package/dist/types-DIsDCwTG.d.mts +39 -0
  109. package/dist/ui.d.mts +111 -552
  110. package/dist/ui.d.ts +111 -552
  111. package/dist/ui.js +111 -1
  112. package/dist/ui.mjs +111 -1
  113. package/dist/useFindReplace-DKy-s3gS.d.ts +261 -0
  114. package/dist/useFindReplace-vuoKpDKE.d.mts +261 -0
  115. package/package.json +47 -49
  116. package/dist/ClipboardManager-CVKX0v9q.d.ts +0 -464
  117. package/dist/ClipboardManager-V3aaMnWE.d.mts +0 -464
  118. package/dist/DocumentAgent-BWflKHpH.d.mts +0 -442
  119. package/dist/DocumentAgent-DsdXtetF.d.ts +0 -442
  120. package/dist/FindReplaceDialog-L3YF5HIS.mjs +0 -1
  121. package/dist/FindReplaceDialog-SEBWC5P7.js +0 -1
  122. package/dist/HyperlinkDialog-WEK6JSAC.js +0 -1
  123. package/dist/ImagePropertiesDialog-527MFLQO.mjs +0 -1
  124. package/dist/ImagePropertiesDialog-HG4K3IE7.js +0 -1
  125. package/dist/PageSetupDialog-GALVJMUB.js +0 -1
  126. package/dist/PageSetupDialog-TGQIAMI7.mjs +0 -1
  127. package/dist/TableToolbar-DUgmob2I.d.ts +0 -1273
  128. package/dist/TableToolbar-YL74HNS1.d.mts +0 -1273
  129. package/dist/chunk-23SXXIZS.js +0 -111
  130. package/dist/chunk-3F52AP2Q.js +0 -1
  131. package/dist/chunk-42O5GXM5.mjs +0 -82
  132. package/dist/chunk-54ULJEHM.mjs +0 -1
  133. package/dist/chunk-5XK326FI.mjs +0 -1
  134. package/dist/chunk-6WPRCJ5A.mjs +0 -1
  135. package/dist/chunk-76IYR7C7.mjs +0 -1
  136. package/dist/chunk-AGRIVA4G.js +0 -1
  137. package/dist/chunk-BTCQ2QI3.mjs +0 -3
  138. package/dist/chunk-BUEMG4NW.js +0 -1
  139. package/dist/chunk-BXRC4U3X.mjs +0 -2
  140. package/dist/chunk-CPAYKE6X.mjs +0 -1
  141. package/dist/chunk-DACWLFKI.mjs +0 -1
  142. package/dist/chunk-EPBFWE36.js +0 -2
  143. package/dist/chunk-FXES3YDB.js +0 -82
  144. package/dist/chunk-HI66BSGS.mjs +0 -9
  145. package/dist/chunk-INTPVEO6.mjs +0 -9
  146. package/dist/chunk-IOAGVW6Q.mjs +0 -2
  147. package/dist/chunk-JCEWC5QL.mjs +0 -4
  148. package/dist/chunk-JTIUFACT.js +0 -1
  149. package/dist/chunk-LUF7PWIC.js +0 -10
  150. package/dist/chunk-MGEN6GOE.mjs +0 -2
  151. package/dist/chunk-MOE2ZGUE.js +0 -18
  152. package/dist/chunk-MWLHJWB6.js +0 -9
  153. package/dist/chunk-OFYVDN3U.mjs +0 -2
  154. package/dist/chunk-P4VSHBGZ.js +0 -2
  155. package/dist/chunk-P5FQHIES.mjs +0 -1
  156. package/dist/chunk-PBC7XAYZ.js +0 -3
  157. package/dist/chunk-PEMB6SZT.js +0 -2
  158. package/dist/chunk-PQMSZTBB.js +0 -9
  159. package/dist/chunk-Q7UDQXAF.js +0 -1
  160. package/dist/chunk-QGTAIC5E.js +0 -1
  161. package/dist/chunk-QVPR2W5S.js +0 -1
  162. package/dist/chunk-R3QMYPL5.mjs +0 -59
  163. package/dist/chunk-RBUTXXQJ.mjs +0 -18
  164. package/dist/chunk-RRWYZ2TS.mjs +0 -111
  165. package/dist/chunk-S3STEPVO.js +0 -182
  166. package/dist/chunk-SFUM35DH.js +0 -2
  167. package/dist/chunk-SNLC6EK2.js +0 -1
  168. package/dist/chunk-TMTLIGLZ.js +0 -59
  169. package/dist/chunk-TSE2PWFX.mjs +0 -10
  170. package/dist/chunk-UKESXQS5.mjs +0 -182
  171. package/dist/chunk-UWYD42WV.js +0 -4
  172. package/dist/chunk-UXVACQCY.mjs +0 -1
  173. package/dist/chunk-W4EIKDM6.mjs +0 -2
  174. package/dist/chunk-W53SI3XW.mjs +0 -1
  175. package/dist/chunk-WNS2RBQD.js +0 -2
  176. package/dist/chunk-Z3KMSHUP.js +0 -1
  177. package/dist/core-plugins-reexport.d.mts +0 -31
  178. package/dist/core-plugins-reexport.d.ts +0 -31
  179. package/dist/core-plugins-reexport.js +0 -1
  180. package/dist/core-plugins-reexport.mjs +0 -1
  181. package/dist/core-reexport.d.mts +0 -340
  182. package/dist/core-reexport.d.ts +0 -340
  183. package/dist/core-reexport.js +0 -1
  184. package/dist/core-reexport.mjs +0 -1
  185. package/dist/documentSerializer-DtS_-oGA.d.mts +0 -664
  186. package/dist/documentSerializer-Wj1p2ASa.d.ts +0 -664
  187. package/dist/executor-C3VXF7QA.mjs +0 -1
  188. package/dist/executor-GDBV3AGV.js +0 -1
  189. package/dist/headless-reexport.d.mts +0 -197
  190. package/dist/headless-reexport.d.ts +0 -197
  191. package/dist/headless-reexport.js +0 -1
  192. package/dist/headless-reexport.mjs +0 -1
  193. package/dist/insertOperations-BTH1Asas.d.mts +0 -176
  194. package/dist/insertOperations-CbUnXAXH.d.ts +0 -176
  195. package/dist/layout-bridge-EA4DJ227.js +0 -1
  196. package/dist/layout-bridge-XDPSO6GO.mjs +0 -1
  197. package/dist/mcp-reexport.d.mts +0 -156
  198. package/dist/mcp-reexport.d.ts +0 -156
  199. package/dist/mcp-reexport.js +0 -16
  200. package/dist/mcp-reexport.mjs +0 -16
  201. package/dist/processTemplate-MJ2PCSO5.js +0 -1
  202. package/dist/react-B0W16SV6.d.ts +0 -1330
  203. package/dist/react-D0Pn1nww.d.mts +0 -1330
  204. package/dist/react.d.mts +0 -10
  205. package/dist/react.d.ts +0 -10
  206. package/dist/react.js +0 -1
  207. package/dist/react.mjs +0 -1
  208. package/dist/registry-CH9V-IX0.d.ts +0 -165
  209. package/dist/registry-CWBKYlNW.d.mts +0 -165
  210. package/dist/types-UDsUq8D3.d.mts +0 -310
  211. package/dist/types-jbivc9Lj.d.ts +0 -310
  212. package/dist/variableDetector-CdQ7ZTzA.d.mts +0 -204
  213. package/dist/variableDetector-DsRV3A9z.d.ts +0 -204
  214. package/i18n/de.json +0 -792
  215. package/i18n/en.json +0 -792
  216. package/i18n/he.json +0 -792
  217. package/i18n/pl.json +0 -792
  218. package/i18n/pt-BR.json +0 -792
  219. package/i18n/tr.json +0 -792
  220. package/i18n/zh-CN.json +0 -792
  221. /package/dist/{chunk-YC5KZSYD.js → chunk-ESZ6JRTW.js} +0 -0
  222. /package/dist/{chunk-LVGJKS7Y.mjs → chunk-TZMMD6RR.mjs} +0 -0
  223. /package/dist/{react.css → fork.css} +0 -0
@@ -0,0 +1,535 @@
1
+ import { D as DocxInput } from './index-bw-PaozF.mjs';
2
+ export { a as DocumentAgent, b as DocxEditor, c as DocxEditorHandle, d as DocxEditorProps, e as DocxEditorRef, E as EditorMode, L as LocaleProvider, f as LocaleProviderProps, R as RenderAsyncOptions, V as VERSION, r as renderAsync, u as useTranslation } from './index-bw-PaozF.mjs';
3
+ export { E as EditorPlugin, R as RenderedDomContext } from './types-BnIs4sE7.mjs';
4
+ export { P as PluginHost } from './PluginHost-HS31VIuo.mjs';
5
+ import { D as Document } from './document-Cu2vq_wS.mjs';
6
+ import { P as Position, R as Range } from './agentApi-BzUJ_kao.mjs';
7
+ import { T as TextFormatting, P as ParagraphFormatting } from './content-REFGFfEH.mjs';
8
+ export { B as BorderSpec, L as LineSpacingRule, N as NumberFormat, a as ParagraphAlignment, b as TableBorders, c as TableCellFormatting } from './content-REFGFfEH.mjs';
9
+ export { L as LocaleStrings, P as PartialLocaleStrings, T as TranslationKey, a as Translations } from './types-BF48VxkC.mjs';
10
+ import 'react';
11
+ import 'prosemirror-view';
12
+ import 'prosemirror-state';
13
+ import './types-DIsDCwTG.mjs';
14
+ import 'react/jsx-runtime';
15
+ import 'prosemirror-model';
16
+ import '@eigenpal/docx-editor-i18n/en.json';
17
+
18
+ /**
19
+ * Selection Tracker Plugin
20
+ *
21
+ * Tracks selection changes and emits events for toolbar state updates.
22
+ * Provides the current selection context including:
23
+ * - Text formatting at cursor/selection
24
+ * - Paragraph formatting
25
+ * - Selection range information
26
+ */
27
+
28
+ /**
29
+ * Selection context for toolbar state
30
+ */
31
+ interface SelectionContext {
32
+ /** Whether there's a non-collapsed selection */
33
+ hasSelection: boolean;
34
+ /** Whether selection spans multiple paragraphs */
35
+ isMultiParagraph: boolean;
36
+ /** Current text formatting at cursor/selection */
37
+ textFormatting: TextFormatting;
38
+ /** Current paragraph formatting */
39
+ paragraphFormatting: ParagraphFormatting;
40
+ /** Start paragraph index */
41
+ startParagraphIndex: number;
42
+ /** End paragraph index */
43
+ endParagraphIndex: number;
44
+ /** Whether cursor is in a list */
45
+ inList: boolean;
46
+ /** List type if in list */
47
+ listType?: 'bullet' | 'numbered';
48
+ /** List level (0-8) */
49
+ listLevel?: number;
50
+ /** Active comment IDs at cursor position */
51
+ activeCommentIds: number[];
52
+ /** Whether cursor is inside a tracked insertion */
53
+ inInsertion: boolean;
54
+ /** Whether cursor is inside a tracked deletion */
55
+ inDeletion: boolean;
56
+ }
57
+
58
+ /**
59
+ * Main Parser Orchestrator - Unified parseDocx function
60
+ *
61
+ * Coordinates all sub-parsers to produce a complete Document model.
62
+ * Handles loading order, dependency resolution, and font preloading.
63
+ *
64
+ * Parsing order:
65
+ * 1. Unzip DOCX package
66
+ * 2. Parse relationships
67
+ * 3. Parse theme (needed for style color/font resolution)
68
+ * 4. Parse styles (depends on theme)
69
+ * 5. Parse numbering
70
+ * 6. Parse document body (depends on styles, theme, numbering, rels)
71
+ * 7. Parse headers/footers (depends on styles, theme, numbering, rels)
72
+ * 8. Parse footnotes/endnotes (depends on styles, theme, numbering, rels)
73
+ * 9. Extract and load fonts
74
+ * 10. Build media file map
75
+ * 11. Assemble final Document
76
+ */
77
+
78
+ /**
79
+ * Progress callback for tracking parsing stages
80
+ */
81
+ type ProgressCallback = (stage: string, percent: number) => void;
82
+ /**
83
+ * Parsing options
84
+ */
85
+ interface ParseOptions {
86
+ /** Progress callback for tracking parsing stages */
87
+ onProgress?: ProgressCallback;
88
+ /** Whether to preload fonts (default: true) */
89
+ preloadFonts?: boolean;
90
+ /** Whether to parse headers/footers (default: true) */
91
+ parseHeadersFooters?: boolean;
92
+ /** Whether to parse footnotes/endnotes (default: true) */
93
+ parseNotes?: boolean;
94
+ /** Whether to detect template variables (default: true) */
95
+ detectVariables?: boolean;
96
+ }
97
+ /**
98
+ * Parse a DOCX file into a complete Document model
99
+ *
100
+ * @param input - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
101
+ * @param options - Parsing options
102
+ * @returns Promise resolving to Document
103
+ * @throws Error if parsing fails
104
+ */
105
+ declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
106
+
107
+ /**
108
+ * Core Plugin System Types
109
+ *
110
+ * Defines the interfaces for headless plugins that work in Node.js
111
+ * without React/DOM dependencies. These plugins extend DocumentAgent
112
+ * with additional commands and expose MCP tools for AI integration.
113
+ */
114
+
115
+ /**
116
+ * Core plugin interface - headless, works in Node.js
117
+ *
118
+ * Plugins can:
119
+ * - Register command handlers that DocumentAgent dispatches to
120
+ * - Declare MCP tools that the MCP server exposes to AI clients
121
+ * - Have optional initialization logic
122
+ * - Declare dependencies on other plugins
123
+ */
124
+ interface CorePlugin {
125
+ /** Unique plugin identifier */
126
+ id: string;
127
+ /** Human-readable plugin name */
128
+ name: string;
129
+ /** Plugin version (semver) */
130
+ version?: string;
131
+ /** Plugin description */
132
+ description?: string;
133
+ /**
134
+ * Command handlers this plugin provides.
135
+ * DocumentAgent dispatches commands to these handlers.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * commandHandlers: {
140
+ * 'insertTemplateVariable': (doc, cmd) => {
141
+ * // Transform document
142
+ * return modifiedDoc;
143
+ * },
144
+ * }
145
+ * ```
146
+ */
147
+ commandHandlers?: Record<string, CommandHandler>;
148
+ /**
149
+ * MCP tools this plugin exposes.
150
+ * MCP server collects these from all plugins.
151
+ */
152
+ mcpTools?: McpToolDefinition[];
153
+ /**
154
+ * Optional setup when plugin is registered.
155
+ * Called once during plugin registration.
156
+ */
157
+ initialize?: () => void | Promise<void>;
158
+ /**
159
+ * Optional cleanup when plugin is unregistered.
160
+ */
161
+ destroy?: () => void | Promise<void>;
162
+ /**
163
+ * Dependencies on other plugins (by ID).
164
+ * The registry ensures dependencies are loaded first.
165
+ */
166
+ dependencies?: string[];
167
+ }
168
+ /**
169
+ * Command handler function type
170
+ *
171
+ * Receives a document and a command, returns a modified document.
172
+ * Must be pure/immutable - always return a new document.
173
+ */
174
+ type CommandHandler = (doc: Document, command: PluginCommand) => Document;
175
+ /**
176
+ * Extended command type for plugins
177
+ *
178
+ * Plugins can define custom command types beyond the built-in AgentCommand types.
179
+ */
180
+ interface PluginCommand {
181
+ /** Command type identifier */
182
+ type: string;
183
+ /** Unique command ID (for undo tracking) */
184
+ id?: string;
185
+ /** Position for positional commands */
186
+ position?: Position;
187
+ /** Range for range-based commands */
188
+ range?: Range;
189
+ /** Additional command-specific data */
190
+ [key: string]: unknown;
191
+ }
192
+ /**
193
+ * MCP tool definition
194
+ *
195
+ * Describes a tool that can be called by AI clients through the MCP server.
196
+ */
197
+ interface McpToolDefinition {
198
+ /** Tool name (used in MCP protocol) */
199
+ name: string;
200
+ /** Human-readable description for AI */
201
+ description: string;
202
+ /**
203
+ * JSON Schema for tool input validation.
204
+ * Can be a Zod schema or plain JSON Schema object.
205
+ */
206
+ inputSchema: JsonSchema | ZodSchemaLike;
207
+ /**
208
+ * Handler function for the tool.
209
+ * Receives validated input and returns a result.
210
+ */
211
+ handler: McpToolHandler;
212
+ /**
213
+ * Optional annotations for the tool
214
+ */
215
+ annotations?: McpToolAnnotations;
216
+ }
217
+ /**
218
+ * MCP tool handler function
219
+ */
220
+ type McpToolHandler = (input: unknown, context: McpToolContext) => Promise<McpToolResult> | McpToolResult;
221
+ /**
222
+ * Context passed to MCP tool handlers
223
+ */
224
+ interface McpToolContext {
225
+ /** Current document (if loaded) */
226
+ document?: Document;
227
+ /** Document buffer (if loaded) */
228
+ documentBuffer?: ArrayBuffer;
229
+ /** Session state */
230
+ session: McpSession;
231
+ /** Logger for debugging */
232
+ log: (message: string, data?: unknown) => void;
233
+ }
234
+ /**
235
+ * MCP session state
236
+ *
237
+ * Maintains state across tool calls within a session.
238
+ */
239
+ interface McpSession {
240
+ /** Session ID */
241
+ id: string;
242
+ /** Loaded documents by ID */
243
+ documents: Map<string, LoadedDocument>;
244
+ /** Custom session data */
245
+ data: Map<string, unknown>;
246
+ }
247
+ /**
248
+ * A loaded document in the session
249
+ */
250
+ interface LoadedDocument {
251
+ /** Document ID */
252
+ id: string;
253
+ /** Parsed document */
254
+ document: Document;
255
+ /** Original buffer (for repacking) */
256
+ buffer?: ArrayBuffer;
257
+ /** Source filename or path */
258
+ source?: string;
259
+ /** Last modified timestamp */
260
+ lastModified: number;
261
+ }
262
+ /**
263
+ * MCP tool result
264
+ */
265
+ interface McpToolResult {
266
+ /** Result content */
267
+ content: McpToolContent[];
268
+ /** Whether this is an error result */
269
+ isError?: boolean;
270
+ }
271
+ /**
272
+ * MCP tool content types
273
+ */
274
+ type McpToolContent = {
275
+ type: 'text';
276
+ text: string;
277
+ } | {
278
+ type: 'image';
279
+ data: string;
280
+ mimeType: string;
281
+ } | {
282
+ type: 'resource';
283
+ uri: string;
284
+ mimeType?: string;
285
+ text?: string;
286
+ };
287
+ /**
288
+ * MCP tool annotations
289
+ */
290
+ interface McpToolAnnotations {
291
+ /** Tool category for organization */
292
+ category?: string;
293
+ /** Whether this tool modifies the document */
294
+ readOnly?: boolean;
295
+ /** Estimated cost/complexity */
296
+ complexity?: 'low' | 'medium' | 'high';
297
+ /** Example usage */
298
+ examples?: McpToolExample[];
299
+ }
300
+ /**
301
+ * MCP tool example
302
+ */
303
+ interface McpToolExample {
304
+ /** Example description */
305
+ description: string;
306
+ /** Example input */
307
+ input: unknown;
308
+ /** Expected output description */
309
+ output?: string;
310
+ }
311
+ /**
312
+ * JSON Schema definition (subset)
313
+ */
314
+ interface JsonSchema {
315
+ type?: string | string[];
316
+ properties?: Record<string, JsonSchema>;
317
+ items?: JsonSchema;
318
+ required?: string[];
319
+ description?: string;
320
+ enum?: unknown[];
321
+ default?: unknown;
322
+ minimum?: number;
323
+ maximum?: number;
324
+ minLength?: number;
325
+ maxLength?: number;
326
+ pattern?: string;
327
+ format?: string;
328
+ additionalProperties?: boolean | JsonSchema;
329
+ anyOf?: JsonSchema[];
330
+ oneOf?: JsonSchema[];
331
+ allOf?: JsonSchema[];
332
+ $ref?: string;
333
+ }
334
+ /**
335
+ * Zod-like schema interface for compatibility
336
+ */
337
+ interface ZodSchemaLike {
338
+ _def?: unknown;
339
+ parse?: (data: unknown) => unknown;
340
+ safeParse?: (data: unknown) => {
341
+ success: boolean;
342
+ data?: unknown;
343
+ error?: unknown;
344
+ };
345
+ }
346
+ /**
347
+ * Plugin lifecycle events
348
+ */
349
+ type PluginEvent = {
350
+ type: 'registered';
351
+ plugin: CorePlugin;
352
+ } | {
353
+ type: 'unregistered';
354
+ pluginId: string;
355
+ } | {
356
+ type: 'error';
357
+ pluginId: string;
358
+ error: Error;
359
+ };
360
+ /**
361
+ * Plugin event listener
362
+ */
363
+ type PluginEventListener = (event: PluginEvent) => void;
364
+ /**
365
+ * Plugin configuration options
366
+ */
367
+ interface PluginOptions {
368
+ /** Enable debug logging */
369
+ debug?: boolean;
370
+ /** Custom configuration */
371
+ config?: Record<string, unknown>;
372
+ }
373
+ /**
374
+ * Result of plugin registration
375
+ */
376
+ interface PluginRegistrationResult {
377
+ /** Whether registration succeeded */
378
+ success: boolean;
379
+ /** Registered plugin (if successful) */
380
+ plugin?: CorePlugin;
381
+ /** Error message (if failed) */
382
+ error?: string;
383
+ /** Warning messages */
384
+ warnings?: string[];
385
+ }
386
+
387
+ /**
388
+ * Plugin Registry
389
+ *
390
+ * Central registry for core plugins. Manages plugin lifecycle,
391
+ * collects command handlers from all plugins, and aggregates
392
+ * MCP tool definitions for the MCP server.
393
+ */
394
+
395
+ /**
396
+ * Plugin Registry - manages core plugins
397
+ *
398
+ * @example
399
+ * ```ts
400
+ * import { pluginRegistry, docxtemplaterPlugin } from '@eigenpal/docx-editor/core-plugins';
401
+ *
402
+ * // Register plugins
403
+ * pluginRegistry.register(docxtemplaterPlugin);
404
+ *
405
+ * // Get all MCP tools for MCP server
406
+ * const tools = pluginRegistry.getMcpTools();
407
+ *
408
+ * // Get command handler for executor
409
+ * const handler = pluginRegistry.getCommandHandler('insertTemplateVariable');
410
+ * ```
411
+ */
412
+ declare class PluginRegistry {
413
+ private plugins;
414
+ private commandHandlers;
415
+ private eventListeners;
416
+ private initialized;
417
+ /**
418
+ * Register a plugin
419
+ *
420
+ * @param plugin - The plugin to register
421
+ * @param options - Optional configuration
422
+ * @returns Registration result
423
+ */
424
+ register(plugin: CorePlugin, options?: PluginOptions): PluginRegistrationResult;
425
+ /**
426
+ * Unregister a plugin
427
+ *
428
+ * @param pluginId - ID of the plugin to unregister
429
+ * @returns Whether unregistration succeeded
430
+ */
431
+ unregister(pluginId: string): boolean;
432
+ /**
433
+ * Get a registered plugin by ID
434
+ *
435
+ * @param id - Plugin ID
436
+ * @returns The plugin or undefined
437
+ */
438
+ get(id: string): CorePlugin | undefined;
439
+ /**
440
+ * Get all registered plugins
441
+ *
442
+ * @returns Array of all plugins
443
+ */
444
+ getAll(): CorePlugin[];
445
+ /**
446
+ * Check if a plugin is registered
447
+ *
448
+ * @param id - Plugin ID
449
+ * @returns Whether the plugin is registered
450
+ */
451
+ has(id: string): boolean;
452
+ /**
453
+ * Get number of registered plugins
454
+ */
455
+ get size(): number;
456
+ /**
457
+ * Get a command handler for a command type
458
+ *
459
+ * @param commandType - The command type
460
+ * @returns The handler or undefined
461
+ */
462
+ getCommandHandler(commandType: string): CommandHandler | undefined;
463
+ /**
464
+ * Get all registered command types
465
+ *
466
+ * @returns Array of command type strings
467
+ */
468
+ getCommandTypes(): string[];
469
+ /**
470
+ * Check if a command type has a handler
471
+ *
472
+ * @param commandType - The command type
473
+ * @returns Whether a handler exists
474
+ */
475
+ hasCommandHandler(commandType: string): boolean;
476
+ /**
477
+ * Get all MCP tools from all registered plugins
478
+ *
479
+ * @returns Array of MCP tool definitions
480
+ */
481
+ getMcpTools(): McpToolDefinition[];
482
+ /**
483
+ * Get MCP tools from a specific plugin
484
+ *
485
+ * @param pluginId - Plugin ID
486
+ * @returns Array of MCP tool definitions
487
+ */
488
+ getMcpToolsForPlugin(pluginId: string): McpToolDefinition[];
489
+ /**
490
+ * Get an MCP tool by name
491
+ *
492
+ * @param toolName - Tool name
493
+ * @returns The tool definition or undefined
494
+ */
495
+ getMcpTool(toolName: string): McpToolDefinition | undefined;
496
+ /**
497
+ * Add an event listener
498
+ *
499
+ * @param listener - Event listener function
500
+ */
501
+ addEventListener(listener: PluginEventListener): void;
502
+ /**
503
+ * Remove an event listener
504
+ *
505
+ * @param listener - Event listener function
506
+ */
507
+ removeEventListener(listener: PluginEventListener): void;
508
+ /**
509
+ * Emit an event to all listeners
510
+ */
511
+ private emit;
512
+ /**
513
+ * Clear all registered plugins
514
+ *
515
+ * Useful for testing or resetting state.
516
+ */
517
+ clear(): void;
518
+ /**
519
+ * Get registry state for debugging
520
+ */
521
+ getDebugInfo(): {
522
+ plugins: string[];
523
+ commandTypes: string[];
524
+ mcpTools: string[];
525
+ initialized: string[];
526
+ };
527
+ }
528
+ /**
529
+ * Global plugin registry instance
530
+ *
531
+ * Use this for registering plugins and accessing their capabilities.
532
+ */
533
+ declare const pluginRegistry: PluginRegistry;
534
+
535
+ export { Document, Position, Range, type SelectionContext, TextFormatting, parseDocx, pluginRegistry };