mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix page breaks
Replace `page-break-*` with `-webkit-column-break-*`. See https://github.com/johnfactotum/foliate/issues/962#issuecomment-1437982082
This commit is contained in:
@@ -572,10 +572,15 @@ class Loader {
|
|||||||
.then(url => `@import "${url}"`))
|
.then(url => `@import "${url}"`))
|
||||||
const w = window?.innerWidth ?? 800
|
const w = window?.innerWidth ?? 800
|
||||||
const h = window?.innerHeight ?? 600
|
const h = window?.innerHeight ?? 600
|
||||||
const replacedVwVh = replacedImports
|
return replacedImports
|
||||||
.replace(/(\d*\.?\d+)vw/g, (_, d) => parseFloat(d) * w / 100 + 'px')
|
// unprefix as most of the props are (only) supported unprefixed
|
||||||
.replace(/(\d*\.?\d+)vh/g, (_, d) => parseFloat(d) * h / 100 + 'px')
|
.replace(/-epub-/gi, '')
|
||||||
return replacedVwVh.replaceAll('-epub-', '')
|
// replace vw and vh as they cause problems with layout
|
||||||
|
.replace(/(\d*\.?\d+)vw/gi, (_, d) => parseFloat(d) * w / 100 + 'px')
|
||||||
|
.replace(/(\d*\.?\d+)vh/gi, (_, d) => parseFloat(d) * h / 100 + 'px')
|
||||||
|
// `page-break-*` unsupported in columns; replace with `column-break-*`
|
||||||
|
.replace(/page-break-(after|before|inside)/gi, (_, x) =>
|
||||||
|
`-webkit-column-break-${x}`)
|
||||||
}
|
}
|
||||||
// find & replace all possible relative paths for all assets without parsing
|
// find & replace all possible relative paths for all assets without parsing
|
||||||
replaceString(str, href, parents = []) {
|
replaceString(str, href, parents = []) {
|
||||||
|
|||||||
Reference in New Issue
Block a user