Skip to content

Commit d7ea499

Browse files
committed
Added viewed checkbox to toggle file content by default on true
1 parent 9f9667d commit d7ea499

File tree

6 files changed

+16
-0
lines changed

6 files changed

+16
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and opt
7373
| flag | alias | description | choices | default |
7474
| ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- |
7575
| -s | --style | Output style | `line`, `side` | `line` |
76+
| --fct | --fileContentToggle | Adds a viewed checkbox to toggle file content | `true`, `false` | `true` |
7677
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
7778
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
7879
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |

Diff for: src/cli.ts

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
6464
searchValue: '//diff2html-fileListToggle',
6565
replaceValue: `diff2htmlUi.fileListToggle(${config.showFilesOpen});`,
6666
},
67+
{
68+
searchValue: '//diff2html-fileContentToggle',
69+
replaceValue: config.fileContentToggle ? `diff2htmlUi.fileContentToggle();` : '',
70+
},
6771
{
6872
searchValue: '//diff2html-synchronisedScroll',
6973
replaceValue: config.synchronisedScroll ? `diff2htmlUi.synchronisedScroll();` : '',

Diff for: src/configuration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] {
3838
const defaultWrapperTemplate = path.resolve(__dirname, '..', 'template.html');
3939
const configuration: Configuration = {
4040
showFilesOpen: argv.summary === 'open' || false,
41+
fileContentToggle: argv.fileContentToggle,
4142
synchronisedScroll: argv.synchronisedScroll,
4243
highlightCode: argv.highlightCode,
4344
formatType: argv.format,

Diff for: src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type OutputType = 'preview' | 'stdout';
88
export type DiffyType = 'browser' | 'pbcopy' | 'print';
99

1010
export type Configuration = {
11+
fileContentToggle: boolean;
1112
synchronisedScroll: boolean;
1213
showFilesOpen: boolean;
1314
highlightCode: boolean;

Diff for: src/yargs.ts

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313

1414
export type Argv = {
1515
style: StyleType;
16+
fileContentToggle: boolean;
1617
synchronisedScroll: boolean;
1718
highlightCode: boolean;
1819
diffStyle: DiffStyleType;
@@ -38,6 +39,7 @@ export type Argv = {
3839

3940
const defaults: Argv = {
4041
style: 'line',
42+
fileContentToggle: true,
4143
synchronisedScroll: true,
4244
highlightCode: true,
4345
summary: 'closed',
@@ -93,6 +95,12 @@ export function setup(): Argv {
9395
choices: choices.style,
9496
default: defaults.style,
9597
})
98+
.option('fileContentToggle', {
99+
alias: 'fct',
100+
describe: 'Show viewed checkbox to toggle file content',
101+
type: 'boolean',
102+
default: defaults.fileContentToggle,
103+
})
96104
.option('synchronisedScroll', {
97105
alias: 'sc',
98106
describe: 'Synchronised horizontal scroll',

Diff for: template.html

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
const targetElement = document.getElementById('diff');
2121
const diff2htmlUi = new Diff2HtmlUI(targetElement);
2222
//diff2html-fileListToggle
23+
//diff2html-fileContentToggle
2324
//diff2html-synchronisedScroll
2425
//diff2html-highlightCode
2526
});

0 commit comments

Comments
 (0)