-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change Selection
points to be nullable
#2991
Comments
Related: #2108 |
Actually, I wonder if instead of the points on the selection being nullable, the It makes it even more clear what's going on, since having However, it means that we'd need to tweak the operations a bit I think. Because I think it would need to be modeled as three operations (?):
Which feels a little overkill? The DOM goes with always having a selection, that may or may not have ranges. But I think this is one of the more awkward parts of the DOM API, so it's not really something I want to take into account, unless we can find a good reason for it. |
Would you need to have three operations? Could Mirroring the DOM API would make sense if Slate supported multiple ranges. Which I think we've talked about before. I've only really wanted multiple ranges in one situation (rectangular table cell selections), and I don't think faking it with anchorCell / focusCell is any worse than having it be officially supported. So I (at least) don't feel a strong need for it. |
That's a good question, we could probably let |
Or maybe even an empty object, if |
Fixed by #3093. |
Do you want to request a feature or report a bug?
Debt / improvement.
What's the current behavior?
Because the user can have "not selected anything", and because the document can actually be empty, with no nodes, such that there is nothing to select even... we have this concept of an "unset" selection.
Right now we model this as a
Point
withpath
andoffset
both set tonull
. But I think this introduces ambiguity into the data model that creeps into lots of places, since all Ranges/Points can then be nullable.Instead, I think it would be better to model it as:
That way the null-ness only ever applies to the
Selection
model. And if you have aRange
or aPoint
you know they are guaranteed to be filled in.This will mean people have to check
Selection.isSet()
, but they really should have been doing it before, we just kind of exit early and other unintuitive behavior when the selection isn't actually set.The text was updated successfully, but these errors were encountered: