Skip to content

Commit cba60a3

Browse files
committed
refactor: remove Angular module entirely
1 parent ea5fded commit cba60a3

File tree

4 files changed

+22
-52
lines changed

4 files changed

+22
-52
lines changed

README.md

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,30 @@ View and edit the live demo Angular app on <a href="https://codesandbox.io/s/ngx
3333
npm install ngx-annotate-text
3434
```
3535

36-
2. Import the Angular module `NgxAnnotateTextModule`:
36+
2. In your Angular component import the `NgxAnnotateTextComponent` and create two properties for the text to be displayed and the list of annotations:
3737

3838
```typescript
39-
import { BrowserModule } from "@angular/platform-browser";
40-
import { NgModule } from "@angular/core";
39+
import { Annotation, NgxAnnotateTextComponent } from 'ngx-annotate-text';
4140

42-
import { AppComponent } from "./app.component";
43-
import { NgxAnnotateTextModule } from "ngx-annotate-text";
44-
45-
@NgModule({
46-
declarations: [AppComponent],
47-
imports: [BrowserModule, NgxAnnotateTextModule],
48-
providers: [],
49-
bootstrap: [AppComponent],
41+
@Component({
42+
selector: 'app-root',
43+
imports: [NgxAnnotateTextComponent],
44+
templateUrl: './app.component.html',
45+
styleUrl: './app.component.css',
5046
})
51-
export class AppModule {}
47+
export class AppComponent {
48+
annotations: Annotation[] = [
49+
new Annotation(3, 11, 'Date', '#0d6efd'),
50+
new Annotation(36, 45, 'City', '#dc3545'),
51+
new Annotation(47, 52, 'Country', '#198754'),
52+
new Annotation(77, 85, 'Time', '#6c757d'),
53+
];
54+
55+
text = 'On August 1, we went on vacation to Barcelona, Spain. Our flight took off at 11:00 am.';
56+
}
5257
```
5358

54-
3. Add the component `ngx-annotate-text` to your template:
59+
3. Add the component `ngx-annotate-text` to your component's template:
5560

5661
```html
5762
<ngx-annotate-text
@@ -64,31 +69,7 @@ View and edit the live demo Angular app on <a href="https://codesandbox.io/s/ngx
6469
</ngx-annotate-text>
6570
```
6671

67-
4. Create properties in your component class for the text to be annotated and an (empty) array of annotations:
68-
69-
```typescript
70-
import { Component, ViewChild } from "@angular/core";
71-
import { Annotation, NgxAnnotateTextComponent } from "ngx-annotate-text";
72-
73-
@Component({
74-
selector: "app-root",
75-
templateUrl: "./app.component.html",
76-
styleUrls: ["./app.component.css"],
77-
})
78-
export class AppComponent {
79-
text: string =
80-
"On August 1, we went on vacation to Barcelona, Spain. Our flight took off at 11:00 am.";
81-
82-
annotations: Annotation[] = [
83-
new Annotation(3, 11, "Date", "#0069d9"),
84-
new Annotation(36, 45, "City", "#dc3545"),
85-
new Annotation(47, 52, "Country", "#28a745"),
86-
new Annotation(77, 85, "Time", "#5a6268"),
87-
];
88-
}
89-
```
90-
91-
5. Having set `annotationClass="my-annotation"`, a custom CSS styling can be applied by combining `::ng-deep` with the class selector `.my-annotation`, e.g., to remove the border-radius:
72+
3. Having set `annotationClass="my-annotation"`, a custom CSS styling can be applied by combining `::ng-deep` with the class selector `.my-annotation`, e.g., to remove the border-radius:
9273
```css
9374
::ng-deep .my-annotation .annotation-parent,
9475
::ng-deep .my-annotation .annotation-content {
@@ -123,6 +104,8 @@ View and edit the live demo Angular app on <a href="https://codesandbox.io/s/ngx
123104
| getCurrentTextSelection | Returns the start index and end index of the currently selected text range. Returns `undefined` if no text is currently selected. | `ISelection|undefined` |
124105
| isOverlappingWithExistingAnnotations | Returns true if the given text selection is (partially) overlapping with an existing annotation. Returns false otherwise. | `boolean` |
125106

107+
---
108+
126109
## Development
127110

128111
### Recreate project from scratch

projects/ngx-annotate-text/src/lib/ngx-annotate-text.module.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

projects/ngx-annotate-text/src/public-api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Public API Surface of ngx-annotate-text
33
*/
44

5-
export * from './lib/ngx-annotate-text.module';
65
export * from './lib/components/ngx-annotate-text/ngx-annotate-text.component';
76
export * from './lib/components/annotation-renderer/annotation-renderer.components';
87
export * from './lib/models/annotation.model';

src/app/app.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component, Type, ViewChild } from '@angular/core';
2-
import { NgxAnnotateTextModule } from '../../projects/ngx-annotate-text/src/lib/ngx-annotate-text.module';
32
import { Annotation, NgxAnnotateTextComponent } from '../../projects/ngx-annotate-text/src/public-api';
43
import { MyAnnotationRendererComponent } from './my-annotation-renderer/my-annotation-renderer.component';
54
import { NgxAnnotationRendererComponent } from '../../projects/ngx-annotate-text/src/lib/components/annotation-renderer/annotation-renderer.components';
@@ -9,7 +8,7 @@ import { NgxAnnotationRendererComponentInterface } from '../../projects/ngx-anno
98
@Component({
109
selector: 'app-root',
1110
standalone: true,
12-
imports: [NgxAnnotateTextModule, FormsModule],
11+
imports: [NgxAnnotateTextComponent, FormsModule],
1312
templateUrl: './app.component.html',
1413
styleUrl: './app.component.css',
1514
})

0 commit comments

Comments
 (0)