Multi-User Selection #604
matthew-carroll
started this conversation in
Design Doc
Replies: 3 comments 2 replies
-
@roughike @miguelcmedeiros can you two take a look at this proposal and let me know if you have any suggestions? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I would love to help you with a better name for The proposal for the change in |
Beta Was this translation helpful? Give feedback.
0 replies
-
Seems just what we need, I have just a couple questions:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Super Editor would like to support rendering multiple user selections at the same time. Recent work on
super_text_layout
makes the rendering possible, but we still need to expose appropriate APIs at thesuper_editor
level.Ideally, multi-user selection management should be simple and easy, but it also shouldn't make single-user selection any more complicated than it already is. The average use-case is single-user selection, and that's likely to be true forever.
How can we offer multi-user selection controls without making single-user selection more tedious?
What needs to be tracked?
Multi-user selection obviously requires tracking multiple
DocumentSelection
s. But it also requires tracking more than that. To update a given selection, or to remove it, the selection must be linked to the corresponding user.However, as we consider rendering multiple selections, it's worth considering a feature like "find", which highlights every span of text in the document that matches a given search query. The "find" use-case also requires multiple selections, but those selections are not tied to a specific user. The primary goal at this point is multi-user selection, but it would be a win to leave the door open for multi-selection controlled by any given feature, such as find.
With whatever information is tracked, the selections should be listenable, individually. It's reasonable to assume that
super_editor
would like to repaint only what's necessary, and part of this optimization requires thatsuper_editor
be aware of which selections changed, and which selections didn't. For example, a selection is likely to sit within a single paragraph. In such a situation,super_editor
should not repaint the other 20 paragraphs in that same document.Representing multiple selections
User selection is currently owned by an object of type
DocumentComposer
. The selection is queried and set with theselection
property. Selection change notifications are sent through aselectionNotifier
property.Given that a
SuperEditor
document should always have at least one user, and there's always a "primary" user,super_editor
can retain the existing selection properties, as-is.Additional selections can be added as a collection within the
DocumentComposer
:The name
NonPrimarySelection
isn't great. I'm open to suggestions. But the above API should make it clear how one would add, change, and remove non-primary selections for any purpose. For multi-user selection, the ID for the non-primary selection could be the user's ID. If non-primary users can select multiple regions, then the ID could add a suffix, e.g., "user1234_1" and "user1234_2".Display user names attached to carets
Superlist would like to display the name of each user next to that user's caret.
Additional user metadata could be attached to each
NonPrimarySelection
, but the diversity of use-cases for selection metadata is unbounded. Instead,super_editor
should make any desired caret decoration possible.Where should a caret be rendered?
Decorating a caret with a user name brings us to an existing issue in
super_editor
. Currently,super_editor
asks each component in the document to render a caret (when using mouse input). This delegation makes it easy for the caret to look very different depending on the type of content. For example, an image might paint a caret very differently from a paragraph of text.Painting the caret within each component created a problem for
super_editor
's mobile implementation. On mobile, the caret is visibly a document-wide control. On Android, for example, the caret includes a drag handle, which allows the user to drag that caret throughout the document. It's impractical to delegate caret drawing to individual components when the user can drag the caret across the document. For this reason, I filed:Assuming that
super_editor
offered a generic overlay anchoring system, the users' carets could be displayed in that document-wide overlay. Each caret could connect to aLayerLink
to allow any other content to layout near the caret. Or, that overlay system could make it easy for apps to draw custom carets, thereby allowing Superlist to paint their own carets with user names next to them.Next steps
DocumentComposer
Beta Was this translation helpful? Give feedback.
All reactions