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

Include block default attributes in created block #686

Merged
merged 1 commit into from
May 9, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented May 5, 2017

Originally considered for #684, this pull request improves the behavior of createBlock by considering a block's defaultAttributes in the return value attributes. Per discussion at #684 and #674 (comment), we may want to standardize on any children attribute being provided a default empty array value, but we should be able to create these blocks without explicitly providing that value (when the block defines it already as a default).

Testing instructions:

There is no expected visual changes, though you should verify no regressions in inserting a new block.

Ensure unit tests pass:

npm test

@aduth aduth added the [Feature] Block API API that allows to express the block paradigm. label May 5, 2017
@aduth aduth requested a review from youknowriad May 5, 2017 18:33
return {
uid: uuid(),
blockType,
attributes
attributes: {
...defaultAttributes,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use blockSettings.defaultAttributes directly here. You showed me that Object.assign handles the undefined value properly :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Could we use blockSettings.defaultAttributes directly here. You showed me that Object.assign handles the undefined value properly :)

It'll handle an undefined defaultAttributes here, but if blockSettings doesn't exist and we try to access the defaultAttributes property on it, an error would be thrown.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants