From 6975f098f714b352b2d0f1b90bff476a0274faf5 Mon Sep 17 00:00:00 2001 From: mhawamdeh Date: Mon, 18 Apr 2022 01:23:15 +0300 Subject: [PATCH] add example --- README.md | 1 + src/render-utils.ts | 2 ++ website/templates/pages/demo/demo.ts | 3 +++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 4d3a113..159eef2 100644 --- a/README.md +++ b/README.md @@ -376,6 +376,7 @@ The HTML output accepts a Javascript object with configuration. Possible options `false` - `matchingMaxComparisons`: perform at most this much comparisons for line matching a block of changes, default is `2500` +- `ignoreWhiteSpaces`: ignore line with only repeated white spacings (Only in Side by side View). - `maxLineSizeInBlockForComparison`: maximum number os characters of the bigger line in a block to apply comparison, default is `200` - `compiledTemplates`: object ([Hogan.js](https://github.com/twitter/hogan.js/) template values) with previously diff --git a/src/render-utils.ts b/src/render-utils.ts index 830628e..3b2813c 100644 --- a/src/render-utils.ts +++ b/src/render-utils.ts @@ -37,6 +37,7 @@ export interface RenderConfig { matchWordsThreshold?: number; maxLineLengthHighlight?: number; diffStyle?: DiffStyleType; + ignoreWhiteSpaces?: boolean; } export const defaultRenderConfig = { @@ -44,6 +45,7 @@ export const defaultRenderConfig = { matchWordsThreshold: 0.25, maxLineLengthHighlight: 10000, diffStyle: DiffStyleType.WORD, + ignoreWhiteSpaces: false, }; const separator = '/'; diff --git a/website/templates/pages/demo/demo.ts b/website/templates/pages/demo/demo.ts index 0cca1f5..1a2f59a 100644 --- a/website/templates/pages/demo/demo.ts +++ b/website/templates/pages/demo/demo.ts @@ -206,6 +206,7 @@ type Elements = { }; checkboxes: { drawFileList: HTMLInputElement; + ignoreWhiteSpaces: HTMLInputElement; }; }; @@ -265,6 +266,7 @@ document.addEventListener('DOMContentLoaded', async () => { }, checkboxes: { drawFileList: getHTMLInputElementById('diff-url-options-show-files'), + ignoreWhiteSpaces: getHTMLInputElementById('diff-url-options-ignore-w-spaces'), }, }; @@ -277,6 +279,7 @@ document.addEventListener('DOMContentLoaded', async () => { config.matchWordsThreshold && (elements.options.wordsThreshold.value = config.matchWordsThreshold.toString()); config.matchingMaxComparisons && (elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString()); + config.ignoreWhiteSpaces && (elements.checkboxes.ignoreWhiteSpaces.checked = config.ignoreWhiteSpaces); Object.entries(elements.options).forEach(([option, element]) => element.addEventListener('change', () => {