1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Add methods to mark a paragraph by cfi (#604)

* Add highlight to contents

* Add marks and pass data to highlights

* Add marks example

* Only add pane when highlight is added

* Include marks in babel processing
This commit is contained in:
Fred Chasen 2017-04-24 15:42:16 -04:00 committed by GitHub
parent f0856ea78c
commit 32672359f5
7 changed files with 206 additions and 133 deletions

View file

@ -310,7 +310,7 @@ class Rendition {
*/
afterDisplayed(view){
this.hooks.content.trigger(view.contents, this);
this.emit("rendered", view.section);
this.emit("rendered", view.section, view);
// this.reportLocation();
}
@ -550,11 +550,11 @@ class Rendition {
passEvents(contents){
var listenedEvents = Contents.listenedEvents;
listenedEvents.forEach(function(e){
contents.on(e, this.triggerViewEvent.bind(this));
}.bind(this));
listenedEvents.forEach((e) => {
contents.on(e, (ev) => this.triggerViewEvent(ev, contents));
});
contents.on("selected", this.triggerSelectedEvent.bind(this));
contents.on("selected", (e) => this.triggerSelectedEvent(e, contents));
}
/**
@ -562,8 +562,8 @@ class Rendition {
* @private
* @param {event} e
*/
triggerViewEvent(e){
this.emit(e.type, e);
triggerViewEvent(e, contents){
this.emit(e.type, e, contents);
}
/**
@ -571,8 +571,8 @@ class Rendition {
* @private
* @param {EpubCFI} cfirange
*/
triggerSelectedEvent(cfirange){
this.emit("selected", cfirange);
triggerSelectedEvent(cfirange, contents){
this.emit("selected", cfirange, contents);
}
/**