-
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
Framework: Set/Get default block slug #1156
Conversation
blocks/api/index.js
Outdated
@@ -13,6 +13,8 @@ export { | |||
unregisterBlockType, | |||
setUnknownTypeHandler, | |||
getUnknownTypeHandler, | |||
setDefaultBlockSlug, |
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.
defaultBlockName? :)
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 got confused, because we were using slug
in the same file.
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.
Updated but I'm still confused when to use slug and when to use name
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.
Related: #974
I think the intent is to replace slug
with name
.
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.
Yes, we still have a few to clean up, but going with name across the board.
c79d0b7
to
4b2df79
Compare
blocks/api/registration.js
Outdated
* | ||
* @param {string} slug Block slug | ||
*/ | ||
export function setDefaultBlockName( slug ) { |
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.
Per prior note, we should probably change this from slug
to name
in anticipation of #974.
4b2df79
to
0ae5458
Compare
I'm going to merge this soon, to move forward with #1082 |
blocks/api/registration.js
Outdated
* | ||
* @param {string} name Block name | ||
*/ | ||
export function setDefaultBlockName( name ) { |
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.
Maybe setDefaultBlock( name )
? Could be confused as "change the name of the block which is the default", not "set the block to be used as the default".
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.
Sounds good
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.
Yes, also redundant because you are passing the name.
0ae5458
to
b8b038f
Compare
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'm continuing to flip-flop on the naming, since we'd distinguished blocks more as instances and block type as the prototype, setDefaultBlock
may not be most accurate.
Anyways, I don't want to hold this up, and we can revisit, notably in pushing along #974.
b8b038f
to
9ef6fcf
Compare
closes #798
In this PR, I'm adding two functions
setDefaultBlockSlug
andgetDefaultBlockSlug
in the same way we havesetUnknownTypeHandler
.I'm hoping to use this default block as an automatic block appended to newly created blocks. #1082