mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 06:46:52 +00:00
75 lines
2.4 KiB
CSS
75 lines
2.4 KiB
CSS
/*
|
|||
|
|
* Minimal pdf.js text-layer styles, adapted from pdfjs-dist's viewer CSS.
|
||
|
|
*
|
||
|
|
* The pdf.js `TextLayer` class lays out invisible text runs by setting inline
|
||
|
|
* styles (left/top as percentages, font-family, --font-height, --scale-x,
|
||
|
|
* --rotate) on `<span>` elements. Without the rules below nothing is
|
||
|
|
* positioned or sized, so this subset is required for text selection to work.
|
||
|
|
*
|
||
|
|
* We render the text layer at viewport scale 1 and transform the whole
|
||
|
|
* container with the same translate/scale the Konva stage applies, hence
|
||
|
|
* `--total-scale-factor: 1` (the spans stay in page coordinates).
|
||
|
|
*/
|
||
|
|
.pdf-text-layer {
|
||
|
|
position: absolute;
|
||
|
|
inset: 0;
|
||
|
|
overflow: clip;
|
||
|
|
text-align: initial;
|
||
|
|
line-height: 1;
|
||
|
|
letter-spacing: normal;
|
||
|
|
word-spacing: normal;
|
||
|
|
transform-origin: 0 0;
|
||
|
|
caret-color: CanvasText;
|
||
|
|
/* The container itself must not be selectable: when a drag ends in empty
|
||
|
|
space Chromium would otherwise target the container as the caret
|
||
|
|
position and extend the selection across rows. Only the spans are
|
||
|
|
selectable (see below), so the caret clamps to the nearest text. */
|
||
|
|
user-select: none;
|
||
|
|
-webkit-user-select: none;
|
||
|
|
-moz-user-select: none;
|
||
|
|
/* Above the page canvas (z-0) so the selection highlight is visible, but
|
||
|
|
below the loading overlay (z-20). */
|
||
|
|
z-index: 10;
|
||
|
|
--total-scale-factor: 1;
|
||
|
|
--scale-round-x: 1px;
|
||
|
|
--scale-round-y: 1px;
|
||
|
|
--min-font-size: 1;
|
||
|
|
--text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
|
||
|
|
--min-font-size-inv: calc(1 / var(--min-font-size));
|
||
|
|
}
|
||
|
|
|
||
|
|
.pdf-text-layer :is(span, br) {
|
||
|
|
color: transparent;
|
||
|
|
position: absolute;
|
||
|
|
white-space: pre;
|
||
|
|
cursor: text;
|
||
|
|
transform-origin: 0% 0%;
|
||
|
|
-webkit-user-select: text;
|
||
|
|
-moz-user-select: text;
|
||
|
|
user-select: text;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* pdf.js appends a <br> after each line-ending text run; without explicit
|
||
|
|
left/top they sit at the container's top-left (static position) and would
|
||
|
|
paint a stray selection highlight when a range spans multiple rows. */
|
||
|
|
.pdf-text-layer br::-moz-selection {
|
||
|
|
background: transparent;
|
||
|
|
}
|
||
|
|
.pdf-text-layer br::selection {
|
||
|
|
background: transparent;
|
||
|
|
}
|
||
|
|
|
||
|
|
.pdf-text-layer > :not(.markedContent),
|
||
|
|
.pdf-text-layer .markedContent span:not(.markedContent) {
|
||
|
|
z-index: 1;
|
||
|
|
--font-height: 0;
|
||
|
|
font-size: calc(var(--text-scale-factor) * var(--font-height));
|
||
|
|
--scale-x: 1;
|
||
|
|
--rotate: 0deg;
|
||
|
|
transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
|
||
|
|
}
|
||
|
|
|
||
|
|
.pdf-text-layer .markedContent {
|
||
|
|
display: contents;
|
||
|
|
}
|