跳到正文

DiffView

虚拟化的分栏或统一文件差异视图,行同步且面板可独立横向滚动。

默认不包含任何语言语法。Rust 可注册静态链接的语法;Go 和 TypeScript 可通过 LoadLanguagePack / loadLanguagePack 加载单个跨平台包,其中包含所选 Tree-sitter Wasm 语法与查询。

组件默认不带视觉样式:文本和行号继承颜色,不添加背景、边框、圆角、内边距或语法/差异配色。外观由应用显式提供样式与颜色。

#导入

bun add @quickgui/extension-editor
import { DiffView } from "@quickgui/extension-editor";
// quickgui.config.ts
extensions: ["@quickgui/extension-editor"]

#用法

<DiffView
  oldPath="before.ts"
  newPath="after.ts"
  oldText={"export const answer = 41;\n"}
  newText={"export const answer = 42;\n"}
  options={{
    layout: "split",
    indicators: "bars",
    lineNumbers: true,
    language: "typescript",
  }}
  style={{ width: "100%", height: 420 }}
/>

#语法高亮

DiffView 使用与 Editor 相同的内置 Tree-sitter 语法。文档、语言或语法调色板变化时,Rust 核心会分别解析每个可见文件的新旧行序列,并把捕获片段分配给逻辑行。样式文本仅在行挂载时创建并缓存,再按互不重叠的字节边界合并行内新增/删除强调。滚动不会调用解析器。

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

DiffView

查看源码
DiffView(props: DiffViewProps): NativeNode
accessibilityLabelstring—

Declares accessibilityLabel (optional). Reactive JSX expressions update this property in place.

string
查看源码
styleStyleProp—

Layout, typography, paint, and interaction-state styles. Arrays merge left to right.

StyleProp
查看源码
disabledboolean—

Declares disabled (optional). Reactive JSX expressions update this property in place.

boolean
查看源码
invalidboolean—

Expose web-style invalid state; the `style.invalid` variant paints while it is set.

boolean
查看源码
selectedboolean—

Expose web-style selected state; the `style.selected` variant paints while it is set.

boolean
查看源码
groupboolean | string—

Makes this element the group its descendants' `groupHover` and `groupActive` styles follow, like Tailwind's `group`: `true` opens an unnamed group, and a string names it so a descendant can follow it past a nearer group with `groupHover: { group: "name" }`.

boolean | string
查看源码
rolestring—

Declares role (optional). Reactive JSX expressions update this property in place.

string
查看源码
tabIndexnumber—

Declares tabIndex (optional). Reactive JSX expressions update this property in place.

number
查看源码
focusOnPointerboolean—

Keep keyboard focus where it is when this element is activated with a pointer.

boolean
查看源码
overlayboolean—

Paint this subtree in the viewport overlay plane above embedded native views.

boolean
查看源码
focusTrapboolean—

Contain keyboard focus within this subtree while it is the topmost trap.

boolean
查看源码
restorePreviousFocusboolean—

Restore the previously focused mounted control when this surface unmounts.

boolean
查看源码
autoFocusboolean—

Prefer this control when its containing focus trap takes focus.

boolean
查看源码
aria-modalboolean—

Expose modal semantics to assistive technology.

boolean
查看源码
ariaModalboolean—

Declares ariaModal (optional). Reactive JSX expressions update this property in place.

boolean
查看源码
dismissOnEscapeboolean—

Declares dismissOnEscape (optional). Reactive JSX expressions update this property in place.

boolean
查看源码
dismissOnPointerOutsideboolean—

Declares dismissOnPointerOutside (optional). Reactive JSX expressions update this property in place.

boolean
查看源码
tooltipstring—

Delayed, pointer-passive native tooltip text shown while this element is hovered.

string
查看源码
tooltipPlacementPopoverPlacement—

Declares tooltipPlacement (optional). Reactive JSX expressions update this property in place.

PopoverPlacement
查看源码
tooltipDelaynumber—

Hover delay in milliseconds, clamped by the Rust core to at most ten seconds.

number
查看源码
tooltipGapnumber—

Declares tooltipGap (optional). Reactive JSX expressions update this property in place.

number
查看源码
tooltipViewportMarginnumber—

Declares tooltipViewportMargin (optional). Reactive JSX expressions update this property in place.

number
查看源码
hitSlopnumber | string—

Declares hitSlop (optional). Reactive JSX expressions update this property in place.

number | string
查看源码
hitSlopTopnumber | string—

Declares hitSlopTop (optional). Reactive JSX expressions update this property in place.

number | string
查看源码
hitSlopRightnumber | string—

Declares hitSlopRight (optional). Reactive JSX expressions update this property in place.

number | string
查看源码
hitSlopBottomnumber | string—

Declares hitSlopBottom (optional). Reactive JSX expressions update this property in place.

number | string
查看源码
hitSlopLeftnumber | string—

Declares hitSlopLeft (optional). Reactive JSX expressions update this property in place.

number | string
查看源码
aria-labelstring—

Declares aria-label (optional). Reactive JSX expressions update this property in place.

string
查看源码
ariaLabelstring—

Declares ariaLabel (optional). Reactive JSX expressions update this property in place.

string
查看源码
ref((node: NativeNode) => void) | NativeNode—

Declares ref (optional). Reactive JSX expressions update this property in place.

((node: NativeNode) => void) | NativeNode
查看源码
onClickEventHandler—

Declares onClick (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onMouseEnterEventHandler—

Declares onMouseEnter (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onMouseLeaveEventHandler—

Declares onMouseLeave (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onPointerEnterEventHandler—

Declares onPointerEnter (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onPointerLeaveEventHandler—

Declares onPointerLeave (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onPointerEventHandler—

Captured pointer stream from press through release/cancel, including outside the element.

EventHandler
查看源码
onInputEventHandler—

Declares onInput (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onChangeEventHandler—

Declares onChange (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onSubmitEventHandler—

Declares onSubmit (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onDismissEventHandler—

Declares onDismiss (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onKeyDownEventHandler—

Focused key press. Declare a `tabIndex` to make an ordinary container focusable.

EventHandler
查看源码
onKeyUpEventHandler—

Declares onKeyUp (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onMouseDownEventHandler—

Declares onMouseDown (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onMouseUpEventHandler—

Declares onMouseUp (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onMouseMoveEventHandler—

Declares onMouseMove (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onDoubleClickEventHandler—

Second press of one exact native multi-click sequence.

EventHandler
查看源码
onWheelEventHandler—

Declares onWheel (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onContextMenuEventHandler—

Secondary-button press. Use `ContextMenu` for a declared native menu.

EventHandler
查看源码
onPinchEventHandler—

Declares onPinch (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onRotateEventHandler—

Declares onRotate (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onSmartMagnifyEventHandler—

Declares onSmartMagnify (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onPressureEventHandler—

Declares onPressure (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onFocusEventHandler—

Declares onFocus (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onBlurEventHandler—

Declares onBlur (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
keymapKeymap—

Bounded accelerator table resolved by the core while this element is focused.

Keymap
查看源码
onActionEventHandler—

Typed binding id dispatched by `keymap`.

EventHandler
查看源码
draggableboolean | DragSource—

Declared drag payload promoted when this element starts a drag.

boolean | DragSource
查看源码
onDragStartEventHandler—

Declares onDragStart (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onDragEndEventHandler—

Declares onDragEnd (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
dropKindsDropKind | readonly DropKind[]—

Payload kinds this element accepts, declared ahead of the native drag.

DropKind | readonly DropKind[]
查看源码
onDropEventHandler—

Declares onDrop (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
onFilesDroppedEventHandler—

Declares onFilesDropped (optional). Reactive JSX expressions update this property in place.

EventHandler
查看源码
patchstring—

Captured Git or ordinary unified patch.

string
查看源码
oldTextstring—

Declares oldText. Reactive JSX expressions update this property in place.

string
查看源码
newTextstring—

Declares newText. Reactive JSX expressions update this property in place.

string
查看源码
oldPathstring—

Declares oldPath (optional). Reactive JSX expressions update this property in place.

string
查看源码
newPathstring—

Declares newPath (optional). Reactive JSX expressions update this property in place.

string
查看源码
optionsDiffViewOptions—

Declares options (optional). Reactive JSX expressions update this property in place.

DiffViewOptions
查看源码
presentationDiffPresentation—

Declares presentation (optional). Reactive JSX expressions update this property in place.

DiffPresentation
查看源码
themeDiffTheme—

Declares theme (optional). Reactive JSX expressions update this property in place.

DiffTheme
查看源码
syntaxThemeSyntaxTheme—

Declares syntaxTheme (optional). Reactive JSX expressions update this property in place.

SyntaxTheme
查看源码