-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add awareness accessor functions to experimental collaboration #70696
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
Add awareness accessor functions to experimental collaboration #70696
Conversation
…ers and state fields before bootstrap.
…imental-collaboration-awareness
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@ingeniumed Please take a look and potentially make a merge when you have the chance. Thank you! |
| /** @typedef {import('./types').UndoManager} UndoManager */ | ||
| /** @typedef {import('./types').HistoryRecord} HistoryRecord */ | ||
|
|
||
| const AWARENESS_DOC_TYPE = 'postType/Posts'; |
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.
Not a blocker rn, but for a future PR: Should this be just postType similar to the undo manager so that it works for pages and other CPTs as well rather than just posts?
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.
Probably, good call-out.
| awareness: connectRemoteResult?.awareness || null, | ||
| destroy: () => { | ||
| destroyLocalConnection?.(); | ||
| connectLocalResult?.destroy?.(); |
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.
Nice spot 👍🏾
7c90a38
into
WordPress:add/expertimental-collaborative-editing
What?
Adds awareness functions to
getSyncProvider().awareness:These functions are proxied to actual awareness functions, and can be enqueued and called before awareness is available. Usage looks like this:
Why?
This will allow plugins to use and implement presense and awareness updates with Yjs using
getSyncProvider().awareness.How?
getSyncProvider()is bootstrapped when the editor is ready, which can make it difficult to use awareness functionality from a plugin. The implementation here uses a pending queue to immediately send/process messages when awareness functionality is ready, and the user can callgetSyncProvider().awarnessfunctions anytime. Additionally we proxy awareness functions to give the user more restricted access to the Yjs internal model.