Skip to content

fix: correctly decorators for vertical scrolling pages #671

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

Merged

Conversation

shovel-kun
Copy link
Contributor

This PR fixes decorators on vertical scrolling pages.

I've decided to expose the writing-mode of a decorator's text range by using a data attribute for styling customizability.

adding_decorators.webm
editing_decorators.webm

@mickael-menu mickael-menu requested a review from Copilot May 27, 2025 08:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes decorator styling for vertical scrolling pages by exposing the writing mode via data attributes and refactoring CSS inline generation.

  • In HtmlDecorationTemplate.kt, the CSS string concatenation is replaced with a buildString block and the styles for different writing modes are added.
  • In decorator.js, attribute assignments and element positioning logic are updated to account for vertical writing modes.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
readium/navigator/src/main/java/org/readium/r2/navigator/html/HtmlDecorationTemplate.kt Refactored CSS generation using buildString and added style rules for vertical writing modes.
readium/navigator/src/main/assets/_scripts/src/decorator.js Updated attribute assignment to use dataset properties and adjusted positioning logic for vertical scrolling.

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thank you @shovel-kun, this is working great!

@qnga
Copy link
Member

qnga commented May 27, 2025

Hello,
In your fix, you treat vertical RL as a special case. Aren't your changes required for vertical LR as well?

@shovel-kun
Copy link
Contributor Author

shovel-kun commented May 27, 2025

@qnga Good catch, I've included changes for vertical LR.

You can find the Mongolian EPUB example used in the screenshots below here: readium/swift-toolkit#516

Rtl

image

Ltr MONGOLIAN

image

EDIT: I've also fixed incorrect bounds layout on vertical RTL, the notes annotation is now correctly aligned above in test app.

@qnga
Copy link
Member

qnga commented May 27, 2025

Great work, thanks a lot!

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes 🙏

@mickael-menu mickael-menu merged commit 38b1a81 into readium:develop May 28, 2025
4 checks passed
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.

3 participants