@eigenpal/docx-js-editor 0.0.17 → 0.0.19
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/ClipboardManager-D6dkOFg6.d.ts +436 -0
- package/dist/ClipboardManager-EZ0C6Onq.d.cts +436 -0
- package/dist/DocumentAgent-B0EC8lPC.d.cts +412 -0
- package/dist/DocumentAgent-BcCDg7i2.d.ts +412 -0
- package/dist/{FindReplaceDialog-MMDEJORP.js → FindReplaceDialog-AWQXKEUQ.js} +2 -2
- package/dist/{FindReplaceDialog-MMDEJORP.js.map → FindReplaceDialog-AWQXKEUQ.js.map} +1 -1
- package/dist/{FindReplaceDialog-K4GRE4JB.cjs → FindReplaceDialog-I4SZDSVP.cjs} +2 -2
- package/dist/{FindReplaceDialog-K4GRE4JB.cjs.map → FindReplaceDialog-I4SZDSVP.cjs.map} +1 -1
- package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs → FootnotePropertiesDialog-73VT2ZVZ.cjs} +2 -2
- package/dist/{FootnotePropertiesDialog-V3YOIJCV.cjs.map → FootnotePropertiesDialog-73VT2ZVZ.cjs.map} +1 -1
- package/dist/{FootnotePropertiesDialog-HG4267LR.js → FootnotePropertiesDialog-ZM3EF3EF.js} +2 -2
- package/dist/{FootnotePropertiesDialog-HG4267LR.js.map → FootnotePropertiesDialog-ZM3EF3EF.js.map} +1 -1
- package/dist/{HyperlinkDialog-SCSX4RP7.js → HyperlinkDialog-BA25XUT5.js} +2 -2
- package/dist/{HyperlinkDialog-SCSX4RP7.js.map → HyperlinkDialog-BA25XUT5.js.map} +1 -1
- package/dist/{HyperlinkDialog-YPKURBZK.cjs → HyperlinkDialog-V63LPOT2.cjs} +2 -2
- package/dist/{HyperlinkDialog-YPKURBZK.cjs.map → HyperlinkDialog-V63LPOT2.cjs.map} +1 -1
- package/dist/{ImagePositionDialog-CJYJ35PI.js → ImagePositionDialog-AIAMKPFK.js} +2 -2
- package/dist/{ImagePositionDialog-CJYJ35PI.js.map → ImagePositionDialog-AIAMKPFK.js.map} +1 -1
- package/dist/{ImagePositionDialog-IMVI7EXA.cjs → ImagePositionDialog-KMK7ROV2.cjs} +2 -2
- package/dist/{ImagePositionDialog-IMVI7EXA.cjs.map → ImagePositionDialog-KMK7ROV2.cjs.map} +1 -1
- package/dist/{ImagePropertiesDialog-P7WN2ALR.js → ImagePropertiesDialog-ERFCUVCW.js} +2 -2
- package/dist/{ImagePropertiesDialog-P7WN2ALR.js.map → ImagePropertiesDialog-ERFCUVCW.js.map} +1 -1
- package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs → ImagePropertiesDialog-USMMRK6X.cjs} +2 -2
- package/dist/{ImagePropertiesDialog-YS4KJRN7.cjs.map → ImagePropertiesDialog-USMMRK6X.cjs.map} +1 -1
- package/dist/{TablePropertiesDialog-CUQXUBQN.cjs → TablePropertiesDialog-72CIUAZT.cjs} +2 -2
- package/dist/{TablePropertiesDialog-CUQXUBQN.cjs.map → TablePropertiesDialog-72CIUAZT.cjs.map} +1 -1
- package/dist/{TablePropertiesDialog-ZHAYVHPZ.js → TablePropertiesDialog-EMUEVYB3.js} +2 -2
- package/dist/{TablePropertiesDialog-ZHAYVHPZ.js.map → TablePropertiesDialog-EMUEVYB3.js.map} +1 -1
- package/dist/agentApi-BFVyKagE.d.cts +2227 -0
- package/dist/agentApi-BFVyKagE.d.ts +2227 -0
- package/dist/chunk-2CHPKB5A.cjs +112 -0
- package/dist/chunk-2CHPKB5A.cjs.map +1 -0
- package/dist/chunk-2QOEHCBX.js +2 -0
- package/dist/chunk-2QOEHCBX.js.map +1 -0
- package/dist/chunk-4QT5LPBA.cjs +24 -0
- package/dist/chunk-4QT5LPBA.cjs.map +1 -0
- package/dist/chunk-5DYSI4O4.cjs +60 -0
- package/dist/chunk-5DYSI4O4.cjs.map +1 -0
- package/dist/chunk-5FJXHXFV.cjs +2 -0
- package/dist/chunk-5FJXHXFV.cjs.map +1 -0
- package/dist/chunk-6FEWNF6B.js +4 -0
- package/dist/chunk-6FEWNF6B.js.map +1 -0
- package/dist/chunk-6LF5HZCV.js +10 -0
- package/dist/chunk-6LF5HZCV.js.map +1 -0
- package/dist/chunk-7JSPKVOW.js +2 -0
- package/dist/chunk-7JSPKVOW.js.map +1 -0
- package/dist/chunk-C33XDRDJ.cjs +28 -0
- package/dist/chunk-C33XDRDJ.cjs.map +1 -0
- package/dist/chunk-CV5WFE7K.js +24 -0
- package/dist/chunk-CV5WFE7K.js.map +1 -0
- package/dist/chunk-CXJRNISO.js +2 -0
- package/dist/chunk-CXJRNISO.js.map +1 -0
- package/dist/chunk-DP6Q75ZD.js +28 -0
- package/dist/chunk-DP6Q75ZD.js.map +1 -0
- package/dist/chunk-FDANI5P4.cjs +2 -0
- package/dist/chunk-FDANI5P4.cjs.map +1 -0
- package/dist/chunk-FGVGZLBL.js +2 -0
- package/dist/chunk-FGVGZLBL.js.map +1 -0
- package/dist/chunk-GJ4GKSDU.cjs +2 -0
- package/dist/chunk-GJ4GKSDU.cjs.map +1 -0
- package/dist/chunk-GWBTKVFD.cjs +2 -0
- package/dist/chunk-GWBTKVFD.cjs.map +1 -0
- package/dist/chunk-JOYPFQW2.js +2 -0
- package/dist/chunk-JOYPFQW2.js.map +1 -0
- package/dist/chunk-L54YNLSE.js +2 -0
- package/dist/chunk-L54YNLSE.js.map +1 -0
- package/dist/chunk-LPGMLJMO.js +259 -0
- package/dist/chunk-LPGMLJMO.js.map +1 -0
- package/dist/chunk-OHG7ROFC.js +11 -0
- package/dist/chunk-OHG7ROFC.js.map +1 -0
- package/dist/chunk-PANKMCFX.cjs +4 -0
- package/dist/chunk-PANKMCFX.cjs.map +1 -0
- package/dist/chunk-QDV75OJ4.js +112 -0
- package/dist/chunk-QDV75OJ4.js.map +1 -0
- package/dist/chunk-QEBO3EQP.cjs +2 -0
- package/dist/{chunk-V3MCDVZE.cjs.map → chunk-QEBO3EQP.cjs.map} +1 -1
- package/dist/chunk-QVIZ775M.cjs +259 -0
- package/dist/chunk-QVIZ775M.cjs.map +1 -0
- package/dist/chunk-RMUMR42R.cjs +10 -0
- package/dist/chunk-RMUMR42R.cjs.map +1 -0
- package/dist/chunk-T2HQYRA7.cjs +2 -0
- package/dist/chunk-T2HQYRA7.cjs.map +1 -0
- package/dist/chunk-ULXNEG66.js +60 -0
- package/dist/chunk-ULXNEG66.js.map +1 -0
- package/dist/chunk-WD2HTKRR.cjs +2 -0
- package/dist/chunk-WD2HTKRR.cjs.map +1 -0
- package/dist/chunk-XZNOV52K.cjs +11 -0
- package/dist/chunk-XZNOV52K.cjs.map +1 -0
- package/dist/chunk-Y6VCTLCJ.js +2 -0
- package/dist/{chunk-AL62KQYJ.js.map → chunk-Y6VCTLCJ.js.map} +1 -1
- package/dist/{TableToolbar-RHX9L4h9.d.ts → clipboard-CqE-UZ2d.d.cts} +125 -2
- package/dist/{TableToolbar-RHX9L4h9.d.cts → clipboard-beGtyabO.d.ts} +125 -2
- package/dist/colorResolver-B5YbO_a4.d.ts +618 -0
- package/dist/colorResolver-Cu46bSKr.d.cts +618 -0
- package/dist/core-plugins-reexport.cjs +1 -1
- package/dist/core-plugins-reexport.cjs.map +1 -1
- package/dist/core-plugins-reexport.d.cts +31 -1
- package/dist/core-plugins-reexport.d.ts +31 -1
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.js.map +1 -1
- package/dist/core-reexport.cjs +1 -1
- package/dist/core-reexport.cjs.map +1 -1
- package/dist/core-reexport.d.cts +309 -4
- package/dist/core-reexport.d.ts +309 -4
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.js.map +1 -1
- package/dist/executor-K5RXUTTR.js +2 -0
- package/dist/executor-K5RXUTTR.js.map +1 -0
- package/dist/executor-XIPIU3H4.cjs +2 -0
- package/dist/executor-XIPIU3H4.cjs.map +1 -0
- package/dist/fontLoader-CFKpg0Ri.d.ts +176 -0
- package/dist/fontLoader-HZYfILUm.d.cts +176 -0
- package/dist/headless-reexport.cjs +4 -1
- package/dist/headless-reexport.cjs.map +1 -1
- package/dist/headless-reexport.d.cts +195 -1
- package/dist/headless-reexport.d.ts +195 -1
- package/dist/headless-reexport.js +4 -1
- package/dist/headless-reexport.js.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +261 -30
- package/dist/index.d.ts +261 -30
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp-reexport.cjs +16 -1
- package/dist/mcp-reexport.cjs.map +1 -1
- package/dist/mcp-reexport.d.cts +156 -1
- package/dist/mcp-reexport.d.ts +156 -1
- package/dist/mcp-reexport.js +16 -1
- package/dist/mcp-reexport.js.map +1 -1
- package/dist/processTemplate-G37IM66O.js +2 -0
- package/dist/processTemplate-G37IM66O.js.map +1 -0
- package/dist/processTemplate-RFBGVH7T.cjs +2 -0
- package/dist/processTemplate-RFBGVH7T.cjs.map +1 -0
- package/dist/react-BjOCdeTs.d.ts +1027 -0
- package/dist/react-UzAn4o7l.d.cts +1027 -0
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +2 -0
- package/dist/react.css.map +1 -0
- package/dist/react.d.cts +10 -860
- package/dist/react.d.ts +10 -860
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/registry-CV6nYWqP.d.ts +165 -0
- package/dist/registry-DjacfR6Q.d.cts +165 -0
- package/dist/selectionRects-6DU7HN7E.js +2 -0
- package/dist/selectionRects-6DU7HN7E.js.map +1 -0
- package/dist/selectionRects-YZSC24ZP.cjs +2 -0
- package/dist/selectionRects-YZSC24ZP.cjs.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/types-Bnp8rvJn.d.cts +310 -0
- package/dist/types-DwZ3xysp.d.ts +310 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.cts +3 -5
- package/dist/ui.d.ts +3 -5
- package/dist/ui.js +1 -1
- package/dist/variableDetector-BaDeXz7D.d.ts +173 -0
- package/dist/variableDetector-CMhJtM96.d.cts +173 -0
- package/package.json +10 -3
- package/dist/chunk-7FEY3YWC.cjs +0 -3
- package/dist/chunk-7FEY3YWC.cjs.map +0 -1
- package/dist/chunk-AL62KQYJ.js +0 -2
- package/dist/chunk-MXGYESPA.cjs +0 -178
- package/dist/chunk-MXGYESPA.cjs.map +0 -1
- package/dist/chunk-NMYD4OJZ.js +0 -3
- package/dist/chunk-NMYD4OJZ.js.map +0 -1
- package/dist/chunk-OD33FUTO.js +0 -178
- package/dist/chunk-OD33FUTO.js.map +0 -1
- package/dist/chunk-V3MCDVZE.cjs +0 -2
- package/dist/chunk-VIEW4NAF.js +0 -112
- package/dist/chunk-VIEW4NAF.js.map +0 -1
- package/dist/chunk-ZX4CSEL3.cjs +0 -112
- package/dist/chunk-ZX4CSEL3.cjs.map +0 -1
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Node } from 'prosemirror-model';
|
|
4
|
+
import { D as Document, e as Table, b as Run } from './agentApi-BFVyKagE.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Framework-Agnostic Plugin Interface for the DOCX Editor
|
|
8
|
+
*
|
|
9
|
+
* Core plugin types that can be used by any framework (React, Vue, etc.).
|
|
10
|
+
* Framework-specific adapters extend EditorPluginCore with their own
|
|
11
|
+
* UI rendering capabilities (e.g., ReactEditorPlugin, VueEditorPlugin).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Coordinates returned by position lookup in the rendered DOM.
|
|
16
|
+
*/
|
|
17
|
+
interface PositionCoordinates {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Context for accessing the rendered DOM in the paged editor.
|
|
24
|
+
*
|
|
25
|
+
* Provides DOM-based position mapping that works with the LayoutPainter
|
|
26
|
+
* output (visible pages). Use this for rendering overlays, annotations,
|
|
27
|
+
* and other visual elements positioned relative to rendered content.
|
|
28
|
+
*
|
|
29
|
+
* The rendered DOM uses data-pm-start/data-pm-end attributes on spans
|
|
30
|
+
* to map between ProseMirror positions and DOM elements.
|
|
31
|
+
*/
|
|
32
|
+
interface RenderedDomContext {
|
|
33
|
+
/** The container element holding all rendered pages. */
|
|
34
|
+
pagesContainer: HTMLElement;
|
|
35
|
+
/**
|
|
36
|
+
* Get pixel coordinates for a ProseMirror position in the rendered DOM.
|
|
37
|
+
* Returns null if the position cannot be found.
|
|
38
|
+
*/
|
|
39
|
+
getCoordinatesForPosition(pmPos: number): PositionCoordinates | null;
|
|
40
|
+
/**
|
|
41
|
+
* Find DOM elements that overlap with a ProseMirror position range.
|
|
42
|
+
*/
|
|
43
|
+
findElementsForRange(from: number, to: number): Element[];
|
|
44
|
+
/**
|
|
45
|
+
* Get bounding rectangles for a range of text, accounting for line wraps.
|
|
46
|
+
* Returns rects relative to the pages container.
|
|
47
|
+
*/
|
|
48
|
+
getRectsForRange(from: number, to: number): Array<{
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}>;
|
|
54
|
+
/** Current zoom level (1 = 100%). */
|
|
55
|
+
zoom: number;
|
|
56
|
+
/**
|
|
57
|
+
* Offset of the pages container from its parent viewport.
|
|
58
|
+
*/
|
|
59
|
+
getContainerOffset(): {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Props passed to plugin panel components (framework-agnostic base).
|
|
66
|
+
*/
|
|
67
|
+
interface PluginPanelProps<TState = unknown> {
|
|
68
|
+
/** Current ProseMirror editor view */
|
|
69
|
+
editorView: EditorView | null;
|
|
70
|
+
/** Current ProseMirror document */
|
|
71
|
+
doc: Node | null;
|
|
72
|
+
/** Scroll editor to a specific position */
|
|
73
|
+
scrollToPosition: (pos: number) => void;
|
|
74
|
+
/** Select a range in the editor */
|
|
75
|
+
selectRange: (from: number, to: number) => void;
|
|
76
|
+
/** Plugin-specific state (managed by the plugin) */
|
|
77
|
+
pluginState: TState;
|
|
78
|
+
/** Width of the panel in pixels */
|
|
79
|
+
panelWidth: number;
|
|
80
|
+
/**
|
|
81
|
+
* Context for the rendered DOM (LayoutPainter output).
|
|
82
|
+
* May be null if layout hasn't completed yet.
|
|
83
|
+
*/
|
|
84
|
+
renderedDomContext: RenderedDomContext | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Configuration for plugin panel rendering.
|
|
88
|
+
*/
|
|
89
|
+
interface PanelConfig {
|
|
90
|
+
/** Where to render the panel */
|
|
91
|
+
position: 'left' | 'right' | 'bottom';
|
|
92
|
+
/** Default width/height of the panel */
|
|
93
|
+
defaultSize: number;
|
|
94
|
+
/** Minimum size */
|
|
95
|
+
minSize?: number;
|
|
96
|
+
/** Maximum size */
|
|
97
|
+
maxSize?: number;
|
|
98
|
+
/** Whether the panel is resizable */
|
|
99
|
+
resizable?: boolean;
|
|
100
|
+
/** Whether the panel can be collapsed */
|
|
101
|
+
collapsible?: boolean;
|
|
102
|
+
/** Initial collapsed state */
|
|
103
|
+
defaultCollapsed?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Framework-agnostic core plugin interface.
|
|
107
|
+
*
|
|
108
|
+
* Contains all non-UI plugin capabilities:
|
|
109
|
+
* - ProseMirror plugins (decorations, keymaps, etc.)
|
|
110
|
+
* - State management (initialize, onStateChange, destroy)
|
|
111
|
+
* - CSS injection
|
|
112
|
+
* - Panel configuration
|
|
113
|
+
*
|
|
114
|
+
* Framework adapters (ReactEditorPlugin, VueEditorPlugin) extend this
|
|
115
|
+
* with their own Panel component type and renderOverlay function.
|
|
116
|
+
*/
|
|
117
|
+
interface EditorPluginCore<TState = any> {
|
|
118
|
+
/** Unique plugin identifier */
|
|
119
|
+
id: string;
|
|
120
|
+
/** Display name for the plugin */
|
|
121
|
+
name: string;
|
|
122
|
+
/**
|
|
123
|
+
* ProseMirror plugins to register with the editor.
|
|
124
|
+
* These are merged with the editor's internal plugins.
|
|
125
|
+
*/
|
|
126
|
+
proseMirrorPlugins?: Plugin[];
|
|
127
|
+
/**
|
|
128
|
+
* Configuration for the panel (position, size, etc.)
|
|
129
|
+
*/
|
|
130
|
+
panelConfig?: PanelConfig;
|
|
131
|
+
/**
|
|
132
|
+
* Called when the editor state changes.
|
|
133
|
+
* Use this to update plugin-specific state based on document changes.
|
|
134
|
+
*/
|
|
135
|
+
onStateChange?: (view: EditorView) => TState | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Initialize plugin state when the plugin is first loaded.
|
|
138
|
+
*/
|
|
139
|
+
initialize?: (view: EditorView | null) => TState;
|
|
140
|
+
/**
|
|
141
|
+
* Called when the plugin is being destroyed.
|
|
142
|
+
* Use this for cleanup (subscriptions, timers, etc.)
|
|
143
|
+
*/
|
|
144
|
+
destroy?: () => void;
|
|
145
|
+
/**
|
|
146
|
+
* CSS styles to inject for this plugin.
|
|
147
|
+
* Can be a string of CSS or a URL to a stylesheet.
|
|
148
|
+
*/
|
|
149
|
+
styles?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Subscribable Base Class
|
|
154
|
+
*
|
|
155
|
+
* Framework-agnostic base for manager classes that need to notify
|
|
156
|
+
* UI frameworks of state changes.
|
|
157
|
+
*
|
|
158
|
+
* Compatible with:
|
|
159
|
+
* - React: useSyncExternalStore(manager.subscribe, manager.getSnapshot)
|
|
160
|
+
* - Vue: watchEffect(() => { manager.subscribe(triggerRef) })
|
|
161
|
+
*/
|
|
162
|
+
declare abstract class Subscribable<TSnapshot> {
|
|
163
|
+
private listeners;
|
|
164
|
+
private snapshot;
|
|
165
|
+
constructor(initialSnapshot: TSnapshot);
|
|
166
|
+
/**
|
|
167
|
+
* Subscribe to state changes. Returns an unsubscribe function.
|
|
168
|
+
* Bound method — safe to pass as `useSyncExternalStore(manager.subscribe, ...)`.
|
|
169
|
+
*/
|
|
170
|
+
subscribe: (listener: () => void) => (() => void);
|
|
171
|
+
/**
|
|
172
|
+
* Get the current snapshot. Returns a stable reference unless state has changed.
|
|
173
|
+
* Bound method — safe to pass as `useSyncExternalStore(..., manager.getSnapshot)`.
|
|
174
|
+
*/
|
|
175
|
+
getSnapshot: () => TSnapshot;
|
|
176
|
+
/**
|
|
177
|
+
* Update the snapshot and notify all subscribers.
|
|
178
|
+
* Subclasses should call this whenever their state changes.
|
|
179
|
+
*/
|
|
180
|
+
protected setSnapshot(snapshot: TSnapshot): void;
|
|
181
|
+
private notify;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Manager Types
|
|
186
|
+
*
|
|
187
|
+
* Framework-agnostic interfaces for the editor's manager classes.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Framework-agnostic interface for an imperatively mounted editor instance.
|
|
192
|
+
*
|
|
193
|
+
* Returned by `renderAsync()` implementations (React, Vue, etc.).
|
|
194
|
+
* Consumers use this to interact with the editor programmatically.
|
|
195
|
+
*/
|
|
196
|
+
interface EditorHandle {
|
|
197
|
+
/** Save the document and return the DOCX as a Blob. */
|
|
198
|
+
save(): Promise<Blob | null>;
|
|
199
|
+
/** Get the current parsed document model. */
|
|
200
|
+
getDocument(): Document | null;
|
|
201
|
+
/** Focus the editor. */
|
|
202
|
+
focus(): void;
|
|
203
|
+
/** Unmount the editor and clean up. */
|
|
204
|
+
destroy(): void;
|
|
205
|
+
}
|
|
206
|
+
/** Auto-save status */
|
|
207
|
+
type AutoSaveStatus = 'idle' | 'saving' | 'saved' | 'error';
|
|
208
|
+
/** Configuration for AutoSaveManager */
|
|
209
|
+
interface AutoSaveManagerOptions {
|
|
210
|
+
/** Storage key for localStorage (default: 'docx-editor-autosave') */
|
|
211
|
+
storageKey?: string;
|
|
212
|
+
/** Save interval in milliseconds (default: 30000 - 30 seconds) */
|
|
213
|
+
interval?: number;
|
|
214
|
+
/** Maximum age of auto-save before it's considered stale (default: 24 hours) */
|
|
215
|
+
maxAge?: number;
|
|
216
|
+
/** Whether to save on document change with debounce (default: true) */
|
|
217
|
+
saveOnChange?: boolean;
|
|
218
|
+
/** Debounce delay for saveOnChange in milliseconds (default: 2000) */
|
|
219
|
+
debounceDelay?: number;
|
|
220
|
+
/** Callback when save succeeds */
|
|
221
|
+
onSave?: (timestamp: Date) => void;
|
|
222
|
+
/** Callback when save fails */
|
|
223
|
+
onError?: (error: Error) => void;
|
|
224
|
+
/** Callback when recovery data is found */
|
|
225
|
+
onRecoveryAvailable?: (savedDocument: SavedDocumentData) => void;
|
|
226
|
+
}
|
|
227
|
+
/** Saved document data structure */
|
|
228
|
+
interface SavedDocumentData {
|
|
229
|
+
/** The document JSON */
|
|
230
|
+
document: Document;
|
|
231
|
+
/** When the document was saved */
|
|
232
|
+
savedAt: string;
|
|
233
|
+
/** Version for format compatibility */
|
|
234
|
+
version: number;
|
|
235
|
+
/** Optional document identifier */
|
|
236
|
+
documentId?: string;
|
|
237
|
+
}
|
|
238
|
+
/** AutoSaveManager snapshot for UI consumption */
|
|
239
|
+
interface AutoSaveSnapshot {
|
|
240
|
+
status: AutoSaveStatus;
|
|
241
|
+
lastSaveTime: Date | null;
|
|
242
|
+
hasRecoveryData: boolean;
|
|
243
|
+
isEnabled: boolean;
|
|
244
|
+
}
|
|
245
|
+
/** Cell coordinates in a table */
|
|
246
|
+
interface CellCoordinates {
|
|
247
|
+
tableIndex: number;
|
|
248
|
+
rowIndex: number;
|
|
249
|
+
columnIndex: number;
|
|
250
|
+
}
|
|
251
|
+
/** TableSelectionManager snapshot */
|
|
252
|
+
interface TableSelectionSnapshot {
|
|
253
|
+
/** Currently selected cell, or null if no selection */
|
|
254
|
+
selectedCell: CellCoordinates | null;
|
|
255
|
+
}
|
|
256
|
+
/** Error severity levels */
|
|
257
|
+
type ErrorSeverity = 'error' | 'warning' | 'info';
|
|
258
|
+
/** Error notification */
|
|
259
|
+
interface ErrorNotification {
|
|
260
|
+
id: string;
|
|
261
|
+
message: string;
|
|
262
|
+
severity: ErrorSeverity;
|
|
263
|
+
details?: string;
|
|
264
|
+
timestamp: number;
|
|
265
|
+
dismissed?: boolean;
|
|
266
|
+
}
|
|
267
|
+
/** ErrorManager snapshot */
|
|
268
|
+
interface ErrorManagerSnapshot {
|
|
269
|
+
notifications: ErrorNotification[];
|
|
270
|
+
}
|
|
271
|
+
/** Plugin lifecycle configuration */
|
|
272
|
+
interface PluginLifecycleConfig {
|
|
273
|
+
id: string;
|
|
274
|
+
styles?: string;
|
|
275
|
+
initialize?: (editorView: EditorView) => unknown;
|
|
276
|
+
onStateChange?: (editorView: EditorView) => unknown;
|
|
277
|
+
destroy?: () => void;
|
|
278
|
+
}
|
|
279
|
+
/** PluginLifecycleManager snapshot */
|
|
280
|
+
interface PluginLifecycleSnapshot {
|
|
281
|
+
/** Map of plugin ID to plugin state */
|
|
282
|
+
states: Map<string, unknown>;
|
|
283
|
+
/** Version counter (incremented on any state change) */
|
|
284
|
+
version: number;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* AutoSaveManager
|
|
289
|
+
*
|
|
290
|
+
* Framework-agnostic class for auto-saving documents to localStorage.
|
|
291
|
+
* Extracted from the React `useAutoSave` hook.
|
|
292
|
+
*
|
|
293
|
+
* Usage with React:
|
|
294
|
+
* ```ts
|
|
295
|
+
* const snapshot = useSyncExternalStore(manager.subscribe, manager.getSnapshot);
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
declare class AutoSaveManager extends Subscribable<AutoSaveSnapshot> {
|
|
300
|
+
private storageKey;
|
|
301
|
+
private interval;
|
|
302
|
+
private maxAge;
|
|
303
|
+
private saveOnChange;
|
|
304
|
+
private debounceDelay;
|
|
305
|
+
private onSaveCallback?;
|
|
306
|
+
private onErrorCallback?;
|
|
307
|
+
private onRecoveryAvailableCallback?;
|
|
308
|
+
private storageAvailable;
|
|
309
|
+
private currentDocument;
|
|
310
|
+
private lastSavedJson;
|
|
311
|
+
private intervalTimer;
|
|
312
|
+
private debounceTimer;
|
|
313
|
+
private status;
|
|
314
|
+
private lastSaveTime;
|
|
315
|
+
private _hasRecoveryData;
|
|
316
|
+
private _isEnabled;
|
|
317
|
+
constructor(options?: AutoSaveManagerOptions);
|
|
318
|
+
/** Update the current document. Triggers debounced save if enabled. */
|
|
319
|
+
onDocumentChanged(document: Document | null): void;
|
|
320
|
+
/** Manually trigger a save. */
|
|
321
|
+
save(): Promise<boolean>;
|
|
322
|
+
/** Clear auto-saved data from storage. */
|
|
323
|
+
clear(): void;
|
|
324
|
+
/** Get recovery data from storage. */
|
|
325
|
+
getRecoveryData(): SavedDocumentData | null;
|
|
326
|
+
/** Accept recovery and return the document. */
|
|
327
|
+
acceptRecovery(): Document | null;
|
|
328
|
+
/** Dismiss recovery and clear saved data. */
|
|
329
|
+
dismissRecovery(): void;
|
|
330
|
+
/** Enable auto-save and start the interval timer. */
|
|
331
|
+
enable(): void;
|
|
332
|
+
/** Disable auto-save and stop all timers. */
|
|
333
|
+
disable(): void;
|
|
334
|
+
/** Start the interval timer. Call after enabling or on init. */
|
|
335
|
+
startInterval(): void;
|
|
336
|
+
/** Save synchronously on destroy (best-effort). */
|
|
337
|
+
destroy(): void;
|
|
338
|
+
private checkRecoveryData;
|
|
339
|
+
private persistToStorage;
|
|
340
|
+
private debounceSave;
|
|
341
|
+
private stopTimers;
|
|
342
|
+
private updateStatus;
|
|
343
|
+
private emitSnapshot;
|
|
344
|
+
}
|
|
345
|
+
/** Format last save time for display */
|
|
346
|
+
declare function formatLastSaveTime(date: Date | null): string;
|
|
347
|
+
/** Get auto-save status label */
|
|
348
|
+
declare function getAutoSaveStatusLabel(status: AutoSaveStatus): string;
|
|
349
|
+
/** Get storage size used by auto-save */
|
|
350
|
+
declare function getAutoSaveStorageSize(storageKey?: string): number;
|
|
351
|
+
/** Format storage size for display */
|
|
352
|
+
declare function formatStorageSize(bytes: number): string;
|
|
353
|
+
/** Check if auto-save is supported */
|
|
354
|
+
declare function isAutoSaveSupported(): boolean;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* TableSelectionManager
|
|
358
|
+
*
|
|
359
|
+
* Framework-agnostic class for managing table cell selection state.
|
|
360
|
+
* Extracted from the React `useTableSelection` hook.
|
|
361
|
+
*
|
|
362
|
+
* Handles:
|
|
363
|
+
* - Cell selection via data-attribute queries on the DOM
|
|
364
|
+
* - Table document operations (add/delete rows/columns, merge/split)
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
/** Data attributes for table elements in the rendered DOM */
|
|
368
|
+
declare const TABLE_DATA_ATTRIBUTES: {
|
|
369
|
+
readonly TABLE_INDEX: "data-table-index";
|
|
370
|
+
readonly ROW_INDEX: "data-row";
|
|
371
|
+
readonly COLUMN_INDEX: "data-col";
|
|
372
|
+
readonly TABLE_CELL: "data-table-cell";
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Find table cell coordinates from a click target by walking up the DOM
|
|
376
|
+
* and reading data attributes.
|
|
377
|
+
*/
|
|
378
|
+
declare function findTableFromClick(target: EventTarget | null, container?: HTMLElement | null): CellCoordinates | null;
|
|
379
|
+
/** Get a table from the document by index. */
|
|
380
|
+
declare function getTableFromDocument(doc: Document, tableIndex: number): Table | null;
|
|
381
|
+
/** Update a table in the document immutably. */
|
|
382
|
+
declare function updateTableInDocument(doc: Document, tableIndex: number, newTable: Table): Document;
|
|
383
|
+
/** Delete a table from the document immutably. */
|
|
384
|
+
declare function deleteTableFromDocument(doc: Document, tableIndex: number): Document;
|
|
385
|
+
declare class TableSelectionManager extends Subscribable<TableSelectionSnapshot> {
|
|
386
|
+
constructor();
|
|
387
|
+
/** Select a specific cell. */
|
|
388
|
+
selectCell(coords: CellCoordinates): void;
|
|
389
|
+
/** Clear the current selection. */
|
|
390
|
+
clearSelection(): void;
|
|
391
|
+
/** Check if a specific cell is selected. */
|
|
392
|
+
isCellSelected(tableIndex: number, rowIndex: number, columnIndex: number): boolean;
|
|
393
|
+
/** Get the currently selected cell coordinates, or null. */
|
|
394
|
+
getSelectedCell(): CellCoordinates | null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* ClipboardManager
|
|
399
|
+
*
|
|
400
|
+
* Framework-agnostic class for clipboard operations in the editor.
|
|
401
|
+
* Extracted from the React `useClipboard` hook.
|
|
402
|
+
*
|
|
403
|
+
* Handles:
|
|
404
|
+
* - DOM selection traversal and run extraction
|
|
405
|
+
* - Formatting extraction from computed styles
|
|
406
|
+
* - Clipboard read/write operations
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
/** Selection data for clipboard operations */
|
|
410
|
+
interface ClipboardSelection {
|
|
411
|
+
text: string;
|
|
412
|
+
runs: Run[];
|
|
413
|
+
startParagraphIndex: number;
|
|
414
|
+
startRunIndex: number;
|
|
415
|
+
startOffset: number;
|
|
416
|
+
endParagraphIndex: number;
|
|
417
|
+
endRunIndex: number;
|
|
418
|
+
endOffset: number;
|
|
419
|
+
isMultiParagraph: boolean;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Convert a CSS color string (rgb/rgba/hex) to a 6-char uppercase hex string.
|
|
423
|
+
*
|
|
424
|
+
* NOTE: This differs from `colorResolver.rgbToHex(r, g, b)` which takes
|
|
425
|
+
* numeric components. This function parses CSS color strings.
|
|
426
|
+
*/
|
|
427
|
+
declare function cssColorToHex(color: string): string | null;
|
|
428
|
+
/** Extract formatting from an HTML element's computed styles. */
|
|
429
|
+
declare function extractFormattingFromElement(element: HTMLElement): Run['formatting'];
|
|
430
|
+
/** Get selected runs from the current DOM selection. */
|
|
431
|
+
declare function getSelectionRuns(): Run[];
|
|
432
|
+
/** Create a ClipboardSelection from the current DOM selection. */
|
|
433
|
+
declare function createSelectionFromDOM(): ClipboardSelection | null;
|
|
434
|
+
declare const rgbToHex: typeof cssColorToHex;
|
|
435
|
+
|
|
436
|
+
export { AutoSaveManager as A, rgbToHex as B, type CellCoordinates as C, updateTableInDocument as D, type ErrorManagerSnapshot as E, type PluginLifecycleSnapshot as P, type RenderedDomContext as R, Subscribable as S, TABLE_DATA_ATTRIBUTES as T, type PluginLifecycleConfig as a, type AutoSaveManagerOptions as b, type AutoSaveSnapshot as c, type AutoSaveStatus as d, type ClipboardSelection as e, type EditorHandle as f, type EditorPluginCore as g, type ErrorNotification as h, type ErrorSeverity as i, type PanelConfig as j, type PluginPanelProps as k, type PositionCoordinates as l, type SavedDocumentData as m, TableSelectionManager as n, type TableSelectionSnapshot as o, createSelectionFromDOM as p, deleteTableFromDocument as q, extractFormattingFromElement as r, findTableFromClick as s, formatLastSaveTime as t, formatStorageSize as u, getAutoSaveStatusLabel as v, getAutoSaveStorageSize as w, getSelectionRuns as x, getTableFromDocument as y, isAutoSaveSupported as z };
|