// ==== step1: generate diff view data, this part can be used in the worker/server environment for better performance ==== //
import { DiffFile } from "@git-diff-view/core";
const file = new DiffFile(
data?.oldFile?.fileName || "",
data?.oldFile?.content || "",
data?.newFile?.fileName || "",
data?.newFile?.content || "",
data?.hunks || [],
data?.oldFile?.fileLang || "",
data?.newFile?.fileLang || ""
);
// light / dark theme, base on current highlight engine
// default is light
file.initTheme(xxx);
// init
file.init();
// or you can use below method to init
file.initRaw();
file.initSyntax(); // if you do not want syntax highlight, you can skip this step
// build the `Split View` data;
file.buildSplitDiffLines();
// build the `Unified View` data;
file.buildUnifiedDiffLines();
// get All the diff data bundle, you can safely to send this data to the client side
const bundle = file.getBundle();
// ==== step2: render the @git-diff-view component ==== //
// merge bundle
const mergeFile = DiffFile.createInstance(data || {}, bundle);
// used for @git-diff-view/react and @git-diff-view/vue
<DiffView diffFile={mergeFile} />
<DiffView :diffFile="mergeFile" />
@git-diff-view/core
0.0.26 • Public • Published Versions
Current Tags
Version | Downloads (Last 7 Days) | Tag |
---|---|---|
0.0.1-beta.2 | 0 | beta |
0.0.26 | 4,353 | latest |
Version History
Version | Downloads (Last 7 Days) | Published |
---|---|---|
0.0.26 | 4,353 | |
0.0.25 | 296 | |
0.0.24 | 244 | |
0.0.23 | 0 | |
0.0.22 | 0 | |
0.0.21 | 2,184 | |
0.0.20 | 70 | |
0.0.19 | 6 | |
0.0.18 | 4 | |
0.0.17 | 3 | |
0.0.16 | 2,139 | |
0.0.15 | 0 | |
0.0.14 | 0 | |
0.0.13 | 0 | |
0.0.12 | 0 | |
0.0.11 | 0 | |
0.0.10 | 0 | |
0.0.9 | 0 | |
0.0.8 | 0 | |
0.0.7 | 0 | |
0.0.6 | 0 | |
0.0.5 | 0 | |
0.0.3 | 0 | |
0.0.2 | 0 | |
0.0.1 | 0 | |
0.0.1-beta.2 | 0 | |
0.0.1-beta.1 | 0 |
Package Sidebar
Install
npm i @git-diff-view/core
Repository
Weekly Downloads
9,299
Version
0.0.26
License
MIT
Unpacked Size
668 kB
Total Files
11