fix: Update typescript typings and default configuration options

This commit is contained in:
Rodrigo Fernandes 2019-07-03 20:42:33 +01:00
parent defd8f399b
commit d131860324
No known key found for this signature in database
GPG key ID: C5DD1B4104382F6B
3 changed files with 20 additions and 14 deletions

View file

@ -14,13 +14,16 @@
}
var defaultConfig = {
wordByWord: true,
inputFormat: 'diff',
outputFormat: 'line-by-line',
showFiles: false,
matching: 'none',
matchWordsThreshold: 0.25,
matchingMaxComparisons: 2500,
maxLineSizeInBlockForComparison: 200,
maxLineLengthHighlight: 10000,
templates: {},
rawTemplates: {},
renderNothingWhenEmpty: false
};

View file

@ -5,18 +5,18 @@ import Diff2Html = require('diff2html');
let d2h = Diff2Html.Diff2Html;
class Diff2HtmlOptionsImpl implements Diff2Html.Options {
constructor(public inputFormat: string) {
}
constructor (public inputFormat: 'diff' | 'json') {
}
}
let strInput =
'diff --git a/sample b/sample\n' +
'index 0000001..0ddf2ba\n' +
'--- a/sample\n' +
'+++ b/sample\n' +
'@@ -1 +1 @@\n' +
'-test\n' +
'+test1r\n';
'diff --git a/sample b/sample\n' +
'index 0000001..0ddf2ba\n' +
'--- a/sample\n' +
'+++ b/sample\n' +
'@@ -1 +1 @@\n' +
'-test\n' +
'+test1r\n';
let strConfiguration = new Diff2HtmlOptionsImpl('diff');
let diffInput = d2h.getJsonFromDiff(strInput, strConfiguration);

View file

@ -6,14 +6,17 @@
declare namespace Diff2Html {
export interface Options {
inputFormat?: string;
outputFormat?: string;
inputFormat?: 'diff' | 'json';
outputFormat?: 'line-by-line' | 'side-by-side';
showFiles?: boolean;
matching?: string;
synchronisedScroll?: boolean;
matching?: 'lines' | 'words' | 'none';
matchWordsThreshold?: number;
matchingMaxComparisons?: number;
maxLineSizeInBlockForComparison?: number;
maxLineLengthHighlight?: number;
templates?: object;
rawTemplates?: object;
renderNothingWhenEmpty?: boolean;
}
export interface Line {