Override default selection background for active match #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ocavue/selection-css"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the editor is focused and
.ProseMirror-active-search-matchexists, the selection background color (usually in light blue) and the orange active decoration will overlap. This PR fixes the issue by only applying background color to::selection.A tiny issue is that, in Chrome, the
<span>and::selectionhas different height, which causes the orange.ProseMirror-active-search-matchis slightly higher than the yellow.ProseMirror-search-match. I think this doesn't bother users. Just FYI.Before
https://github.com/ProseMirror/prosemirror-search/assets/24715727/68614750-d7ad-4666-9d45-139f7ce78759
After
https://github.com/ProseMirror/prosemirror-search/assets/24715727/8a0cbc4e-e2b6-433a-86cd-838c7e38b1ec
I don't think it is a good idea to change the color of the selection when it is on a search match. I'm not sure the overlapping backgrounds are an issue at all.
The
.ProseMirror-active-search-matchclass only appears when the text selection exactly matches it. This means the orange color will never be shown without mixing to users, which seems odd from a design perspective.Additionally, I noticed that the background of the text selection and the span decoration have different heights, creating some padding, shown below:
These issues wouldn't arise if the text selection and
.ProseMirror-active-search-matchdon't need to cover the same range. It seems that most rich text editors like Google Docs and MS Word, unlike code editors, don't change the selection while searching, so they don't have this color overlapping issue.That said, I'm satisfied with the current API. It's flexible, allowing me to easily implement the styling on my end. It also makes sense that this library provides basic implementation and lets users do further customization. Feel free to close this PR.
A common thing to do is to search from some kind of search dialog, without focus on the editor, in which case we need some way to show which match is the currently active one. When the editor is focused, the visible selection mostly fills this role.
But yeah, I'd like to avoid making these complicated or interfering with the selection color by default, so let's close this and let people do things like that in their own styling.
Pull request closed