Commit 1ade05c
authored
fix: collaboration cursor chrome should not wrap mid-line (#1423)
Here be dragons!
The collaboration cursor caret needs to:
- exist in the dom as a non-zero width element, so that when hovering over it, the label can display
- yet, effectively not take up space in the dom, so that it doesn't cause wrapping or otherwise effect layout of the page
To achieve this, it took quite a bit of fiddling to figure out how to do this.
The caret is a span which has a before and after pseudo element.
The before element is what actually takes up space in the dom, and is colored via a border.
The color is actually set by reading the current color from the `.collaboration-cursor__caret` element. Allowing for dynamic coloring from JS.
There are a number of browser specific quirks with these hacks:
- Firefox differs from Chrome & Safari in that it will split a word that is wrapping if not displayed as inline-block (whereas the others need display: inline)
- Safari differs from Chrome & Firefox in that it needs the pseudo element to be position: relative to display a pseudo-element element with a negative margin
The word-joiner char (\u2060) is used to make sure the caret doesn't wrap around the text.
Therefore if modifying this code, please test in all major browsers to ensure that the caret is rendered correctly in all browsers.1 parent af24b5d commit 1ade05c
File tree
2 files changed
+48
-16
lines changed- packages/core/src
- editor
- extensions/Collaboration
2 files changed
+48
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
80 | 102 | | |
81 | 103 | | |
82 | | - | |
83 | 104 | | |
84 | 105 | | |
85 | 106 | | |
86 | 107 | | |
87 | 108 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
97 | 130 | | |
98 | 131 | | |
99 | 132 | | |
| |||
103 | 136 | | |
104 | 137 | | |
105 | 138 | | |
106 | | - | |
| 139 | + | |
107 | 140 | | |
108 | 141 | | |
109 | 142 | | |
| 143 | + | |
110 | 144 | | |
111 | 145 | | |
112 | 146 | | |
| |||
121 | 155 | | |
122 | 156 | | |
123 | 157 | | |
124 | | - | |
125 | | - | |
| 158 | + | |
| 159 | + | |
126 | 160 | | |
127 | 161 | | |
128 | 162 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | | - | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
| |||
0 commit comments