-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Editor: Implement the EntityHandlers
component and basic template blocks.
#17020
Closed
epiqueras
wants to merge
24
commits into
update/the-editor-store-to-use-core-data-entities
from
try/implementing-entity-handlers
Closed
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6854ff6
Editor: Update the store to use Core Data entities.
aduth f0fb34b
Editor: Fix selector test suites.
epiqueras b483709
Editor: Fix some legacy selectors and behaviors.
epiqueras 892fd2e
Editor: Fix action tests.
epiqueras 8bcbd14
Editor: Fix remaining broken unit tests.
epiqueras 2cc0e18
Editor: Fix more tests.
epiqueras a21cb13
Editor: Fix more e2e test behaviors.
epiqueras 1045a01
Editor: Fix preview functionality.
epiqueras 56d0e9e
Core Data: Fix autosaves filtering.
epiqueras d93d239
Editor: Don't make entity dirty with initial edits.
epiqueras f1b18ad
Editor: Don't save if the post is not saveable.
epiqueras 28bae58
Core Data: Fix merged edits logic.
epiqueras afaec5e
Core Data: Fix undo to fit e2e expected behaviors.
epiqueras bfee37a
Core Data: Handle more change detection and saving flows.
epiqueras 97502af
Block Editor: Fix undo level logic.
epiqueras 029b901
Core Data: Clean up undo reducer comment.
epiqueras 7af50bb
Editor: Implement the `EntityHandlers` component and use it to create…
epiqueras 783e97e
Editor: Refactor custom sources into a simple getter/setter approach.
epiqueras b56cb43
Editor: Implement the `handles` prop for Entity Handlers.
epiqueras f8a97bd
Block Library: Make the post block delegate content to its parent and…
epiqueras 0bfcf28
Block Editor: Provide blocks a way to edit entities without relying o…
epiqueras 7245d99
Editor: Make the store multi-entity-kind compatible and implement the…
epiqueras 0f64686
Block Library: Implement post content block.
epiqueras 35bc41c
Block Library: Implement server side rendering for the site title block.
epiqueras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "core/post-title", | ||
"category": "theme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { RichText } from '@wordpress/block-editor'; | ||
import { cleanForSlug } from '@wordpress/editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export default function PostTitleEdit() { | ||
const title = useSelect( | ||
( select ) => select( 'core/editor' ).getEditedEntityAttribute( 'title' ), | ||
[] | ||
); | ||
const dispatch = useDispatch(); | ||
return ( | ||
<RichText | ||
value={ title } | ||
onChange={ ( value ) => | ||
dispatch( 'core/editor' ).editEntity( { | ||
title: value, | ||
slug: cleanForSlug( value ), | ||
} ) | ||
} | ||
tagName="h1" | ||
placeholder={ __( 'Title' ) } | ||
formattingControls={ [] } | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/components'; | ||
|
||
export default ( | ||
<SVG xmlns="https://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
<Path fill="none" d="M0 0h24v24H0V0z" /> | ||
<Path d="M5 4v3h5.5v12h3V7H19V4H5z" /> | ||
</SVG> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
import icon from './icon'; | ||
import edit from './edit'; | ||
|
||
const { name } = metadata; | ||
export { metadata, name }; | ||
|
||
export const settings = { | ||
title: __( 'Post Title' ), | ||
icon, | ||
edit, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this logic is not going to work because innerBlocks will never have the same reference that isSyncingIncomingBlocks.
We call:
this.isSyncingIncomingBlocks = blocks;
replaceInnerBlocks( blocks );
When the replace operation is finished and we get new innerBlocks the reference of these inner blocks is not the same as the blocks we passed to replaceInnerBlocks. Because blocks are not saved as a tree in the state and the reference we get is new computation created by the getBlock selector.
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.
That's not ideal, could we get around it somehow? Maybe the reducer can keep a reference to the original array or something. In any case, this logic should not cause any issues if we leave it in until an enhancement is made to the store.