mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Fix bota for non-latin, fix webkit locationOf
This commit is contained in:
parent
ac08fe0fba
commit
673e5e83dc
4 changed files with 24 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "epubjs",
|
"name": "epubjs",
|
||||||
"version": "0.3.50",
|
"version": "0.3.51",
|
||||||
"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",
|
||||||
|
|
|
@ -448,7 +448,7 @@ class Contents {
|
||||||
var position;
|
var position;
|
||||||
var targetPos = {"left": 0, "top": 0};
|
var targetPos = {"left": 0, "top": 0};
|
||||||
|
|
||||||
if(!this.document) return;
|
if(!this.document) return targetPos;
|
||||||
|
|
||||||
if(this.epubcfi.isCfiString(target)) {
|
if(this.epubcfi.isCfiString(target)) {
|
||||||
let range = new EpubCFI(target).toRange(this.document, ignoreClass);
|
let range = new EpubCFI(target).toRange(this.document, ignoreClass);
|
||||||
|
@ -466,17 +466,22 @@ class Contents {
|
||||||
if (isWebkit) {
|
if (isWebkit) {
|
||||||
let container = range.startContainer;
|
let container = range.startContainer;
|
||||||
let newRange = new Range();
|
let newRange = new Range();
|
||||||
|
try {
|
||||||
if (container.nodeType === ELEMENT_NODE) {
|
if (container.nodeType === ELEMENT_NODE) {
|
||||||
position = container.getBoundingClientRect();
|
position = container.getBoundingClientRect();
|
||||||
} else if (container.length + 2 < range.startOffset) {
|
} else if (range.startOffset + 2 < container.length) {
|
||||||
newRange.setStart(container, range.startOffset);
|
newRange.setStart(container, range.startOffset);
|
||||||
newRange.setEnd(container, range.startOffset + 2);
|
newRange.setEnd(container, range.startOffset + 2);
|
||||||
position = newRange.getBoundingClientRect();
|
position = newRange.getBoundingClientRect();
|
||||||
} else {
|
} else if (range.startOffset - 2 > 0) {
|
||||||
newRange.setStart(container, range.startOffset - 2);
|
newRange.setStart(container, range.startOffset - 2);
|
||||||
newRange.setEnd(container, range.startOffset);
|
newRange.setEnd(container, range.startOffset);
|
||||||
position = newRange.getBoundingClientRect();
|
position = newRange.getBoundingClientRect();
|
||||||
|
} else { // empty, return the parent element
|
||||||
|
position = container.parentNode.getBoundingClientRect();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e, e.stack);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
position = range.getBoundingClientRect();
|
position = range.getBoundingClientRect();
|
||||||
|
|
|
@ -357,16 +357,16 @@ class Rendition {
|
||||||
*/
|
*/
|
||||||
onResized(size){
|
onResized(size){
|
||||||
|
|
||||||
if (this.location && this.location.start) {
|
|
||||||
// this.manager.clear();
|
|
||||||
this.display(this.location.start.cfi);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emit("resized", {
|
this.emit("resized", {
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height
|
height: size.height
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.location && this.location.start) {
|
||||||
|
// this.manager.clear();
|
||||||
|
this.display(this.location.start.cfi);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -279,7 +279,7 @@ export function createBase64Url(content, mime){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = btoa(content);
|
data = btoa(encodeURIComponent(content));
|
||||||
|
|
||||||
datauri = "data:" + mime + ";base64," + data;
|
datauri = "data:" + mime + ";base64," + data;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue