@zeke-02/docx-editor 0.5.1 → 0.5.3
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/LICENSE +204 -0
- package/dist/FindReplaceDialog-7SQOVQWH.js +1 -0
- package/dist/FindReplaceDialog-RK3A7MSK.mjs +1 -0
- package/dist/{FootnotePropertiesDialog-XQ7NIFIU.js → FootnotePropertiesDialog-2Q2SHVMR.js} +1 -1
- package/dist/{FootnotePropertiesDialog-TNVJJCY6.mjs → FootnotePropertiesDialog-ZKQXW3YO.mjs} +1 -1
- package/dist/{HyperlinkDialog-FR4IZZ7E.mjs → HyperlinkDialog-QV3CVFQU.mjs} +1 -1
- package/dist/HyperlinkDialog-XVAF7FVN.js +1 -0
- package/dist/{ImagePositionDialog-JSZSIKF5.mjs → ImagePositionDialog-EGRH3HPP.mjs} +1 -1
- package/dist/{ImagePositionDialog-2YXRAGZS.js → ImagePositionDialog-HIVHUTBT.js} +1 -1
- package/dist/ImagePropertiesDialog-67WLFIIZ.mjs +1 -0
- package/dist/ImagePropertiesDialog-HSM3JJ22.js +1 -0
- package/dist/KeyboardShortcutsDialog-5D_FoAp6.d.ts +395 -0
- package/dist/KeyboardShortcutsDialog-D7ihAj18.d.mts +395 -0
- package/dist/PageSetupDialog-642IAVG2.js +1 -0
- package/dist/PageSetupDialog-ERUQDHAY.mjs +1 -0
- package/dist/{SplitCellDialog-NP3JJYHD.mjs → SplitCellDialog-GFWCFCTD.mjs} +1 -1
- package/dist/{SplitCellDialog-JIAC3RYV.js → SplitCellDialog-M7WF7ANE.js} +1 -1
- package/dist/{TablePropertiesDialog-TIK4AA5M.mjs → TablePropertiesDialog-TZ7VCL6V.mjs} +1 -1
- package/dist/{TablePropertiesDialog-T7D4HSVP.js → TablePropertiesDialog-ZKU2FTUX.js} +1 -1
- package/dist/agentApi-C41hiW-n.d.mts +486 -0
- package/dist/agentApi-D4AZmNfB.d.ts +486 -0
- package/dist/chunk-2XXILKEQ.js +1 -0
- package/dist/chunk-35DG3R42.js +2 -0
- package/dist/chunk-47VJOBJD.mjs +60 -0
- package/dist/chunk-5UX5CD4C.js +1 -0
- package/dist/chunk-7QQSDIWK.mjs +2 -0
- package/dist/chunk-AW5TISUL.js +3 -0
- package/dist/chunk-AYMGSTNG.js +1 -0
- package/dist/chunk-B45ECEGY.js +18 -0
- package/dist/chunk-B7CCL7SL.mjs +2 -0
- package/dist/chunk-BRMTZRLJ.js +2 -0
- package/dist/chunk-D47GTKGU.js +2 -0
- package/dist/chunk-E6MQXELR.js +1 -0
- package/dist/chunk-F5SERL7X.mjs +2 -0
- package/dist/chunk-FWPVBFKQ.mjs +1 -0
- package/dist/chunk-GGQK26JO.js +2 -0
- package/dist/chunk-GM2S2WMT.mjs +1 -0
- package/dist/chunk-ILYKDR3C.js +1 -0
- package/dist/chunk-IP5NAYHL.js +60 -0
- package/dist/chunk-JPF5R2ZM.mjs +1 -0
- package/dist/chunk-KOXCF3CL.mjs +1 -0
- package/dist/chunk-KRLNX56Y.mjs +2 -0
- package/dist/chunk-LUJ6HCMH.mjs +1 -0
- package/dist/chunk-MKNSJOCN.js +70 -0
- package/dist/chunk-NIBCC7WQ.js +1 -0
- package/dist/chunk-NLFXR2VH.js +2 -0
- package/dist/chunk-ONIYA2FU.mjs +2 -0
- package/dist/chunk-ONNHQWAX.mjs +1 -0
- package/dist/chunk-RCIZ7OM3.mjs +70 -0
- package/dist/{chunk-EHFEG3TX.js → chunk-SNZ57XBI.js} +1 -1
- package/dist/chunk-SOTWG3KJ.mjs +1 -0
- package/dist/chunk-TYPGB4KF.js +1 -0
- package/dist/chunk-U7ZW2DOO.mjs +2 -0
- package/dist/{chunk-PKEOQIQO.mjs → chunk-WPI3YRFO.mjs} +1 -1
- package/dist/chunk-XQZTWWRF.mjs +18 -0
- package/dist/chunk-ZVAFVHWR.mjs +3 -0
- package/dist/chunk-ZXPCJWVY.js +2 -0
- package/dist/{agentApi-DLt94vXk.d.mts → content-B2MzIMwA.d.mts} +8 -755
- package/dist/{agentApi-DLt94vXk.d.ts → content-B2MzIMwA.d.ts} +8 -755
- package/dist/dialogs.d.mts +25 -0
- package/dist/dialogs.d.ts +25 -0
- package/dist/dialogs.js +1 -0
- package/dist/dialogs.mjs +1 -0
- package/dist/document-DZ_ZeZEH.d.ts +294 -0
- package/dist/document-Di1qGqLS.d.mts +294 -0
- package/dist/executor-EPEB53SJ.js +1 -0
- package/dist/executor-TVJ6K6MW.mjs +1 -0
- package/dist/findReplace-CpIoILbP.d.mts +138 -0
- package/dist/findReplace-pkMskVJU.d.ts +138 -0
- package/dist/hooks.d.mts +598 -0
- package/dist/hooks.d.ts +598 -0
- package/dist/hooks.js +1 -0
- package/dist/hooks.mjs +1 -0
- package/dist/index.d.mts +1013 -483
- package/dist/index.d.ts +1013 -483
- package/dist/index.js +40 -120
- package/dist/index.mjs +40 -120
- package/dist/layout-bridge-5GYGYKM5.mjs +1 -0
- package/dist/layout-bridge-QQDA7ELH.js +1 -0
- package/dist/plugin-api.d.mts +176 -0
- package/dist/plugin-api.d.ts +176 -0
- package/dist/plugin-api.js +260 -0
- package/dist/plugin-api.mjs +260 -0
- package/dist/processTemplate-BTBTR7AM.js +1 -0
- package/dist/{processTemplate-W2C5PXZB.mjs → processTemplate-MBX2KDLE.mjs} +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.d.mts +18 -0
- package/dist/styles.d.ts +18 -0
- package/dist/styles.js +1 -0
- package/dist/styles.mjs +1 -0
- package/dist/types-Bd_YzkhG.d.mts +281 -0
- package/dist/types-Bd_YzkhG.d.ts +281 -0
- package/dist/types-CkfDgB0O.d.mts +39 -0
- package/dist/types-DZUhB7Ao.d.mts +18 -0
- package/dist/types-DZUhB7Ao.d.ts +18 -0
- package/dist/types-DcxHFUSc.d.ts +39 -0
- package/dist/ui.d.mts +111 -552
- package/dist/ui.d.ts +111 -552
- package/dist/ui.js +111 -1
- package/dist/ui.mjs +111 -1
- package/dist/useFindReplace-DDs533b-.d.mts +261 -0
- package/dist/useFindReplace-eyhMSZZf.d.ts +261 -0
- package/package.json +41 -43
- package/dist/ClipboardManager-CVKX0v9q.d.ts +0 -464
- package/dist/ClipboardManager-V3aaMnWE.d.mts +0 -464
- package/dist/DocumentAgent-BWflKHpH.d.mts +0 -442
- package/dist/DocumentAgent-DsdXtetF.d.ts +0 -442
- package/dist/FindReplaceDialog-L3YF5HIS.mjs +0 -1
- package/dist/FindReplaceDialog-SEBWC5P7.js +0 -1
- package/dist/HyperlinkDialog-WEK6JSAC.js +0 -1
- package/dist/ImagePropertiesDialog-527MFLQO.mjs +0 -1
- package/dist/ImagePropertiesDialog-HG4K3IE7.js +0 -1
- package/dist/PageSetupDialog-GALVJMUB.js +0 -1
- package/dist/PageSetupDialog-TGQIAMI7.mjs +0 -1
- package/dist/TableToolbar-DUgmob2I.d.ts +0 -1273
- package/dist/TableToolbar-YL74HNS1.d.mts +0 -1273
- package/dist/chunk-23SXXIZS.js +0 -111
- package/dist/chunk-3F52AP2Q.js +0 -1
- package/dist/chunk-42O5GXM5.mjs +0 -82
- package/dist/chunk-54ULJEHM.mjs +0 -1
- package/dist/chunk-5XK326FI.mjs +0 -1
- package/dist/chunk-6WPRCJ5A.mjs +0 -1
- package/dist/chunk-76IYR7C7.mjs +0 -1
- package/dist/chunk-7BG7QY7I.js +0 -182
- package/dist/chunk-AGRIVA4G.js +0 -1
- package/dist/chunk-BTCQ2QI3.mjs +0 -3
- package/dist/chunk-BUEMG4NW.js +0 -1
- package/dist/chunk-BXRC4U3X.mjs +0 -2
- package/dist/chunk-CPAYKE6X.mjs +0 -1
- package/dist/chunk-DACWLFKI.mjs +0 -1
- package/dist/chunk-EPBFWE36.js +0 -2
- package/dist/chunk-FXES3YDB.js +0 -82
- package/dist/chunk-HI66BSGS.mjs +0 -9
- package/dist/chunk-INTPVEO6.mjs +0 -9
- package/dist/chunk-IOAGVW6Q.mjs +0 -2
- package/dist/chunk-JCEWC5QL.mjs +0 -4
- package/dist/chunk-JTIUFACT.js +0 -1
- package/dist/chunk-KUTCCI4X.mjs +0 -182
- package/dist/chunk-LUF7PWIC.js +0 -10
- package/dist/chunk-MGEN6GOE.mjs +0 -2
- package/dist/chunk-MOE2ZGUE.js +0 -18
- package/dist/chunk-MWLHJWB6.js +0 -9
- package/dist/chunk-OFYVDN3U.mjs +0 -2
- package/dist/chunk-P4VSHBGZ.js +0 -2
- package/dist/chunk-P5FQHIES.mjs +0 -1
- package/dist/chunk-PBC7XAYZ.js +0 -3
- package/dist/chunk-PEMB6SZT.js +0 -2
- package/dist/chunk-PQMSZTBB.js +0 -9
- package/dist/chunk-Q7UDQXAF.js +0 -1
- package/dist/chunk-QGTAIC5E.js +0 -1
- package/dist/chunk-QVPR2W5S.js +0 -1
- package/dist/chunk-R3QMYPL5.mjs +0 -59
- package/dist/chunk-RBUTXXQJ.mjs +0 -18
- package/dist/chunk-RRWYZ2TS.mjs +0 -111
- package/dist/chunk-SFUM35DH.js +0 -2
- package/dist/chunk-SNLC6EK2.js +0 -1
- package/dist/chunk-TMTLIGLZ.js +0 -59
- package/dist/chunk-TSE2PWFX.mjs +0 -10
- package/dist/chunk-UWYD42WV.js +0 -4
- package/dist/chunk-UXVACQCY.mjs +0 -1
- package/dist/chunk-W4EIKDM6.mjs +0 -2
- package/dist/chunk-W53SI3XW.mjs +0 -1
- package/dist/chunk-WNS2RBQD.js +0 -2
- package/dist/chunk-Z3KMSHUP.js +0 -1
- package/dist/core-plugins-reexport.d.mts +0 -31
- package/dist/core-plugins-reexport.d.ts +0 -31
- package/dist/core-plugins-reexport.js +0 -1
- package/dist/core-plugins-reexport.mjs +0 -1
- package/dist/core-reexport.d.mts +0 -340
- package/dist/core-reexport.d.ts +0 -340
- package/dist/core-reexport.js +0 -1
- package/dist/core-reexport.mjs +0 -1
- package/dist/documentSerializer-DtS_-oGA.d.mts +0 -664
- package/dist/documentSerializer-Wj1p2ASa.d.ts +0 -664
- package/dist/executor-C3VXF7QA.mjs +0 -1
- package/dist/executor-GDBV3AGV.js +0 -1
- package/dist/headless-reexport.d.mts +0 -197
- package/dist/headless-reexport.d.ts +0 -197
- package/dist/headless-reexport.js +0 -1
- package/dist/headless-reexport.mjs +0 -1
- package/dist/insertOperations-BTH1Asas.d.mts +0 -176
- package/dist/insertOperations-CbUnXAXH.d.ts +0 -176
- package/dist/layout-bridge-EA4DJ227.js +0 -1
- package/dist/layout-bridge-XDPSO6GO.mjs +0 -1
- package/dist/mcp-reexport.d.mts +0 -156
- package/dist/mcp-reexport.d.ts +0 -156
- package/dist/mcp-reexport.js +0 -16
- package/dist/mcp-reexport.mjs +0 -16
- package/dist/processTemplate-MJ2PCSO5.js +0 -1
- package/dist/react-B0W16SV6.d.ts +0 -1330
- package/dist/react-D0Pn1nww.d.mts +0 -1330
- package/dist/react.css +0 -1
- package/dist/react.d.mts +0 -10
- package/dist/react.d.ts +0 -10
- package/dist/react.js +0 -1
- package/dist/react.mjs +0 -1
- package/dist/registry-CH9V-IX0.d.ts +0 -165
- package/dist/registry-CWBKYlNW.d.mts +0 -165
- package/dist/types-UDsUq8D3.d.mts +0 -310
- package/dist/types-jbivc9Lj.d.ts +0 -310
- package/dist/variableDetector-CdQ7ZTzA.d.mts +0 -204
- package/dist/variableDetector-DsRV3A9z.d.ts +0 -204
- package/i18n/de.json +0 -792
- package/i18n/en.json +0 -792
- package/i18n/he.json +0 -792
- package/i18n/pl.json +0 -792
- package/i18n/pt-BR.json +0 -792
- package/i18n/tr.json +0 -792
- package/i18n/zh-CN.json +0 -792
- /package/dist/{chunk-YC5KZSYD.js → chunk-ESZ6JRTW.js} +0 -0
- /package/dist/{chunk-LVGJKS7Y.mjs → chunk-TZMMD6RR.mjs} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { D as DEFAULT_SELECTION_STYLE, a as DocxEditor, b as DocxEditorHandle, c as DocxEditorProps, d as DocxEditorRef, E as EditorMode, e as EditorPlugin, f as ErrorBoundary, g as ErrorBoundaryProps, h as ErrorContextValue, i as ErrorProvider, H as HIGH_CONTRAST_SELECTION_STYLE, j as HighlightRect, P as PLUGIN_HOST_STYLES, k as ParseErrorDisplay, l as ParseErrorDisplayProps, m as PluginContext, n as PluginHost, o as PluginHostProps, p as PluginHostRef, q as ReactSidebarItem, r as RenderAsyncOptions, S as SELECTION_CSS_VARS, s as SelectionHighlightConfig, t as SelectionOverlayProps, u as SelectionRange, v as SidebarItemRenderProps, T as TableSelectionState, U as UnsupportedFeatureWarning, w as UnsupportedFeatureWarningProps, x as UseAutoSaveOptions, y as UseAutoSaveReturn, z as UseClipboardOptions, A as UseClipboardReturn, B as UseSelectionHighlightOptions, C as UseSelectionHighlightReturn, F as UseTableSelectionOptions, G as UseTableSelectionReturn, I as UseWheelZoomOptions, J as UseWheelZoomReturn, Z as ZOOM_PRESETS, K as areSelectionStylesInjected, L as clampZoom, M as clearSelection, N as createSelectionChangeHandler, O as findNearestZoomPreset, Q as formatZoom, V as generateOverlayElements, W as generateSelectionCSS, X as getHighlightRectStyle, Y as getMergedSelectionRects, _ as getNextZoomPreset, $ as getPreviousZoomPreset, a0 as getSelectedText, a1 as getSelectionBoundingRect, a2 as getSelectionRects, a3 as getUserFriendlyMessage, a4 as getZoomPresets, a5 as hasActiveSelection, a6 as highlightTextRange, a7 as injectSelectionStyles, a8 as isParseError, a9 as isSelectionBackwards, aa as isSelectionWithin, ab as isZoomPreset, ac as mergeAdjacentRects, ad as normalizeSelectionDirection, ae as parseZoom, af as removeSelectionStyles, ag as renderAsync, ah as selectRange, ai as useAutoSave, aj as useClipboard, ak as useErrorNotifications, al as useSelectionHighlight, am as useTableSelection, an as useWheelZoom } from './react-D0Pn1nww.mjs';
|
|
3
|
-
export { A as AgentContextOptions, C as CreateEmptyDocumentOptions, E as ExtendedSelectionContext, P as ProcessTemplateOptions, a as ProcessTemplateResult, b as SelectionContextOptions, c as blendColors, d as buildExtendedSelectionContext, e as buildSelectionContext, g as colorsEqual, h as createDocumentWithText, i as createEmptyDocument, j as createRgbColor, l as createThemeColor, m as darkenColor, n as emuToPixels, o as emuToTwips, p as executeCommand, q as executeCommands, r as formatPx, s as getAgentContext, t as getContrastingColor, u as getDocumentSummary, x as getTemplateTags, y as halfPointsToPixels, z as isBlack, B as isWhite, D as lightenColor, G as parseColorString, H as parseDocx, I as pixelsToEmu, J as pixelsToTwips, K as pointsToPixels, M as processTemplate, O as processTemplateAsBlob, Q as processTemplateDetailed, R as resolveColor, U as resolveHighlightColor, V as resolveShadingColor, W as serializeDocumentBody, X as serializeDocx, Y as serializeSectionProperties, Z as twipsToEmu, _ as twipsToPixels, $ as validateTemplate } from './documentSerializer-DtS_-oGA.mjs';
|
|
4
|
-
import { T as Translations, a as TranslationKey } from './TableToolbar-YL74HNS1.mjs';
|
|
5
|
-
export { C as CLIPBOARD_TYPES, b as ClipboardContent, c as ClipboardOptions, F as FontOption, d as FontPicker, e as FontPickerProps, I as INTERNAL_CLIPBOARD_TYPE, L as LocaleStrings, P as ParsedClipboardContent, f as PartialLocaleStrings, g as PrintButton, h as PrintButtonProps, i as PrintOptions, j as PrintStyles, k as TableAction, l as TableContext, m as TableSelection, n as TableSplitConfig, o as TableToolbar, p as TableToolbarProps, q as addColumn, r as addRow, s as cleanWordHtml, t as copyParagraphs, u as copyRuns, v as createClipboardHandlers, w as createTableContext, x as deleteColumn, y as deleteRow, z as formatPrintPageRange, A as getCellAt, B as getColumnCount, D as getDefaultPrintOptions, E as getTableSplitCellDialogConfig, G as handlePasteEvent, H as htmlToRuns, J as isEditorHtml, K as isPrintSupported, M as isWordHtml, N as mergeCells, O as openPrintWindow, Q as paragraphsToClipboardContent, R as parseClipboardHtml, S as parsePageRange, U as readFromClipboard, V as runsToClipboardContent, W as splitCell, X as splitTableCell, Y as triggerPrint, Z as writeToClipboard } from './TableToolbar-YL74HNS1.mjs';
|
|
6
|
-
export { D as DocumentAgent, g as DocxInput, t as toArrayBuffer } from './DocumentAgent-BWflKHpH.mjs';
|
|
7
|
-
export { I as InsertPosition, c as canRenderFont, a as countPageBreaks, b as createColumnBreak, d as createHorizontalRule, e as createLineBreak, f as createPageBreak, g as createPageBreakParagraph, h as createPageBreakRun, i as findPageBreaks, j as getLoadedFonts, k as hasPageBreakBefore, l as insertHorizontalRule, m as insertPageBreak, n as isBreakContent, o as isColumnBreak, p as isFontLoaded, q as isFontsLoading, r as isLineBreak, s as isPageBreak, t as loadFont, u as loadFontFromBuffer, v as loadFonts, w as onFontsLoaded, x as preloadCommonFonts, y as removePageBreak } from './insertOperations-BTH1Asas.mjs';
|
|
8
|
-
export { f as AIAction, g as AIActionRequest, A as AgentCommand, h as AgentContext, i as AgentResponse, j as ApplyStyleCommand, l as BlockContent, ad as BookmarkEnd, ae as BookmarkStart, aq as BorderSpec, C as Comment, p as DeleteTextCommand, D as Document, d as DocumentBody, r as DocxPackage, E as Endnote, af as Field, ag as FooterReference, F as Footnote, t as FormatTextCommand, ah as HeaderFooter, ai as HeaderReference, H as Hyperlink, I as Image, u as InsertHyperlinkCommand, v as InsertImageCommand, w as InsertTableCommand, x as InsertTextCommand, ar as LineSpacingRule, L as ListLevel, as as NumberFormat, N as NumberingDefinitions, a as Paragraph, at as ParagraphAlignment, G as ParagraphContent, J as ParagraphContext, K as ParagraphFormatting, P as Position, R as Range, Q as Relationship, S as ReplaceTextCommand, b as Run, c as RunContent, au as Section, V as SectionProperties, W as SelectionContext, X as SetVariableCommand, aj as Shape, Y as Style, Z as StyleDefinitions, $ as SuggestedAction, e as Table, av as TableBorders, a0 as TableCell, aw as TableCellFormatting, a1 as TableRow, ak as TextBox, a2 as TextContent, T as TextFormatting, a3 as Theme, al as ThemeColorScheme, am as ThemeFont, an as ThemeFontScheme } from './agentApi-DLt94vXk.mjs';
|
|
9
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
|
+
import * as React from 'react';
|
|
10
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
11
|
-
import
|
|
12
|
-
|
|
3
|
+
import * as prosemirror_view from 'prosemirror-view';
|
|
4
|
+
import { EditorView } from 'prosemirror-view';
|
|
13
5
|
import * as prosemirror_state from 'prosemirror-state';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
7
|
+
import { D as Document, T as Theme } from './document-Di1qGqLS.mjs';
|
|
8
|
+
import { S as StyleInfo, A as AgentContext, P as Position, R as Range, a as AgentCommand, F as FontOption, b as PrintOptions } from './agentApi-C41hiW-n.mjs';
|
|
9
|
+
import { R as RenderedDomContext, a as ReactSidebarItem } from './types-Bd_YzkhG.mjs';
|
|
10
|
+
import { T as TextFormatting, P as ParagraphFormatting, C as Comment } from './content-B2MzIMwA.mjs';
|
|
11
|
+
import { T as Translations, a as TranslationKey } from './types-DZUhB7Ao.mjs';
|
|
12
|
+
export { L as LocaleStrings, P as PartialLocaleStrings } from './types-DZUhB7Ao.mjs';
|
|
13
|
+
import { E as EditorHandle } from './types-CkfDgB0O.mjs';
|
|
14
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
20
15
|
import 'prosemirror-model';
|
|
16
|
+
import '@eigenpal/docx-editor-i18n/en.json';
|
|
21
17
|
|
|
22
18
|
interface LocaleProviderProps {
|
|
23
19
|
i18n?: Translations;
|
|
@@ -29,564 +25,1098 @@ declare function useTranslation(): {
|
|
|
29
25
|
};
|
|
30
26
|
|
|
31
27
|
/**
|
|
32
|
-
*
|
|
28
|
+
* Selective Save Module
|
|
33
29
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* - Shift+Home/End: Select to start/end of line
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Navigation direction
|
|
43
|
-
*/
|
|
44
|
-
type NavigationDirection = 'left' | 'right' | 'up' | 'down';
|
|
45
|
-
/**
|
|
46
|
-
* Navigation unit
|
|
47
|
-
*/
|
|
48
|
-
type NavigationUnit = 'character' | 'word' | 'line' | 'paragraph' | 'document';
|
|
49
|
-
/**
|
|
50
|
-
* Keyboard navigation action
|
|
51
|
-
*/
|
|
52
|
-
interface NavigationAction {
|
|
53
|
-
/** Direction to navigate */
|
|
54
|
-
direction: NavigationDirection;
|
|
55
|
-
/** Unit of movement */
|
|
56
|
-
unit: NavigationUnit;
|
|
57
|
-
/** Whether to extend selection */
|
|
58
|
-
extend: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Keyboard shortcut definition
|
|
30
|
+
* Orchestrates selective XML patching for the save flow.
|
|
31
|
+
* Serializes full document.xml, validates patch safety, builds patched XML,
|
|
32
|
+
* and calls applyUpdatesToZip() to produce the final DOCX.
|
|
33
|
+
*
|
|
34
|
+
* Returns null on any failure, signaling the caller to fall back to full repack.
|
|
62
35
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
|
|
37
|
+
interface SelectiveSaveOptions {
|
|
38
|
+
/** Changed paragraph IDs to selectively patch */
|
|
39
|
+
changedParaIds: Set<string>;
|
|
40
|
+
/** Whether structural changes occurred (paragraph add/delete) */
|
|
41
|
+
structuralChange: boolean;
|
|
42
|
+
/** Whether any changes affected paragraphs without paraId */
|
|
43
|
+
hasUntrackedChanges: boolean;
|
|
69
44
|
}
|
|
45
|
+
|
|
70
46
|
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Check if a character is whitespace
|
|
76
|
-
*/
|
|
77
|
-
declare function isWhitespace(char: string): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Check if a character is a punctuation character
|
|
47
|
+
* Flexible input types for DOCX documents.
|
|
48
|
+
*
|
|
49
|
+
* Accepts any common binary format so consumers don't need to manually
|
|
50
|
+
* convert before passing data to the editor or parser.
|
|
80
51
|
*/
|
|
81
|
-
declare function isPunctuation(char: string): boolean;
|
|
82
52
|
/**
|
|
83
|
-
*
|
|
53
|
+
* Any binary representation of a DOCX file that the editor can consume.
|
|
54
|
+
*
|
|
55
|
+
* - `ArrayBuffer` — from `FileReader.readAsArrayBuffer()` or `fetch().arrayBuffer()`
|
|
56
|
+
* - `Uint8Array` — from Node.js `fs.readFile()` or streaming APIs
|
|
57
|
+
* - `Blob` — from drag-and-drop or `<input type="file">`
|
|
58
|
+
* - `File` — subclass of Blob, from `<input type="file">`
|
|
84
59
|
*/
|
|
85
|
-
|
|
60
|
+
type DocxInput = ArrayBuffer | Uint8Array | Blob | File;
|
|
61
|
+
|
|
86
62
|
/**
|
|
87
|
-
*
|
|
63
|
+
* DocumentAgent - High-level fluent API for programmatic document manipulation
|
|
64
|
+
*
|
|
65
|
+
* Provides a convenient interface for:
|
|
66
|
+
* - Reading document content and metadata
|
|
67
|
+
* - Editing text with formatting
|
|
68
|
+
* - Inserting tables, images, and hyperlinks
|
|
69
|
+
* - Managing template variables
|
|
70
|
+
* - Exporting to DOCX buffer
|
|
71
|
+
*
|
|
72
|
+
* All operations are immutable - they return a new DocumentAgent instance
|
|
73
|
+
* or don't modify the underlying document.
|
|
88
74
|
*/
|
|
89
|
-
|
|
75
|
+
|
|
90
76
|
/**
|
|
91
|
-
*
|
|
77
|
+
* Options for inserting text
|
|
92
78
|
*/
|
|
93
|
-
|
|
79
|
+
interface InsertTextOptions {
|
|
80
|
+
/** Text formatting */
|
|
81
|
+
formatting?: TextFormatting;
|
|
82
|
+
}
|
|
94
83
|
/**
|
|
95
|
-
*
|
|
84
|
+
* Options for inserting table
|
|
96
85
|
*/
|
|
97
|
-
|
|
86
|
+
interface InsertTableOptions {
|
|
87
|
+
/** Table data (2D array of strings) */
|
|
88
|
+
data?: string[][];
|
|
89
|
+
/** Whether first row is a header */
|
|
90
|
+
hasHeader?: boolean;
|
|
91
|
+
}
|
|
98
92
|
/**
|
|
99
|
-
*
|
|
100
|
-
* Uses visual line detection based on bounding rectangles
|
|
93
|
+
* Options for inserting image
|
|
101
94
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
interface InsertImageOptions {
|
|
96
|
+
/** Image width in pixels */
|
|
97
|
+
width?: number;
|
|
98
|
+
/** Image height in pixels */
|
|
99
|
+
height?: number;
|
|
100
|
+
/** Alt text for accessibility */
|
|
101
|
+
alt?: string;
|
|
102
|
+
}
|
|
106
103
|
/**
|
|
107
|
-
*
|
|
108
|
-
* Uses visual line detection based on bounding rectangles
|
|
104
|
+
* Options for inserting hyperlink
|
|
109
105
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
interface InsertHyperlinkOptions {
|
|
107
|
+
/** Display text (overrides selected text) */
|
|
108
|
+
displayText?: string;
|
|
109
|
+
/** Tooltip on hover */
|
|
110
|
+
tooltip?: string;
|
|
111
|
+
}
|
|
114
112
|
/**
|
|
115
|
-
*
|
|
113
|
+
* Formatted text segment
|
|
116
114
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
offset: number;
|
|
120
|
-
anchorNode: Node | null;
|
|
121
|
-
anchorOffset: number;
|
|
122
|
-
focusNode: Node | null;
|
|
123
|
-
focusOffset: number;
|
|
124
|
-
isCollapsed: boolean;
|
|
115
|
+
interface FormattedTextSegment {
|
|
116
|
+
/** Text content */
|
|
125
117
|
text: string;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*/
|
|
134
|
-
declare function extendSelectionTo(node: Node, offset: number): void;
|
|
135
|
-
/**
|
|
136
|
-
* Move selection by word in a text node
|
|
137
|
-
*/
|
|
138
|
-
declare function moveByWord(direction: 'left' | 'right', extend?: boolean): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Move to start/end of line
|
|
141
|
-
*/
|
|
142
|
-
declare function moveToLineEdge(edge: 'start' | 'end', extend?: boolean): boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Parse a keyboard event into a navigation action
|
|
145
|
-
*/
|
|
146
|
-
declare function parseNavigationAction(event: KeyboardEvent): NavigationAction | null;
|
|
118
|
+
/** Applied formatting */
|
|
119
|
+
formatting?: TextFormatting;
|
|
120
|
+
/** Is part of a hyperlink */
|
|
121
|
+
isHyperlink?: boolean;
|
|
122
|
+
/** Hyperlink URL if applicable */
|
|
123
|
+
hyperlinkUrl?: string;
|
|
124
|
+
}
|
|
147
125
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
126
|
+
* DocumentAgent provides a fluent API for document manipulation
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const agent = new DocumentAgent(buffer);
|
|
131
|
+
*
|
|
132
|
+
* // Read operations
|
|
133
|
+
* const text = agent.getText();
|
|
134
|
+
* const wordCount = agent.getWordCount();
|
|
135
|
+
* const variables = agent.getVariables();
|
|
136
|
+
*
|
|
137
|
+
* // Write operations (returns new agent)
|
|
138
|
+
* const newAgent = agent
|
|
139
|
+
* .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ', { formatting: { bold: true } })
|
|
140
|
+
* .applyStyle({ paragraphIndex: 0, offset: 0 }, { paragraphIndex: 0, offset: 5 }, 'Heading1');
|
|
141
|
+
*
|
|
142
|
+
* // Export
|
|
143
|
+
* const newBuffer = await newAgent.toBuffer();
|
|
144
|
+
* ```
|
|
150
145
|
*/
|
|
151
|
-
declare
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
declare class DocumentAgent {
|
|
147
|
+
private _document;
|
|
148
|
+
private _pendingVariables;
|
|
149
|
+
/**
|
|
150
|
+
* Create a new DocumentAgent
|
|
151
|
+
*
|
|
152
|
+
* @param source - Document object or ArrayBuffer to parse
|
|
153
|
+
*/
|
|
154
|
+
constructor(source: Document | ArrayBuffer);
|
|
155
|
+
/**
|
|
156
|
+
* Create a DocumentAgent from a DOCX buffer (async)
|
|
157
|
+
*
|
|
158
|
+
* @param buffer - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
|
|
159
|
+
* @returns Promise resolving to DocumentAgent
|
|
160
|
+
*/
|
|
161
|
+
static fromBuffer(buffer: DocxInput): Promise<DocumentAgent>;
|
|
162
|
+
/**
|
|
163
|
+
* Create a DocumentAgent from a Document object
|
|
164
|
+
*
|
|
165
|
+
* @param document - Parsed Document
|
|
166
|
+
* @returns DocumentAgent
|
|
167
|
+
*/
|
|
168
|
+
static fromDocument(document: Document): DocumentAgent;
|
|
169
|
+
/**
|
|
170
|
+
* Get the underlying document
|
|
171
|
+
*/
|
|
172
|
+
getDocument(): Document;
|
|
173
|
+
/**
|
|
174
|
+
* Get plain text content of the document
|
|
175
|
+
*
|
|
176
|
+
* @returns All document text concatenated
|
|
177
|
+
*/
|
|
178
|
+
getText(): string;
|
|
179
|
+
/**
|
|
180
|
+
* Get formatted text segments
|
|
181
|
+
*
|
|
182
|
+
* @returns Array of text segments with formatting info
|
|
183
|
+
*/
|
|
184
|
+
getFormattedText(): FormattedTextSegment[];
|
|
185
|
+
/**
|
|
186
|
+
* Get detected template variables
|
|
187
|
+
*
|
|
188
|
+
* @returns Array of variable names (without braces)
|
|
189
|
+
*/
|
|
190
|
+
getVariables(): string[];
|
|
191
|
+
/**
|
|
192
|
+
* Get available styles from the document
|
|
193
|
+
*
|
|
194
|
+
* @returns Array of style info
|
|
195
|
+
*/
|
|
196
|
+
getStyles(): StyleInfo[];
|
|
197
|
+
/**
|
|
198
|
+
* Get approximate page count
|
|
199
|
+
*
|
|
200
|
+
* Note: This is an estimate based on content length.
|
|
201
|
+
* Actual page count requires full layout computation.
|
|
202
|
+
*
|
|
203
|
+
* @returns Estimated page count
|
|
204
|
+
*/
|
|
205
|
+
getPageCount(): number;
|
|
206
|
+
/**
|
|
207
|
+
* Get word count
|
|
208
|
+
*
|
|
209
|
+
* @returns Number of words in the document
|
|
210
|
+
*/
|
|
211
|
+
getWordCount(): number;
|
|
212
|
+
/**
|
|
213
|
+
* Get character count
|
|
214
|
+
*
|
|
215
|
+
* @param includeSpaces - Whether to include whitespace
|
|
216
|
+
* @returns Number of characters
|
|
217
|
+
*/
|
|
218
|
+
getCharacterCount(includeSpaces?: boolean): number;
|
|
219
|
+
/**
|
|
220
|
+
* Get paragraph count
|
|
221
|
+
*
|
|
222
|
+
* @returns Number of paragraphs
|
|
223
|
+
*/
|
|
224
|
+
getParagraphCount(): number;
|
|
225
|
+
/**
|
|
226
|
+
* Get table count
|
|
227
|
+
*
|
|
228
|
+
* @returns Number of tables
|
|
229
|
+
*/
|
|
230
|
+
getTableCount(): number;
|
|
231
|
+
/**
|
|
232
|
+
* Get document context for AI agents
|
|
233
|
+
*
|
|
234
|
+
* @param outlineMaxChars - Max characters per paragraph in outline
|
|
235
|
+
* @returns Agent context
|
|
236
|
+
*/
|
|
237
|
+
getAgentContext(outlineMaxChars?: number): AgentContext;
|
|
238
|
+
/**
|
|
239
|
+
* Insert text at a position
|
|
240
|
+
*
|
|
241
|
+
* @param position - Where to insert
|
|
242
|
+
* @param text - Text to insert
|
|
243
|
+
* @param options - Insert options
|
|
244
|
+
* @returns New DocumentAgent with text inserted
|
|
245
|
+
*/
|
|
246
|
+
insertText(position: Position, text: string, options?: InsertTextOptions): DocumentAgent;
|
|
247
|
+
/**
|
|
248
|
+
* Replace text in a range
|
|
249
|
+
*
|
|
250
|
+
* @param range - Range to replace
|
|
251
|
+
* @param text - Replacement text
|
|
252
|
+
* @param options - Replace options
|
|
253
|
+
* @returns New DocumentAgent with text replaced
|
|
254
|
+
*/
|
|
255
|
+
replaceRange(range: Range, text: string, options?: InsertTextOptions): DocumentAgent;
|
|
256
|
+
/**
|
|
257
|
+
* Delete text in a range
|
|
258
|
+
*
|
|
259
|
+
* @param range - Range to delete
|
|
260
|
+
* @returns New DocumentAgent with text deleted
|
|
261
|
+
*/
|
|
262
|
+
deleteRange(range: Range): DocumentAgent;
|
|
263
|
+
/**
|
|
264
|
+
* Apply text formatting to a range
|
|
265
|
+
*
|
|
266
|
+
* @param range - Range to format
|
|
267
|
+
* @param formatting - Formatting to apply
|
|
268
|
+
* @returns New DocumentAgent with formatting applied
|
|
269
|
+
*/
|
|
270
|
+
applyFormatting(range: Range, formatting: Partial<TextFormatting>): DocumentAgent;
|
|
271
|
+
/**
|
|
272
|
+
* Apply a named style to a paragraph
|
|
273
|
+
*
|
|
274
|
+
* @param paragraphIndex - Index of the paragraph
|
|
275
|
+
* @param styleId - Style ID to apply
|
|
276
|
+
* @returns New DocumentAgent with style applied
|
|
277
|
+
*/
|
|
278
|
+
applyStyle(paragraphIndex: number, styleId: string): DocumentAgent;
|
|
279
|
+
/**
|
|
280
|
+
* Apply paragraph formatting
|
|
281
|
+
*
|
|
282
|
+
* @param paragraphIndex - Index of the paragraph
|
|
283
|
+
* @param formatting - Formatting to apply
|
|
284
|
+
* @returns New DocumentAgent with formatting applied
|
|
285
|
+
*/
|
|
286
|
+
applyParagraphFormatting(paragraphIndex: number, formatting: Partial<ParagraphFormatting>): DocumentAgent;
|
|
287
|
+
/**
|
|
288
|
+
* Insert a table at a position
|
|
289
|
+
*
|
|
290
|
+
* @param position - Where to insert the table
|
|
291
|
+
* @param rows - Number of rows
|
|
292
|
+
* @param cols - Number of columns
|
|
293
|
+
* @param options - Table options
|
|
294
|
+
* @returns New DocumentAgent with table inserted
|
|
295
|
+
*/
|
|
296
|
+
insertTable(position: Position, rows: number, cols: number, options?: InsertTableOptions): DocumentAgent;
|
|
297
|
+
/**
|
|
298
|
+
* Insert an image at a position
|
|
299
|
+
*
|
|
300
|
+
* @param position - Where to insert the image
|
|
301
|
+
* @param src - Image source (base64 data URL or URL)
|
|
302
|
+
* @param options - Image options
|
|
303
|
+
* @returns New DocumentAgent with image inserted
|
|
304
|
+
*/
|
|
305
|
+
insertImage(position: Position, src: string, options?: InsertImageOptions): DocumentAgent;
|
|
306
|
+
/**
|
|
307
|
+
* Insert a hyperlink
|
|
308
|
+
*
|
|
309
|
+
* @param range - Range to make into a hyperlink
|
|
310
|
+
* @param url - URL of the hyperlink
|
|
311
|
+
* @param options - Hyperlink options
|
|
312
|
+
* @returns New DocumentAgent with hyperlink inserted
|
|
313
|
+
*/
|
|
314
|
+
insertHyperlink(range: Range, url: string, options?: InsertHyperlinkOptions): DocumentAgent;
|
|
315
|
+
/**
|
|
316
|
+
* Remove a hyperlink but keep the text
|
|
317
|
+
*
|
|
318
|
+
* @param range - Range containing the hyperlink
|
|
319
|
+
* @returns New DocumentAgent with hyperlink removed
|
|
320
|
+
*/
|
|
321
|
+
removeHyperlink(range: Range): DocumentAgent;
|
|
322
|
+
/**
|
|
323
|
+
* Insert a paragraph break
|
|
324
|
+
*
|
|
325
|
+
* @param position - Where to break the paragraph
|
|
326
|
+
* @returns New DocumentAgent with paragraph broken
|
|
327
|
+
*/
|
|
328
|
+
insertParagraphBreak(position: Position): DocumentAgent;
|
|
329
|
+
/**
|
|
330
|
+
* Merge consecutive paragraphs
|
|
331
|
+
*
|
|
332
|
+
* @param startParagraphIndex - First paragraph index
|
|
333
|
+
* @param count - Number of paragraphs to merge with the first
|
|
334
|
+
* @returns New DocumentAgent with paragraphs merged
|
|
335
|
+
*/
|
|
336
|
+
mergeParagraphs(startParagraphIndex: number, count: number): DocumentAgent;
|
|
337
|
+
/**
|
|
338
|
+
* Set a template variable value
|
|
339
|
+
*
|
|
340
|
+
* Note: Variables are not applied until `applyVariables()` is called
|
|
341
|
+
*
|
|
342
|
+
* @param name - Variable name (without braces)
|
|
343
|
+
* @param value - Variable value
|
|
344
|
+
* @returns This DocumentAgent (for chaining)
|
|
345
|
+
*/
|
|
346
|
+
setVariable(name: string, value: string): DocumentAgent;
|
|
347
|
+
/**
|
|
348
|
+
* Set multiple template variables
|
|
349
|
+
*
|
|
350
|
+
* @param variables - Map of variable names to values
|
|
351
|
+
* @returns This DocumentAgent (for chaining)
|
|
352
|
+
*/
|
|
353
|
+
setVariables(variables: Record<string, string>): DocumentAgent;
|
|
354
|
+
/**
|
|
355
|
+
* Get pending variable values
|
|
356
|
+
*
|
|
357
|
+
* @returns Map of pending variable values
|
|
358
|
+
*/
|
|
359
|
+
getPendingVariables(): Record<string, string>;
|
|
360
|
+
/**
|
|
361
|
+
* Clear pending variables
|
|
362
|
+
*
|
|
363
|
+
* @returns This DocumentAgent (for chaining)
|
|
364
|
+
*/
|
|
365
|
+
clearPendingVariables(): DocumentAgent;
|
|
366
|
+
/**
|
|
367
|
+
* Apply all pending template variables
|
|
368
|
+
*
|
|
369
|
+
* Uses docxtemplater to substitute variables while preserving formatting.
|
|
370
|
+
*
|
|
371
|
+
* @param variables - Optional additional variables (merged with pending)
|
|
372
|
+
* @returns New DocumentAgent with variables applied
|
|
373
|
+
*/
|
|
374
|
+
applyVariables(variables?: Record<string, string>): Promise<DocumentAgent>;
|
|
375
|
+
/**
|
|
376
|
+
* Export document to DOCX ArrayBuffer
|
|
377
|
+
*
|
|
378
|
+
* @returns Promise resolving to DOCX file as ArrayBuffer
|
|
379
|
+
*/
|
|
380
|
+
toBuffer(options?: {
|
|
381
|
+
selective?: SelectiveSaveOptions;
|
|
382
|
+
}): Promise<ArrayBuffer>;
|
|
383
|
+
/**
|
|
384
|
+
* Export document to Blob
|
|
385
|
+
*
|
|
386
|
+
* @param mimeType - MIME type for the blob
|
|
387
|
+
* @returns Promise resolving to DOCX file as Blob
|
|
388
|
+
*/
|
|
389
|
+
toBlob(mimeType?: string): Promise<Blob>;
|
|
390
|
+
/**
|
|
391
|
+
* Execute multiple commands in sequence
|
|
392
|
+
*
|
|
393
|
+
* @param commands - Commands to execute
|
|
394
|
+
* @returns New DocumentAgent with all commands applied
|
|
395
|
+
*/
|
|
396
|
+
executeCommands(commands: AgentCommand[]): DocumentAgent;
|
|
397
|
+
/**
|
|
398
|
+
* Execute a single command and return new agent
|
|
399
|
+
*/
|
|
400
|
+
private _executeCommand;
|
|
401
|
+
/**
|
|
402
|
+
* Get plain text from document body
|
|
403
|
+
*/
|
|
404
|
+
private _getBodyText;
|
|
405
|
+
/**
|
|
406
|
+
* Get plain text from a paragraph
|
|
407
|
+
*/
|
|
408
|
+
private _getParagraphText;
|
|
409
|
+
/**
|
|
410
|
+
* Get plain text from a run
|
|
411
|
+
*/
|
|
412
|
+
private _getRunText;
|
|
413
|
+
/**
|
|
414
|
+
* Get plain text from a hyperlink
|
|
415
|
+
*/
|
|
416
|
+
private _getHyperlinkText;
|
|
417
|
+
/**
|
|
418
|
+
* Get plain text from a table
|
|
419
|
+
*/
|
|
420
|
+
private _getTableText;
|
|
421
|
+
/**
|
|
422
|
+
* Extract formatted text segments from a paragraph
|
|
423
|
+
*/
|
|
424
|
+
private _extractParagraphSegments;
|
|
425
|
+
/**
|
|
426
|
+
* Parse heading level from style ID
|
|
427
|
+
*/
|
|
428
|
+
private _parseHeadingLevel;
|
|
429
|
+
/**
|
|
430
|
+
* Check if document has images
|
|
431
|
+
*/
|
|
432
|
+
private _hasImages;
|
|
433
|
+
/**
|
|
434
|
+
* Check if document has hyperlinks
|
|
435
|
+
*/
|
|
436
|
+
private _hasHyperlinks;
|
|
437
|
+
}
|
|
438
|
+
|
|
155
439
|
/**
|
|
156
|
-
*
|
|
440
|
+
* Selection State Utilities
|
|
441
|
+
*
|
|
442
|
+
* Extracts selection state from ProseMirror for toolbar integration.
|
|
157
443
|
*/
|
|
158
|
-
|
|
444
|
+
|
|
159
445
|
/**
|
|
160
|
-
*
|
|
161
|
-
* Used for double-click word selection
|
|
446
|
+
* Selection state for toolbar integration
|
|
162
447
|
*/
|
|
163
|
-
|
|
448
|
+
interface SelectionState {
|
|
449
|
+
/** Whether there's an active selection (not just cursor) */
|
|
450
|
+
hasSelection: boolean;
|
|
451
|
+
/** Whether selection spans multiple paragraphs */
|
|
452
|
+
isMultiParagraph: boolean;
|
|
453
|
+
/** Current text formatting at selection/cursor */
|
|
454
|
+
textFormatting: TextFormatting;
|
|
455
|
+
/** Current paragraph formatting */
|
|
456
|
+
paragraphFormatting: ParagraphFormatting;
|
|
457
|
+
/** Current paragraph style ID (e.g., 'Heading1', 'Normal') */
|
|
458
|
+
styleId: string | null;
|
|
459
|
+
/** Start paragraph index */
|
|
460
|
+
startParagraphIndex: number;
|
|
461
|
+
/** End paragraph index */
|
|
462
|
+
endParagraphIndex: number;
|
|
463
|
+
}
|
|
464
|
+
|
|
164
465
|
/**
|
|
165
|
-
*
|
|
466
|
+
* Layout Engine Types
|
|
467
|
+
*
|
|
468
|
+
* Core types for the paginated layout engine.
|
|
469
|
+
* Converts document blocks + measurements into positioned fragments on pages.
|
|
166
470
|
*/
|
|
167
|
-
declare function getWordAtCursor(): string | null;
|
|
168
471
|
/**
|
|
169
|
-
*
|
|
472
|
+
* Unique identifier for a block in the document.
|
|
473
|
+
* Format: typically `${index}-${type}` or just the block index.
|
|
170
474
|
*/
|
|
171
|
-
|
|
475
|
+
type BlockId = string | number;
|
|
172
476
|
/**
|
|
173
|
-
*
|
|
477
|
+
* Base fragment properties common to all fragment types.
|
|
174
478
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
479
|
+
type FragmentBase = {
|
|
480
|
+
/** Block ID this fragment belongs to. */
|
|
481
|
+
blockId: BlockId;
|
|
482
|
+
/** X position on page (relative to page left). */
|
|
483
|
+
x: number;
|
|
484
|
+
/** Y position on page (relative to page top). */
|
|
485
|
+
y: number;
|
|
486
|
+
/** Width of the fragment. */
|
|
487
|
+
width: number;
|
|
488
|
+
/** ProseMirror start position (for click mapping). */
|
|
489
|
+
pmStart?: number;
|
|
490
|
+
/** ProseMirror end position (for click mapping). */
|
|
491
|
+
pmEnd?: number;
|
|
188
492
|
};
|
|
189
493
|
/**
|
|
190
|
-
*
|
|
191
|
-
|
|
192
|
-
declare function describeShortcut(shortcut: KeyboardShortcut): string;
|
|
193
|
-
/**
|
|
194
|
-
* Get all navigation shortcuts with descriptions
|
|
195
|
-
*/
|
|
196
|
-
declare function getNavigationShortcutDescriptions(): Array<{
|
|
197
|
-
action: string;
|
|
198
|
-
shortcut: string;
|
|
199
|
-
}>;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Find word boundaries around a position in text
|
|
203
|
-
* Returns [startIndex, endIndex] inclusive start, exclusive end
|
|
204
|
-
*/
|
|
205
|
-
declare function findWordBoundaries(text: string, position: number): [number, number];
|
|
206
|
-
/**
|
|
207
|
-
* Get the word at a position in text
|
|
494
|
+
* A paragraph fragment positioned on a page.
|
|
495
|
+
* May span only part of the paragraph's lines if split across pages.
|
|
208
496
|
*/
|
|
209
|
-
|
|
497
|
+
type ParagraphFragment = FragmentBase & {
|
|
498
|
+
kind: 'paragraph';
|
|
499
|
+
/** First line index (inclusive) from the measure. */
|
|
500
|
+
fromLine: number;
|
|
501
|
+
/** Last line index (exclusive) from the measure. */
|
|
502
|
+
toLine: number;
|
|
503
|
+
/** Height of this fragment. */
|
|
504
|
+
height: number;
|
|
505
|
+
/** True if this continues from a previous page. */
|
|
506
|
+
continuesFromPrev?: boolean;
|
|
507
|
+
/** True if this continues onto the next page. */
|
|
508
|
+
continuesOnNext?: boolean;
|
|
509
|
+
};
|
|
210
510
|
/**
|
|
211
|
-
*
|
|
511
|
+
* A table fragment positioned on a page.
|
|
512
|
+
* May span only part of the table's rows if split across pages.
|
|
212
513
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
514
|
+
type TableFragment = FragmentBase & {
|
|
515
|
+
kind: 'table';
|
|
516
|
+
/** First row index (inclusive). */
|
|
517
|
+
fromRow: number;
|
|
518
|
+
/** Last row index (exclusive). */
|
|
519
|
+
toRow: number;
|
|
520
|
+
/** Height of this fragment. */
|
|
521
|
+
height: number;
|
|
522
|
+
/** True if this is a floating table. */
|
|
523
|
+
isFloating?: boolean;
|
|
524
|
+
/** True if this continues from a previous page. */
|
|
525
|
+
continuesFromPrev?: boolean;
|
|
526
|
+
/** True if this continues onto the next page. */
|
|
527
|
+
continuesOnNext?: boolean;
|
|
528
|
+
/** Number of header rows prepended to this continuation fragment (0 or undefined for first fragment). */
|
|
529
|
+
headerRowCount?: number;
|
|
530
|
+
};
|
|
221
531
|
/**
|
|
222
|
-
*
|
|
532
|
+
* An image fragment positioned on a page.
|
|
223
533
|
*/
|
|
224
|
-
|
|
534
|
+
type ImageFragment = FragmentBase & {
|
|
535
|
+
kind: 'image';
|
|
536
|
+
/** Height of the image. */
|
|
537
|
+
height: number;
|
|
538
|
+
/** True if this is an anchored/floating image. */
|
|
539
|
+
isAnchored?: boolean;
|
|
540
|
+
/** Z-index for layering. */
|
|
541
|
+
zIndex?: number;
|
|
542
|
+
};
|
|
225
543
|
/**
|
|
226
|
-
*
|
|
227
|
-
* This works reliably across different browsers and handles contentEditable well.
|
|
544
|
+
* A text box fragment positioned on a page.
|
|
228
545
|
*/
|
|
229
|
-
|
|
546
|
+
type TextBoxFragment = FragmentBase & {
|
|
547
|
+
kind: 'textBox';
|
|
548
|
+
/** Height of the text box. */
|
|
549
|
+
height: number;
|
|
550
|
+
/** True when positioned outside normal document flow. */
|
|
551
|
+
isFloating?: boolean;
|
|
552
|
+
/** Stack order hint for anchored text boxes. */
|
|
553
|
+
zIndex?: number;
|
|
554
|
+
};
|
|
230
555
|
/**
|
|
231
|
-
*
|
|
556
|
+
* Union of all fragment types.
|
|
232
557
|
*/
|
|
233
|
-
|
|
558
|
+
type Fragment = ParagraphFragment | TableFragment | ImageFragment | TextBoxFragment;
|
|
234
559
|
/**
|
|
235
|
-
*
|
|
236
|
-
* If there's a collapsed selection (cursor), selects the word at cursor.
|
|
237
|
-
* If there's an existing selection, expands to include complete words.
|
|
560
|
+
* Page margin configuration.
|
|
238
561
|
*/
|
|
239
|
-
|
|
562
|
+
type PageMargins = {
|
|
563
|
+
top: number;
|
|
564
|
+
right: number;
|
|
565
|
+
bottom: number;
|
|
566
|
+
left: number;
|
|
567
|
+
/** Distance from page top to header content. */
|
|
568
|
+
header?: number;
|
|
569
|
+
/** Distance from page bottom to footer content. */
|
|
570
|
+
footer?: number;
|
|
571
|
+
};
|
|
240
572
|
/**
|
|
241
|
-
*
|
|
242
|
-
* Looks for the nearest element with [data-paragraph-index] attribute.
|
|
573
|
+
* A rendered page containing positioned fragments.
|
|
243
574
|
*/
|
|
244
|
-
|
|
575
|
+
type Page = {
|
|
576
|
+
/** Page number (1-indexed). */
|
|
577
|
+
number: number;
|
|
578
|
+
/** Fragments positioned on this page. */
|
|
579
|
+
fragments: Fragment[];
|
|
580
|
+
/** Page margins. */
|
|
581
|
+
margins: PageMargins;
|
|
582
|
+
/** Page size (width, height). */
|
|
583
|
+
size: {
|
|
584
|
+
w: number;
|
|
585
|
+
h: number;
|
|
586
|
+
};
|
|
587
|
+
/** Page orientation. */
|
|
588
|
+
orientation?: 'portrait' | 'landscape';
|
|
589
|
+
/** Section index this page belongs to. */
|
|
590
|
+
sectionIndex?: number;
|
|
591
|
+
/** Header/footer references for this page. */
|
|
592
|
+
headerFooterRefs?: {
|
|
593
|
+
headerDefault?: string;
|
|
594
|
+
headerFirst?: string;
|
|
595
|
+
headerEven?: string;
|
|
596
|
+
footerDefault?: string;
|
|
597
|
+
footerFirst?: string;
|
|
598
|
+
footerEven?: string;
|
|
599
|
+
};
|
|
600
|
+
/** Footnote IDs that appear on this page (for rendering). */
|
|
601
|
+
footnoteIds?: number[];
|
|
602
|
+
/** Height reserved for the footnote area at page bottom (pixels). */
|
|
603
|
+
footnoteReservedHeight?: number;
|
|
604
|
+
/** Column layout for this page (if multi-column). */
|
|
605
|
+
columns?: ColumnLayout;
|
|
606
|
+
};
|
|
245
607
|
/**
|
|
246
|
-
*
|
|
247
|
-
* Call this in your click handler.
|
|
248
|
-
* Returns the click count (1 = single, 2 = double, 3 = triple).
|
|
608
|
+
* Column layout configuration.
|
|
249
609
|
*/
|
|
250
|
-
|
|
610
|
+
type ColumnLayout = {
|
|
611
|
+
count: number;
|
|
612
|
+
gap: number;
|
|
613
|
+
equalWidth?: boolean;
|
|
614
|
+
/** Draw vertical separator line between columns (w:sep). */
|
|
615
|
+
separator?: boolean;
|
|
616
|
+
};
|
|
251
617
|
/**
|
|
252
|
-
*
|
|
253
|
-
* Returns a function that should be called on dblclick events.
|
|
618
|
+
* Header/footer layout for a specific type.
|
|
254
619
|
*/
|
|
255
|
-
|
|
620
|
+
type HeaderFooterLayout = {
|
|
621
|
+
height: number;
|
|
622
|
+
fragments: Fragment[];
|
|
623
|
+
};
|
|
256
624
|
/**
|
|
257
|
-
*
|
|
258
|
-
* This uses our custom click counting since browsers have inconsistent triple-click.
|
|
625
|
+
* Final layout output ready for rendering/painting.
|
|
259
626
|
*/
|
|
260
|
-
|
|
627
|
+
type Layout = {
|
|
628
|
+
/** Default page size for the document. */
|
|
629
|
+
pageSize: {
|
|
630
|
+
w: number;
|
|
631
|
+
h: number;
|
|
632
|
+
};
|
|
633
|
+
/** All rendered pages with positioned fragments. */
|
|
634
|
+
pages: Page[];
|
|
635
|
+
/** Column configuration (if multi-column). */
|
|
636
|
+
columns?: ColumnLayout;
|
|
637
|
+
/** Header layouts by type (default, first, even). */
|
|
638
|
+
headers?: Record<string, HeaderFooterLayout>;
|
|
639
|
+
/** Footer layouts by type (default, first, even). */
|
|
640
|
+
footers?: Record<string, HeaderFooterLayout>;
|
|
641
|
+
/** Gap between pages in pixels (for rendering). */
|
|
642
|
+
pageGap?: number;
|
|
643
|
+
};
|
|
261
644
|
|
|
262
|
-
interface
|
|
263
|
-
/**
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
|
|
645
|
+
interface PagedEditorRef {
|
|
646
|
+
/** Get the current document. */
|
|
647
|
+
getDocument(): Document | null;
|
|
648
|
+
/** Get the ProseMirror EditorState. */
|
|
649
|
+
getState(): EditorState | null;
|
|
650
|
+
/** Get the ProseMirror EditorView. */
|
|
651
|
+
getView(): EditorView | null;
|
|
652
|
+
/** Focus the editor. */
|
|
653
|
+
focus(): void;
|
|
654
|
+
/** Blur the editor. */
|
|
655
|
+
blur(): void;
|
|
656
|
+
/** Check if focused. */
|
|
657
|
+
isFocused(): boolean;
|
|
658
|
+
/** Dispatch a transaction. */
|
|
659
|
+
dispatch(tr: Transaction): void;
|
|
660
|
+
/** Undo. */
|
|
661
|
+
undo(): boolean;
|
|
662
|
+
/** Redo. */
|
|
663
|
+
redo(): boolean;
|
|
664
|
+
/** Set selection by PM position. */
|
|
665
|
+
setSelection(anchor: number, head?: number): void;
|
|
666
|
+
/** Get current layout. */
|
|
667
|
+
getLayout(): Layout | null;
|
|
668
|
+
/** Force re-layout. */
|
|
669
|
+
relayout(): void;
|
|
670
|
+
/** Scroll the visible pages to bring a PM position into view. */
|
|
671
|
+
scrollToPosition(pmPos: number): void;
|
|
672
|
+
/**
|
|
673
|
+
* Scroll to the paragraph identified by Word `w14:paraId` / PM `paraId`.
|
|
674
|
+
* @returns whether a matching paragraph was found
|
|
675
|
+
*/
|
|
676
|
+
scrollToParaId(paraId: string): boolean;
|
|
283
677
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* close/reopen). The DocxEditor wrapper passes this when the user
|
|
287
|
-
* toggles the panel — kept off by default for standalone usage.
|
|
678
|
+
* Scroll the paginated view so `pageNumber` (1-indexed) is in view.
|
|
679
|
+
* No-op if the layout isn't ready yet or pageNumber is out of range.
|
|
288
680
|
*/
|
|
289
|
-
|
|
681
|
+
scrollToPage(pageNumber: number): void;
|
|
290
682
|
}
|
|
291
|
-
declare function AgentPanel({ title, icon, width: controlledWidth, defaultWidth, minWidth, maxWidth, onWidthChange, onClose, children, className, closed, }: AgentPanelProps): react_jsx_runtime.JSX.Element;
|
|
292
683
|
|
|
293
|
-
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
684
|
+
/**
|
|
685
|
+
* DocxEditor props
|
|
686
|
+
*/
|
|
687
|
+
interface DocxEditorProps {
|
|
688
|
+
/** Document data — ArrayBuffer, Uint8Array, Blob, or File */
|
|
689
|
+
documentBuffer?: DocxInput | null;
|
|
690
|
+
/** Pre-parsed document (alternative to documentBuffer) */
|
|
691
|
+
document?: Document | null;
|
|
692
|
+
/** Callback when document is saved */
|
|
693
|
+
onSave?: (buffer: ArrayBuffer) => void;
|
|
694
|
+
/** Author name used for comments and track changes */
|
|
695
|
+
author?: string;
|
|
696
|
+
/** Callback when document changes */
|
|
697
|
+
onChange?: (document: Document) => void;
|
|
698
|
+
/** Callback when selection changes */
|
|
699
|
+
onSelectionChange?: (state: SelectionState | null) => void;
|
|
700
|
+
/** Callback on error */
|
|
701
|
+
onError?: (error: Error) => void;
|
|
702
|
+
/** Callback when fonts are loaded */
|
|
703
|
+
onFontsLoaded?: () => void;
|
|
704
|
+
/** External ProseMirror plugins (from PluginHost) */
|
|
705
|
+
externalPlugins?: prosemirror_state.Plugin[];
|
|
312
706
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
707
|
+
* When true, the editor treats the `document` prop as a schema seed only and
|
|
708
|
+
* does not load it into ProseMirror on mount. Content is expected to come from
|
|
709
|
+
* external sources — typically `externalPlugins` such as `ySyncPlugin` from
|
|
710
|
+
* `y-prosemirror`, but also any code that dispatches transactions directly.
|
|
711
|
+
*
|
|
712
|
+
* You must still pass a `document` prop (e.g., `createEmptyDocument()`) so the
|
|
713
|
+
* editor can build its schema and render the shell.
|
|
316
714
|
*/
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
715
|
+
externalContent?: boolean;
|
|
716
|
+
/** Callback when editor view is ready (for PluginHost) */
|
|
717
|
+
onEditorViewReady?: (view: prosemirror_view.EditorView) => void;
|
|
718
|
+
/** Theme for styling */
|
|
719
|
+
theme?: Theme | null;
|
|
720
|
+
/** Whether to show toolbar (default: true) */
|
|
721
|
+
showToolbar?: boolean;
|
|
722
|
+
/** Whether to show zoom control (default: true) */
|
|
723
|
+
showZoomControl?: boolean;
|
|
724
|
+
/** Whether to show page margin guides/boundaries (default: false) */
|
|
725
|
+
showMarginGuides?: boolean;
|
|
726
|
+
/** Color for margin guides (default: '#c0c0c0') */
|
|
727
|
+
marginGuideColor?: string;
|
|
728
|
+
/** Whether to show horizontal ruler (default: false) */
|
|
729
|
+
showRuler?: boolean;
|
|
730
|
+
/** Unit for ruler display (default: 'inch') */
|
|
731
|
+
rulerUnit?: 'inch' | 'cm';
|
|
732
|
+
/** Initial zoom level (default: 1.0) */
|
|
733
|
+
initialZoom?: number;
|
|
734
|
+
/** Whether the editor is read-only. When true, hides toolbar and rulers */
|
|
735
|
+
readOnly?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* When true, the editor does not intercept Cmd/Ctrl+F or Cmd/Ctrl+H.
|
|
738
|
+
* This lets the browser or host app handle native find/history shortcuts.
|
|
739
|
+
*/
|
|
740
|
+
disableFindReplaceShortcuts?: boolean;
|
|
741
|
+
/** Custom toolbar actions */
|
|
742
|
+
toolbarExtra?: ReactNode;
|
|
743
|
+
/** Additional CSS class name */
|
|
339
744
|
className?: string;
|
|
745
|
+
/** Additional inline styles */
|
|
340
746
|
style?: CSSProperties;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
|
|
747
|
+
/** Placeholder when no document */
|
|
748
|
+
placeholder?: ReactNode;
|
|
749
|
+
/** Loading indicator */
|
|
750
|
+
loadingIndicator?: ReactNode;
|
|
751
|
+
/** Whether to show the document outline sidebar (default: false) */
|
|
752
|
+
showOutline?: boolean;
|
|
753
|
+
/** Whether to show the floating outline toggle button (default: true) */
|
|
754
|
+
showOutlineButton?: boolean;
|
|
345
755
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
756
|
+
* Custom list of fonts shown in the toolbar's font-family dropdown.
|
|
757
|
+
* Strings render in the "Other" group; pass `FontOption[]` for category
|
|
758
|
+
* grouping and CSS fallback chains. Omit to use the built-in 12-font
|
|
759
|
+
* default. An empty array renders an empty (but enabled) dropdown.
|
|
760
|
+
*
|
|
761
|
+
* Pass a stable reference (memoized or module-level) — inline arrays
|
|
762
|
+
* create a new identity per render and invalidate the picker's memo.
|
|
763
|
+
*
|
|
764
|
+
* @example fontFamilies={['Arial', 'Roboto']}
|
|
765
|
+
* @example fontFamilies={[{ name: 'Roboto', fontFamily: 'Roboto, sans-serif', category: 'sans-serif' }]}
|
|
349
766
|
*/
|
|
350
|
-
|
|
767
|
+
fontFamilies?: ReadonlyArray<string | FontOption>;
|
|
768
|
+
/** Whether to show print button in toolbar (default: true) */
|
|
769
|
+
showPrintButton?: boolean;
|
|
770
|
+
/** Whether to show the editing mode switcher (Editing/Suggesting/Viewing) in toolbar (default: true) */
|
|
771
|
+
showModeSwitcher?: boolean;
|
|
772
|
+
/** Whether to show the comments sidebar toggle button in toolbar (default: true) */
|
|
773
|
+
showCommentsSidebarToggle?: boolean;
|
|
774
|
+
/** Print options for print preview */
|
|
775
|
+
printOptions?: PrintOptions;
|
|
351
776
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
777
|
+
* Callback when print is triggered. Pass it to enable the `File > Print`
|
|
778
|
+
* menu entry; omit to hide. The imperative `ref.current.print()` also
|
|
779
|
+
* invokes this callback.
|
|
354
780
|
*/
|
|
355
|
-
|
|
781
|
+
onPrint?: () => void;
|
|
782
|
+
/** Callback when content is copied */
|
|
783
|
+
onCopy?: () => void;
|
|
784
|
+
/** Callback when content is cut */
|
|
785
|
+
onCut?: () => void;
|
|
786
|
+
/** Callback when content is pasted */
|
|
787
|
+
onPaste?: () => void;
|
|
788
|
+
/** Editor mode: 'editing' (direct edits), 'suggesting' (track changes), or 'viewing' (read-only). Default: 'editing' */
|
|
789
|
+
mode?: EditorMode;
|
|
790
|
+
/** Callback when the editing mode changes */
|
|
791
|
+
onModeChange?: (mode: EditorMode) => void;
|
|
792
|
+
/** Callback when a comment is added via the UI */
|
|
793
|
+
onCommentAdd?: (comment: Comment) => void;
|
|
794
|
+
/** Callback when a comment is resolved via the UI */
|
|
795
|
+
onCommentResolve?: (comment: Comment) => void;
|
|
796
|
+
/** Callback when a comment is deleted via the UI */
|
|
797
|
+
onCommentDelete?: (comment: Comment) => void;
|
|
798
|
+
/** Callback when a reply is added to a comment via the UI */
|
|
799
|
+
onCommentReply?: (reply: Comment, parent: Comment) => void;
|
|
356
800
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
801
|
+
* Controlled comments array. When provided, the editor reads comment thread
|
|
802
|
+
* metadata (text, author, replies, resolved status) from this prop instead
|
|
803
|
+
* of internal state, and emits every change through `onCommentsChange`.
|
|
804
|
+
*
|
|
805
|
+
* Use this with collaboration backends (Yjs, Liveblocks, Automerge, …) so
|
|
806
|
+
* comment threads sync across peers — the PM document only carries the
|
|
807
|
+
* range markers; thread metadata lives outside the doc and needs its own
|
|
808
|
+
* sync channel.
|
|
809
|
+
*
|
|
810
|
+
* If omitted, the editor falls back to internal state (current behavior).
|
|
811
|
+
* The granular `onCommentAdd`/`onCommentResolve`/`onCommentDelete`/
|
|
812
|
+
* `onCommentReply` callbacks fire in both modes.
|
|
360
813
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
814
|
+
comments?: Comment[];
|
|
815
|
+
/** Fires whenever the comments array changes (controlled mode). */
|
|
816
|
+
onCommentsChange?: (comments: Comment[]) => void;
|
|
817
|
+
/**
|
|
818
|
+
* Callback when rendered DOM context is ready (for plugin overlays).
|
|
819
|
+
* Used by PluginHost to get access to the rendered page DOM for positioning.
|
|
820
|
+
*/
|
|
821
|
+
onRenderedDomContextReady?: (context: RenderedDomContext) => void;
|
|
822
|
+
/**
|
|
823
|
+
* Plugin overlays to render inside the editor viewport.
|
|
824
|
+
* Passed from PluginHost to render plugin-specific overlays.
|
|
825
|
+
*/
|
|
826
|
+
pluginOverlays?: ReactNode;
|
|
827
|
+
/** Sidebar items from plugins (passed from PluginHost). */
|
|
828
|
+
pluginSidebarItems?: ReactSidebarItem[];
|
|
829
|
+
/** Rendered DOM context from PluginHost (for sidebar position resolution). */
|
|
830
|
+
pluginRenderedDomContext?: RenderedDomContext | null;
|
|
831
|
+
/** Custom logo/icon for the title bar */
|
|
832
|
+
renderLogo?: () => ReactNode;
|
|
833
|
+
/** Document name shown in the title bar */
|
|
834
|
+
documentName?: string;
|
|
835
|
+
/** Callback when document name changes */
|
|
836
|
+
onDocumentNameChange?: (name: string) => void;
|
|
837
|
+
/** Whether the document name is editable (default: true) */
|
|
838
|
+
documentNameEditable?: boolean;
|
|
839
|
+
/** Custom right-side actions for the title bar */
|
|
840
|
+
renderTitleBarRight?: () => ReactNode;
|
|
841
|
+
/** Translation overrides. Import a locale JSON file and pass it directly. */
|
|
842
|
+
i18n?: Translations;
|
|
843
|
+
/**
|
|
844
|
+
* Mount a controllable agent panel on the right side of the editor. The
|
|
845
|
+
* panel is the chrome (header, close button, drag-resize); the consumer
|
|
846
|
+
* supplies whatever content goes inside via `render` — typically a chat
|
|
847
|
+
* UI from `@ai-sdk/react`'s `useChat`, `assistant-ui`, or any other
|
|
848
|
+
* framework. We do not ship message bubbles, a composer, or a chat engine.
|
|
849
|
+
*
|
|
850
|
+
* Three control patterns:
|
|
851
|
+
* - **Uncontrolled**: `agentPanel={{ render }}` — toolbar button + panel
|
|
852
|
+
* close button toggle the panel. Width persists to localStorage.
|
|
853
|
+
* - **Controlled**: `agentPanel={{ render, open, onOpenChange }}` — the
|
|
854
|
+
* consumer owns open state (e.g. tied to a global menu).
|
|
855
|
+
* - **Headless**: omit `agentPanel`, use the toolkit directly via
|
|
856
|
+
* `useDocxAgentTools` — render the panel anywhere you want.
|
|
857
|
+
*/
|
|
858
|
+
agentPanel?: {
|
|
859
|
+
/** Render-prop returning the panel content. Called only when open. */
|
|
860
|
+
render: (ctx: {
|
|
861
|
+
close: () => void;
|
|
862
|
+
}) => ReactNode;
|
|
863
|
+
/** Controlled open state. Omit for uncontrolled. */
|
|
864
|
+
open?: boolean;
|
|
865
|
+
/** Fires when toolbar button or panel close button is clicked. */
|
|
866
|
+
onOpenChange?: (open: boolean) => void;
|
|
867
|
+
/** Show the toolbar toggle button. Default: true. */
|
|
868
|
+
showToolbarButton?: boolean;
|
|
869
|
+
/** Optional badge / dot on the toolbar button. */
|
|
870
|
+
toolbarBadge?: ReactNode;
|
|
871
|
+
/** Optional panel title. Default: t('agentPanel.defaultTitle'). */
|
|
872
|
+
title?: string;
|
|
873
|
+
/** Optional panel header icon. Default: sparkle. */
|
|
874
|
+
icon?: ReactNode;
|
|
875
|
+
/** Initial panel width in px (uncontrolled). Default: 360. */
|
|
876
|
+
defaultWidth?: number;
|
|
877
|
+
/** Min drag width. Default: 280. */
|
|
878
|
+
minWidth?: number;
|
|
879
|
+
/** Max drag width. Default: 600. */
|
|
880
|
+
maxWidth?: number;
|
|
881
|
+
};
|
|
413
882
|
}
|
|
414
883
|
/**
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* ┌──────────┬────────────────────────────┬──────────────────┐
|
|
418
|
-
* │ │ Document Name │ │
|
|
419
|
-
* │ Logo │ │ Right Actions │
|
|
420
|
-
* │ │ File Format Insert │ │
|
|
421
|
-
* └──────────┴────────────────────────────┴──────────────────┘
|
|
422
|
-
*
|
|
423
|
-
* Logo and TitleBarRight span full height. DocumentName + MenuBar
|
|
424
|
-
* stack vertically in the center column.
|
|
884
|
+
* DocxEditor ref interface
|
|
425
885
|
*/
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
|
|
886
|
+
interface DocxEditorRef {
|
|
887
|
+
/** Get the DocumentAgent for programmatic access */
|
|
888
|
+
getAgent: () => DocumentAgent | null;
|
|
889
|
+
/** Get the current document */
|
|
890
|
+
getDocument: () => Document | null;
|
|
891
|
+
/** Get the editor ref */
|
|
892
|
+
getEditorRef: () => PagedEditorRef | null;
|
|
893
|
+
/** Save the document to buffer. Pass { selective: false } to force full repack. */
|
|
894
|
+
save: (options?: {
|
|
895
|
+
selective?: boolean;
|
|
896
|
+
}) => Promise<ArrayBuffer | null>;
|
|
897
|
+
/** Set zoom level */
|
|
898
|
+
setZoom: (zoom: number) => void;
|
|
899
|
+
/** Get current zoom level */
|
|
900
|
+
getZoom: () => number;
|
|
901
|
+
/** Focus the editor */
|
|
902
|
+
focus: () => void;
|
|
903
|
+
/** Get current page number */
|
|
904
|
+
getCurrentPage: () => number;
|
|
905
|
+
/** Get total page count */
|
|
906
|
+
getTotalPages: () => number;
|
|
907
|
+
/**
|
|
908
|
+
* Scroll the paginated view so the given page is in view.
|
|
909
|
+
* Page numbers are 1-indexed (matches `getCurrentPage` / `getTotalPages`).
|
|
910
|
+
* No-op for out-of-range or non-integer values.
|
|
911
|
+
* @example ref.current?.scrollToPage(2)
|
|
912
|
+
*/
|
|
913
|
+
scrollToPage: (pageNumber: number) => void;
|
|
914
|
+
/**
|
|
915
|
+
* Scroll the paginated view to the paragraph with the given Word `w14:paraId`.
|
|
916
|
+
* @returns whether a matching paragraph exists in the ProseMirror document
|
|
917
|
+
* @example ref.current?.scrollToParaId('1A2B3C4D')
|
|
918
|
+
*/
|
|
919
|
+
scrollToParaId: (paraId: string) => boolean;
|
|
920
|
+
/**
|
|
921
|
+
* Scroll the paginated view to a specific ProseMirror document position.
|
|
922
|
+
* Use this when you have a raw PM offset; for Word `w14:paraId` use
|
|
923
|
+
* `scrollToParaId` instead.
|
|
924
|
+
* @example ref.current?.scrollToPosition(42)
|
|
925
|
+
*/
|
|
926
|
+
scrollToPosition: (pmPos: number) => void;
|
|
927
|
+
/** Open print preview */
|
|
928
|
+
openPrintPreview: () => void;
|
|
929
|
+
/** Print the document directly */
|
|
930
|
+
print: () => void;
|
|
931
|
+
/** Load a pre-parsed document programmatically */
|
|
932
|
+
loadDocument: (doc: Document) => void;
|
|
933
|
+
/** Load a DOCX buffer programmatically (ArrayBuffer, Uint8Array, Blob, or File) */
|
|
934
|
+
loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
|
|
935
|
+
/**
|
|
936
|
+
* Apply document changes from a DocumentAgent while preserving undo history.
|
|
937
|
+
* This dispatches a PM transaction that replaces the document content,
|
|
938
|
+
* allowing undo/redo to work with agent-made changes.
|
|
939
|
+
*
|
|
940
|
+
* @param doc - The modified Document from an agent
|
|
941
|
+
* @returns true if the changes were applied, false if the editor is not ready
|
|
942
|
+
*
|
|
943
|
+
* @example
|
|
944
|
+
* ```ts
|
|
945
|
+
* const agent = EnhancedDocumentAgent.fromDocument(editorRef.current.getDocument());
|
|
946
|
+
* const updated = agent.toggleBulletList([0, 1, 2]).getDocument();
|
|
947
|
+
* editorRef.current.applyDocumentChanges(updated);
|
|
948
|
+
* // Ctrl+Z will undo the bullet list changes
|
|
949
|
+
* ```
|
|
950
|
+
*/
|
|
951
|
+
applyDocumentChanges: (doc: Document) => boolean;
|
|
952
|
+
/** Add a comment programmatically. Anchored by Word `w14:paraId` so
|
|
953
|
+
* it survives unrelated edits. Returns the comment ID, or null if
|
|
954
|
+
* the paraId is unknown or the search text isn't found / is ambiguous. */
|
|
955
|
+
addComment: (options: {
|
|
956
|
+
paraId: string;
|
|
957
|
+
text: string;
|
|
958
|
+
author: string;
|
|
959
|
+
/** Optional: anchor to a specific phrase within the paragraph (must be unique). */
|
|
960
|
+
search?: string;
|
|
961
|
+
}) => number | null;
|
|
962
|
+
/** Reply to an existing comment. Returns the reply comment ID. */
|
|
963
|
+
replyToComment: (commentId: number, text: string, author: string) => number | null;
|
|
964
|
+
/** Resolve (mark as done) a comment. */
|
|
965
|
+
resolveComment: (commentId: number) => void;
|
|
966
|
+
/** Suggest a tracked change. Pass `replaceWith: ''` to delete the matched text;
|
|
967
|
+
* pass `search: ''` to insert at paragraph end. Returns false on missing paraId,
|
|
968
|
+
* missing/ambiguous search, or attempt to layer on an existing tracked change. */
|
|
969
|
+
proposeChange: (options: {
|
|
970
|
+
paraId: string;
|
|
971
|
+
search: string;
|
|
972
|
+
replaceWith: string;
|
|
973
|
+
author: string;
|
|
974
|
+
}) => boolean;
|
|
975
|
+
/** Locate every paragraph containing `query` (case-insensitive substring).
|
|
976
|
+
* Returns a stable handle (paraId + the matched phrase) the agent can pass
|
|
977
|
+
* back to `addComment` / `proposeChange`. */
|
|
978
|
+
findInDocument: (query: string, options?: {
|
|
979
|
+
caseSensitive?: boolean;
|
|
980
|
+
limit?: number;
|
|
981
|
+
}) => Array<{
|
|
982
|
+
paraId: string;
|
|
983
|
+
match: string;
|
|
984
|
+
before: string;
|
|
985
|
+
after: string;
|
|
986
|
+
}>;
|
|
987
|
+
/**
|
|
988
|
+
* Apply character formatting (bold / italic / color / size / font / etc.)
|
|
989
|
+
* to a paragraph or to a unique phrase within it. This is a direct edit,
|
|
990
|
+
* not a tracked change. Returns false on missing paraId or ambiguous search.
|
|
991
|
+
*/
|
|
992
|
+
applyFormatting: (options: {
|
|
993
|
+
paraId: string;
|
|
994
|
+
search?: string;
|
|
995
|
+
marks: {
|
|
996
|
+
bold?: boolean;
|
|
997
|
+
italic?: boolean;
|
|
998
|
+
underline?: boolean | {
|
|
999
|
+
style?: string;
|
|
1000
|
+
};
|
|
1001
|
+
strike?: boolean;
|
|
1002
|
+
color?: {
|
|
1003
|
+
rgb?: string;
|
|
1004
|
+
themeColor?: string;
|
|
1005
|
+
};
|
|
1006
|
+
highlight?: string;
|
|
1007
|
+
fontSize?: number;
|
|
1008
|
+
fontFamily?: {
|
|
1009
|
+
ascii?: string;
|
|
1010
|
+
hAnsi?: string;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
}) => boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Apply a paragraph style by styleId (e.g. `'Heading1'`, `'Quote'`).
|
|
1016
|
+
* Direct edit, not a tracked change. Returns false if paraId is unknown.
|
|
1017
|
+
*/
|
|
1018
|
+
setParagraphStyle: (options: {
|
|
1019
|
+
paraId: string;
|
|
1020
|
+
styleId: string;
|
|
1021
|
+
}) => boolean;
|
|
1022
|
+
/**
|
|
1023
|
+
* Read the contents of a single page. 1-indexed; returns null if the page
|
|
1024
|
+
* does not exist. Each paragraph is returned with its stable paraId so the
|
|
1025
|
+
* agent can comment on or modify it without an extra round-trip.
|
|
1026
|
+
*/
|
|
1027
|
+
getPageContent: (pageNumber: number) => {
|
|
1028
|
+
pageNumber: number;
|
|
1029
|
+
text: string;
|
|
1030
|
+
paragraphs: Array<{
|
|
1031
|
+
paraId: string;
|
|
1032
|
+
text: string;
|
|
1033
|
+
styleId?: string;
|
|
1034
|
+
}>;
|
|
1035
|
+
} | null;
|
|
1036
|
+
/** Read the user's current cursor / selection — what's highlighted right now. */
|
|
1037
|
+
getSelectionInfo: () => {
|
|
1038
|
+
paraId: string | null;
|
|
1039
|
+
selectedText: string;
|
|
1040
|
+
paragraphText: string;
|
|
1041
|
+
before: string;
|
|
1042
|
+
after: string;
|
|
1043
|
+
} | null;
|
|
1044
|
+
/** Get all comments. */
|
|
1045
|
+
getComments: () => Comment[];
|
|
1046
|
+
/** Subscribe to document changes. Fires after every committed edit. Returns unsubscribe. */
|
|
1047
|
+
onContentChange: (listener: (document: Document) => void) => () => void;
|
|
1048
|
+
/** Subscribe to selection changes (cursor moves / selection changes). Returns unsubscribe. */
|
|
1049
|
+
onSelectionChange: (listener: (selection: SelectionState | null) => void) => () => void;
|
|
433
1050
|
}
|
|
1051
|
+
type EditorMode = 'editing' | 'suggesting' | 'viewing';
|
|
434
1052
|
/**
|
|
435
|
-
*
|
|
436
|
-
* bold/italic/underline, colors, alignment, lists, table/image context, clear formatting.
|
|
1053
|
+
* DocxEditor - Complete DOCX editor component
|
|
437
1054
|
*/
|
|
438
|
-
declare
|
|
1055
|
+
declare const DocxEditor: React.ForwardRefExoticComponent<DocxEditorProps & React.RefAttributes<DocxEditorRef>>;
|
|
439
1056
|
|
|
440
1057
|
/**
|
|
441
|
-
*
|
|
1058
|
+
* Simple imperative API for rendering a DOCX editor into a DOM element.
|
|
442
1059
|
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
* <EditorToolbar.TitleBar>
|
|
446
|
-
* <EditorToolbar.Logo><MyIcon /></EditorToolbar.Logo>
|
|
447
|
-
* <EditorToolbar.DocumentName value={name} onChange={setName} />
|
|
448
|
-
* <EditorToolbar.MenuBar />
|
|
449
|
-
* <EditorToolbar.TitleBarRight>
|
|
450
|
-
* <button>Save</button>
|
|
451
|
-
* </EditorToolbar.TitleBarRight>
|
|
452
|
-
* </EditorToolbar.TitleBar>
|
|
453
|
-
* <EditorToolbar.FormattingBar />
|
|
454
|
-
* </EditorToolbar>
|
|
455
|
-
*/
|
|
456
|
-
|
|
457
|
-
interface EditorToolbarComponent {
|
|
458
|
-
(props: EditorToolbarProps & {
|
|
459
|
-
children: ReactNode;
|
|
460
|
-
}): React.JSX.Element;
|
|
461
|
-
TitleBar: typeof TitleBar;
|
|
462
|
-
Logo: typeof Logo;
|
|
463
|
-
DocumentName: typeof DocumentName;
|
|
464
|
-
MenuBar: typeof MenuBar;
|
|
465
|
-
TitleBarRight: typeof TitleBarRight;
|
|
466
|
-
FormattingBar: typeof FormattingBar;
|
|
467
|
-
}
|
|
468
|
-
declare const EditorToolbar: EditorToolbarComponent;
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Template tag types
|
|
472
|
-
*/
|
|
473
|
-
type TagType = 'variable' | 'sectionStart' | 'sectionEnd' | 'invertedStart' | 'raw';
|
|
474
|
-
/**
|
|
475
|
-
* A found template tag
|
|
476
|
-
*/
|
|
477
|
-
interface TemplateTag {
|
|
478
|
-
id: string;
|
|
479
|
-
type: TagType;
|
|
480
|
-
name: string;
|
|
481
|
-
rawTag: string;
|
|
482
|
-
from: number;
|
|
483
|
-
to: number;
|
|
484
|
-
/** For sections: nested variable names */
|
|
485
|
-
nestedVars?: string[];
|
|
486
|
-
/** True if this variable is inside a section (shown in section's nested vars) */
|
|
487
|
-
insideSection?: boolean;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Plugin state
|
|
491
|
-
*/
|
|
492
|
-
interface TemplatePluginState$1 {
|
|
493
|
-
tags: TemplateTag[];
|
|
494
|
-
decorations: DecorationSet;
|
|
495
|
-
hoveredId?: string;
|
|
496
|
-
selectedId?: string;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Plugin key
|
|
500
|
-
*/
|
|
501
|
-
declare const templatePluginKey: PluginKey<TemplatePluginState$1>;
|
|
502
|
-
/**
|
|
503
|
-
* Create the template plugin
|
|
504
|
-
*/
|
|
505
|
-
declare function createTemplatePlugin(): Plugin<TemplatePluginState$1>;
|
|
506
|
-
/**
|
|
507
|
-
* Get tags from editor state
|
|
508
|
-
*/
|
|
509
|
-
declare function getTemplateTags(state: prosemirror_state.EditorState): TemplateTag[];
|
|
510
|
-
/**
|
|
511
|
-
* Set hovered tag
|
|
512
|
-
*/
|
|
513
|
-
declare function setHoveredElement(view: EditorView, id: string | undefined): void;
|
|
514
|
-
/**
|
|
515
|
-
* Set selected tag
|
|
516
|
-
*/
|
|
517
|
-
declare function setSelectedElement(view: EditorView, id: string | undefined): void;
|
|
518
|
-
/**
|
|
519
|
-
* CSS styles for template decorations
|
|
520
|
-
*/
|
|
521
|
-
declare const TEMPLATE_DECORATION_STYLES = "\n.docx-template-tag {\n cursor: pointer;\n transition: background-color 0.1s;\n}\n\n.docx-template-tag:hover,\n.docx-template-tag.hovered {\n filter: brightness(0.95);\n}\n\n.docx-template-tag.selected {\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);\n}\n";
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Template Plugin
|
|
1060
|
+
* Returns an `EditorHandle` (from @eigenpal/docx-editor-core) that works with
|
|
1061
|
+
* any framework implementation.
|
|
525
1062
|
*
|
|
526
|
-
*
|
|
1063
|
+
* Usage:
|
|
1064
|
+
* ```ts
|
|
1065
|
+
* import { renderAsync } from '@eigenpal/docx-editor-react';
|
|
527
1066
|
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
1067
|
+
* const editor = await renderAsync(docxBlob, document.getElementById('container'), {
|
|
1068
|
+
* readOnly: false,
|
|
1069
|
+
* showToolbar: true,
|
|
1070
|
+
* });
|
|
532
1071
|
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* import { PluginHost } from '@docx-editor/plugin-api';
|
|
536
|
-
* import { templatePlugin } from '@docx-editor/plugins/template';
|
|
1072
|
+
* // Save the edited document
|
|
1073
|
+
* const blob = await editor.save();
|
|
537
1074
|
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
* <PluginHost plugins={[templatePlugin]}>
|
|
541
|
-
* <DocxEditor document={doc} onChange={handleChange} />
|
|
542
|
-
* </PluginHost>
|
|
543
|
-
* );
|
|
544
|
-
* }
|
|
1075
|
+
* // Clean up
|
|
1076
|
+
* editor.destroy();
|
|
545
1077
|
* ```
|
|
546
1078
|
*/
|
|
547
1079
|
|
|
548
|
-
interface TemplatePluginState {
|
|
549
|
-
tags: TemplateTag[];
|
|
550
|
-
hoveredId?: string;
|
|
551
|
-
selectedId?: string;
|
|
552
|
-
}
|
|
553
1080
|
/**
|
|
554
|
-
*
|
|
1081
|
+
* Options for {@link renderAsync}. A subset of DocxEditorProps minus
|
|
1082
|
+
* `documentBuffer` / `document` (passed as the first argument instead).
|
|
555
1083
|
*/
|
|
556
|
-
|
|
557
|
-
/** @deprecated — panel is no longer used; template chips render in the unified sidebar */
|
|
558
|
-
defaultCollapsed?: boolean;
|
|
559
|
-
/** @deprecated */
|
|
560
|
-
panelPosition?: 'left' | 'right';
|
|
561
|
-
/** @deprecated */
|
|
562
|
-
panelWidth?: number;
|
|
563
|
-
}): ReactEditorPlugin<TemplatePluginState>;
|
|
1084
|
+
type RenderAsyncOptions = Omit<DocxEditorProps, 'documentBuffer' | 'document'>;
|
|
564
1085
|
/**
|
|
565
|
-
*
|
|
1086
|
+
* React-specific handle that extends the framework-agnostic EditorHandle
|
|
1087
|
+
* with zoom control.
|
|
566
1088
|
*/
|
|
567
|
-
|
|
568
|
-
|
|
1089
|
+
interface DocxEditorHandle extends EditorHandle {
|
|
1090
|
+
/** Set zoom level (1.0 = 100%). */
|
|
1091
|
+
setZoom: (zoom: number) => void;
|
|
1092
|
+
/** Scroll to a body paragraph by Word `w14:paraId`. */
|
|
1093
|
+
scrollToParaId: (paraId: string) => boolean;
|
|
1094
|
+
/** Scroll to a raw ProseMirror document position. */
|
|
1095
|
+
scrollToPosition: (pmPos: number) => void;
|
|
1096
|
+
}
|
|
569
1097
|
/**
|
|
570
|
-
*
|
|
1098
|
+
* Render a DOCX editor into a container element.
|
|
571
1099
|
*
|
|
572
|
-
*
|
|
1100
|
+
* @param input - DOCX data as ArrayBuffer, Uint8Array, Blob, or File
|
|
1101
|
+
* @param container - DOM element to render into
|
|
1102
|
+
* @param options - Editor configuration (toolbar, readOnly, callbacks, etc.)
|
|
1103
|
+
* @returns A handle with save / destroy / getDocument methods
|
|
1104
|
+
*/
|
|
1105
|
+
declare function renderAsync(input: DocxInput, container: HTMLElement, options?: RenderAsyncOptions): Promise<DocxEditorHandle>;
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* @eigenpal/docx-editor-react
|
|
573
1109
|
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* -
|
|
577
|
-
* -
|
|
578
|
-
* -
|
|
579
|
-
* -
|
|
580
|
-
* - DocumentAgent API for programmatic editing
|
|
581
|
-
* - Template variable substitution
|
|
582
|
-
* - AI-powered context menu
|
|
1110
|
+
* Curated root entry for the documented React editor API. Advanced surfaces
|
|
1111
|
+
* stay public through explicit subpaths:
|
|
1112
|
+
* - `@eigenpal/docx-editor-react/ui`
|
|
1113
|
+
* - `@eigenpal/docx-editor-react/dialogs`
|
|
1114
|
+
* - `@eigenpal/docx-editor-react/hooks`
|
|
1115
|
+
* - `@eigenpal/docx-editor-react/plugin-api`
|
|
583
1116
|
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* ```
|
|
587
|
-
* import '@eigenpal/docx-js-editor/styles/editor.css';
|
|
588
|
-
* ```
|
|
1117
|
+
* Framework-agnostic document utilities live in `@eigenpal/docx-editor-core`.
|
|
1118
|
+
* Agent/MCP surfaces live in `@eigenpal/docx-editor-agents`.
|
|
589
1119
|
*/
|
|
590
1120
|
declare const VERSION = "0.0.2";
|
|
591
1121
|
|
|
592
|
-
export {
|
|
1122
|
+
export { DocxEditor, type DocxEditorHandle, type DocxEditorProps, type DocxEditorRef, type EditorMode, LocaleProvider, type LocaleProviderProps, type RenderAsyncOptions, TranslationKey, Translations, VERSION, renderAsync, useTranslation };
|