@d-i-t-a/reader 1.11.0 → 1.11.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.
@@ -0,0 +1,18 @@
1
+ import Store from "./Store";
2
+ import Positions from "./Positions";
3
+ export interface LocalAnnotatorConfig {
4
+ store: Store;
5
+ }
6
+ /** Annotator that stores annotations locally, in the browser. */
7
+ export default class LocalPositions implements Positions {
8
+ private readonly store;
9
+ private static readonly POSITIONS;
10
+ private static readonly WEIGHT;
11
+ constructor(config: LocalAnnotatorConfig);
12
+ savePositions(positions: any): Promise<any>;
13
+ deletePositions(): Promise<any>;
14
+ getPositions(): Promise<any>;
15
+ saveWeights(weights: any): Promise<any>;
16
+ deleteWeights(): Promise<any>;
17
+ getWeights(): Promise<any>;
18
+ }
@@ -0,0 +1,9 @@
1
+ interface Positions {
2
+ savePositions(positions: any): Promise<any>;
3
+ deletePositions(): Promise<any>;
4
+ getPositions(): Promise<any>;
5
+ saveWeights(weights: any): Promise<any>;
6
+ deleteWeights(): Promise<any>;
7
+ getWeights(): Promise<any>;
8
+ }
9
+ export default Positions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-i-t-a/reader",
3
- "version": "1.11.0",
3
+ "version": "1.11.3",
4
4
  "description": "A viewer application for EPUB files.",
5
5
  "repository": "https://github.com/d-i-t-a/R2D2BC",
6
6
  "license": "Apache-2.0",
@@ -21,7 +21,8 @@
21
21
  "streamed": "node \"./examples/streamed/server/server-cli.inlinesourcemap.js\" ./examples/streamed/epubs/",
22
22
  "clean": "rimraf node_modules lib dist examples/streamed/readers/viewer",
23
23
  "start": "http-server viewer",
24
- "lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix"
24
+ "lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
25
+ "serve": "npm run build && npm run examples && npm run streamed"
25
26
  },
26
27
  "dependencies": {
27
28
  "browserslist-useragent": "^3.0.3",
package/NOTICE DELETED
@@ -1,20 +0,0 @@
1
- R2D2BC
2
- Copyright 2018-2020 DITA (AM Consulting LLC)
3
-
4
- This project bundles the following dependencies under the MIT license.
5
- See bundled license files for details.
6
-
7
- - Materialize | Copyright (c) 2014-2018 Materialize
8
- -> in "styles/sass/materialize"
9
-
10
- This project bundles the following dependencies under the SIL Open Font License.
11
- See bundled license files for details.
12
-
13
- - OpenDyxslexic Font | Copyright (c) 12/2012 - 2019
14
- -> in "viewer/fonts/opendyslexic"
15
-
16
- This project bundles the following dependencies under the BSD license.
17
- See bundled license files for details.
18
-
19
- - Readium-CSS | Copyright (c) 2017, Readium
20
- -> in "viewer/readium-css"
@@ -1,6 +0,0 @@
1
- /*!
2
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
3
- *
4
- * Copyright (c) 2014-2017, Jon Schlinkert.
5
- * Released under the MIT License.
6
- */
@@ -1,37 +0,0 @@
1
- import { Publication } from "../../model/Publication";
2
- import IFrameNavigator from "../../navigator/IFrameNavigator";
3
- import ReaderModule from "../ReaderModule";
4
- export declare enum CitationStyle {
5
- Chicago = 0,
6
- MLA = 1,
7
- APA = 2
8
- }
9
- export declare enum ContributorType {
10
- Author = "Author",
11
- Editor = "Editor",
12
- Translator = "Translator",
13
- Compiler = "Compiler"
14
- }
15
- export interface CitationModuleProperties {
16
- characters: number;
17
- appName: string;
18
- appLink: string;
19
- library: string;
20
- styles: string[];
21
- }
22
- export interface CitationModuleConfig extends CitationModuleProperties {
23
- publication: Publication;
24
- delegate: IFrameNavigator;
25
- }
26
- export default class CitationModule implements ReaderModule {
27
- private publication;
28
- private delegate;
29
- private properties;
30
- static create(config: CitationModuleConfig): Promise<CitationModule>;
31
- private constructor();
32
- stop(): Promise<void>;
33
- protected start(): Promise<void>;
34
- copyToClipboard(textToClipboard: any): void;
35
- createElementForExecCommand(textToClipboard: any): HTMLDivElement;
36
- selectContent(element: any): void;
37
- }
File without changes
@@ -1,278 +0,0 @@
1
- import { HighlightType, IHighlight, IMarkerIcon, IPopupStyle, IStyle, SelectionMenuItem } from "./common/highlight";
2
- import { ISelectionInfo } from "./common/selection";
3
- import { IRectSimple } from "./common/rect-utils";
4
- import { IReadiumIFrameWindow } from "./renderer/iframe/state";
5
- import { AnnotationMarker } from "../../model/Locator";
6
- import IFrameNavigator from "../../navigator/IFrameNavigator";
7
- import { Definition } from "../search/DefinitionsModule";
8
- export declare const ID_HIGHLIGHTS_CONTAINER = "R2_ID_HIGHLIGHTS_CONTAINER";
9
- export declare const ID_READALOUD_CONTAINER = "R2_ID_READALOUD_CONTAINER";
10
- export declare const ID_POPUP_CONTAINER = "R2_ID_POPUP_CONTAINER";
11
- export declare const CLASS_HIGHLIGHT_CONTAINER = "R2_CLASS_HIGHLIGHT_CONTAINER";
12
- export declare const CLASS_HIGHLIGHT_AREA = "R2_CLASS_HIGHLIGHT_AREA";
13
- export declare const CLASS_HIGHLIGHT_ICON = "R2_CLASS_HIGHLIGHT_ICON";
14
- export declare const CLASS_HIGHLIGHT_BOUNDING_AREA = "R2_CLASS_HIGHLIGHT_BOUNDING_AREA";
15
- export declare const _highlights: IHighlight[];
16
- interface IWithRect {
17
- rect: IRectSimple;
18
- scale: number;
19
- }
20
- export interface TextSelectorAPI {
21
- selectionMenuOpen: any;
22
- selectionMenuClose: any;
23
- selection: any;
24
- }
25
- export interface IHTMLDivElementWithRect extends HTMLDivElement, IWithRect {
26
- }
27
- export interface HTMLElementRect {
28
- node: Element;
29
- height: number;
30
- top: number;
31
- width: number;
32
- left: number;
33
- textContent: string;
34
- }
35
- export interface TextHighlighterProperties {
36
- selectionMenuItems: Array<SelectionMenuItem>;
37
- }
38
- export interface TextHighlighterConfig extends TextHighlighterProperties {
39
- delegate: IFrameNavigator;
40
- api: TextSelectorAPI;
41
- }
42
- export default class TextHighlighterFXL {
43
- private options;
44
- private readonly delegate;
45
- private lastSelectedHighlight;
46
- properties: TextHighlighterProperties;
47
- private api;
48
- private hasEventListener;
49
- activeAnnotationMarkerId?: string;
50
- static create(config: TextHighlighterConfig): Promise<any>;
51
- private constructor();
52
- initialize(): Promise<void>;
53
- /**
54
- * Returns true if elements a i b have the same color.
55
- * @param {Node} a
56
- * @param {Node} b
57
- * @returns {boolean}
58
- */
59
- haveSameColor(a: any, b: any): boolean;
60
- /**
61
- * Fills undefined values in obj with default properties with the same name from source object.
62
- * @param {object} obj - target object
63
- * @param {object} source - source object with default values
64
- * @returns {object}
65
- */
66
- defaults(obj: {
67
- [x: string]: any;
68
- }, source: {
69
- [x: string]: any;
70
- color?: string;
71
- highlightedClass?: string;
72
- contextClass?: string;
73
- onBeforeHighlight?: () => boolean;
74
- onAfterHighlight?: () => void;
75
- container?: any;
76
- andSelf?: boolean;
77
- grouped?: boolean;
78
- hasOwnProperty?: any;
79
- }): object;
80
- /**
81
- * Returns array without duplicated values.
82
- * @param {Array} arr
83
- * @returns {Array}
84
- */
85
- unique(arr: {
86
- filter: (arg0: (value: any, idx: any, self: any) => boolean) => void;
87
- }): void;
88
- /**
89
- * Takes range object as parameter and refines it boundaries
90
- * @param range
91
- * @returns {object} refined boundaries and initial state of highlighting algorithm.
92
- */
93
- refineRangeBoundaries(range: {
94
- startContainer: any;
95
- endContainer: any;
96
- commonAncestorContainer: any;
97
- endOffset: number;
98
- startOffset: number;
99
- }): object;
100
- /**
101
- * Sorts array of DOM elements by its depth in DOM tree.
102
- * @param {HTMLElement[]} arr - array to sort.
103
- * @param {boolean} descending - order of sort.
104
- */
105
- sortByDepth(arr: {
106
- sort: (arg0: (a: any, b: any) => number) => void;
107
- }, descending: boolean): void;
108
- /**
109
- * Groups given highlights by timestamp.
110
- * @param {Array} highlights
111
- * @returns {Array} Grouped highlights.
112
- */
113
- groupHighlights(highlights: {
114
- forEach: (arg0: (hl: any) => void) => void;
115
- }): Array<any>;
116
- /**
117
- * Utility functions to make DOM manipulation easier.
118
- * @param {Node|HTMLElement} [el] - base DOM element to manipulate
119
- * @returns {object}
120
- */
121
- dom(el?: any): any;
122
- disableContext(e: {
123
- preventDefault: () => void;
124
- stopPropagation: () => void;
125
- }): boolean;
126
- bindEvents(el: any, _scope: any, hasEventListener: boolean): void;
127
- unbindEvents(el: any, _scope: any): void;
128
- /**
129
- * Permanently disables highlighting.
130
- * Unbinds events and remove context element class.
131
- * @memberof TextHighlighter
132
- */
133
- destroy(): void;
134
- initializeToolbox(): void;
135
- toolboxMode(mode: "colors" | "edit" | "add" | "action"): void;
136
- toolboxHide(): void;
137
- toolboxShowDelayed(): void;
138
- snapSelectionToWord(): any;
139
- toolboxShow(): void;
140
- isSelectionMenuOpen: boolean;
141
- selectionMenuOpened: (() => void) & {
142
- clear(): void;
143
- };
144
- selectionMenuClosed: (() => void) & {
145
- clear(): void;
146
- };
147
- selection: ((text: any, selection: any) => void) & {
148
- clear(): void;
149
- };
150
- toolboxPlacement(): void;
151
- toolboxHandler(): void;
152
- /**
153
- * Highlights current range.
154
- * @param {boolean} keepRange - Don't remove range after highlighting. Default: false.
155
- * @param marker
156
- * @memberof TextHighlighter
157
- */
158
- doHighlight(iframe: any, keepRange?: boolean, marker?: AnnotationMarker): void;
159
- speak(iframe: any): void;
160
- stopReadAloud(): void;
161
- speakAll(iframe: any): void;
162
- callbackComplete(): void;
163
- visibleTextRects(iframe: any): HTMLElementRect[];
164
- doneSpeaking(reload?: boolean): void;
165
- /**
166
- * Normalizes highlights. Ensures that highlighting is done with use of the smallest possible number of
167
- * wrapping HTML elements.
168
- * Flattens highlights structure and merges sibling highlights. Normalizes text nodes within highlights.
169
- * @param {Array} highlights - highlights to normalize.
170
- * @returns {Array} - array of normalized highlights. Order and number of returned highlights may be different than
171
- * input highlights.
172
- * @memberof TextHighlighter
173
- */
174
- normalizeHighlights(highlights: any): any;
175
- /**
176
- * Flattens highlights structure.
177
- * Note: this method changes input highlights - their order and number after calling this method may change.
178
- * @param {Array} highlights - highlights to flatten.
179
- * @memberof TextHighlighter
180
- */
181
- flattenNestedHighlights(highlights: any): void;
182
- /**
183
- * Merges sibling highlights and normalizes descendant text nodes.
184
- * Note: this method changes input highlights - their order and number after calling this method may change.
185
- * @param highlights
186
- * @memberof TextHighlighter
187
- */
188
- mergeSiblingHighlights(highlights: any): void;
189
- /**
190
- * Sets highlighting color.
191
- * @param {string} color - valid CSS color.
192
- * @memberof TextHighlighter
193
- */
194
- setColor(color: any): void;
195
- /**
196
- * Returns highlighting color.
197
- * @returns {string}
198
- * @memberof TextHighlighter
199
- */
200
- getColor(): string;
201
- /**
202
- * Returns highlights from given container.
203
- * @param params
204
- * @param {HTMLElement} [params.container] - return highlights from this element. Default: the element the
205
- * highlighter is applied to.
206
- * @param {boolean} [params.andSelf] - if set to true and container is a highlight itself, add container to
207
- * returned results. Default: true.
208
- * @param {boolean} [params.grouped] - if set to true, highlights are grouped in logical groups of highlights added
209
- * in the same moment. Each group is an object which has got array of highlights, 'toString' method and 'timestamp'
210
- * property. Default: false.
211
- * @returns {Array} - array of highlights.
212
- * @memberof TextHighlighter
213
- */
214
- getHighlights(iframe: any, params?: any): Array<any>;
215
- /**
216
- * Returns true if element is a highlight.
217
- * All highlights have 'data-highlighted' attribute.
218
- * @param el - element to check.
219
- * @returns {boolean}
220
- * @memberof TextHighlighter
221
- */
222
- isHighlight(el: any): boolean;
223
- /**
224
- * Serializes all highlights in the element the highlighter is applied to.
225
- * @returns {string} - stringified JSON with highlights definition
226
- * @memberof TextHighlighter
227
- */
228
- serializeHighlights(iframe: any): string;
229
- /**
230
- * Deserializes highlights.
231
- * @throws exception when can't parse JSON or JSON has invalid structure.
232
- * @param {object} json - JSON object with highlights definition.
233
- * @returns {Array} - array of deserialized highlights.
234
- * @memberof TextHighlighter
235
- */
236
- deserializeHighlights(iframe: any, json: any): Array<any>;
237
- /**
238
- * Creates wrapper for highlights.
239
- * TextHighlighter instance calls this method each time it needs to create highlights and pass options retrieved
240
- * in constructor.
241
- * @returns {HTMLElement}
242
- * @memberof TextHighlighter
243
- * @static
244
- */
245
- createWrapper(): HTMLElement;
246
- static isHexColor(hex: string): boolean;
247
- static hexToRgbString(hex: string): any;
248
- static hexToRgbChannels(hex: string): {
249
- red: number;
250
- green: number;
251
- blue: number;
252
- };
253
- static hexToRgbA(hex: string): string;
254
- static hexToRgbAWithOpacity(hex: string, opacity: number): string;
255
- resetHighlightBoundingStyle(_win: IReadiumIFrameWindow, highlightBounding: HTMLElement): void;
256
- resetHighlightAreaStyle(_win: IReadiumIFrameWindow, highlightArea: HTMLElement, id_container: string): void;
257
- setHighlightAreaStyle(_win: IReadiumIFrameWindow, highlightAreas: Array<HTMLElement>, highlight: IHighlight): void;
258
- isIOS(): boolean;
259
- isAndroid(): boolean;
260
- getScrollingElement: (documant: Document) => Element;
261
- processMouseEvent(win: IReadiumIFrameWindow, ev: MouseEvent): Promise<void>;
262
- ensureHighlightsContainer(win: IReadiumIFrameWindow, id: string): HTMLElement;
263
- hideAllhighlights(_documant: Document): void;
264
- destroyAllhighlights(documant: Document): void;
265
- destroyHighlights(type: HighlightType): void;
266
- destroyHighlight(documant: Document, id: string): void;
267
- recreateAllHighlightsRaw(win: IReadiumIFrameWindow): void;
268
- recreateAllHighlightsDebounced: ((win: IReadiumIFrameWindow) => void) & {
269
- clear(): void;
270
- };
271
- recreateAllHighlights(win: IReadiumIFrameWindow): void;
272
- createPopupHighlight(iframe: any, selectionInfo: ISelectionInfo, item: Definition): IHighlight;
273
- createSearchHighlight(iframe: any, selectionInfo: ISelectionInfo, color: string): IHighlight;
274
- createPageBreakHighlight(iframe: any, selectionInfo: ISelectionInfo, title: string): IHighlight;
275
- createHighlight(win: IReadiumIFrameWindow, 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];
276
- createHighlightDom(win: IReadiumIFrameWindow, highlight: IHighlight): HTMLDivElement | undefined;
277
- }
278
- export {};