Move WPBlockSelection to a single canonical location in block-editor#77864
Move WPBlockSelection to a single canonical location in block-editor#77864Copilot wants to merge 4 commits into
Conversation
…ckages. The `WPBlockSelection` type is more complicated than it may seem at face value. This change expands the docblock information on the type and links together the currently-existing duplicates in other packages, which are duplicated to avoid creating circular dependencies. This is prepartory work for #77658, but stands on its own as a clarifying update.
58ec519 to
d61e793
Compare
|
@copilot go ahead and start the work. what is the best new canonical location for the you will need to actually add when this is done, only a single declaration for the type will exist. if you have multiple copies leftover in the repo then you are not finished. keep going. |
Agent-Logs-Url: https://github.com/WordPress/gutenberg/sessions/552eb0ef-138b-4eb5-b090-5a4c93da5b33 Co-authored-by: dmsnell <5431237+dmsnell@users.noreply.github.com>
Done in commit Canonical location: Changes:
One finding during implementation: the |
d61e793 to
c67e682
Compare
|
@copilot update based on the updates to the original PR |
Agent-Logs-Url: https://github.com/WordPress/gutenberg/sessions/8e983424-87c0-49c7-be1d-638f663f849e Co-authored-by: dmsnell <5431237+dmsnell@users.noreply.github.com>
Updated in commit |
|
@copilot monitor the discussion in WordPress.org’s Slack team https://wordpress.slack.com/archives/C02QB2JS7/p1777595987225769 If someone answers, update this PR |
11dd3f3 to
9b5b867
Compare
The
WPBlockSelectiontype was duplicated across four locations (core-data/src/types.ts,block-editor/src/store/selectors.js,block-editor/src/store/actions.js,editor/src/store/selectors.js) with a@todoto consolidate it. This PR implements that consolidation.Canonical Location
packages/block-editor/src/store/types.ts(new file) — bothcore-dataandeditoralready depend on@wordpress/block-editor, so importing from there introduces no new dependencies or circular refs.block-editorsemantically owns the selection concept.Changes
packages/block-editor/src/store/types.tsexporting the single canonicalWPBlockSelectionandWPSelectionTypeScript interfacesblock-editor/tsconfig.jsonto include the newtypes.tsfilecore-data/src/types.tsto re-export both types from@wordpress/block-editor/src/store/typesinstead of defining them inline (removes the@todocomment)block-editor/src/store/selectors.js,block-editor/src/store/actions.js, andeditor/src/store/selectors.jsto replace@typedef {Object} WPBlockSelectiondeclarations with@typedef {import(...).WPBlockSelection}references pointing to the canonical fileThere is now exactly one
interface WPBlockSelectiondeclaration in the repository.Notes
During implementation, the
WPSelectiontypedef previously inactions.jswas found to describe a genuinely different type ({ start, end }for action payloads) versus the canonicalWPSelection({ selectionStart, selectionEnd }for stored state). TheselectionChange()function now uses an inline{start: WPBlockSelection, end: WPBlockSelection}type annotation to avoid the naming confusion.