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:
parent
4f4a13fadb
commit
bbb05616ab
7 changed files with 14 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "epubjs",
|
"name": "epubjs",
|
||||||
"version": "0.3.55",
|
"version": "0.3.56",
|
||||||
"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",
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Annotations {
|
||||||
|
|
||||||
let views = this.rendition.views();
|
let views = this.rendition.views();
|
||||||
|
|
||||||
views.each( (view) => {
|
views.forEach( (view) => {
|
||||||
if (annotation.sectionIndex === view.index) {
|
if (annotation.sectionIndex === view.index) {
|
||||||
annotation.attach(view);
|
annotation.attach(view);
|
||||||
}
|
}
|
||||||
|
@ -75,12 +75,13 @@ class Annotations {
|
||||||
|
|
||||||
if (hash in this._annotations) {
|
if (hash in this._annotations) {
|
||||||
let annotation = this._annotations[hash];
|
let annotation = this._annotations[hash];
|
||||||
if (annotation.type !== type) {
|
|
||||||
|
if (type && annotation.type !== type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let views = this.rendition.views();
|
let views = this.rendition.views();
|
||||||
views.each( (view) => {
|
views.forEach( (view) => {
|
||||||
this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash);
|
this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash);
|
||||||
if (annotation.sectionIndex === view.index) {
|
if (annotation.sectionIndex === view.index) {
|
||||||
annotation.detach(view);
|
annotation.detach(view);
|
||||||
|
|
|
@ -928,7 +928,7 @@ class EpubCFI {
|
||||||
range.setStart(missed.container, missed.offset);
|
range.setStart(missed.container, missed.offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("NO START");
|
console.log("No startContainer found for", this.toString());
|
||||||
// No start found
|
// No start found
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ class ContinuousViewManager extends DefaultViewManager {
|
||||||
this.overflow = this.settings.overflow;
|
this.overflow = this.settings.overflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.views.each(function(view){
|
// this.views.forEach(function(view){
|
||||||
// view.setAxis(axis);
|
// view.setAxis(axis);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
|
|
@ -733,7 +733,7 @@ class DefaultViewManager {
|
||||||
|
|
||||||
if(this.views) {
|
if(this.views) {
|
||||||
|
|
||||||
this.views.each(function(view){
|
this.views.forEach(function(view){
|
||||||
if (view) {
|
if (view) {
|
||||||
view.setLayout(layout);
|
view.setLayout(layout);
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ class DefaultViewManager {
|
||||||
} else {
|
} else {
|
||||||
this.overflow = this.settings.overflow;
|
this.overflow = this.settings.overflow;
|
||||||
}
|
}
|
||||||
// this.views.each(function(view){
|
// this.views.forEach(function(view){
|
||||||
// view.setAxis(axis);
|
// view.setAxis(axis);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ class DefaultViewManager {
|
||||||
if (!this.views) {
|
if (!this.views) {
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
this.views.each(function(view){
|
this.views.forEach(function(view){
|
||||||
const viewContents = view && view.contents;
|
const viewContents = view && view.contents;
|
||||||
if (viewContents) {
|
if (viewContents) {
|
||||||
contents.push(viewContents);
|
contents.push(viewContents);
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Views {
|
||||||
|
|
||||||
// Iterators
|
// Iterators
|
||||||
|
|
||||||
each() {
|
forEach() {
|
||||||
return this._views.forEach.apply(this._views, arguments);
|
return this._views.forEach.apply(this._views, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -570,7 +570,9 @@ class IframeView {
|
||||||
}
|
}
|
||||||
|
|
||||||
let range = this.contents.range(cfiRange);
|
let range = this.contents.range(cfiRange);
|
||||||
|
if (!range) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let container = range.commonAncestorContainer;
|
let container = range.commonAncestorContainer;
|
||||||
let parent = (container.nodeType === 1) ? container : container.parentNode;
|
let parent = (container.nodeType === 1) ? container : container.parentNode;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue