@readium/navigator 2.2.3 → 2.2.4
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 +805 -968
- package/dist/index.umd.cjs +33 -221
- package/package.json +2 -2
- package/src/epub/preferences/EpubPreferencesEditor.ts +24 -3
- package/src/webpub/WebPubBlobBuilder.ts +17 -8
- package/src/webpub/css/Properties.ts +8 -0
- package/src/webpub/css/WebPubCSS.ts +2 -0
- package/src/webpub/css/index.ts +1 -2
- package/src/webpub/preferences/WebPubDefaults.ts +12 -0
- package/src/webpub/preferences/WebPubPreferences.ts +6 -0
- package/src/webpub/preferences/WebPubPreferencesEditor.ts +22 -0
- package/src/webpub/preferences/WebPubSettings.ts +17 -0
- package/types/src/webpub/css/Properties.d.ts +4 -0
- package/types/src/webpub/css/index.d.ts +0 -1
- package/types/src/webpub/preferences/WebPubDefaults.d.ts +4 -0
- package/types/src/webpub/preferences/WebPubPreferences.d.ts +4 -0
- package/types/src/webpub/preferences/WebPubPreferencesEditor.d.ts +2 -0
- package/types/src/webpub/preferences/WebPubSettings.d.ts +4 -0
- package/src/webpub/css/WebPubStylesheet.ts +0 -205
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/navigator",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
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.
|
|
52
|
+
"@readium/css": "2.0.0-beta.22",
|
|
53
53
|
"@readium/navigator-html-injectables": "workspace:*",
|
|
54
54
|
"@readium/shared": "workspace:*",
|
|
55
55
|
"@types/path-browserify": "^1.0.3",
|
|
@@ -256,9 +256,30 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
|
|
|
256
256
|
return new BooleanPreference({
|
|
257
257
|
initialValue: this.preferences.ligatures,
|
|
258
258
|
effectiveValue: this.settings.ligatures || true,
|
|
259
|
-
isEffective:
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
isEffective: (() => {
|
|
260
|
+
// Always respect explicit null (disabled) preference
|
|
261
|
+
if (this.preferences.ligatures === null) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Disable for fixed layout
|
|
266
|
+
if (this.layout === Layout.fixed) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Check for languages/scripts that should disable ligatures
|
|
271
|
+
// ReadiumCSS does not apply in CJK
|
|
272
|
+
const primaryLang = this.metadata?.languages?.[0]?.toLowerCase();
|
|
273
|
+
if (primaryLang) {
|
|
274
|
+
// Disable for Chinese, Japanese, Korean, and Traditional Mongolian (mn-Mong)
|
|
275
|
+
if (["zh", "ja", "ko", "mn-mong"].some(lang => primaryLang.startsWith(lang))) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Enable by default
|
|
281
|
+
return true;
|
|
282
|
+
})(),
|
|
262
283
|
onChange: (newValue: boolean | null | undefined) => {
|
|
263
284
|
this.updatePreference("ligatures", newValue || null);
|
|
264
285
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Link, Publication } from "@readium/shared";
|
|
2
|
-
import { webPubStylesheet } from "./css/WebPubStylesheet";
|
|
3
2
|
|
|
4
|
-
//
|
|
3
|
+
// Readium CSS imports
|
|
4
|
+
// The "?inline" query is to prevent some bundlers from injecting these into the page (e.g. vite)
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import readiumCSSWebPub from "@readium/css/css/dist/webPub/ReadiumCSS-webPub.css?inline";
|
|
7
|
+
|
|
8
|
+
// Utilities
|
|
5
9
|
const blobify = (source: string, type: string) => URL.createObjectURL(new Blob([source], { type }));
|
|
6
10
|
const stripJS = (source: string) => source.replace(/\/\/.*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n/g, "").replace(/\s+/g, " ");
|
|
11
|
+
const stripCSS = (source: string) => source.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, '').replace(/ {2,}/g, ' ')
|
|
12
|
+
// Fully resolve absolute local URLs created by bundlers since it's going into a blob
|
|
13
|
+
.replace(/url\((?!(https?:)?\/\/)("?)\/([^\)]+)/g, `url($2${window.location.origin}/$3`);
|
|
7
14
|
const scriptify = (doc: Document, source: string) => {
|
|
8
15
|
const s = doc.createElement("script");
|
|
9
16
|
s.dataset.readium = "true";
|
|
@@ -11,16 +18,18 @@ const scriptify = (doc: Document, source: string) => {
|
|
|
11
18
|
return s;
|
|
12
19
|
}
|
|
13
20
|
const styleify = (doc: Document, source: string) => {
|
|
14
|
-
const s = doc.createElement("
|
|
21
|
+
const s = doc.createElement("link");
|
|
15
22
|
s.dataset.readium = "true";
|
|
16
|
-
s.
|
|
23
|
+
s.rel = "stylesheet";
|
|
24
|
+
s.type = "text/css";
|
|
25
|
+
s.href = source.startsWith("blob:") ? source : blobify(source, "text/css");
|
|
17
26
|
return s;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
type CacheFunction = () => string;
|
|
21
30
|
const resourceBlobCache = new Map<string, string>();
|
|
22
31
|
const cached = (key: string, cacher: CacheFunction) => {
|
|
23
|
-
if
|
|
32
|
+
if(resourceBlobCache.has(key)) return resourceBlobCache.get(key)!;
|
|
24
33
|
const value = cacher();
|
|
25
34
|
resourceBlobCache.set(key, value);
|
|
26
35
|
return value;
|
|
@@ -103,9 +112,9 @@ export class WebPubBlobBuilder {
|
|
|
103
112
|
private finalizeDOM(doc: Document, base: string | undefined, mediaType: any, txt?: string, cssProperties?: { [key: string]: string }): string {
|
|
104
113
|
if(!doc) return "";
|
|
105
114
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
// ReadiumCSS WebPub
|
|
116
|
+
doc.head.appendChild(styleify(doc, cached("ReadiumCSS-webpub", () => blobify(stripCSS(readiumCSSWebPub), "text/css"))));
|
|
117
|
+
|
|
109
118
|
if (cssProperties) {
|
|
110
119
|
this.setProperties(cssProperties, doc);
|
|
111
120
|
}
|
|
@@ -6,6 +6,8 @@ export interface IWebUserProperties {
|
|
|
6
6
|
bodyHyphens?: BodyHyphens | null;
|
|
7
7
|
fontFamily?: string | null;
|
|
8
8
|
fontWeight?: number | null;
|
|
9
|
+
iOSPatch?: boolean | null;
|
|
10
|
+
iPadOSPatch?: boolean | null;
|
|
9
11
|
letterSpacing?: number | null;
|
|
10
12
|
ligatures?: Ligatures | null;
|
|
11
13
|
lineHeight?: number | null;
|
|
@@ -22,6 +24,8 @@ export class WebUserProperties extends Properties {
|
|
|
22
24
|
bodyHyphens: BodyHyphens | null;
|
|
23
25
|
fontFamily: string | null;
|
|
24
26
|
fontWeight: number | null;
|
|
27
|
+
iOSPatch: boolean | null;
|
|
28
|
+
iPadOSPatch: boolean | null;
|
|
25
29
|
letterSpacing: number | null;
|
|
26
30
|
ligatures: Ligatures | null;
|
|
27
31
|
lineHeight: number | null;
|
|
@@ -38,6 +42,8 @@ export class WebUserProperties extends Properties {
|
|
|
38
42
|
this.bodyHyphens = props.bodyHyphens ?? null;
|
|
39
43
|
this.fontFamily = props.fontFamily ?? null;
|
|
40
44
|
this.fontWeight = props.fontWeight ?? null;
|
|
45
|
+
this.iOSPatch = props.iOSPatch ?? null;
|
|
46
|
+
this.iPadOSPatch = props.iPadOSPatch ?? null;
|
|
41
47
|
this.letterSpacing = props.letterSpacing ?? null;
|
|
42
48
|
this.ligatures = props.ligatures ?? null;
|
|
43
49
|
this.lineHeight = props.lineHeight ?? null;
|
|
@@ -56,6 +62,8 @@ export class WebUserProperties extends Properties {
|
|
|
56
62
|
if (this.bodyHyphens) cssProperties["--USER__bodyHyphens"] = this.bodyHyphens;
|
|
57
63
|
if (this.fontFamily) cssProperties["--USER__fontFamily"] = this.fontFamily;
|
|
58
64
|
if (this.fontWeight != null) cssProperties["--USER__fontWeight"] = this.toUnitless(this.fontWeight);
|
|
65
|
+
if (this.iOSPatch) cssProperties["--USER__iOSPatch"] = this.toFlag("iOSPatch");
|
|
66
|
+
if (this.iPadOSPatch) cssProperties["--USER__iPadOSPatch"] = this.toFlag("iPadOSPatch");
|
|
59
67
|
if (this.letterSpacing != null) cssProperties["--USER__letterSpacing"] = this.toRem(this.letterSpacing);
|
|
60
68
|
if (this.ligatures) cssProperties["--USER__ligatures"] = this.ligatures;
|
|
61
69
|
if (this.lineHeight != null) cssProperties["--USER__lineHeight"] = this.toUnitless(this.lineHeight);
|
|
@@ -22,6 +22,8 @@ export class WebPubCSS {
|
|
|
22
22
|
: "none",
|
|
23
23
|
fontFamily: settings.fontFamily,
|
|
24
24
|
fontWeight: settings.fontWeight,
|
|
25
|
+
iOSPatch: settings.iOSPatch,
|
|
26
|
+
iPadOSPatch: settings.iPadOSPatch,
|
|
25
27
|
letterSpacing: settings.letterSpacing,
|
|
26
28
|
ligatures: typeof settings.ligatures !== "boolean"
|
|
27
29
|
? null
|
package/src/webpub/css/index.ts
CHANGED
|
@@ -12,10 +12,14 @@ import {
|
|
|
12
12
|
ensureString
|
|
13
13
|
} from "../../preferences/guards";
|
|
14
14
|
|
|
15
|
+
import { sMLWithRequest } from "../../helpers";
|
|
16
|
+
|
|
15
17
|
export interface IWebPubDefaults {
|
|
16
18
|
fontFamily?: string | null,
|
|
17
19
|
fontWeight?: number | null,
|
|
18
20
|
hyphens?: boolean | null,
|
|
21
|
+
iOSPatch?: boolean | null,
|
|
22
|
+
iPadOSPatch?: boolean | null,
|
|
19
23
|
letterSpacing?: number | null,
|
|
20
24
|
ligatures?: boolean | null,
|
|
21
25
|
lineHeight?: number | null,
|
|
@@ -32,6 +36,8 @@ export class WebPubDefaults {
|
|
|
32
36
|
fontFamily: string | null;
|
|
33
37
|
fontWeight: number | null;
|
|
34
38
|
hyphens: boolean | null;
|
|
39
|
+
iOSPatch: boolean | null;
|
|
40
|
+
iPadOSPatch: boolean | null;
|
|
35
41
|
letterSpacing: number | null;
|
|
36
42
|
ligatures: boolean | null;
|
|
37
43
|
lineHeight: number | null;
|
|
@@ -47,6 +53,12 @@ export class WebPubDefaults {
|
|
|
47
53
|
this.fontFamily = ensureString(defaults.fontFamily) || null;
|
|
48
54
|
this.fontWeight = ensureValueInRange(defaults.fontWeight, fontWeightRangeConfig.range) || null;
|
|
49
55
|
this.hyphens = ensureBoolean(defaults.hyphens) ?? null;
|
|
56
|
+
this.iOSPatch = defaults.iOSPatch === false
|
|
57
|
+
? false
|
|
58
|
+
: ((sMLWithRequest.OS.iOS || sMLWithRequest.OS.iPadOS) && sMLWithRequest.iOSRequest === "mobile");
|
|
59
|
+
this.iPadOSPatch = defaults.iPadOSPatch === false
|
|
60
|
+
? false
|
|
61
|
+
: (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop");
|
|
50
62
|
this.letterSpacing = ensureNonNegative(defaults.letterSpacing) || null;
|
|
51
63
|
this.ligatures = ensureBoolean(defaults.ligatures) ?? null;
|
|
52
64
|
this.lineHeight = ensureNonNegative(defaults.lineHeight) || null;
|
|
@@ -18,6 +18,8 @@ export interface IWebPubPreferences {
|
|
|
18
18
|
fontFamily?: string | null,
|
|
19
19
|
fontWeight?: number | null,
|
|
20
20
|
hyphens?: boolean | null,
|
|
21
|
+
iOSPatch?: boolean | null,
|
|
22
|
+
iPadOSPatch?: boolean | null,
|
|
21
23
|
letterSpacing?: number | null,
|
|
22
24
|
ligatures?: boolean | null,
|
|
23
25
|
lineHeight?: number | null,
|
|
@@ -34,6 +36,8 @@ export class WebPubPreferences implements ConfigurablePreferences {
|
|
|
34
36
|
fontFamily?: string | null;
|
|
35
37
|
fontWeight?: number | null;
|
|
36
38
|
hyphens?: boolean | null;
|
|
39
|
+
iOSPatch?: boolean | null;
|
|
40
|
+
iPadOSPatch?: boolean | null;
|
|
37
41
|
letterSpacing?: number | null;
|
|
38
42
|
ligatures?: boolean | null;
|
|
39
43
|
lineHeight?: number | null;
|
|
@@ -49,6 +53,8 @@ export class WebPubPreferences implements ConfigurablePreferences {
|
|
|
49
53
|
this.fontFamily = ensureString(preferences.fontFamily);
|
|
50
54
|
this.fontWeight = ensureValueInRange(preferences.fontWeight, fontWeightRangeConfig.range);
|
|
51
55
|
this.hyphens = ensureBoolean(preferences.hyphens);
|
|
56
|
+
this.iOSPatch = ensureBoolean(preferences.iOSPatch);
|
|
57
|
+
this.iPadOSPatch = ensureBoolean(preferences.iPadOSPatch);
|
|
52
58
|
this.letterSpacing = ensureNonNegative(preferences.letterSpacing);
|
|
53
59
|
this.ligatures = ensureBoolean(preferences.ligatures);
|
|
54
60
|
this.lineHeight = ensureNonNegative(preferences.lineHeight);
|
|
@@ -74,6 +74,28 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
get iOSPatch(): BooleanPreference {
|
|
78
|
+
return new BooleanPreference({
|
|
79
|
+
initialValue: this.preferences.iOSPatch,
|
|
80
|
+
effectiveValue: this.settings.iOSPatch || false,
|
|
81
|
+
isEffective: true,
|
|
82
|
+
onChange: (newValue: boolean | null | undefined) => {
|
|
83
|
+
this.updatePreference("iOSPatch", newValue || null);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get iPadOSPatch(): BooleanPreference {
|
|
89
|
+
return new BooleanPreference({
|
|
90
|
+
initialValue: this.preferences.iPadOSPatch,
|
|
91
|
+
effectiveValue: this.settings.iPadOSPatch || false,
|
|
92
|
+
isEffective: true,
|
|
93
|
+
onChange: (newValue: boolean | null | undefined) => {
|
|
94
|
+
this.updatePreference("iPadOSPatch", newValue || null);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
77
99
|
get letterSpacing(): RangePreference<number> {
|
|
78
100
|
return new RangePreference<number>({
|
|
79
101
|
initialValue: this.preferences.letterSpacing,
|
|
@@ -3,10 +3,14 @@ import { TextAlignment } from "../../preferences/Types";
|
|
|
3
3
|
import { WebPubDefaults } from "./WebPubDefaults";
|
|
4
4
|
import { WebPubPreferences } from "./WebPubPreferences";
|
|
5
5
|
|
|
6
|
+
import { sMLWithRequest } from "../../helpers";
|
|
7
|
+
|
|
6
8
|
export interface IWebPubSettings {
|
|
7
9
|
fontFamily?: string | null,
|
|
8
10
|
fontWeight?: number | null,
|
|
9
11
|
hyphens?: boolean | null,
|
|
12
|
+
iOSPatch?: boolean | null,
|
|
13
|
+
iPadOSPatch?: boolean | null,
|
|
10
14
|
letterSpacing?: number | null,
|
|
11
15
|
ligatures?: boolean | null,
|
|
12
16
|
lineHeight?: number | null,
|
|
@@ -23,6 +27,8 @@ export class WebPubSettings implements ConfigurableSettings {
|
|
|
23
27
|
fontFamily: string | null = null;
|
|
24
28
|
fontWeight: number | null = null;
|
|
25
29
|
hyphens: boolean | null = null;
|
|
30
|
+
iOSPatch: boolean | null = null;
|
|
31
|
+
iPadOSPatch: boolean | null = null;
|
|
26
32
|
letterSpacing: number | null = null;
|
|
27
33
|
ligatures: boolean | null = null;
|
|
28
34
|
lineHeight: number | null = null;
|
|
@@ -45,6 +51,16 @@ export class WebPubSettings implements ConfigurableSettings {
|
|
|
45
51
|
this.hyphens = typeof preferences.hyphens === "boolean"
|
|
46
52
|
? preferences.hyphens
|
|
47
53
|
: defaults.hyphens ?? null;
|
|
54
|
+
this.iOSPatch = preferences.iOSPatch === false
|
|
55
|
+
? false
|
|
56
|
+
: preferences.iOSPatch === true
|
|
57
|
+
? ((sMLWithRequest.OS.iOS || sMLWithRequest.OS.iPadOS) && sMLWithRequest.iOSRequest === "mobile")
|
|
58
|
+
: defaults.iOSPatch;
|
|
59
|
+
this.iPadOSPatch = preferences.iPadOSPatch === false
|
|
60
|
+
? false
|
|
61
|
+
: preferences.iPadOSPatch === true
|
|
62
|
+
? (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop")
|
|
63
|
+
: defaults.iPadOSPatch;
|
|
48
64
|
this.letterSpacing = preferences.letterSpacing !== undefined
|
|
49
65
|
? preferences.letterSpacing
|
|
50
66
|
: defaults.letterSpacing !== undefined
|
|
@@ -81,6 +97,7 @@ export class WebPubSettings implements ConfigurableSettings {
|
|
|
81
97
|
? defaults.wordSpacing
|
|
82
98
|
: null;
|
|
83
99
|
}
|
|
100
|
+
|
|
84
101
|
this.zoom = preferences.zoom !== undefined
|
|
85
102
|
? preferences.zoom
|
|
86
103
|
: defaults.zoom !== undefined
|
|
@@ -5,6 +5,8 @@ export interface IWebUserProperties {
|
|
|
5
5
|
bodyHyphens?: BodyHyphens | null;
|
|
6
6
|
fontFamily?: string | null;
|
|
7
7
|
fontWeight?: number | null;
|
|
8
|
+
iOSPatch?: boolean | null;
|
|
9
|
+
iPadOSPatch?: boolean | null;
|
|
8
10
|
letterSpacing?: number | null;
|
|
9
11
|
ligatures?: Ligatures | null;
|
|
10
12
|
lineHeight?: number | null;
|
|
@@ -20,6 +22,8 @@ export declare class WebUserProperties extends Properties {
|
|
|
20
22
|
bodyHyphens: BodyHyphens | null;
|
|
21
23
|
fontFamily: string | null;
|
|
22
24
|
fontWeight: number | null;
|
|
25
|
+
iOSPatch: boolean | null;
|
|
26
|
+
iPadOSPatch: boolean | null;
|
|
23
27
|
letterSpacing: number | null;
|
|
24
28
|
ligatures: Ligatures | null;
|
|
25
29
|
lineHeight: number | null;
|
|
@@ -3,6 +3,8 @@ export interface IWebPubDefaults {
|
|
|
3
3
|
fontFamily?: string | null;
|
|
4
4
|
fontWeight?: number | null;
|
|
5
5
|
hyphens?: boolean | null;
|
|
6
|
+
iOSPatch?: boolean | null;
|
|
7
|
+
iPadOSPatch?: boolean | null;
|
|
6
8
|
letterSpacing?: number | null;
|
|
7
9
|
ligatures?: boolean | null;
|
|
8
10
|
lineHeight?: number | null;
|
|
@@ -18,6 +20,8 @@ export declare class WebPubDefaults {
|
|
|
18
20
|
fontFamily: string | null;
|
|
19
21
|
fontWeight: number | null;
|
|
20
22
|
hyphens: boolean | null;
|
|
23
|
+
iOSPatch: boolean | null;
|
|
24
|
+
iPadOSPatch: boolean | null;
|
|
21
25
|
letterSpacing: number | null;
|
|
22
26
|
ligatures: boolean | null;
|
|
23
27
|
lineHeight: number | null;
|
|
@@ -4,6 +4,8 @@ export interface IWebPubPreferences {
|
|
|
4
4
|
fontFamily?: string | null;
|
|
5
5
|
fontWeight?: number | null;
|
|
6
6
|
hyphens?: boolean | null;
|
|
7
|
+
iOSPatch?: boolean | null;
|
|
8
|
+
iPadOSPatch?: boolean | null;
|
|
7
9
|
letterSpacing?: number | null;
|
|
8
10
|
ligatures?: boolean | null;
|
|
9
11
|
lineHeight?: number | null;
|
|
@@ -19,6 +21,8 @@ export declare class WebPubPreferences implements ConfigurablePreferences {
|
|
|
19
21
|
fontFamily?: string | null;
|
|
20
22
|
fontWeight?: number | null;
|
|
21
23
|
hyphens?: boolean | null;
|
|
24
|
+
iOSPatch?: boolean | null;
|
|
25
|
+
iPadOSPatch?: boolean | null;
|
|
22
26
|
letterSpacing?: number | null;
|
|
23
27
|
ligatures?: boolean | null;
|
|
24
28
|
lineHeight?: number | null;
|
|
@@ -15,6 +15,8 @@ export declare class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
15
15
|
get fontFamily(): Preference<string>;
|
|
16
16
|
get fontWeight(): RangePreference<number>;
|
|
17
17
|
get hyphens(): BooleanPreference;
|
|
18
|
+
get iOSPatch(): BooleanPreference;
|
|
19
|
+
get iPadOSPatch(): BooleanPreference;
|
|
18
20
|
get letterSpacing(): RangePreference<number>;
|
|
19
21
|
get ligatures(): BooleanPreference;
|
|
20
22
|
get lineHeight(): RangePreference<number>;
|
|
@@ -6,6 +6,8 @@ export interface IWebPubSettings {
|
|
|
6
6
|
fontFamily?: string | null;
|
|
7
7
|
fontWeight?: number | null;
|
|
8
8
|
hyphens?: boolean | null;
|
|
9
|
+
iOSPatch?: boolean | null;
|
|
10
|
+
iPadOSPatch?: boolean | null;
|
|
9
11
|
letterSpacing?: number | null;
|
|
10
12
|
ligatures?: boolean | null;
|
|
11
13
|
lineHeight?: number | null;
|
|
@@ -21,6 +23,8 @@ export declare class WebPubSettings implements ConfigurableSettings {
|
|
|
21
23
|
fontFamily: string | null;
|
|
22
24
|
fontWeight: number | null;
|
|
23
25
|
hyphens: boolean | null;
|
|
26
|
+
iOSPatch: boolean | null;
|
|
27
|
+
iPadOSPatch: boolean | null;
|
|
24
28
|
letterSpacing: number | null;
|
|
25
29
|
ligatures: boolean | null;
|
|
26
30
|
lineHeight: number | null;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
// WebPubCSS is equivalent to ReadiumCSS for WebPub
|
|
2
|
-
// Respects the stylesheet order from after
|
|
3
|
-
|
|
4
|
-
export const webPubStylesheet = `
|
|
5
|
-
/* TextAlign */
|
|
6
|
-
|
|
7
|
-
:root[style*="--USER__textAlign"] {
|
|
8
|
-
text-align: var(--USER__textAlign);
|
|
9
|
-
}
|
|
10
|
-
|
|
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;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* Hyphens */
|
|
22
|
-
|
|
23
|
-
:root[style*="--USER__bodyHyphens"] {
|
|
24
|
-
-webkit-hyphens: var(--USER__bodyHyphens) !important;
|
|
25
|
-
-moz-hyphens: var(--USER__bodyHyphens) !important;
|
|
26
|
-
-ms-hyphens: var(--USER__bodyHyphens) !important;
|
|
27
|
-
-epub-hyphens: var(--USER__bodyHyphens) !important;
|
|
28
|
-
hyphens: var(--USER__bodyHyphens) !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
:root[style*="--USER__bodyHyphens"] body,
|
|
32
|
-
:root[style*="--USER__bodyHyphens"] p,
|
|
33
|
-
:root[style*="--USER__bodyHyphens"] li,
|
|
34
|
-
:root[style*="--USER__bodyHyphens"] div,
|
|
35
|
-
:root[style*="--USER__bodyHyphens"] dd {
|
|
36
|
-
-webkit-hyphens: inherit;
|
|
37
|
-
-moz-hyphens: inherit;
|
|
38
|
-
-ms-hyphens: inherit;
|
|
39
|
-
-epub-hyphens: inherit;
|
|
40
|
-
hyphens: inherit;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* FontFamily */
|
|
44
|
-
|
|
45
|
-
:root[style*="--USER__fontFamily"] {
|
|
46
|
-
font-family: var(--USER__fontFamily) !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
:root[style*="--USER__fontFamily"] * {
|
|
50
|
-
font-family: revert !important;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* TextNormalize */
|
|
54
|
-
|
|
55
|
-
:root[style*="readium-a11y-on"] {
|
|
56
|
-
font-weight: normal !important;
|
|
57
|
-
font-style: normal !important;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
:root[style*="readium-a11y-on"] body *:not(code):not(var):not(kbd):not(samp) {
|
|
61
|
-
font-family: inherit !important;
|
|
62
|
-
font-weight: inherit !important;
|
|
63
|
-
font-style: inherit !important;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
:root[style*="readium-a11y-on"] body * {
|
|
67
|
-
text-decoration: none !important;
|
|
68
|
-
font-variant-caps: normal !important;
|
|
69
|
-
font-variant-position: normal !important;
|
|
70
|
-
font-variant-numeric: normal !important;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:root[style*="readium-a11y-on"] sup,
|
|
74
|
-
:root[style*="readium-a11y-on"] sub {
|
|
75
|
-
font-size: 1rem !important;
|
|
76
|
-
vertical-align: baseline !important;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Zoom */
|
|
80
|
-
|
|
81
|
-
:root {
|
|
82
|
-
--USER__zoom: 1;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
:root[style*="--USER__zoom"] body {
|
|
86
|
-
zoom: var(--USER__zoom) !important;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@supports selector(figure:has(> img)) {
|
|
90
|
-
:root[style*="--USER__zoom"] figure:has(> img),
|
|
91
|
-
:root[style*="--USER__zoom"] figure:has(> video),
|
|
92
|
-
:root[style*="--USER__zoom"] figure:has(> svg),
|
|
93
|
-
:root[style*="--USER__zoom"] figure:has(> canvas),
|
|
94
|
-
:root[style*="--USER__zoom"] figure:has(> iframe),
|
|
95
|
-
:root[style*="--USER__zoom"] figure:has(> audio),
|
|
96
|
-
:root[style*="--USER__zoom"] div:has(> img),
|
|
97
|
-
:root[style*="--USER__zoom"] div:has(> video),
|
|
98
|
-
:root[style*="--USER__zoom"] div:has(> svg),
|
|
99
|
-
:root[style*="--USER__zoom"] div:has(> canvas),
|
|
100
|
-
:root[style*="--USER__zoom"] div:has(> iframe),
|
|
101
|
-
:root[style*="--USER__zoom"] div:has(> audio),
|
|
102
|
-
:root[style*="--USER__zoom"] table {
|
|
103
|
-
zoom: calc(100% / var(--USER__zoom)) !important;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
:root[style*="--USER__zoom"] figcaption,
|
|
107
|
-
:root[style*="--USER__zoom"] caption,
|
|
108
|
-
:root[style*="--USER__zoom"] td,
|
|
109
|
-
:root[style*="--USER__zoom"] th {
|
|
110
|
-
zoom: var(--USER__zoom) !important;
|
|
111
|
-
}
|
|
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
|
-
}
|
|
205
|
-
`;
|