|
1 | | -<button |
2 | | - *ngIf="annotation" |
3 | | - class="annotation-parent" |
4 | | - [style.border-color]="annotation.color" |
5 | | - [style.background-color]="annotation.color" |
6 | | - (click)="clickAnnotation(annotation)" |
7 | | -> |
8 | | - <span class="annotation-content"> |
9 | | - <pre>{{ annotation.text }}</pre> |
10 | | - </span> |
| 1 | +@if (annotation) { |
| 2 | + <button |
| 3 | + class="annotation-parent" |
| 4 | + [style.border-color]="annotation.color" |
| 5 | + [style.background-color]="annotation.color" |
| 6 | + (click)="clickAnnotation(annotation)" |
| 7 | + > |
| 8 | + <span class="annotation-content"> |
| 9 | + <pre>{{ annotation.text }}</pre> |
| 10 | + </span> |
11 | 11 |
|
12 | | - <!-- Instead of setting the property "innerText" of this HTML element, we set "data-label". In CSS, we can then |
| 12 | + <!-- Instead of setting the property "innerText" of this HTML element, we set "data-label". In CSS, we can then |
13 | 13 | reference the content of this property and can use the CSS pseudo- element "::after" to insert the content |
14 | 14 | of "data-label" as text into the DOM. What's the advantage of this? At first, I tried to use the "innerText" |
15 | 15 | property of this HTML element to visualize the annotation's label. Whenever the user selected a range of the |
16 | 16 | original text, then the labels of the annotations were counted into the range, too. This made it difficult to |
17 | 17 | extract which text range the user actually selected. By using the CSS pseudo-class "::after", we can prevent |
18 | 18 | the annotations' labels from being included into the selected text range. --> |
19 | 19 |
|
20 | | - <span class="annotation-label" [attr.data-label]="annotation.label" [style.background-color]="annotation.color"> |
21 | | - </span> |
22 | | - |
23 | | - <span class="annotation-button" *ngIf="removable"> |
24 | | - <span> |
25 | | - <button |
26 | | - class="remove-annotation" |
27 | | - (click)="removeAnnotation(annotation)" |
28 | | - aria-label="remove annotation" |
29 | | - ></button> |
| 20 | + <span class="annotation-label" [attr.data-label]="annotation.label" [style.background-color]="annotation.color"> |
30 | 21 | </span> |
31 | | - </span> |
32 | | -</button> |
| 22 | + |
| 23 | + @if (removable) { |
| 24 | + <span class="annotation-button"> |
| 25 | + <span> |
| 26 | + <button |
| 27 | + class="remove-annotation" |
| 28 | + (click)="removeAnnotation(annotation)" |
| 29 | + aria-label="remove annotation" |
| 30 | + ></button> |
| 31 | + </span> |
| 32 | + </span> |
| 33 | + } |
| 34 | + </button> |
| 35 | +} |
0 commit comments