# Diff View Diff view for the code editor: themed changed and deleted lines, chunk navigation with position and line counts, per-chunk and bulk accept or reject actions, keyboard shortcuts, and a side-by-side mode with revert controls between the panes. ## Installation ```bash npx shadcn@latest add litingyes/blocove/code-editor-diff ``` This example also uses: `code-editor`, `code-editor-shiki`, `code-editor-languages`, `code-editor-line-numbers`. ```bash npx shadcn@latest add litingyes/blocove/code-editor litingyes/blocove/code-editor-shiki litingyes/blocove/code-editor-languages litingyes/blocove/code-editor-line-numbers ``` The demos are editable: type in the buffer and the diff updates against the fixed original. Accept moves the comparison forward, Reject restores the buffer from it, and Accept all or Reject all settle the remaining chunks. Once nothing is left, Reset comparison brings the demo back. Keyboard: Mod Alt Down and Mod Alt Up move between changes, Mod Enter accepts and Shift Mod Enter rejects the chunk under the cursor. With mode="split" the documents sit side by side instead, and the revert controls between the panes replace the accept and reject actions. ## API Reference ### CodeEditorDiff Declares the diff view. The editor content is compared against `original`, either inline in one view or side by side with `mode="split"`. Inline, changed lines are themed with the editor tokens and every changed chunk gets accept and reject controls. Split, both documents are aligned chunk by chunk with revert controls between the panes. Changing the props recreates the editor view, so keep the documents stable while chunks are applied. | Prop | Type | Default | | --- | --- | --- | | `original` | `string` | - | | `mode` | `'inline' | 'split'` | `'inline'` | | `revertControls` | `'a-to-b' | 'b-to-a' | false` | `'a-to-b'` | | `orientation` | `'a-b' | 'b-a'` | `'a-b'` | | `highlightChanges` | `boolean` | `true` | | `gutter` | `boolean` | `true` | | `mergeControls` | `boolean` | `true` | | `collapseUnchanged` | `false | { margin?: number, minSize?: number }` | `{ margin: 2, minSize: 4 }` | | `allowInlineDiffs` | `boolean` | `false` | | `syntaxHighlightDeletions` | `boolean` | `true` | | `shortcuts` | `boolean` | `true` | | `labels` | `{ accept?: string, reject?: string }` | `{ accept: 'Accept', reject: 'Reject' }` | ### CodeEditorDiffToolbar Toolbar controls for the diff view: previous and next change with their position and line counts, accept or reject for the chunk under the cursor, accept or reject for every remaining chunk, and a reset once the review settles. Render it inside the editor toolbar. In split mode the accept and reject actions are hidden automatically, since reverting happens between the panes. | Prop | Type | Default | | --- | --- | --- | | `hideCount` | `boolean` | `false` | | `hideActions` | `boolean` | `false` | ## Registry dependencies - `litingyes/blocove/code-editor` - `litingyes/blocove/code-editor-extension` - `separator` Namespace: `npx shadcn@latest add @blocove/code-editor-diff`