RTC: Sync the content even if its a function#76796
Conversation
|
Size Change: +27 B (0%) Total Size: 7.69 MB
ℹ️ View Unchanged
|
| // A function that derives content from blocks (used by useEntityBlockEditor). | ||
| type ContentFromBlocksFn = ( args: { blocks: Block[] } ) => string; | ||
|
|
||
| function isContentFromBlocksFn( value: unknown ): value is ContentFromBlocksFn { |
There was a problem hiding this comment.
Could the checks here be improved any further?
|
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. |
| const currentValue = ymap.get( 'content' ); | ||
|
|
||
| if ( currentValue instanceof Y.Text ) { | ||
| mergeRichTextUpdate( currentValue, contentValue ); |
There was a problem hiding this comment.
A side effect of this that needs to be looked into, for the tests only, is the undo stack being modified. The actual undo/redo behaviour remains the same but the test is failing.
|
Flaky tests detected in 0213d77. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23575917639
|
…tate (#76848) * Return deferrer operations from applyPostChangesToCRDTDoc() to explicitly execute on a non-undo transaction * Don't compute content changes, instead locally inject a content function when blocks change to match dirty state
|
This'll be delayed till after 7.0's release to avoid introducing any risks this late. |
What?
Sync the
contentof a post, even if it's a function.Closes #76656
Why?
The save button should consistently becoming visible whenever any changes are detected. In an RTC session this applies across all collaborators because all changes are synced right away to everyone.
That means syncing the content so it doesn't go stale between collaborators.
How?
The content can be synced as a function. Due to the way we sync the properties right now, we ignore any functions as they can't be serialized. While this is true in general, there should be an exception for the content when the blocks are included as alongside it. The content can be generated using the blocks, and then that content can be synced.
This originates from the
use-entity-block-editorhook.This ensures that all collaborators have the updated content always.
Testing Instructions
Follow the duplication steps mentioned in the linked issue. It shouldn't be duplicated anymore.
Testing Instructions for Keyboard
Follow the duplication steps mentioned in the linked issue. It shouldn't be duplicated anymore either.
Use of AI Tools
Claude code for tests as well as to improve the function guard check.