@d-i-t-a/reader 1.12.0-alpha.3 → 1.12.0-beta.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.d.ts CHANGED
@@ -33,6 +33,11 @@ export declare function publicationLanguage(): string[];
33
33
  export declare function resetUserSettings(): Promise<void>;
34
34
  export declare function applyUserSettings(userSettings: any): Promise<void>;
35
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;
36
41
  export declare function currentSettings(): Promise<{
37
42
  appearance: string;
38
43
  fontFamily: string;
@@ -67,8 +72,6 @@ export declare function goToPosition(value: any): void;
67
72
  export declare function applyAttributes(value: any): void;
68
73
  export declare function hideAnnotationLayer(): void;
69
74
  export declare function showAnnotationLayer(): void;
70
- export declare function lineUp(): void;
71
- export declare function lineDown(): void;
72
75
  export declare function hideLayer(layer: any): void;
73
76
  export declare function showLayer(layer: any): void;
74
77
  export declare function clearDefinitions(): Promise<void>;
@@ -76,7 +79,4 @@ export declare function addDefinition(definition: any): Promise<void>;
76
79
  export declare function snapToElement(value: any): void;
77
80
  export declare function activateMarker(id: any, position: any): void;
78
81
  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;
82
82
  export declare function load(config: ReaderConfig): Promise<any>;
@@ -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,16 +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";
11
- export declare const ID_LINEFOCUS_CONTAINER = "R2_ID_LINEFOCUS_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
+ }
12
16
  export declare const CLASS_HIGHLIGHT_CONTAINER = "R2_CLASS_HIGHLIGHT_CONTAINER";
17
+ export declare const CLASS_HIGHLIGHT_BOUNDING_AREA = "R2_CLASS_HIGHLIGHT_BOUNDING_AREA";
13
18
  export declare const CLASS_HIGHLIGHT_AREA = "R2_CLASS_HIGHLIGHT_AREA";
14
19
  export declare const CLASS_HIGHLIGHT_ICON = "R2_CLASS_HIGHLIGHT_ICON";
15
- export declare const CLASS_HIGHLIGHT_BOUNDING_AREA = "R2_CLASS_HIGHLIGHT_BOUNDING_AREA";
16
20
  export declare const DEFAULT_BACKGROUND_COLOR: {
17
21
  blue: number;
18
22
  green: number;
@@ -44,10 +48,13 @@ export interface TextHighlighterProperties {
44
48
  export interface TextHighlighterConfig extends TextHighlighterProperties {
45
49
  delegate: IFrameNavigator;
46
50
  api: TextSelectorAPI;
51
+ layerSettings: LayerSettings;
47
52
  }
48
53
  export default class TextHighlighter {
49
54
  private options;
50
55
  private readonly delegate;
56
+ layerSettings: LayerSettings;
57
+ private lastSelectedHighlight;
51
58
  properties: TextHighlighterProperties;
52
59
  private api;
53
60
  private hasEventListener;
@@ -102,6 +109,22 @@ export default class TextHighlighter {
102
109
  endOffset: number;
103
110
  startOffset: number;
104
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>;
105
128
  /**
106
129
  * Utility functions to make DOM manipulation easier.
107
130
  * @param {Node|HTMLElement} [el] - base DOM element to manipulate
@@ -112,8 +135,8 @@ export default class TextHighlighter {
112
135
  preventDefault: () => void;
113
136
  stopPropagation: () => void;
114
137
  }): boolean;
115
- bindEvents(iframeIndex: number, hasEventListener: boolean): void;
116
- unbindEvents(iframeIndex: number): void;
138
+ bindEvents(el: any, _scope: any, hasEventListener: boolean): void;
139
+ unbindEvents(el: any, _scope: any): void;
117
140
  /**
118
141
  * Permanently disables highlighting.
119
142
  * Unbinds events and remove context element class.
@@ -123,9 +146,9 @@ export default class TextHighlighter {
123
146
  initializeToolbox(): void;
124
147
  toolboxMode(mode: "colors" | "edit" | "add" | "action"): void;
125
148
  toolboxHide(): void;
126
- toolboxShowDelayed(iframeIndex: number): void;
127
- snapSelectionToWord(iframeIndex: number): any;
128
- toolboxShow(iframeIndex: number): void;
149
+ toolboxShowDelayed(): void;
150
+ snapSelectionToWord(): any;
151
+ toolboxShow(): void;
129
152
  isSelectionMenuOpen: boolean;
130
153
  selectionMenuOpened: (() => void) & {
131
154
  clear(): void;
@@ -136,21 +159,21 @@ export default class TextHighlighter {
136
159
  selection: ((text: any, selection: any) => void) & {
137
160
  clear(): void;
138
161
  };
139
- toolboxPlacement(iframeIndex: number): void;
140
- toolboxHandler(iframeIndex: number): void;
162
+ toolboxPlacement(): void;
163
+ toolboxHandler(): void;
141
164
  /**
142
165
  * Highlights current range.
143
166
  * @param {boolean} keepRange - Don't remove range after highlighting. Default: false.
144
167
  * @param marker
145
168
  * @memberof TextHighlighter
146
169
  */
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
+ 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;
154
177
  /**
155
178
  * Normalizes highlights. Ensures that highlighting is done with use of the smallest possible number of
156
179
  * wrapping HTML elements.
@@ -161,6 +184,13 @@ export default class TextHighlighter {
161
184
  * @memberof TextHighlighter
162
185
  */
163
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;
164
194
  /**
165
195
  * Merges sibling highlights and normalizes descendant text nodes.
166
196
  * Note: this method changes input highlights - their order and number after calling this method may change.
@@ -206,20 +236,21 @@ export default class TextHighlighter {
206
236
  };
207
237
  static hexToRgbA(hex: string): string;
208
238
  static hexToRgbAWithOpacity(hex: string, opacity: number): string;
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;
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;
213
243
  isIOS(): boolean;
214
244
  isAndroid(): boolean;
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;
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;
224
255
  }
225
256
  export {};
@@ -39,8 +39,8 @@ export declare enum HighlightType {
39
39
  Search = 1,
40
40
  ReadAloud = 2,
41
41
  PageBreak = 3,
42
- Popup = 4,
43
- Lines = 5
42
+ Definition = 4,
43
+ LineFocus = 5
44
44
  }
45
45
  export interface IHighlight {
46
46
  id: string;
@@ -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;
@@ -19,7 +19,7 @@ export interface DefinitionsModuleProperties {
19
19
  definitions: Definition[];
20
20
  color?: string;
21
21
  fullWordSearch?: boolean;
22
- api?: DefinitionsModuleAPI;
22
+ hideLayer?: boolean;
23
23
  }
24
24
  export interface DefinitionsModuleConfig extends DefinitionsModuleProperties {
25
25
  api: DefinitionsModuleAPI;
@@ -46,7 +46,7 @@ export default class DefinitionsModule implements ReaderModule {
46
46
  define(item: Definition): Promise<void>;
47
47
  drawDefinitions(): void;
48
48
  handleResize(): Promise<void>;
49
- createPopupHighlight(selectionInfo: ISelectionInfo, item: Definition): IHighlight;
49
+ createDefinitionHighlight(selectionInfo: ISelectionInfo, item: Definition): IHighlight;
50
50
  addDefinition(definition: any): Promise<void>;
51
51
  clearDefinitions(): Promise<void>;
52
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;
@@ -14,7 +14,7 @@ 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
19
  import LineFocusModule, { LineFocusModuleConfig } from "../modules/linefocus/LineFocusModule";
20
20
  export declare type GetContent = (href: string) => Promise<string>;
@@ -86,12 +86,13 @@ export interface ReaderRights {
86
86
  enableTTS?: boolean;
87
87
  enableSearch?: boolean;
88
88
  enableDefinitions?: boolean;
89
- enableLineFocus?: boolean;
90
89
  enableContentProtection?: boolean;
91
90
  enableMaterial?: boolean;
92
91
  enableTimeline?: boolean;
93
92
  autoGeneratePositions?: boolean;
94
93
  enableMediaOverlays?: boolean;
94
+ enablePageBreaks?: boolean;
95
+ enableLineFocus?: boolean;
95
96
  }
96
97
  export interface ReaderUI {
97
98
  settings: UserSettingsUIConfig;
@@ -108,11 +109,12 @@ export interface ReaderConfig {
108
109
  tts?: TTSModuleConfig;
109
110
  search?: SearchModuleConfig;
110
111
  define?: DefinitionsModuleConfig;
111
- lineFocus?: LineFocusModuleConfig;
112
112
  protection?: ContentProtectionModuleConfig;
113
113
  mediaOverlays?: MediaOverlayModuleConfig;
114
+ pagebreak?: PageBreakModuleConfig;
114
115
  annotations?: AnnotationModuleConfig;
115
116
  bookmarks?: BookmarkModuleConfig;
117
+ lineFocus?: LineFocusModuleConfig;
116
118
  highlighter?: TextHighlighterConfig;
117
119
  injectables: Array<Injectable>;
118
120
  injectablesFixed: Array<Injectable>;
@@ -133,12 +135,12 @@ export default class IFrameNavigator implements Navigator {
133
135
  ttsModule?: ReaderModule;
134
136
  searchModule?: SearchModule;
135
137
  definitionsModule?: DefinitionsModule;
136
- lineFocusModule?: LineFocusModule;
137
138
  contentProtectionModule?: ContentProtectionModule;
138
139
  highlighter?: TextHighlighter;
139
140
  timelineModule?: TimelineModule;
140
141
  pageBreakModule?: PageBreakModule;
141
142
  mediaOverlayModule?: MediaOverlayModule;
143
+ lineFocusModule?: LineFocusModule;
142
144
  sideNavExpanded: boolean;
143
145
  material: boolean;
144
146
  mTabs: Array<any>;