Skip to content

Commit 1cc369e

Browse files
committed
Remove special handling for ancient mobile Safari cursor-color issue
1 parent f0316b1 commit 1cc369e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/draw-selection.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import {EditorSelection, Extension, Facet, combineConfig, Prec, EditorState} from "@codemirror/state"
2-
import {StyleSpec} from "style-mod"
32
import {ViewUpdate, nativeSelectionHidden} from "./extension"
43
import {EditorView} from "./editorview"
54
import {layer, RectangleMarker} from "./layer"
6-
import browser from "./browser"
7-
8-
const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534)
95

106
type SelectionConfig = {
117
/// The length of a full cursor blink cycle, in milliseconds.
@@ -72,7 +68,7 @@ const cursorLayer = layer({
7268
let cursors = []
7369
for (let r of state.selection.ranges) {
7470
let prim = r == state.selection.main
75-
if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
71+
if (r.empty || conf.drawRangeCursor) {
7672
let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary"
7773
let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1)
7874
for (let piece of RectangleMarker.forRange(view, className, cursor)) cursors.push(piece)
@@ -109,19 +105,18 @@ const selectionLayer = layer({
109105
class: "cm-selectionLayer"
110106
})
111107

112-
const themeSpec: {[selector: string]: StyleSpec} = {
108+
const hideNativeSelection = Prec.highest(EditorView.theme({
113109
".cm-line": {
114110
"& ::selection, &::selection": {backgroundColor: "transparent !important"},
111+
caretColor: "transparent !important"
115112
},
116113
".cm-content": {
114+
caretColor: "transparent !important",
117115
"& :focus": {
118116
caretColor: "initial !important",
119117
"&::selection, & ::selection": {
120118
backgroundColor: "Highlight !important"
121119
}
122120
}
123121
}
124-
}
125-
if (CanHidePrimary)
126-
themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important"
127-
const hideNativeSelection = Prec.highest(EditorView.theme(themeSpec))
122+
}))

0 commit comments

Comments
 (0)