@zeke-02/docx-editor 0.5.3 → 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 (65) hide show
  1. package/dist/{KeyboardShortcutsDialog-5D_FoAp6.d.ts → KeyboardShortcutsDialog-B0UFuR4w.d.ts} +2 -2
  2. package/dist/{KeyboardShortcutsDialog-D7ihAj18.d.mts → KeyboardShortcutsDialog-t6JKL4Aj.d.mts} +2 -2
  3. package/dist/PageSetupDialog-642IAVG2.js +1 -1
  4. package/dist/PageSetupDialog-ERUQDHAY.mjs +1 -1
  5. package/dist/PluginHost-HS31VIuo.d.mts +16 -0
  6. package/dist/PluginHost-zILZO7zX.d.ts +16 -0
  7. package/dist/{agentApi-D4AZmNfB.d.ts → agentApi-B2Y7kexW.d.ts} +1 -1
  8. package/dist/{agentApi-C41hiW-n.d.mts → agentApi-BzUJ_kao.d.mts} +1 -1
  9. package/dist/{chunk-E6MQXELR.js → chunk-HXDMASAR.js} +1 -1
  10. package/dist/chunk-JFRDFK7V.mjs +260 -0
  11. package/dist/{chunk-LUJ6HCMH.mjs → chunk-LWOHVYKW.mjs} +1 -1
  12. package/dist/chunk-MDTA25AN.mjs +60 -0
  13. package/dist/chunk-NOLMVQNN.mjs +40 -0
  14. package/dist/chunk-SGTUE33R.js +260 -0
  15. package/dist/chunk-WO3FIV4B.js +40 -0
  16. package/dist/{chunk-ONNHQWAX.mjs → chunk-XGJ2EORY.mjs} +1 -1
  17. package/dist/{chunk-AYMGSTNG.js → chunk-Y3SEHWZ2.js} +1 -1
  18. package/dist/chunk-YBEVHQCT.js +60 -0
  19. package/dist/{content-B2MzIMwA.d.mts → content-REFGFfEH.d.mts} +1 -1
  20. package/dist/{content-B2MzIMwA.d.ts → content-REFGFfEH.d.ts} +1 -1
  21. package/dist/dialogs.d.mts +4 -4
  22. package/dist/dialogs.d.ts +4 -4
  23. package/dist/dialogs.js +1 -1
  24. package/dist/dialogs.mjs +1 -1
  25. package/dist/{document-Di1qGqLS.d.mts → document-Cu2vq_wS.d.mts} +1 -1
  26. package/dist/{document-DZ_ZeZEH.d.ts → document-CxOagoLQ.d.ts} +1 -1
  27. package/dist/executor-WBHID2RK.mjs +1 -0
  28. package/dist/{executor-EPEB53SJ.js → executor-Y5VUOAHY.js} +1 -1
  29. package/dist/{findReplace-pkMskVJU.d.ts → findReplace-Bue0JaXh.d.ts} +1 -1
  30. package/dist/{findReplace-CpIoILbP.d.mts → findReplace-shXbOjFQ.d.mts} +1 -1
  31. package/dist/fork.css +1 -0
  32. package/dist/fork.d.mts +535 -0
  33. package/dist/fork.d.ts +535 -0
  34. package/dist/fork.js +1 -0
  35. package/dist/fork.mjs +1 -0
  36. package/dist/hooks.d.mts +6 -6
  37. package/dist/hooks.d.ts +6 -6
  38. package/dist/hooks.js +1 -1
  39. package/dist/hooks.mjs +1 -1
  40. package/dist/index-B5A-J9GC.d.ts +1119 -0
  41. package/dist/index-bw-PaozF.d.mts +1119 -0
  42. package/dist/index.d.mts +11 -1120
  43. package/dist/index.d.ts +11 -1120
  44. package/dist/index.js +1 -40
  45. package/dist/index.mjs +1 -40
  46. package/dist/plugin-api.d.mts +5 -16
  47. package/dist/plugin-api.d.ts +5 -16
  48. package/dist/plugin-api.js +1 -260
  49. package/dist/plugin-api.mjs +1 -260
  50. package/dist/{types-DZUhB7Ao.d.mts → types-BF48VxkC.d.mts} +1 -1
  51. package/dist/{types-DZUhB7Ao.d.ts → types-BF48VxkC.d.ts} +1 -1
  52. package/dist/{types-Bd_YzkhG.d.mts → types-BnIs4sE7.d.mts} +1 -1
  53. package/dist/{types-Bd_YzkhG.d.ts → types-BnIs4sE7.d.ts} +1 -1
  54. package/dist/{types-DcxHFUSc.d.ts → types-CW6HFAX6.d.ts} +1 -1
  55. package/dist/{types-CkfDgB0O.d.mts → types-DIsDCwTG.d.mts} +1 -1
  56. package/dist/ui.d.mts +9 -9
  57. package/dist/ui.d.ts +9 -9
  58. package/dist/ui.js +1 -1
  59. package/dist/ui.mjs +1 -1
  60. package/dist/{useFindReplace-eyhMSZZf.d.ts → useFindReplace-DKy-s3gS.d.ts} +2 -2
  61. package/dist/{useFindReplace-DDs533b-.d.mts → useFindReplace-vuoKpDKE.d.mts} +2 -2
  62. package/package.json +7 -7
  63. package/dist/chunk-47VJOBJD.mjs +0 -60
  64. package/dist/chunk-IP5NAYHL.js +0 -60
  65. package/dist/executor-TVJ6K6MW.mjs +0 -1
package/dist/fork.d.ts ADDED
@@ -0,0 +1,535 @@
1
+ import { D as DocxInput } from './index-B5A-J9GC.js';
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-B5A-J9GC.js';
3
+ export { E as EditorPlugin, R as RenderedDomContext } from './types-BnIs4sE7.js';
4
+ export { P as PluginHost } from './PluginHost-zILZO7zX.js';
5
+ import { D as Document } from './document-CxOagoLQ.js';
6
+ import { P as Position, R as Range } from './agentApi-B2Y7kexW.js';
7
+ import { T as TextFormatting, P as ParagraphFormatting } from './content-REFGFfEH.js';
8
+ export { B as BorderSpec, L as LineSpacingRule, N as NumberFormat, a as ParagraphAlignment, b as TableBorders, c as TableCellFormatting } from './content-REFGFfEH.js';
9
+ export { L as LocaleStrings, P as PartialLocaleStrings, T as TranslationKey, a as Translations } from './types-BF48VxkC.js';
10
+ import 'react';
11
+ import 'prosemirror-view';
12
+ import 'prosemirror-state';
13
+ import './types-CW6HFAX6.js';
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 };
package/dist/fork.js ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var chunkWO3FIV4B_js=require('./chunk-WO3FIV4B.js');require('./chunk-AW5TISUL.js'),require('./chunk-TYPGB4KF.js'),require('./chunk-SNZ57XBI.js'),require('./chunk-Y3SEHWZ2.js'),require('./chunk-BRMTZRLJ.js'),require('./chunk-MKNSJOCN.js'),require('./chunk-35DG3R42.js');var chunkNLFXR2VH_js=require('./chunk-NLFXR2VH.js'),chunkSGTUE33R_js=require('./chunk-SGTUE33R.js');require('./chunk-2XXILKEQ.js');var chunkYBEVHQCT_js=require('./chunk-YBEVHQCT.js'),chunkHXDMASAR_js=require('./chunk-HXDMASAR.js');require('./chunk-IFPN3NT3.js'),require('./chunk-B45ECEGY.js'),require('./chunk-GGQK26JO.js'),require('./chunk-ZXPCJWVY.js'),require('./chunk-ILYKDR3C.js'),require('./chunk-ESZ6JRTW.js'),require('./chunk-H5NTJZO4.js');Object.defineProperty(exports,"DocxEditor",{enumerable:true,get:function(){return chunkWO3FIV4B_js.a}});Object.defineProperty(exports,"VERSION",{enumerable:true,get:function(){return chunkWO3FIV4B_js.c}});Object.defineProperty(exports,"renderAsync",{enumerable:true,get:function(){return chunkWO3FIV4B_js.b}});Object.defineProperty(exports,"LocaleProvider",{enumerable:true,get:function(){return chunkNLFXR2VH_js.b}});Object.defineProperty(exports,"useTranslation",{enumerable:true,get:function(){return chunkNLFXR2VH_js.c}});Object.defineProperty(exports,"PluginHost",{enumerable:true,get:function(){return chunkSGTUE33R_js.b}});Object.defineProperty(exports,"DocumentAgent",{enumerable:true,get:function(){return chunkYBEVHQCT_js.b}});Object.defineProperty(exports,"parseDocx",{enumerable:true,get:function(){return chunkYBEVHQCT_js.a}});Object.defineProperty(exports,"pluginRegistry",{enumerable:true,get:function(){return chunkHXDMASAR_js.a}});
package/dist/fork.mjs ADDED
@@ -0,0 +1 @@
1
+ export{a as DocxEditor,c as VERSION,b as renderAsync}from'./chunk-NOLMVQNN.mjs';import'./chunk-ZVAFVHWR.mjs';import'./chunk-JPF5R2ZM.mjs';import'./chunk-WPI3YRFO.mjs';import'./chunk-LWOHVYKW.mjs';import'./chunk-U7ZW2DOO.mjs';import'./chunk-RCIZ7OM3.mjs';import'./chunk-F5SERL7X.mjs';export{b as LocaleProvider,c as useTranslation}from'./chunk-7QQSDIWK.mjs';export{b as PluginHost}from'./chunk-JFRDFK7V.mjs';import'./chunk-KOXCF3CL.mjs';export{b as DocumentAgent,a as parseDocx}from'./chunk-MDTA25AN.mjs';export{a as pluginRegistry}from'./chunk-XGJ2EORY.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-XQZTWWRF.mjs';import'./chunk-B7CCL7SL.mjs';import'./chunk-ONIYA2FU.mjs';import'./chunk-FWPVBFKQ.mjs';import'./chunk-TZMMD6RR.mjs';import'./chunk-TAUMSKRE.mjs';
package/dist/hooks.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { D as Document, T as Theme } from './document-Di1qGqLS.mjs';
2
- import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-DDs533b-.mjs';
3
- export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-DDs533b-.mjs';
4
- import { R as Run, d as Table } from './content-B2MzIMwA.mjs';
1
+ import { D as Document, T as Theme } from './document-Cu2vq_wS.mjs';
2
+ import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-vuoKpDKE.mjs';
3
+ export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-vuoKpDKE.mjs';
4
+ import { R as Run, f as Table } from './content-REFGFfEH.mjs';
5
5
  import * as React$1 from 'react';
6
6
  import React__default, { CSSProperties as CSSProperties$1, RefObject } from 'react';
7
- import { P as ParsedClipboardContent } from './findReplace-CpIoILbP.mjs';
8
- import { A as AutoSaveStatus, S as SavedDocumentData } from './types-CkfDgB0O.mjs';
7
+ import { P as ParsedClipboardContent } from './findReplace-shXbOjFQ.mjs';
8
+ import { A as AutoSaveStatus, S as SavedDocumentData } from './types-DIsDCwTG.mjs';
9
9
  import { EditorView } from 'prosemirror-view';
10
10
 
11
11
  /**
package/dist/hooks.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { D as Document, T as Theme } from './document-DZ_ZeZEH.js';
2
- import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-eyhMSZZf.js';
3
- export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-eyhMSZZf.js';
4
- import { R as Run, d as Table } from './content-B2MzIMwA.js';
1
+ import { D as Document, T as Theme } from './document-CxOagoLQ.js';
2
+ import { b as TableContext, T as TableAction, d as TableSplitConfig } from './useFindReplace-DKy-s3gS.js';
3
+ export { F as FindReplaceOptions, a as FindReplaceState, U as UseFindReplaceReturn, u as useFindReplace } from './useFindReplace-DKy-s3gS.js';
4
+ import { R as Run, f as Table } from './content-REFGFfEH.js';
5
5
  import * as React$1 from 'react';
6
6
  import React__default, { CSSProperties as CSSProperties$1, RefObject } from 'react';
7
- import { P as ParsedClipboardContent } from './findReplace-pkMskVJU.js';
8
- import { A as AutoSaveStatus, S as SavedDocumentData } from './types-DcxHFUSc.js';
7
+ import { P as ParsedClipboardContent } from './findReplace-Bue0JaXh.js';
8
+ import { A as AutoSaveStatus, S as SavedDocumentData } from './types-CW6HFAX6.js';
9
9
  import { EditorView } from 'prosemirror-view';
10
10
 
11
11
  /**
package/dist/hooks.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkAYMGSTNG_js=require('./chunk-AYMGSTNG.js'),chunkNIBCC7WQ_js=require('./chunk-NIBCC7WQ.js'),chunkBRMTZRLJ_js=require('./chunk-BRMTZRLJ.js'),chunkMKNSJOCN_js=require('./chunk-MKNSJOCN.js'),chunk35DG3R42_js=require('./chunk-35DG3R42.js');require('./chunk-NLFXR2VH.js');var chunkIP5NAYHL_js=require('./chunk-IP5NAYHL.js');require('./chunk-IFPN3NT3.js'),require('./chunk-B45ECEGY.js'),require('./chunk-GGQK26JO.js');var chunkZXPCJWVY_js=require('./chunk-ZXPCJWVY.js');require('./chunk-ESZ6JRTW.js'),require('./chunk-E6MQXELR.js'),require('./chunk-ILYKDR3C.js'),require('./chunk-H5NTJZO4.js');var he=require('react');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var he__default=/*#__PURE__*/_interopDefault(he);function ve(n){let{containerRef:e,enabled:r=true,config:s=chunkMKNSJOCN_js.a,useOverlay:c=false,debounceMs:u=16,onSelectionChange:f}=n,[S,p]=he.useState(false),[x,v]=he.useState(""),[a,m]=he.useState([]),[d,y]=he.useState(false),h=he.useRef(null),C=he.useRef(0),o=he.useCallback(()=>{let t=e.current,b=chunkMKNSJOCN_js.c(),D=chunkMKNSJOCN_js.d(),U=t?chunkMKNSJOCN_js.e(t):false;if(p(b),v(D),y(U),c&&U){let ae=chunkMKNSJOCN_js.b(t);m(ae);}else m([]);f&&f(b&&U,D);},[e,c,f]),i=he.useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=he.useCallback(()=>{o();},[o]),R=he.useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return he.useEffect(()=>(r&&!chunkMKNSJOCN_js.g()&&chunkMKNSJOCN_js.f(s),()=>{}),[r,s]),he.useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a,isSelectionInContainer:d,refresh:l,getOverlayStyle:R}}function ge(n,e=chunkMKNSJOCN_js.a){return n.map((r,s)=>he__default.default.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p=he.useRef(false),x=he.useRef(null),v=he.useCallback(async o=>{if(p.current)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p.current=false;}},[e,f,S]),a=he.useCallback(async o=>{if(p.current||!u)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p.current=false;}},[r,u,f,S]),m=he.useCallback(async(o=false)=>{if(p.current||!u)return null;p.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=chunkZXPCJWVY_js.k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p.current=false;}},[u,c,s,f]),d=he.useCallback(o=>{let i=chunkIP5NAYHL_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=he.useCallback(o=>{if(!u)return;let i=chunkIP5NAYHL_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h=he.useCallback(o=>{if(!u)return;o.preventDefault();let i=chunkZXPCJWVY_js.j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=he.useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h,handleKeyDown:C,isProcessing:p.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=he.useMemo(()=>new chunkIP5NAYHL_js.d({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);he.useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),he.useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),he.useEffect(()=>()=>{a.destroy();},[a]);let m=he.useSyncExternalStore(a.subscribe,a.getSnapshot),d=he.useCallback(()=>a.save(),[a]),y=he.useCallback(()=>a.clear(),[a]),h=he.useCallback(()=>a.getRecoveryData(),[a]),C=he.useCallback(()=>a.acceptRecovery(),[a]),o=he.useCallback(()=>a.dismissRecovery(),[a]),i=he.useCallback(()=>a.enable(),[a]),l=he.useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=he.useState(e),m=he.useRef(v);he.useEffect(()=>{m.current=v;},[v]);let d=he.useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=he.useCallback(()=>{d(m.current+c);},[c,d]),h=he.useCallback(()=>{d(m.current-c);},[c,d]),C=he.useCallback(()=>{d(e);},[e,d]),o=he.useCallback(()=>{d(1);},[d]),i=he.useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=he.useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=he.useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return he.useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),he.useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}Object.defineProperty(exports,"HistoryManager",{enumerable:true,get:function(){return chunkAYMGSTNG_js.e}});Object.defineProperty(exports,"useAutoHistory",{enumerable:true,get:function(){return chunkAYMGSTNG_js.c}});Object.defineProperty(exports,"useDocumentHistory",{enumerable:true,get:function(){return chunkAYMGSTNG_js.d}});Object.defineProperty(exports,"useDragAutoScroll",{enumerable:true,get:function(){return chunkAYMGSTNG_js.h}});Object.defineProperty(exports,"useHistory",{enumerable:true,get:function(){return chunkAYMGSTNG_js.b}});Object.defineProperty(exports,"useTableSelection",{enumerable:true,get:function(){return chunkAYMGSTNG_js.a}});Object.defineProperty(exports,"useVisualLineNavigation",{enumerable:true,get:function(){return chunkAYMGSTNG_js.g}});Object.defineProperty(exports,"useAspectLockedSize",{enumerable:true,get:function(){return chunkNIBCC7WQ_js.a}});Object.defineProperty(exports,"useFixedDropdown",{enumerable:true,get:function(){return chunkBRMTZRLJ_js.c}});Object.defineProperty(exports,"useFindReplace",{enumerable:true,get:function(){return chunk35DG3R42_js.m}});Object.defineProperty(exports,"TABLE_DATA_ATTRIBUTES",{enumerable:true,get:function(){return chunkIP5NAYHL_js.j}});Object.defineProperty(exports,"createSelectionFromDOM",{enumerable:true,get:function(){return chunkIP5NAYHL_js.p}});Object.defineProperty(exports,"formatLastSaveTime",{enumerable:true,get:function(){return chunkIP5NAYHL_js.e}});Object.defineProperty(exports,"formatStorageSize",{enumerable:true,get:function(){return chunkIP5NAYHL_js.h}});Object.defineProperty(exports,"getAutoSaveStatusLabel",{enumerable:true,get:function(){return chunkIP5NAYHL_js.f}});Object.defineProperty(exports,"getAutoSaveStorageSize",{enumerable:true,get:function(){return chunkIP5NAYHL_js.g}});Object.defineProperty(exports,"getSelectionRuns",{enumerable:true,get:function(){return chunkIP5NAYHL_js.o}});Object.defineProperty(exports,"isAutoSaveSupported",{enumerable:true,get:function(){return chunkIP5NAYHL_js.i}});exports.ZOOM_PRESETS=g;exports.clampZoom=Ie;exports.findNearestZoomPreset=He;exports.formatZoom=ze;exports.generateOverlayElements=ge;exports.getNextZoomPreset=we;exports.getPreviousZoomPreset=Le;exports.getZoomPresets=Me;exports.isZoomPreset=ke;exports.parseZoom=Fe;exports.useAutoSave=Re;exports.useClipboard=xe;exports.useSelectionHighlight=ve;exports.useWheelZoom=Ue;
1
+ 'use strict';var chunkY3SEHWZ2_js=require('./chunk-Y3SEHWZ2.js'),chunkNIBCC7WQ_js=require('./chunk-NIBCC7WQ.js'),chunkBRMTZRLJ_js=require('./chunk-BRMTZRLJ.js'),chunkMKNSJOCN_js=require('./chunk-MKNSJOCN.js'),chunk35DG3R42_js=require('./chunk-35DG3R42.js');require('./chunk-NLFXR2VH.js');var chunkYBEVHQCT_js=require('./chunk-YBEVHQCT.js');require('./chunk-HXDMASAR.js'),require('./chunk-IFPN3NT3.js'),require('./chunk-B45ECEGY.js'),require('./chunk-GGQK26JO.js');var chunkZXPCJWVY_js=require('./chunk-ZXPCJWVY.js');require('./chunk-ILYKDR3C.js'),require('./chunk-ESZ6JRTW.js'),require('./chunk-H5NTJZO4.js');var he=require('react');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var he__default=/*#__PURE__*/_interopDefault(he);function ve(n){let{containerRef:e,enabled:r=true,config:s=chunkMKNSJOCN_js.a,useOverlay:c=false,debounceMs:u=16,onSelectionChange:f}=n,[S,p]=he.useState(false),[x,v]=he.useState(""),[a,m]=he.useState([]),[d,y]=he.useState(false),h=he.useRef(null),C=he.useRef(0),o=he.useCallback(()=>{let t=e.current,b=chunkMKNSJOCN_js.c(),D=chunkMKNSJOCN_js.d(),U=t?chunkMKNSJOCN_js.e(t):false;if(p(b),v(D),y(U),c&&U){let ae=chunkMKNSJOCN_js.b(t);m(ae);}else m([]);f&&f(b&&U,D);},[e,c,f]),i=he.useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=he.useCallback(()=>{o();},[o]),R=he.useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return he.useEffect(()=>(r&&!chunkMKNSJOCN_js.g()&&chunkMKNSJOCN_js.f(s),()=>{}),[r,s]),he.useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a,isSelectionInContainer:d,refresh:l,getOverlayStyle:R}}function ge(n,e=chunkMKNSJOCN_js.a){return n.map((r,s)=>he__default.default.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p=he.useRef(false),x=he.useRef(null),v=he.useCallback(async o=>{if(p.current)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p.current=false;}},[e,f,S]),a=he.useCallback(async o=>{if(p.current||!u)return false;p.current=true;try{let i=await chunkZXPCJWVY_js.g(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p.current=false;}},[r,u,f,S]),m=he.useCallback(async(o=false)=>{if(p.current||!u)return null;p.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=chunkZXPCJWVY_js.k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p.current=false;}},[u,c,s,f]),d=he.useCallback(o=>{let i=chunkYBEVHQCT_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=he.useCallback(o=>{if(!u)return;let i=chunkYBEVHQCT_js.p();if(!i)return;o.preventDefault();let l=chunkZXPCJWVY_js.h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h=he.useCallback(o=>{if(!u)return;o.preventDefault();let i=chunkZXPCJWVY_js.j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=he.useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h,handleKeyDown:C,isProcessing:p.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=he.useMemo(()=>new chunkYBEVHQCT_js.d({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);he.useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),he.useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),he.useEffect(()=>()=>{a.destroy();},[a]);let m=he.useSyncExternalStore(a.subscribe,a.getSnapshot),d=he.useCallback(()=>a.save(),[a]),y=he.useCallback(()=>a.clear(),[a]),h=he.useCallback(()=>a.getRecoveryData(),[a]),C=he.useCallback(()=>a.acceptRecovery(),[a]),o=he.useCallback(()=>a.dismissRecovery(),[a]),i=he.useCallback(()=>a.enable(),[a]),l=he.useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=he.useState(e),m=he.useRef(v);he.useEffect(()=>{m.current=v;},[v]);let d=he.useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=he.useCallback(()=>{d(m.current+c);},[c,d]),h=he.useCallback(()=>{d(m.current-c);},[c,d]),C=he.useCallback(()=>{d(e);},[e,d]),o=he.useCallback(()=>{d(1);},[d]),i=he.useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=he.useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=he.useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return he.useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),he.useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}Object.defineProperty(exports,"HistoryManager",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.e}});Object.defineProperty(exports,"useAutoHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.c}});Object.defineProperty(exports,"useDocumentHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.d}});Object.defineProperty(exports,"useDragAutoScroll",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.h}});Object.defineProperty(exports,"useHistory",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.b}});Object.defineProperty(exports,"useTableSelection",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.a}});Object.defineProperty(exports,"useVisualLineNavigation",{enumerable:true,get:function(){return chunkY3SEHWZ2_js.g}});Object.defineProperty(exports,"useAspectLockedSize",{enumerable:true,get:function(){return chunkNIBCC7WQ_js.a}});Object.defineProperty(exports,"useFixedDropdown",{enumerable:true,get:function(){return chunkBRMTZRLJ_js.c}});Object.defineProperty(exports,"useFindReplace",{enumerable:true,get:function(){return chunk35DG3R42_js.m}});Object.defineProperty(exports,"TABLE_DATA_ATTRIBUTES",{enumerable:true,get:function(){return chunkYBEVHQCT_js.j}});Object.defineProperty(exports,"createSelectionFromDOM",{enumerable:true,get:function(){return chunkYBEVHQCT_js.p}});Object.defineProperty(exports,"formatLastSaveTime",{enumerable:true,get:function(){return chunkYBEVHQCT_js.e}});Object.defineProperty(exports,"formatStorageSize",{enumerable:true,get:function(){return chunkYBEVHQCT_js.h}});Object.defineProperty(exports,"getAutoSaveStatusLabel",{enumerable:true,get:function(){return chunkYBEVHQCT_js.f}});Object.defineProperty(exports,"getAutoSaveStorageSize",{enumerable:true,get:function(){return chunkYBEVHQCT_js.g}});Object.defineProperty(exports,"getSelectionRuns",{enumerable:true,get:function(){return chunkYBEVHQCT_js.o}});Object.defineProperty(exports,"isAutoSaveSupported",{enumerable:true,get:function(){return chunkYBEVHQCT_js.i}});exports.ZOOM_PRESETS=g;exports.clampZoom=Ie;exports.findNearestZoomPreset=He;exports.formatZoom=ze;exports.generateOverlayElements=ge;exports.getNextZoomPreset=we;exports.getPreviousZoomPreset=Le;exports.getZoomPresets=Me;exports.isZoomPreset=ke;exports.parseZoom=Fe;exports.useAutoSave=Re;exports.useClipboard=xe;exports.useSelectionHighlight=ve;exports.useWheelZoom=Ue;
package/dist/hooks.mjs CHANGED
@@ -1 +1 @@
1
- export{e as HistoryManager,c as useAutoHistory,d as useDocumentHistory,h as useDragAutoScroll,b as useHistory,a as useTableSelection,g as useVisualLineNavigation}from'./chunk-LUJ6HCMH.mjs';export{a as useAspectLockedSize}from'./chunk-GM2S2WMT.mjs';export{c as useFixedDropdown}from'./chunk-U7ZW2DOO.mjs';import {a,c,d,e,b,g as g$1,f}from'./chunk-RCIZ7OM3.mjs';export{m as useFindReplace}from'./chunk-F5SERL7X.mjs';import'./chunk-7QQSDIWK.mjs';import {p,d as d$1}from'./chunk-47VJOBJD.mjs';export{j as TABLE_DATA_ATTRIBUTES,p as createSelectionFromDOM,e as formatLastSaveTime,h as formatStorageSize,f as getAutoSaveStatusLabel,g as getAutoSaveStorageSize,o as getSelectionRuns,i as isAutoSaveSupported}from'./chunk-47VJOBJD.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-XQZTWWRF.mjs';import'./chunk-B7CCL7SL.mjs';import {g as g$2,k,h,j}from'./chunk-ONIYA2FU.mjs';import'./chunk-TZMMD6RR.mjs';import'./chunk-ONNHQWAX.mjs';import'./chunk-FWPVBFKQ.mjs';import'./chunk-TAUMSKRE.mjs';import he,{useState,useRef,useCallback,useEffect,useMemo,useSyncExternalStore}from'react';function ve(n){let{containerRef:e$1,enabled:r=true,config:s=a,useOverlay:c$1=false,debounceMs:u=16,onSelectionChange:f$1}=n,[S,p]=useState(false),[x,v]=useState(""),[a$1,m]=useState([]),[d$1,y]=useState(false),h=useRef(null),C=useRef(0),o=useCallback(()=>{let t=e$1.current,b$1=c(),D=d(),U=t?e(t):false;if(p(b$1),v(D),y(U),c$1&&U){let ae=b(t);m(ae);}else m([]);f$1&&f$1(b$1&&U,D);},[e$1,c$1,f$1]),i=useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=useCallback(()=>{o();},[o]),R=useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return useEffect(()=>(r&&!g$1()&&f(s),()=>{}),[r,s]),useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a$1,isSelectionInContainer:d$1,refresh:l,getOverlayStyle:R}}function ge(n,e=a){return n.map((r,s)=>he.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p$1=useRef(false),x=useRef(null),v=useCallback(async o=>{if(p$1.current)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p$1.current=false;}},[e,f,S]),a=useCallback(async o=>{if(p$1.current||!u)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p$1.current=false;}},[r,u,f,S]),m=useCallback(async(o=false)=>{if(p$1.current||!u)return null;p$1.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p$1.current=false;}},[u,c,s,f]),d=useCallback(o=>{let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=useCallback(o=>{if(!u)return;let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h$1=useCallback(o=>{if(!u)return;o.preventDefault();let i=j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h$1,handleKeyDown:C,isProcessing:p$1.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=useMemo(()=>new d$1({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),useEffect(()=>()=>{a.destroy();},[a]);let m=useSyncExternalStore(a.subscribe,a.getSnapshot),d=useCallback(()=>a.save(),[a]),y=useCallback(()=>a.clear(),[a]),h=useCallback(()=>a.getRecoveryData(),[a]),C=useCallback(()=>a.acceptRecovery(),[a]),o=useCallback(()=>a.dismissRecovery(),[a]),i=useCallback(()=>a.enable(),[a]),l=useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=useState(e),m=useRef(v);useEffect(()=>{m.current=v;},[v]);let d=useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=useCallback(()=>{d(m.current+c);},[c,d]),h=useCallback(()=>{d(m.current-c);},[c,d]),C=useCallback(()=>{d(e);},[e,d]),o=useCallback(()=>{d(1);},[d]),i=useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}export{g as ZOOM_PRESETS,Ie as clampZoom,He as findNearestZoomPreset,ze as formatZoom,ge as generateOverlayElements,we as getNextZoomPreset,Le as getPreviousZoomPreset,Me as getZoomPresets,ke as isZoomPreset,Fe as parseZoom,Re as useAutoSave,xe as useClipboard,ve as useSelectionHighlight,Ue as useWheelZoom};
1
+ export{e as HistoryManager,c as useAutoHistory,d as useDocumentHistory,h as useDragAutoScroll,b as useHistory,a as useTableSelection,g as useVisualLineNavigation}from'./chunk-LWOHVYKW.mjs';export{a as useAspectLockedSize}from'./chunk-GM2S2WMT.mjs';export{c as useFixedDropdown}from'./chunk-U7ZW2DOO.mjs';import {a,c,d,e,b,g as g$1,f}from'./chunk-RCIZ7OM3.mjs';export{m as useFindReplace}from'./chunk-F5SERL7X.mjs';import'./chunk-7QQSDIWK.mjs';import {p,d as d$1}from'./chunk-MDTA25AN.mjs';export{j as TABLE_DATA_ATTRIBUTES,p as createSelectionFromDOM,e as formatLastSaveTime,h as formatStorageSize,f as getAutoSaveStatusLabel,g as getAutoSaveStorageSize,o as getSelectionRuns,i as isAutoSaveSupported}from'./chunk-MDTA25AN.mjs';import'./chunk-XGJ2EORY.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-XQZTWWRF.mjs';import'./chunk-B7CCL7SL.mjs';import {g as g$2,k,h,j}from'./chunk-ONIYA2FU.mjs';import'./chunk-FWPVBFKQ.mjs';import'./chunk-TZMMD6RR.mjs';import'./chunk-TAUMSKRE.mjs';import he,{useState,useRef,useCallback,useEffect,useMemo,useSyncExternalStore}from'react';function ve(n){let{containerRef:e$1,enabled:r=true,config:s=a,useOverlay:c$1=false,debounceMs:u=16,onSelectionChange:f$1}=n,[S,p]=useState(false),[x,v]=useState(""),[a$1,m]=useState([]),[d$1,y]=useState(false),h=useRef(null),C=useRef(0),o=useCallback(()=>{let t=e$1.current,b$1=c(),D=d(),U=t?e(t):false;if(p(b$1),v(D),y(U),c$1&&U){let ae=b(t);m(ae);}else m([]);f$1&&f$1(b$1&&U,D);},[e$1,c$1,f$1]),i=useCallback(()=>{let t=performance.now();if(t-C.current<u){h.current!==null&&clearTimeout(h.current),h.current=window.setTimeout(()=>{C.current=performance.now(),o(),h.current=null;},u);return}C.current=t,o();},[u,o]),l=useCallback(()=>{o();},[o]),R=useCallback(t=>({position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:s.backgroundColor,borderRadius:s.borderRadius?`${s.borderRadius}px`:void 0,border:s.borderColor?`1px solid ${s.borderColor}`:void 0,zIndex:s.zIndex??0,opacity:s.opacity??1,mixBlendMode:s.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[s]);return useEffect(()=>(r&&!g$1()&&f(s),()=>{}),[r,s]),useEffect(()=>{if(!r)return;let t=()=>{i();};return document.addEventListener("selectionchange",t),document.addEventListener("mouseup",t),o(),()=>{document.removeEventListener("selectionchange",t),document.removeEventListener("mouseup",t),h.current!==null&&clearTimeout(h.current);}},[r,i,o]),{hasSelection:S,selectedText:x,highlightRects:a$1,isSelectionInContainer:d$1,refresh:l,getOverlayStyle:R}}function ge(n,e=a){return n.map((r,s)=>he.createElement("div",{key:`selection-overlay-${s}`,style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,backgroundColor:e.backgroundColor,borderRadius:e.borderRadius?`${e.borderRadius}px`:void 0,border:e.borderColor?`1px solid ${e.borderColor}`:void 0,zIndex:e.zIndex??0,opacity:e.opacity??1,mixBlendMode:e.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function xe(n={}){let{onCopy:e,onCut:r,onPaste:s,cleanWordFormatting:c=true,editable:u=true,onError:f,theme:S}=n,p$1=useRef(false),x=useRef(null),v=useCallback(async o=>{if(p$1.current)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&e?.(o),i}finally{p$1.current=false;}},[e,f,S]),a=useCallback(async o=>{if(p$1.current||!u)return false;p$1.current=true;try{let i=await g$2(o.runs,{onError:f,theme:S});return i&&r?.(o),i}finally{p$1.current=false;}},[r,u,f,S]),m=useCallback(async(o=false)=>{if(p$1.current||!u)return null;p$1.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),l="",R="";for(let b of i)b.types.includes("text/html")&&(l=await(await b.getType("text/html")).text()),b.types.includes("text/plain")&&(R=await(await b.getType("text/plain")).text());o&&(l="");let t=k(l,R,c);return x.current=t,s?.(t,o),t}return null}catch(i){return f?.(i),null}finally{p$1.current=false;}},[u,c,s,f]),d=useCallback(o=>{let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),e?.(i);},[e,S]),y=useCallback(o=>{if(!u)return;let i=p();if(!i)return;o.preventDefault();let l=h(i.runs,true,S);o.clipboardData&&(o.clipboardData.setData("text/plain",l.plainText),o.clipboardData.setData("text/html",l.html),l.internal&&o.clipboardData.setData("application/x-docx-editor",l.internal)),r?.(i);},[u,r,S]),h$1=useCallback(o=>{if(!u)return;o.preventDefault();let i=j(o,{cleanWordFormatting:c});if(i){x.current=i;let l=o.shiftKey??false;s?.(i,l);}},[u,c,s]),C=useCallback(o=>{},[]);return {copy:v,cut:a,paste:m,handleCopy:d,handleCut:y,handlePaste:h$1,handleKeyDown:C,isProcessing:p$1.current,lastPastedContent:x.current}}function Re(n,e={}){let{storageKey:r,interval:s,enabled:c=true,maxAge:u,onSave:f,onError:S,onRecoveryAvailable:p,saveOnChange:x,debounceDelay:v}=e,a=useMemo(()=>new d$1({storageKey:r,interval:s,maxAge:u,saveOnChange:x,debounceDelay:v,onSave:f,onError:S,onRecoveryAvailable:p}),[r]);useEffect(()=>{c?(a.enable(),a.startInterval()):a.disable();},[a,c]),useEffect(()=>{a.onDocumentChanged(n??null);},[a,n]),useEffect(()=>()=>{a.destroy();},[a]);let m=useSyncExternalStore(a.subscribe,a.getSnapshot),d=useCallback(()=>a.save(),[a]),y=useCallback(()=>a.clear(),[a]),h=useCallback(()=>a.getRecoveryData(),[a]),C=useCallback(()=>a.acceptRecovery(),[a]),o=useCallback(()=>a.dismissRecovery(),[a]),i=useCallback(()=>a.enable(),[a]),l=useCallback(()=>a.disable(),[a]);return {status:m.status,lastSaveTime:m.lastSaveTime,save:d,clearAutoSave:y,hasRecoveryData:m.hasRecoveryData,getRecoveryData:h,acceptRecovery:C,dismissRecovery:o,isEnabled:m.isEnabled,enable:i,disable:l}}var Oe=1,te=.25,oe=4,Pe=.1,g=[.25,.5,.75,1,1.25,1.5,2,3,4];function ne(n,e,r){return Math.max(e,Math.min(r,n))}function re(n){return Math.round(n*100)/100}function Ze(n){let e=g[0],r=Math.abs(n-e);for(let s of g){let c=Math.abs(n-s);c<r&&(r=c,e=s);}return e}function Te(n){for(let e of g)if(e>n+.01)return e;return g[g.length-1]}function Ae(n){for(let e=g.length-1;e>=0;e--)if(g[e]<n-.01)return g[e];return g[0]}function Ue(n={}){let{initialZoom:e=Oe,minZoom:r=te,maxZoom:s=oe,zoomStep:c=Pe,enabled:u=true,containerRef:f,onZoomChange:S,enableKeyboardShortcuts:p=true,preventDefault:x=true}=n,[v,a]=useState(e),m=useRef(v);useEffect(()=>{m.current=v;},[v]);let d=useCallback(t=>{let b=re(ne(t,r,s));b!==m.current&&(a(b),S?.(b));},[r,s,S]),y=useCallback(()=>{d(m.current+c);},[c,d]),h=useCallback(()=>{d(m.current-c);},[c,d]),C=useCallback(()=>{d(e);},[e,d]),o=useCallback(()=>{d(1);},[d]),i=useCallback((t,b)=>{if(b>0){let D=t/b;d(D);}},[d]),l=useCallback(t=>{if(!u||!(t.ctrlKey||t.metaKey))return;x&&t.preventDefault();let D=t.deltaY;D<0?d(m.current+c):D>0&&d(m.current-c);},[u,x,c,d]),R=useCallback(t=>{if(!(!u||!p||!(t.ctrlKey||t.metaKey))){if(t.key==="0"){t.preventDefault(),o();return}if(t.key==="+"||t.key==="="){t.preventDefault(),y();return}if(t.key==="-"){t.preventDefault(),h();return}}},[u,p,y,h,o]);return useEffect(()=>{if(!u)return;let t=f?.current;if(t)return t.addEventListener("wheel",l,{passive:false}),()=>{t.removeEventListener("wheel",l);}},[u,f,l]),useEffect(()=>{if(!(!u||!p))return document.addEventListener("keydown",R),()=>{document.removeEventListener("keydown",R);}},[u,p,R]),{zoom:v,setZoom:d,zoomIn:y,zoomOut:h,resetZoom:C,zoomTo100:o,zoomToFit:i,isMinZoom:v<=r,isMaxZoom:v>=s,zoomPercent:Math.round(v*100),handleWheel:l,handleKeyDown:R}}function Me(){return [...g]}function He(n){return Ze(n)}function we(n){return Te(n)}function Le(n){return Ae(n)}function ze(n){return `${Math.round(n*100)}%`}function Fe(n){let e=n.match(/(\d+(\.\d+)?)/);if(e){let r=parseFloat(e[1]);if(!isNaN(r))return r/100}return null}function ke(n){return g.some(e=>Math.abs(e-n)<.01)}function Ie(n,e=te,r=oe){return re(ne(n,e,r))}export{g as ZOOM_PRESETS,Ie as clampZoom,He as findNearestZoomPreset,ze as formatZoom,ge as generateOverlayElements,we as getNextZoomPreset,Le as getPreviousZoomPreset,Me as getZoomPresets,ke as isZoomPreset,Fe as parseZoom,Re as useAutoSave,xe as useClipboard,ve as useSelectionHighlight,Ue as useWheelZoom};