diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 84d2f23c244e2..866aadc88ddbb 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -1371,8 +1371,12 @@ class AnnotationEditorUIManager { if (!boxes) { return; } + const layer = this.#getLayerForTextLayer(textLayer); + if (layer) { + layer.div.hidden = false; + } this.#floatingToolbar ||= new FloatingToolbar(this); - this.#floatingToolbar.show(textLayer, boxes, this.direction === "ltr"); + this.#floatingToolbar.show(layer?.div || textLayer, boxes, this.direction === "ltr"); } /** @@ -1427,6 +1431,14 @@ class AnnotationEditorUIManager { if (!selection || selection.isCollapsed) { if (this.#selectedTextNode) { this.#floatingToolbar?.hide(); + const anchorElement = this.#getAnchorElementForSelection(selection); + const textLayer = anchorElement?.closest(".textLayer"); + if (textLayer) { + const layer = this.#getLayerForTextLayer(textLayer); + if (layer?.isEmpty && this.#mode === AnnotationEditorType.NONE) { + layer.div.hidden = true; + } + } this.#selectedTextNode = null; this.#dispatchUpdateStates({ hasSelectedText: false, diff --git a/web/annotation_editor_layer_builder.css b/web/annotation_editor_layer_builder.css index e7d80a7979578..1fa413c9c5c05 100644 --- a/web/annotation_editor_layer_builder.css +++ b/web/annotation_editor_layer_builder.css @@ -52,6 +52,10 @@ } .textLayer { + @media screen and (forced-colors: active) { + opacity: 1; + } + &.highlighting { cursor: var(--editorFreeHighlight-editing-cursor); @@ -230,14 +234,7 @@ } } -.annotationEditorLayer - :is( - .freeTextEditor, - .inkEditor, - .stampEditor, - .highlightEditor, - .signatureEditor - ), +.annotationEditorLayer, .textLayer { .editToolbar { --editor-toolbar-delete-image: url(images/editor-toolbar-delete.svg); @@ -273,6 +270,7 @@ --alt-text-warning-color: var(--editor-toolbar-fg-color); --alt-text-hover-done-color: var(--editor-toolbar-hover-fg-color); --alt-text-hover-warning-color: var(--editor-toolbar-hover-fg-color); + opacity: 1; } display: flex; @@ -282,8 +280,9 @@ justify-content: center; align-items: center; cursor: default; - pointer-events: auto; + pointer-events: auto !important; box-sizing: content-box; + z-index: 100001; padding: var(--editor-toolbar-padding); position: absolute; diff --git a/web/text_layer_builder.css b/web/text_layer_builder.css index 1b8209de44736..4fcfbfc557bd4 100644 --- a/web/text_layer_builder.css +++ b/web/text_layer_builder.css @@ -18,14 +18,20 @@ text-align: initial; inset: 0; overflow: clip; - opacity: 1; + opacity: 0.25; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; - caret-color: CanvasText; z-index: 0; + @media screen and (forced-colors: active) { + opacity: 1; + forced-color-adjust: auto; + } + + caret-color: CanvasText; + &.highlighting { touch-action: none; } @@ -50,7 +56,8 @@ .markedContent span:not(.markedContent) { z-index: 1; - --font-height: 0; /* set by text_layer.js */ + --font-height: 0; + /* set by text_layer.js */ font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; @@ -69,8 +76,8 @@ } .highlight { - --highlight-bg-color: rgb(180 0 170 / 0.25); - --highlight-selected-bg-color: rgb(0 100 0 / 0.25); + --highlight-bg-color: rgb(180 0 170); + --highlight-selected-bg-color: rgb(0 100 0); --highlight-backdrop-filter: none; --highlight-selected-backdrop-filter: none; @@ -114,10 +121,10 @@ ::selection { /* stylelint-disable declaration-block-no-duplicate-properties */ /*#if !MOZCENTRAL*/ - background: rgba(0 0 255 / 0.25); + background: rgb(0 0 255); /*#endif*/ + background: AccentColor; /* stylelint-enable declaration-block-no-duplicate-properties */ - background: color-mix(in srgb, AccentColor, transparent 75%); } /* Avoids https://github.com/mozilla/pdf.js/issues/13840 in Chrome */ @@ -125,6 +132,7 @@ br::selection { background: transparent; } + /*#endif*/ .endOfContent {