@readium/navigator 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@laynezh/vite-plugin-lib-assets": "^2.1.0",
52
- "@readium/css": "2.0.0-beta.19",
52
+ "@readium/css": "2.0.0-beta.20",
53
53
  "@readium/navigator-html-injectables": "workspace:*",
54
54
  "@readium/shared": "workspace:*",
55
55
  "@types/path-browserify": "^1.0.3",
@@ -1,9 +1,11 @@
1
- import { Link, Locator, Publication, ReadingProgression, LocatorLocations } from "@readium/shared";
1
+ import { Feature, Link, Locator, Publication, ReadingProgression, LocatorLocations } from "@readium/shared";
2
2
  import { VisualNavigator, VisualNavigatorViewport, ProgressionRange } from "../Navigator";
3
3
  import { Configurable } from "../preferences/Configurable";
4
4
  import { WebPubFramePoolManager } from "./WebPubFramePoolManager";
5
5
  import { BasicTextSelection, CommsEventKey, FrameClickEvent, ModuleLibrary, ModuleName, WebPubModules } from "@readium/navigator-html-injectables";
6
6
  import * as path from "path-browserify";
7
+ import { WebPubFrameManager } from "./WebPubFrameManager";
8
+
7
9
  import { ManagerEventKey } from "../epub/EpubNavigator";
8
10
  import { WebPubCSS } from "./css/WebPubCSS";
9
11
  import { WebUserProperties } from "./css/Properties";
@@ -12,7 +14,6 @@ import { IWebPubDefaults, WebPubDefaults } from "./preferences/WebPubDefaults";
12
14
  import { WebPubSettings } from "./preferences/WebPubSettings";
13
15
  import { IPreferencesEditor } from "../preferences/PreferencesEditor";
14
16
  import { WebPubPreferencesEditor } from "./preferences/WebPubPreferencesEditor";
15
-
16
17
  export interface WebPubNavigatorConfiguration {
17
18
  preferences: IWebPubPreferences;
18
19
  defaults: IWebPubDefaults;
@@ -71,7 +72,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
71
72
  // Initialize preference system
72
73
  this._preferences = new WebPubPreferences(configuration.preferences);
73
74
  this._defaults = new WebPubDefaults(configuration.defaults);
74
- this._settings = new WebPubSettings(this._preferences, this._defaults);
75
+ this._settings = new WebPubSettings(this._preferences, this._defaults, this.hasDisplayTransformability);
75
76
  this._css = new WebPubCSS({
76
77
  userProperties: new WebUserProperties({ zoom: this._settings.zoom })
77
78
  });
@@ -115,7 +116,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
115
116
  }
116
117
 
117
118
  private async applyPreferences() {
118
- this._settings = new WebPubSettings(this._preferences, this._defaults);
119
+ this._settings = new WebPubSettings(this._preferences, this._defaults, this.hasDisplayTransformability);
119
120
 
120
121
  if (this._preferencesEditor !== null) {
121
122
  this._preferencesEditor = new WebPubPreferencesEditor(this._preferences, this.settings, this.pub.metadata);
@@ -146,6 +147,20 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
146
147
  this.framePool.setCSSProperties(properties);
147
148
  }
148
149
 
150
+ /**
151
+ * Exposed to the public to compensate for lack of implemented readium conveniences
152
+ * TODO remove when settings management is incorporated
153
+ */
154
+ public get _cframes(): (WebPubFrameManager | undefined)[] {
155
+ return this.framePool.currentFrames;
156
+ }
157
+
158
+ private get hasDisplayTransformability(): boolean {
159
+ return this.pub.metadata?.accessibility?.feature?.some(
160
+ f => f.value === Feature.DISPLAY_TRANSFORMABILITY.value
161
+ ) ?? false;
162
+ }
163
+
149
164
  public eventListener(key: CommsEventKey | ManagerEventKey, data: unknown) {
150
165
  switch (key) {
151
166
  case "_pong":
@@ -1,26 +1,21 @@
1
1
  // WebPubCSS is equivalent to ReadiumCSS for WebPub
2
+ // Respects the stylesheet order from after
2
3
 
3
4
  export const webPubStylesheet = `
4
- /* FontFamily */
5
-
6
- :root[style*="--USER__fontFamily"] {
7
- font-family: var(--USER__fontFamily) !important;
8
- }
9
-
10
- :root[style*="--USER__fontFamily"] * {
11
- font-family: revert !important;
12
- }
13
-
14
- /* FontWeight */
5
+ /* TextAlign */
15
6
 
16
- :root[style*="--USER__fontWeight"] body {
17
- font-weight: var(--USER__fontWeight) !important;
7
+ :root[style*="--USER__textAlign"] {
8
+ text-align: var(--USER__textAlign);
18
9
  }
19
10
 
20
- /* Attempt to handle known bolds */
21
- :root[style*="--USER__fontWeight"] b,
22
- :root[style*="--USER__fontWeight"] strong {
23
- font-weight: bolder;
11
+ :root[style*="--USER__textAlign"] body,
12
+ :root[style*="--USER__textAlign"] p:not([class*="title"]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+ *) > h1 + p):not(div:has(+ *) > p:has(+ h1)),
13
+ :root[style*="--USER__textAlign"] li,
14
+ :root[style*="--USER__textAlign"] dd {
15
+ text-align: var(--USER__textAlign) !important;
16
+ -moz-text-align-last: auto !important;
17
+ -epub-text-align-last: auto !important;
18
+ text-align-last: auto !important;
24
19
  }
25
20
 
26
21
  /* Hyphens */
@@ -45,84 +40,14 @@ export const webPubStylesheet = `
45
40
  hyphens: inherit;
46
41
  }
47
42
 
48
- /* LetterSpacing */
49
-
50
- :root[style*="--USER__letterSpacing"] h1,
51
- :root[style*="--USER__letterSpacing"] h2,
52
- :root[style*="--USER__letterSpacing"] h3,
53
- :root[style*="--USER__letterSpacing"] h4,
54
- :root[style*="--USER__letterSpacing"] h5,
55
- :root[style*="--USER__letterSpacing"] h6,
56
- :root[style*="--USER__letterSpacing"] p,
57
- :root[style*="--USER__letterSpacing"] li,
58
- :root[style*="--USER__letterSpacing"] div,
59
- :root[style*="--USER__letterSpacing"] dt,
60
- :root[style*="--USER__letterSpacing"] dd {
61
- letter-spacing: var(--USER__letterSpacing);
62
- font-variant: none;
63
- }
64
-
65
- /* Ligatures */
66
-
67
- :root[style*="--USER__ligatures"] {
68
- font-variant-ligatures: var(--USER__ligatures) !important;
69
- }
70
-
71
- :root[style*="--USER__ligatures"] * {
72
- font-variant-ligatures: inherit !important;
73
- }
74
-
75
- /* LineHeight */
76
-
77
- :root[style*="--USER__lineHeight"] {
78
- line-height: var(--USER__lineHeight) !important;
79
- }
80
-
81
- :root[style*="--USER__lineHeight"] body,
82
- :root[style*="--USER__lineHeight"] p,
83
- :root[style*="--USER__lineHeight"] li,
84
- :root[style*="--USER__lineHeight"] div {
85
- line-height: inherit;
86
- }
87
-
88
- /* ParagraphIndent */
89
-
90
- :root[style*="--USER__paraIndent"] p {
91
- text-indent: var(--USER__paraIndent) !important;
92
- }
93
-
94
- :root[style*="--USER__paraIndent"] p *,
95
- :root[style*="--USER__paraIndent"] p:first-letter {
96
- text-indent: 0 !important;
97
- }
98
-
99
- /* ParagraphSpacing */
100
-
101
- :root[style*="--USER__paraSpacing"] p {
102
- margin-block: var(--USER__paraSpacing) !important;
103
- }
104
-
105
- /* Ruby */
106
-
107
- :root[style*="readium-noRuby-on"] body rt,
108
- :root[style*="readium-noRuby-on"] body rp {
109
- display: none;
110
- }
111
-
112
- /* TextAlign */
43
+ /* FontFamily */
113
44
 
114
- :root[style*="--USER__textAlign"] {
115
- text-align: var(--USER__textAlign);
45
+ :root[style*="--USER__fontFamily"] {
46
+ font-family: var(--USER__fontFamily) !important;
116
47
  }
117
48
 
118
- :root[style*="--USER__textAlign"] body,
119
- :root[style*="--USER__textAlign"] p:not(blockquote p):not(figcaption p):not(hgroup p),
120
- :root[style*="--USER__textAlign"] li,
121
- :root[style*="--USER__textAlign"] dd {
122
- text-align: var(--USER__textAlign) !important;
123
- -moz-text-align-last: auto !important;
124
- -epub-text-align-last: auto !important;
125
- text-align-last: auto !important;
49
+ :root[style*="--USER__fontFamily"] * {
50
+ font-family: revert !important;
126
51
  }
127
52
 
128
53
  /* TextNormalize */
@@ -132,13 +57,13 @@ export const webPubStylesheet = `
132
57
  font-style: normal !important;
133
58
  }
134
59
 
135
- :root[style*="readium-a11y-on"] *:not(code):not(var):not(kbd):not(samp) {
60
+ :root[style*="readium-a11y-on"] body *:not(code):not(var):not(kbd):not(samp) {
136
61
  font-family: inherit !important;
137
62
  font-weight: inherit !important;
138
63
  font-style: inherit !important;
139
64
  }
140
65
 
141
- :root[style*="readium-a11y-on"] * {
66
+ :root[style*="readium-a11y-on"] body * {
142
67
  text-decoration: none !important;
143
68
  font-variant-caps: normal !important;
144
69
  font-variant-position: normal !important;
@@ -151,22 +76,6 @@ export const webPubStylesheet = `
151
76
  vertical-align: baseline !important;
152
77
  }
153
78
 
154
- /* Word Spacing */
155
-
156
- :root[style*="--USER__wordSpacing"] h1,
157
- :root[style*="--USER__wordSpacing"] h2,
158
- :root[style*="--USER__wordSpacing"] h3,
159
- :root[style*="--USER__wordSpacing"] h4,
160
- :root[style*="--USER__wordSpacing"] h5,
161
- :root[style*="--USER__wordSpacing"] h6,
162
- :root[style*="--USER__wordSpacing"] p,
163
- :root[style*="--USER__wordSpacing"] li,
164
- :root[style*="--USER__wordSpacing"] div,
165
- :root[style*="--USER__wordSpacing"] dt,
166
- :root[style*="--USER__wordSpacing"] dd {
167
- word-spacing: var(--USER__wordSpacing);
168
- }
169
-
170
79
  /* Zoom */
171
80
 
172
81
  :root {
@@ -201,4 +110,96 @@ export const webPubStylesheet = `
201
110
  zoom: var(--USER__zoom) !important;
202
111
  }
203
112
  }
113
+
114
+ /* LineHeight */
115
+
116
+ :root[style*="--USER__lineHeight"] {
117
+ line-height: var(--USER__lineHeight) !important;
118
+ }
119
+
120
+ :root[style*="--USER__lineHeight"] body,
121
+ :root[style*="--USER__lineHeight"] p,
122
+ :root[style*="--USER__lineHeight"] li,
123
+ :root[style*="--USER__lineHeight"] div {
124
+ line-height: inherit;
125
+ }
126
+
127
+ /* ParagraphSpacing */
128
+
129
+ :root[style*="--USER__paraSpacing"] p {
130
+ margin-block: var(--USER__paraSpacing) !important;
131
+ }
132
+
133
+ /* ParagraphIndent */
134
+
135
+ :root[style*="--USER__paraIndent"] p {
136
+ text-indent: var(--USER__paraIndent) !important;
137
+ }
138
+
139
+ :root[style*="--USER__paraIndent"] p *,
140
+ :root[style*="--USER__paraIndent"] p:first-letter {
141
+ text-indent: 0 !important;
142
+ }
143
+
144
+ /* WordSpacing */
145
+
146
+ :root[style*="--USER__wordSpacing"] h1,
147
+ :root[style*="--USER__wordSpacing"] h2,
148
+ :root[style*="--USER__wordSpacing"] h3,
149
+ :root[style*="--USER__wordSpacing"] h4,
150
+ :root[style*="--USER__wordSpacing"] h5,
151
+ :root[style*="--USER__wordSpacing"] h6,
152
+ :root[style*="--USER__wordSpacing"] p,
153
+ :root[style*="--USER__wordSpacing"] li,
154
+ :root[style*="--USER__wordSpacing"] div,
155
+ :root[style*="--USER__wordSpacing"] dt,
156
+ :root[style*="--USER__wordSpacing"] dd {
157
+ word-spacing: var(--USER__wordSpacing);
158
+ }
159
+
160
+ /* LetterSpacing */
161
+
162
+ :root[style*="--USER__letterSpacing"] h1,
163
+ :root[style*="--USER__letterSpacing"] h2,
164
+ :root[style*="--USER__letterSpacing"] h3,
165
+ :root[style*="--USER__letterSpacing"] h4,
166
+ :root[style*="--USER__letterSpacing"] h5,
167
+ :root[style*="--USER__letterSpacing"] h6,
168
+ :root[style*="--USER__letterSpacing"] p,
169
+ :root[style*="--USER__letterSpacing"] li,
170
+ :root[style*="--USER__letterSpacing"] div,
171
+ :root[style*="--USER__letterSpacing"] dt,
172
+ :root[style*="--USER__letterSpacing"] dd {
173
+ letter-spacing: var(--USER__letterSpacing);
174
+ font-variant: none;
175
+ }
176
+
177
+ /* FontWeight */
178
+
179
+ :root[style*="--USER__fontWeight"] body {
180
+ font-weight: var(--USER__fontWeight) !important;
181
+ }
182
+
183
+ /* Attempt to handle known bolds */
184
+ :root[style*="--USER__fontWeight"] b,
185
+ :root[style*="--USER__fontWeight"] strong {
186
+ font-weight: bolder;
187
+ }
188
+
189
+ /* Ruby */
190
+
191
+ :root[style*="readium-noRuby-on"] body rt,
192
+ :root[style*="readium-noRuby-on"] body rp {
193
+ display: none;
194
+ }
195
+
196
+ /* Ligatures */
197
+
198
+ :root[style*="--USER__ligatures"] {
199
+ font-variant-ligatures: var(--USER__ligatures) !important;
200
+ }
201
+
202
+ :root[style*="--USER__ligatures"] * {
203
+ font-variant-ligatures: inherit !important;
204
+ }
204
205
  `;
@@ -33,11 +33,17 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
33
33
  this.preferences[key] = value;
34
34
  }
35
35
 
36
+ private get isDisplayTransformable(): boolean {
37
+ return this.metadata?.accessibility?.feature?.some(
38
+ f => f.value === Feature.DISPLAY_TRANSFORMABILITY.value
39
+ ) ?? false; // Default to false if no metadata
40
+ }
41
+
36
42
  get fontFamily(): Preference<string> {
37
43
  return new Preference<string>({
38
44
  initialValue: this.preferences.fontFamily,
39
45
  effectiveValue: this.settings.fontFamily || null,
40
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
46
+ isEffective: this.isDisplayTransformable,
41
47
  onChange: (newValue: string | null | undefined) => {
42
48
  this.updatePreference("fontFamily", newValue || null);
43
49
  }
@@ -48,7 +54,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
48
54
  return new RangePreference<number>({
49
55
  initialValue: this.preferences.fontWeight,
50
56
  effectiveValue: this.settings.fontWeight || 400,
51
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
57
+ isEffective: this.isDisplayTransformable,
52
58
  onChange: (newValue: number | null | undefined) => {
53
59
  this.updatePreference("fontWeight", newValue || null);
54
60
  },
@@ -61,7 +67,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
61
67
  return new BooleanPreference({
62
68
  initialValue: this.preferences.hyphens,
63
69
  effectiveValue: this.settings.hyphens || false,
64
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
70
+ isEffective: this.isDisplayTransformable,
65
71
  onChange: (newValue: boolean | null | undefined) => {
66
72
  this.updatePreference("hyphens", newValue || null);
67
73
  }
@@ -72,7 +78,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
72
78
  return new RangePreference<number>({
73
79
  initialValue: this.preferences.letterSpacing,
74
80
  effectiveValue: this.settings.letterSpacing || 0,
75
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
81
+ isEffective: this.isDisplayTransformable,
76
82
  onChange: (newValue: number | null | undefined) => {
77
83
  this.updatePreference("letterSpacing", newValue || null);
78
84
  },
@@ -85,7 +91,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
85
91
  return new BooleanPreference({
86
92
  initialValue: this.preferences.ligatures,
87
93
  effectiveValue: this.settings.ligatures || true,
88
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
94
+ isEffective: this.isDisplayTransformable,
89
95
  onChange: (newValue: boolean | null | undefined) => {
90
96
  this.updatePreference("ligatures", newValue || null);
91
97
  }
@@ -96,7 +102,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
96
102
  return new RangePreference<number>({
97
103
  initialValue: this.preferences.lineHeight,
98
104
  effectiveValue: this.settings.lineHeight,
99
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
105
+ isEffective: this.isDisplayTransformable,
100
106
  onChange: (newValue: number | null | undefined) => {
101
107
  this.updatePreference("lineHeight", newValue || null);
102
108
  },
@@ -109,7 +115,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
109
115
  return new BooleanPreference({
110
116
  initialValue: this.preferences.noRuby,
111
117
  effectiveValue: this.settings.noRuby || false,
112
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
118
+ isEffective: this.isDisplayTransformable,
113
119
  onChange: (newValue: boolean | null | undefined) => {
114
120
  this.updatePreference("noRuby", newValue || null);
115
121
  }
@@ -120,7 +126,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
120
126
  return new RangePreference<number>({
121
127
  initialValue: this.preferences.paragraphIndent,
122
128
  effectiveValue: this.settings.paragraphIndent || 0,
123
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
129
+ isEffective: this.isDisplayTransformable,
124
130
  onChange: (newValue: number | null | undefined) => {
125
131
  this.updatePreference("paragraphIndent", newValue || null);
126
132
  },
@@ -133,7 +139,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
133
139
  return new RangePreference<number>({
134
140
  initialValue: this.preferences.paragraphSpacing,
135
141
  effectiveValue: this.settings.paragraphSpacing || 0,
136
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
142
+ isEffective: this.isDisplayTransformable,
137
143
  onChange: (newValue: number | null | undefined) => {
138
144
  this.updatePreference("paragraphSpacing", newValue || null);
139
145
  },
@@ -146,7 +152,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
146
152
  return new EnumPreference<TextAlignment>({
147
153
  initialValue: this.preferences.textAlign,
148
154
  effectiveValue: this.settings.textAlign || TextAlignment.start,
149
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
155
+ isEffective: this.isDisplayTransformable,
150
156
  onChange: (newValue: TextAlignment | null | undefined) => {
151
157
  this.updatePreference("textAlign", newValue || null);
152
158
  },
@@ -158,7 +164,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
158
164
  return new BooleanPreference({
159
165
  initialValue: this.preferences.textNormalization,
160
166
  effectiveValue: this.settings.textNormalization || false,
161
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
167
+ isEffective: this.isDisplayTransformable,
162
168
  onChange: (newValue: boolean | null | undefined) => {
163
169
  this.updatePreference("textNormalization", newValue || null);
164
170
  }
@@ -169,7 +175,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
169
175
  return new RangePreference<number>({
170
176
  initialValue: this.preferences.wordSpacing,
171
177
  effectiveValue: this.settings.wordSpacing || 0,
172
- isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false,
178
+ isEffective: this.isDisplayTransformable,
173
179
  onChange: (newValue: number | null | undefined) => {
174
180
  this.updatePreference("wordSpacing", newValue || null);
175
181
  },
@@ -20,65 +20,67 @@ export interface IWebPubSettings {
20
20
  }
21
21
 
22
22
  export class WebPubSettings implements ConfigurableSettings {
23
- fontFamily: string | null;
24
- fontWeight: number | null;
25
- hyphens: boolean | null;
26
- letterSpacing: number | null;
27
- ligatures: boolean | null;
28
- lineHeight: number | null;
29
- noRuby: boolean | null;
30
- paragraphIndent: number | null;
31
- paragraphSpacing: number | null;
32
- textAlign: TextAlignment | null;
33
- textNormalization: boolean | null;
34
- wordSpacing: number | null;
23
+ fontFamily: string | null = null;
24
+ fontWeight: number | null = null;
25
+ hyphens: boolean | null = null;
26
+ letterSpacing: number | null = null;
27
+ ligatures: boolean | null = null;
28
+ lineHeight: number | null = null;
29
+ noRuby: boolean | null = null;
30
+ paragraphIndent: number | null = null;
31
+ paragraphSpacing: number | null = null;
32
+ textAlign: TextAlignment | null = null;
33
+ textNormalization: boolean | null = null;
34
+ wordSpacing: number | null = null;
35
35
  zoom: number | null;
36
36
 
37
- constructor(preferences: WebPubPreferences, defaults: WebPubDefaults) {
38
- this.fontFamily = preferences.fontFamily || defaults.fontFamily || null;
39
- this.fontWeight = preferences.fontWeight !== undefined
40
- ? preferences.fontWeight
41
- : defaults.fontWeight !== undefined
42
- ? defaults.fontWeight
43
- : null;
44
- this.hyphens = typeof preferences.hyphens === "boolean"
45
- ? preferences.hyphens
46
- : defaults.hyphens ?? null;
47
- this.letterSpacing = preferences.letterSpacing !== undefined
48
- ? preferences.letterSpacing
49
- : defaults.letterSpacing !== undefined
50
- ? defaults.letterSpacing
51
- : null;
52
- this.ligatures = typeof preferences.ligatures === "boolean"
53
- ? preferences.ligatures
54
- : defaults.ligatures ?? null;
55
- this.lineHeight = preferences.lineHeight !== undefined
56
- ? preferences.lineHeight
57
- : defaults.lineHeight !== undefined
58
- ? defaults.lineHeight
59
- : null;
60
- this.noRuby = typeof preferences.noRuby === "boolean"
61
- ? preferences.noRuby
62
- : defaults.noRuby ?? null;
63
- this.paragraphIndent = preferences.paragraphIndent !== undefined
64
- ? preferences.paragraphIndent
65
- : defaults.paragraphIndent !== undefined
66
- ? defaults.paragraphIndent
67
- : null;
68
- this.paragraphSpacing = preferences.paragraphSpacing !== undefined
69
- ? preferences.paragraphSpacing
70
- : defaults.paragraphSpacing !== undefined
71
- ? defaults.paragraphSpacing
72
- : null;
73
- this.textAlign = preferences.textAlign || defaults.textAlign || null;
74
- this.textNormalization = typeof preferences.textNormalization === "boolean"
75
- ? preferences.textNormalization
76
- : defaults.textNormalization ?? null;
77
- this.wordSpacing = preferences.wordSpacing !== undefined
78
- ? preferences.wordSpacing
79
- : defaults.wordSpacing !== undefined
80
- ? defaults.wordSpacing
81
- : null;
37
+ constructor(preferences: WebPubPreferences, defaults: WebPubDefaults, hasDisplayTransformability: boolean) {
38
+ if (hasDisplayTransformability) {
39
+ this.fontFamily = preferences.fontFamily || defaults.fontFamily || null;
40
+ this.fontWeight = preferences.fontWeight !== undefined
41
+ ? preferences.fontWeight
42
+ : defaults.fontWeight !== undefined
43
+ ? defaults.fontWeight
44
+ : null;
45
+ this.hyphens = typeof preferences.hyphens === "boolean"
46
+ ? preferences.hyphens
47
+ : defaults.hyphens ?? null;
48
+ this.letterSpacing = preferences.letterSpacing !== undefined
49
+ ? preferences.letterSpacing
50
+ : defaults.letterSpacing !== undefined
51
+ ? defaults.letterSpacing
52
+ : null;
53
+ this.ligatures = typeof preferences.ligatures === "boolean"
54
+ ? preferences.ligatures
55
+ : defaults.ligatures ?? null;
56
+ this.lineHeight = preferences.lineHeight !== undefined
57
+ ? preferences.lineHeight
58
+ : defaults.lineHeight !== undefined
59
+ ? defaults.lineHeight
60
+ : null;
61
+ this.noRuby = typeof preferences.noRuby === "boolean"
62
+ ? preferences.noRuby
63
+ : defaults.noRuby ?? null;
64
+ this.paragraphIndent = preferences.paragraphIndent !== undefined
65
+ ? preferences.paragraphIndent
66
+ : defaults.paragraphIndent !== undefined
67
+ ? defaults.paragraphIndent
68
+ : null;
69
+ this.paragraphSpacing = preferences.paragraphSpacing !== undefined
70
+ ? preferences.paragraphSpacing
71
+ : defaults.paragraphSpacing !== undefined
72
+ ? defaults.paragraphSpacing
73
+ : null;
74
+ this.textAlign = preferences.textAlign || defaults.textAlign || null;
75
+ this.textNormalization = typeof preferences.textNormalization === "boolean"
76
+ ? preferences.textNormalization
77
+ : defaults.textNormalization ?? null;
78
+ this.wordSpacing = preferences.wordSpacing !== undefined
79
+ ? preferences.wordSpacing
80
+ : defaults.wordSpacing !== undefined
81
+ ? defaults.wordSpacing
82
+ : null;
83
+ }
82
84
  this.zoom = preferences.zoom !== undefined
83
85
  ? preferences.zoom
84
86
  : defaults.zoom !== undefined
@@ -2,6 +2,7 @@ import { Link, Locator, Publication, ReadingProgression } from "@readium/shared"
2
2
  import { VisualNavigator, VisualNavigatorViewport } from "../Navigator";
3
3
  import { Configurable } from "../preferences/Configurable";
4
4
  import { BasicTextSelection, CommsEventKey, FrameClickEvent } from "@readium/navigator-html-injectables";
5
+ import { WebPubFrameManager } from "./WebPubFrameManager";
5
6
  import { ManagerEventKey } from "../epub/EpubNavigator";
6
7
  import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences";
7
8
  import { IWebPubDefaults } from "./preferences/WebPubDefaults";
@@ -44,6 +45,12 @@ export declare class WebPubNavigator extends VisualNavigator implements Configur
44
45
  private updateCSS;
45
46
  private compileCSSProperties;
46
47
  private commitCSS;
48
+ /**
49
+ * Exposed to the public to compensate for lack of implemented readium conveniences
50
+ * TODO remove when settings management is incorporated
51
+ */
52
+ get _cframes(): (WebPubFrameManager | undefined)[];
53
+ private get hasDisplayTransformability();
47
54
  eventListener(key: CommsEventKey | ManagerEventKey, data: unknown): void;
48
55
  private determineModules;
49
56
  private attachListener;
@@ -1 +1 @@
1
- export declare const webPubStylesheet = "\n/* FontFamily */\n\n:root[style*=\"--USER__fontFamily\"] {\n font-family: var(--USER__fontFamily) !important;\n}\n\n:root[style*=\"--USER__fontFamily\"] * {\n font-family: revert !important;\n}\n\n/* FontWeight */\n\n:root[style*=\"--USER__fontWeight\"] body {\n font-weight: var(--USER__fontWeight) !important;\n}\n\n/* Attempt to handle known bolds */\n:root[style*=\"--USER__fontWeight\"] b,\n:root[style*=\"--USER__fontWeight\"] strong {\n font-weight: bolder;\n}\n\n/* Hyphens */\n\n:root[style*=\"--USER__bodyHyphens\"] {\n -webkit-hyphens: var(--USER__bodyHyphens) !important;\n -moz-hyphens: var(--USER__bodyHyphens) !important;\n -ms-hyphens: var(--USER__bodyHyphens) !important;\n -epub-hyphens: var(--USER__bodyHyphens) !important;\n hyphens: var(--USER__bodyHyphens) !important;\n}\n\n:root[style*=\"--USER__bodyHyphens\"] body,\n:root[style*=\"--USER__bodyHyphens\"] p,\n:root[style*=\"--USER__bodyHyphens\"] li,\n:root[style*=\"--USER__bodyHyphens\"] div,\n:root[style*=\"--USER__bodyHyphens\"] dd {\n -webkit-hyphens: inherit;\n -moz-hyphens: inherit;\n -ms-hyphens: inherit;\n -epub-hyphens: inherit;\n hyphens: inherit;\n}\n\n/* LetterSpacing */\n\n:root[style*=\"--USER__letterSpacing\"] h1,\n:root[style*=\"--USER__letterSpacing\"] h2,\n:root[style*=\"--USER__letterSpacing\"] h3,\n:root[style*=\"--USER__letterSpacing\"] h4,\n:root[style*=\"--USER__letterSpacing\"] h5,\n:root[style*=\"--USER__letterSpacing\"] h6,\n:root[style*=\"--USER__letterSpacing\"] p,\n:root[style*=\"--USER__letterSpacing\"] li,\n:root[style*=\"--USER__letterSpacing\"] div,\n:root[style*=\"--USER__letterSpacing\"] dt,\n:root[style*=\"--USER__letterSpacing\"] dd {\n letter-spacing: var(--USER__letterSpacing);\n font-variant: none;\n}\n\n/* Ligatures */\n\n:root[style*=\"--USER__ligatures\"] {\n font-variant-ligatures: var(--USER__ligatures) !important;\n}\n\n:root[style*=\"--USER__ligatures\"] * {\n font-variant-ligatures: inherit !important;\n}\n\n/* LineHeight */\n\n:root[style*=\"--USER__lineHeight\"] {\n line-height: var(--USER__lineHeight) !important;\n}\n\n:root[style*=\"--USER__lineHeight\"] body,\n:root[style*=\"--USER__lineHeight\"] p,\n:root[style*=\"--USER__lineHeight\"] li,\n:root[style*=\"--USER__lineHeight\"] div {\n line-height: inherit;\n}\n\n/* ParagraphIndent */\n\n:root[style*=\"--USER__paraIndent\"] p {\n text-indent: var(--USER__paraIndent) !important;\n}\n\n:root[style*=\"--USER__paraIndent\"] p *,\n:root[style*=\"--USER__paraIndent\"] p:first-letter {\n text-indent: 0 !important;\n}\n\n/* ParagraphSpacing */\n\n:root[style*=\"--USER__paraSpacing\"] p {\n margin-block: var(--USER__paraSpacing) !important;\n}\n\n/* Ruby */\n\n:root[style*=\"readium-noRuby-on\"] body rt,\n:root[style*=\"readium-noRuby-on\"] body rp {\n display: none;\n}\n\n/* TextAlign */\n\n:root[style*=\"--USER__textAlign\"] {\n text-align: var(--USER__textAlign);\n}\n\n:root[style*=\"--USER__textAlign\"] body,\n:root[style*=\"--USER__textAlign\"] p:not(blockquote p):not(figcaption p):not(hgroup p),\n:root[style*=\"--USER__textAlign\"] li,\n:root[style*=\"--USER__textAlign\"] dd {\n text-align: var(--USER__textAlign) !important;\n -moz-text-align-last: auto !important;\n -epub-text-align-last: auto !important;\n text-align-last: auto !important;\n}\n\n/* TextNormalize */\n\n:root[style*=\"readium-a11y-on\"] {\n font-weight: normal !important;\n font-style: normal !important;\n}\n\n:root[style*=\"readium-a11y-on\"] *:not(code):not(var):not(kbd):not(samp) {\n font-family: inherit !important;\n font-weight: inherit !important;\n font-style: inherit !important;\n}\n\n:root[style*=\"readium-a11y-on\"] * {\n text-decoration: none !important;\n font-variant-caps: normal !important;\n font-variant-position: normal !important;\n font-variant-numeric: normal !important;\n}\n\n:root[style*=\"readium-a11y-on\"] sup,\n:root[style*=\"readium-a11y-on\"] sub {\n font-size: 1rem !important;\n vertical-align: baseline !important;\n}\n\n/* Word Spacing */\n\n:root[style*=\"--USER__wordSpacing\"] h1,\n:root[style*=\"--USER__wordSpacing\"] h2,\n:root[style*=\"--USER__wordSpacing\"] h3,\n:root[style*=\"--USER__wordSpacing\"] h4,\n:root[style*=\"--USER__wordSpacing\"] h5,\n:root[style*=\"--USER__wordSpacing\"] h6,\n:root[style*=\"--USER__wordSpacing\"] p,\n:root[style*=\"--USER__wordSpacing\"] li,\n:root[style*=\"--USER__wordSpacing\"] div,\n:root[style*=\"--USER__wordSpacing\"] dt,\n:root[style*=\"--USER__wordSpacing\"] dd {\n word-spacing: var(--USER__wordSpacing);\n}\n\n/* Zoom */\n\n:root {\n --USER__zoom: 1;\n}\n\n:root[style*=\"--USER__zoom\"] body {\n zoom: var(--USER__zoom) !important;\n}\n\n@supports selector(figure:has(> img)) {\n :root[style*=\"--USER__zoom\"] figure:has(> img),\n :root[style*=\"--USER__zoom\"] figure:has(> video),\n :root[style*=\"--USER__zoom\"] figure:has(> svg),\n :root[style*=\"--USER__zoom\"] figure:has(> canvas),\n :root[style*=\"--USER__zoom\"] figure:has(> iframe),\n :root[style*=\"--USER__zoom\"] figure:has(> audio),\n :root[style*=\"--USER__zoom\"] div:has(> img),\n :root[style*=\"--USER__zoom\"] div:has(> video),\n :root[style*=\"--USER__zoom\"] div:has(> svg),\n :root[style*=\"--USER__zoom\"] div:has(> canvas),\n :root[style*=\"--USER__zoom\"] div:has(> iframe),\n :root[style*=\"--USER__zoom\"] div:has(> audio),\n :root[style*=\"--USER__zoom\"] table {\n zoom: calc(100% / var(--USER__zoom)) !important;\n }\n\n :root[style*=\"--USER__zoom\"] figcaption,\n :root[style*=\"--USER__zoom\"] caption,\n :root[style*=\"--USER__zoom\"] td,\n :root[style*=\"--USER__zoom\"] th {\n zoom: var(--USER__zoom) !important;\n }\n}\n";
1
+ export declare const webPubStylesheet = "\n/* TextAlign */\n\n:root[style*=\"--USER__textAlign\"] {\n text-align: var(--USER__textAlign);\n}\n\n:root[style*=\"--USER__textAlign\"] body,\n:root[style*=\"--USER__textAlign\"] p:not([class*=\"title\"]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+ *) > h1 + p):not(div:has(+ *) > p:has(+ h1)),\n:root[style*=\"--USER__textAlign\"] li,\n:root[style*=\"--USER__textAlign\"] dd {\n text-align: var(--USER__textAlign) !important;\n -moz-text-align-last: auto !important;\n -epub-text-align-last: auto !important;\n text-align-last: auto !important;\n}\n\n/* Hyphens */\n\n:root[style*=\"--USER__bodyHyphens\"] {\n -webkit-hyphens: var(--USER__bodyHyphens) !important;\n -moz-hyphens: var(--USER__bodyHyphens) !important;\n -ms-hyphens: var(--USER__bodyHyphens) !important;\n -epub-hyphens: var(--USER__bodyHyphens) !important;\n hyphens: var(--USER__bodyHyphens) !important;\n}\n\n:root[style*=\"--USER__bodyHyphens\"] body,\n:root[style*=\"--USER__bodyHyphens\"] p,\n:root[style*=\"--USER__bodyHyphens\"] li,\n:root[style*=\"--USER__bodyHyphens\"] div,\n:root[style*=\"--USER__bodyHyphens\"] dd {\n -webkit-hyphens: inherit;\n -moz-hyphens: inherit;\n -ms-hyphens: inherit;\n -epub-hyphens: inherit;\n hyphens: inherit;\n}\n\n/* FontFamily */\n\n:root[style*=\"--USER__fontFamily\"] {\n font-family: var(--USER__fontFamily) !important;\n}\n\n:root[style*=\"--USER__fontFamily\"] * {\n font-family: revert !important;\n}\n\n/* TextNormalize */\n\n:root[style*=\"readium-a11y-on\"] {\n font-weight: normal !important;\n font-style: normal !important;\n}\n\n:root[style*=\"readium-a11y-on\"] body *:not(code):not(var):not(kbd):not(samp) {\n font-family: inherit !important;\n font-weight: inherit !important;\n font-style: inherit !important;\n}\n\n:root[style*=\"readium-a11y-on\"] body * {\n text-decoration: none !important;\n font-variant-caps: normal !important;\n font-variant-position: normal !important;\n font-variant-numeric: normal !important;\n}\n\n:root[style*=\"readium-a11y-on\"] sup,\n:root[style*=\"readium-a11y-on\"] sub {\n font-size: 1rem !important;\n vertical-align: baseline !important;\n}\n\n/* Zoom */\n\n:root {\n --USER__zoom: 1;\n}\n\n:root[style*=\"--USER__zoom\"] body {\n zoom: var(--USER__zoom) !important;\n}\n\n@supports selector(figure:has(> img)) {\n :root[style*=\"--USER__zoom\"] figure:has(> img),\n :root[style*=\"--USER__zoom\"] figure:has(> video),\n :root[style*=\"--USER__zoom\"] figure:has(> svg),\n :root[style*=\"--USER__zoom\"] figure:has(> canvas),\n :root[style*=\"--USER__zoom\"] figure:has(> iframe),\n :root[style*=\"--USER__zoom\"] figure:has(> audio),\n :root[style*=\"--USER__zoom\"] div:has(> img),\n :root[style*=\"--USER__zoom\"] div:has(> video),\n :root[style*=\"--USER__zoom\"] div:has(> svg),\n :root[style*=\"--USER__zoom\"] div:has(> canvas),\n :root[style*=\"--USER__zoom\"] div:has(> iframe),\n :root[style*=\"--USER__zoom\"] div:has(> audio),\n :root[style*=\"--USER__zoom\"] table {\n zoom: calc(100% / var(--USER__zoom)) !important;\n }\n\n :root[style*=\"--USER__zoom\"] figcaption,\n :root[style*=\"--USER__zoom\"] caption,\n :root[style*=\"--USER__zoom\"] td,\n :root[style*=\"--USER__zoom\"] th {\n zoom: var(--USER__zoom) !important;\n }\n}\n\n/* LineHeight */\n\n:root[style*=\"--USER__lineHeight\"] {\n line-height: var(--USER__lineHeight) !important;\n}\n\n:root[style*=\"--USER__lineHeight\"] body,\n:root[style*=\"--USER__lineHeight\"] p,\n:root[style*=\"--USER__lineHeight\"] li,\n:root[style*=\"--USER__lineHeight\"] div {\n line-height: inherit;\n}\n\n/* ParagraphSpacing */\n\n:root[style*=\"--USER__paraSpacing\"] p {\n margin-block: var(--USER__paraSpacing) !important;\n}\n\n/* ParagraphIndent */\n\n:root[style*=\"--USER__paraIndent\"] p {\n text-indent: var(--USER__paraIndent) !important;\n}\n\n:root[style*=\"--USER__paraIndent\"] p *,\n:root[style*=\"--USER__paraIndent\"] p:first-letter {\n text-indent: 0 !important;\n}\n\n/* WordSpacing */\n\n:root[style*=\"--USER__wordSpacing\"] h1,\n:root[style*=\"--USER__wordSpacing\"] h2,\n:root[style*=\"--USER__wordSpacing\"] h3,\n:root[style*=\"--USER__wordSpacing\"] h4,\n:root[style*=\"--USER__wordSpacing\"] h5,\n:root[style*=\"--USER__wordSpacing\"] h6,\n:root[style*=\"--USER__wordSpacing\"] p,\n:root[style*=\"--USER__wordSpacing\"] li,\n:root[style*=\"--USER__wordSpacing\"] div,\n:root[style*=\"--USER__wordSpacing\"] dt,\n:root[style*=\"--USER__wordSpacing\"] dd {\n word-spacing: var(--USER__wordSpacing);\n}\n\n/* LetterSpacing */\n\n:root[style*=\"--USER__letterSpacing\"] h1,\n:root[style*=\"--USER__letterSpacing\"] h2,\n:root[style*=\"--USER__letterSpacing\"] h3,\n:root[style*=\"--USER__letterSpacing\"] h4,\n:root[style*=\"--USER__letterSpacing\"] h5,\n:root[style*=\"--USER__letterSpacing\"] h6,\n:root[style*=\"--USER__letterSpacing\"] p,\n:root[style*=\"--USER__letterSpacing\"] li,\n:root[style*=\"--USER__letterSpacing\"] div,\n:root[style*=\"--USER__letterSpacing\"] dt,\n:root[style*=\"--USER__letterSpacing\"] dd {\n letter-spacing: var(--USER__letterSpacing);\n font-variant: none;\n}\n\n/* FontWeight */\n\n:root[style*=\"--USER__fontWeight\"] body {\n font-weight: var(--USER__fontWeight) !important;\n}\n\n/* Attempt to handle known bolds */\n:root[style*=\"--USER__fontWeight\"] b,\n:root[style*=\"--USER__fontWeight\"] strong {\n font-weight: bolder;\n}\n\n/* Ruby */\n\n:root[style*=\"readium-noRuby-on\"] body rt,\n:root[style*=\"readium-noRuby-on\"] body rp {\n display: none;\n}\n\n/* Ligatures */\n\n:root[style*=\"--USER__ligatures\"] {\n font-variant-ligatures: var(--USER__ligatures) !important;\n}\n\n:root[style*=\"--USER__ligatures\"] * {\n font-variant-ligatures: inherit !important;\n}\n";
@@ -11,6 +11,7 @@ export declare class WebPubPreferencesEditor implements IPreferencesEditor {
11
11
  constructor(initialPreferences: WebPubPreferences, settings: WebPubSettings, metadata: Metadata);
12
12
  clear(): void;
13
13
  private updatePreference;
14
+ private get isDisplayTransformable();
14
15
  get fontFamily(): Preference<string>;
15
16
  get fontWeight(): RangePreference<number>;
16
17
  get hyphens(): BooleanPreference;
@@ -31,5 +31,5 @@ export declare class WebPubSettings implements ConfigurableSettings {
31
31
  textNormalization: boolean | null;
32
32
  wordSpacing: number | null;
33
33
  zoom: number | null;
34
- constructor(preferences: WebPubPreferences, defaults: WebPubDefaults);
34
+ constructor(preferences: WebPubPreferences, defaults: WebPubDefaults, hasDisplayTransformability: boolean);
35
35
  }