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

marksClicked event

This commit is contained in:
Fred Chasen 2017-04-27 13:51:49 -04:00
parent a2c8ac6d94
commit 1eb2566b15
3 changed files with 23 additions and 7 deletions

View file

@ -79,7 +79,8 @@
this.rendition.themes.default({
'p': {
'padding': '0 35px',
'padding': '0 20px 0 0',
'text-align': 'left',
'position': 'relative'
},
'[ref="epubjs-mk"]::before' : {
@ -88,8 +89,9 @@
'display': 'block',
'right' : '0',
'position' : 'absolute',
'width': '30px',
'height': '30px',
'width': '20px',
'height': '20px',
'margin': '0',
'cursor': 'pointer'
}
});

View file

@ -1,6 +1,6 @@
{
"name": "epubjs",
"version": "0.3.27",
"version": "0.3.28",
"description": "Parse and Render Epubs",
"main": "lib/index.js",
"module": "src/index.js",

View file

@ -6,7 +6,7 @@ import {replaceLinks} from "./utils/replacements";
import { Pane, Highlight, Underline } from "marks-pane";
// Dom events to listen for
const EVENTS = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click", "touchend", "touchstart"];
const EVENTS = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click", "touchend", "touchstart", "markClicked"];
class Contents {
constructor(doc, content, cfiBase) {
@ -767,6 +767,11 @@ class Contents {
let m = new Highlight(range, "epubjs-hl", data, {'fill': 'yellow', 'fill-opacity': '0.3', 'mix-blend-mode': 'multiply'});
let h = this.pane.addMark(m);
h.addEventListener("click", () => {
this.emit("markClicked", cfiRange, data);
});
if (cb) {
h.element.addEventListener("click", cb);
}
@ -784,6 +789,11 @@ class Contents {
let m = new Underline(range, "epubjs-ul", data, {'stroke': 'black', 'stroke-opacity': '0.3', 'mix-blend-mode': 'multiply'});
let h = this.pane.addMark(m);
h.addEventListener("click", () => {
this.emit("markClicked", cfiRange, data);
});
if (cb) {
h.element.addEventListener("click", cb);
}
@ -801,16 +811,20 @@ class Contents {
parent.dataset["epubcfi"] = cfiRange;
if (data) {
Object.entries(data).forEach(([key, val]) => {
parent.dataset[key] = val;
Object.keys(data).forEach((key) => {
parent.dataset[key] = data[key];
});
}
parent.addEventListener("click", () => {
this.emit("markClicked", cfiRange, data);
});
if (cb) {
parent.addEventListener("click", cb);
}
return parent;
}
destroy() {