Skip to content
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

Use createBlock helper in place of manual block creation #690

Merged
merged 3 commits into from
May 10, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented May 5, 2017

Closes #688

This pull request seeks to use the wp.blocks.createBlock helper consistently for creating blocks, particularly in block transforms.

Testing instructions:

Verify that there are no regressions in changing between heading, text, and quote block types.

@youknowriad
Copy link
Contributor

This means all the blocks returned already have uids. We may want to update switchToBlockType helper to avoid recreating new uids.

@aduth aduth added [Feature] Block API API that allows to express the block paradigm. [Status] In Progress Tracking issues with work in progress labels May 8, 2017
@aduth
Copy link
Member Author

aduth commented May 9, 2017

This means all the blocks returned already have uids. We may want to update switchToBlockType helper to avoid recreating new uids.

Isn't that what's already happening here?

https://github.com/WordPress/gutenberg/blob/90cc25b/blocks/api/factory.js#L88-L90

@youknowriad
Copy link
Contributor

Isn't that what's already happening here?

@aduth no I'd update this to :

index === firstSwitchedBlock ? block.uid : result.uid

@aduth aduth force-pushed the update/688-consistent-create-block branch from 8e5c6d5 to baa6737 Compare May 9, 2017 21:09
@aduth
Copy link
Member Author

aduth commented May 9, 2017

Thanks for the pointer @youknowriad . I've updated the factory method and updated the tests to assume blocks to be returned via createBlock.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use wp.blocks.createBlock in transforms handlers
3 participants