@eigenpal/docx-editor-react 1.0.3 → 1.2.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/dist/index.d.ts CHANGED
@@ -20,15 +20,15 @@ import * as prosemirror_view from 'prosemirror-view';
20
20
  import { EditorView } from 'prosemirror-view';
21
21
  import * as prosemirror_state from 'prosemirror-state';
22
22
  import { EditorState, Transaction } from 'prosemirror-state';
23
- import { Document, Theme } from '@eigenpal/docx-editor-core/types/document';
23
+ import { Document, HeaderFooter, Theme } from '@eigenpal/docx-editor-core/types/document';
24
24
  import { FontOption } from '@eigenpal/docx-editor-core/utils/fontOptions';
25
25
  import { R as ReactSidebarItem } from './types-D35gNE-_.js';
26
26
  import { Comment } from '@eigenpal/docx-editor-core/types/content';
27
27
  import { Translations, TFunction } from '@eigenpal/docx-editor-i18n';
28
28
  import { P as PrintOptions } from './PrintPreview-DEhwRBC_.js';
29
- import { DocumentAgent } from '@eigenpal/docx-editor-core/agent';
30
- import { DocxInput } from '@eigenpal/docx-editor-core/utils';
31
- import { SelectionState } from '@eigenpal/docx-editor-core/prosemirror';
29
+ import { DocumentAgent, ContentControlFilter, ContentControlValue } from '@eigenpal/docx-editor-core/agent';
30
+ import { DocxInput, FontDefinition } from '@eigenpal/docx-editor-core/utils';
31
+ import { SelectionState, PMContentControl } from '@eigenpal/docx-editor-core/prosemirror';
32
32
  import { Layout } from '@eigenpal/docx-editor-core/layout-engine';
33
33
  import { RenderedDomContext } from '@eigenpal/docx-editor-core/plugin-api';
34
34
  import { EditorHandle } from '@eigenpal/docx-editor-core';
@@ -108,6 +108,17 @@ interface PagedEditorRef {
108
108
  * No-op if the layout isn't ready yet or pageNumber is out of range.
109
109
  */
110
110
  scrollToPage(pageNumber: number): void;
111
+ /**
112
+ * Look up the persistent hidden HF PM EditorView for a given HeaderFooter
113
+ * instance. Returns null when none is mounted (no document, or `hf` is not
114
+ * present in `Document.package.headers/footers`). Phase 2 of the HF
115
+ * unification: the inline overlay uses this to replicate edits into the
116
+ * persistent PM so the painter — which reads from the persistent PM per
117
+ * phase 1 — re-renders live during typing. Phase 5 deletes the inline
118
+ * overlay's PM and this method's only remaining caller is the click /
119
+ * focus router (phase 3).
120
+ */
121
+ getHfPmView(hf: HeaderFooter): EditorView | null;
111
122
  }
112
123
 
113
124
  /**
@@ -202,6 +213,23 @@ interface DocxEditorProps {
202
213
  * @example fontFamilies={[{ name: 'Roboto', fontFamily: 'Roboto, sans-serif', category: 'sans-serif' }]}
203
214
  */
204
215
  fontFamilies?: ReadonlyArray<string | FontOption>;
216
+ /**
217
+ * Custom font faces to register with the browser before the editor measures
218
+ * text. Each entry injects an `@font-face` rule. Pass a URL (woff2/woff/
219
+ * ttf/otf), an ArrayBuffer, or omit `src` to load by name from Google Fonts.
220
+ * Multiple entries can share `family` to register different weights/styles.
221
+ *
222
+ * Pass a stable reference — inline arrays re-register faces on each render
223
+ * (the loader dedupes by `family|weight|style`, so it's harmless but wastes
224
+ * work).
225
+ *
226
+ * @example
227
+ * fonts={[
228
+ * { family: 'Custom Sans', src: '/fonts/CustomSans-Regular.woff2' },
229
+ * { family: 'Custom Sans', src: '/fonts/CustomSans-Bold.woff2', weight: 700 },
230
+ * ]}
231
+ */
232
+ fonts?: ReadonlyArray<FontDefinition>;
205
233
  /** Print options for print preview */
206
234
  printOptions?: PrintOptions;
207
235
  /**
@@ -434,6 +462,41 @@ interface DocxEditorRef {
434
462
  } | null;
435
463
  /** Get all comments. */
436
464
  getComments: () => Comment[];
465
+ /**
466
+ * List block-level content controls (SDTs) in the live document, optionally
467
+ * filtered by `tag`/`alias`/`id`/`type`. Each result includes the control's
468
+ * text and PM position. Anchors for templates and document automation.
469
+ */
470
+ getContentControls: (filter?: ContentControlFilter) => PMContentControl[];
471
+ /** Scroll the first content control matching `filter` into view. Returns false if none. */
472
+ scrollToContentControl: (filter: ContentControlFilter) => boolean;
473
+ /**
474
+ * Replace the content of the first control matching `filter` with `text`
475
+ * (newlines become paragraphs). Returns false if no match. Throws if the
476
+ * control is content-locked unless `{ force: true }`.
477
+ */
478
+ setContentControlContent: (filter: ContentControlFilter, text: string, options?: {
479
+ force?: boolean;
480
+ }) => boolean;
481
+ /**
482
+ * Remove the first control matching `filter`. With `{ keepContent: true }`
483
+ * the inner blocks are unwrapped in place. Returns false if no match. Throws
484
+ * if the control is deletion-locked unless `{ force: true }`.
485
+ */
486
+ removeContentControl: (filter: ContentControlFilter, options?: {
487
+ force?: boolean;
488
+ keepContent?: boolean;
489
+ }) => boolean;
490
+ /**
491
+ * Set a typed value on the first control matching `filter`: a dropdown
492
+ * selection (`{ kind: 'dropdown', value }`), checkbox (`{ kind: 'checkbox',
493
+ * checked }`), or date (`{ kind: 'date', date }`). Updates the visible
494
+ * content and structured state. Returns false if no match; throws if
495
+ * content-locked (unless `force`) or the value doesn't fit the control type.
496
+ */
497
+ setContentControlValue: (filter: ContentControlFilter, value: ContentControlValue, options?: {
498
+ force?: boolean;
499
+ }) => boolean;
437
500
  /** Subscribe to document changes. Fires after every committed edit. Returns unsubscribe. */
438
501
  onContentChange: (listener: (document: Document) => void) => () => void;
439
502
  /** Subscribe to selection changes (cursor moves / selection changes). Returns unsubscribe. */