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

View file

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

View file

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