Skip to content

Commit

Permalink
Merge pull request #29 from d-i-t-a/feature/injectable-context-menu
Browse files Browse the repository at this point in the history
Feature/injectable context menu
  • Loading branch information
aferditamuriqi authored May 16, 2020
2 parents f880fd6 + d023334 commit 348e24e
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 74 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "1.1.2",
"version": "1.1.3",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"main": "src/index.js",
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export async function load(config: ReaderConfig): Promise<any> {
initialLastReadingPosition: config.lastReadingPosition,
material: config.material,
api: config.api,
injectables: config.injectables
injectables: config.injectables,
selectionMenuItems: config.selectionMenuItems,
initialAnnotationColor: config.initialAnnotationColor
})
// add custom modules
// Bookmark Module
Expand Down
13 changes: 10 additions & 3 deletions src/modules/AnnotationModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import * as HTMLUtilities from "../utils/HTMLUtilities";
import Annotator, { AnnotationType } from "../store/Annotator";
import IFrameNavigator, { ReaderRights } from "../navigator/IFrameNavigator";
import IFrameNavigator, { ReaderRights, SelectionMenuItem } from "../navigator/IFrameNavigator";
import Publication, { Link } from "../model/Publication";
import TextHighlighter, { _highlights } from "./highlight/TextHighlighter";
import ReaderModule from "./ReaderModule";
Expand Down Expand Up @@ -52,6 +52,7 @@ export default class AnnotationModule implements ReaderModule {
private initialAnnotations: any;

delegate: IFrameNavigator
selectionMenuItems: SelectionMenuItem[];

public static async create(config: AnnotationModuleConfig) {
const annotations = new this(
Expand Down Expand Up @@ -103,13 +104,16 @@ export default class AnnotationModule implements ReaderModule {
}, 10);
}

initialize() {
initialAnnotationColor?: string

initialize(initialAnnotationColor?:string) {
this.initialAnnotationColor = initialAnnotationColor
return new Promise(async (resolve) => {
await (document as any).fonts.ready;
if (this.rights.enableAnnotations) {
const body = HTMLUtilities.findRequiredIframeElement(this.delegate.iframe.contentDocument, "body") as HTMLBodyElement;
var self = this
this.highlighter = new TextHighlighter(this, body, {
this.highlighter = new TextHighlighter(this, body, this.selectionMenuItems, {
onBeforeHighlight: function (selectionInfo: any) {
if (IS_DEV) {
console.log("onBeforeHighlight")
Expand Down Expand Up @@ -320,6 +324,9 @@ export default class AnnotationModule implements ReaderModule {
});
}
}
if (this.initialAnnotationColor) {
this.highlighter.setColor(this.initialAnnotationColor);
}
}
}

Expand Down
Loading

0 comments on commit 348e24e

Please sign in to comment.