Skip to content
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

Preferences API #106

Draft
wants to merge 142 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
11d0985
Bump ReadiumCSS version
JayPanoz Feb 7, 2025
c474f7c
Remove scroll anchors
JayPanoz Feb 7, 2025
42b4a2b
Init interfaces
JayPanoz Feb 12, 2025
2057d00
Classes for Preference
JayPanoz Feb 13, 2025
bc13f84
EPUBPreferences class
JayPanoz Feb 13, 2025
2fb3856
Create EpubDefaults.ts
JayPanoz Feb 13, 2025
7f1c445
Match case of Epub interfaces and classes
JayPanoz Feb 13, 2025
45c83a4
EpubSettings class
JayPanoz Feb 13, 2025
1e6a0d3
Update image filters
JayPanoz Feb 13, 2025
dc7e8d3
Add checks in EpubPreferences constructor
JayPanoz Feb 13, 2025
0d2346b
Init EPUBPreferencesEditor
JayPanoz Feb 14, 2025
ea54b32
Add minimal and optimal lineLength
JayPanoz Feb 18, 2025
f8be9b6
LineLength as a helper
JayPanoz Feb 18, 2025
eac5e2c
Corrections in Preferences interfaces
JayPanoz Feb 18, 2025
189ea87
Add Properties for ReadiumCSS
JayPanoz Feb 19, 2025
b88f023
separate RCSS types from Preferences
JayPanoz Feb 19, 2025
091dc2b
Correct Theme enum
JayPanoz Feb 19, 2025
4751eb7
rename valueInRange method for consistency
JayPanoz Feb 19, 2025
986751c
Init ReadiumCSS class
JayPanoz Feb 19, 2025
8132b58
Corrections in lineLength helper
JayPanoz Feb 20, 2025
544291e
Update User Properties for corrected ReadiumCSS
JayPanoz Feb 20, 2025
67bc063
Rename visitedLinkColor property
JayPanoz Feb 20, 2025
f14883d
Init EpubNavigator config + pref editor
JayPanoz Feb 20, 2025
3cc4a69
Replace config with pref + defaults
JayPanoz Feb 20, 2025
9bd8203
add mixing export for preferences in Navigator
JayPanoz Feb 20, 2025
71658f0
Update @readium/css package
JayPanoz Feb 20, 2025
2c5b0e9
[WIP] CSS handling in EpubNavigator
JayPanoz Feb 21, 2025
9c75563
[WIP] setting properties methods and helpers
JayPanoz Feb 21, 2025
a0423be
colCount with line lengths
JayPanoz Feb 22, 2025
defab72
index for css folder
JayPanoz Feb 22, 2025
9460d07
add constraint prop in EpubPrefs
JayPanoz Feb 22, 2025
6adf033
Add missing prefs in LineLength
JayPanoz Feb 22, 2025
3c4e3de
Plug EpubDefaults
JayPanoz Feb 22, 2025
1c1c006
Handle optimal line length default
JayPanoz Feb 22, 2025
749a62d
add viewport width in data when update_properties
JayPanoz Feb 23, 2025
955d3a5
consistency in epubnav constructor
JayPanoz Feb 23, 2025
41bcf7a
Update virtual columns
JayPanoz Feb 23, 2025
6e59c17
Corrections in css update & commit
JayPanoz Feb 24, 2025
13b9db2
updateCSS in apply method
JayPanoz Feb 24, 2025
3c56d90
use values from ReadiumCSS in PrefEditor
JayPanoz Feb 24, 2025
fd13e75
Add comment re fontFamily effectiveValue
JayPanoz Feb 24, 2025
f5b896c
Update darkMode check in Decorator
JayPanoz Feb 24, 2025
c4ae60e
Add support for hex with 4 numbers in colorToRgba
JayPanoz Feb 24, 2025
4e8b41f
Correct currentProgression
JayPanoz Feb 24, 2025
61daba4
ReadiumCSS’ required attr
JayPanoz Feb 24, 2025
74c3c09
resume comms on setCSSProperties
JayPanoz Feb 24, 2025
66b70cf
Correct lang setting in BlobBuilder
JayPanoz Feb 24, 2025
ea10e49
Add PreferencesEditor in Configurable
JayPanoz Feb 24, 2025
3236321
pass settings to epubPreferenceEditor
JayPanoz Feb 24, 2025
a4146ca
Add link + selection colors to settings
JayPanoz Feb 25, 2025
4a142b2
Update effectiveValue of lineLength
JayPanoz Feb 25, 2025
6de7f7f
Add invertGaijiFilter to EpubSettings
JayPanoz Feb 25, 2025
b916448
Consistency in added constructors
JayPanoz Feb 25, 2025
41be484
handle ColCount setting in FXL
JayPanoz Feb 25, 2025
befc756
Apply constraint in EpubNavigator
JayPanoz Feb 25, 2025
fa3a57c
Correct effective values
JayPanoz Feb 25, 2025
25524ad
Add some color utils for contrast
JayPanoz Feb 25, 2025
745cebd
update contrast helper in color
JayPanoz Feb 25, 2025
12b0504
Correct adjustment of colors
JayPanoz Feb 25, 2025
5dc4aa5
Remove ResizeObserver polyfill
JayPanoz Feb 26, 2025
eca7fa8
Add custom key in Theme enum
JayPanoz Feb 26, 2025
96c8c4e
Adding Missing pieces of Pref API in EpubNavigator
JayPanoz Feb 26, 2025
cc76fe6
Correct preferencesEditor getters
JayPanoz Feb 26, 2025
080e552
Set some EpubDefaults
JayPanoz Feb 26, 2025
1be2160
Pass callback to update PrefEditor preferences
JayPanoz Feb 26, 2025
0fcaf3e
More PreferenceEditor fixes
JayPanoz Feb 26, 2025
6e45715
Only update prefEditor if not null
JayPanoz Feb 26, 2025
00f0b69
Bump version for breaking changes
JayPanoz Feb 26, 2025
465fc1b
Remove fontOpticalSizing default
JayPanoz Feb 26, 2025
aebfe62
Add missing export in EpubNavigator
JayPanoz Feb 26, 2025
e399760
Correct ReadiumCSS update
JayPanoz Feb 27, 2025
a1e8178
More fixes in ReadiumCSS
JayPanoz Feb 27, 2025
25468c5
Correct UserSettings constructor
JayPanoz Feb 27, 2025
556fdde
Add boolean check in EpubPreferences
JayPanoz Feb 27, 2025
f02a76f
More corrections in init + merging
JayPanoz Feb 27, 2025
d594bc5
Correct merging
JayPanoz Feb 27, 2025
002796c
Correct resizeObserver
JayPanoz Feb 27, 2025
f9b819d
Remove resize + orientationChange events in FXL
JayPanoz Feb 27, 2025
7e4ab6f
Correct init of Preferences
JayPanoz Feb 27, 2025
929bce1
Correct async in applyPref
JayPanoz Feb 27, 2025
0cd6ad9
update constraint pref
JayPanoz Feb 27, 2025
ad18bcb
Fix setting CSS props for hidden iframes
JayPanoz Feb 27, 2025
54b5e94
Update line lengths in ReadiumCSS
JayPanoz Feb 28, 2025
fb4704b
apply correct line-length on user property
JayPanoz Feb 28, 2025
33f9f57
move serializer to EpubPreferences
JayPanoz Feb 28, 2025
88c4f0a
Remove PreferenceSerializer export
JayPanoz Feb 28, 2025
afe62f0
Correct settings / defaults
JayPanoz Feb 28, 2025
68200e9
Resolve some column snapping issues
JayPanoz Feb 28, 2025
1d65686
SetContainerWidth on settings update
JayPanoz Feb 28, 2025
ba25b83
Fix updating of virtualCols
JayPanoz Feb 28, 2025
978be0a
consistency with resize/orientationChange
JayPanoz Feb 28, 2025
8c378f2
setCSSProperties in blob
JayPanoz Mar 3, 2025
9246537
Fix snapOffset when going backwards
JayPanoz Mar 3, 2025
a9ac8c8
Fix ColumnSnapping on mobile
JayPanoz Mar 3, 2025
e3343fc
transform as regex in column snapper Mutation
JayPanoz Mar 3, 2025
fbbf218
Override colCount in settings
JayPanoz Mar 4, 2025
302f55b
return settings as readonly
JayPanoz Mar 4, 2025
975456e
Init lineLengths with settings
JayPanoz Mar 4, 2025
c3e7014
Fix EpubNavigator for FXL
JayPanoz Mar 4, 2025
181338b
Move constraint to settings
JayPanoz Mar 4, 2025
cbc002a
Return settings for FXL
JayPanoz Mar 4, 2025
b304ab6
Remove unecessary number constructor
JayPanoz Mar 5, 2025
b7fb7d9
Protect setting CSS props if frame destroyed
JayPanoz Mar 5, 2025
5cda7e0
Round incremented/decremented RangePref
JayPanoz Mar 6, 2025
1a28710
Correct ranges in EpubPreferences
JayPanoz Mar 6, 2025
0eb5ec5
Fix Preference getters
JayPanoz Mar 6, 2025
8b1b99f
fix ReadiumCSS font-size
JayPanoz Mar 7, 2025
8ce2a0f
Single source of truth for RangePreferences
JayPanoz Mar 7, 2025
6f4cf83
[WIP] Zoom nasty side effects
JayPanoz Mar 7, 2025
0588003
Fix container sizing with zoom
JayPanoz Mar 7, 2025
97187c1
Fix line-length instability on font-size increase
JayPanoz Mar 10, 2025
1f0a35e
Fix EpubNav resizeHandler
JayPanoz Mar 10, 2025
c53504b
Add maximalLineLength pref
JayPanoz Mar 10, 2025
d2e9c0d
Rename max lineLength prop in helper
JayPanoz Mar 10, 2025
2568a78
Make min, optimal, and max line lengths settable
JayPanoz Mar 10, 2025
70b6458
Implement paginationStrategy pref
JayPanoz Mar 11, 2025
c721375
Correct serialization
JayPanoz Mar 11, 2025
bd18b84
Make min and max linelengths nullable
JayPanoz Mar 11, 2025
79d5284
Implement pagination strategies for auto
JayPanoz Mar 11, 2025
492ea1e
Rewrite logic for n cols
JayPanoz Mar 11, 2025
dc1346d
Commit CSS on lineLength change
JayPanoz Mar 11, 2025
73558c7
Fix incorrect containerWidth
JayPanoz Mar 11, 2025
9e92821
Revamp auto-pagination for fluidity
JayPanoz Mar 12, 2025
19bda6c
Update lineLength helper for base font size
JayPanoz Mar 12, 2025
8841956
Make paginationStrategy nullable
JayPanoz Mar 12, 2025
d25be41
Take negative zoom into account
JayPanoz Mar 12, 2025
492bb75
Implement null maximal linelength
JayPanoz Mar 12, 2025
9e93bbe
Correct updating of lineLength props
JayPanoz Mar 12, 2025
a114b26
Implement margin pagination strategy
JayPanoz Mar 13, 2025
d6dab6f
Remove zoomCompensation for margin strategy
JayPanoz Mar 13, 2025
03f6054
Fix previous commit for col > 1
JayPanoz Mar 13, 2025
1859dd0
Make EpubDefaults nullable
JayPanoz Mar 13, 2025
8fe11c6
Add font-family to relayout condition
JayPanoz Mar 14, 2025
8cd7afc
Remove relayout from EpubNavigator
JayPanoz Mar 15, 2025
aab8e5e
Implement strategies for scroll
JayPanoz Mar 17, 2025
2d6f2b5
Improve Properties utils
JayPanoz Mar 18, 2025
f554d03
Start consolidating layout in ReadiumCSS
JayPanoz Mar 18, 2025
fd2511b
Fix scroll line-length on zoom >= 1
JayPanoz Mar 18, 2025
58491b8
Correct paginate lineLength
JayPanoz Mar 18, 2025
5d383ed
Fallback to oldStyle serif if no fontFace
JayPanoz Mar 19, 2025
12ad514
Force fontFace with default in linelength helper
JayPanoz Mar 19, 2025
6a48cba
Correct handling of number values
JayPanoz Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
separate RCSS types from Preferences
JayPanoz committed Feb 19, 2025
commit b88f02365201535fae8bf7ebdc269f321c463a70
10 changes: 9 additions & 1 deletion navigator/src/epub/css/Properties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { BodyHyphens, BoxSizing, FontOpticalSizing, FontWidth, Ligatures, TextAlignment, Theme, TypeScale, View } from "../../preferences/Types";
import { TextAlignment, Theme } from "../../preferences/Types";

export type BodyHyphens = "auto" | "none";
export type BoxSizing = "content-box" | "border-box";
export type FontOpticalSizing = "auto" | "none";
export type FontWidth = "ultra-condensed" | "extra-condensed" | "condensed" | "semi-condensed" | "normal" | "semi-expanded" | "expanded" | "extra-expanded" | "ultra-expanded" | number;
export type Ligatures = "common-ligatures" | "none";
export type TypeScale = 1 | 1.067 | 1.125 | 1.2 | 1.25 | 1.333 | 1.414 | 1.5 | 1.618;
export type View = "paged" | "scroll";

abstract class Properties {
constructor() {}
10 changes: 5 additions & 5 deletions navigator/src/epub/preferences/EpubDefaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FontOpticalSizing, FontWidth, TextAlignment, Theme } from "../../preferences/Types";
import { TextAlignment, Theme } from "../../preferences/Types";

// Expose everything available in Preferences except blend and gaiji filters ATM
export interface IEpubDefaults {
@@ -8,9 +8,9 @@ export interface IEpubDefaults {
darkenFilter?: boolean | number | null,
fontFamily?: string | null,
fontSize?: number | null,
fontOpticalSizing?: FontOpticalSizing | null,
fontOpticalSizing?: boolean | null,
fontWeight?: number | null,
fontWidth?: FontWidth | null,
fontWidth?: number | null,
hyphens?: boolean | null,
invertFilter?: boolean | number | null,
invertGaijiFilter?: boolean | number | null,
@@ -44,9 +44,9 @@ export class EpubDefaults {
darkenFilter: boolean | number | null;
fontFamily: string | null;
fontSize: number | null;
fontOpticalSizing: FontOpticalSizing | null;
fontOpticalSizing: boolean | null;
fontWeight: number | null;
fontWidth: FontWidth | null;
fontWidth: number | null;
hyphens: boolean | null;
invertFilter: boolean | number | null;
invertGaijiFilter: boolean | number | null;
10 changes: 5 additions & 5 deletions navigator/src/epub/preferences/EpubPreferences.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FontOpticalSizing, FontWidth, TextAlignment, Theme } from "../../preferences/Types";
import { TextAlignment, Theme } from "../../preferences/Types";
import { ConfigurablePreferences } from "../../preferences/Configurable";

export interface IEpubPreferences {
@@ -8,9 +8,9 @@ export interface IEpubPreferences {
darkenFilter?: boolean | number | null,
fontFamily?: string | null,
fontSize?: number | null,
fontOpticalSizing?: FontOpticalSizing | null,
fontOpticalSizing?: boolean | null,
fontWeight?: number | null,
fontWidth?: FontWidth | null,
fontWidth?: number | null,
hyphens?: boolean | null,
invertFilter?: boolean | number | null,
invertGaijiFilter?: boolean | number | null,
@@ -44,9 +44,9 @@ export class EpubPreferences implements ConfigurablePreferences {
darkenFilter: boolean | number | null;
fontFamily: string | null;
fontSize: number | null;
fontOpticalSizing: FontOpticalSizing | null;
fontOpticalSizing: boolean | null;
fontWeight: number | null;
fontWidth: FontWidth | null;
fontWidth: number | null;
hyphens: boolean | null;
invertFilter: boolean | number | null;
invertGaijiFilter: boolean | number | null;
11 changes: 5 additions & 6 deletions navigator/src/epub/preferences/EpubPreferencesEditor.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { IPreferencesEditor } from "../../preferences/PreferencesEditor";
import { EpubDefaults } from "./EpubDefaults";
import { EpubPreferences } from "./EpubPreferences";
import { EpubSettings } from "./EpubSettings";
import { FontOpticalSizing, TextAlignment, Theme } from "../../preferences/Types";
import { TextAlignment, Theme } from "../../preferences/Types";
import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference";

// WIP: will change cos’ of all the missing pieces
@@ -84,10 +84,10 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
});
}

get fontOpticalSizing(): Preference<FontOpticalSizing> | null {
return new Preference<FontOpticalSizing>({
get fontOpticalSizing(): BooleanPreference | null {
return new BooleanPreference({
initialValue: this.preferences.fontOpticalSizing,
effectiveValue: this.settings.fontOpticalSizing || "auto",
effectiveValue: this.settings.fontOpticalSizing || true,
isEffective: this.layout === EPUBLayout.reflowable && !this.settings.publisherStyles && this.preferences.fontOpticalSizing !== null
});
}
@@ -102,13 +102,12 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
});
}

// TODO: support keywords
get fontWidth(): RangePreference<number> | null {
return new RangePreference<number>({
initialValue: this.preferences.fontWidth,
effectiveValue: this.settings.fontWidth || 100,
isEffective: this.layout === EPUBLayout.reflowable && !this.settings.publisherStyles && this.preferences.fontWidth !== null,
supportedRange: [70, 200],
supportedRange: [50, 250],
step: 10
});
}
10 changes: 5 additions & 5 deletions navigator/src/epub/preferences/EpubSettings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConfigurableSettings } from "../../preferences/Configurable";
import { FontOpticalSizing, FontWidth, TextAlignment, Theme } from "../../preferences/Types";
import { TextAlignment, Theme } from "../../preferences/Types";

// Expose everything available in Preferences except blend and gaiji filters ATM
export interface IEpubSettings {
@@ -9,9 +9,9 @@ export interface IEpubSettings {
darkenFilter?: boolean | number | null,
fontFamily?: string | null,
fontSize?: number | null,
fontOpticalSizing?: FontOpticalSizing | null,
fontOpticalSizing?: boolean | null,
fontWeight?: number | null,
fontWidth?: FontWidth | null,
fontWidth?: number | null,
hyphens?: boolean | null,
invertFilter?: boolean | number | null,
letterSpacing?: number | null,
@@ -37,9 +37,9 @@ export class EpubSettings implements ConfigurableSettings {
darkenFilter: boolean | number | null;
fontFamily: string | null;
fontSize: number | null;
fontOpticalSizing: FontOpticalSizing | null;
fontOpticalSizing: boolean | null;
fontWeight: number | null;
fontWidth: FontWidth | null;
fontWidth: number | null;
hyphens: boolean | null;
invertFilter: boolean | number | null;
letterSpacing: number | null;
16 changes: 1 addition & 15 deletions navigator/src/preferences/Types.ts
Original file line number Diff line number Diff line change
@@ -9,18 +9,4 @@ export enum Theme {
light = "day",
sepia = "sepia",
night = "night"
}

export type BodyHyphens = "auto" | "none";

export type BoxSizing = "content-box" | "border-box";

export type FontOpticalSizing = "auto" | "none";

export type FontWidth = /* "ultra-condensed" | "extra-condensed" | "condensed" | "semi-condensed" | "normal" | "semi-expanded" | "expanded" | "extra-expanded" | "ultra-expanded" | */ number;

export type Ligatures = "common-ligatures" | "none";

export type TypeScale = 1 | 1.067 | 1.125 | 1.2 | 1.25 | 1.333 | 1.414 | 1.5 | 1.618;

export type View = "paged" | "scroll";
}