Diff utility

diffUtility

Compares two Tiptap documents and returns a list of changes between them.

Parameters (DiffUtilityOptions)

  • docA (Node): Original document
  • docB (Node): Modified document
  • simplifyChanges? (boolean): Whether to simplify the changes so that if there are multiple changes in the same word, they are merged into one change. Default: true

Returns (Change[])

Returns a list of changes. Each Change item contains:

  • rangeA (Range): The range in the original document that has changed
  • rangeB (Range): The range in the modified document that has changed

Example

// Compute changes between two documents
import { diffUtility } from '@tiptap-pro/ai-toolkit'
const changes = diffUtility({ docA, docB })