@docx-editor.dev/react 2.0.0 → 2.1.0
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/README.md +8 -8
- package/dist/index.d.mts +58 -7
- package/dist/index.d.ts +58 -7
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ WYSIWYG `.docx` editor for React. Opens a Word file in the browser, paints the r
|
|
|
18
18
|
layout, edits it in place, and writes a `.docx` back out. No upload service, no conversion
|
|
19
19
|
backend: parsing and serialization both happen client-side.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Saving is lossless. Everything you do not edit comes back byte for byte, including the parts
|
|
22
22
|
the editor does not understand: custom XML, embedded fonts, macros, unknown extensions. Two
|
|
23
23
|
oracles gate that in CI, so opening a document here cannot quietly destroy it.
|
|
24
24
|
|
|
@@ -31,7 +31,7 @@ npm install @docx-editor.dev/react
|
|
|
31
31
|
```tsx
|
|
32
32
|
import { useState } from 'react';
|
|
33
33
|
import { DocxEditor } from '@docx-editor.dev/react';
|
|
34
|
-
import '@docx-editor.dev/
|
|
34
|
+
import '@docx-editor.dev/core/styles/editor.css';
|
|
35
35
|
|
|
36
36
|
export function App() {
|
|
37
37
|
const [doc, setDoc] = useState<Uint8Array>();
|
|
@@ -54,17 +54,17 @@ export function App() {
|
|
|
54
54
|
}
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
`<DocxEditor>` is the
|
|
58
|
-
context menu, and the painted document.
|
|
59
|
-
|
|
57
|
+
`<DocxEditor>` is the full packaged editor: title bar, menu, toolbar, navigation pane,
|
|
58
|
+
context menu, and the painted document. It fills its parent, so give it a box with a real
|
|
59
|
+
height, and import the stylesheet once.
|
|
60
60
|
|
|
61
61
|
> **Next.js / SSR:** the editor measures text in the DOM at mount, so render it client-side
|
|
62
62
|
> (`dynamic(..., { ssr: false })`).
|
|
63
63
|
|
|
64
64
|
## Build your own UI
|
|
65
65
|
|
|
66
|
-
The packaged chrome is one arrangement of parts
|
|
67
|
-
|
|
66
|
+
The packaged chrome is one arrangement of public parts. Every packaged control uses the same
|
|
67
|
+
hooks you would; there is no private API behind it.
|
|
68
68
|
|
|
69
69
|
```tsx
|
|
70
70
|
import { DocxEditor, useEditorCommand } from '@docx-editor.dev/react';
|
|
@@ -96,7 +96,7 @@ export function Editor({ bytes }: { bytes: Uint8Array }) {
|
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
`Root` owns the editor instance, `Viewport` is the scroll container, `Content` is where pages
|
|
99
|
-
are painted. Everything else
|
|
99
|
+
are painted. Everything else (toolbar, menu, rulers, navigation, link popover, context menu)
|
|
100
100
|
is optional and placed by name.
|
|
101
101
|
|
|
102
102
|
The customization ladder, in order: `className` and `data-active` → the `icon` prop →
|
package/dist/index.d.mts
CHANGED
|
@@ -38,7 +38,7 @@ interface DocxEditorLoadingProps {
|
|
|
38
38
|
* provider only after those resolve.
|
|
39
39
|
*/
|
|
40
40
|
when?: boolean;
|
|
41
|
-
/** Appended after the load-bearing `
|
|
41
|
+
/** Appended after the load-bearing `docx-editor docx-editor__loading` classes. */
|
|
42
42
|
className?: string;
|
|
43
43
|
/** Inline styles for the loading container, as on `DocxEditor.Viewport`. */
|
|
44
44
|
style?: CSSProperties;
|
|
@@ -101,7 +101,7 @@ interface DocxEditorLoadingComponent {
|
|
|
101
101
|
* report otherwise — the same rule `useEditorState` documents for a null editor. Place
|
|
102
102
|
* it inside the provider unless a permanently-visible placeholder is what you want.
|
|
103
103
|
*
|
|
104
|
-
* Carries its own `
|
|
104
|
+
* Carries its own `docx-editor`, so the theme tokens resolve wherever it is composed.
|
|
105
105
|
*
|
|
106
106
|
* @public
|
|
107
107
|
*/
|
|
@@ -1079,17 +1079,23 @@ interface DocxEditorRulerProps {
|
|
|
1079
1079
|
* draggable when the engine supports page-setup writes; the drag previews locally and
|
|
1080
1080
|
* commits one undoable step on release.
|
|
1081
1081
|
*
|
|
1082
|
+
* Renders nothing while the editor holds no document — see
|
|
1083
|
+
* {@link selectDocumentAbsent}.
|
|
1084
|
+
*
|
|
1082
1085
|
* @public
|
|
1083
1086
|
*/
|
|
1084
|
-
declare function DocxEditorHorizontalRuler(props: DocxEditorRulerProps): ReactElement;
|
|
1087
|
+
declare function DocxEditorHorizontalRuler(props: DocxEditorRulerProps): ReactElement | null;
|
|
1085
1088
|
/**
|
|
1086
1089
|
* The vertical ruler as a context-fed part (`DocxEditor.VerticalRuler`): page height,
|
|
1087
1090
|
* margins and zoom straight from the editor. Top/bottom margin handles are draggable
|
|
1088
1091
|
* when the engine supports page-setup writes, committing one undoable step on release.
|
|
1089
1092
|
*
|
|
1093
|
+
* Renders nothing while the editor holds no document — see
|
|
1094
|
+
* {@link selectDocumentAbsent}.
|
|
1095
|
+
*
|
|
1090
1096
|
* @public
|
|
1091
1097
|
*/
|
|
1092
|
-
declare function DocxEditorVerticalRuler(props: DocxEditorRulerProps): ReactElement;
|
|
1098
|
+
declare function DocxEditorVerticalRuler(props: DocxEditorRulerProps): ReactElement | null;
|
|
1093
1099
|
|
|
1094
1100
|
/** Props for the context-fed outline part. @public */
|
|
1095
1101
|
interface DocxEditorDocumentOutlineProps {
|
|
@@ -1105,9 +1111,12 @@ interface DocxEditorDocumentOutlineProps {
|
|
|
1105
1111
|
* from `Editor.getOutline()`, in document order; clicking one moves the caret to that
|
|
1106
1112
|
* heading. The panel positions absolutely — give it a `position: relative` container.
|
|
1107
1113
|
*
|
|
1114
|
+
* Renders nothing while the editor has no document — a floating panel saying "no
|
|
1115
|
+
* headings" about a document that is not there is the same false claim the rulers made.
|
|
1116
|
+
*
|
|
1108
1117
|
* @public
|
|
1109
1118
|
*/
|
|
1110
|
-
declare function DocxEditorDocumentOutline(props: DocxEditorDocumentOutlineProps): ReactElement;
|
|
1119
|
+
declare function DocxEditorDocumentOutline(props: DocxEditorDocumentOutlineProps): ReactElement | null;
|
|
1111
1120
|
|
|
1112
1121
|
/** The pane's tabs. Word's Replace tab is a later slice; nothing here pretends it exists. */
|
|
1113
1122
|
type NavigationTab$1 = 'headings' | 'find';
|
|
@@ -1839,8 +1848,12 @@ interface DocxEditorProps {
|
|
|
1839
1848
|
* Strings still come from `packages/i18n/en.json` rather than literals in components;
|
|
1840
1849
|
* this only chooses who resolves the key. For another language, pass
|
|
1841
1850
|
* `createT(locale)` from `@docx-editor.dev/i18n`.
|
|
1851
|
+
*
|
|
1852
|
+
* `params` carries interpolation values for parameterized keys (for example the
|
|
1853
|
+
* navigation pane's `{current} of {total}` match counter) — a resolver that ignores
|
|
1854
|
+
* them renders the raw placeholders for those labels.
|
|
1842
1855
|
*/
|
|
1843
|
-
t?: (key: string) => string;
|
|
1856
|
+
t?: (key: string, params?: Record<string, string | number>) => string;
|
|
1844
1857
|
/**
|
|
1845
1858
|
* Renders the packaged chrome — title bar and toolbar — around the document.
|
|
1846
1859
|
* Default `true`. Set `false` for the painted surface alone when the host supplies
|
|
@@ -2074,6 +2087,44 @@ declare function useTranslation(): {
|
|
|
2074
2087
|
t: TFunction;
|
|
2075
2088
|
};
|
|
2076
2089
|
|
|
2090
|
+
/**
|
|
2091
|
+
* A chrome-part label resolver: plain string keys, optional interpolation params.
|
|
2092
|
+
*
|
|
2093
|
+
* This is the shape every packaged part's `t` prop accepts. It takes `string` rather
|
|
2094
|
+
* than the `TranslationKey` union so a host can route its own extra keys through the
|
|
2095
|
+
* same resolver.
|
|
2096
|
+
*
|
|
2097
|
+
* @public
|
|
2098
|
+
*/
|
|
2099
|
+
type ChromeTranslate = (key: string, params?: Record<string, string | number>) => string;
|
|
2100
|
+
/**
|
|
2101
|
+
* The catalogue-backed resolver for composed chrome, ready to pass as any part's `t`.
|
|
2102
|
+
*
|
|
2103
|
+
* `useTranslation().t` is keyed by the strict `TranslationKey` union, which does not
|
|
2104
|
+
* assign to the parts' plain-`string` `t` props — so before this hook, every composing
|
|
2105
|
+
* host hand-wrote the same cast wrapper `<DocxEditor>` builds internally. This is that
|
|
2106
|
+
* wrapper, exported: it resolves through the active `LocaleContext` catalogue (bundled
|
|
2107
|
+
* English by default), with `overrides` consulted first for key-level renames.
|
|
2108
|
+
*
|
|
2109
|
+
* ```tsx
|
|
2110
|
+
* const MY_LABELS = new Map([['toolbar.bold', 'Heavy']]); // module-level: stable identity
|
|
2111
|
+
*
|
|
2112
|
+
* const t = useChromeTranslate(MY_LABELS);
|
|
2113
|
+
* <DocxEditor.Toolbar t={t} />
|
|
2114
|
+
* ```
|
|
2115
|
+
*
|
|
2116
|
+
* Keep the `overrides` Map identity stable (module-level or memoized) — the returned
|
|
2117
|
+
* resolver is memoized on it, and an inline `new Map(...)` re-creates the resolver, and
|
|
2118
|
+
* with it every consuming part's props, on each render.
|
|
2119
|
+
*
|
|
2120
|
+
* `overrides` is a `Map` on purpose: the key is caller input, and an object literal
|
|
2121
|
+
* would answer `constructor` and `toString` off the prototype chain. Parts pass no
|
|
2122
|
+
* `params` today for overridden keys, so override values are literal strings.
|
|
2123
|
+
*
|
|
2124
|
+
* @public
|
|
2125
|
+
*/
|
|
2126
|
+
declare function useChromeTranslate(overrides?: ReadonlyMap<string, string>): ChromeTranslate;
|
|
2127
|
+
|
|
2077
2128
|
/** Live furniture scope state from `Editor.getHeaderFooterState()`. */
|
|
2078
2129
|
type HeaderFooterState = Exclude<ReturnType<Editor['getHeaderFooterState']>, null>;
|
|
2079
2130
|
/**
|
|
@@ -3260,4 +3311,4 @@ declare function useEditorSnapshot(editor: Editor | null): number;
|
|
|
3260
3311
|
*/
|
|
3261
3312
|
declare const VERSION = "0.0.2";
|
|
3262
3313
|
|
|
3263
|
-
export { CONTENT_CONTROL_SLOTS, type ContentControlActionProps, type ContentControlInspectorState, type ContentControlLock, type ContentControlPartProps, type ContentControlProps, type ContentControlSlotId, type ContextMenuAnchor, ContextMenuCellVerticalAlignment, type ContextMenuCommandProps, ContextMenuCopy, ContextMenuCut, ContextMenuDelete, ContextMenuDeleteTable, ContextMenuDeleteTableColumn, ContextMenuDeleteTableRow, ContextMenuInsertColumnLeft, ContextMenuInsertColumnRight, ContextMenuInsertRowAbove, ContextMenuInsertRowBelow, ContextMenuItem, type ContextMenuItemProps, ContextMenuPaste, ContextMenuSelectAll, type ContextMenuTableRowProps, DocumentName, DocxEditor, DocxEditorContent, DocxEditorContentControl, type DocxEditorContentControlNamespace, type DocxEditorContentProps, DocxEditorContextMenu, type DocxEditorContextMenuNamespace, type DocxEditorContextMenuProps, DocxEditorDocumentOutline, type DocxEditorDocumentOutlineProps, DocxEditorFontNotice, type DocxEditorFontNoticeProps, DocxEditorHeaderFooterChrome, type DocxEditorHeaderFooterChromeProps, DocxEditorHorizontalRuler, DocxEditorHyperLink, type DocxEditorHyperLinkNamespace, DocxEditorImagePropertiesDialog, type DocxEditorImagePropertiesDialogProps, DocxEditorLoading, type DocxEditorLoadingComponent, type DocxEditorLoadingProps, DocxEditorLoadingSpinner, type DocxEditorLoadingSpinnerProps, DocxEditorMenu, type DocxEditorMenuNamespace, type DocxEditorMenuProps, type DocxEditorNamespace, DocxEditorNavigation, type DocxEditorNavigationNamespace, type DocxEditorNavigationProps, DocxEditorNotesChrome, type DocxEditorNotesChromeProps, DocxEditorPageSetupDialog, type DocxEditorPageSetupDialogProps, type DocxEditorProps, type DocxEditorRef, DocxEditorRoot, type DocxEditorRootProps, type DocxEditorRulerProps, DocxEditorShell, DocxEditorToolbar, type DocxEditorToolbarNamespace, type DocxEditorToolbarProps, DocxEditorVerticalRuler, DocxEditorViewport, type DocxEditorViewportProps, type DocxFontsInput, type DocxFontsSource, type DocxSource, type EditorCaret, type EditorCommandState, type EditorMode, type EditorValueCommandState, type FontFamilyItemProps, type FontFamilyNamespace, type FontFamilyPartProps, type FontFamilyProps, type FontsInput, type HeaderFooterState, HorizontalRuler, type HorizontalRulerProps$1 as HorizontalRulerProps, type HyperLinkActionProps, type HyperLinkPartProps, type HyperLinkProps, type HyperlinkPopupAnchor, type HyperlinkPopupMode, type HyperlinkPopupState, ImageAltText, ImageInsertProvider, ImageInsertTrigger, ImagePropertiesTrigger, ImageWrap, type IndentUpdate, LocaleProvider, Logo, type MenuActionProps, MenuBar, type MenuGroupProps, type MenuId, type MenuItemProps, type MenuPartComponent, type MenuProps, type MenuReportIssueProps, type MenuRowProps, type MenuSeparatorProps, type MenuSubmenuProps, type MenuTableGridProps, NAVIGATION_PANE_GAP, NAVIGATION_PANE_INSET, NAVIGATION_PANE_WIDTH, NavigationClose, NavigationFind, NavigationHeader, NavigationHeadings, type NavigationPartProps, type NavigationShiftInput, NavigationTab, type NavigationTabProps, type NavigationTab$1 as NavigationTabValue, NavigationTabs, NavigationTitle, NavigationToggle, type NormalizedImagePayload, type NotePropertiesState, type OutlineHeading$1 as OutlineHeading, type OutlineHeadingItem, PageIndicator, type PageSetupUpdate, PaginatedDocxEditor, type PaginatedDocxEditorHandle as PaginatedDocxEditorExpose, type PaginatedDocxEditorHandle, type PaginatedDocxEditorProps, PaginatedDocxEditorShell, type PaginatedDocxEditorShellProps, type ParagraphStyleItemProps, type ParagraphStyleNamespace, type ParagraphStyleOption, type ParagraphStylePartProps, type ParagraphStyleProps, RULER_WIDTH, ReviewRailContext, type ReviewRailRegistry, SEARCH_DEBOUNCE_MS, SEARCH_MATCH_LIMIT, Slot, type SlotProps, type TableBorderColorNamespace, type TableBorderStyleNamespace, type TableBorderTargetNamespace, type TableBorderWidthNamespace, type TableCellFillNamespace, type TableChromeItemProps, type TableChromePartComponent, type TableChromePartProps, TitleBar, TitleBarRight, Toolbar, type ToolbarActionProps, type ToolbarAlignmentComponent, ToolbarButton, type ToolbarButtonProps$1 as ToolbarButtonProps, ToolbarGroup, type ToolbarPartComponent, type ToolbarPartProps, type ToolbarProps, type ToolbarSeparatorProps, type ToolbarSlotPartComponent, type ToolbarSlotPartProps, type ToolbarTranslate, type UseContentControlResult, type UseDocumentOutlineResult, type UseDocumentSearchResult, type UseDocxSourceOptions, type UseDocxSourceResult, type UseFontFamilyResult, type UseHyperlinkPopupResult, type UseNavigationPaneOptions, type UseNavigationPaneResult, type UsePageSetupReturn, type UseParagraphIndentReturn, type UseParagraphStyleResult, VERSION, VerticalRuler, type VerticalRulerProps, navigationPaneReservation, navigationShift, normalizeImageBytes, useContentControl, useContentControlInstance, useContextMenuTarget, useDocumentOutline, useDocumentSearch, useDocxEditor, useDocxSource, useEditorCaret, useEditorCommand, useEditorEvent, useEditorSnapshot, useEditorState, useEditorValueCommand, useFontFamily, useFonts, useHeaderFooterState, useHyperlinkPopup, useHyperlinkPopupInstance, useNavigationPane, useNavigationShift, useNotePropertiesState, useNoteScopeState, usePageSetup, useParagraphIndent, useParagraphStyle, useTableBorderTargetLabel, useTranslation };
|
|
3314
|
+
export { CONTENT_CONTROL_SLOTS, type ChromeTranslate, type ContentControlActionProps, type ContentControlInspectorState, type ContentControlLock, type ContentControlPartProps, type ContentControlProps, type ContentControlSlotId, type ContextMenuAnchor, ContextMenuCellVerticalAlignment, type ContextMenuCommandProps, ContextMenuCopy, ContextMenuCut, ContextMenuDelete, ContextMenuDeleteTable, ContextMenuDeleteTableColumn, ContextMenuDeleteTableRow, ContextMenuInsertColumnLeft, ContextMenuInsertColumnRight, ContextMenuInsertRowAbove, ContextMenuInsertRowBelow, ContextMenuItem, type ContextMenuItemProps, ContextMenuPaste, ContextMenuSelectAll, type ContextMenuTableRowProps, DocumentName, DocxEditor, DocxEditorContent, DocxEditorContentControl, type DocxEditorContentControlNamespace, type DocxEditorContentProps, DocxEditorContextMenu, type DocxEditorContextMenuNamespace, type DocxEditorContextMenuProps, DocxEditorDocumentOutline, type DocxEditorDocumentOutlineProps, DocxEditorFontNotice, type DocxEditorFontNoticeProps, DocxEditorHeaderFooterChrome, type DocxEditorHeaderFooterChromeProps, DocxEditorHorizontalRuler, DocxEditorHyperLink, type DocxEditorHyperLinkNamespace, DocxEditorImagePropertiesDialog, type DocxEditorImagePropertiesDialogProps, DocxEditorLoading, type DocxEditorLoadingComponent, type DocxEditorLoadingProps, DocxEditorLoadingSpinner, type DocxEditorLoadingSpinnerProps, DocxEditorMenu, type DocxEditorMenuNamespace, type DocxEditorMenuProps, type DocxEditorNamespace, DocxEditorNavigation, type DocxEditorNavigationNamespace, type DocxEditorNavigationProps, DocxEditorNotesChrome, type DocxEditorNotesChromeProps, DocxEditorPageSetupDialog, type DocxEditorPageSetupDialogProps, type DocxEditorProps, type DocxEditorRef, DocxEditorRoot, type DocxEditorRootProps, type DocxEditorRulerProps, DocxEditorShell, DocxEditorToolbar, type DocxEditorToolbarNamespace, type DocxEditorToolbarProps, DocxEditorVerticalRuler, DocxEditorViewport, type DocxEditorViewportProps, type DocxFontsInput, type DocxFontsSource, type DocxSource, type EditorCaret, type EditorCommandState, type EditorMode, type EditorValueCommandState, type FontFamilyItemProps, type FontFamilyNamespace, type FontFamilyPartProps, type FontFamilyProps, type FontsInput, type HeaderFooterState, HorizontalRuler, type HorizontalRulerProps$1 as HorizontalRulerProps, type HyperLinkActionProps, type HyperLinkPartProps, type HyperLinkProps, type HyperlinkPopupAnchor, type HyperlinkPopupMode, type HyperlinkPopupState, ImageAltText, ImageInsertProvider, ImageInsertTrigger, ImagePropertiesTrigger, ImageWrap, type IndentUpdate, LocaleProvider, Logo, type MenuActionProps, MenuBar, type MenuGroupProps, type MenuId, type MenuItemProps, type MenuPartComponent, type MenuProps, type MenuReportIssueProps, type MenuRowProps, type MenuSeparatorProps, type MenuSubmenuProps, type MenuTableGridProps, NAVIGATION_PANE_GAP, NAVIGATION_PANE_INSET, NAVIGATION_PANE_WIDTH, NavigationClose, NavigationFind, NavigationHeader, NavigationHeadings, type NavigationPartProps, type NavigationShiftInput, NavigationTab, type NavigationTabProps, type NavigationTab$1 as NavigationTabValue, NavigationTabs, NavigationTitle, NavigationToggle, type NormalizedImagePayload, type NotePropertiesState, type OutlineHeading$1 as OutlineHeading, type OutlineHeadingItem, PageIndicator, type PageSetupUpdate, PaginatedDocxEditor, type PaginatedDocxEditorHandle as PaginatedDocxEditorExpose, type PaginatedDocxEditorHandle, type PaginatedDocxEditorProps, PaginatedDocxEditorShell, type PaginatedDocxEditorShellProps, type ParagraphStyleItemProps, type ParagraphStyleNamespace, type ParagraphStyleOption, type ParagraphStylePartProps, type ParagraphStyleProps, RULER_WIDTH, ReviewRailContext, type ReviewRailRegistry, SEARCH_DEBOUNCE_MS, SEARCH_MATCH_LIMIT, Slot, type SlotProps, type TableBorderColorNamespace, type TableBorderStyleNamespace, type TableBorderTargetNamespace, type TableBorderWidthNamespace, type TableCellFillNamespace, type TableChromeItemProps, type TableChromePartComponent, type TableChromePartProps, TitleBar, TitleBarRight, Toolbar, type ToolbarActionProps, type ToolbarAlignmentComponent, ToolbarButton, type ToolbarButtonProps$1 as ToolbarButtonProps, ToolbarGroup, type ToolbarPartComponent, type ToolbarPartProps, type ToolbarProps, type ToolbarSeparatorProps, type ToolbarSlotPartComponent, type ToolbarSlotPartProps, type ToolbarTranslate, type UseContentControlResult, type UseDocumentOutlineResult, type UseDocumentSearchResult, type UseDocxSourceOptions, type UseDocxSourceResult, type UseFontFamilyResult, type UseHyperlinkPopupResult, type UseNavigationPaneOptions, type UseNavigationPaneResult, type UsePageSetupReturn, type UseParagraphIndentReturn, type UseParagraphStyleResult, VERSION, VerticalRuler, type VerticalRulerProps, navigationPaneReservation, navigationShift, normalizeImageBytes, useChromeTranslate, useContentControl, useContentControlInstance, useContextMenuTarget, useDocumentOutline, useDocumentSearch, useDocxEditor, useDocxSource, useEditorCaret, useEditorCommand, useEditorEvent, useEditorSnapshot, useEditorState, useEditorValueCommand, useFontFamily, useFonts, useHeaderFooterState, useHyperlinkPopup, useHyperlinkPopupInstance, useNavigationPane, useNavigationShift, useNotePropertiesState, useNoteScopeState, usePageSetup, useParagraphIndent, useParagraphStyle, useTableBorderTargetLabel, useTranslation };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface DocxEditorLoadingProps {
|
|
|
38
38
|
* provider only after those resolve.
|
|
39
39
|
*/
|
|
40
40
|
when?: boolean;
|
|
41
|
-
/** Appended after the load-bearing `
|
|
41
|
+
/** Appended after the load-bearing `docx-editor docx-editor__loading` classes. */
|
|
42
42
|
className?: string;
|
|
43
43
|
/** Inline styles for the loading container, as on `DocxEditor.Viewport`. */
|
|
44
44
|
style?: CSSProperties;
|
|
@@ -101,7 +101,7 @@ interface DocxEditorLoadingComponent {
|
|
|
101
101
|
* report otherwise — the same rule `useEditorState` documents for a null editor. Place
|
|
102
102
|
* it inside the provider unless a permanently-visible placeholder is what you want.
|
|
103
103
|
*
|
|
104
|
-
* Carries its own `
|
|
104
|
+
* Carries its own `docx-editor`, so the theme tokens resolve wherever it is composed.
|
|
105
105
|
*
|
|
106
106
|
* @public
|
|
107
107
|
*/
|
|
@@ -1079,17 +1079,23 @@ interface DocxEditorRulerProps {
|
|
|
1079
1079
|
* draggable when the engine supports page-setup writes; the drag previews locally and
|
|
1080
1080
|
* commits one undoable step on release.
|
|
1081
1081
|
*
|
|
1082
|
+
* Renders nothing while the editor holds no document — see
|
|
1083
|
+
* {@link selectDocumentAbsent}.
|
|
1084
|
+
*
|
|
1082
1085
|
* @public
|
|
1083
1086
|
*/
|
|
1084
|
-
declare function DocxEditorHorizontalRuler(props: DocxEditorRulerProps): ReactElement;
|
|
1087
|
+
declare function DocxEditorHorizontalRuler(props: DocxEditorRulerProps): ReactElement | null;
|
|
1085
1088
|
/**
|
|
1086
1089
|
* The vertical ruler as a context-fed part (`DocxEditor.VerticalRuler`): page height,
|
|
1087
1090
|
* margins and zoom straight from the editor. Top/bottom margin handles are draggable
|
|
1088
1091
|
* when the engine supports page-setup writes, committing one undoable step on release.
|
|
1089
1092
|
*
|
|
1093
|
+
* Renders nothing while the editor holds no document — see
|
|
1094
|
+
* {@link selectDocumentAbsent}.
|
|
1095
|
+
*
|
|
1090
1096
|
* @public
|
|
1091
1097
|
*/
|
|
1092
|
-
declare function DocxEditorVerticalRuler(props: DocxEditorRulerProps): ReactElement;
|
|
1098
|
+
declare function DocxEditorVerticalRuler(props: DocxEditorRulerProps): ReactElement | null;
|
|
1093
1099
|
|
|
1094
1100
|
/** Props for the context-fed outline part. @public */
|
|
1095
1101
|
interface DocxEditorDocumentOutlineProps {
|
|
@@ -1105,9 +1111,12 @@ interface DocxEditorDocumentOutlineProps {
|
|
|
1105
1111
|
* from `Editor.getOutline()`, in document order; clicking one moves the caret to that
|
|
1106
1112
|
* heading. The panel positions absolutely — give it a `position: relative` container.
|
|
1107
1113
|
*
|
|
1114
|
+
* Renders nothing while the editor has no document — a floating panel saying "no
|
|
1115
|
+
* headings" about a document that is not there is the same false claim the rulers made.
|
|
1116
|
+
*
|
|
1108
1117
|
* @public
|
|
1109
1118
|
*/
|
|
1110
|
-
declare function DocxEditorDocumentOutline(props: DocxEditorDocumentOutlineProps): ReactElement;
|
|
1119
|
+
declare function DocxEditorDocumentOutline(props: DocxEditorDocumentOutlineProps): ReactElement | null;
|
|
1111
1120
|
|
|
1112
1121
|
/** The pane's tabs. Word's Replace tab is a later slice; nothing here pretends it exists. */
|
|
1113
1122
|
type NavigationTab$1 = 'headings' | 'find';
|
|
@@ -1839,8 +1848,12 @@ interface DocxEditorProps {
|
|
|
1839
1848
|
* Strings still come from `packages/i18n/en.json` rather than literals in components;
|
|
1840
1849
|
* this only chooses who resolves the key. For another language, pass
|
|
1841
1850
|
* `createT(locale)` from `@docx-editor.dev/i18n`.
|
|
1851
|
+
*
|
|
1852
|
+
* `params` carries interpolation values for parameterized keys (for example the
|
|
1853
|
+
* navigation pane's `{current} of {total}` match counter) — a resolver that ignores
|
|
1854
|
+
* them renders the raw placeholders for those labels.
|
|
1842
1855
|
*/
|
|
1843
|
-
t?: (key: string) => string;
|
|
1856
|
+
t?: (key: string, params?: Record<string, string | number>) => string;
|
|
1844
1857
|
/**
|
|
1845
1858
|
* Renders the packaged chrome — title bar and toolbar — around the document.
|
|
1846
1859
|
* Default `true`. Set `false` for the painted surface alone when the host supplies
|
|
@@ -2074,6 +2087,44 @@ declare function useTranslation(): {
|
|
|
2074
2087
|
t: TFunction;
|
|
2075
2088
|
};
|
|
2076
2089
|
|
|
2090
|
+
/**
|
|
2091
|
+
* A chrome-part label resolver: plain string keys, optional interpolation params.
|
|
2092
|
+
*
|
|
2093
|
+
* This is the shape every packaged part's `t` prop accepts. It takes `string` rather
|
|
2094
|
+
* than the `TranslationKey` union so a host can route its own extra keys through the
|
|
2095
|
+
* same resolver.
|
|
2096
|
+
*
|
|
2097
|
+
* @public
|
|
2098
|
+
*/
|
|
2099
|
+
type ChromeTranslate = (key: string, params?: Record<string, string | number>) => string;
|
|
2100
|
+
/**
|
|
2101
|
+
* The catalogue-backed resolver for composed chrome, ready to pass as any part's `t`.
|
|
2102
|
+
*
|
|
2103
|
+
* `useTranslation().t` is keyed by the strict `TranslationKey` union, which does not
|
|
2104
|
+
* assign to the parts' plain-`string` `t` props — so before this hook, every composing
|
|
2105
|
+
* host hand-wrote the same cast wrapper `<DocxEditor>` builds internally. This is that
|
|
2106
|
+
* wrapper, exported: it resolves through the active `LocaleContext` catalogue (bundled
|
|
2107
|
+
* English by default), with `overrides` consulted first for key-level renames.
|
|
2108
|
+
*
|
|
2109
|
+
* ```tsx
|
|
2110
|
+
* const MY_LABELS = new Map([['toolbar.bold', 'Heavy']]); // module-level: stable identity
|
|
2111
|
+
*
|
|
2112
|
+
* const t = useChromeTranslate(MY_LABELS);
|
|
2113
|
+
* <DocxEditor.Toolbar t={t} />
|
|
2114
|
+
* ```
|
|
2115
|
+
*
|
|
2116
|
+
* Keep the `overrides` Map identity stable (module-level or memoized) — the returned
|
|
2117
|
+
* resolver is memoized on it, and an inline `new Map(...)` re-creates the resolver, and
|
|
2118
|
+
* with it every consuming part's props, on each render.
|
|
2119
|
+
*
|
|
2120
|
+
* `overrides` is a `Map` on purpose: the key is caller input, and an object literal
|
|
2121
|
+
* would answer `constructor` and `toString` off the prototype chain. Parts pass no
|
|
2122
|
+
* `params` today for overridden keys, so override values are literal strings.
|
|
2123
|
+
*
|
|
2124
|
+
* @public
|
|
2125
|
+
*/
|
|
2126
|
+
declare function useChromeTranslate(overrides?: ReadonlyMap<string, string>): ChromeTranslate;
|
|
2127
|
+
|
|
2077
2128
|
/** Live furniture scope state from `Editor.getHeaderFooterState()`. */
|
|
2078
2129
|
type HeaderFooterState = Exclude<ReturnType<Editor['getHeaderFooterState']>, null>;
|
|
2079
2130
|
/**
|
|
@@ -3260,4 +3311,4 @@ declare function useEditorSnapshot(editor: Editor | null): number;
|
|
|
3260
3311
|
*/
|
|
3261
3312
|
declare const VERSION = "0.0.2";
|
|
3262
3313
|
|
|
3263
|
-
export { CONTENT_CONTROL_SLOTS, type ContentControlActionProps, type ContentControlInspectorState, type ContentControlLock, type ContentControlPartProps, type ContentControlProps, type ContentControlSlotId, type ContextMenuAnchor, ContextMenuCellVerticalAlignment, type ContextMenuCommandProps, ContextMenuCopy, ContextMenuCut, ContextMenuDelete, ContextMenuDeleteTable, ContextMenuDeleteTableColumn, ContextMenuDeleteTableRow, ContextMenuInsertColumnLeft, ContextMenuInsertColumnRight, ContextMenuInsertRowAbove, ContextMenuInsertRowBelow, ContextMenuItem, type ContextMenuItemProps, ContextMenuPaste, ContextMenuSelectAll, type ContextMenuTableRowProps, DocumentName, DocxEditor, DocxEditorContent, DocxEditorContentControl, type DocxEditorContentControlNamespace, type DocxEditorContentProps, DocxEditorContextMenu, type DocxEditorContextMenuNamespace, type DocxEditorContextMenuProps, DocxEditorDocumentOutline, type DocxEditorDocumentOutlineProps, DocxEditorFontNotice, type DocxEditorFontNoticeProps, DocxEditorHeaderFooterChrome, type DocxEditorHeaderFooterChromeProps, DocxEditorHorizontalRuler, DocxEditorHyperLink, type DocxEditorHyperLinkNamespace, DocxEditorImagePropertiesDialog, type DocxEditorImagePropertiesDialogProps, DocxEditorLoading, type DocxEditorLoadingComponent, type DocxEditorLoadingProps, DocxEditorLoadingSpinner, type DocxEditorLoadingSpinnerProps, DocxEditorMenu, type DocxEditorMenuNamespace, type DocxEditorMenuProps, type DocxEditorNamespace, DocxEditorNavigation, type DocxEditorNavigationNamespace, type DocxEditorNavigationProps, DocxEditorNotesChrome, type DocxEditorNotesChromeProps, DocxEditorPageSetupDialog, type DocxEditorPageSetupDialogProps, type DocxEditorProps, type DocxEditorRef, DocxEditorRoot, type DocxEditorRootProps, type DocxEditorRulerProps, DocxEditorShell, DocxEditorToolbar, type DocxEditorToolbarNamespace, type DocxEditorToolbarProps, DocxEditorVerticalRuler, DocxEditorViewport, type DocxEditorViewportProps, type DocxFontsInput, type DocxFontsSource, type DocxSource, type EditorCaret, type EditorCommandState, type EditorMode, type EditorValueCommandState, type FontFamilyItemProps, type FontFamilyNamespace, type FontFamilyPartProps, type FontFamilyProps, type FontsInput, type HeaderFooterState, HorizontalRuler, type HorizontalRulerProps$1 as HorizontalRulerProps, type HyperLinkActionProps, type HyperLinkPartProps, type HyperLinkProps, type HyperlinkPopupAnchor, type HyperlinkPopupMode, type HyperlinkPopupState, ImageAltText, ImageInsertProvider, ImageInsertTrigger, ImagePropertiesTrigger, ImageWrap, type IndentUpdate, LocaleProvider, Logo, type MenuActionProps, MenuBar, type MenuGroupProps, type MenuId, type MenuItemProps, type MenuPartComponent, type MenuProps, type MenuReportIssueProps, type MenuRowProps, type MenuSeparatorProps, type MenuSubmenuProps, type MenuTableGridProps, NAVIGATION_PANE_GAP, NAVIGATION_PANE_INSET, NAVIGATION_PANE_WIDTH, NavigationClose, NavigationFind, NavigationHeader, NavigationHeadings, type NavigationPartProps, type NavigationShiftInput, NavigationTab, type NavigationTabProps, type NavigationTab$1 as NavigationTabValue, NavigationTabs, NavigationTitle, NavigationToggle, type NormalizedImagePayload, type NotePropertiesState, type OutlineHeading$1 as OutlineHeading, type OutlineHeadingItem, PageIndicator, type PageSetupUpdate, PaginatedDocxEditor, type PaginatedDocxEditorHandle as PaginatedDocxEditorExpose, type PaginatedDocxEditorHandle, type PaginatedDocxEditorProps, PaginatedDocxEditorShell, type PaginatedDocxEditorShellProps, type ParagraphStyleItemProps, type ParagraphStyleNamespace, type ParagraphStyleOption, type ParagraphStylePartProps, type ParagraphStyleProps, RULER_WIDTH, ReviewRailContext, type ReviewRailRegistry, SEARCH_DEBOUNCE_MS, SEARCH_MATCH_LIMIT, Slot, type SlotProps, type TableBorderColorNamespace, type TableBorderStyleNamespace, type TableBorderTargetNamespace, type TableBorderWidthNamespace, type TableCellFillNamespace, type TableChromeItemProps, type TableChromePartComponent, type TableChromePartProps, TitleBar, TitleBarRight, Toolbar, type ToolbarActionProps, type ToolbarAlignmentComponent, ToolbarButton, type ToolbarButtonProps$1 as ToolbarButtonProps, ToolbarGroup, type ToolbarPartComponent, type ToolbarPartProps, type ToolbarProps, type ToolbarSeparatorProps, type ToolbarSlotPartComponent, type ToolbarSlotPartProps, type ToolbarTranslate, type UseContentControlResult, type UseDocumentOutlineResult, type UseDocumentSearchResult, type UseDocxSourceOptions, type UseDocxSourceResult, type UseFontFamilyResult, type UseHyperlinkPopupResult, type UseNavigationPaneOptions, type UseNavigationPaneResult, type UsePageSetupReturn, type UseParagraphIndentReturn, type UseParagraphStyleResult, VERSION, VerticalRuler, type VerticalRulerProps, navigationPaneReservation, navigationShift, normalizeImageBytes, useContentControl, useContentControlInstance, useContextMenuTarget, useDocumentOutline, useDocumentSearch, useDocxEditor, useDocxSource, useEditorCaret, useEditorCommand, useEditorEvent, useEditorSnapshot, useEditorState, useEditorValueCommand, useFontFamily, useFonts, useHeaderFooterState, useHyperlinkPopup, useHyperlinkPopupInstance, useNavigationPane, useNavigationShift, useNotePropertiesState, useNoteScopeState, usePageSetup, useParagraphIndent, useParagraphStyle, useTableBorderTargetLabel, useTranslation };
|
|
3314
|
+
export { CONTENT_CONTROL_SLOTS, type ChromeTranslate, type ContentControlActionProps, type ContentControlInspectorState, type ContentControlLock, type ContentControlPartProps, type ContentControlProps, type ContentControlSlotId, type ContextMenuAnchor, ContextMenuCellVerticalAlignment, type ContextMenuCommandProps, ContextMenuCopy, ContextMenuCut, ContextMenuDelete, ContextMenuDeleteTable, ContextMenuDeleteTableColumn, ContextMenuDeleteTableRow, ContextMenuInsertColumnLeft, ContextMenuInsertColumnRight, ContextMenuInsertRowAbove, ContextMenuInsertRowBelow, ContextMenuItem, type ContextMenuItemProps, ContextMenuPaste, ContextMenuSelectAll, type ContextMenuTableRowProps, DocumentName, DocxEditor, DocxEditorContent, DocxEditorContentControl, type DocxEditorContentControlNamespace, type DocxEditorContentProps, DocxEditorContextMenu, type DocxEditorContextMenuNamespace, type DocxEditorContextMenuProps, DocxEditorDocumentOutline, type DocxEditorDocumentOutlineProps, DocxEditorFontNotice, type DocxEditorFontNoticeProps, DocxEditorHeaderFooterChrome, type DocxEditorHeaderFooterChromeProps, DocxEditorHorizontalRuler, DocxEditorHyperLink, type DocxEditorHyperLinkNamespace, DocxEditorImagePropertiesDialog, type DocxEditorImagePropertiesDialogProps, DocxEditorLoading, type DocxEditorLoadingComponent, type DocxEditorLoadingProps, DocxEditorLoadingSpinner, type DocxEditorLoadingSpinnerProps, DocxEditorMenu, type DocxEditorMenuNamespace, type DocxEditorMenuProps, type DocxEditorNamespace, DocxEditorNavigation, type DocxEditorNavigationNamespace, type DocxEditorNavigationProps, DocxEditorNotesChrome, type DocxEditorNotesChromeProps, DocxEditorPageSetupDialog, type DocxEditorPageSetupDialogProps, type DocxEditorProps, type DocxEditorRef, DocxEditorRoot, type DocxEditorRootProps, type DocxEditorRulerProps, DocxEditorShell, DocxEditorToolbar, type DocxEditorToolbarNamespace, type DocxEditorToolbarProps, DocxEditorVerticalRuler, DocxEditorViewport, type DocxEditorViewportProps, type DocxFontsInput, type DocxFontsSource, type DocxSource, type EditorCaret, type EditorCommandState, type EditorMode, type EditorValueCommandState, type FontFamilyItemProps, type FontFamilyNamespace, type FontFamilyPartProps, type FontFamilyProps, type FontsInput, type HeaderFooterState, HorizontalRuler, type HorizontalRulerProps$1 as HorizontalRulerProps, type HyperLinkActionProps, type HyperLinkPartProps, type HyperLinkProps, type HyperlinkPopupAnchor, type HyperlinkPopupMode, type HyperlinkPopupState, ImageAltText, ImageInsertProvider, ImageInsertTrigger, ImagePropertiesTrigger, ImageWrap, type IndentUpdate, LocaleProvider, Logo, type MenuActionProps, MenuBar, type MenuGroupProps, type MenuId, type MenuItemProps, type MenuPartComponent, type MenuProps, type MenuReportIssueProps, type MenuRowProps, type MenuSeparatorProps, type MenuSubmenuProps, type MenuTableGridProps, NAVIGATION_PANE_GAP, NAVIGATION_PANE_INSET, NAVIGATION_PANE_WIDTH, NavigationClose, NavigationFind, NavigationHeader, NavigationHeadings, type NavigationPartProps, type NavigationShiftInput, NavigationTab, type NavigationTabProps, type NavigationTab$1 as NavigationTabValue, NavigationTabs, NavigationTitle, NavigationToggle, type NormalizedImagePayload, type NotePropertiesState, type OutlineHeading$1 as OutlineHeading, type OutlineHeadingItem, PageIndicator, type PageSetupUpdate, PaginatedDocxEditor, type PaginatedDocxEditorHandle as PaginatedDocxEditorExpose, type PaginatedDocxEditorHandle, type PaginatedDocxEditorProps, PaginatedDocxEditorShell, type PaginatedDocxEditorShellProps, type ParagraphStyleItemProps, type ParagraphStyleNamespace, type ParagraphStyleOption, type ParagraphStylePartProps, type ParagraphStyleProps, RULER_WIDTH, ReviewRailContext, type ReviewRailRegistry, SEARCH_DEBOUNCE_MS, SEARCH_MATCH_LIMIT, Slot, type SlotProps, type TableBorderColorNamespace, type TableBorderStyleNamespace, type TableBorderTargetNamespace, type TableBorderWidthNamespace, type TableCellFillNamespace, type TableChromeItemProps, type TableChromePartComponent, type TableChromePartProps, TitleBar, TitleBarRight, Toolbar, type ToolbarActionProps, type ToolbarAlignmentComponent, ToolbarButton, type ToolbarButtonProps$1 as ToolbarButtonProps, ToolbarGroup, type ToolbarPartComponent, type ToolbarPartProps, type ToolbarProps, type ToolbarSeparatorProps, type ToolbarSlotPartComponent, type ToolbarSlotPartProps, type ToolbarTranslate, type UseContentControlResult, type UseDocumentOutlineResult, type UseDocumentSearchResult, type UseDocxSourceOptions, type UseDocxSourceResult, type UseFontFamilyResult, type UseHyperlinkPopupResult, type UseNavigationPaneOptions, type UseNavigationPaneResult, type UsePageSetupReturn, type UseParagraphIndentReturn, type UseParagraphStyleResult, VERSION, VerticalRuler, type VerticalRulerProps, navigationPaneReservation, navigationShift, normalizeImageBytes, useChromeTranslate, useContentControl, useContentControlInstance, useContextMenuTarget, useDocumentOutline, useDocumentSearch, useDocxEditor, useDocxSource, useEditorCaret, useEditorCommand, useEditorEvent, useEditorSnapshot, useEditorState, useEditorValueCommand, useFontFamily, useFonts, useHeaderFooterState, useHyperlinkPopup, useHyperlinkPopupInstance, useNavigationPane, useNavigationShift, useNotePropertiesState, useNoteScopeState, usePageSetup, useParagraphIndent, useParagraphStyle, useTableBorderTargetLabel, useTranslation };
|