Skip to Content
API Referenceproofread-react

@stesura/proofread-react

The proofread UI: toolbar group, panel, context and floating menus, and the status-bar indicator, for the @stesura/proofread plugin. Setup is in the Proofread guide.

UI extension

Pass one of these in uiExtensions for all of the UI below. Build it once, at module level: the editor expects a stable uiExtensions array.

proofreadUIExtension

createProofreadUIExtension with no options.

NameTypeDefault
leftPanelsLeftPanelElement[]
rightPanelsRightPanelElement[]
bottomPanelsBottomPanelElement[]
contextMenuExtensionsContextMenuExtension[]
textMenuExtensionsTextMenuExtension<string>[]
toolbarDefaultTabsPartial<Record<ToolbarDefaultTabs, false>>
toolbarDefaultExtensionsToolbarDefaultExtension[]
toolbarGroupExtensionsToolbarGroupExtension[]
toolbarTabsToolbarExtensionTab[]

Whole tabs after the built-in ones, usually contextual.

floatingMenuExtensionsFloatingMenuExtension[]
slashMenuExtensionsMenuElement[]
StatusBarElementsStatusBarElement[]
nodeViewsNodeViews
nodeViewWrappersRecord<string, ComponentType<NodeViewWrapperComponentProps>>

DOM-less wrappers composed around whichever view wins for a node type. A wrapper must render {children} (the wrapped view) and add no DOM; it contributes via context, typically NodeViewSlotsProvider. Unlike a nodeViews entry, it survives the consumer’s nodeViews overrides.

nodeViewFallback(type: NodeType) => NodeView | undefined

The view for a block type core doesn’t define and nothing registered a view for by name (a host schema’s own node), or undefined to pass. The last extension answering wins; otherwise editor-react renders the type’s toDOM with its derived values and slots (DerivedSpecView).

nodeViewWrapperFallback(type: NodeType) => ComponentType<NodeViewWrapperComponentProps> | undefined

A nodeViewWrappers entry for a block type core doesn’t define, when this extension names no wrapper for it. Composed around whichever view wins, the host’s own included, so a host node gets the extension’s behaviour (pagination’s page-break lead) without being listed.

pdfPreviewPdfPreviewCapability

Renders PDF file nodes as page previews (@stesura/pdf-viewer-react). Declared on the extension rather than set from an effect so the file view, pagination and export know it before the first layout; an effect arrives a commit late and forced a second pagination pass.

calloutFrameComponentType<CalloutFrameProps>

Replaces the callout title bar’s content (icon + title). Rendered inside the non-editable bar above the body; pagination measures it as chrome, so give it padding, never margins.

documentOverlaySlotReact.ReactNode
ResizableLayoutBottomSlotReact.ReactNode
TopLeftSlotReact.ReactNode
CommentsSlotReact.ReactNode

createProofreadUIExtension

All proofread UI (context menu, floating menu, Review-tab group, status bar, panel), to pass via uiExtensions. Create it once, at module level: the editor expects a stable uiExtensions array. The components are also exported individually.

Parameters:
NameTypeDefault
__0ProofreadUIExtensionOptions
Returns:
StesuraUIExtension

ProofreadUIExtensionOptions

Options for createProofreadUIExtension.

NameTypeDefault
statusBarMenuFooterReactNode

Rendered at the bottom of the status-bar proofread menu, below a separator — e.g. attribution for the checking service. It sits inside the menu, so anything interactive should be a DropdownMenuItem.

Components

The pieces the extension mounts, for custom toolbars and layouts.

ProofreadPanel

Right-hand panel listing every proofread error, including headers, footers and notes (badged with their origin), filterable by spelling/grammar.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

ProofingGroup

Review-tab toolbar group: language picker plus the proofread on/off toggle.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

ProofreadToggle

Toolbar on/off toggle for the global proofread preference. The status-bar counterpart is ProofreadToggleStatusBar.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

LanguageSelector

Sets the selected blocks’ proofingLanguage override. “Follow document” clears it, so the blocks inherit from their style, else the document (whose language is set from the status bar). Shows “mixed” when the selection spans several languages.

Parameters:
NameTypeDefault
props{ className?: string; portal?: boolean; languages?: readonly ProofingLanguageOption[]; }
Returns:
ReactNode

ProofreadButton

Large toolbar button toggling the proofread panel, for custom toolbars. Not used by ProofingGroup, which opens the panel from its expand button.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

ProofreadContextMenu

Context-menu submenu for the error under the selection: suggestions, ignore once, ignore all and, for spelling errors with a dictionary configured, add to dictionary. The only surface offering the last two.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

ProofreadFloatingMenuController

Floating menu with suggestions and ignore-once, opened when the caret arrives on a flagged range. Hidden while the context menu is open, and off when the user turned the proofReadFloatingMenu preference off.

Parameters:
NameTypeDefault
props{}
Returns:
ReactNode

ProofreadToggleStatusBar

Status-bar entry showing proofreading as on, off or unavailable (api failing), with a menu to toggle, retry or open the panel. The toolbar counterpart is ProofreadToggle.

Parameters:
NameTypeDefault
propsProofreadToggleStatusBarProps
Returns:
ReactNode

ProofreadToggleStatusBarProps

Props of ProofreadToggleStatusBar.

NameTypeDefault
Last updated on