@d-i-t-a/reader 1.11.0-beta.7 → 1.12.0-alpha.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/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare function totalResources(): number;
32
32
  export declare function publicationLanguage(): string[];
33
33
  export declare function resetUserSettings(): Promise<void>;
34
34
  export declare function applyUserSettings(userSettings: any): Promise<void>;
35
+ export declare function applyLineFocusSettings(userSettings: any): Promise<void>;
35
36
  export declare function currentSettings(): Promise<{
36
37
  appearance: string;
37
38
  fontFamily: string;
@@ -66,6 +67,8 @@ export declare function goToPosition(value: any): void;
66
67
  export declare function applyAttributes(value: any): void;
67
68
  export declare function hideAnnotationLayer(): void;
68
69
  export declare function showAnnotationLayer(): void;
70
+ export declare function lineUp(): void;
71
+ export declare function lineDown(): void;
69
72
  export declare function hideLayer(layer: any): void;
70
73
  export declare function showLayer(layer: any): void;
71
74
  export declare function clearDefinitions(): Promise<void>;
@@ -73,4 +76,7 @@ export declare function addDefinition(definition: any): Promise<void>;
73
76
  export declare function snapToElement(value: any): void;
74
77
  export declare function activateMarker(id: any, position: any): void;
75
78
  export declare function deactivateMarker(): void;
79
+ export declare function enableLineFocus(): Promise<void>;
80
+ export declare function lineFocus(active: boolean): Promise<void>;
81
+ export declare function disableLineFocus(): void;
76
82
  export declare function load(config: ReaderConfig): Promise<any>;
@@ -57,10 +57,10 @@ export default class AnnotationModule implements ReaderModule {
57
57
  deleteHighlight(highlight: Annotation): Promise<any>;
58
58
  deleteSelectedHighlight(highlight: Annotation): Promise<any>;
59
59
  updateAnnotation(highlight: Annotation): Promise<any>;
60
- saveAnnotation(highlight: IHighlight): Promise<Annotation>;
60
+ saveAnnotation(highlight: IHighlight, iframehref: any): Promise<Annotation>;
61
61
  getAnnotations(): Promise<any>;
62
62
  showHighlights(): Promise<void>;
63
- drawHighlights(): Promise<void>;
63
+ drawHighlights(iframeIndex: any, iframehref: string): Promise<void>;
64
64
  private createTree;
65
65
  private handleAnnotationLinkClick;
66
66
  private handleAnnotationLinkDeleteClick;
@@ -8,6 +8,7 @@ export declare const ID_READALOUD_CONTAINER = "R2_ID_READALOUD_CONTAINER";
8
8
  export declare const ID_PAGEBREAK_CONTAINER = "R2_ID_PAGEBREAK_CONTAINER";
9
9
  export declare const ID_SEARCH_CONTAINER = "R2_ID_SEARCH_CONTAINER";
10
10
  export declare const ID_POPUP_CONTAINER = "R2_ID_POPUP_CONTAINER";
11
+ export declare const ID_LINEFOCUS_CONTAINER = "R2_ID_LINEFOCUS_CONTAINER";
11
12
  export declare const CLASS_HIGHLIGHT_CONTAINER = "R2_CLASS_HIGHLIGHT_CONTAINER";
12
13
  export declare const CLASS_HIGHLIGHT_AREA = "R2_CLASS_HIGHLIGHT_AREA";
13
14
  export declare const CLASS_HIGHLIGHT_ICON = "R2_CLASS_HIGHLIGHT_ICON";
@@ -46,8 +47,7 @@ export interface TextHighlighterConfig extends TextHighlighterProperties {
46
47
  }
47
48
  export default class TextHighlighter {
48
49
  private options;
49
- private delegate;
50
- private lastSelectedHighlight;
50
+ private readonly delegate;
51
51
  properties: TextHighlighterProperties;
52
52
  private api;
53
53
  private hasEventListener;
@@ -102,22 +102,6 @@ export default class TextHighlighter {
102
102
  endOffset: number;
103
103
  startOffset: number;
104
104
  }): object;
105
- /**
106
- * Sorts array of DOM elements by its depth in DOM tree.
107
- * @param {HTMLElement[]} arr - array to sort.
108
- * @param {boolean} descending - order of sort.
109
- */
110
- sortByDepth(arr: {
111
- sort: (arg0: (a: any, b: any) => number) => void;
112
- }, descending: boolean): void;
113
- /**
114
- * Groups given highlights by timestamp.
115
- * @param {Array} highlights
116
- * @returns {Array} Grouped highlights.
117
- */
118
- groupHighlights(highlights: {
119
- forEach: (arg0: (hl: any) => void) => void;
120
- }): Array<any>;
121
105
  /**
122
106
  * Utility functions to make DOM manipulation easier.
123
107
  * @param {Node|HTMLElement} [el] - base DOM element to manipulate
@@ -128,8 +112,8 @@ export default class TextHighlighter {
128
112
  preventDefault: () => void;
129
113
  stopPropagation: () => void;
130
114
  }): boolean;
131
- bindEvents(el: any, _scope: any, hasEventListener: boolean): void;
132
- unbindEvents(el: any, _scope: any): void;
115
+ bindEvents(iframeIndex: number, hasEventListener: boolean): void;
116
+ unbindEvents(iframeIndex: number): void;
133
117
  /**
134
118
  * Permanently disables highlighting.
135
119
  * Unbinds events and remove context element class.
@@ -139,9 +123,9 @@ export default class TextHighlighter {
139
123
  initializeToolbox(): void;
140
124
  toolboxMode(mode: "colors" | "edit" | "add" | "action"): void;
141
125
  toolboxHide(): void;
142
- toolboxShowDelayed(): void;
143
- snapSelectionToWord(): any;
144
- toolboxShow(): void;
126
+ toolboxShowDelayed(iframeIndex: number): void;
127
+ snapSelectionToWord(iframeIndex: number): any;
128
+ toolboxShow(iframeIndex: number): void;
145
129
  isSelectionMenuOpen: boolean;
146
130
  selectionMenuOpened: (() => void) & {
147
131
  clear(): void;
@@ -152,21 +136,21 @@ export default class TextHighlighter {
152
136
  selection: ((text: any, selection: any) => void) & {
153
137
  clear(): void;
154
138
  };
155
- toolboxPlacement(): void;
156
- toolboxHandler(): void;
139
+ toolboxPlacement(iframeIndex: number): void;
140
+ toolboxHandler(iframeIndex: number): void;
157
141
  /**
158
142
  * Highlights current range.
159
143
  * @param {boolean} keepRange - Don't remove range after highlighting. Default: false.
160
144
  * @param marker
161
145
  * @memberof TextHighlighter
162
146
  */
163
- doHighlight(keepRange?: boolean, marker?: AnnotationMarker): void;
164
- speak(): void;
165
- stopReadAloud(): void;
166
- speakAll(): void;
167
- callbackComplete(): void;
168
- get visibleTextRects(): HTMLElementRect[];
169
- doneSpeaking(reload?: boolean): void;
147
+ doHighlight(iframeIndex: number, keepRange?: boolean, marker?: AnnotationMarker): void;
148
+ speak(iframeIndex: number): void;
149
+ stopReadAloud(iframeIndex: number): void;
150
+ speakAll(iframeIndex: number): void;
151
+ callbackComplete(iframeIndex: number): void;
152
+ visibleTextRects(iframeIndex: number): HTMLElementRect[];
153
+ doneSpeaking(iframeIndex: number, reload?: boolean): void;
170
154
  /**
171
155
  * Normalizes highlights. Ensures that highlighting is done with use of the smallest possible number of
172
156
  * wrapping HTML elements.
@@ -177,13 +161,6 @@ export default class TextHighlighter {
177
161
  * @memberof TextHighlighter
178
162
  */
179
163
  normalizeHighlights(highlights: any): any;
180
- /**
181
- * Flattens highlights structure.
182
- * Note: this method changes input highlights - their order and number after calling this method may change.
183
- * @param {Array} highlights - highlights to flatten.
184
- * @memberof TextHighlighter
185
- */
186
- flattenNestedHighlights(highlights: any): void;
187
164
  /**
188
165
  * Merges sibling highlights and normalizes descendant text nodes.
189
166
  * Note: this method changes input highlights - their order and number after calling this method may change.
@@ -229,20 +206,20 @@ export default class TextHighlighter {
229
206
  };
230
207
  static hexToRgbA(hex: string): string;
231
208
  static hexToRgbAWithOpacity(hex: string, opacity: number): string;
232
- resetHighlightBoundingStyle(_win: any, highlightBounding: HTMLElement): void;
233
- resetHighlightAreaStyle(_win: any, highlightArea: HTMLElement, id_container: string): void;
234
- setHighlightAreaStyle(_win: any, highlightAreas: Array<HTMLElement>, highlight: IHighlight): void;
235
- setAndResetSearchHighlight(highlight: any, highlights: any): void;
209
+ resetHighlightBoundingStyle(highlightBounding: HTMLElement): void;
210
+ resetHighlightAreaStyle(highlightArea: HTMLElement, id_container: string, iframeIndex: number): void;
211
+ setHighlightAreaStyle(highlightAreas: Array<HTMLElement>, highlight: IHighlight, iframeIndex: number): void;
212
+ setAndResetSearchHighlight(highlight: any, highlights: any, iframeIndex: number): void;
236
213
  isIOS(): boolean;
237
214
  isAndroid(): boolean;
238
- getScrollingElement: (documant: Document) => Element;
239
- processMouseEvent(win: any, ev: MouseEvent): Promise<void>;
240
- ensureHighlightsContainer(win: any, id: string): HTMLElement;
241
- hideAllhighlights(_documant: Document): void;
242
- destroyAllhighlights(documant: Document): void;
243
- destroyHighlights(type: HighlightType): void;
244
- destroyHighlight(documant: Document, id: string): void;
245
- createHighlight(win: any, selectionInfo: ISelectionInfo, color: string | undefined, pointerInteraction: boolean, marker: AnnotationMarker, icon?: IMarkerIcon | undefined, popup?: IPopupStyle | undefined, style?: IStyle | undefined, type?: HighlightType | undefined, prefix?: string | undefined): [IHighlight, HTMLDivElement];
246
- createHighlightDom(win: any, highlight: IHighlight): HTMLDivElement | undefined;
215
+ getScrollingElement: (iframeDocument: Document) => Element;
216
+ processMouseEvent(iframeIndex: number, ev: MouseEvent): Promise<void>;
217
+ ensureHighlightsContainer(id: string, iframeIndex: number): HTMLElement;
218
+ hideAllHighlights(iframeIndex: number): void;
219
+ destroyAllHighlights(iframeIndex: number): void;
220
+ destroyHighlights(type: HighlightType, iframeIndex: number): void;
221
+ destroyHighlight(id: string, iframeIndex: number): void;
222
+ createHighlight(iframeIndex: any, selectionInfo: ISelectionInfo, color: string | undefined, pointerInteraction: boolean, marker: AnnotationMarker, icon?: IMarkerIcon | undefined, popup?: IPopupStyle | undefined, style?: IStyle | undefined, type?: HighlightType | undefined, prefix?: string | undefined): [IHighlight, HTMLDivElement];
223
+ createHighlightDom(iframeIndex: number, highlight: IHighlight): HTMLDivElement | undefined;
247
224
  }
248
225
  export {};
@@ -39,7 +39,8 @@ export declare enum HighlightType {
39
39
  Search = 1,
40
40
  ReadAloud = 2,
41
41
  PageBreak = 3,
42
- Popup = 4
42
+ Popup = 4,
43
+ Lines = 5
43
44
  }
44
45
  export interface IHighlight {
45
46
  id: string;
@@ -6,9 +6,7 @@ export interface LineFocusModuleAPI {
6
6
  }
7
7
  export interface LineFocusModuleProperties {
8
8
  api?: LineFocusModuleAPI;
9
- factor: number;
10
- startIndex: number;
11
- currentIndex: number;
9
+ lines: number;
12
10
  }
13
11
  export interface LineFocusModuleConfig extends LineFocusModuleProperties {
14
12
  api: LineFocusModuleAPI;
@@ -25,12 +23,15 @@ export default class LineFocusModule implements ReaderModule {
25
23
  index: number;
26
24
  isActive: boolean;
27
25
  isDebug: boolean;
26
+ lineFocusContainer: HTMLElement;
27
+ lineFocusTopBlinder: HTMLElement;
28
+ lineFocusBottomBlinder: HTMLElement;
28
29
  static create(config: LineFocusModuleConfig): Promise<LineFocusModule>;
29
30
  private constructor();
30
31
  stop(): Promise<void>;
31
32
  protected start(): Promise<void>;
32
33
  handleResize(): void;
33
- enableLineFocus(): void;
34
+ enableLineFocus(): Promise<void>;
34
35
  disableLineFocus(): void;
35
36
  lineFocus(): void;
36
37
  currentLine(): void;
@@ -16,6 +16,7 @@ import ReaderModule from "../modules/ReaderModule";
16
16
  import { TTSModuleConfig } from "../modules/TTS/TTSSettings";
17
17
  import PageBreakModule from "../modules/pagebreak/PageBreakModule";
18
18
  import DefinitionsModule, { DefinitionsModuleConfig } from "../modules/search/DefinitionsModule";
19
+ import LineFocusModule, { LineFocusModuleConfig } from "../modules/linefocus/LineFocusModule";
19
20
  export declare type GetContent = (href: string) => Promise<string>;
20
21
  export declare type GetContentBytesLength = (href: string) => Promise<number>;
21
22
  export interface NavigatorAPI {
@@ -85,6 +86,7 @@ export interface ReaderRights {
85
86
  enableTTS?: boolean;
86
87
  enableSearch?: boolean;
87
88
  enableDefinitions?: boolean;
89
+ enableLineFocus?: boolean;
88
90
  enableContentProtection?: boolean;
89
91
  enableMaterial?: boolean;
90
92
  enableTimeline?: boolean;
@@ -106,6 +108,7 @@ export interface ReaderConfig {
106
108
  tts?: TTSModuleConfig;
107
109
  search?: SearchModuleConfig;
108
110
  define?: DefinitionsModuleConfig;
111
+ lineFocus?: LineFocusModuleConfig;
109
112
  protection?: ContentProtectionModuleConfig;
110
113
  mediaOverlays?: MediaOverlayModuleConfig;
111
114
  annotations?: AnnotationModuleConfig;
@@ -130,6 +133,7 @@ export default class IFrameNavigator implements Navigator {
130
133
  ttsModule?: ReaderModule;
131
134
  searchModule?: SearchModule;
132
135
  definitionsModule?: DefinitionsModule;
136
+ lineFocusModule?: LineFocusModule;
133
137
  contentProtectionModule?: ContentProtectionModule;
134
138
  highlighter?: TextHighlighter;
135
139
  timelineModule?: TimelineModule;