Update README.md
This commit is contained in:
parent
973842064c
commit
bc6ca55e8d
1 changed files with 42 additions and 0 deletions
42
README.md
42
README.md
|
|
@ -300,6 +300,48 @@ index 0000001..0ddf2ba
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### StimulusJS with TypeScript
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Diff2HtmlUI,
|
||||||
|
Diff2HtmlUIConfig,
|
||||||
|
} from "diff2html/lib/ui/js/diff2html-ui-slim.js";
|
||||||
|
|
||||||
|
// Requires `yarn add highlight.js`
|
||||||
|
import "highlight.js/styles/github.css";
|
||||||
|
import "diff2html/bundles/css/diff2html.min.css";
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect(): void {
|
||||||
|
const diff2htmlUi = new Diff2HtmlUI(
|
||||||
|
this.diffElement,
|
||||||
|
this.unifiedDiff,
|
||||||
|
this.diffConfiguration
|
||||||
|
);
|
||||||
|
|
||||||
|
diff2htmlUi.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
get unifiedDiff(): string {
|
||||||
|
return this.data.get("unifiedDiff") || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
get diffElement(): HTMLElement {
|
||||||
|
return this.element as HTMLElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
get diffConfiguration(): Diff2HtmlUIConfig {
|
||||||
|
return {
|
||||||
|
drawFileList: true,
|
||||||
|
matching: "lines",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Diff2Html Usage
|
## Diff2Html Usage
|
||||||
|
|
||||||
### Diff2Html API
|
### Diff2Html API
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue