-
Notifications
You must be signed in to change notification settings - Fork 27
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
Proposal – Add support for presences #25
base: master
Are you sure you want to change the base?
Conversation
607d42f
to
70dabfd
Compare
I just changed a bit the implementation to also allow arbitrary data inside the presence without dropping it. What do you think of this proposal @josephg? |
@Calyhre Have you used it in production? I'm looking to upgrade from json0 |
This ot-type yes, we are using it at Slite.com. As for the presence patch, not yet. |
Sorry, but why it isn't merged, yet? |
if (et.transformPosition) path[i] = et.transformPosition(path[i], e) | ||
if (et.transformPosition) { | ||
path[i] = et.transformPosition(path[i], e) | ||
} else if (et.transformCursor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where would transformCursor
come from? Is this for rich text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, not ideal but they renamed it there: https://github.com/ottypes/rich-text/blob/master/lib/type.js#L39-L41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I got it backward. As per the main OTType documentation it's transformCursor
that the type should implement. And it's text-unicode
(the default subtype in JSON1), that is missing it but implements transformPosition
.
This looks like interesting work! Eager to try it out. I'm curious, @Calyhre do you happen to have any interactive prototype that uses this that we could try? Here's an interactive demo that @houshuang and I came up with for the JSON0 presence work we did 2 years ago: https://github.com/datavis-tech/json0-presence-demo It would be interesting to see this JSON1 presence work inside a working demo like that one. That demo code could probably be modified to use JSON1 and this implementation. Another take - might it be possible to implement presence by extending JSON1 from an external package, rather than modifying JSON1 itself? |
I've dropped the ball on this. Sorry everyone! I'll take a look soon. |
Didn't made any other than implementing it on Slite.com using that very same code.
While I still think the JSON1.transformPresence = json1TransformPresence
|
Very nice! That's a great solution. In that case, it may make sense to publish this work as a separate package, and have this sort of patching be the way that it's used.
Would it work to patch rich text externally with something like |
So here is were things get a bit mixed up:
I understood it that way: It's up to the type to implement and support the However, this PR is a proposal for the minimum viable API to support |
I'm interested in re-visiting the challenge of presence with JSON1. |
Again, I'm picking this up, this time in the context of this open source web-based IDE: https://github.com/vizhub-core/vzcode with @Anooj-Pai. Tracking the presence task here: vizhub-core/vzcode#16 I'm curious to try out the changes in this PR and see if it works for our case. Since it's not merged, I may create a fork of JSON1 based on this and then iterate from there. From previous conversations here:
This, I suppose, would be the first step in verifying that this works. I'll try implementing it in VZCode and will report here how it goes. If we could get this eventually merged that would be amazing! But I understand the hesitancy to merge this without any fully working open source example based on it. |
I'm considering maintaining a fork with this work. I've been trying to test this in this VZCode project which uses Vite as the build tool, but am having all sorts of problems relating to the legacy build requirements (CommonJS + Node polyfills due to the My game plan at the moment for implementing presence in a project that uses Vite as its build system:
|
Suggest to update the "test" script in
|
The main substantive feedback on this that I have is that it does not support multiple selections. I'm working on an integration with CodeMirror 6, which does support multiple selections. So one of the limiting factors with the integration is that in case a user makes multiple selections, we need to just pick one to broadcast as presence. Perhaps the shape of the presence could be changed from
to
|
Hello 👋 As stated in #9, ShareDB "recently" introduced presences in share/sharedb#322
The shape of the presence object is up to the OT type to define. So I propose a very simple one:
This pull request propose this type and the following
transformPresence
implementation. This internally callstransformPosition
for each end of the presence, and fallbacks on thetransformPosition
ortransformCursor
of the leaf subtypes if needed. There is a few examples in the tests for a better understanding.We could also consider shortening the keys to match the size saving effect used by operations.
Let me know what you think!