@stesura/contract-check-react
The contract check UI for the @stesura/contract-check plugin. Setup is in
the Contract check guide.
UI extension
createContractCheckUIExtension
The contract check UI: Review-tab button and on/off switch, status-bar count, findings
panel, defined-term hover card. The switch is a user preference kept in localStorage. Pass it via uiExtensions next to contractCheckPlugin() in the mount’s
plugins. Create it at module level: the editor expects a stable uiExtensions array.
| Name | Type | Default |
|---|---|---|
__0 | ContractCheckUIExtensionOptions |
ContractCheckUIExtensionOptions
| Name | Type | Default |
|---|---|---|
settingsEndpoint | stringAnswers a GET with the organisation’s |
contractCheckUIExtension
The UI with the built-in settings.
Components
ContractCheckPanel
Right-hand panel listing the document’s contract findings in document order: errors and warnings, then hints, then the ignored ones (collapsed). Each can be ignored or flagged; that state lives on the document, shared with collaborators. The header fixes what can be fixed (typed references made live) and saves the report as Markdown or JSON. While track changes is on, fixing needs an explicit override.
| Name | Type | Default |
|---|---|---|
props | {} |
ContractCheckStatusBar
Status-bar count of open errors and warnings; opens the panel. Off, it says so and turns checking on.
| Name | Type | Default |
|---|---|---|
props | {} |
ContractCheckToolbarGroup
Review-tab group: the button toggles the contract check panel, its menu turns checking on or off.
| Name | Type | Default |
|---|---|---|
props | {} |
ContractCheckSettingsLoader
Fetches the organisation’s CheckSettings from endpoint and hands them to the
contract-check plugin, which rebuilds. Renders nothing; mounted through
documentOverlaySlot by createContractCheckUIExtension({ settingsEndpoint }).
| Name | Type | Default |
|---|---|---|
__0 | { endpoint: string; } |
DefinedTermCard
A defined term’s definition, its version in a bilingual document and how often it
is used, shown when the pointer is over the term or the caret is in it. Mounted
through documentOverlaySlot.
Keyboard users reach it by moving the caret into a term: the card appears without
taking focus, and a polite live region reads it. “Go to definition” from the
keyboard is goToDefinitionAtSelection, for the host to bind. The card is
viewport-fixed and a reading of one doc version, so it closes on scroll, Escape,
typing and when the pointer leaves both the term and the card.
ContractCheckVisibleRange
Tells the contract-check plugin what is on screen, so underlines are drawn only
there: decorating every use in a 200-page agreement costs a frame on each edit.
Renders nothing; mounted through documentOverlaySlot.
Hooks
CONTRACT_CHECK_PANEL_ACTION
Right-panel action id of the contract check panel.
useContractCheck
The root editor’s findings, from the debounced state; installed is false without the plugin.
useContractCheckActions
Actions against the root editor, stable across renders.
{ fix: (selection: string[] | "all", force: boolean) => boolean | undefined; setStatus: (id: string, status: CheckReviewStatus) => boolean | undefined; focus: (id: string | null, range?: number | ... 1 more ... | undefined) => boolean | undefined; goTo: (id: string, index?: number | undefined) => boolean | undefined...