Skip to content

Maintaining Text Selection with Focus Shift in Plate.js #3126

Answered by 12joan
SID9-HoneyBee asked this question in Q&A
Discussion options

You must be logged in to vote

If your font size controls do not require focus (which they probably don't require unless they involve a text input), you can prevent focus from leaving the editor while the user interacts with the controls by calling event.preventDefault() on each mousedown event.

Otherwise, you can render a fake selection rectangle using either an absolutely positioned div (see getSelectionBoundingClientRect) or a Slate decoration (see this tutorial and the code for createFindReplacePlugin for an example of using decorators in Plate).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SID9-HoneyBee
Comment options

Answer selected by SID9-HoneyBee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants