Skip to content

Migrate annotation changes#1554

Draft
schu96 wants to merge 1 commit into
internetarchive:masterfrom
schu96:annotation-merge
Draft

Migrate annotation changes#1554
schu96 wants to merge 1 commit into
internetarchive:masterfrom
schu96:annotation-merge

Conversation

@schu96

@schu96 schu96 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Migrated annotation code to work with newly improved main branch

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 10.00000% with 153 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.52%. Comparing base (2501a95) to head (274ddda).

Files with missing lines Patch % Lines
src/util/TextSelectionManager.js 10.00% 153 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Fix renamed parameter within markRange function
@schu96 schu96 force-pushed the annotation-merge branch from cc2e50c to 274ddda Compare June 18, 2026 02:44

@cdrini cdrini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got through the first half ; will finish the rest later today!

}

@customElement('br-annotation-menu')
class BRAnnotationMenu extends LitElement {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/util/TextSelectionManager.js
@property({type: String})
lastHighlightColorUsed = this.HIGHLIGHT_YELLOW;

currentAnnotationNodes;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdoc/types

/** @override */
connectedCallback() {
super.connectedCallback();
this.setAttribute('role', 'menu');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Comment on lines +870 to +874
if (storage[idx].uuid === currentUUID) {
storage.splice(idx, 1);
saveToLocalStorage(storage);
for (const ele of this.currentAnnotationNodes) {
const tempText = ele.textContent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/util/TextSelectionManager.js
Comment thread src/util/TextSelectionManager.js
}

show(nodes) {
if (this.br.plugins.translate?.userToggleTranslate) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this relevant here? This can only be displayed via the select menu, which should already have that check embedded in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants