add example

This commit is contained in:
mhawamdeh 2022-04-18 01:23:15 +03:00
parent e2b70660df
commit 6975f098f7
3 changed files with 6 additions and 0 deletions

View file

@ -376,6 +376,7 @@ The HTML output accepts a Javascript object with configuration. Possible options
`false` `false`
- `matchingMaxComparisons`: perform at most this much comparisons for line matching a block of changes, default is - `matchingMaxComparisons`: perform at most this much comparisons for line matching a block of changes, default is
`2500` `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, - `maxLineSizeInBlockForComparison`: maximum number os characters of the bigger line in a block to apply comparison,
default is `200` default is `200`
- `compiledTemplates`: object ([Hogan.js](https://github.com/twitter/hogan.js/) template values) with previously - `compiledTemplates`: object ([Hogan.js](https://github.com/twitter/hogan.js/) template values) with previously

View file

@ -37,6 +37,7 @@ export interface RenderConfig {
matchWordsThreshold?: number; matchWordsThreshold?: number;
maxLineLengthHighlight?: number; maxLineLengthHighlight?: number;
diffStyle?: DiffStyleType; diffStyle?: DiffStyleType;
ignoreWhiteSpaces?: boolean;
} }
export const defaultRenderConfig = { export const defaultRenderConfig = {
@ -44,6 +45,7 @@ export const defaultRenderConfig = {
matchWordsThreshold: 0.25, matchWordsThreshold: 0.25,
maxLineLengthHighlight: 10000, maxLineLengthHighlight: 10000,
diffStyle: DiffStyleType.WORD, diffStyle: DiffStyleType.WORD,
ignoreWhiteSpaces: false,
}; };
const separator = '/'; const separator = '/';

View file

@ -206,6 +206,7 @@ type Elements = {
}; };
checkboxes: { checkboxes: {
drawFileList: HTMLInputElement; drawFileList: HTMLInputElement;
ignoreWhiteSpaces: HTMLInputElement;
}; };
}; };
@ -265,6 +266,7 @@ document.addEventListener('DOMContentLoaded', async () => {
}, },
checkboxes: { checkboxes: {
drawFileList: getHTMLInputElementById('diff-url-options-show-files'), 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.matchWordsThreshold && (elements.options.wordsThreshold.value = config.matchWordsThreshold.toString());
config.matchingMaxComparisons && config.matchingMaxComparisons &&
(elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString()); (elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString());
config.ignoreWhiteSpaces && (elements.checkboxes.ignoreWhiteSpaces.checked = config.ignoreWhiteSpaces);
Object.entries(elements.options).forEach(([option, element]) => Object.entries(elements.options).forEach(([option, element]) =>
element.addEventListener('change', () => { element.addEventListener('change', () => {