Skip to content

Commit e011cf4

Browse files
authored
fix: cursors will not break to new-line on firefox and fix zoom on chrome #1419 (#1422)
This PR updates the collaboration cursor's UI to more robust work across browsers. Specifically addressing an issue with Firefox where the cursor could cause an unnecessary line break and an issue with chrome breaking when zoomed in.
1 parent b4cf81d commit e011cf4

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

packages/core/src/editor/editor.css

+19-11
Original file line numberDiff line numberDiff line change
@@ -79,43 +79,51 @@ Tippy popups that are appended to document.body directly
7979

8080
/* Give a remote user a caret */
8181
.collaboration-cursor__caret {
82-
border-left: 1px solid #0d0d0d;
83-
border-right: 1px solid #0d0d0d;
84-
margin-left: -1px;
85-
margin-right: -1px;
82+
outline: 1px solid #0d0d0d;
8683
position: relative;
8784
word-break: normal;
8885
white-space: nowrap !important;
8986
}
9087

88+
/* Allow the caret to be hovered over */
89+
.collaboration-cursor__caret::after {
90+
content: "";
91+
position: absolute;
92+
top: 0;
93+
right: 0;
94+
left: 0;
95+
bottom: 0;
96+
width: 2px;
97+
}
98+
9199
/* Render the username above the caret */
92100
.collaboration-cursor__label {
93-
border-radius: 3px 3px 3px 0;
101+
border-radius: 0 1.5px 1.5px 0;
94102
font-size: 12px;
95103
font-style: normal;
96104
font-weight: 600;
97105
line-height: normal;
98-
left: -1px;
106+
left: 0;
99107
overflow: hidden;
100108
position: absolute;
101109
white-space: nowrap;
102110

103111
color: transparent;
104-
max-height: 4px;
112+
max-height: 5px;
105113
max-width: 4px;
106114
padding: 0;
107-
top: 0;
108-
115+
top: -1px;
109116
transition: all 0.2s;
110-
111117
}
112118

113119
.collaboration-cursor__caret[data-active] > .collaboration-cursor__label {
114120
color: #0d0d0d;
115121
max-height: 1.1rem;
116122
max-width: 20rem;
117123
padding: 0.1rem 0.3rem;
118-
top: -14px;
124+
top: -18px;
125+
left: -1px;
126+
border-radius: 3px 3px 3px 0;
119127

120128
transition: all 0.2s;
121129
}

packages/core/src/extensions/Collaboration/createCollaborationExtensions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const createCollaborationExtensions = (collaboration: {
6666
const cursorElement = document.createElement("span");
6767

6868
cursorElement.classList.add("collaboration-cursor__caret");
69-
cursorElement.setAttribute("style", `border-color: ${user.color}`);
69+
cursorElement.setAttribute("style", `outline-color: ${user.color}`);
7070
if (collaboration?.showCursorLabels === "always") {
7171
cursorElement.setAttribute("data-active", "");
7272
}

0 commit comments

Comments
 (0)