code/editor/DiffView
import { … } from 'zidane-ui/code/editor'ui/src/code/editor/DiffView.tsx
Components#
DiffScrollerComponent#
pierre's virtualizer as the scroll box of a list of diffs: every DiffView inside renders only its lines
near the viewport, so a large change set opens and scrolls in frames.
function DiffScroller(props: DiffScrollerProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | DiffScrollerProps | The scroll box's and content box's classes, and the diffs. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children? | ReactNode | The diffs. |
| className? | string | Classes on the scroll box. |
| contentClassName? | string | Classes on the content box inside it. |
DiffViewComponent#
One file's diff, rendered by pierre in the editor environment's theme, with optional line selection and annotation rows.
function DiffView<A>(props: DiffViewProps<A>): ElementType parameters
| Name | Description |
|---|---|
| A |
Parameters
| Name | Type | Description |
|---|---|---|
| props | DiffViewProps<A> | The patch or parsed diff, the style, and the selection and annotation hooks. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| annotations? | readonly DiffLineAnnotation<A>[] | Rows under lines (review comments). |
| className? | string | Classes on pierre's host element. |
| diffStyle? | DiffStyle | Unified or split. Default unified. |
| fileDiff? | FileDiffMetadata | An already-parsed file diff (wins over |
| hideHeader? | boolean | Hide the per-file header (when the caller renders its own). |
| onContextMenu? | (e: MouseEvent<HTMLDivElement>) => void | Right-click anywhere in the view (the host element, so shadow paths are intact). |
| onGutterAction? | (range: SelectedLineRange) => void | Gutter "+" on hover / at the selection end; called with the range it covers. |
| onSelectionEnd? | (range: SelectedLineRange | null) => void | A line range was selected (enables selection). |
| patch? | string | Unified patch for exactly one file. |
| renderAnnotation? | (annotation: DiffLineAnnotation<A>) => ReactNode | Renders one annotation row. |
| selectedLines? | SelectedLineRange | null | The selected line range (controlled). |
| wrap? | boolean | Wrap long lines instead of scrolling. |
Interfaces#
DiffScrollerPropsInterface#
Props for DiffScroller.
interface DiffScrollerPropsProperties
| Name | Type | Description |
|---|---|---|
| children? | ReactNode | The diffs. |
| className? | string | Classes on the scroll box. |
| contentClassName? | string | Classes on the content box inside it. |
DiffViewPropsInterface#
Props for DiffView.
interface DiffViewProps<A = unknown>Type parameters
| Name | Default | Description |
|---|---|---|
| A | unknown |
Properties
| Name | Type | Description |
|---|---|---|
| annotations? | readonly DiffLineAnnotation<A>[] | Rows under lines (review comments). |
| className? | string | Classes on pierre's host element. |
| diffStyle? | DiffStyle | Unified or split. Default unified. |
| fileDiff? | FileDiffMetadata | An already-parsed file diff (wins over |
| hideHeader? | boolean | Hide the per-file header (when the caller renders its own). |
| onContextMenu? | (e: MouseEvent<HTMLDivElement>) => void | Right-click anywhere in the view (the host element, so shadow paths are intact). |
| onGutterAction? | (range: SelectedLineRange) => void | Gutter "+" on hover / at the selection end; called with the range it covers. |
| onSelectionEnd? | (range: SelectedLineRange | null) => void | A line range was selected (enables selection). |
| patch? | string | Unified patch for exactly one file. |
| renderAnnotation? | (annotation: DiffLineAnnotation<A>) => ReactNode | Renders one annotation row. |
| selectedLines? | SelectedLineRange | null | The selected line range (controlled). |
| wrap? | boolean | Wrap long lines instead of scrolling. |
Types#
DiffStyleType#
One column with removals above additions, or two side by side.
type DiffStyle = 'unified' | 'split'Re-exports#
These names are documented on the entry point that owns them.
- DiffLineAnnotation
- FileDiffMetadata
- LineAnnotation
- SelectedLineRange