Migrate annotation changes#1554
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1554 +/- ##
==========================================
- Coverage 63.78% 62.52% -1.26%
==========================================
Files 67 67
Lines 6166 6314 +148
Branches 1361 1382 +21
==========================================
+ Hits 3933 3948 +15
- Misses 2197 2330 +133
Partials 36 36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fix renamed parameter within markRange function
cdrini
left a comment
There was a problem hiding this comment.
Got through the first half ; will finish the rest later today!
| } | ||
|
|
||
| @customElement('br-annotation-menu') | ||
| class BRAnnotationMenu extends LitElement { |
There was a problem hiding this comment.
This more of a modal then a menu ; so let's call call it BRAnnotationModal or *Popup or *Form or something.
| } | ||
|
|
||
| @customElement('br-annotation-menu') | ||
| class BRAnnotationMenu extends LitElement { |
There was a problem hiding this comment.
Also let's create a new file, plugin.annotations.js and move this there and then import it into this file. That'll let us start structuring these in the way we'll eventually want them to be structured, can keep this file a bit more focussed/targetted.
| @property({type: String}) | ||
| lastHighlightColorUsed = this.HIGHLIGHT_YELLOW; | ||
|
|
||
| currentAnnotationNodes; |
| /** @override */ | ||
| connectedCallback() { | ||
| super.connectedCallback(); | ||
| this.setAttribute('role', 'menu'); |
There was a problem hiding this comment.
I don't think this would be considered an aria menu; see https://www.w3.org/WAI/ARIA/apg/patterns/menubar/ . Alert/dialog might be most appropriate? https://www.w3.org/WAI/ARIA/apg/patterns/
| if (storage[idx].uuid === currentUUID) { | ||
| storage.splice(idx, 1); | ||
| saveToLocalStorage(storage); | ||
| for (const ele of this.currentAnnotationNodes) { | ||
| const tempText = ele.textContent; |
There was a problem hiding this comment.
This is a lot of logic in this web component that requires internal knowledge of how annotations are saved. It would be better if it didn't have that internal knowledge, and all that logic was centralized in one place. Let's create a new class (in plugin.annotations.js) called AnnotationStorageService. That should have methods for easy edit/save/delete. This will also set us up for when we switch all these methods from local storage to instead using API calls.
This component can then just take in the storage service as another parameter.
| } | ||
|
|
||
| show(nodes) { | ||
| if (this.br.plugins.translate?.userToggleTranslate) return; |
There was a problem hiding this comment.
Is this relevant here? This can only be displayed via the select menu, which should already have that check embedded in it.
Migrated annotation code to work with newly improved main branch