Diff utility
diffUtility
Compares two Tiptap documents and returns a list of changes between them.
Parameters (DiffUtilityOptions
)
docA
(Node
): Original documentdocB
(Node
): Modified documentsimplifyChanges?
(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 changedrangeB
(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 })