Skip to content

Migrate annotation changes - #1554

Draft
schu96 wants to merge 6 commits into
internetarchive:masterfrom
schu96:annotation-merge
Draft

Migrate annotation changes#1554
schu96 wants to merge 6 commits 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 5.55556% with 561 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.63%. Comparing base (882adbc) to head (a738684).

Files with missing lines Patch % Lines
src/util/OlPopover.js 1.79% 327 Missing and 2 partials ⚠️
src/plugins/plugin.annotations.js 10.45% 137 Missing ⚠️
src/util/TextSelectionManager.js 9.41% 75 Missing and 2 partials ⚠️
src/util/scroll-lock.js 14.28% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1554      +/-   ##
==========================================
- Coverage   63.81%   59.63%   -4.18%     
==========================================
  Files          69       72       +3     
  Lines        6256     6826     +570     
  Branches     1391     1518     +127     
==========================================
+ Hits         3992     4071      +79     
- Misses       2225     2710     +485     
- Partials       39       45       +6     

☔ 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.

@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!

Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
Comment thread src/util/TextSelectionManager.js Outdated
@schu96
schu96 force-pushed the annotation-merge branch 2 times, most recently from b205c70 to 1ac3b87 Compare July 13, 2026 03:21
@schu96
schu96 force-pushed the annotation-merge branch from 467afe4 to 2ed063b Compare August 8, 2026 22:03
const BR_HIGHLIGHTS_LOCAL_STORAGE_KEY = "BRhighlightStorage";

@customElement('br-annotation-modal')

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.

Suggested change

}

renderColorOptions() {
const colors = {

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 appears to be duplicating the static constants on this class also below where have another similar object. These might be able to be DRY'd up somehow so that we're not duplicated the color names / hex values.

placement="bottom-start"
.anchor=${this.anchorEl}
.open=${live(this.open)}
._position=${this.positionObj}

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 seems like something that shouldn't be private ; we can like make _position just position.

Comment thread src/plugins/plugin.annotations.js
}

updateTextArea(text) {
const inputEle = document.querySelector("#annotateTextArea");

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.

Suggested change
const inputEle = document.querySelector("#annotateTextArea");
const inputEle = this.querySelector("#annotateTextArea");

Comment thread src/util/scroll-lock.js
@@ -0,0 +1,57 @@
/**

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.

Add a link to the OL file so we can potentially in theory at some point sync/updated.

if (!this.activeHighlightNodes) { // highlight selection if not already done
this.handleHighlightSave();
}
this.br.plugins.textSelection?.textSelectionManager.showAnnotationModal(this.activeHighlightNodes, anchorEl);

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 think we need to create the plugin annotations class matching the other plugins, so that we can attach the annotation-specific methods/data/logic to that alone.

That also keeps/fulfills the promise of BR plugins being optional. Letting people load the plugin files only if they support/want to support the associated functionality.

Suggested change
this.br.plugins.textSelection?.textSelectionManager.showAnnotationModal(this.activeHighlightNodes, anchorEl);
this.br.plugins.annotations.showAnnotationModal(this.activeHighlightNodes, anchorEl);

* @param {HTMLElement} [anchorEl] Element to anchor the annotation popover
* to, e.g. the br-menu-option button that was clicked
*/
showAnnotationModal(nodes, anchorEl) {

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.

These sorts of methods would make sense to move to a dedicated AnnotationPlugin

* Saves all the highlights in an array to localStorage
* @param {BookReaderSavedHighlight[]} highlights
*/
function saveToLocalStorage(highlights) {

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.

Should these still exist? Or should these now be done by the StorageService?

I think we want to treat highlights and annotations as the same thing. They're both "Annotations" ; one just has a comment attached to it, and one doesn't.

endTextNode.parentElement.classList.contains("BRhighlight")) {
return;
const existingMarks = [];
const walker = document.createTreeWalker(

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 there anyway we can re-use some of the helper methods we have? Not sure.

@cdrini

cdrini commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

UI feedback:

  1. CSS tweaks for modal
  2. chrome mobile issues

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