| 4 | import { createTOCView } from "./ui/tree.js"; |
| 5 | |
| 6 | const getCSS = ({ spacing, justify, hyphenate }) => ` |
| 7 | @namespace epub "http://www.idpf.org/2007/ops"; |
| 8 | html { |
| 9 | color-scheme: light dark; |
| 10 | } |
| 11 | /* https://github.com/whatwg/html/issues/5426 */ |
| 12 | @media (prefers-color-scheme: dark) { |
| 13 | a:link { |
| 14 | color: lightblue; |
| 15 | } |
| 16 | } |
| 17 | p, li, blockquote, dd { |
| 18 | line-height: ${spacing}; |
| 19 | text-align: ${justify ? "justify" : "start"}; |
| 20 | -webkit-hyphens: ${hyphenate ? "auto" : "manual"}; |
| 21 | hyphens: ${hyphenate ? "auto" : "manual"}; |
| 22 | -webkit-hyphenate-limit-before: 3; |
| 23 | -webkit-hyphenate-limit-after: 2; |
| 24 | -webkit-hyphenate-limit-lines: 2; |
| 25 | hanging-punctuation: allow-end last; |
| 26 | widows: 2; |
| 27 | } |
| 28 | /* prevent the above from overriding the align attribute */ |
| 29 | [align="left"] { text-align: left; } |
| 30 | [align="right"] { text-align: right; } |
| 31 | [align="center"] { text-align: center; } |
| 32 | [align="justify"] { text-align: justify; } |
| 33 | |
| 34 | pre { |
| 35 | white-space: pre-wrap !important; |
| 36 | } |
| 37 | aside[epub|type~="endnote"], |
| 38 | aside[epub|type~="footnote"], |
| 39 | aside[epub|type~="note"], |
| 40 | aside[epub|type~="rearnote"] { |
| 41 | display: none; |
| 42 | } |
| 43 | `; |
| 44 | |
| 45 | const $ = document.querySelector.bind(document); |
| 46 | |