Templates: Assign default post format block as template setting#9287
Templates: Assign default post format block as template setting#9287
Conversation
| await newPost( { postType: 'book' } ); | ||
| } ); | ||
| describe( 'templates', () => { | ||
| describe( 'Using a CPT with a predefined template', () => { |
There was a problem hiding this comment.
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
| * @return {string} Block name. | ||
| */ | ||
| export function getDefaultBlockForPostFormat( postFormat ) { | ||
| deprecated( 'getDefaultBlockForPostFormat', { |
There was a problem hiding this comment.
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.
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.
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.
jorgefilipecosta
left a comment
There was a problem hiding this comment.
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: