Skip to content

Commit

Permalink
Merge pull request #17581 from calixteman/editor_highlight_cursor
Browse files Browse the repository at this point in the history
[Editor] Change the cursors for highlighting (bug 1876588)
  • Loading branch information
calixteman authored Jan 26, 2024
2 parents 3192d37 + f3bdbed commit e63fafd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
3 changes: 2 additions & 1 deletion gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,8 @@ function buildComponents(defines, dir) {
"web/images/loading-icon.gif",
"web/images/altText_*.svg",
"web/images/editor-toolbar-*.svg",
"web/images/toolbarButton-menuArrow.svg",
"web/images/toolbarButton-{editorHighlight,menuArrow}.svg",
"web/images/cursor-*.svg",
];

return merge([
Expand Down
12 changes: 10 additions & 2 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class AnnotationEditorLayer {
"pointerdown",
this.#boundTextLayerPointerDown
);
this.#textLayer.div.classList.add("drawing");
this.#textLayer.div.classList.add("highlighting");
}
}

Expand All @@ -345,7 +345,7 @@ class AnnotationEditorLayer {
"pointerdown",
this.#boundTextLayerPointerDown
);
this.#textLayer.div.classList.remove("drawing");
this.#textLayer.div.classList.remove("highlighting");
}
}

Expand All @@ -359,11 +359,19 @@ class AnnotationEditorLayer {
// Do nothing on right click.
return;
}
this.#textLayer.div.classList.add("free");
HighlightEditor.startHighlighting(
this,
this.#uiManager.direction === "ltr",
event
);
this.#textLayer.div.addEventListener(
"pointerup",
() => {
this.#textLayer.div.classList.remove("free");
},
{ once: true }
);
event.preventDefault();
}
}
Expand Down
24 changes: 18 additions & 6 deletions web/annotation_editor_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,31 @@
var(--outline-around-width)
);
--editorFreeText-editing-cursor: text;
/*#if COMPONENTS*/
--editorInk-editing-cursor: pointer;
/*#else*/
--editorInk-editing-cursor: url(images/cursor-editorInk.svg) 0 16, pointer;
/*#endif*/
--editorHighlight-editing-cursor: url(images/cursor-editorTextHighlight.svg)
23 23,
text;
--editorFreeHighlight-editing-cursor: url(images/toolbarButton-editorHighlight.svg)
0 16,
pointer;
}

.textLayer.highlighting {
cursor: var(--editorFreeHighlight-editing-cursor);

&:not(.free) span {
cursor: var(--editorHighlight-editing-cursor);
}

&.free span {
cursor: var(--editorFreeHighlight-editing-cursor);
}
}

@media (min-resolution: 1.1dppx) {
:root {
/*#if !COMPONENTS*/
--editorFreeText-editing-cursor: url(images/cursor-editorFreeText.svg) 0 16,
text;
/*#endif*/
}
}

Expand Down
4 changes: 4 additions & 0 deletions web/images/cursor-editorTextHighlight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/text_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
z-index: 2;
caret-color: CanvasText;

&.drawing {
&.highlighting {
touch-action: none;
}

Expand Down

0 comments on commit e63fafd

Please sign in to comment.