StS
February 17, 2023, 11:16am
1
I figured out the class to set the background-color of the marked/selected text :
.CodeMirror-focused .CodeMirror-selected {background-color:yellow; }
I’m unable to set the color of the marked/selected text - tested with
.CodeMirror-selectedtext,
.CodeMirror-selected,
.CodeMirror-focused,
.CodeMirror-focused .CodeMirror-selected { color: black !important; }
Settings:
Any ideas?
Thanks
Stefan
pmario
February 18, 2023, 5:40am
2
They are defined with the TW palette manager.
View in edit mode: https://tiddlywiki.com/plugins/tiddlywiki/codemirror/#%24%3A%2Fplugins%2Ftiddlywiki%2Fcodemirror%2Fstyles and go to.
\define set-selection-background-colours(palette)
you’ll see, how it is calculated. It’s a dynamic setting. So you need to change your TW palette
\define set-selection-background-css(colour,colourA,colourB,tiddlerEditorBackground)
<$wikify name="tiddlerEditorBackground" text={{{ [[$tiddlerEditorBackground$]lowercase[]] }}}>
<$set name="backgroundColour" value=<<contrastcolour target:"""$colour$""" fallbackTarget:"""""" colourA:"""$colourA$""" colourB:"""$colourB$""">>>
<$set name="backgroundColour" value={{{ [<backgroundColour>lowercase[]match<tiddlerEditorBackground>then[]] ~[<backgroundColour>] }}}>
.cm-s-tiddlywiki div.CodeMirror-selected { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki.CodeMirror ::selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
</$set>
</$set>
</$wikify>
\end
pmario
February 18, 2023, 5:46am
3
I think there is a bug too: Palette Manager — Preview
has selection-background and selection-foreground. … which is applied to the default TW textarea. … BUT it seems the CM setting is different. We should probably fix. that.
It seems the CM code snippet shown above uses the foreground color instead of selection-foreground
StS
February 18, 2023, 5:16pm
4
Thanks for investigation - I’m looking forward for a solution.