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

Add metatags for annotations

This commit is contained in:
Fred Chasen 2017-07-06 17:53:48 -04:00
parent fdf7fda0d9
commit 661d4d77d1
9 changed files with 111 additions and 50 deletions

View file

@ -76,6 +76,8 @@ class Rendition {
this.hooks.content.register(this.passEvents.bind(this));
this.hooks.content.register(this.adjustImages.bind(this));
this.book.spine.hooks.content.register(this.injectSource.bind(this));
if (this.settings.stylesheet) {
this.book.spine.hooks.content.register(this.injectStylesheet.bind(this));
}
@ -661,10 +663,12 @@ class Rendition {
}
handleLinks(contents) {
contents.on("link", (href) => {
let relative = this.book.path.relative(href);
this.display(relative);
});
if (contents) {
contents.on("link", (href) => {
let relative = this.book.path.relative(href);
this.display(relative);
});
}
}
injectStylesheet(doc, section) {
@ -683,6 +687,16 @@ class Rendition {
doc.getElementsByTagName("head")[0].appendChild(script);
}
injectSource(doc, section) {
let ident = this.book.package.metadata.identifier;
let meta = doc.createElement("meta");
meta.setAttribute("property", "dc:source");
if (ident) {
meta.setAttribute("contents", ident);
}
doc.getElementsByTagName("head")[0].appendChild(meta);
}
}
//-- Enable binding events to Renderer