@readium/navigator 2.0.0-beta.6 → 2.0.0-beta.7
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/dist/index.js +604 -561
- package/dist/index.umd.cjs +12 -12
- package/package.json +2 -2
- package/src/epub/css/Properties.ts +16 -0
- package/src/epub/css/ReadiumCSS.ts +12 -0
- package/src/epub/preferences/EpubDefaults.ts +12 -0
- package/src/epub/preferences/EpubPreferences.ts +12 -0
- package/src/epub/preferences/EpubPreferencesEditor.ts +46 -0
- package/src/epub/preferences/EpubSettings.ts +30 -0
- package/types/src/epub/css/Properties.d.ts +4 -0
- package/types/src/epub/preferences/EpubDefaults.d.ts +4 -0
- package/types/src/epub/preferences/EpubPreferences.d.ts +4 -0
- package/types/src/epub/preferences/EpubPreferencesEditor.d.ts +2 -0
- package/types/src/epub/preferences/EpubSettings.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/navigator",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
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": "^0.5.25",
|
|
52
|
-
"@readium/css": ">=2.0.0-beta.
|
|
52
|
+
"@readium/css": ">=2.0.0-beta.15",
|
|
53
53
|
"@readium/navigator-html-injectables": "workspace:*",
|
|
54
54
|
"@readium/shared": "workspace:*",
|
|
55
55
|
"@types/path-browserify": "^1.0.3",
|
|
@@ -240,6 +240,10 @@ export interface IRSProperties {
|
|
|
240
240
|
sansSerifJa?: string | null;
|
|
241
241
|
sansSerifJaV?: string | null;
|
|
242
242
|
sansTf?: string | null;
|
|
243
|
+
scrollPaddingBottom?: number | null;
|
|
244
|
+
// scrollPaddingLeft?: number | null;
|
|
245
|
+
// scrollPaddingRight?: number | null;
|
|
246
|
+
scrollPaddingTop?: number | null;
|
|
243
247
|
secondaryColor?: string | null;
|
|
244
248
|
selectionBackgroundColor?: string | null;
|
|
245
249
|
selectionTextColor?: string | null;
|
|
@@ -280,6 +284,10 @@ export class RSProperties extends Properties {
|
|
|
280
284
|
sansSerifJa: string | null;
|
|
281
285
|
sansSerifJaV: string | null;
|
|
282
286
|
sansTf: string | null;
|
|
287
|
+
scrollPaddingBottom: number | null;
|
|
288
|
+
// scrollPaddingLeft: number | null;
|
|
289
|
+
// scrollPaddingRight: number | null;
|
|
290
|
+
scrollPaddingTop: number | null;
|
|
283
291
|
secondaryColor: string | null;
|
|
284
292
|
selectionBackgroundColor: string | null;
|
|
285
293
|
selectionTextColor: string | null;
|
|
@@ -317,6 +325,10 @@ export class RSProperties extends Properties {
|
|
|
317
325
|
this.paraIndent = props.paraIndent ?? null;
|
|
318
326
|
this.paraSpacing = props.paraSpacing ?? null;
|
|
319
327
|
this.primaryColor = props.primaryColor ?? null;
|
|
328
|
+
this.scrollPaddingBottom = props.scrollPaddingBottom ?? null;
|
|
329
|
+
// this.scrollPaddingLeft = props.scrollPaddingLeft ?? null;
|
|
330
|
+
// this.scrollPaddingRight = props.scrollPaddingRight ?? null;
|
|
331
|
+
this.scrollPaddingTop = props.scrollPaddingTop ?? null;
|
|
320
332
|
this.sansSerifJa = props.sansSerifJa ?? null;
|
|
321
333
|
this.sansSerifJaV = props.sansSerifJaV ?? null;
|
|
322
334
|
this.sansTf = props.sansTf ?? null;
|
|
@@ -362,6 +374,10 @@ export class RSProperties extends Properties {
|
|
|
362
374
|
if (this.sansSerifJa) cssProperties["--RS__sans-serif-ja"] = this.sansSerifJa;
|
|
363
375
|
if (this.sansSerifJaV) cssProperties["--RS__sans-serif-ja-v"] = this.sansSerifJaV;
|
|
364
376
|
if (this.sansTf) cssProperties["--RS__sansTf"] = this.sansTf;
|
|
377
|
+
if (this.scrollPaddingBottom != null) cssProperties["--RS__scrollPaddingBottom"] = this.toPx(this.scrollPaddingBottom);
|
|
378
|
+
// if (this.scrollPaddingLeft != null) cssProperties["--RS__scrollPaddingLeft"] = this.toPx(this.scrollPaddingLeft);
|
|
379
|
+
// if (this.scrollPaddingRight != null) cssProperties["--RS__scrollPaddingRight"] = this.toPx(this.scrollPaddingRight);
|
|
380
|
+
if (this.scrollPaddingTop != null) cssProperties["--RS__scrollPaddingTop"] = this.toPx(this.scrollPaddingTop);
|
|
365
381
|
if (this.secondaryColor) cssProperties["--RS__secondaryColor"] = this.secondaryColor;
|
|
366
382
|
if (this.selectionBackgroundColor) cssProperties["--RS__selectionBackgroundColor"] = this.selectionBackgroundColor;
|
|
367
383
|
if (this.selectionTextColor) cssProperties["--RS__selectionTextColor"] = this.selectionTextColor;
|
|
@@ -49,6 +49,18 @@ export class ReadiumCSS {
|
|
|
49
49
|
if (settings.pageGutter !== this.rsProperties.pageGutter)
|
|
50
50
|
this.rsProperties.pageGutter = settings.pageGutter;
|
|
51
51
|
|
|
52
|
+
if (settings.scrollPaddingBottom !== this.rsProperties.scrollPaddingBottom)
|
|
53
|
+
this.rsProperties.scrollPaddingBottom = settings.scrollPaddingBottom;
|
|
54
|
+
|
|
55
|
+
// if (settings.scrollPaddingLeft !== this.rsProperties.scrollPaddingLeft)
|
|
56
|
+
// this.rsProperties.scrollPaddingLeft = settings.scrollPaddingLeft;
|
|
57
|
+
|
|
58
|
+
// if (settings.scrollPaddingRight !== this.rsProperties.scrollPaddingRight)
|
|
59
|
+
// this.rsProperties.scrollPaddingRight = settings.scrollPaddingRight;
|
|
60
|
+
|
|
61
|
+
if (settings.scrollPaddingTop !== this.rsProperties.scrollPaddingTop)
|
|
62
|
+
this.rsProperties.scrollPaddingTop = settings.scrollPaddingTop;
|
|
63
|
+
|
|
52
64
|
// This has to be updated before pagination
|
|
53
65
|
// otherwise the metrics won’t be correct for line length
|
|
54
66
|
this.lineLengths.update({
|
|
@@ -51,6 +51,10 @@ export interface IEpubDefaults {
|
|
|
51
51
|
paragraphIndent?: number | null,
|
|
52
52
|
paragraphSpacing?: number | null,
|
|
53
53
|
scroll?: boolean | null,
|
|
54
|
+
scrollPaddingTop?: number | null,
|
|
55
|
+
scrollPaddingBottom?: number | null,
|
|
56
|
+
// scrollPaddingLeft?: number | null,
|
|
57
|
+
// scrollPaddingRight?: number | null,
|
|
54
58
|
selectionBackgroundColor?: string | null,
|
|
55
59
|
selectionTextColor?: string | null,
|
|
56
60
|
textAlign?: TextAlignment | null,
|
|
@@ -91,6 +95,10 @@ export class EpubDefaults {
|
|
|
91
95
|
paragraphIndent: number | null;
|
|
92
96
|
paragraphSpacing: number | null;
|
|
93
97
|
scroll: boolean | null;
|
|
98
|
+
scrollPaddingTop: number | null;
|
|
99
|
+
scrollPaddingBottom: number | null;
|
|
100
|
+
// scrollPaddingLeft: number | null;
|
|
101
|
+
// scrollPaddingRight: number | null;
|
|
94
102
|
selectionBackgroundColor: string | null;
|
|
95
103
|
selectionTextColor: string | null;
|
|
96
104
|
textAlign: TextAlignment | null;
|
|
@@ -132,6 +140,10 @@ export class EpubDefaults {
|
|
|
132
140
|
this.paragraphIndent = ensureNonNegative(defaults.paragraphIndent) ?? null;
|
|
133
141
|
this.paragraphSpacing = ensureNonNegative(defaults.paragraphSpacing) ?? null;
|
|
134
142
|
this.scroll = ensureBoolean(defaults.scroll) ?? false;
|
|
143
|
+
this.scrollPaddingTop = ensureNonNegative(defaults.scrollPaddingTop) ?? null;
|
|
144
|
+
this.scrollPaddingBottom = ensureNonNegative(defaults.scrollPaddingBottom) ?? null;
|
|
145
|
+
// this.scrollPaddingLeft = ensureNonNegative(defaults.scrollPaddingLeft) ?? null;
|
|
146
|
+
// this.scrollPaddingRight = ensureNonNegative(defaults.scrollPaddingRight) ?? null;
|
|
135
147
|
this.selectionBackgroundColor = ensureString(defaults.selectionBackgroundColor) || null;
|
|
136
148
|
this.selectionTextColor = ensureString(defaults.selectionTextColor) || null;
|
|
137
149
|
this.textAlign = ensureEnumValue<TextAlignment>(defaults.textAlign, TextAlignment) || null;
|
|
@@ -48,6 +48,10 @@ export interface IEpubPreferences {
|
|
|
48
48
|
paragraphIndent?: number | null,
|
|
49
49
|
paragraphSpacing?: number | null,
|
|
50
50
|
scroll?: boolean | null,
|
|
51
|
+
scrollPaddingTop?: number | null,
|
|
52
|
+
scrollPaddingBottom?: number | null,
|
|
53
|
+
// scrollPaddingLeft?: number | null,
|
|
54
|
+
// scrollPaddingRight?: number | null,
|
|
51
55
|
selectionBackgroundColor?: string | null,
|
|
52
56
|
selectionTextColor?: string | null,
|
|
53
57
|
textAlign?: TextAlignment | null,
|
|
@@ -88,6 +92,10 @@ export class EpubPreferences implements ConfigurablePreferences {
|
|
|
88
92
|
paragraphIndent?: number | null;
|
|
89
93
|
paragraphSpacing?: number | null;
|
|
90
94
|
scroll?: boolean | null;
|
|
95
|
+
scrollPaddingTop?: number | null;
|
|
96
|
+
scrollPaddingBottom?: number | null;
|
|
97
|
+
// scrollPaddingLeft?: number | null;
|
|
98
|
+
// scrollPaddingRight?: number | null;
|
|
91
99
|
selectionBackgroundColor?: string | null;
|
|
92
100
|
selectionTextColor?: string | null;
|
|
93
101
|
textAlign?: TextAlignment | null;
|
|
@@ -124,6 +132,10 @@ export class EpubPreferences implements ConfigurablePreferences {
|
|
|
124
132
|
this.paragraphIndent = ensureNonNegative(preferences.paragraphIndent);
|
|
125
133
|
this.paragraphSpacing = ensureNonNegative(preferences.paragraphSpacing);
|
|
126
134
|
this.scroll = ensureBoolean(preferences.scroll);
|
|
135
|
+
this.scrollPaddingTop = ensureNonNegative(preferences.scrollPaddingTop);
|
|
136
|
+
this.scrollPaddingBottom = ensureNonNegative(preferences.scrollPaddingBottom);
|
|
137
|
+
// this.scrollPaddingLeft = ensureNonNegative(preferences.scrollPaddingLeft);
|
|
138
|
+
// this.scrollPaddingRight = ensureNonNegative(preferences.scrollPaddingRight);
|
|
127
139
|
this.selectionBackgroundColor = ensureString(preferences.selectionBackgroundColor);
|
|
128
140
|
this.selectionTextColor = ensureString(preferences.selectionTextColor);
|
|
129
141
|
this.textAlign = ensureEnumValue<TextAlignment>(preferences.textAlign, TextAlignment);
|
|
@@ -383,6 +383,52 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
|
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
get scrollPaddingTop(): Preference<number> {
|
|
387
|
+
return new Preference<number>({
|
|
388
|
+
initialValue: this.preferences.scrollPaddingTop,
|
|
389
|
+
effectiveValue: this.settings.scrollPaddingTop || 0,
|
|
390
|
+
isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingTop !== null,
|
|
391
|
+
onChange: (newValue: number | null | undefined) => {
|
|
392
|
+
this.updatePreference("scrollPaddingTop", newValue || null);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
get scrollPaddingBottom(): Preference<number> {
|
|
398
|
+
return new Preference<number>({
|
|
399
|
+
initialValue: this.preferences.scrollPaddingBottom,
|
|
400
|
+
effectiveValue: this.settings.scrollPaddingBottom || 0,
|
|
401
|
+
isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingBottom !== null,
|
|
402
|
+
onChange: (newValue: number | null | undefined) => {
|
|
403
|
+
this.updatePreference("scrollPaddingBottom", newValue || null);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/*
|
|
409
|
+
get scrollPaddingLeft(): Preference<number> {
|
|
410
|
+
return new Preference<number>({
|
|
411
|
+
initialValue: this.preferences.scrollPaddingLeft,
|
|
412
|
+
effectiveValue: this.settings.scrollPaddingLeft || 0,
|
|
413
|
+
isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingLeft !== null,
|
|
414
|
+
onChange: (newValue: number | null | undefined) => {
|
|
415
|
+
this.updatePreference("scrollPaddingLeft", newValue || null);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
get scrollPaddingRight(): Preference<number> {
|
|
421
|
+
return new Preference<number>({
|
|
422
|
+
initialValue: this.preferences.scrollPaddingRight,
|
|
423
|
+
effectiveValue: this.settings.scrollPaddingRight || 0,
|
|
424
|
+
isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingRight !== null,
|
|
425
|
+
onChange: (newValue: number | null | undefined) => {
|
|
426
|
+
this.updatePreference("scrollPaddingRight", newValue || null);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
*/
|
|
431
|
+
|
|
386
432
|
get selectionBackgroundColor(): Preference<string> {
|
|
387
433
|
return new Preference<string>({
|
|
388
434
|
initialValue: this.preferences.selectionBackgroundColor,
|
|
@@ -35,6 +35,10 @@ export interface IEpubSettings {
|
|
|
35
35
|
paragraphIndent?: number | null,
|
|
36
36
|
paragraphSpacing?: number | null,
|
|
37
37
|
scroll?: boolean | null,
|
|
38
|
+
scrollPaddingTop?: number | null,
|
|
39
|
+
scrollPaddingBottom?: number | null,
|
|
40
|
+
// scrollPaddingLeft?: number | null,
|
|
41
|
+
// scrollPaddingRight?: number | null,
|
|
38
42
|
selectionBackgroundColor?: string | null,
|
|
39
43
|
selectionTextColor?: string | null,
|
|
40
44
|
textAlign?: TextAlignment | null,
|
|
@@ -75,6 +79,10 @@ export class EpubSettings implements ConfigurableSettings {
|
|
|
75
79
|
paragraphIndent: number | null;
|
|
76
80
|
paragraphSpacing: number | null;
|
|
77
81
|
scroll: boolean | null;
|
|
82
|
+
scrollPaddingTop: number | null;
|
|
83
|
+
scrollPaddingBottom: number | null;
|
|
84
|
+
// scrollPaddingLeft: number | null;
|
|
85
|
+
// scrollPaddingRight: number | null;
|
|
78
86
|
selectionBackgroundColor: string | null;
|
|
79
87
|
selectionTextColor: string | null;
|
|
80
88
|
textAlign: TextAlignment | null;
|
|
@@ -182,6 +190,28 @@ export class EpubSettings implements ConfigurableSettings {
|
|
|
182
190
|
this.scroll = typeof preferences.scroll === "boolean"
|
|
183
191
|
? preferences.scroll
|
|
184
192
|
: defaults.scroll ?? null;
|
|
193
|
+
this.scrollPaddingTop = preferences.scrollPaddingTop !== undefined
|
|
194
|
+
? preferences.scrollPaddingTop
|
|
195
|
+
: defaults.scrollPaddingTop !== undefined
|
|
196
|
+
? defaults.scrollPaddingTop
|
|
197
|
+
: null;
|
|
198
|
+
this.scrollPaddingBottom = preferences.scrollPaddingBottom !== undefined
|
|
199
|
+
? preferences.scrollPaddingBottom
|
|
200
|
+
: defaults.scrollPaddingBottom !== undefined
|
|
201
|
+
? defaults.scrollPaddingBottom
|
|
202
|
+
: null;
|
|
203
|
+
/*
|
|
204
|
+
this.scrollPaddingLeft = preferences.scrollPaddingLeft !== undefined
|
|
205
|
+
? preferences.scrollPaddingLeft
|
|
206
|
+
: defaults.scrollPaddingLeft !== undefined
|
|
207
|
+
? defaults.scrollPaddingLeft
|
|
208
|
+
: null;
|
|
209
|
+
this.scrollPaddingRight = preferences.scrollPaddingRight !== undefined
|
|
210
|
+
? preferences.scrollPaddingRight
|
|
211
|
+
: defaults.scrollPaddingRight !== undefined
|
|
212
|
+
? defaults.scrollPaddingRight
|
|
213
|
+
: null;
|
|
214
|
+
*/
|
|
185
215
|
this.selectionBackgroundColor = preferences.selectionBackgroundColor || defaults.selectionBackgroundColor || null;
|
|
186
216
|
this.selectionTextColor = preferences.selectionTextColor || defaults.selectionTextColor || null;
|
|
187
217
|
this.textAlign = preferences.textAlign || defaults.textAlign || null;
|
|
@@ -122,6 +122,8 @@ export interface IRSProperties {
|
|
|
122
122
|
sansSerifJa?: string | null;
|
|
123
123
|
sansSerifJaV?: string | null;
|
|
124
124
|
sansTf?: string | null;
|
|
125
|
+
scrollPaddingBottom?: number | null;
|
|
126
|
+
scrollPaddingTop?: number | null;
|
|
125
127
|
secondaryColor?: string | null;
|
|
126
128
|
selectionBackgroundColor?: string | null;
|
|
127
129
|
selectionTextColor?: string | null;
|
|
@@ -161,6 +163,8 @@ export declare class RSProperties extends Properties {
|
|
|
161
163
|
sansSerifJa: string | null;
|
|
162
164
|
sansSerifJaV: string | null;
|
|
163
165
|
sansTf: string | null;
|
|
166
|
+
scrollPaddingBottom: number | null;
|
|
167
|
+
scrollPaddingTop: number | null;
|
|
164
168
|
secondaryColor: string | null;
|
|
165
169
|
selectionBackgroundColor: string | null;
|
|
166
170
|
selectionTextColor: string | null;
|
|
@@ -29,6 +29,8 @@ export interface IEpubDefaults {
|
|
|
29
29
|
paragraphIndent?: number | null;
|
|
30
30
|
paragraphSpacing?: number | null;
|
|
31
31
|
scroll?: boolean | null;
|
|
32
|
+
scrollPaddingTop?: number | null;
|
|
33
|
+
scrollPaddingBottom?: number | null;
|
|
32
34
|
selectionBackgroundColor?: string | null;
|
|
33
35
|
selectionTextColor?: string | null;
|
|
34
36
|
textAlign?: TextAlignment | null;
|
|
@@ -68,6 +70,8 @@ export declare class EpubDefaults {
|
|
|
68
70
|
paragraphIndent: number | null;
|
|
69
71
|
paragraphSpacing: number | null;
|
|
70
72
|
scroll: boolean | null;
|
|
73
|
+
scrollPaddingTop: number | null;
|
|
74
|
+
scrollPaddingBottom: number | null;
|
|
71
75
|
selectionBackgroundColor: string | null;
|
|
72
76
|
selectionTextColor: string | null;
|
|
73
77
|
textAlign: TextAlignment | null;
|
|
@@ -30,6 +30,8 @@ export interface IEpubPreferences {
|
|
|
30
30
|
paragraphIndent?: number | null;
|
|
31
31
|
paragraphSpacing?: number | null;
|
|
32
32
|
scroll?: boolean | null;
|
|
33
|
+
scrollPaddingTop?: number | null;
|
|
34
|
+
scrollPaddingBottom?: number | null;
|
|
33
35
|
selectionBackgroundColor?: string | null;
|
|
34
36
|
selectionTextColor?: string | null;
|
|
35
37
|
textAlign?: TextAlignment | null;
|
|
@@ -69,6 +71,8 @@ export declare class EpubPreferences implements ConfigurablePreferences {
|
|
|
69
71
|
paragraphIndent?: number | null;
|
|
70
72
|
paragraphSpacing?: number | null;
|
|
71
73
|
scroll?: boolean | null;
|
|
74
|
+
scrollPaddingTop?: number | null;
|
|
75
|
+
scrollPaddingBottom?: number | null;
|
|
72
76
|
selectionBackgroundColor?: string | null;
|
|
73
77
|
selectionTextColor?: string | null;
|
|
74
78
|
textAlign?: TextAlignment | null;
|
|
@@ -41,6 +41,8 @@ export declare class EpubPreferencesEditor implements IPreferencesEditor {
|
|
|
41
41
|
get paragraphIndent(): RangePreference<number>;
|
|
42
42
|
get paragraphSpacing(): RangePreference<number>;
|
|
43
43
|
get scroll(): BooleanPreference;
|
|
44
|
+
get scrollPaddingTop(): Preference<number>;
|
|
45
|
+
get scrollPaddingBottom(): Preference<number>;
|
|
44
46
|
get selectionBackgroundColor(): Preference<string>;
|
|
45
47
|
get selectionTextColor(): Preference<string>;
|
|
46
48
|
get textAlign(): EnumPreference<TextAlignment>;
|
|
@@ -32,6 +32,8 @@ export interface IEpubSettings {
|
|
|
32
32
|
paragraphIndent?: number | null;
|
|
33
33
|
paragraphSpacing?: number | null;
|
|
34
34
|
scroll?: boolean | null;
|
|
35
|
+
scrollPaddingTop?: number | null;
|
|
36
|
+
scrollPaddingBottom?: number | null;
|
|
35
37
|
selectionBackgroundColor?: string | null;
|
|
36
38
|
selectionTextColor?: string | null;
|
|
37
39
|
textAlign?: TextAlignment | null;
|
|
@@ -71,6 +73,8 @@ export declare class EpubSettings implements ConfigurableSettings {
|
|
|
71
73
|
paragraphIndent: number | null;
|
|
72
74
|
paragraphSpacing: number | null;
|
|
73
75
|
scroll: boolean | null;
|
|
76
|
+
scrollPaddingTop: number | null;
|
|
77
|
+
scrollPaddingBottom: number | null;
|
|
74
78
|
selectionBackgroundColor: string | null;
|
|
75
79
|
selectionTextColor: string | null;
|
|
76
80
|
textAlign: TextAlignment | null;
|