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

Fix removing annotations with no type and attaching marks to invalid cfi

This commit is contained in:
Fred Chasen 2017-10-04 18:45:15 -07:00
parent 4f4a13fadb
commit bbb05616ab
7 changed files with 14 additions and 11 deletions

View file

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

View file

@ -61,7 +61,7 @@ class Annotations {
let views = this.rendition.views();
views.each( (view) => {
views.forEach( (view) => {
if (annotation.sectionIndex === view.index) {
annotation.attach(view);
}
@ -75,12 +75,13 @@ class Annotations {
if (hash in this._annotations) {
let annotation = this._annotations[hash];
if (annotation.type !== type) {
if (type && annotation.type !== type) {
return;
}
let views = this.rendition.views();
views.each( (view) => {
views.forEach( (view) => {
this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash);
if (annotation.sectionIndex === view.index) {
annotation.detach(view);

View file

@ -928,7 +928,7 @@ class EpubCFI {
range.setStart(missed.container, missed.offset);
}
} else {
console.log("NO START");
console.log("No startContainer found for", this.toString());
// No start found
return null;
}

View file

@ -532,7 +532,7 @@ class ContinuousViewManager extends DefaultViewManager {
this.overflow = this.settings.overflow;
}
// this.views.each(function(view){
// this.views.forEach(function(view){
// view.setAxis(axis);
// });

View file

@ -733,7 +733,7 @@ class DefaultViewManager {
if(this.views) {
this.views.each(function(view){
this.views.forEach(function(view){
if (view) {
view.setLayout(layout);
}
@ -757,7 +757,7 @@ class DefaultViewManager {
} else {
this.overflow = this.settings.overflow;
}
// this.views.each(function(view){
// this.views.forEach(function(view){
// view.setAxis(axis);
// });
@ -770,7 +770,7 @@ class DefaultViewManager {
if (!this.views) {
return contents;
}
this.views.each(function(view){
this.views.forEach(function(view){
const viewContents = view && view.contents;
if (viewContents) {
contents.push(viewContents);

View file

@ -89,7 +89,7 @@ class Views {
// Iterators
each() {
forEach() {
return this._views.forEach.apply(this._views, arguments);
}

View file

@ -570,7 +570,9 @@ class IframeView {
}
let range = this.contents.range(cfiRange);
if (!range) {
return;
}
let container = range.commonAncestorContainer;
let parent = (container.nodeType === 1) ? container : container.parentNode;