Epub improvements (#162)
* Added a "Remove Edge Padding" option in "Visual Options" * Added support for paragraph gap settings in the EPUB vertical reader. * Added support for adjustable paragraph gaps in the paginated reader. * fix(epub-pagination): ensure custom fonts override embedded epub fonts * feat(epub): allow overlapping highlights and resolve gesture selection conflicts
This commit is contained in:
parent
291504fd90
commit
49e08cc9f1
11 changed files with 315 additions and 264 deletions
|
|
@ -381,6 +381,10 @@
|
|||
};
|
||||
|
||||
function handleHighlightInteraction(e) {
|
||||
if (window.getSelection && window.getSelection().toString().trim().length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = e.target;
|
||||
var highlightSpan = null;
|
||||
|
||||
|
|
@ -426,7 +430,6 @@
|
|||
if (rawCfi && rawCfi.includes(";;")) {
|
||||
var cfiParts = rawCfi.split(";;");
|
||||
cfiToReport = cfiParts[cfiParts.length - 1];
|
||||
console.log("HandleInteraction: Multi-CFI detected on single span. Reporting top layer: " + cfiToReport);
|
||||
}
|
||||
|
||||
if (window.HighlightBridge) {
|
||||
|
|
@ -445,25 +448,10 @@
|
|||
function (e) {
|
||||
handleHighlightInteraction(e);
|
||||
},
|
||||
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
// 2. Handle Long Press (Context Menu) - "Atomic" Behavior
|
||||
// This prevents the native Android selection handles from appearing inside the highlight
|
||||
document.addEventListener(
|
||||
"contextmenu",
|
||||
function (e) {
|
||||
if (handleHighlightInteraction(e)) {
|
||||
e.preventDefault(); // Ensure menu doesn't show
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
true,
|
||||
);
|
||||
|
||||
window.updateReaderStyles = function (fontSizeEm, lineHeight, fontFamily, textAlign) {
|
||||
window.updateReaderStyles = function (fontSizeEm, lineHeight, fontFamily, textAlign, paragraphGap) {
|
||||
var logTag = "ReaderFontDiagnosis";
|
||||
console.log(
|
||||
logTag +
|
||||
|
|
@ -475,7 +463,8 @@
|
|||
fontFamily +
|
||||
"', Align: '" +
|
||||
textAlign +
|
||||
"'",
|
||||
"', Gap: " +
|
||||
paragraphGap
|
||||
);
|
||||
|
||||
var dynamicStyleId = "dynamicReaderStyles";
|
||||
|
|
@ -489,9 +478,11 @@
|
|||
|
||||
var newFontSize = parseFloat(fontSizeEm);
|
||||
var newLineHeight = parseFloat(lineHeight);
|
||||
var newGap = parseFloat(paragraphGap);
|
||||
|
||||
if (isNaN(newFontSize) || newFontSize < 0.5 || newFontSize > 5.0) newFontSize = 1.0;
|
||||
if (isNaN(newLineHeight) || newLineHeight < 1.0 || newLineHeight > 3.0) newLineHeight = 1.6;
|
||||
if (isNaN(newGap) || newGap < 0.0 || newGap > 3.0) newGap = 1.0;
|
||||
|
||||
var fontCss = "";
|
||||
var selector = "body";
|
||||
|
|
@ -535,6 +526,17 @@
|
|||
`;
|
||||
}
|
||||
|
||||
// --- GAP LOGIC ---
|
||||
var gapCss = `
|
||||
body p, body ul, body ol, body blockquote {
|
||||
margin-top: ` + (0.5 * newGap) + `em !important;
|
||||
margin-bottom: ` + (0.5 * newGap) + `em !important;
|
||||
}
|
||||
body li {
|
||||
margin-bottom: ` + (0.25 * newGap) + `em !important;
|
||||
}
|
||||
`;
|
||||
|
||||
dynamicStyleElement.innerHTML =
|
||||
` body {
|
||||
font-size: ` +
|
||||
|
|
@ -555,7 +557,7 @@
|
|||
|
||||
` +
|
||||
alignCss +
|
||||
` `;
|
||||
gapCss;
|
||||
|
||||
setTimeout(
|
||||
function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue