From d131860324d4e68c25188c93d1aac2f5286e4d70 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Wed, 3 Jul 2019 20:42:33 +0100 Subject: [PATCH] fix: Update typescript typings and default configuration options --- src/diff2html.js | 5 ++++- typescript/diff2html-tests.ts | 18 +++++++++--------- typescript/diff2html.d.ts | 11 +++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/diff2html.js b/src/diff2html.js index 8ef8339..715ff30 100644 --- a/src/diff2html.js +++ b/src/diff2html.js @@ -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 }; diff --git a/typescript/diff2html-tests.ts b/typescript/diff2html-tests.ts index 2fe6b3d..ad1f81f 100644 --- a/typescript/diff2html-tests.ts +++ b/typescript/diff2html-tests.ts @@ -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); diff --git a/typescript/diff2html.d.ts b/typescript/diff2html.d.ts index 23c338f..561a10c 100644 --- a/typescript/diff2html.d.ts +++ b/typescript/diff2html.d.ts @@ -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 {