|
15 | 15 |
|
16 | 16 | :root { |
17 | 17 | --react-pdf-text-layer: 1; |
18 | | - --highlight-bg-color: rgba(180, 0, 170, 1); |
19 | | - --highlight-selected-bg-color: rgba(0, 100, 0, 1); |
20 | | -} |
21 | | - |
22 | | -@media screen and (forced-colors: active) { |
23 | | - :root { |
24 | | - --highlight-bg-color: Highlight; |
25 | | - --highlight-selected-bg-color: ButtonText; |
26 | | - } |
27 | 18 | } |
28 | 19 |
|
29 | 20 | [data-main-rotation='90'] { |
|
37 | 28 | } |
38 | 29 |
|
39 | 30 | .textLayer { |
| 31 | + color-scheme: only light; |
| 32 | + |
40 | 33 | position: absolute; |
41 | 34 | text-align: initial; |
42 | 35 | inset: 0; |
43 | | - overflow: hidden; |
| 36 | + overflow: clip; |
| 37 | + opacity: 1; |
44 | 38 | line-height: 1; |
45 | 39 | text-size-adjust: none; |
46 | 40 | forced-color-adjust: none; |
47 | 41 | transform-origin: 0 0; |
48 | | - z-index: 2; |
| 42 | + caret-color: CanvasText; |
| 43 | + z-index: 0; |
| 44 | + |
| 45 | + /* We multiply the font size by --min-font-size, and then scale the text |
| 46 | + * elements by 1/--min-font-size. This allows us to effectively ignore the |
| 47 | + * minimum font size enforced by the browser, so that the text layer <span>s |
| 48 | + * can always match the size of the text in the canvas. */ |
| 49 | + --min-font-size: 1; |
| 50 | + --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); |
| 51 | + --min-font-size-inv: calc(1 / var(--min-font-size)); |
49 | 52 | } |
50 | 53 |
|
51 | 54 | .textLayer :is(span, br) { |
|
57 | 60 | transform-origin: 0 0; |
58 | 61 | } |
59 | 62 |
|
60 | | -/* Only necessary in Google Chrome, see issue 14205, and most unfortunately |
61 | | - * the problem doesn't show up in "text" reference tests. */ |
62 | | -.textLayer span.markedContent { |
63 | | - top: 0; |
64 | | - height: 0; |
| 63 | +.textLayer > :not(.markedContent), |
| 64 | +.textLayer .markedContent span:not(.markedContent) { |
| 65 | + z-index: 1; |
| 66 | + |
| 67 | + --font-height: 0; /* set by text_layer.js */ |
| 68 | + font-size: calc(var(--text-scale-factor) * var(--font-height)); |
| 69 | + |
| 70 | + --scale-x: 1; |
| 71 | + --rotate: 0deg; |
| 72 | + transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); |
| 73 | +} |
| 74 | + |
| 75 | +.textLayer .markedContent { |
| 76 | + display: contents; |
| 77 | +} |
| 78 | + |
| 79 | +.textLayer span[role='img'] { |
| 80 | + user-select: none; |
| 81 | + cursor: default; |
65 | 82 | } |
66 | 83 |
|
67 | 84 | .textLayer .highlight { |
| 85 | + --highlight-bg-color: rgb(180 0 170 / 0.25); |
| 86 | + --highlight-selected-bg-color: rgb(0 100 0 / 0.25); |
| 87 | + --highlight-backdrop-filter: none; |
| 88 | + --highlight-selected-backdrop-filter: none; |
| 89 | + |
68 | 90 | margin: -1px; |
69 | 91 | padding: 1px; |
70 | 92 | background-color: var(--highlight-bg-color); |
| 93 | + backdrop-filter: var(--highlight-backdrop-filter); |
71 | 94 | border-radius: 4px; |
72 | 95 | } |
73 | 96 |
|
| 97 | +@media screen and (forced-colors: active) { |
| 98 | + .textLayer .highlight { |
| 99 | + --highlight-bg-color: Highlight; |
| 100 | + --highlight-selected-bg-color: ButtonText; |
| 101 | + } |
| 102 | +} |
| 103 | + |
74 | 104 | .textLayer .highlight.appended { |
75 | 105 | position: initial; |
76 | 106 | } |
|
89 | 119 |
|
90 | 120 | .textLayer .highlight.selected { |
91 | 121 | background-color: var(--highlight-selected-bg-color); |
| 122 | + backdrop-filter: var(--highlight-selected-backdrop-filter); |
| 123 | +} |
| 124 | + |
| 125 | +.textLayer ::selection { |
| 126 | + background: rgba(0 0 255 / 0.25); |
| 127 | + background: color-mix(in srgb, AccentColor, transparent 75%); |
92 | 128 | } |
93 | 129 |
|
94 | 130 | /* Avoids https://github.com/mozilla/pdf.js/issues/13840 in Chrome */ |
|
100 | 136 | display: block; |
101 | 137 | position: absolute; |
102 | 138 | inset: 100% 0 0; |
103 | | - z-index: -1; |
| 139 | + z-index: 0; |
104 | 140 | cursor: default; |
105 | 141 | user-select: none; |
106 | 142 | } |
|
0 commit comments