Skip to content

Added viewed checkbox to toggle file content by default on true #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and opt
| flag | alias | description | choices | default |
| ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- |
| -s | --style | Output style | `line`, `side` | `line` |
| --fct | --fileContentToggle | Adds a viewed checkbox to toggle file content | `true`, `false` | `true` |
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
Expand Down
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string {
searchValue: '//diff2html-fileListToggle',
replaceValue: `diff2htmlUi.fileListToggle(${config.showFilesOpen});`,
},
{
searchValue: '//diff2html-fileContentToggle',
replaceValue: config.fileContentToggle ? `diff2htmlUi.fileContentToggle();` : '',
},
{
searchValue: '//diff2html-synchronisedScroll',
replaceValue: config.synchronisedScroll ? `diff2htmlUi.synchronisedScroll();` : '',
Expand Down
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] {
const defaultWrapperTemplate = path.resolve(__dirname, '..', 'template.html');
const configuration: Configuration = {
showFilesOpen: argv.summary === 'open' || false,
fileContentToggle: argv.fileContentToggle,
synchronisedScroll: argv.synchronisedScroll,
highlightCode: argv.highlightCode,
formatType: argv.format,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type OutputType = 'preview' | 'stdout';
export type DiffyType = 'browser' | 'pbcopy' | 'print';

export type Configuration = {
fileContentToggle: boolean;
synchronisedScroll: boolean;
showFilesOpen: boolean;
highlightCode: boolean;
Expand Down
8 changes: 8 additions & 0 deletions src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {

export type Argv = {
style: StyleType;
fileContentToggle: boolean;
synchronisedScroll: boolean;
highlightCode: boolean;
diffStyle: DiffStyleType;
Expand All @@ -38,6 +39,7 @@ export type Argv = {

const defaults: Argv = {
style: 'line',
fileContentToggle: true,
synchronisedScroll: true,
highlightCode: true,
summary: 'closed',
Expand Down Expand Up @@ -93,6 +95,12 @@ export function setup(): Argv {
choices: choices.style,
default: defaults.style,
})
.option('fileContentToggle', {
alias: 'fct',
describe: 'Show viewed checkbox to toggle file content',
type: 'boolean',
default: defaults.fileContentToggle,
})
.option('synchronisedScroll', {
alias: 'sc',
describe: 'Synchronised horizontal scroll',
Expand Down
1 change: 1 addition & 0 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const targetElement = document.getElementById('diff');
const diff2htmlUi = new Diff2HtmlUI(targetElement);
//diff2html-fileListToggle
//diff2html-fileContentToggle
//diff2html-synchronisedScroll
//diff2html-highlightCode
});
Expand Down