Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 46 additions & 36 deletions docs/PROPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,55 @@

## Props

| Prop | Type | Default | Description |
| ---------------------- | ------------------------------------------- | ----------- | -------------------------------------------------------------------------------------- |
| `documentBuffer` | `ArrayBuffer \| Uint8Array \| Blob \| File` | — | `.docx` file contents to load |
| `document` | `Document` | — | Pre-parsed document (alternative to buffer) |
| `author` | `string` | `'User'` | Author name for comments and track changes |
| `mode` | `'editing' \| 'suggesting' \| 'viewing'` | `'editing'` | Editor mode — editing, suggesting (track changes), or viewing (read-only with toolbar) |
| `onModeChange` | `(mode: EditorMode) => void` | — | Called when the user changes the editing mode |
| `readOnly` | `boolean` | `false` | Read-only preview (hides toolbar, rulers, panel) |
| `showToolbar` | `boolean` | `true` | Show formatting toolbar |
| `showRuler` | `boolean` | `false` | Show horizontal & vertical rulers |
| `rulerUnit` | `'inch' \| 'cm'` | `'inch'` | Unit for ruler display |
| `showZoomControl` | `boolean` | `true` | Show zoom controls in toolbar |
| `showPrintButton` | `boolean` | `true` | Show print button in toolbar |
| `showOutline` | `boolean` | `false` | Show document outline sidebar (table of contents) |
| `showMarginGuides` | `boolean` | `false` | Show page margin guide boundaries |
| `marginGuideColor` | `string` | `'#c0c0c0'` | Color for margin guides |
| `initialZoom` | `number` | `1.0` | Initial zoom level |
| `theme` | `Theme \| null` | — | Theme for styling |
| `toolbarExtra` | `ReactNode` | — | Custom toolbar items appended to the toolbar |
| `placeholder` | `ReactNode` | — | Placeholder when no document is loaded |
| `loadingIndicator` | `ReactNode` | — | Custom loading indicator |
| `className` | `string` | — | Additional CSS class name |
| `style` | `CSSProperties` | — | Additional inline styles |
| `onChange` | `(doc: Document) => void` | — | Called on document change |
| `onSave` | `(buffer: ArrayBuffer) => void` | — | Called on save |
| `onError` | `(error: Error) => void` | — | Called on error |
| `onSelectionChange` | `(state: SelectionState \| null) => void` | — | Called on selection change |
| `onFontsLoaded` | `() => void` | — | Called when fonts finish loading |
| `onPrint` | `() => void` | — | Called when print is triggered |
| `onCopy` | `() => void` | — | Called when content is copied |
| `onCut` | `() => void` | — | Called when content is cut |
| `onPaste` | `() => void` | — | Called when content is pasted |
| `renderLogo` | `() => ReactNode` | — | Custom logo in the title bar |
| `documentName` | `string` | — | Editable document name in the title bar |
| `onDocumentNameChange` | `(name: string) => void` | — | Called when the user edits the document name |
| `renderTitleBarRight` | `() => ReactNode` | — | Custom right-side actions in the title bar |
| Prop | Type | Default | Description |
| ------------------------- | ------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------- |
| `documentBuffer` | `ArrayBuffer \| Uint8Array \| Blob \| File` | — | `.docx` file contents to load |
| `document` | `Document` | — | Pre-parsed document (alternative to buffer) |
| `author` | `string` | `'User'` | Author name for comments and track changes |
| `mode` | `'editing' \| 'suggesting' \| 'viewing'` | `'editing'` | Editor mode — editing, suggesting (track changes), or viewing (read-only with toolbar) |
| `onModeChange` | `(mode: EditorMode) => void` | — | Called when the user changes the editing mode |
| `readOnly` | `boolean` | `false` | Read-only preview (toolbar hidden unless `showToolbarWhenReadOnly` is true) |
| `showToolbar` | `boolean` | `true` | Show the toolbar area |
| `toolbar` | `'compact' \| 'ribbon'` | `'compact'` | Toolbar mode. Defaults to compact; ribbon is opt-in |
| `showToolbarWhenReadOnly` | `boolean` | — | Show toolbar in read-only (defaults to `true` for ribbon, `false` for compact) |
| `showRuler` | `boolean` | `false` | Show horizontal & vertical rulers (acts as initial value unless controlled) |
| `onShowRulerChange` | `(visible: boolean) => void` | — | Called when ribbon toggles ruler visibility (controlled mode) |
| `rulerUnit` | `'inch' \| 'cm'` | `'inch'` | Unit for ruler display |
| `showZoomControl` | `boolean` | `true` | Show zoom controls in toolbar |
| `showPrintButton` | `boolean` | `true` | Show print button in toolbar |
| `showPageNumbers` | `boolean` | `true` | Show page number indicator |
| `enablePageNavigation` | `boolean` | `true` | Enable interactive page navigation |
| `pageNumberPosition` | `string` | `'bottom-center'` | Position of page number indicator |
| `pageNumberVariant` | `string` | `'default'` | Variant of page number indicator |
| `showOutline` | `boolean` | `false` | Show document outline sidebar (table of contents) |
| `showMarginGuides` | `boolean` | `false` | Show page margin guide boundaries |
| `marginGuideColor` | `string` | `'#c0c0c0'` | Color for margin guides |
| `initialZoom` | `number` | `1.0` | Initial zoom level |
| `theme` | `Theme \| null` | — | Theme for styling |
| `toolbarExtra` | `ReactNode` | — | Custom toolbar items appended to the toolbar |
| `renderLogo` | `() => ReactNode` | — | Custom logo in the title bar |
| `documentName` | `string` | — | Editable document name in the title bar |
| `onDocumentNameChange` | `(name: string) => void` | — | Called when the user edits the document name |
| `documentNameEditable` | `boolean` | `true` | Whether the document name is editable |
| `renderTitleBarRight` | `() => ReactNode` | — | Custom right-side actions in the title bar |
| `placeholder` | `ReactNode` | — | Placeholder when no document is loaded |
| `loadingIndicator` | `ReactNode` | — | Custom loading indicator |
| `className` | `string` | — | Additional CSS class name |
| `style` | `CSSProperties` | — | Additional inline styles |
| `onChange` | `(doc: Document) => void` | — | Called on document change |
| `onSave` | `(buffer: ArrayBuffer) => void` | — | Called on save |
| `onError` | `(error: Error) => void` | — | Called on error |
| `onSelectionChange` | `(state: SelectionState \| null) => void` | — | Called on selection change |
| `onFontsLoaded` | `() => void` | — | Called when fonts finish loading |
| `onPrint` | `() => void` | — | Called when print is triggered |
| `onCopy` | `() => void` | — | Called when content is copied |
| `onCut` | `() => void` | — | Called when content is cut |
| `onPaste` | `() => void` | — | Called when content is pasted |

Source: [`DocxEditorProps`](../packages/react/src/components/DocxEditor.tsx)

**Ribbon View modes:** The View tab’s `Print Layout` and `Web Layout` toggles are CSS-only presentation modes; they do not reflow document layout. `Show Bookmarks` maps to the existing “Show/Hide Marks” behavior.

## Ref Methods

```tsx
Expand Down
12 changes: 12 additions & 0 deletions docs/plugins/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ npm install && npm run dev # http://localhost:5174

Source: [`examples/plugins/docxtemplater/`](../../examples/plugins/docxtemplater/)

### Spellcheck (Word-like)

Client-side spellcheck with red squiggles and right-click suggestions.

```tsx
import { DocxEditor, PluginHost, spellcheckPlugin } from '@eigenpal/docx-js-editor';

<PluginHost plugins={[spellcheckPlugin]}>
<DocxEditor documentBuffer={file} />
</PluginHost>;
```

## Patterns

### Combining EditorPlugin + CorePlugin
Expand Down
8 changes: 8 additions & 0 deletions e2e/agentic/scenario-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ export class ScenarioRunner {
await this.editor.setFontSize(args.size as number);
break;

case 'setLineSpacing':
await this.editor.setLineSpacing(args.spacing as string);
break;

case 'setParagraphStyle':
await this.editor.setParagraphStyle(args.style as string);
break;

case 'setTextColor':
await this.editor.setTextColor(args.color as string);
break;
Expand Down
Loading