Review options

All AI Toolkit methods that edit the document have a reviewOptions property. When configured, it allows you to display a review UI after the document is edited.

const result = toolkit.executeTool({
  toolName: 'tiptapEdit',
  input,
  // Display a UI that allows the user to review
  // the changes after they are applied.
  reviewOptions: { mode: 'review' },
})

After editing the document, a list of suggestions will be displayed.

The reviewOptions property takes a ReviewOptions configuration object.

ReviewOptions

  • mode? ('disabled' | 'review' | 'preview' | 'trackedChanges'): Whether to review the changes before or after applying them. Default: 'disabled'
    • 'disabled': No review UI is displayed.
    • 'review': The changes are applied first, then a review UI is displayed allowing the user to undo them.
    • 'preview': A preview UI is displayed before applying the changes, allowing the user to accept or reject them.
    • 'trackedChanges': AI-generated changes are encoded as tracked changes using the Tracked Changes extension, allowing users to accept or reject individual changes.
  • displayOptions? (DisplayOptions): Customize how suggestions are displayed in the editor UI. Sets the displayOptions property of the Suggestion type. See available options.
  • metadata? (Record<string, any>): Extra metadata for the suggestions that can be used to store additional information about them (e.g. their source or their category). It is not used internally by the extension but it may help developers customize how the suggestions are displayed in the UI.
  • trackedChangesOptions? ({ userId: string, userMetadata?: Record<string, unknown> | null }): Configuration for the trackedChanges mode. userId identifies the author of the tracked changes. userMetadata stores additional information about the author.
  • commentsOptions? ({ threadData?: Record<string, unknown>, commentData?: Record<string, unknown> }): When provided alongside the trackedChanges mode, operation metadata (the meta field in edit operations) becomes a comment thread linked to each tracked change. Requires the Comments extension.
  • useDiffUtility? (boolean): Whether to use the Diff Utility to compare the documents before and after the change, displaying the deleted and added content as a rich diff. If false, the deleted content and added content are displayed in a whole block, as a single change. Default: true
  • diffUtilityOptions? (ExternalDiffUtilityOptions): Options for comparing the documents with the diff utility. See available options.