pdf.js/web/annotation_editor_layer_builder.css

531 lines
13 KiB
CSS
Raw Normal View History

/* Copyright 2022 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
:root {
--outline-width: 2px;
--outline-color: #0060df;
--outline-around-width: 1px;
--outline-around-color: #f0f0f4;
--focus-outline: solid var(--outline-width) var(--outline-color);
--unfocus-outline: solid var(--outline-width) transparent;
--focus-outline-around: solid var(--outline-around-width)
var(--outline-around-color);
--hover-outline: dashed var(--outline-width) var(--outline-color);
--freetext-line-height: 1.35;
--freetext-padding: 2px;
--resizer-bg-color: var(--outline-color);
--resizer-size: 6px;
--resizer-shift: calc(
0px - (var(--outline-width) + var(--resizer-size)) / 2 -
var(--outline-around-width)
);
2022-10-27 18:49:03 +09:00
--editorFreeText-editing-cursor: text;
/*#if COMPONENTS*/
--editorInk-editing-cursor: pointer;
/*#else*/
2022-10-27 18:49:03 +09:00
--editorInk-editing-cursor: url(images/cursor-editorInk.svg) 0 16, pointer;
/*#endif*/
--alt-text-opacity: 0.8;
--alt-text-add-image: url(images/altText_add.svg);
--alt-text-done-image: url(images/altText_done.svg);
--alt-text-bg-color: rgba(43, 42, 51, var(--alt-text-opacity));
--alt-text-fg-color: #fbfbfe;
--alt-text-border-color: var(--alt-text-bg-color);
--alt-text-hover-bg-color: rgba(82, 82, 94, var(--alt-text-opacity));
--alt-text-hover-fg-color: var(--alt-text-fg-color);
--alt-text-hover-border-color: var(--alt-text-hover-bg-color);
--alt-text-active-bg-color: rgba(91, 91, 102, var(--alt-text-opacity));
--alt-text-active-fg-color: var(--alt-text-fg-color);
--alt-text-active-border-color: var(--alt-text-hover-bg-color);
--alt-text-focus-outline-color: #0060df;
--alt-text-focus-border-color: #f0f0f4;
--alt-text-shadow: 0 2px 6px 0 rgba(28, 27, 34, 0.5);
}
@media (min-resolution: 1.1dppx) {
:root {
/*#if !COMPONENTS*/
--editorFreeText-editing-cursor: url(images/cursor-editorFreeText.svg) 0 16,
text;
/*#endif*/
}
}
@media screen and (forced-colors: active) {
:root {
--outline-color: CanvasText;
--outline-around-color: ButtonFace;
--resizer-bg-color: ButtonText;
--alt-text-bg-color: Canvas;
--alt-text-fg-color: ButtonText;
--alt-text-border-color: ButtonText;
--alt-text-hover-bg-color: Canvas;
--alt-text-hover-fg-color: SelectedItem;
--alt-text-hover-border-color: SelectedItem;
--alt-text-active-bg-color: ButtonFace;
--alt-text-active-fg-color: SelectedItem;
--alt-text-active-border-color: ButtonText;
--alt-text-focus-outline-color: CanvasText;
--alt-text-focus-border-color: ButtonText;
--alt-text-shadow: none;
--alt-text-opacity: 1;
}
}
[data-editor-rotation="90"] {
transform: rotate(90deg);
}
[data-editor-rotation="180"] {
transform: rotate(180deg);
}
[data-editor-rotation="270"] {
transform: rotate(270deg);
}
.annotationEditorLayer {
background: transparent;
position: absolute;
inset: 0;
font-size: calc(100px * var(--scale-factor));
transform-origin: 0 0;
cursor: auto;
z-index: 4;
}
.annotationEditorLayer.waiting {
content: "";
cursor: wait;
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.annotationEditorLayer.freeTextEditing {
2022-10-27 18:49:03 +09:00
cursor: var(--editorFreeText-editing-cursor);
}
.annotationEditorLayer.inkEditing {
2022-10-27 18:49:03 +09:00
cursor: var(--editorInk-editing-cursor);
}
.annotationEditorLayer :is(.freeTextEditor, .inkEditor, .stampEditor) {
position: absolute;
background: transparent;
border-radius: 3px;
z-index: 1;
transform-origin: 0 0;
cursor: auto;
max-width: 100%;
max-height: 100%;
border: var(--unfocus-outline);
&.draggable.selectedEditor {
cursor: move;
}
&.selectedEditor {
border: var(--focus-outline);
outline: var(--focus-outline-around);
&::before {
/*
This is a workaround for the lack of support for stripes(...) (see
https://drafts.csswg.org/css-images-4/#stripes).
The outline should be composed of 1px white, 2px blue and 1px white.
This could be achieved in different ways:
- using a linear-gradient;
- using a box-shadow;
- using an outline on the selected element and an outline+border on
the ::before pseudo-element.
All these options lead to incorrect rendering likely due to rounding
issues.
That said it doesn't mean that the current is ideal, but it's the best
we could come up with for the moment.
One drawback of this approach is that we use a border on the selected
element which means that we must take care of it when positioning the
div in js (see AnnotationEditor._borderLineWidth in editor.js).
*/
content: "";
position: absolute;
inset: 0;
border: var(--focus-outline-around);
}
}
&:hover:not(.selectedEditor) {
border: var(--hover-outline);
}
}
.annotationEditorLayer .freeTextEditor {
padding: calc(var(--freetext-padding) * var(--scale-factor));
width: auto;
height: auto;
touch-action: none;
}
.annotationEditorLayer .freeTextEditor .internal {
background: transparent;
border: none;
inset: 0;
overflow: visible;
white-space: nowrap;
font: 10px sans-serif;
line-height: var(--freetext-line-height);
user-select: none;
}
.annotationEditorLayer .freeTextEditor .overlay {
position: absolute;
display: none;
background: transparent;
inset: 0;
width: 100%;
height: 100%;
}
.annotationEditorLayer .freeTextEditor .overlay.enabled {
display: block;
}
.annotationEditorLayer .freeTextEditor .internal:empty::before {
content: attr(default-content);
color: gray;
}
.annotationEditorLayer .freeTextEditor .internal:focus {
outline: none;
user-select: auto;
}
.annotationEditorLayer .inkEditor {
width: 100%;
height: 100%;
}
.annotationEditorLayer .inkEditor.editing {
cursor: inherit;
}
.annotationEditorLayer .inkEditor .inkEditorCanvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
touch-action: none;
}
.annotationEditorLayer .stampEditor {
width: auto;
height: auto;
}
.annotationEditorLayer .stampEditor canvas {
width: 100%;
height: 100%;
}
.annotationEditorLayer {
:is(.freeTextEditor, .inkEditor, .stampEditor) {
& > .resizers {
position: absolute;
inset: 0;
&.hidden {
display: none;
}
& > .resizer {
width: var(--resizer-size);
height: var(--resizer-size);
background: var(--resizer-bg-color);
border: var(--focus-outline-around);
position: absolute;
&.topLeft {
top: var(--resizer-shift);
left: var(--resizer-shift);
}
&.topMiddle {
top: var(--resizer-shift);
left: calc(50% + var(--resizer-shift));
}
&.topRight {
top: var(--resizer-shift);
right: var(--resizer-shift);
}
&.middleRight {
top: calc(50% + var(--resizer-shift));
right: var(--resizer-shift);
}
&.bottomRight {
bottom: var(--resizer-shift);
right: var(--resizer-shift);
}
&.bottomMiddle {
bottom: var(--resizer-shift);
left: calc(50% + var(--resizer-shift));
}
&.bottomLeft {
bottom: var(--resizer-shift);
left: var(--resizer-shift);
}
&.middleLeft {
top: calc(50% + var(--resizer-shift));
left: var(--resizer-shift);
}
}
}
}
&[data-main-rotation="0"]
:is([data-editor-rotation="0"], [data-editor-rotation="180"]),
&[data-main-rotation="90"]
:is([data-editor-rotation="270"], [data-editor-rotation="90"]),
&[data-main-rotation="180"]
:is([data-editor-rotation="180"], [data-editor-rotation="0"]),
&[data-main-rotation="270"]
:is([data-editor-rotation="90"], [data-editor-rotation="270"]) {
& > .resizers > .resizer {
&.topLeft,
&.bottomRight {
cursor: nwse-resize;
}
&.topMiddle,
&.bottomMiddle {
cursor: ns-resize;
}
&.topRight,
&.bottomLeft {
cursor: nesw-resize;
}
&.middleRight,
&.middleLeft {
cursor: ew-resize;
}
}
}
&[data-main-rotation="0"]
:is([data-editor-rotation="90"], [data-editor-rotation="270"]),
&[data-main-rotation="90"]
:is([data-editor-rotation="0"], [data-editor-rotation="180"]),
&[data-main-rotation="180"]
:is([data-editor-rotation="270"], [data-editor-rotation="90"]),
&[data-main-rotation="270"]
:is([data-editor-rotation="180"], [data-editor-rotation="0"]) {
& > .resizers > .resizer {
&.topLeft,
&.bottomRight {
cursor: nesw-resize;
}
&.topMiddle,
&.bottomMiddle {
cursor: ew-resize;
}
&.topRight,
&.bottomLeft {
cursor: nwse-resize;
}
&.middleRight,
&.middleLeft {
cursor: ns-resize;
}
}
}
&
:is(
[data-main-rotation="0"] [data-editor-rotation="90"],
[data-main-rotation="90"] [data-editor-rotation="0"],
[data-main-rotation="180"] [data-editor-rotation="270"],
[data-main-rotation="270"] [data-editor-rotation="180"]
) {
& .altText {
rotate: 270deg;
&:dir(ltr) {
inset-inline-start: calc(100% - 8px);
&.small {
inset-inline-start: calc(100% + 8px);
inset-block-start: 100%;
}
}
&:dir(rtl) {
inset-block-end: calc(100% - 8px);
&.small {
inset-inline-start: -8px;
inset-block-start: 0;
}
}
}
}
&
:is(
[data-main-rotation="0"] [data-editor-rotation="180"],
[data-main-rotation="90"] [data-editor-rotation="90"],
[data-main-rotation="180"] [data-editor-rotation="0"],
[data-main-rotation="270"] [data-editor-rotation="270"]
) {
& .altText {
rotate: 180deg;
inset-block-end: calc(100% - 8px);
inset-inline-start: calc(100% - 8px);
&.small {
inset-inline-start: 100%;
inset-block-start: -8px;
}
}
}
&
:is(
[data-main-rotation="0"] [data-editor-rotation="270"],
[data-main-rotation="90"] [data-editor-rotation="180"],
[data-main-rotation="180"] [data-editor-rotation="90"],
[data-main-rotation="270"] [data-editor-rotation="0"]
) {
& .altText {
rotate: 90deg;
&:dir(ltr) {
inset-block-end: calc(100% - 8px);
&.small {
inset-inline-start: -8px;
inset-block-start: 0;
}
}
&:dir(rtl) {
inset-inline-start: calc(100% - 8px);
&.small {
inset-inline-start: calc(100% + 8px);
inset-block-start: 100%;
}
}
}
}
}
.altText {
display: flex;
align-items: center;
justify-content: center;
width: auto;
height: 24px;
min-width: 88px;
z-index: 1;
pointer-events: all;
color: var(--alt-text-fg-color);
font: menu;
font-size: 12px;
border-radius: 4px;
border: 1px solid var(--alt-text-border-color);
background-color: var(--alt-text-bg-color);
box-shadow: var(--alt-text-shadow);
position: absolute;
inset-block-end: 8px;
inset-inline-start: 8px;
&:dir(ltr) {
transform-origin: 0 100%;
}
&:dir(rtl) {
transform-origin: 100% 100%;
}
&.small {
&:dir(ltr) {
transform-origin: 0 0;
}
&:dir(rtl) {
transform-origin: 100% 0;
}
inset-block-end: unset;
inset-inline-start: 0;
inset-block-start: calc(100% + 8px);
}
&:hover {
background-color: var(--alt-text-hover-bg-color);
border-color: var(--alt-text-hover-border-color);
color: var(--alt-text-hover-fg-color);
cursor: pointer;
&::before {
background-color: var(--alt-text-hover-fg-color);
}
}
&:active {
background-color: var(--alt-text-active-bg-color);
border-color: var(--alt-text-active-border-color);
color: var(--alt-text-active-fg-color);
&::before {
background-color: var(--alt-text-active-fg-color);
}
}
&:focus-visible {
outline: 2px solid var(--alt-text-focus-outline-color);
border-color: var(--alt-text-focus-border-color);
}
&::before {
content: "";
mask-image: var(--alt-text-add-image);
mask-size: cover;
mask-repeat: no-repeat;
mask-position: center;
display: inline-block;
width: 12px;
height: 12px;
background-color: var(--alt-text-fg-color);
margin-inline-end: 4px;
}
&.done::before {
mask-image: var(--alt-text-done-image);
}
}