Skip to content

Commit 4c33c44

Browse files
committed
Update README
1 parent 283b423 commit 4c33c44

File tree

3 files changed

+14
-85
lines changed

3 files changed

+14
-85
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ npm install --save ngx-diff2html
4646
+ @import "~diff2html/dist/diff2html.min.css";
4747
```
4848

49-
**3**. Add the following line to `polyfills.ts`:
49+
**3**. You may also need to add the following lines to `polyfills.ts`:
5050

5151
```diff
5252
// Add global to window, assigning the value of window itself.
5353
+ (window as any).global = window;
54+
+ (window as any).process = { env: { DEBUG: undefined } };
5455
```
5556

5657
**4**. Start using the component:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve --project=demo",
7-
"build": "ng build ngx-diff2html",
7+
"build": "ng build ngx-diff2html && npm run copy:readme",
8+
"copy:readme": "cp README.md dist/ngx-diff2html/",
89
"build:demo": "ng build demo",
910
"build:demo:github": "ng build demo --prod --base-href \"/ngx-diff2html/\"",
1011
"deploy:demo:github": "ngh --dir=dist/demo",

projects/ngx-diff2html/README.md

Lines changed: 10 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,11 @@
11
# NgxDiff2html
22

3-
[![NPM version](https://img.shields.io/npm/v/ngx-diff2html)](https://www.npmjs.com/package/ngx-diff2html)
4-
[![Downloads](https://img.shields.io/npm/dt/ngx-diff2html)](https://npmjs.org/package/ngx-diff2html)
5-
[![License](https://img.shields.io/npm/l/ngx-diff2html)](LICENSE)
3+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.14.
64

7-
A simple text diff component for Angular, based on [diff-match-patch](https://github.com/google/diff-match-patch) & [diff2html](https://github.com/rtfpessoa/diff2html).
5+
## Code scaffolding
86

9-
## Demo
10-
11-
[ngx-diff2html Demo](https://axel-dev.github.io/ngx-diff2html)
12-
13-
## Installation
14-
15-
```
16-
npm install --save ngx-diff2html
17-
```
18-
19-
## Usage
20-
21-
**1**. Register the `NgxDiff2htmlModule` in a module, for example app module:
22-
23-
```diff
24-
import { BrowserModule } from '@angular/platform-browser';
25-
import { NgModule } from '@angular/core';
26-
27-
import { AppComponent } from './app.component';
28-
+ import { NgxDiff2htmlModule } from 'ngx-diff2html';
29-
30-
@NgModule({
31-
declarations: [AppComponent],
32-
imports: [
33-
BrowserModule,
34-
+ NgxDiff2htmlModule
35-
],
36-
providers: [],
37-
bootstrap: [AppComponent]
38-
})
39-
export class AppModule {}
40-
```
41-
42-
**2**. Import diff2html css in `styles.css`:
43-
44-
```diff
45-
/* You can add global styles to this file, and also import other style files */
46-
+ @import "~diff2html/dist/diff2html.min.css";
47-
```
48-
49-
**3**. Add the following line to `polyfills.ts`:
50-
51-
```diff
52-
// Add global to window, assigning the value of window itself.
53-
+ (window as any).global = window;
54-
```
55-
56-
**4**. Start using the component:
57-
58-
```html
59-
<ngx-diff2html
60-
left="some text"
61-
right="some other text"
62-
></ngx-diff2html>
63-
```
64-
65-
## API
66-
67-
- module: `NgxDiff2htmlModule`
68-
- component: `NgxDiff2htmlComponent`
69-
- selector: `ngx-diff2html`
70-
71-
### Inputs
72-
73-
| Input | Type | Required | Description
74-
| -------------------- | ----------------- | ------------------------------------ | --------------------------
75-
| left | string | Yes | First text to be compared
76-
| right | string | Yes | Second text to be compared
77-
| filename | string | Optional, default: `` (empty) | Can be used to display a filename at the top of diff results.
78-
| format | `DiffFormat` | Optional, default: `side-by-side` | Possible values:<br> - `side-by-side`<br> - `line-by-line`
79-
| style | `DiffStyle` | Optional, default: `word` | Possible values:<br> - `word`<br> - `char`
80-
81-
### Outputs
82-
83-
| Output | Type | Required | Description
84-
| -------------------- | ----------------- | ------------------------------------ | --------------------------
85-
| diffChange | string | Optional | Event fired when diff changes. The returned value is the text diff in [unified format](http://fileformats.archiveteam.org/wiki/Unified_diff)
7+
Run `ng generate component component-name --project ngx-diff2html` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-diff2html`.
8+
> Note: Don't forget to add `--project ngx-diff2html` or else it will be added to the default project in your `angular.json` file.
869
8710
## Build
8811

@@ -92,6 +15,10 @@ Run `ng build ngx-diff2html` to build the project. The build artifacts will be s
9215

9316
After building your library with `ng build ngx-diff2html`, go to the dist folder `cd dist/ngx-diff2html` and run `npm publish`.
9417

95-
## License
18+
## Running unit tests
19+
20+
Run `ng test ngx-diff2html` to execute the unit tests via [Karma](https://karma-runner.github.io).
21+
22+
## Further help
9623

97-
This project is licensed under the [MIT](LICENSE) license.
24+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

0 commit comments

Comments
 (0)