Phase 2: Capture Suggest-mode edits as an in-memory overlay#77404
Phase 2: Capture Suggest-mode edits as an in-memory overlay#77404adamsilverstein wants to merge 13 commits into
Conversation
|
Size Change: +3.49 kB (+0.04%) Total Size: 7.97 MB 📦 View Changed
ℹ️ View Unchanged
|
edf102e to
fa199f5
Compare
f78a787 to
3ca48fe
Compare
8043af8 to
b1af20a
Compare
3ca48fe to
4bdfdda
Compare
Add the suggestion-overlay subsystem that powers the `suggest` editor
intent added in the previous step. An `editor.BlockEdit` filter wraps
every block; when the intent is `suggest` it diverts `setAttributes`
into an overlay reducer keyed by `clientId` and passes merged
`{ ...real, ...overlay }` attributes into the block for rendering.
The block-editor store is never touched, so autosave, undo, and RTC
sync stay at the real baseline.
A `SuggestionCommitBar` exposes Submit / Discard controls in the
block toolbar when the selected block has a pending overlay. Submit
creates a note comment carrying a versioned `_wp_suggestion` JSON
payload (`blockName`, `baseRevision`, `operations`) via REST; discard
clears the overlay. The `applySuggestion` / `rejectSuggestion` hooks
are stubbed behind the same provider interface so Phase 3 can plug in
without UI changes, and a future Yjs AttributionManager-backed
provider can drop in with the same shape.
PHP-side registers `_wp_suggestion` and `_wp_suggestion_status`
comment meta with REST exposure. Both require `edit_comment`; no new
routes are added.
Refs #73411
b1af20a to
6ae1fa6
Compare
Move the baseline-captured signal from a local ref onto the reducer's entry map so Submit/Discard/orphan-prune cleanly resets it — a second edit after the overlay is cleared now reliably captures a new baseline instead of silently no-op'ing on the stale ref. Split the HOC into an outer Suggest-mode check and an inner SuggestingBlockEdit component. The overlay's context lookup, refs, and merge memo only run when intent === suggest; in Edit/View the wrapper executes a single useSelect and returns the original BlockEdit untouched, removing measurable per-render overhead on timing-sensitive e2e specs running on shards 4/5. Add unit coverage for View-intent pass-through and for re-capturing a baseline after the overlay is cleared.
6ae1fa6 to
b09c96d
Compare
|
Flaky tests detected in 9d144ea. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26054060512
|
|
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. |
d45e494 to
89c12b6
Compare
Add lint suppressions for the recently introduced react-hooks/refs violation in with-suggestion-overlay.js and react-hooks/globals violation in its test, matching the pattern already used elsewhere in the suggestion-mode directory.
Overview
This is one of 5 stacked PRs implementing Suggest mode for the WordPress editor — a Google Docs–style workflow where reviewers can propose changes that the post author can Accept or Reject. Tracked in #73411, with design direction from #73410 and jasmussen's mockups.
This PR (Phase 2)
Builds the in-memory suggestion overlay:
SuggestionOverlayProvider— React context that stores pending attribute changes perclientId, plus a baseline snapshot captured on the first edit. The block-editor store is never written.withSuggestionOverlayHOC — registered as aneditor.BlockEditfilter. The HOC is split into an outeruseSelectwrapper and an innerSuggestingBlockEditcomponent: non-Suggest intents run a singleuseSelectand return the wrappedBlockEdituntouched, so the overlay's context lookup, refs, and merge memo add no measurable overhead on timing-sensitive e2e specs.{ ...realAttributes, ...overlayAttributes }for rendering, so the user sees their in-progress change live. Object-valued attributes (style,metadata) are one-level merged so untouched fields survive.What's NOT in this PR
_wp_suggestioncomment meta and REST plumbing (Phase 3)Phase 2 test plan
wp.data.select('core/editor').getEditedPostContent()and confirm the serialized content does not include your suggested textnpm run test:unit -- packages/editor/src/components/suggestion-mode/test/overlay-context.jsnpm run test:unit -- packages/editor/src/components/suggestion-mode/test/with-suggestion-overlay.js🗺️ PR Stack Navigation
_wp_suggestionmeta, provider, sidebar actions📋 Tracking issue: #73411