@readium/navigator 2.5.0 → 2.5.2-beta.1

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.5.0",
3
+ "version": "2.5.2-beta.1",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -2,7 +2,7 @@ import { Layout, Link, Locator, Profile, Publication, ReadingProgression } from
2
2
  import { Configurable, ConfigurableSettings, LineLengths, ProgressionRange, VisualNavigator, VisualNavigatorViewport } from "../index.ts";
3
3
  import { FramePoolManager } from "./frame/FramePoolManager.ts";
4
4
  import { FXLFramePoolManager } from "./fxl/FXLFramePoolManager.ts";
5
- import { CommsEventKey, ContextMenuEvent, FXLModules, KeyboardEventData, ModuleLibrary, ModuleName, ReflowableModules, BasicTextSelection, FrameClickEvent, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
5
+ import { CommsEventKey, ContextMenuEvent, FXLModules, ModuleLibrary, ModuleName, ReflowableModules, BasicTextSelection, FrameClickEvent, SuspiciousActivityEvent, KeyboardPeripheralEvent } from "@readium/navigator-html-injectables";
6
6
  import * as path from "path-browserify";
7
7
  import { FXLFrameManager } from "./fxl/FXLFrameManager.ts";
8
8
  import { FrameManager } from "./frame/FrameManager.ts";
@@ -23,6 +23,10 @@ import { getScriptMode } from "../helpers/scriptMode.ts";
23
23
 
24
24
  export type ManagerEventKey = "zoom";
25
25
 
26
+ export interface KeyboardPeripheralEventData extends Omit<KeyboardPeripheralEvent, 'interactiveElement'> {
27
+ interactiveElement?: Element;
28
+ }
29
+
26
30
  export interface EpubNavigatorConfiguration {
27
31
  preferences: IEpubPreferences;
28
32
  defaults: IEpubDefaults;
@@ -44,7 +48,7 @@ export interface EpubNavigatorListeners {
44
48
  textSelected: (selection: BasicTextSelection) => void;
45
49
  contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
46
50
  contextMenu: (data: ContextMenuEvent) => void;
47
- peripheral: (data: KeyboardEventData) => void;
51
+ peripheral: (data: KeyboardPeripheralEventData) => void;
48
52
  // showToc: () => void;
49
53
  }
50
54
 
@@ -540,7 +544,15 @@ export class EpubNavigator extends VisualNavigator implements Configurable<Confi
540
544
  this.listeners.contextMenu(data as ContextMenuEvent);
541
545
  break;
542
546
  case "keyboard_peripherals":
543
- this.listeners.peripheral(data as KeyboardEventData);
547
+ const event = data as KeyboardPeripheralEvent;
548
+ const parsedEvent: KeyboardPeripheralEventData = { ...event, interactiveElement: undefined };
549
+ if (event.interactiveElement) {
550
+ parsedEvent.interactiveElement = new DOMParser().parseFromString(
551
+ event.interactiveElement,
552
+ "text/html"
553
+ ).body.children[0] as Element;
554
+ }
555
+ this.listeners.peripheral(parsedEvent);
544
556
  break;
545
557
  case "log":
546
558
  console.log(this._cframes[0]?.source?.split("/")[3], ...(data as any[]));
@@ -11,7 +11,6 @@ import {
11
11
  } from "../../css/Properties.ts";
12
12
 
13
13
  export interface IUserProperties {
14
- advancedSettings?: boolean | null;
15
14
  a11yNormalize?: boolean | null;
16
15
  backgroundColor?: string | null;
17
16
  blendFilter?: boolean | null;
@@ -2,11 +2,11 @@ import { Feature, Link, Locator, Publication, ReadingProgression, LocatorLocatio
2
2
  import { VisualNavigator, VisualNavigatorViewport, ProgressionRange } from "../Navigator.ts";
3
3
  import { Configurable } from "../preferences/Configurable.ts";
4
4
  import { WebPubFramePoolManager } from "./WebPubFramePoolManager.ts";
5
- import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardEventData, ModuleName, SuspiciousActivityEvent, WebPubModules } from "@readium/navigator-html-injectables";
5
+ import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardPeripheralEvent, ModuleName, SuspiciousActivityEvent, WebPubModules } from "@readium/navigator-html-injectables";
6
6
  import * as path from "path-browserify";
7
7
  import { WebPubFrameManager } from "./WebPubFrameManager.ts";
8
8
 
9
- import { ManagerEventKey } from "../epub/EpubNavigator.ts";
9
+ import { KeyboardPeripheralEventData, ManagerEventKey } from "../epub/EpubNavigator.ts";
10
10
  import { getScriptMode } from "../helpers/scriptMode.ts";
11
11
  import { WebPubCSS } from "./css/WebPubCSS.ts";
12
12
  import { WebUserProperties, WebRSProperties } from "./css/Properties.ts";
@@ -41,7 +41,7 @@ export interface WebPubNavigatorListeners {
41
41
  textSelected: (selection: BasicTextSelection) => void;
42
42
  contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
43
43
  contextMenu: (data: ContextMenuEvent) => void;
44
- peripheral: (data: KeyboardEventData) => void;
44
+ peripheral: (data: KeyboardPeripheralEventData) => void;
45
45
  }
46
46
 
47
47
  const defaultListeners = (listeners: WebPubNavigatorListeners): WebPubNavigatorListeners => ({
@@ -356,7 +356,15 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
356
356
  this.listeners.contextMenu(data as ContextMenuEvent);
357
357
  break;
358
358
  case "keyboard_peripherals":
359
- this.listeners.peripheral(data as KeyboardEventData);
359
+ const event = data as KeyboardPeripheralEvent;
360
+ const parsedEvent: KeyboardPeripheralEventData = { ...event, interactiveElement: undefined };
361
+ if (event.interactiveElement) {
362
+ parsedEvent.interactiveElement = new DOMParser().parseFromString(
363
+ event.interactiveElement,
364
+ "text/html"
365
+ ).body.children[0] as Element;
366
+ }
367
+ this.listeners.peripheral(parsedEvent);
360
368
  break;
361
369
  case "log":
362
370
  console.log(this.framePool.currentFrames[0]?.source?.split("/")[3], ...(data as any[]));
@@ -2,7 +2,7 @@ import { Layout, Link, Locator, Publication, ReadingProgression } from "@readium
2
2
  import { Configurable, ConfigurableSettings, VisualNavigator, VisualNavigatorViewport } from "../index.ts";
3
3
  import { FramePoolManager } from "./frame/FramePoolManager.ts";
4
4
  import { FXLFramePoolManager } from "./fxl/FXLFramePoolManager.ts";
5
- import { CommsEventKey, ContextMenuEvent, KeyboardEventData, BasicTextSelection, FrameClickEvent, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
5
+ import { CommsEventKey, ContextMenuEvent, BasicTextSelection, FrameClickEvent, SuspiciousActivityEvent, KeyboardPeripheralEvent } from "@readium/navigator-html-injectables";
6
6
  import { FXLFrameManager } from "./fxl/FXLFrameManager.ts";
7
7
  import { FrameManager } from "./frame/FrameManager.ts";
8
8
  import { IEpubPreferences, EpubPreferences } from "./preferences/EpubPreferences.ts";
@@ -12,6 +12,9 @@ import { EpubPreferencesEditor } from "./preferences/EpubPreferencesEditor.ts";
12
12
  import { IInjectablesConfig } from "../injection/Injectable.ts";
13
13
  import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator.ts";
14
14
  export type ManagerEventKey = "zoom";
15
+ export interface KeyboardPeripheralEventData extends Omit<KeyboardPeripheralEvent, 'interactiveElement'> {
16
+ interactiveElement?: Element;
17
+ }
15
18
  export interface EpubNavigatorConfiguration {
16
19
  preferences: IEpubPreferences;
17
20
  defaults: IEpubDefaults;
@@ -32,7 +35,7 @@ export interface EpubNavigatorListeners {
32
35
  textSelected: (selection: BasicTextSelection) => void;
33
36
  contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
34
37
  contextMenu: (data: ContextMenuEvent) => void;
35
- peripheral: (data: KeyboardEventData) => void;
38
+ peripheral: (data: KeyboardPeripheralEventData) => void;
36
39
  }
37
40
  export declare class EpubNavigator extends VisualNavigator implements Configurable<ConfigurableSettings, EpubPreferences> {
38
41
  private readonly pub;
@@ -1,7 +1,6 @@
1
1
  import { ExperimentKey, TextAlignment } from "../../preferences/Types.ts";
2
2
  import { BodyHyphens, BoxSizing, FontOpticalSizing, FontWidth, Ligatures, Properties, TypeScale, View } from "../../css/Properties.ts";
3
3
  export interface IUserProperties {
4
- advancedSettings?: boolean | null;
5
4
  a11yNormalize?: boolean | null;
6
5
  backgroundColor?: string | null;
7
6
  blendFilter?: boolean | null;
@@ -1,9 +1,9 @@
1
1
  import { Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
2
  import { VisualNavigator, VisualNavigatorViewport } from "../Navigator.ts";
3
3
  import { Configurable } from "../preferences/Configurable.ts";
4
- import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardEventData, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
4
+ import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
5
5
  import { WebPubFrameManager } from "./WebPubFrameManager.ts";
6
- import { ManagerEventKey } from "../epub/EpubNavigator.ts";
6
+ import { KeyboardPeripheralEventData, ManagerEventKey } from "../epub/EpubNavigator.ts";
7
7
  import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences.ts";
8
8
  import { IWebPubDefaults } from "./preferences/WebPubDefaults.ts";
9
9
  import { WebPubSettings } from "./preferences/WebPubSettings.ts";
@@ -29,7 +29,7 @@ export interface WebPubNavigatorListeners {
29
29
  textSelected: (selection: BasicTextSelection) => void;
30
30
  contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
31
31
  contextMenu: (data: ContextMenuEvent) => void;
32
- peripheral: (data: KeyboardEventData) => void;
32
+ peripheral: (data: KeyboardPeripheralEventData) => void;
33
33
  }
34
34
  export declare class WebPubNavigator extends VisualNavigator implements Configurable<WebPubSettings, WebPubPreferences> {
35
35
  private readonly pub;