-
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
Editor: Operate on template CPT posts and add a default template with post title and content blocks. #16565
Conversation
…block. Remove the `PostTitle` component from the `VisualEditor` component.
5b4aa69
to
39745cf
Compare
…'s static and the post is new.
39745cf
to
07392e0
Compare
I've rebased the zoom prototyping out of this PR and into #16578 . |
packages/editor/src/store/actions.js
Outdated
STORE_KEY, | ||
'getEditedPostContent' | ||
); | ||
|
||
const template = ( yield select( STORE_KEY, 'getEditorSettings' ) ).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.
Oh, so you're using the current template
editor setting as the actual "FSE template". The template
property is meant to be the post_content
template while the actual FSE template is something that get stored separately. There's a question to be asked about "naming confusion" and also whether we may want to absorb one use-case in another in the future but I think for now we may want to consider them as two separate entities.
Basically what I had in mind is something like that:
- a separate
template
prop in theEditorProvider
for the FSE template - The same way we have
currentPost
andedits
for the post in the reducer, I think we'd needcurrentTemplate
andtemplateEdits
maybe. - a boolean prop or something like that in the
EditorProvider
to switch between FSE mode (showing the template blocks) and current mode (showing a PostTitle input and the PostContent blocks as root level) - Both
core/post-content
andcore/post-title
blocks should be dynamic blocks that render the actual post title and post content in the frontend. - Basically
post-content.php
file shouldn't have to be touched to be loaded in an editor that has a template as well.
Does that make sense?
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.
Yeah, that was what I was planning, except I wasn't sure if I should change the way the template was being injected and was going to leave that for last so we could discuss it further.
From my zoom prototyping:
I started by trying to support insertions, replacements, and removals, but I quickly realized that it would take a pretty widespread refactor due to a lot of assumptions we make in the logic for getting insertion indexes and other data. I don't think the need for this feature warrants those changes. This makes me think that we might have to try a different approach for #16485 where the editor just switches between editing the template and editing post content with a static post title component like it does now.
So for next steps here I see:
- Give the template its own reducer and make all the necessary refactors. (Use the
'block_editor_settings'
filter to send it to the client in its own, new key.) - Implement the "zoom" as a toggle between setting up the editor with the template or post.
- Implement the render callbacks of the post title and post content blocks.
…nd add a toggle between template and post mode.
Read-only mode enabled on post content in edd9eeb. |
This reverts commit edd9eeb.
02fb194
to
8cfb1e4
Compare
Closing this as it was just a prototype and most of the functionality has already been merged in more granular PRs. See: https://github.com/WordPress/gutenberg/labels/%5BFeature%5D%20Full%20Site%20Editing |
cc @youknowriad
Closes #16281
Description
This PR builds on @aduth 's work on #16402 to add backwards compatible support for making the editor operate on and persist to template CPT posts instead of the actual edited post.
It adds a single, default, editable template to the "post" post type which contains a new post-title block, which persists to the edited post's title, followed by a new post-content block, which persists to the edited post's
post_content
. Note that this post-content block produces no markup onsave
so that the template only stores the location ofpost-content
relative to the other blocks in the template. When the template is rendered by a theme, either explicitly or dynamically like in #4659, a render callback for the block could fill in the viewed post's content.Future work will be needed to allow users or theme authors to create a template hierarchy and apply them to specific posts.
How has this been tested?
Posts were edited and saved and it was verified that the template updated correctly when making changes outside of the post-content block, as well as the title for the post-title block, and the content for the post-content block.
Screenshots
Types of Changes
New Feature: Operate on template CPT posts and add a default template with post title and content blocks.
Checklist: