-
Notifications
You must be signed in to change notification settings - Fork 20
Feature/text annotator menu #139
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
Open
giacomocerre
wants to merge
14
commits into
develop
Choose a base branch
from
feature/text-annotator-menu
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d93f016
Update themes and colors with annotator style
giacomocerre 868a9ef
Update translation for annotator terms
giacomocerre f2c3351
Add annotator icons
giacomocerre e44a13a
Update edition config for annotator colors
giacomocerre ed3fe0e
Update style in button component for annotator
giacomocerre a7d6bd9
Add evt-text-annotator package
giacomocerre e0a9201
Update app config with annotator conf
giacomocerre bef7631
Update app module with text annotator component
giacomocerre 8bf784b
Add text annotator component
giacomocerre 89573e3
Add evt-text-annotator component to app.component
giacomocerre 92ff3cb
Update CHANGELOG
giacomocerre 3fa5bf9
Fix TextAnnotatorComponent declaration order
giuliac89 a594240
Merge remote-tracking branch 'origin/develop' into feature/text-annot…
davivcu 3d11ba6
Fix spinner missing type attribute
davivcu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/app/components/annotator/text-annotator/text-annotator.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <div class="evt-adder-annotation" [ngStyle]="{'left.px': annotator.options.position.x, 'top.px':annotator.options.position.y}"> | ||
| <div class="evt-adder-toolbar" *ngIf="annotator.options.showAdder"> | ||
| <div class="evt-annotator-option evt-annotate" (click)="openCreation('annotate')"> | ||
| <span>{{'annotate' | translate}} <evt-icon [iconInfo] = "{icon:'annotate', iconSet:'evt'}"></evt-icon></span> | ||
| </div> | ||
| <div class="evt-annotator-option evt-highlight" (click)="openCreation('highlight')"> | ||
| <span>{{'highlight' | translate}} <evt-icon [iconInfo] = "{icon:'highlight', iconSet:'evt'}"></evt-icon></span> | ||
| </div> | ||
| <ng-container *ngIf="annotator.values.type === 'highlight' then createHighlight"></ng-container> | ||
| </div> | ||
| <ng-container *ngIf="annotator.values.type === 'annotate' then createAnnotation"></ng-container> | ||
| </div> | ||
|
|
||
| <ng-template #createHighlight> | ||
| <div class="evt-annotator-option evt-highlight-colors" *ngFor="let color of annotator.options.highlightColors.highlights"> | ||
| <div class="evt-highlighter" [ngStyle]="{'background-color': color}"></div> | ||
| </div> | ||
| </ng-template> | ||
|
|
||
| <ng-template #createAnnotation> | ||
| <div class="evt-annotate-creator"> | ||
| <div class="evt-note evt-note-header"> | ||
| <span><evt-icon [iconInfo] = "{icon:'note', iconSet:'evt'}"></evt-icon> {{'annotatorNote' | translate}}</span> | ||
| <evt-icon [iconInfo]="{icon:'close', iconSet:'evt'}" [ngStyle]="{'float': 'right', 'cursor': 'pointer'}" (click)="closeAdder()"></evt-icon> | ||
| </div> | ||
| <div class="evt-note evt-note-body"> | ||
| <div class="note-title" attr.contenteditable="{{annotator.options.updateMode}}" attr.data-placeholder="{{'noteTitle' | translate}}"></div> | ||
| <div class="note-body" attr.contenteditable="{{annotator.options.updateMode}}" attr.data-placeholder="{{'noteBody' | translate}}"></div> | ||
| </div> | ||
| <div class="evt-note evt-note-footer" [ngStyle]="{'float': 'right'}"> | ||
| <evt-button class="btn-anno" label="{{'noteCancel' | translate}}" additionalClasses="btn-annotator"></evt-button> | ||
| <evt-button class="btn-anno" label="{{'noteSave' | translate}}" additionalClasses="btn-annotator-light"></evt-button> | ||
| </div> | ||
| </div> | ||
| </ng-template> |
127 changes: 127 additions & 0 deletions
127
src/app/components/annotator/text-annotator/text-annotator.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| @import "../../../../assets/scss/colors"; | ||
|
|
||
|
|
||
| $buttonColor: get-anno-color(buttonColors); | ||
| $noteColor: get-anno-color(noteColor); | ||
|
|
||
|
|
||
| .evt-adder-annotation { | ||
| font-family: Junicode, Times, serif; | ||
| display: block; | ||
| position: absolute; | ||
| z-index: 999; | ||
| height: auto; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| .evt-annotate { | ||
| border-right: 1px solid #ccc; | ||
| } | ||
|
|
||
| .evt-annotator-option { | ||
| background: $buttonColor; | ||
| padding: 8px 5px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .evt-annotator-option span { | ||
| margin: 0; | ||
| } | ||
|
|
||
| .evt-adder-toolbar { | ||
| all: initial; | ||
| z-index: 1; | ||
| display: flex; | ||
| flex-direction: row; | ||
| margin-top: 15px; | ||
| box-shadow: 0px 0px 9px 0 rgb(0 0 0 / 33%); | ||
| border-radius: 5px; | ||
| border: 1px solid #ccc; | ||
| } | ||
|
|
||
| .evt-adder-toolbar::after { | ||
| content: ""; | ||
| position: absolute; | ||
| width: 0; | ||
| height: 0; | ||
| margin-left: -0.5em; | ||
| bottom: 25px; | ||
| left: 15%; | ||
| box-sizing: border-box; | ||
| border: 5px solid #ccc; | ||
| border-color: transparent transparent #fff #fff; | ||
| transform-origin: 0 0; | ||
| transform: rotate(135deg); | ||
| box-shadow: -3px 3px 3px 0 rgb(0 0 0 / 14%); | ||
| } | ||
|
|
||
| .evt-highlight-colors div { | ||
| width: 20px; | ||
| height: 20px; | ||
| float: left; | ||
| } | ||
|
|
||
|
|
||
| .evt-annotate-creator { | ||
| width: 280px; | ||
| height: auto; | ||
| } | ||
|
|
||
| [contentEditable=true]:empty:not(:focus):before{ | ||
| content:attr(data-placeholder); | ||
| color:grey; | ||
| font-style:italic; | ||
| } | ||
|
|
||
| .evt-annotate-creator { | ||
| margin-top: 15px; | ||
| background: $buttonColor; | ||
| overflow: hidden; | ||
| box-shadow: 0px 0px 9px 0 rgb(0 0 0 / 33%); | ||
| } | ||
|
|
||
| .evt-annotate-creator::after { | ||
| content: ""; | ||
| position: absolute; | ||
| width: 0; | ||
| height: 0; | ||
| margin-left: -0.5em; | ||
| bottom: 92%; | ||
| left: 15%; | ||
| box-sizing: border-box; | ||
| border: 5px solid #ccc; | ||
| border-color: transparent transparent #E4EBF6 #E4EBF6; | ||
| transform-origin: 0 0; | ||
| transform: rotate(135deg); | ||
| box-shadow: -3px 3px 3px 0 rgb(0 0 0 / 14%); | ||
| } | ||
|
|
||
| .evt-note-header { | ||
| background-color: $noteColor; | ||
| padding: 10px; | ||
| } | ||
|
|
||
| .evt-note.evt-note-body { | ||
| padding: 20px; | ||
| } | ||
|
|
||
| .note-title, | ||
| .note-body { | ||
| border: 1px solid #ccc; | ||
| padding: 5px; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| .note-title:focus, | ||
| .note-body:focus { | ||
| outline: none; | ||
| border: 1px solid #000; | ||
| } | ||
|
|
||
| .note-body { | ||
| height: 100px; | ||
| } | ||
|
|
||
| .evt-note-footer { | ||
| padding: 0 20px 20px 0; | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/app/components/annotator/text-annotator/text-annotator.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { TextAnnotatorComponent } from './text-annotator.component'; | ||
|
|
||
| describe('TextAnnotatorComponent', () => { | ||
| let component: TextAnnotatorComponent; | ||
| let fixture: ComponentFixture<TextAnnotatorComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| declarations: [ TextAnnotatorComponent ], | ||
| }) | ||
| .compileComponents(); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| fixture = TestBed.createComponent(TextAnnotatorComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
83 changes: 83 additions & 0 deletions
83
src/app/components/annotator/text-annotator/text-annotator.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { Component, OnDestroy } from '@angular/core'; | ||
| import { Subscription } from 'rxjs'; | ||
| import { AnnotationTextType, AnnotatorColors, AppConfig } from 'src/app/app.config'; | ||
| import { AnnotatorService } from 'src/app/services/annotator/annotator.service'; | ||
|
|
||
| interface TextAnnotation { | ||
| options: { | ||
| position: AnnotatorPosition; | ||
| highlightColors: AnnotatorColors; | ||
| showAdder: Boolean; | ||
| updateMode: Boolean; | ||
| } | ||
| values: { | ||
| range: Range; | ||
| type: AnnotationTextType; | ||
| selectedText: string; | ||
| } | ||
| } | ||
| interface AnnotatorPosition { | ||
| x: number; | ||
| y: number; | ||
| } | ||
| @Component({ | ||
| selector: 'evt-text-annotator', | ||
| templateUrl: './text-annotator.component.html', | ||
| styleUrls: ['./text-annotator.component.scss'], | ||
| }) | ||
| export class TextAnnotatorComponent implements OnDestroy { | ||
| private subscriptions: Subscription[] = []; | ||
| public annotator: TextAnnotation = { | ||
| options: { | ||
| position: { x: 0, y: 0 }, | ||
| highlightColors: AppConfig.evtSettings.edition.annotatorColors, | ||
| showAdder: false, | ||
| updateMode: true, | ||
| }, | ||
| values: { | ||
| range: null, | ||
| type: null, | ||
| selectedText: '', | ||
| }, | ||
| } | ||
|
|
||
| constructor( | ||
| private annotatorService: AnnotatorService, | ||
| ) { | ||
| const { values } = this.annotator; | ||
|
|
||
| this.subscriptions.push(this.annotatorService.textSelection$ | ||
| .subscribe((selection) => { | ||
| values.selectedText = selection.toString(); | ||
| if (/\S/.test(values.selectedText)) { | ||
| this.openAdder(selection); | ||
| } else { | ||
| this.closeAdder(); | ||
| } | ||
| })); | ||
| } | ||
|
|
||
| openAdder(selection: Selection) { | ||
| const { options, values } = this.annotator; | ||
| values.range = selection.getRangeAt(0); | ||
| options.showAdder = true | ||
| const rect = values.range.getBoundingClientRect(); | ||
| options.position = { y: rect.bottom, x: rect.left }; | ||
| } | ||
|
|
||
| closeAdder() { | ||
| const { options, values } = this.annotator; | ||
| options.showAdder = false; | ||
| values.type = null; | ||
| } | ||
|
|
||
| openCreation(choice: string) { | ||
| const { options, values } = this.annotator; | ||
| values.type = choice as AnnotationTextType; | ||
| options.showAdder = choice !== 'annotate'; | ||
| } | ||
|
|
||
| ngOnDestroy() { | ||
| this.subscriptions.forEach((subscription) => subscription.unsubscribe()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.