Skip to content

Commit 52939ff

Browse files
committed
Add libary model
1 parent 1773e5e commit 52939ff

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

projects/ngx-diff2html/src/lib/ngx-diff2html.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit, Input, OnChanges, SimpleChanges, SimpleChange, ViewEncapsulation } from '@angular/core';
22
import { NgxDiff2htmlService } from './ngx-diff2html.service';
3+
import { DiffFormat, DiffStyle } from './ngx-diff2html.model';
34

45
@Component({
56
selector: 'ngx-diff2html',
@@ -14,8 +15,8 @@ export class NgxDiff2htmlComponent implements OnInit, OnChanges {
1415
@Input() private left: string;
1516
@Input() private right: string;
1617
@Input() private filename: string = ' '; // cannot be null or empty
17-
@Input() private format: 'side-by-side' | 'line-by-line' = 'line-by-line';
18-
@Input() private style: 'word' | 'char' = 'word';
18+
@Input() private format: DiffFormat = 'line-by-line';
19+
@Input() private style: DiffStyle = 'word';
1920
private diff: string = null;
2021
diffHTML: string = null;
2122

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export type DiffFormat = 'side-by-side' | 'line-by-line';
3+
4+
export type DiffStyle = 'word' | 'char';

projects/ngx-diff2html/src/lib/ngx-diff2html.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { diff_match_patch } from 'diff-match-patch';
33
import { Diff2Html } from 'diff2html';
4+
import { DiffFormat, DiffStyle } from './ngx-diff2html.model';
45

56
@Injectable({
67
providedIn: 'root'
@@ -43,7 +44,7 @@ export class NgxDiff2htmlService {
4344
return diff;
4445
}
4546

46-
diffToHTML(diff: string, format: 'side-by-side' | 'line-by-line', style: 'word' | 'char') {
47+
diffToHTML(diff: string, format: DiffFormat, style: DiffStyle) {
4748
return Diff2Html.getPrettyHtml(diff, {
4849
inputFormat: 'diff',
4950
matching: 'lines',

0 commit comments

Comments
 (0)