@eigenpal/docx-editor-react/dialogs
Modal dialogs for hyperlinks, find/replace, paste-special, page setup, and keyboard shortcuts. Pair with the hooks under `@eigenpal/docx-editor-react/hooks` when wiring custom UI.
Functions(26)
createBookmarkLinkData
Create HyperlinkData for an internal bookmark
declare function createBookmarkLinkData(bookmark: string, displayText?: string): HyperlinkData;createHyperlinkData
Create HyperlinkData from a URL string
declare function createHyperlinkData(url: string, displayText?: string): HyperlinkData;Convert email address to mailto: link
declare function emailToMailto(email: string): string;extractBookmarksForDialog
Extract bookmarks from document for the dialog
declare function extractBookmarksForDialog(bookmarks: {
name: string;
id: number;
}[]): BookmarkOption[];FindReplaceDialog
FindReplaceDialog component - Modal for finding and replacing text
declare function FindReplaceDialog(input: FindReplaceDialogProps): React__default.ReactElement | null;formatShortcutKeys
Format key combination for current platform
declare function formatKeys(keys: string): string;Get all categories
declare function getAllCategories(): ShortcutCategory[];getAllPasteOptions
Get all paste option definitions
declare function getAllPasteOptions(): PasteOptionDef[];Get category label translation key
declare function getCategoryLabel(category: ShortcutCategory): string;getCommonShortcuts
Get common/frequently used shortcuts
declare function getCommonShortcuts(): KeyboardShortcut[];getDefaultPasteOption
Get default paste option
declare function getDefaultPasteOption(): PasteOption;getDefaultShortcuts
Get all default shortcuts
declare function getDefaultShortcuts(): KeyboardShortcut[];getDisplayText
Get display text from HyperlinkData, falling back to URL/bookmark
declare function getDisplayText(data: HyperlinkData): string;getPasteOption
Get paste option definition by id
declare function getPasteOption(id: PasteOption): PasteOptionDef | undefined;getShortcutsByCategory
Get shortcuts by category
declare function getShortcutsByCategory(category: ShortcutCategory): KeyboardShortcut[];Detect URL type from string
declare function getUrlType(url: string): 'web' | 'email' | 'phone' | 'ftp' | 'unknown';HyperlinkDialog
HyperlinkDialog component - Modal for inserting/editing hyperlinks
declare function HyperlinkDialog(input: HyperlinkDialogProps): React__default.ReactElement | null;isBookmarkHyperlinkData
Check if HyperlinkData is for an internal bookmark
declare function isBookmarkHyperlinkData(data: HyperlinkData): boolean;isExternalHyperlinkData
Check if HyperlinkData is for an external URL
declare function isExternalHyperlinkData(data: HyperlinkData): boolean;isPasteSpecialShortcut
Check if paste special shortcut
declare function isPasteSpecialShortcut(event: KeyboardEvent): boolean;Validate a URL string Supports http, https, mailto, tel, ftp protocols
declare function isValidUrl(url: string): boolean;Normalize a URL by adding protocol if needed
declare function normalizeUrl(url: string): string;PageSetupDialog
declare function PageSetupDialog(input: PageSetupDialogProps): React__default.ReactElement | null;Convert phone number to tel: link
declare function phoneToTel(phone: string): string;useKeyboardShortcutsDialog
Hook to manage keyboard shortcuts dialog
declare function useKeyboardShortcutsDialog(options?: UseKeyboardShortcutsDialogOptions): UseKeyboardShortcutsDialogReturn;usePasteSpecial
Hook to manage paste special dialog
declare function usePasteSpecial(options?: UsePasteSpecialOptions): UsePasteSpecialReturn;Interfaces(12)
BookmarkOption
Bookmark option for internal link selection
interface BookmarkOption| Member | Type | Summary |
|---|---|---|
| label? | string | Optional display label |
| name | string | Bookmark name/ID |
FindReplaceDialogProps
Props for the FindReplaceDialog component
interface FindReplaceDialogProps| Member | Type | Summary |
|---|---|---|
| className? | string | Additional CSS class |
| currentResult? | FindResult | null | Current match result (from external state) |
| initialSearchText? | string | Initial search text (e.g., from selected text) |
| isOpen | boolean | Whether the dialog is open |
| onClearHighlights? | () => void | Callback to clear highlights |
| onClose | () => void | Callback when dialog is closed |
| onFind | (searchText: string, options: FindOptions) => FindResult | null | Callback when searching for text |
| onFindNext | () => FindMatch | null | Callback when navigating to next match |
| onFindPrevious | () => FindMatch | null | Callback when navigating to previous match |
| onHighlightMatches? | (matches: FindMatch[]) => void | Callback to highlight matches in document |
| onReplace | (replaceText: string) => boolean | Callback when replacing current match |
| onReplaceAll | (searchText: string, replaceText: string, options: FindOptions) => number | Callback when replacing all matches |
| replaceMode? | boolean | Whether to start in replace mode |
| style? | CSSProperties | Additional inline styles |
HyperlinkData
Hyperlink data structure for dialog
interface HyperlinkData| Member | Type | Summary |
|---|---|---|
| bookmark? | string | Internal bookmark name |
| displayText? | string | Display text for the link |
| tooltip? | string | Tooltip text |
| url? | string | URL for external link |
HyperlinkDialogProps
Props for the HyperlinkDialog component
interface HyperlinkDialogProps| Member | Type | Summary |
|---|---|---|
| bookmarks? | BookmarkOption[] | Available bookmarks for internal links |
| className? | string | Additional CSS class |
| initialData? | HyperlinkData | Initial data for editing existing hyperlink |
| isEditing? | boolean | Whether we're editing an existing hyperlink |
| isOpen | boolean | Whether the dialog is open |
| onClose | () => void | Callback when dialog is closed |
| onRemove? | () => void | Callback when hyperlink is removed |
| onSubmit | (data: HyperlinkData) => void | Callback when hyperlink is inserted/updated |
| selectedText? | string | Currently selected text (used as default display text) |
| style? | CSSProperties | Additional inline styles |
KeyboardShortcut
Keyboard shortcut definition
interface KeyboardShortcut| Member | Type | Summary |
|---|---|---|
| altKeys? | string | Alternative key combination |
| category | ShortcutCategory | Category for grouping |
| common? | boolean | Whether this is a common/frequently used shortcut |
| description | string | Description of what the shortcut does |
| descriptionKey? | TranslationKey | Translation key for description (used internally) |
| id | string | Unique identifier |
| keys | string | Primary key combination (e.g., 'Ctrl+C') |
| name | string | Display name |
| nameKey? | TranslationKey | Translation key for display name (used internally) |
KeyboardShortcutsDialogProps
Dialog props
interface KeyboardShortcutsDialogProps| Member | Type | Summary |
|---|---|---|
| className? | string | Additional className |
| customShortcuts? | KeyboardShortcut[] | Custom shortcuts (merged with defaults) |
| isOpen | boolean | Whether the dialog is open |
| onClose | () => void | Close callback |
| showSearch? | boolean | Whether to show search |
PageSetupDialogProps
Page Setup Dialog
Modal for editing page layout properties: - Page size (Letter, A4, Legal, etc.) - Orientation (portrait/landscape) - Margins (top, bottom, left, right) in inches
interface PageSetupDialogProps| Member | Type | Summary |
|---|---|---|
| currentProps? | SectionProperties | |
| isOpen | boolean | |
| onApply | (props: Partial<SectionProperties>) => void | |
| onClose | () => void |
PasteSpecialDialogProps
Paste special dialog props
interface PasteSpecialDialogProps| Member | Type | Summary |
|---|---|---|
| className? | string | Additional className |
| isOpen | boolean | Whether the dialog is open |
| onClose | () => void | Callback when dialog is closed |
| onPaste | (content: ParsedClipboardContent, asPlainText: boolean) => void | Callback when paste is confirmed |
| position? | {
x: number;
y: number;
} | Optional custom position |
UseKeyboardShortcutsDialogOptions
Hook options
interface UseKeyboardShortcutsDialogOptions| Member | Type | Summary |
|---|---|---|
| enabled? | boolean | Whether the dialog can be opened with Ctrl+? or F1 |
| openShortcut? | string | Custom open shortcut (default: Ctrl+/) |
UseKeyboardShortcutsDialogReturn
Hook return value
interface UseKeyboardShortcutsDialogReturn| Member | Type | Summary |
|---|---|---|
| close | () => void | Close the dialog |
| handleKeyDown | (event: KeyboardEvent) => void | Keyboard event handler |
| isOpen | boolean | Whether dialog is open |
| open | () => void | Open the dialog |
| toggle | () => void | Toggle the dialog |
UsePasteSpecialOptions
Options for usePasteSpecial hook
interface UsePasteSpecialOptions| Member | Type | Summary |
|---|---|---|
| enabled? | boolean | Whether paste operations are enabled |
| onPaste? | (content: ParsedClipboardContent, asPlainText: boolean) => void | Callback when paste is confirmed |
UsePasteSpecialReturn
Hook return value for paste special
interface UsePasteSpecialReturn| Member | Type | Summary |
|---|---|---|
| closeDialog | () => void | Close the dialog |
| handleKeyDown | (event: KeyboardEvent) => boolean | Handle keyboard shortcut (Ctrl+Shift+V) |
| isOpen | boolean | Whether the dialog is open |
| openDialog | () => void | Open the paste special dialog |
| pasteAsPlainText | () => Promise<void> | Paste as plain text directly |
Type aliases(2)
Paste option type
type PasteOption = 'formatted' | 'plainText';ShortcutCategory
Shortcut category
type ShortcutCategory = 'editing' | 'formatting' | 'navigation' | 'clipboard' | 'selection' | 'view' | 'file' | 'other';Variables(2)
KeyboardShortcutsDialog
KeyboardShortcutsDialog: React__default.FC<KeyboardShortcutsDialogProps>PasteSpecialDialog
PasteSpecialDialog: React__default.FC<PasteSpecialDialogProps>