@eigenpal/docx-js-editor 0.0.16 → 0.0.17
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.
- package/dist/FindReplaceDialog-K4GRE4JB.cjs +2 -0
- package/dist/FindReplaceDialog-K4GRE4JB.cjs.map +1 -0
- package/dist/{FindReplaceDialog-UMXCBBST.js → FindReplaceDialog-MMDEJORP.js} +2 -1
- package/dist/FindReplaceDialog-MMDEJORP.js.map +1 -0
- package/dist/{FootnotePropertiesDialog-TYQGPWPX.js → FootnotePropertiesDialog-HG4267LR.js} +2 -1
- package/dist/FootnotePropertiesDialog-HG4267LR.js.map +1 -0
- package/dist/{FootnotePropertiesDialog-OBQXOBJE.cjs → FootnotePropertiesDialog-V3YOIJCV.cjs} +2 -1
- package/dist/FootnotePropertiesDialog-V3YOIJCV.cjs.map +1 -0
- package/dist/{HyperlinkDialog-UOERZIBM.js → HyperlinkDialog-SCSX4RP7.js} +2 -1
- package/dist/HyperlinkDialog-SCSX4RP7.js.map +1 -0
- package/dist/HyperlinkDialog-YPKURBZK.cjs +2 -0
- package/dist/HyperlinkDialog-YPKURBZK.cjs.map +1 -0
- package/dist/{ImagePositionDialog-52FDANUK.js → ImagePositionDialog-CJYJ35PI.js} +2 -1
- package/dist/ImagePositionDialog-CJYJ35PI.js.map +1 -0
- package/dist/{ImagePositionDialog-ZK5WFBRC.cjs → ImagePositionDialog-IMVI7EXA.cjs} +2 -1
- package/dist/ImagePositionDialog-IMVI7EXA.cjs.map +1 -0
- package/dist/{ImagePropertiesDialog-YPSLPSF6.js → ImagePropertiesDialog-P7WN2ALR.js} +2 -1
- package/dist/ImagePropertiesDialog-P7WN2ALR.js.map +1 -0
- package/dist/{ImagePropertiesDialog-LU44RDIY.cjs → ImagePropertiesDialog-YS4KJRN7.cjs} +2 -1
- package/dist/ImagePropertiesDialog-YS4KJRN7.cjs.map +1 -0
- package/dist/{TablePropertiesDialog-KMOYHPGF.cjs → TablePropertiesDialog-CUQXUBQN.cjs} +2 -1
- package/dist/TablePropertiesDialog-CUQXUBQN.cjs.map +1 -0
- package/dist/{TablePropertiesDialog-OUUJAA7D.js → TablePropertiesDialog-ZHAYVHPZ.js} +2 -1
- package/dist/TablePropertiesDialog-ZHAYVHPZ.js.map +1 -0
- package/dist/{clipboard-BOocwmAM.d.ts → TableToolbar-RHX9L4h9.d.cts} +2 -125
- package/dist/{clipboard-Cx7cb3kX.d.cts → TableToolbar-RHX9L4h9.d.ts} +2 -125
- package/dist/chunk-7FEY3YWC.cjs +3 -0
- package/dist/chunk-7FEY3YWC.cjs.map +1 -0
- package/dist/chunk-AL62KQYJ.js +2 -0
- package/dist/chunk-AL62KQYJ.js.map +1 -0
- package/dist/{chunk-VTAS7VZ6.cjs → chunk-DJAEBZ33.cjs} +2 -1
- package/dist/chunk-DJAEBZ33.cjs.map +1 -0
- package/dist/{chunk-CTYOM6BE.js → chunk-M2T6XKT5.js} +2 -1
- package/dist/chunk-M2T6XKT5.js.map +1 -0
- package/dist/chunk-MXGYESPA.cjs +178 -0
- package/dist/chunk-MXGYESPA.cjs.map +1 -0
- package/dist/chunk-NMYD4OJZ.js +3 -0
- package/dist/chunk-NMYD4OJZ.js.map +1 -0
- package/dist/chunk-OD33FUTO.js +178 -0
- package/dist/chunk-OD33FUTO.js.map +1 -0
- package/dist/{chunk-PJVI53AH.js → chunk-Q6HUGWO6.js} +2 -1
- package/dist/chunk-Q6HUGWO6.js.map +1 -0
- package/dist/{chunk-XS2AQFMF.cjs → chunk-S26DZVRQ.cjs} +2 -1
- package/dist/chunk-S26DZVRQ.cjs.map +1 -0
- package/dist/chunk-V3MCDVZE.cjs +2 -0
- package/dist/chunk-V3MCDVZE.cjs.map +1 -0
- package/dist/{chunk-MLSHZVL7.js → chunk-VIEW4NAF.js} +6 -5
- package/dist/chunk-VIEW4NAF.js.map +1 -0
- package/dist/{chunk-OEOUMSWH.cjs → chunk-ZX4CSEL3.cjs} +6 -5
- package/dist/chunk-ZX4CSEL3.cjs.map +1 -0
- package/dist/core-plugins-reexport.cjs +2 -0
- package/dist/core-plugins-reexport.cjs.map +1 -0
- package/dist/core-plugins-reexport.d.cts +1 -0
- package/dist/core-plugins-reexport.d.ts +1 -0
- package/dist/core-plugins-reexport.js +2 -0
- package/dist/core-plugins-reexport.js.map +1 -0
- package/dist/core-reexport.cjs +2 -0
- package/dist/core-reexport.cjs.map +1 -0
- package/dist/core-reexport.d.cts +4 -0
- package/dist/core-reexport.d.ts +4 -0
- package/dist/core-reexport.js +2 -0
- package/dist/core-reexport.js.map +1 -0
- package/dist/headless-reexport.cjs +2 -0
- package/dist/headless-reexport.cjs.map +1 -0
- package/dist/headless-reexport.d.cts +1 -0
- package/dist/headless-reexport.d.ts +1 -0
- package/dist/headless-reexport.js +2 -0
- package/dist/headless-reexport.js.map +1 -0
- package/dist/index.cjs +10 -9
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -257
- package/dist/index.d.ts +28 -257
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -0
- package/dist/mcp-reexport.cjs +2 -0
- package/dist/mcp-reexport.cjs.map +1 -0
- package/dist/mcp-reexport.d.cts +1 -0
- package/dist/mcp-reexport.d.ts +1 -0
- package/dist/mcp-reexport.js +2 -0
- package/dist/mcp-reexport.js.map +1 -0
- package/dist/react.cjs +2 -1
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +860 -9
- package/dist/react.d.ts +860 -9
- package/dist/react.js +2 -1
- package/dist/react.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/ui.cjs +2 -1
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +5 -3
- package/dist/ui.d.ts +5 -3
- package/dist/ui.js +2 -1
- package/dist/ui.js.map +1 -0
- package/package.json +27 -87
- package/LICENSE +0 -21
- package/README.md +0 -171
- package/dist/DocumentAgent-Ci6_T-XM.d.ts +0 -412
- package/dist/DocumentAgent-DEGFgYEN.d.cts +0 -412
- package/dist/FindReplaceDialog-46BE7Q2G.cjs +0 -1
- package/dist/HyperlinkDialog-22NH7ZLP.cjs +0 -1
- package/dist/agentApi-CbVUCZRu.d.cts +0 -2086
- package/dist/agentApi-CbVUCZRu.d.ts +0 -2086
- package/dist/chunk-24N3L4IL.cjs +0 -258
- package/dist/chunk-2ASOEN3V.js +0 -1
- package/dist/chunk-46OFHSPJ.cjs +0 -2
- package/dist/chunk-65OFYOHF.cjs +0 -58
- package/dist/chunk-6YFGCUHU.js +0 -4
- package/dist/chunk-DYQUXFE5.cjs +0 -1
- package/dist/chunk-EMKABJPH.js +0 -1
- package/dist/chunk-ESI4BSBF.js +0 -1
- package/dist/chunk-FYAWM7MP.cjs +0 -1
- package/dist/chunk-GLFFXY2X.js +0 -258
- package/dist/chunk-ITWEFKGQ.cjs +0 -1
- package/dist/chunk-JKN7TNPA.js +0 -12
- package/dist/chunk-KESNGXGO.js +0 -1
- package/dist/chunk-L34XFLQZ.cjs +0 -1
- package/dist/chunk-NO7WUK5E.cjs +0 -12
- package/dist/chunk-NT2REEAA.cjs +0 -1
- package/dist/chunk-O7QVCJN6.cjs +0 -4
- package/dist/chunk-OW5H5DNE.cjs +0 -1
- package/dist/chunk-OWMXCVKB.js +0 -1
- package/dist/chunk-PXC7ARQB.cjs +0 -1
- package/dist/chunk-R5SKERM2.js +0 -1
- package/dist/chunk-RM3ITJ2H.cjs +0 -10
- package/dist/chunk-SF53KLDZ.cjs +0 -1
- package/dist/chunk-TOI5W3HK.js +0 -8
- package/dist/chunk-UAVOWAIF.cjs +0 -8
- package/dist/chunk-ULNHBTYA.js +0 -2
- package/dist/chunk-UXXV4GT6.js +0 -10
- package/dist/chunk-VOWKSURW.cjs +0 -1
- package/dist/chunk-WFWLPKQA.js +0 -1
- package/dist/chunk-WFYRA2TH.js +0 -1
- package/dist/chunk-YMXKVLTU.js +0 -58
- package/dist/chunk-ZDYHAYN6.js +0 -1
- package/dist/colorResolver-CIDiSPWd.d.cts +0 -618
- package/dist/colorResolver-KXbUgzWC.d.ts +0 -618
- package/dist/core-plugins.cjs +0 -1
- package/dist/core-plugins.d.cts +0 -31
- package/dist/core-plugins.d.ts +0 -31
- package/dist/core-plugins.js +0 -1
- package/dist/core.cjs +0 -1
- package/dist/core.d.cts +0 -23
- package/dist/core.d.ts +0 -23
- package/dist/core.js +0 -1
- package/dist/executor-ITYZTNSH.cjs +0 -1
- package/dist/executor-TC7CLATE.js +0 -1
- package/dist/headless.cjs +0 -4
- package/dist/headless.d.cts +0 -195
- package/dist/headless.d.ts +0 -195
- package/dist/headless.js +0 -4
- package/dist/index.css +0 -1
- package/dist/insertOperations-CzB5b-Of.d.ts +0 -176
- package/dist/insertOperations-DKVmCV32.d.cts +0 -176
- package/dist/mcp-cli.js +0 -136
- package/dist/mcp.cjs +0 -16
- package/dist/mcp.d.cts +0 -156
- package/dist/mcp.d.ts +0 -156
- package/dist/mcp.js +0 -16
- package/dist/processTemplate-525HZL4S.cjs +0 -1
- package/dist/processTemplate-RJN6452W.js +0 -1
- package/dist/react-BZxD04XV.d.ts +0 -1350
- package/dist/react-D8eAYckC.d.cts +0 -1350
- package/dist/react.css +0 -1
- package/dist/registry-D4tvj9f3.d.ts +0 -165
- package/dist/registry-ngv6Bumt.d.cts +0 -165
- package/dist/selectionRects-PQEUEW35.cjs +0 -1
- package/dist/selectionRects-QAG5RSHD.js +0 -1
- package/dist/types-D96elyJF.d.cts +0 -310
- package/dist/types-xMzSPT4i.d.ts +0 -310
- package/dist/variableDetector-CPxKo9jP.d.cts +0 -173
- package/dist/variableDetector-DeM1N-_L.d.ts +0 -173
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,860 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import 'prosemirror-view';
|
|
5
|
-
import 'prosemirror-state';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode, CSSProperties, Component, ErrorInfo } from 'react';
|
|
3
|
+
import * as prosemirror_view from 'prosemirror-view';
|
|
4
|
+
import { EditorView } from 'prosemirror-view';
|
|
5
|
+
import * as prosemirror_state from 'prosemirror-state';
|
|
6
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
7
|
+
import { Document, Theme, Table, Run } from '@eigenpal/docx-core/types/document';
|
|
8
|
+
import { P as PageIndicatorPosition, c as PageNavigatorPosition, a as PageIndicatorVariant, e as PageNavigatorVariant, j as PrintOptions, l as TableContext, T as TableAction } from './TableToolbar-RHX9L4h9.js';
|
|
9
|
+
import { DocumentAgent } from '@eigenpal/docx-core/agent/DocumentAgent';
|
|
10
|
+
import { DocxInput } from '@eigenpal/docx-core/utils/docxInput';
|
|
11
|
+
export { DocxInput, toArrayBuffer } from '@eigenpal/docx-core/utils/docxInput';
|
|
12
|
+
import { SelectionState } from '@eigenpal/docx-core/prosemirror';
|
|
13
|
+
import { Layout } from '@eigenpal/docx-core/layout-engine/types';
|
|
14
|
+
import { EditorPluginCore, PluginPanelProps, RenderedDomContext } from '@eigenpal/docx-core/plugin-api/types';
|
|
15
|
+
export { PanelConfig, PluginPanelProps } from '@eigenpal/docx-core/plugin-api/types';
|
|
16
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
17
|
+
import { ParsedClipboardContent } from '@eigenpal/docx-core/utils/clipboard';
|
|
18
|
+
import { HighlightRect, SelectionHighlightConfig } from '@eigenpal/docx-core/utils/selectionHighlight';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* React Plugin Interface for the DOCX Editor
|
|
22
|
+
*
|
|
23
|
+
* Extends the framework-agnostic EditorPluginCore with React-specific
|
|
24
|
+
* UI rendering capabilities (Panel component, renderOverlay).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* React-specific editor plugin interface.
|
|
29
|
+
*
|
|
30
|
+
* Extends EditorPluginCore with:
|
|
31
|
+
* - Panel: React component for rendering in the annotation panel
|
|
32
|
+
* - renderOverlay: Function returning ReactNode for overlay rendering
|
|
33
|
+
*/
|
|
34
|
+
interface ReactEditorPlugin<TState = any> extends EditorPluginCore<TState> {
|
|
35
|
+
/**
|
|
36
|
+
* React component to render in the annotation panel area.
|
|
37
|
+
* Receives editor state and callbacks for interaction.
|
|
38
|
+
*/
|
|
39
|
+
Panel?: React.ComponentType<PluginPanelProps<TState>>;
|
|
40
|
+
/**
|
|
41
|
+
* Render an overlay on top of the rendered pages.
|
|
42
|
+
* Use this for highlights, annotations, or other visual elements
|
|
43
|
+
* that need to be positioned relative to the document content.
|
|
44
|
+
*
|
|
45
|
+
* @param context - The rendered DOM context for position lookup
|
|
46
|
+
* @param state - Current plugin state
|
|
47
|
+
* @param editorView - The editor view for dispatching transactions
|
|
48
|
+
* @returns React node to render as overlay, or null
|
|
49
|
+
*/
|
|
50
|
+
renderOverlay?: (context: RenderedDomContext, state: TState, editorView: EditorView | null) => ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Backwards-compatible alias — EditorPlugin is now ReactEditorPlugin.
|
|
54
|
+
*/
|
|
55
|
+
type EditorPlugin<TState = any> = ReactEditorPlugin<TState>;
|
|
56
|
+
/**
|
|
57
|
+
* Context value provided to plugins and panels.
|
|
58
|
+
*/
|
|
59
|
+
interface PluginContext {
|
|
60
|
+
/** All registered plugins */
|
|
61
|
+
plugins: EditorPlugin[];
|
|
62
|
+
/** Current editor view */
|
|
63
|
+
editorView: EditorView | null;
|
|
64
|
+
/** Set the editor view (called by editor on mount) */
|
|
65
|
+
setEditorView: (view: EditorView | null) => void;
|
|
66
|
+
/** Get plugin state by plugin ID */
|
|
67
|
+
getPluginState: <T>(pluginId: string) => T | undefined;
|
|
68
|
+
/** Update plugin state */
|
|
69
|
+
setPluginState: <T>(pluginId: string, state: T) => void;
|
|
70
|
+
/** Scroll to a position in the editor */
|
|
71
|
+
scrollToPosition: (pos: number) => void;
|
|
72
|
+
/** Select a range in the editor */
|
|
73
|
+
selectRange: (from: number, to: number) => void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Props for the PluginHost component.
|
|
77
|
+
*/
|
|
78
|
+
interface PluginHostProps {
|
|
79
|
+
/** Plugins to enable */
|
|
80
|
+
plugins: EditorPlugin[];
|
|
81
|
+
/** The editor component (passed as child) */
|
|
82
|
+
children: React.ReactElement;
|
|
83
|
+
/** Class name for the host container */
|
|
84
|
+
className?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Ref interface for the PluginHost component.
|
|
88
|
+
*/
|
|
89
|
+
interface PluginHostRef {
|
|
90
|
+
/** Get plugin state by plugin ID */
|
|
91
|
+
getPluginState: <T>(pluginId: string) => T | undefined;
|
|
92
|
+
/** Update plugin state for a plugin */
|
|
93
|
+
setPluginState: <T>(pluginId: string, state: T) => void;
|
|
94
|
+
/** Get the current editor view */
|
|
95
|
+
getEditorView: () => EditorView | null;
|
|
96
|
+
/** Force a refresh of all plugin states */
|
|
97
|
+
refreshPluginStates: () => void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface PagedEditorRef {
|
|
101
|
+
/** Get the current document. */
|
|
102
|
+
getDocument(): Document | null;
|
|
103
|
+
/** Get the ProseMirror EditorState. */
|
|
104
|
+
getState(): EditorState | null;
|
|
105
|
+
/** Get the ProseMirror EditorView. */
|
|
106
|
+
getView(): EditorView | null;
|
|
107
|
+
/** Focus the editor. */
|
|
108
|
+
focus(): void;
|
|
109
|
+
/** Blur the editor. */
|
|
110
|
+
blur(): void;
|
|
111
|
+
/** Check if focused. */
|
|
112
|
+
isFocused(): boolean;
|
|
113
|
+
/** Dispatch a transaction. */
|
|
114
|
+
dispatch(tr: Transaction): void;
|
|
115
|
+
/** Undo. */
|
|
116
|
+
undo(): boolean;
|
|
117
|
+
/** Redo. */
|
|
118
|
+
redo(): boolean;
|
|
119
|
+
/** Set selection by PM position. */
|
|
120
|
+
setSelection(anchor: number, head?: number): void;
|
|
121
|
+
/** Get current layout. */
|
|
122
|
+
getLayout(): Layout | null;
|
|
123
|
+
/** Force re-layout. */
|
|
124
|
+
relayout(): void;
|
|
125
|
+
/** Scroll the visible pages to bring a PM position into view. */
|
|
126
|
+
scrollToPosition(pmPos: number): void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* DocxEditor props
|
|
131
|
+
*/
|
|
132
|
+
interface DocxEditorProps {
|
|
133
|
+
/** Document data — ArrayBuffer, Uint8Array, Blob, or File */
|
|
134
|
+
documentBuffer?: DocxInput | null;
|
|
135
|
+
/** Pre-parsed document (alternative to documentBuffer) */
|
|
136
|
+
document?: Document | null;
|
|
137
|
+
/** Callback when document is saved */
|
|
138
|
+
onSave?: (buffer: ArrayBuffer) => void;
|
|
139
|
+
/** Callback when document changes */
|
|
140
|
+
onChange?: (document: Document) => void;
|
|
141
|
+
/** Callback when selection changes */
|
|
142
|
+
onSelectionChange?: (state: SelectionState | null) => void;
|
|
143
|
+
/** Callback on error */
|
|
144
|
+
onError?: (error: Error) => void;
|
|
145
|
+
/** Callback when fonts are loaded */
|
|
146
|
+
onFontsLoaded?: () => void;
|
|
147
|
+
/** External ProseMirror plugins (from PluginHost) */
|
|
148
|
+
externalPlugins?: prosemirror_state.Plugin[];
|
|
149
|
+
/** Callback when editor view is ready (for PluginHost) */
|
|
150
|
+
onEditorViewReady?: (view: prosemirror_view.EditorView) => void;
|
|
151
|
+
/** Theme for styling */
|
|
152
|
+
theme?: Theme | null;
|
|
153
|
+
/** Whether to show toolbar (default: true) */
|
|
154
|
+
showToolbar?: boolean;
|
|
155
|
+
/** Whether to show zoom control (default: true) */
|
|
156
|
+
showZoomControl?: boolean;
|
|
157
|
+
/** Whether to show page number indicator (default: true) */
|
|
158
|
+
showPageNumbers?: boolean;
|
|
159
|
+
/** Whether to enable interactive page navigation (default: true) */
|
|
160
|
+
enablePageNavigation?: boolean;
|
|
161
|
+
/** Position of page number indicator (default: 'bottom-center') */
|
|
162
|
+
pageNumberPosition?: PageIndicatorPosition | PageNavigatorPosition;
|
|
163
|
+
/** Variant of page number indicator (default: 'default') */
|
|
164
|
+
pageNumberVariant?: PageIndicatorVariant | PageNavigatorVariant;
|
|
165
|
+
/** Whether to show page margin guides/boundaries (default: false) */
|
|
166
|
+
showMarginGuides?: boolean;
|
|
167
|
+
/** Color for margin guides (default: '#c0c0c0') */
|
|
168
|
+
marginGuideColor?: string;
|
|
169
|
+
/** Whether to show horizontal ruler (default: false) */
|
|
170
|
+
showRuler?: boolean;
|
|
171
|
+
/** Unit for ruler display (default: 'inch') */
|
|
172
|
+
rulerUnit?: 'inch' | 'cm';
|
|
173
|
+
/** Initial zoom level (default: 1.0) */
|
|
174
|
+
initialZoom?: number;
|
|
175
|
+
/** Whether the editor is read-only. When true, hides toolbar and rulers */
|
|
176
|
+
readOnly?: boolean;
|
|
177
|
+
/** Custom toolbar actions */
|
|
178
|
+
toolbarExtra?: ReactNode;
|
|
179
|
+
/** Additional CSS class name */
|
|
180
|
+
className?: string;
|
|
181
|
+
/** Additional inline styles */
|
|
182
|
+
style?: CSSProperties;
|
|
183
|
+
/** Placeholder when no document */
|
|
184
|
+
placeholder?: ReactNode;
|
|
185
|
+
/** Loading indicator */
|
|
186
|
+
loadingIndicator?: ReactNode;
|
|
187
|
+
/** Whether to show the document outline sidebar (default: false) */
|
|
188
|
+
showOutline?: boolean;
|
|
189
|
+
/** Whether to show print button in toolbar (default: true) */
|
|
190
|
+
showPrintButton?: boolean;
|
|
191
|
+
/** Print options for print preview */
|
|
192
|
+
printOptions?: PrintOptions;
|
|
193
|
+
/** Callback when print is triggered */
|
|
194
|
+
onPrint?: () => void;
|
|
195
|
+
/** Callback when content is copied */
|
|
196
|
+
onCopy?: () => void;
|
|
197
|
+
/** Callback when content is cut */
|
|
198
|
+
onCut?: () => void;
|
|
199
|
+
/** Callback when content is pasted */
|
|
200
|
+
onPaste?: () => void;
|
|
201
|
+
/**
|
|
202
|
+
* Callback when rendered DOM context is ready (for plugin overlays).
|
|
203
|
+
* Used by PluginHost to get access to the rendered page DOM for positioning.
|
|
204
|
+
*/
|
|
205
|
+
onRenderedDomContextReady?: (context: RenderedDomContext) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Plugin overlays to render inside the editor viewport.
|
|
208
|
+
* Passed from PluginHost to render plugin-specific overlays.
|
|
209
|
+
*/
|
|
210
|
+
pluginOverlays?: ReactNode;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* DocxEditor ref interface
|
|
214
|
+
*/
|
|
215
|
+
interface DocxEditorRef {
|
|
216
|
+
/** Get the DocumentAgent for programmatic access */
|
|
217
|
+
getAgent: () => DocumentAgent | null;
|
|
218
|
+
/** Get the current document */
|
|
219
|
+
getDocument: () => Document | null;
|
|
220
|
+
/** Get the editor ref */
|
|
221
|
+
getEditorRef: () => PagedEditorRef | null;
|
|
222
|
+
/** Save the document to buffer */
|
|
223
|
+
save: () => Promise<ArrayBuffer | null>;
|
|
224
|
+
/** Set zoom level */
|
|
225
|
+
setZoom: (zoom: number) => void;
|
|
226
|
+
/** Get current zoom level */
|
|
227
|
+
getZoom: () => number;
|
|
228
|
+
/** Focus the editor */
|
|
229
|
+
focus: () => void;
|
|
230
|
+
/** Get current page number */
|
|
231
|
+
getCurrentPage: () => number;
|
|
232
|
+
/** Get total page count */
|
|
233
|
+
getTotalPages: () => number;
|
|
234
|
+
/** Scroll to a specific page */
|
|
235
|
+
scrollToPage: (pageNumber: number) => void;
|
|
236
|
+
/** Open print preview */
|
|
237
|
+
openPrintPreview: () => void;
|
|
238
|
+
/** Print the document directly */
|
|
239
|
+
print: () => void;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* DocxEditor - Complete DOCX editor component
|
|
243
|
+
*/
|
|
244
|
+
declare const DocxEditor: React$1.ForwardRefExoticComponent<DocxEditorProps & React$1.RefAttributes<DocxEditorRef>>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Simple imperative API for rendering a DOCX editor into a DOM element.
|
|
248
|
+
*
|
|
249
|
+
* Usage:
|
|
250
|
+
* ```ts
|
|
251
|
+
* import { renderAsync } from '@eigenpal/docx-js-editor';
|
|
252
|
+
*
|
|
253
|
+
* const editor = await renderAsync(docxBlob, document.getElementById('container'), {
|
|
254
|
+
* readOnly: false,
|
|
255
|
+
* showToolbar: true,
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* // Save the edited document
|
|
259
|
+
* const buffer = await editor.save();
|
|
260
|
+
*
|
|
261
|
+
* // Clean up
|
|
262
|
+
* editor.destroy();
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Options for {@link renderAsync}. A subset of DocxEditorProps minus
|
|
268
|
+
* `documentBuffer` / `document` (passed as the first argument instead).
|
|
269
|
+
*/
|
|
270
|
+
type RenderAsyncOptions = Omit<DocxEditorProps, 'documentBuffer' | 'document'>;
|
|
271
|
+
/**
|
|
272
|
+
* Handle returned by {@link renderAsync} for interacting with the editor.
|
|
273
|
+
*/
|
|
274
|
+
interface DocxEditorHandle {
|
|
275
|
+
/** Save the document and return the DOCX as an ArrayBuffer. */
|
|
276
|
+
save: () => Promise<ArrayBuffer | null>;
|
|
277
|
+
/** Get the current parsed document model. */
|
|
278
|
+
getDocument: () => Document | null;
|
|
279
|
+
/** Focus the editor. */
|
|
280
|
+
focus: () => void;
|
|
281
|
+
/** Set zoom level (1.0 = 100%). */
|
|
282
|
+
setZoom: (zoom: number) => void;
|
|
283
|
+
/** Unmount the editor and clean up. */
|
|
284
|
+
destroy: () => void;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Render a DOCX editor into a container element.
|
|
288
|
+
*
|
|
289
|
+
* @param input - DOCX data as ArrayBuffer, Uint8Array, Blob, or File
|
|
290
|
+
* @param container - DOM element to render into
|
|
291
|
+
* @param options - Editor configuration (toolbar, readOnly, callbacks, etc.)
|
|
292
|
+
* @returns A handle with save / destroy / getDocument methods
|
|
293
|
+
*/
|
|
294
|
+
declare function renderAsync(input: DocxInput, container: HTMLElement, options?: RenderAsyncOptions): Promise<DocxEditorHandle>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Error severity levels
|
|
298
|
+
*/
|
|
299
|
+
type ErrorSeverity = 'error' | 'warning' | 'info';
|
|
300
|
+
/**
|
|
301
|
+
* Error notification
|
|
302
|
+
*/
|
|
303
|
+
interface ErrorNotification {
|
|
304
|
+
id: string;
|
|
305
|
+
message: string;
|
|
306
|
+
severity: ErrorSeverity;
|
|
307
|
+
details?: string;
|
|
308
|
+
timestamp: number;
|
|
309
|
+
dismissed?: boolean;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Error context value
|
|
313
|
+
*/
|
|
314
|
+
interface ErrorContextValue {
|
|
315
|
+
/** Current notifications */
|
|
316
|
+
notifications: ErrorNotification[];
|
|
317
|
+
/** Show an error notification */
|
|
318
|
+
showError: (message: string, details?: string) => void;
|
|
319
|
+
/** Show a warning notification */
|
|
320
|
+
showWarning: (message: string, details?: string) => void;
|
|
321
|
+
/** Show an info notification */
|
|
322
|
+
showInfo: (message: string, details?: string) => void;
|
|
323
|
+
/** Dismiss a notification */
|
|
324
|
+
dismissNotification: (id: string) => void;
|
|
325
|
+
/** Clear all notifications */
|
|
326
|
+
clearNotifications: () => void;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Error boundary props
|
|
330
|
+
*/
|
|
331
|
+
interface ErrorBoundaryProps {
|
|
332
|
+
/** Child components to render */
|
|
333
|
+
children: ReactNode;
|
|
334
|
+
/** Custom fallback UI */
|
|
335
|
+
fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);
|
|
336
|
+
/** Callback when error occurs */
|
|
337
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
338
|
+
/** Whether to show error details */
|
|
339
|
+
showDetails?: boolean;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Error boundary state
|
|
343
|
+
*/
|
|
344
|
+
interface ErrorBoundaryState {
|
|
345
|
+
hasError: boolean;
|
|
346
|
+
error: Error | null;
|
|
347
|
+
errorInfo: ErrorInfo | null;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Hook to use error notifications
|
|
351
|
+
*/
|
|
352
|
+
declare function useErrorNotifications(): ErrorContextValue;
|
|
353
|
+
/**
|
|
354
|
+
* Error notification provider
|
|
355
|
+
*/
|
|
356
|
+
declare function ErrorProvider({ children }: {
|
|
357
|
+
children: ReactNode;
|
|
358
|
+
}): react_jsx_runtime.JSX.Element;
|
|
359
|
+
/**
|
|
360
|
+
* Error Boundary class component
|
|
361
|
+
*
|
|
362
|
+
* Catches render errors in child components and displays fallback UI.
|
|
363
|
+
*/
|
|
364
|
+
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
365
|
+
constructor(props: ErrorBoundaryProps);
|
|
366
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
367
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
368
|
+
resetError: () => void;
|
|
369
|
+
render(): ReactNode;
|
|
370
|
+
}
|
|
371
|
+
interface ParseErrorDisplayProps {
|
|
372
|
+
message: string;
|
|
373
|
+
details?: string;
|
|
374
|
+
onRetry?: () => void;
|
|
375
|
+
className?: string;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Parse error display component
|
|
379
|
+
*
|
|
380
|
+
* Shows a helpful message for DOCX parsing errors.
|
|
381
|
+
*/
|
|
382
|
+
declare function ParseErrorDisplay({ message, details, onRetry, className, }: ParseErrorDisplayProps): React__default.ReactElement;
|
|
383
|
+
interface UnsupportedFeatureWarningProps {
|
|
384
|
+
feature: string;
|
|
385
|
+
description?: string;
|
|
386
|
+
className?: string;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Unsupported feature warning component
|
|
390
|
+
*
|
|
391
|
+
* Shows a non-blocking warning for unsupported features.
|
|
392
|
+
*/
|
|
393
|
+
declare function UnsupportedFeatureWarning({ feature, description, className, }: UnsupportedFeatureWarningProps): React__default.ReactElement;
|
|
394
|
+
/**
|
|
395
|
+
* Check if an error is a parse error
|
|
396
|
+
*/
|
|
397
|
+
declare function isParseError(error: Error): boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Get user-friendly error message
|
|
400
|
+
*/
|
|
401
|
+
declare function getUserFriendlyMessage(error: Error): string;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* useTableSelection Hook
|
|
405
|
+
*
|
|
406
|
+
* Tracks table selection state based on user clicks.
|
|
407
|
+
* Provides:
|
|
408
|
+
* - Current table context when clicking in a table cell
|
|
409
|
+
* - Methods to handle table actions (add row, delete column, etc.)
|
|
410
|
+
* - Clears selection when clicking outside tables
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Table selection state
|
|
415
|
+
*/
|
|
416
|
+
interface TableSelectionState {
|
|
417
|
+
/** Current table context (null if not in a table) */
|
|
418
|
+
context: TableContext | null;
|
|
419
|
+
/** The selected table */
|
|
420
|
+
table: Table | null;
|
|
421
|
+
/** Index of the table in the document */
|
|
422
|
+
tableIndex: number | null;
|
|
423
|
+
/** Row index */
|
|
424
|
+
rowIndex: number | null;
|
|
425
|
+
/** Column index */
|
|
426
|
+
columnIndex: number | null;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Return type for useTableSelection hook
|
|
430
|
+
*/
|
|
431
|
+
interface UseTableSelectionReturn {
|
|
432
|
+
/** Current table selection state */
|
|
433
|
+
state: TableSelectionState;
|
|
434
|
+
/** Handle click on a table cell */
|
|
435
|
+
handleCellClick: (tableIndex: number, rowIndex: number, columnIndex: number) => void;
|
|
436
|
+
/** Handle table action */
|
|
437
|
+
handleAction: (action: TableAction) => void;
|
|
438
|
+
/** Clear the selection */
|
|
439
|
+
clearSelection: () => void;
|
|
440
|
+
/** Check if a cell is selected */
|
|
441
|
+
isCellSelected: (tableIndex: number, rowIndex: number, columnIndex: number) => boolean;
|
|
442
|
+
/** The table context for the TableToolbar */
|
|
443
|
+
tableContext: TableContext | null;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Options for useTableSelection
|
|
447
|
+
*/
|
|
448
|
+
interface UseTableSelectionOptions {
|
|
449
|
+
/** The document being edited */
|
|
450
|
+
document: Document | null;
|
|
451
|
+
/** Callback when document changes */
|
|
452
|
+
onChange?: (document: Document) => void;
|
|
453
|
+
/** Callback when table selection changes */
|
|
454
|
+
onSelectionChange?: (context: TableContext | null) => void;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Data attributes for table elements
|
|
458
|
+
*/
|
|
459
|
+
declare const TABLE_DATA_ATTRIBUTES: {
|
|
460
|
+
/** Attribute for table index */
|
|
461
|
+
TABLE_INDEX: string;
|
|
462
|
+
/** Attribute for row index */
|
|
463
|
+
ROW_INDEX: string;
|
|
464
|
+
/** Attribute for column index */
|
|
465
|
+
COLUMN_INDEX: string;
|
|
466
|
+
/** Attribute marking a table cell */
|
|
467
|
+
TABLE_CELL: string;
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Hook for tracking and managing table selection
|
|
471
|
+
*/
|
|
472
|
+
declare function useTableSelection({ document: doc, onChange, onSelectionChange, }: UseTableSelectionOptions): UseTableSelectionReturn;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* useAutoSave Hook
|
|
476
|
+
*
|
|
477
|
+
* Automatically saves document state to localStorage at configurable intervals.
|
|
478
|
+
*
|
|
479
|
+
* Features:
|
|
480
|
+
* - Configurable save interval (default: 30 seconds)
|
|
481
|
+
* - Saves document JSON to localStorage
|
|
482
|
+
* - Recovery of saved state on load
|
|
483
|
+
* - Manual save trigger
|
|
484
|
+
* - Last save timestamp tracking
|
|
485
|
+
* - Save status callbacks
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Auto-save status
|
|
490
|
+
*/
|
|
491
|
+
type AutoSaveStatus = 'idle' | 'saving' | 'saved' | 'error';
|
|
492
|
+
/**
|
|
493
|
+
* Options for useAutoSave hook
|
|
494
|
+
*/
|
|
495
|
+
interface UseAutoSaveOptions {
|
|
496
|
+
/** Storage key for localStorage (default: 'docx-editor-autosave') */
|
|
497
|
+
storageKey?: string;
|
|
498
|
+
/** Save interval in milliseconds (default: 30000 - 30 seconds) */
|
|
499
|
+
interval?: number;
|
|
500
|
+
/** Whether auto-save is enabled (default: true) */
|
|
501
|
+
enabled?: boolean;
|
|
502
|
+
/** Maximum age of auto-save in milliseconds before it's considered stale (default: 24 hours) */
|
|
503
|
+
maxAge?: number;
|
|
504
|
+
/** Callback when save succeeds */
|
|
505
|
+
onSave?: (timestamp: Date) => void;
|
|
506
|
+
/** Callback when save fails */
|
|
507
|
+
onError?: (error: Error) => void;
|
|
508
|
+
/** Callback when recovery data is found */
|
|
509
|
+
onRecoveryAvailable?: (savedDocument: SavedDocumentData) => void;
|
|
510
|
+
/** Whether to save immediately when document changes (debounced) */
|
|
511
|
+
saveOnChange?: boolean;
|
|
512
|
+
/** Debounce delay for saveOnChange in milliseconds (default: 2000) */
|
|
513
|
+
debounceDelay?: number;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Return value of useAutoSave hook
|
|
517
|
+
*/
|
|
518
|
+
interface UseAutoSaveReturn {
|
|
519
|
+
/** Current auto-save status */
|
|
520
|
+
status: AutoSaveStatus;
|
|
521
|
+
/** Last save timestamp */
|
|
522
|
+
lastSaveTime: Date | null;
|
|
523
|
+
/** Manually trigger a save */
|
|
524
|
+
save: () => Promise<boolean>;
|
|
525
|
+
/** Clear auto-saved data from storage */
|
|
526
|
+
clearAutoSave: () => void;
|
|
527
|
+
/** Check if there's recoverable data */
|
|
528
|
+
hasRecoveryData: boolean;
|
|
529
|
+
/** Get the saved document data for recovery */
|
|
530
|
+
getRecoveryData: () => SavedDocumentData | null;
|
|
531
|
+
/** Accept and apply recovered data */
|
|
532
|
+
acceptRecovery: () => Document | null;
|
|
533
|
+
/** Dismiss recovery (clears saved data) */
|
|
534
|
+
dismissRecovery: () => void;
|
|
535
|
+
/** Whether auto-save is currently enabled */
|
|
536
|
+
isEnabled: boolean;
|
|
537
|
+
/** Enable auto-save */
|
|
538
|
+
enable: () => void;
|
|
539
|
+
/** Disable auto-save */
|
|
540
|
+
disable: () => void;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Saved document data structure
|
|
544
|
+
*/
|
|
545
|
+
interface SavedDocumentData {
|
|
546
|
+
/** The document JSON */
|
|
547
|
+
document: Document;
|
|
548
|
+
/** When the document was saved */
|
|
549
|
+
savedAt: string;
|
|
550
|
+
/** Version for format compatibility */
|
|
551
|
+
version: number;
|
|
552
|
+
/** Optional document identifier */
|
|
553
|
+
documentId?: string;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* React hook for auto-saving document to localStorage
|
|
557
|
+
*/
|
|
558
|
+
declare function useAutoSave(document: Document | null | undefined, options?: UseAutoSaveOptions): UseAutoSaveReturn;
|
|
559
|
+
/**
|
|
560
|
+
* Format last save time for display
|
|
561
|
+
*/
|
|
562
|
+
declare function formatLastSaveTime(date: Date | null): string;
|
|
563
|
+
/**
|
|
564
|
+
* Get auto-save status label
|
|
565
|
+
*/
|
|
566
|
+
declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;
|
|
567
|
+
/**
|
|
568
|
+
* Get storage size used by auto-save
|
|
569
|
+
*/
|
|
570
|
+
declare function getAutoSaveStorageSize(storageKey?: string): number;
|
|
571
|
+
/**
|
|
572
|
+
* Format storage size for display
|
|
573
|
+
*/
|
|
574
|
+
declare function formatStorageSize(bytes: number): string;
|
|
575
|
+
/**
|
|
576
|
+
* Check if auto-save is supported in this environment
|
|
577
|
+
*/
|
|
578
|
+
declare function isAutoSaveSupported(): boolean;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* useWheelZoom Hook
|
|
582
|
+
*
|
|
583
|
+
* Enables Ctrl+scroll (or Cmd+scroll on Mac) to zoom in/out.
|
|
584
|
+
* Features:
|
|
585
|
+
* - Configurable zoom range and step
|
|
586
|
+
* - Smooth zoom transitions
|
|
587
|
+
* - Pinch-to-zoom support on trackpads
|
|
588
|
+
* - Zoom reset (Ctrl+0)
|
|
589
|
+
* - Zoom in/out shortcuts (Ctrl++, Ctrl+-)
|
|
590
|
+
*/
|
|
591
|
+
/**
|
|
592
|
+
* Options for useWheelZoom hook
|
|
593
|
+
*/
|
|
594
|
+
interface UseWheelZoomOptions {
|
|
595
|
+
/** Initial zoom level (default: 1.0) */
|
|
596
|
+
initialZoom?: number;
|
|
597
|
+
/** Minimum zoom level (default: 0.25) */
|
|
598
|
+
minZoom?: number;
|
|
599
|
+
/** Maximum zoom level (default: 4.0) */
|
|
600
|
+
maxZoom?: number;
|
|
601
|
+
/** Zoom step for each scroll event (default: 0.1) */
|
|
602
|
+
zoomStep?: number;
|
|
603
|
+
/** Whether zoom is enabled (default: true) */
|
|
604
|
+
enabled?: boolean;
|
|
605
|
+
/** Container element ref to attach wheel listener */
|
|
606
|
+
containerRef?: React.RefObject<HTMLElement>;
|
|
607
|
+
/** Callback when zoom changes */
|
|
608
|
+
onZoomChange?: (zoom: number) => void;
|
|
609
|
+
/** Whether to enable keyboard shortcuts (Ctrl++, Ctrl+-, Ctrl+0) */
|
|
610
|
+
enableKeyboardShortcuts?: boolean;
|
|
611
|
+
/** Whether to prevent default browser zoom behavior */
|
|
612
|
+
preventDefault?: boolean;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Return value of useWheelZoom hook
|
|
616
|
+
*/
|
|
617
|
+
interface UseWheelZoomReturn {
|
|
618
|
+
/** Current zoom level */
|
|
619
|
+
zoom: number;
|
|
620
|
+
/** Set zoom level directly */
|
|
621
|
+
setZoom: (zoom: number) => void;
|
|
622
|
+
/** Zoom in by step */
|
|
623
|
+
zoomIn: () => void;
|
|
624
|
+
/** Zoom out by step */
|
|
625
|
+
zoomOut: () => void;
|
|
626
|
+
/** Reset zoom to initial level */
|
|
627
|
+
resetZoom: () => void;
|
|
628
|
+
/** Reset zoom to 100% */
|
|
629
|
+
zoomTo100: () => void;
|
|
630
|
+
/** Zoom to fit width */
|
|
631
|
+
zoomToFit: (containerWidth: number, contentWidth: number) => void;
|
|
632
|
+
/** Whether currently at minimum zoom */
|
|
633
|
+
isMinZoom: boolean;
|
|
634
|
+
/** Whether currently at maximum zoom */
|
|
635
|
+
isMaxZoom: boolean;
|
|
636
|
+
/** Zoom percentage (e.g., 100 for zoom level 1.0) */
|
|
637
|
+
zoomPercent: number;
|
|
638
|
+
/** Wheel event handler (for manual attachment) */
|
|
639
|
+
handleWheel: (event: WheelEvent) => void;
|
|
640
|
+
/** Keyboard event handler (for manual attachment) */
|
|
641
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Preset zoom levels for snapping
|
|
645
|
+
*/
|
|
646
|
+
declare const ZOOM_PRESETS: number[];
|
|
647
|
+
/**
|
|
648
|
+
* React hook for Ctrl+scroll zoom functionality
|
|
649
|
+
*/
|
|
650
|
+
declare function useWheelZoom(options?: UseWheelZoomOptions): UseWheelZoomReturn;
|
|
651
|
+
/**
|
|
652
|
+
* Get zoom presets
|
|
653
|
+
*/
|
|
654
|
+
declare function getZoomPresets(): number[];
|
|
655
|
+
/**
|
|
656
|
+
* Find nearest zoom preset
|
|
657
|
+
*/
|
|
658
|
+
declare function findNearestZoomPreset(zoom: number): number;
|
|
659
|
+
/**
|
|
660
|
+
* Get next zoom preset (for zoom in)
|
|
661
|
+
*/
|
|
662
|
+
declare function getNextZoomPreset(zoom: number): number;
|
|
663
|
+
/**
|
|
664
|
+
* Get previous zoom preset (for zoom out)
|
|
665
|
+
*/
|
|
666
|
+
declare function getPreviousZoomPreset(zoom: number): number;
|
|
667
|
+
/**
|
|
668
|
+
* Format zoom level for display
|
|
669
|
+
*/
|
|
670
|
+
declare function formatZoom(zoom: number): string;
|
|
671
|
+
/**
|
|
672
|
+
* Parse zoom from percentage string
|
|
673
|
+
*/
|
|
674
|
+
declare function parseZoom(zoomString: string): number | null;
|
|
675
|
+
/**
|
|
676
|
+
* Check if zoom level is at a preset
|
|
677
|
+
*/
|
|
678
|
+
declare function isZoomPreset(zoom: number): boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Clamp zoom to valid range
|
|
681
|
+
*/
|
|
682
|
+
declare function clampZoom(zoom: number, minZoom?: number, maxZoom?: number): number;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Selection Highlight Hook
|
|
686
|
+
*
|
|
687
|
+
* A React hook that manages visual selection highlighting across multiple runs.
|
|
688
|
+
* Uses a combination of CSS ::selection pseudo-element styling and optional
|
|
689
|
+
* overlay rectangles for complex scenarios.
|
|
690
|
+
*
|
|
691
|
+
* Features:
|
|
692
|
+
* - Consistent selection highlighting across all text runs
|
|
693
|
+
* - Support for text with different backgrounds (highlighted, dark bg)
|
|
694
|
+
* - Optional overlay rectangles for custom highlight effects
|
|
695
|
+
* - Debounced updates for performance
|
|
696
|
+
*/
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Options for the useSelectionHighlight hook
|
|
700
|
+
*/
|
|
701
|
+
interface UseSelectionHighlightOptions {
|
|
702
|
+
/** Reference to the container element */
|
|
703
|
+
containerRef: React__default.RefObject<HTMLElement>;
|
|
704
|
+
/** Whether to enable selection highlighting */
|
|
705
|
+
enabled?: boolean;
|
|
706
|
+
/** Custom highlight configuration */
|
|
707
|
+
config?: SelectionHighlightConfig;
|
|
708
|
+
/** Whether to use overlay rectangles (default: false, uses CSS) */
|
|
709
|
+
useOverlay?: boolean;
|
|
710
|
+
/** Debounce delay for rect updates in ms (default: 16) */
|
|
711
|
+
debounceMs?: number;
|
|
712
|
+
/** Callback when selection changes */
|
|
713
|
+
onSelectionChange?: (hasSelection: boolean, text: string) => void;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Return value from the useSelectionHighlight hook
|
|
717
|
+
*/
|
|
718
|
+
interface UseSelectionHighlightReturn {
|
|
719
|
+
/** Whether there is an active selection */
|
|
720
|
+
hasSelection: boolean;
|
|
721
|
+
/** The selected text */
|
|
722
|
+
selectedText: string;
|
|
723
|
+
/** Highlight rectangles (only populated if useOverlay is true) */
|
|
724
|
+
highlightRects: HighlightRect[];
|
|
725
|
+
/** Whether selection is within the container */
|
|
726
|
+
isSelectionInContainer: boolean;
|
|
727
|
+
/** Refresh the highlight state */
|
|
728
|
+
refresh: () => void;
|
|
729
|
+
/** Get styles for a highlight rect overlay */
|
|
730
|
+
getOverlayStyle: (rect: HighlightRect) => CSSProperties;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Hook to manage selection highlighting in the editor
|
|
734
|
+
*/
|
|
735
|
+
declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
|
|
736
|
+
/**
|
|
737
|
+
* Props for selection overlay component
|
|
738
|
+
*/
|
|
739
|
+
interface SelectionOverlayProps {
|
|
740
|
+
/** Highlight rectangles to render */
|
|
741
|
+
rects: HighlightRect[];
|
|
742
|
+
/** Style configuration */
|
|
743
|
+
config?: SelectionHighlightConfig;
|
|
744
|
+
/** Additional class name */
|
|
745
|
+
className?: string;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Generate selection overlay elements (for use in JSX)
|
|
749
|
+
*
|
|
750
|
+
* Usage:
|
|
751
|
+
* ```tsx
|
|
752
|
+
* const { highlightRects } = useSelectionHighlight({ ... });
|
|
753
|
+
* return (
|
|
754
|
+
* <div style={{ position: 'relative' }}>
|
|
755
|
+
* {generateOverlayElements(highlightRects)}
|
|
756
|
+
* <div>... content ...</div>
|
|
757
|
+
* </div>
|
|
758
|
+
* );
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
761
|
+
declare function generateOverlayElements(rects: HighlightRect[], config?: SelectionHighlightConfig): React__default.ReactNode[];
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* useClipboard Hook
|
|
765
|
+
*
|
|
766
|
+
* React hook for managing clipboard operations in the editor with formatting preservation.
|
|
767
|
+
*
|
|
768
|
+
* Features:
|
|
769
|
+
* - Copy: Copies selected runs/paragraphs to clipboard with formatting as HTML
|
|
770
|
+
* - Cut: Copies and removes selected content
|
|
771
|
+
* - Paste: Parses clipboard HTML/text and applies formatting
|
|
772
|
+
* - Handles Word-pasted content (cleans Word-specific markup)
|
|
773
|
+
* - Keyboard shortcuts (Ctrl+C, Ctrl+X, Ctrl+V)
|
|
774
|
+
*/
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Selection data for clipboard operations
|
|
778
|
+
*/
|
|
779
|
+
interface ClipboardSelection {
|
|
780
|
+
/** Selected text (plain text) */
|
|
781
|
+
text: string;
|
|
782
|
+
/** Selected runs */
|
|
783
|
+
runs: Run[];
|
|
784
|
+
/** Start position */
|
|
785
|
+
startParagraphIndex: number;
|
|
786
|
+
startRunIndex: number;
|
|
787
|
+
startOffset: number;
|
|
788
|
+
/** End position */
|
|
789
|
+
endParagraphIndex: number;
|
|
790
|
+
endRunIndex: number;
|
|
791
|
+
endOffset: number;
|
|
792
|
+
/** Whether selection spans multiple paragraphs */
|
|
793
|
+
isMultiParagraph: boolean;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Options for useClipboard hook
|
|
797
|
+
*/
|
|
798
|
+
interface UseClipboardOptions {
|
|
799
|
+
/** Callback when content is copied */
|
|
800
|
+
onCopy?: (selection: ClipboardSelection) => void;
|
|
801
|
+
/** Callback when content is cut */
|
|
802
|
+
onCut?: (selection: ClipboardSelection) => void;
|
|
803
|
+
/** Callback when content is pasted */
|
|
804
|
+
onPaste?: (content: ParsedClipboardContent, asPlainText: boolean) => void;
|
|
805
|
+
/** Whether to clean Word-specific formatting */
|
|
806
|
+
cleanWordFormatting?: boolean;
|
|
807
|
+
/** Whether the editor is editable */
|
|
808
|
+
editable?: boolean;
|
|
809
|
+
/** Callback for errors */
|
|
810
|
+
onError?: (error: Error) => void;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Return value of useClipboard hook
|
|
814
|
+
*/
|
|
815
|
+
interface UseClipboardReturn {
|
|
816
|
+
/** Copy the current selection to clipboard */
|
|
817
|
+
copy: (selection: ClipboardSelection) => Promise<boolean>;
|
|
818
|
+
/** Cut the current selection to clipboard */
|
|
819
|
+
cut: (selection: ClipboardSelection) => Promise<boolean>;
|
|
820
|
+
/** Paste from clipboard */
|
|
821
|
+
paste: (asPlainText?: boolean) => Promise<ParsedClipboardContent | null>;
|
|
822
|
+
/** Handle copy event from DOM */
|
|
823
|
+
handleCopy: (event: ClipboardEvent) => void;
|
|
824
|
+
/** Handle cut event from DOM */
|
|
825
|
+
handleCut: (event: ClipboardEvent) => void;
|
|
826
|
+
/** Handle paste event from DOM */
|
|
827
|
+
handlePaste: (event: ClipboardEvent) => void;
|
|
828
|
+
/** Handle keyboard shortcuts */
|
|
829
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
830
|
+
/** Whether a clipboard operation is in progress */
|
|
831
|
+
isProcessing: boolean;
|
|
832
|
+
/** Last pasted content */
|
|
833
|
+
lastPastedContent: ParsedClipboardContent | null;
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Get selected runs from the current DOM selection
|
|
837
|
+
*/
|
|
838
|
+
declare function getSelectionRuns(): Run[];
|
|
839
|
+
/**
|
|
840
|
+
* Create a selection object from the current DOM selection
|
|
841
|
+
*/
|
|
842
|
+
declare function createSelectionFromDOM(): ClipboardSelection | null;
|
|
843
|
+
/**
|
|
844
|
+
* React hook for clipboard operations
|
|
845
|
+
*/
|
|
846
|
+
declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturn;
|
|
847
|
+
|
|
848
|
+
declare const PLUGIN_HOST_STYLES = "\n.plugin-host {\n display: flex;\n width: 100%;\n height: 100%;\n overflow: visible;\n position: relative;\n}\n\n.plugin-host-editor {\n flex: 1;\n display: flex;\n flex-direction: column;\n min-width: 0;\n overflow: visible;\n}\n\n\n.plugin-panels-left,\n.plugin-panels-right {\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n background: #f8f9fa;\n border-color: #e9ecef;\n}\n\n.plugin-panels-left {\n border-right: 1px solid #e9ecef;\n}\n\n.plugin-panels-right {\n border-left: 1px solid #e9ecef;\n}\n\n.plugin-panels-bottom {\n border-top: 1px solid #e9ecef;\n background: #f8f9fa;\n}\n\n.plugin-panel {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n transition: width 0.2s ease, height 0.2s ease;\n}\n\n.plugin-panel.collapsed {\n overflow: visible;\n}\n\n.plugin-panel-toggle {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 6px 8px;\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 12px;\n color: #6c757d;\n white-space: nowrap;\n}\n\n.plugin-panel.collapsed .plugin-panel-toggle {\n writing-mode: vertical-rl;\n text-orientation: mixed;\n flex-direction: column;\n height: 100%;\n padding: 8px 6px;\n}\n\n.plugin-panel-toggle:hover {\n background: #e9ecef;\n color: #495057;\n}\n\n.plugin-panel-toggle-icon {\n font-weight: bold;\n font-size: 14px;\n}\n\n.plugin-panel.collapsed .plugin-panel-toggle-icon {\n transform: rotate(90deg);\n}\n\n.plugin-panel-toggle-label {\n font-weight: 500;\n}\n\n.plugin-panel-content {\n flex: 1;\n overflow: auto;\n}\n\n/* Right panel rendered inside viewport - scrolls with content */\n.plugin-panel-in-viewport {\n position: absolute;\n top: 0;\n /* Position is set dynamically via inline styles based on page edge */\n width: 220px;\n pointer-events: auto;\n z-index: 10;\n overflow: visible;\n}\n\n.plugin-panel-in-viewport.collapsed {\n width: 32px;\n}\n\n.plugin-panel-in-viewport .plugin-panel-toggle {\n position: sticky;\n top: 0;\n background: rgba(255, 255, 255, 0.95);\n border-radius: 4px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n.plugin-panel-in-viewport-content {\n overflow: visible;\n position: relative;\n}\n\n/* Plugin overlay container for rendering highlights/decorations */\n.plugin-overlays-container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n z-index: 5;\n}\n\n.plugin-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n}\n\n.plugin-overlay > * {\n pointer-events: auto;\n}\n";
|
|
849
|
+
/**
|
|
850
|
+
* PluginHost Component
|
|
851
|
+
*
|
|
852
|
+
* Wraps the editor and provides:
|
|
853
|
+
* - Plugin state management
|
|
854
|
+
* - Panel rendering for each plugin
|
|
855
|
+
* - CSS injection for plugin styles
|
|
856
|
+
* - Callbacks for editor interaction
|
|
857
|
+
*/
|
|
858
|
+
declare const PluginHost: React$1.ForwardRefExoticComponent<PluginHostProps & React$1.RefAttributes<PluginHostRef>>;
|
|
859
|
+
|
|
860
|
+
export { type AutoSaveStatus, type ClipboardSelection, DocxEditor, type DocxEditorHandle, type DocxEditorProps, type DocxEditorRef, type EditorPlugin, ErrorBoundary, type ErrorBoundaryProps, type ErrorContextValue, type ErrorNotification, ErrorProvider, type ErrorSeverity, PLUGIN_HOST_STYLES, ParseErrorDisplay, type ParseErrorDisplayProps, type PluginContext, PluginHost, type PluginHostProps, type PluginHostRef, type RenderAsyncOptions, type SavedDocumentData, type SelectionOverlayProps, TABLE_DATA_ATTRIBUTES, type TableSelectionState, UnsupportedFeatureWarning, type UnsupportedFeatureWarningProps, type UseAutoSaveOptions, type UseAutoSaveReturn, type UseClipboardOptions, type UseClipboardReturn, type UseSelectionHighlightOptions, type UseSelectionHighlightReturn, type UseTableSelectionOptions, type UseTableSelectionReturn, type UseWheelZoomOptions, type UseWheelZoomReturn, ZOOM_PRESETS, clampZoom, createSelectionFromDOM, findNearestZoomPreset, formatLastSaveTime, formatStorageSize, formatZoom, generateOverlayElements, getAutoSaveStatusLabel, getAutoSaveStorageSize, getNextZoomPreset, getPreviousZoomPreset, getSelectionRuns, getUserFriendlyMessage, getZoomPresets, isAutoSaveSupported, isParseError, isZoomPreset, parseZoom, renderAsync, useAutoSave, useClipboard, useErrorNotifications, useSelectionHighlight, useTableSelection, useWheelZoom };
|