@readium/navigator 2.2.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.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.19",
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: this.layout !== Layout.fixed
260
- && this.metadata?.languages?.some(lang => lang === "ar" || lang === "fa")
261
- && this.preferences.ligatures !== null || false,
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
- // Utilities (matching FrameBlobBuilder pattern)
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("style");
21
+ const s = doc.createElement("link");
15
22
  s.dataset.readium = "true";
16
- s.textContent = source;
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 (resourceBlobCache.has(key)) return resourceBlobCache.get(key)!;
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
- // Add WebPubCSS stylesheet at end of head (like EPUB ReadiumCSS-after)
107
- const webPubStyle = styleify(doc, webPubStylesheet);
108
- doc.head.appendChild(webPubStyle);
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
@@ -1,3 +1,2 @@
1
1
  export * from "./Properties";
2
- export * from "./WebPubCSS";
3
- export * from "./WebPubStylesheet";
2
+ export * from "./WebPubCSS";
@@ -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;
@@ -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";
@@ -1,3 +1,2 @@
1
1
  export * from "./Properties";
2
2
  export * from "./WebPubCSS";
3
- export * from "./WebPubStylesheet";
@@ -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,204 +0,0 @@
1
- // WebPubCSS is equivalent to ReadiumCSS for WebPub
2
-
3
- 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 */
15
-
16
- :root[style*="--USER__fontWeight"] body {
17
- font-weight: var(--USER__fontWeight) !important;
18
- }
19
-
20
- /* Attempt to handle known bolds */
21
- :root[style*="--USER__fontWeight"] b,
22
- :root[style*="--USER__fontWeight"] strong {
23
- font-weight: bolder;
24
- }
25
-
26
- /* Hyphens */
27
-
28
- :root[style*="--USER__bodyHyphens"] {
29
- -webkit-hyphens: var(--USER__bodyHyphens) !important;
30
- -moz-hyphens: var(--USER__bodyHyphens) !important;
31
- -ms-hyphens: var(--USER__bodyHyphens) !important;
32
- -epub-hyphens: var(--USER__bodyHyphens) !important;
33
- hyphens: var(--USER__bodyHyphens) !important;
34
- }
35
-
36
- :root[style*="--USER__bodyHyphens"] body,
37
- :root[style*="--USER__bodyHyphens"] p,
38
- :root[style*="--USER__bodyHyphens"] li,
39
- :root[style*="--USER__bodyHyphens"] div,
40
- :root[style*="--USER__bodyHyphens"] dd {
41
- -webkit-hyphens: inherit;
42
- -moz-hyphens: inherit;
43
- -ms-hyphens: inherit;
44
- -epub-hyphens: inherit;
45
- hyphens: inherit;
46
- }
47
-
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 */
113
-
114
- :root[style*="--USER__textAlign"] {
115
- text-align: var(--USER__textAlign);
116
- }
117
-
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;
126
- }
127
-
128
- /* TextNormalize */
129
-
130
- :root[style*="readium-a11y-on"] {
131
- font-weight: normal !important;
132
- font-style: normal !important;
133
- }
134
-
135
- :root[style*="readium-a11y-on"] *:not(code):not(var):not(kbd):not(samp) {
136
- font-family: inherit !important;
137
- font-weight: inherit !important;
138
- font-style: inherit !important;
139
- }
140
-
141
- :root[style*="readium-a11y-on"] * {
142
- text-decoration: none !important;
143
- font-variant-caps: normal !important;
144
- font-variant-position: normal !important;
145
- font-variant-numeric: normal !important;
146
- }
147
-
148
- :root[style*="readium-a11y-on"] sup,
149
- :root[style*="readium-a11y-on"] sub {
150
- font-size: 1rem !important;
151
- vertical-align: baseline !important;
152
- }
153
-
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
- /* Zoom */
171
-
172
- :root {
173
- --USER__zoom: 1;
174
- }
175
-
176
- :root[style*="--USER__zoom"] body {
177
- zoom: var(--USER__zoom) !important;
178
- }
179
-
180
- @supports selector(figure:has(> img)) {
181
- :root[style*="--USER__zoom"] figure:has(> img),
182
- :root[style*="--USER__zoom"] figure:has(> video),
183
- :root[style*="--USER__zoom"] figure:has(> svg),
184
- :root[style*="--USER__zoom"] figure:has(> canvas),
185
- :root[style*="--USER__zoom"] figure:has(> iframe),
186
- :root[style*="--USER__zoom"] figure:has(> audio),
187
- :root[style*="--USER__zoom"] div:has(> img),
188
- :root[style*="--USER__zoom"] div:has(> video),
189
- :root[style*="--USER__zoom"] div:has(> svg),
190
- :root[style*="--USER__zoom"] div:has(> canvas),
191
- :root[style*="--USER__zoom"] div:has(> iframe),
192
- :root[style*="--USER__zoom"] div:has(> audio),
193
- :root[style*="--USER__zoom"] table {
194
- zoom: calc(100% / var(--USER__zoom)) !important;
195
- }
196
-
197
- :root[style*="--USER__zoom"] figcaption,
198
- :root[style*="--USER__zoom"] caption,
199
- :root[style*="--USER__zoom"] td,
200
- :root[style*="--USER__zoom"] th {
201
- zoom: var(--USER__zoom) !important;
202
- }
203
- }
204
- `;