@d-i-t-a/reader 1.12.0-alpha.1 → 1.12.0-beta.5

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,12 @@ 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>;
36
+ export declare function lineUp(): void;
37
+ export declare function lineDown(): void;
38
+ export declare function enableLineFocus(): Promise<void>;
39
+ export declare function lineFocus(active: boolean): Promise<void>;
40
+ export declare function disableLineFocus(): void;
35
41
  export declare function currentSettings(): Promise<{
36
42
  appearance: string;
37
43
  fontFamily: string;
@@ -66,6 +72,10 @@ export declare function goToPosition(value: any): void;
66
72
  export declare function applyAttributes(value: any): void;
67
73
  export declare function hideAnnotationLayer(): void;
68
74
  export declare function showAnnotationLayer(): void;
75
+ export declare function hideLayer(layer: any): void;
76
+ export declare function showLayer(layer: any): void;
77
+ export declare function clearDefinitions(): Promise<void>;
78
+ export declare function addDefinition(definition: any): Promise<void>;
69
79
  export declare function snapToElement(value: any): void;
70
80
  export declare function activateMarker(id: any, position: any): void;
71
81
  export declare function deactivateMarker(): void;
@@ -14,6 +14,7 @@ export interface AnnotationModuleAPI {
14
14
  }
15
15
  export interface AnnotationModuleProperties {
16
16
  initialAnnotationColor: string;
17
+ hideLayer?: boolean;
17
18
  }
18
19
  export interface AnnotationModuleConfig extends AnnotationModuleProperties {
19
20
  annotator: Annotator;
@@ -57,10 +58,10 @@ export default class AnnotationModule implements ReaderModule {
57
58
  deleteHighlight(highlight: Annotation): Promise<any>;
58
59
  deleteSelectedHighlight(highlight: Annotation): Promise<any>;
59
60
  updateAnnotation(highlight: Annotation): Promise<any>;
60
- saveAnnotation(highlight: IHighlight, iframehref: any): Promise<Annotation>;
61
+ saveAnnotation(highlight: IHighlight): Promise<Annotation>;
61
62
  getAnnotations(): Promise<any>;
62
63
  showHighlights(): Promise<void>;
63
- drawHighlights(iframeIndex: any, iframehref: string): Promise<void>;
64
+ drawHighlights(): Promise<void>;
64
65
  private createTree;
65
66
  private handleAnnotationLinkClick;
66
67
  private handleAnnotationLinkDeleteClick;
@@ -10,15 +10,15 @@ export interface BookmarkModuleAPI {
10
10
  getBookmarks: Array<any>;
11
11
  }
12
12
  export interface BookmarkModuleProperties {
13
+ hideLayer?: boolean;
13
14
  }
14
- export interface BookmarkModuleConfig {
15
+ export interface BookmarkModuleConfig extends BookmarkModuleProperties {
15
16
  annotator: Annotator;
16
17
  headerMenu: HTMLElement;
17
18
  rights: ReaderRights;
18
19
  publication: Publication;
19
20
  delegate: IFrameNavigator;
20
21
  initialAnnotations?: any;
21
- properties: BookmarkModuleProperties;
22
22
  api: BookmarkModuleAPI;
23
23
  }
24
24
  export default class BookmarkModule implements ReaderModule {
@@ -18,6 +18,7 @@ export interface TTSModuleProperties {
18
18
  pitch?: number;
19
19
  volume?: number;
20
20
  voice?: TTSVoice;
21
+ hideLayer?: boolean;
21
22
  }
22
23
  export interface TTSModuleConfig extends TTSModuleProperties {
23
24
  delegate: IFrameNavigator;
@@ -0,0 +1,19 @@
1
+ import Store from "../../store/Store";
2
+ import { UserProperty, UserProperties } from "../../model/user-settings/UserProperties";
3
+ export interface LayerConfig {
4
+ store: Store;
5
+ }
6
+ export interface ILayerSettings {
7
+ }
8
+ export declare class LayerSettings implements ILayerSettings {
9
+ private readonly store;
10
+ private readonly LAYERSETTINGS;
11
+ userProperties: UserProperties;
12
+ static create(config: LayerConfig): Promise<any>;
13
+ protected constructor(store: Store);
14
+ stop(): Promise<void>;
15
+ private initialize;
16
+ private getLayerSettings;
17
+ saveProperty(property: UserProperty): Promise<any>;
18
+ getProperty(name: string): Promise<UserProperty>;
19
+ }
@@ -3,15 +3,20 @@ import { ISelectionInfo } from "./common/selection";
3
3
  import { IRectSimple } from "./common/rect-utils";
4
4
  import { AnnotationMarker } from "../../model/Locator";
5
5
  import IFrameNavigator from "../../navigator/IFrameNavigator";
6
- export declare const ID_HIGHLIGHTS_CONTAINER = "R2_ID_HIGHLIGHTS_CONTAINER";
7
- export declare const ID_READALOUD_CONTAINER = "R2_ID_READALOUD_CONTAINER";
8
- export declare const ID_PAGEBREAK_CONTAINER = "R2_ID_PAGEBREAK_CONTAINER";
9
- export declare const ID_SEARCH_CONTAINER = "R2_ID_SEARCH_CONTAINER";
10
- export declare const ID_POPUP_CONTAINER = "R2_ID_POPUP_CONTAINER";
6
+ import { LayerSettings } from "./LayerSettings";
7
+ export declare enum HighlightContainer {
8
+ R2_ID_HIGHLIGHTS_CONTAINER = "R2_ID_HIGHLIGHTS_CONTAINER",
9
+ R2_ID_BOOKMAKRS_CONTAINER = "R2_ID_BOOKMAKRS_CONTAINER",
10
+ R2_ID_READALOUD_CONTAINER = "R2_ID_READALOUD_CONTAINER",
11
+ R2_ID_PAGEBREAK_CONTAINER = "R2_ID_PAGEBREAK_CONTAINER",
12
+ R2_ID_SEARCH_CONTAINER = "R2_ID_SEARCH_CONTAINER",
13
+ R2_ID_DEFINITIONS_CONTAINER = "R2_ID_DEFINITIONS_CONTAINER",
14
+ R2_ID_LINEFOCUS_CONTAINER = "R2_ID_LINEFOCUS_CONTAINER"
15
+ }
11
16
  export declare const CLASS_HIGHLIGHT_CONTAINER = "R2_CLASS_HIGHLIGHT_CONTAINER";
17
+ export declare const CLASS_HIGHLIGHT_BOUNDING_AREA = "R2_CLASS_HIGHLIGHT_BOUNDING_AREA";
12
18
  export declare const CLASS_HIGHLIGHT_AREA = "R2_CLASS_HIGHLIGHT_AREA";
13
19
  export declare const CLASS_HIGHLIGHT_ICON = "R2_CLASS_HIGHLIGHT_ICON";
14
- export declare const CLASS_HIGHLIGHT_BOUNDING_AREA = "R2_CLASS_HIGHLIGHT_BOUNDING_AREA";
15
20
  export declare const DEFAULT_BACKGROUND_COLOR: {
16
21
  blue: number;
17
22
  green: number;
@@ -43,10 +48,13 @@ export interface TextHighlighterProperties {
43
48
  export interface TextHighlighterConfig extends TextHighlighterProperties {
44
49
  delegate: IFrameNavigator;
45
50
  api: TextSelectorAPI;
51
+ layerSettings: LayerSettings;
46
52
  }
47
53
  export default class TextHighlighter {
48
54
  private options;
49
55
  private readonly delegate;
56
+ layerSettings: LayerSettings;
57
+ private lastSelectedHighlight;
50
58
  properties: TextHighlighterProperties;
51
59
  private api;
52
60
  private hasEventListener;
@@ -101,6 +109,22 @@ export default class TextHighlighter {
101
109
  endOffset: number;
102
110
  startOffset: number;
103
111
  }): object;
112
+ /**
113
+ * Sorts array of DOM elements by its depth in DOM tree.
114
+ * @param {HTMLElement[]} arr - array to sort.
115
+ * @param {boolean} descending - order of sort.
116
+ */
117
+ sortByDepth(arr: {
118
+ sort: (arg0: (a: any, b: any) => number) => void;
119
+ }, descending: boolean): void;
120
+ /**
121
+ * Groups given highlights by timestamp.
122
+ * @param {Array} highlights
123
+ * @returns {Array} Grouped highlights.
124
+ */
125
+ groupHighlights(highlights: {
126
+ forEach: (arg0: (hl: any) => void) => void;
127
+ }): Array<any>;
104
128
  /**
105
129
  * Utility functions to make DOM manipulation easier.
106
130
  * @param {Node|HTMLElement} [el] - base DOM element to manipulate
@@ -111,8 +135,8 @@ export default class TextHighlighter {
111
135
  preventDefault: () => void;
112
136
  stopPropagation: () => void;
113
137
  }): boolean;
114
- bindEvents(iframeIndex: number, hasEventListener: boolean): void;
115
- unbindEvents(iframeIndex: number): void;
138
+ bindEvents(el: any, _scope: any, hasEventListener: boolean): void;
139
+ unbindEvents(el: any, _scope: any): void;
116
140
  /**
117
141
  * Permanently disables highlighting.
118
142
  * Unbinds events and remove context element class.
@@ -122,9 +146,9 @@ export default class TextHighlighter {
122
146
  initializeToolbox(): void;
123
147
  toolboxMode(mode: "colors" | "edit" | "add" | "action"): void;
124
148
  toolboxHide(): void;
125
- toolboxShowDelayed(iframeIndex: number): void;
126
- snapSelectionToWord(iframeIndex: number): any;
127
- toolboxShow(iframeIndex: number): void;
149
+ toolboxShowDelayed(): void;
150
+ snapSelectionToWord(): any;
151
+ toolboxShow(): void;
128
152
  isSelectionMenuOpen: boolean;
129
153
  selectionMenuOpened: (() => void) & {
130
154
  clear(): void;
@@ -135,21 +159,21 @@ export default class TextHighlighter {
135
159
  selection: ((text: any, selection: any) => void) & {
136
160
  clear(): void;
137
161
  };
138
- toolboxPlacement(iframeIndex: number): void;
139
- toolboxHandler(iframeIndex: number): void;
162
+ toolboxPlacement(): void;
163
+ toolboxHandler(): void;
140
164
  /**
141
165
  * Highlights current range.
142
166
  * @param {boolean} keepRange - Don't remove range after highlighting. Default: false.
143
167
  * @param marker
144
168
  * @memberof TextHighlighter
145
169
  */
146
- doHighlight(iframeIndex: number, keepRange?: boolean, marker?: AnnotationMarker): void;
147
- speak(iframeIndex: number): void;
148
- stopReadAloud(iframeIndex: number): void;
149
- speakAll(iframeIndex: number): void;
150
- callbackComplete(iframeIndex: number): void;
151
- visibleTextRects(iframeIndex: number): HTMLElementRect[];
152
- doneSpeaking(iframeIndex: number, reload?: boolean): void;
170
+ doHighlight(keepRange?: boolean, marker?: AnnotationMarker): void;
171
+ speak(): void;
172
+ stopReadAloud(): void;
173
+ speakAll(): void;
174
+ callbackComplete(): void;
175
+ get visibleTextRects(): HTMLElementRect[];
176
+ doneSpeaking(reload?: boolean): void;
153
177
  /**
154
178
  * Normalizes highlights. Ensures that highlighting is done with use of the smallest possible number of
155
179
  * wrapping HTML elements.
@@ -160,6 +184,13 @@ export default class TextHighlighter {
160
184
  * @memberof TextHighlighter
161
185
  */
162
186
  normalizeHighlights(highlights: any): any;
187
+ /**
188
+ * Flattens highlights structure.
189
+ * Note: this method changes input highlights - their order and number after calling this method may change.
190
+ * @param {Array} highlights - highlights to flatten.
191
+ * @memberof TextHighlighter
192
+ */
193
+ flattenNestedHighlights(highlights: any): void;
163
194
  /**
164
195
  * Merges sibling highlights and normalizes descendant text nodes.
165
196
  * Note: this method changes input highlights - their order and number after calling this method may change.
@@ -205,20 +236,21 @@ export default class TextHighlighter {
205
236
  };
206
237
  static hexToRgbA(hex: string): string;
207
238
  static hexToRgbAWithOpacity(hex: string, opacity: number): string;
208
- resetHighlightBoundingStyle(highlightBounding: HTMLElement): void;
209
- resetHighlightAreaStyle(highlightArea: HTMLElement, id_container: string, iframeIndex: number): void;
210
- setHighlightAreaStyle(highlightAreas: Array<HTMLElement>, highlight: IHighlight, iframeIndex: number): void;
211
- setAndResetSearchHighlight(highlight: any, highlights: any, iframeIndex: number): void;
239
+ resetHighlightBoundingStyle(_win: any, highlightBounding: HTMLElement): void;
240
+ resetHighlightAreaStyle(win: any, highlightArea: HTMLElement, id_container: string): void;
241
+ setHighlightAreaStyle(win: any, highlightAreas: Array<HTMLElement>, highlight: IHighlight): void;
242
+ setAndResetSearchHighlight(highlight: any, highlights: any): void;
212
243
  isIOS(): boolean;
213
244
  isAndroid(): boolean;
214
- getScrollingElement: (iframeDocument: Document) => Element;
215
- processMouseEvent(iframeIndex: number, ev: MouseEvent): Promise<void>;
216
- ensureHighlightsContainer(id: string, iframeIndex: number): HTMLElement;
217
- hideAllHighlights(iframeIndex: number): void;
218
- destroyAllHighlights(iframeIndex: number): void;
219
- destroyHighlights(type: HighlightType, iframeIndex: number): void;
220
- destroyHighlight(id: string, iframeIndex: number): void;
221
- 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];
222
- createHighlightDom(iframeIndex: number, highlight: IHighlight): HTMLDivElement | undefined;
245
+ getScrollingElement: (doc: Document) => Element;
246
+ processMouseEvent(win: any, ev: MouseEvent): Promise<void>;
247
+ ensureHighlightsContainer(win: any, id: string): Promise<HTMLElement>;
248
+ hideAllhighlights(doc: Document): void;
249
+ destroyAllhighlights(doc: Document): void;
250
+ removeAllChildNodes(parent: any): void;
251
+ destroyHighlights(type: HighlightType): void;
252
+ destroyHighlight(doc: Document, id: string): void;
253
+ 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];
254
+ createHighlightDom(win: any, highlight: IHighlight): HTMLDivElement | undefined;
223
255
  }
224
256
  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
+ Definition = 4,
43
+ LineFocus = 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;
@@ -18,6 +18,7 @@ export interface MediaOverlayModuleProperties {
18
18
  autoTurn?: boolean;
19
19
  volume?: number;
20
20
  wait?: number;
21
+ hideLayer?: boolean;
21
22
  }
22
23
  export interface MediaOverlayModuleConfig extends MediaOverlayModuleProperties {
23
24
  publication: Publication;
@@ -3,7 +3,10 @@ import ReaderModule from "../ReaderModule";
3
3
  import { IHighlight } from "../highlight/common/highlight";
4
4
  import { ISelectionInfo } from "../highlight/common/selection";
5
5
  import { Publication } from "../../model/Publication";
6
- export interface PageBreakModuleConfig {
6
+ export interface PageBreakModuleProperties {
7
+ hideLayer?: boolean;
8
+ }
9
+ export interface PageBreakModuleConfig extends PageBreakModuleProperties {
7
10
  delegate: IFrameNavigator;
8
11
  headerMenu: HTMLElement;
9
12
  publication: Publication;
@@ -12,6 +15,7 @@ export default class PageBreakModule implements ReaderModule {
12
15
  private delegate;
13
16
  private readonly headerMenu;
14
17
  private publication;
18
+ private properties;
15
19
  private goToPageView;
16
20
  private goToPageNumberInput;
17
21
  private goToPageNumberButton;
@@ -18,7 +18,8 @@ export interface Definition {
18
18
  export interface DefinitionsModuleProperties {
19
19
  definitions: Definition[];
20
20
  color?: string;
21
- api?: DefinitionsModuleAPI;
21
+ fullWordSearch?: boolean;
22
+ hideLayer?: boolean;
22
23
  }
23
24
  export interface DefinitionsModuleConfig extends DefinitionsModuleProperties {
24
25
  api: DefinitionsModuleAPI;
@@ -43,7 +44,9 @@ export default class DefinitionsModule implements ReaderModule {
43
44
  clear(): void;
44
45
  };
45
46
  define(item: Definition): Promise<void>;
46
- drawDefinitions(): void;
47
+ drawDefinitions(): Promise<void>;
47
48
  handleResize(): Promise<void>;
48
- createPopupHighlight(selectionInfo: ISelectionInfo, item: Definition): IHighlight;
49
+ createDefinitionHighlight(selectionInfo: ISelectionInfo, item: Definition): IHighlight;
50
+ addDefinition(definition: any): Promise<void>;
51
+ clearDefinitions(): Promise<void>;
49
52
  }
@@ -9,6 +9,7 @@ export interface SearchModuleAPI {
9
9
  export interface SearchModuleProperties {
10
10
  color?: string;
11
11
  current?: string;
12
+ hideLayer?: boolean;
12
13
  }
13
14
  export interface SearchModuleConfig extends SearchModuleProperties {
14
15
  api: SearchModuleAPI;
@@ -11,4 +11,4 @@ export interface ISearchResult {
11
11
  }
12
12
  export declare function escapeRegExp(str: string): string;
13
13
  export declare const reset: () => void;
14
- export declare function searchDocDomSeek(searchInput: string, doc: Document, href: string, title: string): Promise<ISearchResult[]>;
14
+ export declare function searchDocDomSeek(searchInput: string, doc: Document, href: string, title: string, fullWordSearch?: boolean): Promise<ISearchResult[]>;
@@ -14,8 +14,9 @@ import MediaOverlayModule, { MediaOverlayModuleConfig } from "../modules/mediaov
14
14
  import { D2Link, Link } from "../model/Link";
15
15
  import ReaderModule from "../modules/ReaderModule";
16
16
  import { TTSModuleConfig } from "../modules/TTS/TTSSettings";
17
- import PageBreakModule from "../modules/pagebreak/PageBreakModule";
17
+ import PageBreakModule, { PageBreakModuleConfig } 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 {
@@ -90,6 +91,8 @@ export interface ReaderRights {
90
91
  enableTimeline?: boolean;
91
92
  autoGeneratePositions?: boolean;
92
93
  enableMediaOverlays?: boolean;
94
+ enablePageBreaks?: boolean;
95
+ enableLineFocus?: boolean;
93
96
  }
94
97
  export interface ReaderUI {
95
98
  settings: UserSettingsUIConfig;
@@ -108,8 +111,10 @@ export interface ReaderConfig {
108
111
  define?: DefinitionsModuleConfig;
109
112
  protection?: ContentProtectionModuleConfig;
110
113
  mediaOverlays?: MediaOverlayModuleConfig;
114
+ pagebreak?: PageBreakModuleConfig;
111
115
  annotations?: AnnotationModuleConfig;
112
116
  bookmarks?: BookmarkModuleConfig;
117
+ lineFocus?: LineFocusModuleConfig;
113
118
  highlighter?: TextHighlighterConfig;
114
119
  injectables: Array<Injectable>;
115
120
  injectablesFixed: Array<Injectable>;
@@ -135,6 +140,7 @@ export default class IFrameNavigator implements Navigator {
135
140
  timelineModule?: TimelineModule;
136
141
  pageBreakModule?: PageBreakModule;
137
142
  mediaOverlayModule?: MediaOverlayModule;
143
+ lineFocusModule?: LineFocusModule;
138
144
  sideNavExpanded: boolean;
139
145
  material: boolean;
140
146
  mTabs: Array<any>;
@@ -280,4 +286,6 @@ export default class IFrameNavigator implements Navigator {
280
286
  private static createJavascriptLink;
281
287
  activateMarker(id: any, position: any): void;
282
288
  deactivateMarker(): void;
289
+ showLayer(layer: any): void;
290
+ hideLayer(layer: any): void;
283
291
  }