You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Cli DiffView Component like GitHub, Easy to use and feature complete.
Usage
There are two ways to use this component:
Use the DiffView component directly.
import{DiffView,DiffModeEnum}from"@git-diff-view/cli";<DiffView<string>// use datadata={{oldFile?: {fileName?: string|null;fileLang?: string|null;content?: string|null};newFile?: {fileName?: string|null;fileLang?: string|null;content?: string|null};hunks: string[];}}width={number}extendData={{oldFile: {10: {data: 'foo'}},newFile: {20: {data: 'bar'}}}}renderExtendLine={({ data })=>ReactNode}diffViewHighlight={boolean}diffViewTabSpace={boolean}diffViewTabWidth={"small"|"medium"|"large"}diffViewMode={DiffModeEnum.Split|DiffModeEnum.Unified}diffViewTheme={'light'|'dark'}/>
Use the DiffView component with @git-diff-view/core or @git-diff-view/file
// with @git-diff-view/fileimport{DiffFile,generateDiffFile}from"@git-diff-view/file";constfile=generateDiffFile(data?.oldFile?.fileName||"",data?.oldFile?.content||"",data?.newFile?.fileName||"",data?.newFile?.content||"",data?.oldFile?.fileLang||"",data?.newFile?.fileLang||"");file.init();file.buildSplitDiffLines();file.buildUnifiedDiffLines();// with @git-diff-view/coreimport{DiffFile}from"@git-diff-view/core";constfile=newDiffFile(data?.oldFile?.fileName||"",data?.oldFile?.content||"",data?.newFile?.fileName||"",data?.newFile?.content||"",data?.hunks||[],data?.oldFile?.fileLang||"",data?.newFile?.fileLang||"");file.init();file.buildSplitDiffLines();file.buildUnifiedDiffLines();// use current data to render<DiffViewdiffFile={file}{...props}/>;// or use the bundle data to render, eg: postMessage/httpRequestconstbundle=file.getBundle();constdiffFile=DiffFile.createInstance(data||{},bundle);<DiffViewdiffFile={diffFile}{...props}/>;