content/docs/examples/version-history.mdx
This example stores immutable Plate value snapshots in local React state. It compares the selected revision with the current value through @platejs/diff.
| Piece | Owner | Role |
|---|---|---|
createVersionSnapshot | registry example | Clones each Value with cloneDeep before saving or diffing. |
revisions | registry example | Stores the saved Plate values and feeds the revision picker. |
computeDiff | @platejs/diff | Compares the selected revision and live value, then returns diff-marked nodes. |
DiffPlugin | registry example | Renders diff leaves and wraps diff elements with insert, delete, or update styling. |
InlinePlugin and InlineVoidPlugin | registry example | Keep inline and inline-void nodes in the demo value so the diff path covers mixed content. |
withGetFragmentExcludeDiff | @platejs/diff | Removes diff and diffOperation metadata from copied fragments. |
initialValue and keeps the live value in local state.Save revision clones the live value and appends it to revisions.computeDiff receives the selected revision, current value, editor.api.isInline, and lineBreakChar: '¶'.DiffPlugin.Potion uses the same document-history idea in a full app surface with stored versions, restore actions, and visual comparison.
<ComponentPreview name="potion-iframe-demo" />render.node and render.aboveNodes.