-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Templates: Assign default post format block as template setting #9287
Conversation
test/e2e/specs/templates.test.js
Outdated
await newPost( { postType: 'book' } ); | ||
} ); | ||
describe( 'templates', () => { | ||
describe( 'Using a CPT with a predefined template', () => { |
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.
None of these existing "Using a CPT" test cases have been changed. They're simply grouped / nested within a new "templates" describe
block.
Edit: Scratch that, while I was here, I normalized to use getEditedPostContent
instead of the existing "switch to code editor" logic.
0b0b5b7
to
109d0ca
Compare
@@ -228,6 +229,11 @@ export function getDefaultBlockName() { | |||
* @return {string} Block name. | |||
*/ | |||
export function getDefaultBlockForPostFormat( postFormat ) { | |||
deprecated( 'getDefaultBlockForPostFormat', { |
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 not sure if we should deprecate this selector as it may be a useful selector for plugins, that may want to have a UI based on post formats. We also have a possible use case of this selector, the getSuggestedPostFormat selector. Currently is not using this selector but I think we may do a refactor there to use it instead of removing the 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.
On a second thought, a refactor of getSuggestedPostFormat may not be possible as in this selector we may have multiple blocks mapping to a single post format.
I still think getDefaultBlockForPostFormat may be useful for plugins but If we don't have a use case for it we should not be sending its bytes so probably what we have now is the best option.
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 tend to optimize toward avoiding keeping things around because we'd anticipate them to possibly be useful. In this particular case, it's also a heavy maintenance burden to maintain mapping between post formats and default block both within JavaScript and in PHP. If it's something we want in the future, I think it'd be better for us to refactor how we provide it, bootstrapping from some constant (optionally filtered) defined server-side.
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 did some tests on the post formats (post init and suggestions) and the tests went well, everything seems to be working correctly. I think removing this system of starting a post with a block already inserted and using the one from templates is a positive change 👍
109d0ca
to
45ef23b
Compare
This pull request seeks to refactor default block by post format to be effected as a template.
This is being proposed for two primary reasons:
There are two notable differences from how this behaves in master:
Testing instructions:
Verify there are no regressions in the behavior of the default block by post format.
Ensure new end-to-end tests pass: