Skip to content

Preferences API #106

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
wants to merge 176 commits into
base: develop
Choose a base branch
from
Open

Preferences API #106

wants to merge 176 commits into from

Conversation

JayPanoz
Copy link
Contributor

@JayPanoz JayPanoz commented Feb 7, 2025

This branch is meant to implementing the Preferences API in the ts-toolkit Navigator, bringing it on par with – and taking inspiration from – Readium’s Mobile toolkits.

This will make it a lot easier to implement user settings in apps and is using ReadiumCSS version 2.

It will be merged as a new major version since it will consequently come with breaking changes.

In ReadiumCSS v1, auto pagination was built-in, switching from 1 to 2 columns depending on the window/screen width. This is no longer the case. However, we plan to replace this feature with preferences that can be set:

  • an optimal line length, in ch (number of characters)
  • a minimal line length: can be ch, can be undefined, or null.

The logic is the following:

  • the number of columns is no longer limited to 2. It can be as many as apps see fit
  • the number of columns will be computed based on this optimal line length in auto mode
  • the minimal line length is used to apply a lower bound even if the number of columns is larger than 1, dropping a column in the process if it can’t fit
  • in case this minimal line length is undefined, then optimal line-length is the minimal one
  • in case it’s null then this lower bound is disabled entirely and apps can enforce the number of columns they want

This is currently implemented in Readium/Playground and will be ported back into the ts-toolkit.

These anchor elements are implementation-specific and shouldn’t be forced upon all consumers of the ts-toolkit. An Injectable API should be provided to do this.
So that they stay consistent across the Navigator package
Rewritten as a class whose properties you can update for user settings
Updates from Playground:
- user line length is used instead of optimal if defined
- colCount more than 2
- colCount null instead of auto
- line length getters in px
JayPanoz added 7 commits April 1, 2025 09:30
This has been fixed in ReadiumCSS
We have to pretty much nuke everything for it to work properly, otherwise it inits with paged or scroll while the currentCSS Property may have been updated, and that throws everything off.
Previously it was only doing it for the hrefs in the pool, which missed blobs whose href was not in the pool
So that progress is reported when preferences update triggers a relayout
@JayPanoz
Copy link
Contributor Author

JayPanoz commented Apr 4, 2025

Update: there are some additional changes coming (line-length, removal of advanced settings/publisherStyles) so I have to delay things a little bit.

JayPanoz added 14 commits April 8, 2025 10:54
Since some are set to false as a fallback in defaults, the flag was applied so we filter the types that should append the prop
Handle blob invalidation on setCssProperties in FramePoolManager. This keeps track of blobs that should be revoked and re-created to update CSS Properties, only when needed i.e. href is added to pool. If href is currently in the pool, it will be updated dynamically then handled when disposed of.
Re Firefox Bug with non-publisher font
Not implementing the sniffing in ts-toolkit right now, even as a fallback in EpubDefaults, as we have to discuss where it should belong.
In case you prefer to rely on the older implementation of ReadiumCSS font-size user setting instead of the new one.
Basically zoom does not change metrics while font-size does, so we must apply compensation differently
Depends on UA sniffing + deprecated font size implementation so it makes sense to handle it by default in the Preferences API. It’s still possible to disable it through defaults or Preferences though.
TODO: Building settings UI
@JayPanoz JayPanoz marked this pull request as ready for review May 5, 2025 15:59
JayPanoz added 6 commits May 7, 2025 18:07
When lines of text are less than 20% of the viewport height, the column can fit without requiring a column break
So basically if it’s 99% it fits… it has to be the height of the iframe document…
So that it can be overridden and not handled internally without any way to do so
Otherwise it’s always overridden
It was bumped in Thorium Desktop on user’s demand since 2.5 was not enough
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.

None yet

1 participant