From 5d4d490fea204e7a152121062d5d5d256d136063 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 2 May 2024 08:55:59 +0200 Subject: [PATCH] Disable hiding of selection inside focused widgets FIX: Don't hide the native selection in widgets that have focus. See https://discuss.codemirror.net/t/inability-to-use-selector-with-an-input-widget-when-using-the-drawselection-plugin/8182 --- src/draw-selection.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/draw-selection.ts b/src/draw-selection.ts index 497bc31..bbd625e 100644 --- a/src/draw-selection.ts +++ b/src/draw-selection.ts @@ -111,12 +111,17 @@ const selectionLayer = layer({ const themeSpec: {[selector: string]: StyleSpec} = { ".cm-line": { - "& ::selection": {backgroundColor: "transparent !important"}, - "&::selection": {backgroundColor: "transparent !important"} + "& ::selection, &::selection": {backgroundColor: "transparent !important"}, + }, + ".cm-content": { + "& :focus": { + caretColor: "initial !important", + "&::selection, & ::selection": { + backgroundColor: "Highlight !important" + } + } } } -if (CanHidePrimary) { - themeSpec[".cm-line"].caretColor = "transparent !important" - themeSpec[".cm-content"] = {caretColor: "transparent !important"} -} +if (CanHidePrimary) + themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important" const hideNativeSelection = Prec.highest(EditorView.theme(themeSpec))