mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Update CFI marker to use textContent, pageListReady only calls when a pagelist is present
This commit is contained in:
parent
fc50b6ed51
commit
aba8dc3c6f
14 changed files with 44 additions and 29 deletions
2
books
2
books
|
@ -1 +1 @@
|
|||
Subproject commit 950c742b3d66cc7ac53bd0663a41315f001da1c4
|
||||
Subproject commit ab9755a74714b647290c861f666515de220935d8
|
|
@ -2036,7 +2036,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
|
|||
|
||||
// No pageList found
|
||||
if(pageList.length === 0) {
|
||||
book.ready.pageList.resolve([]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2163,16 +2162,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
|
|||
// Width and Height are optional and will default to the current dimensions
|
||||
EPUBJS.Book.prototype.generatePagination = function(width, height) {
|
||||
var book = this;
|
||||
var pageListReady;
|
||||
|
||||
this.ready.spine.promise.then(function(){
|
||||
pageListReady = book.generatePageList(width, height).then(function(pageList){
|
||||
book.generatePageList(width, height).then(function(pageList){
|
||||
book.pageList = book.contents.pageList = pageList;
|
||||
book.pagination.process(pageList);
|
||||
book.ready.pageList.resolve(book.pageList);
|
||||
});
|
||||
});
|
||||
return pageListReady;
|
||||
|
||||
return this.pageListReady;
|
||||
};
|
||||
|
||||
// Process the pagination from a JSON array containing the pagelist
|
||||
|
@ -3613,7 +3612,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
|
|||
nextSib.nodeType === 3 &&
|
||||
prevSib.nodeType === 3){
|
||||
|
||||
prevSib.innerText += nextSib.innerText;
|
||||
prevSib.textContent += nextSib.textContent;
|
||||
marker.parentElement.removeChild(nextSib);
|
||||
}
|
||||
marker.parentElement.removeChild(marker);
|
||||
|
|
6
build/epub.min.js
vendored
6
build/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -2035,7 +2035,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
|
|||
|
||||
// No pageList found
|
||||
if(pageList.length === 0) {
|
||||
book.ready.pageList.resolve([]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2162,16 +2161,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
|
|||
// Width and Height are optional and will default to the current dimensions
|
||||
EPUBJS.Book.prototype.generatePagination = function(width, height) {
|
||||
var book = this;
|
||||
var pageListReady;
|
||||
|
||||
this.ready.spine.promise.then(function(){
|
||||
pageListReady = book.generatePageList(width, height).then(function(pageList){
|
||||
book.generatePageList(width, height).then(function(pageList){
|
||||
book.pageList = book.contents.pageList = pageList;
|
||||
book.pagination.process(pageList);
|
||||
book.ready.pageList.resolve(book.pageList);
|
||||
});
|
||||
});
|
||||
return pageListReady;
|
||||
|
||||
return this.pageListReady;
|
||||
};
|
||||
|
||||
// Process the pagination from a JSON array containing the pagelist
|
||||
|
@ -3612,7 +3611,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
|
|||
nextSib.nodeType === 3 &&
|
||||
prevSib.nodeType === 3){
|
||||
|
||||
prevSib.innerText += nextSib.innerText;
|
||||
prevSib.textContent += nextSib.textContent;
|
||||
marker.parentElement.removeChild(nextSib);
|
||||
}
|
||||
marker.parentElement.removeChild(marker);
|
||||
|
|
File diff suppressed because one or more lines are too long
2
build/libs/zip.min.js
vendored
2
build/libs/zip.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -249,8 +249,17 @@ EPUBJS.Reader.prototype.hashChanged = function(){
|
|||
};
|
||||
|
||||
EPUBJS.Reader.prototype.selectedRange = function(range){
|
||||
var epubcfi = new EPUBJS.EpubCFI();
|
||||
var cfi = epubcfi.generateCfiFromElement(range.anchorNode.parentElement, this.book.renderer.currentChapter.cfiBase);
|
||||
var cfiFragment = "#"+cfi;
|
||||
console.log("range", range)
|
||||
};
|
||||
console.log("anchor", cfi)
|
||||
// Update the History Location
|
||||
if(this.settings.history &&
|
||||
window.location.hash != cfiFragment) {
|
||||
// Add CFI fragment to the history
|
||||
history.pushState({}, '', cfiFragment);
|
||||
}};
|
||||
|
||||
//-- Enable binding events to reader
|
||||
RSVP.EventTarget.mixin(EPUBJS.Reader.prototype);
|
||||
|
|
6
demo/js/epub.min.js
vendored
6
demo/js/epub.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/js/libs/inflate.min.js
vendored
2
demo/js/libs/inflate.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/js/libs/zip.min.js
vendored
2
demo/js/libs/zip.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/js/reader.min.js
vendored
2
demo/js/reader.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -249,8 +249,17 @@ EPUBJS.Reader.prototype.hashChanged = function(){
|
|||
};
|
||||
|
||||
EPUBJS.Reader.prototype.selectedRange = function(range){
|
||||
var epubcfi = new EPUBJS.EpubCFI();
|
||||
var cfi = epubcfi.generateCfiFromElement(range.anchorNode.parentElement, this.book.renderer.currentChapter.cfiBase);
|
||||
var cfiFragment = "#"+cfi;
|
||||
console.log("range", range)
|
||||
};
|
||||
console.log("anchor", cfi)
|
||||
// Update the History Location
|
||||
if(this.settings.history &&
|
||||
window.location.hash != cfiFragment) {
|
||||
// Add CFI fragment to the history
|
||||
history.pushState({}, '', cfiFragment);
|
||||
}};
|
||||
|
||||
//-- Enable binding events to reader
|
||||
RSVP.EventTarget.mixin(EPUBJS.Reader.prototype);
|
|
@ -260,7 +260,6 @@ EPUBJS.Book.prototype.unpack = function(packageXml){
|
|||
|
||||
// No pageList found
|
||||
if(pageList.length === 0) {
|
||||
book.ready.pageList.resolve([]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -387,16 +386,16 @@ EPUBJS.Book.prototype.generatePageList = function(width, height){
|
|||
// Width and Height are optional and will default to the current dimensions
|
||||
EPUBJS.Book.prototype.generatePagination = function(width, height) {
|
||||
var book = this;
|
||||
var pageListReady;
|
||||
|
||||
this.ready.spine.promise.then(function(){
|
||||
pageListReady = book.generatePageList(width, height).then(function(pageList){
|
||||
book.generatePageList(width, height).then(function(pageList){
|
||||
book.pageList = book.contents.pageList = pageList;
|
||||
book.pagination.process(pageList);
|
||||
book.ready.pageList.resolve(book.pageList);
|
||||
});
|
||||
});
|
||||
return pageListReady;
|
||||
|
||||
return this.pageListReady;
|
||||
};
|
||||
|
||||
// Process the pagination from a JSON array containing the pagelist
|
||||
|
|
|
@ -242,7 +242,7 @@ EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) {
|
|||
nextSib.nodeType === 3 &&
|
||||
prevSib.nodeType === 3){
|
||||
|
||||
prevSib.innerText += nextSib.innerText;
|
||||
prevSib.textContent += nextSib.textContent;
|
||||
marker.parentElement.removeChild(nextSib);
|
||||
}
|
||||
marker.parentElement.removeChild(marker);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue