Collaborative editing: Make syncing a side-concern instead of a replacement for local state#72114
Conversation
|
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. |
This reverts commit 7d8fdf0.
| name | ||
| ); | ||
| const namespace = postType?.rest_namespace ?? 'wp/v2'; | ||
| const syncedProperties = new Set( [ 'blocks' ] ); |
There was a problem hiding this comment.
I don't understand why we need this change here? It feels very ad-hoc?
There was a problem hiding this comment.
Also what about post types that don't support "content" (so have no "blocks" property)
There was a problem hiding this comment.
I don't understand why we need this change here? It feels very ad-hoc?
It is very ad hoc:
In the entity sync config, introduce a set of synced properties. This set is currently limited to
blocksto help navigate syncing errors, but it will be expanded in future PRs.
"Syncing errors" is shorthand for all sorts of edge cases, but the most serious issues are:
- Rich text attributes need to target the
rawproperty. - The
statusfield cannot be synced until it "matures" past"auto-draft", otherwise timing issues can result in the post getting stuck.
I didn't address these in this PR because we have more robust solutions available in other PRs, which I will open shortly. But I can create targeted fixes in this PR if that is desired.
There was a problem hiding this comment.
I don't feel like this addresses my question though. I guess what I'm asking is that before making "blocks" a synced property for a given post type entity, we should first ensure the post type in question supports "content" (which we can do in the supports array no?)
There was a problem hiding this comment.
Anyway, it's not a huge concern though but we should be thinking about post types that don't have "content" or "blocks".
There was a problem hiding this comment.
Yes, also addressed in a future PR. You can see how we approached this in #72040 in this commit:
Apologies, I will have them all open today and can give you better pointers.
|
Thanks for splitting the work into small PRs, this one is good to go :) |
|
Note that I sent you an invite to join the Gutenberg team, which means you should be able to use branches instead of a fork and also can merge approved PRs |
|
I invite you to check the different PR practices (labels, merging props...) |
…cement for local state (WordPress#72114) Co-authored-by: chriszarate <czarate@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
What?
Instead of effectively replacing the core-data store with a "database" Yjs provider (IndexedDB), this change makes syncing a side-effect of the
core-datastore, without changing how the entity records are represented and treated within it.Note
This is the first of a series of modular PRs related to collaborative editing derived from the work in #72040. Not all PRs result in a fully functional editing experience.
Why?
guid,_links, andmodifiedshould not be synced because we want the local codebase to remain authoritative over their values.contentshould not be synced because we prefer to sync a derivative property (blocks) instead.core-datastore continues to function as it does now, and the sync package interacts with it as a (privileged) client.How?
editEntityRecord(core-dataactions), do not skip dispatching edits and adding undo records for entities with syncing enabled.getEntityRecord(core-dataresolvers), do not conditionally load the entity record into the store, and invert the order so that the entity is loaded before "bootstrapping."963b9796c15a1a44431b3386775e7fe05e5bfd1f96293a8e20f5debae3478bc8).
blocksto help navigate syncing errors, but it will be expanded in future PRs.Testing Instructions
Note: This provider uses requests to
admin-ajax.phpfor signaling and the initial connection is delayed.Testing Instructions for Keyboard
No UI changes in this pull request.
Screenshots or screencast
pr-1.mov