Repository navigation
Commands: add toggle for content-only pattern/template part editing #78383
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
Changes from all commits
d6007f1
b4529ea
96a15f2
20dee27
ca7b805
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,8 @@ const getEditorCommandLoader = () => | |
| isCodeEditingEnabled, | ||
| isRichEditingEnabled, | ||
| isPublishSidebarEnabled, | ||
| disableContentOnlyForUnsyncedPatterns, | ||
| disableContentOnlyForTemplateParts, | ||
| } = useSelect( ( select ) => { | ||
| const { get } = select( preferencesStore ); | ||
| const { isListViewOpened, getCurrentPostType, getEditorSettings } = | ||
|
|
@@ -74,6 +76,11 @@ const getEditorCommandLoader = () => | |
| isRichEditingEnabled: getEditorSettings().richEditingEnabled, | ||
| isPublishSidebarEnabled: | ||
| select( editorStore ).isPublishSidebarEnabled(), | ||
| disableContentOnlyForUnsyncedPatterns: | ||
| !! getEditorSettings() | ||
| .disableContentOnlyForUnsyncedPatterns, | ||
| disableContentOnlyForTemplateParts: | ||
| !! getEditorSettings().disableContentOnlyForTemplateParts, | ||
| }; | ||
| }, [] ); | ||
| const { getActiveComplementaryArea } = useSelect( interfaceStore ); | ||
|
|
@@ -86,7 +93,12 @@ const getEditorCommandLoader = () => | |
| toggleDistractionFree, | ||
| toggleSpotlightMode, | ||
| toggleTopToolbar, | ||
| updateEditorSettings, | ||
| } = useDispatch( editorStore ); | ||
| // eslint-disable-next-line @wordpress/no-unused-vars-before-return | ||
| const { stopEditingContentOnlySection } = unlock( | ||
| useDispatch( blockEditorStore ) | ||
| ); | ||
| const { openModal, enableComplementaryArea, disableComplementaryArea } = | ||
| useDispatch( interfaceStore ); | ||
| const { getCurrentPostId } = useSelect( editorStore ); | ||
|
|
@@ -98,6 +110,9 @@ const getEditorCommandLoader = () => | |
| } | ||
|
|
||
| const commands = []; | ||
| const disableContentOnlyForPatternsAndTemplateParts = | ||
| disableContentOnlyForUnsyncedPatterns && | ||
| disableContentOnlyForTemplateParts; | ||
|
|
||
| commands.push( { | ||
| name: 'core/open-shortcut-help', | ||
|
|
@@ -176,6 +191,25 @@ const getEditorCommandLoader = () => | |
| }, | ||
| } ); | ||
|
|
||
| commands.push( { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look into pushing it into the default commands when a pattern is selected
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested adding this to the command suggestions on pattern/template-part selection. The suggestions list is already very long and this just gets lost at the bottom. Kapture.2026-06-24.at.15.03.47.mp4I'm thinking it should be a follow up anyway.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice to make it contextual, but I don't think it's a blocker. If anyone uses it regularly then it appears in 'Recent'.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make a note to follow up with this. |
||
| name: 'core/toggle-pattern-editing', | ||
| label: disableContentOnlyForPatternsAndTemplateParts | ||
| ? __( 'Disable editing all patterns' ) | ||
| : __( 'Enable editing all patterns' ), | ||
| icon: symbol, | ||
| category: 'command', | ||
| callback: ( { close } ) => { | ||
| const disableContentOnly = | ||
| ! disableContentOnlyForPatternsAndTemplateParts; | ||
| stopEditingContentOnlySection(); | ||
| updateEditorSettings( { | ||
|
ramonjd marked this conversation as resolved.
|
||
| disableContentOnlyForUnsyncedPatterns: disableContentOnly, | ||
| disableContentOnlyForTemplateParts: disableContentOnly, | ||
| } ); | ||
| close(); | ||
| }, | ||
| } ); | ||
|
|
||
| if ( allowSwitchEditorMode ) { | ||
| commands.push( { | ||
| name: 'core/toggle-code-editor', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 wonder if it should be checking
isSectionBlockinstead, as that should already encapsulate many of these conditions:gutenberg/packages/block-editor/src/store/private-selectors.js
Lines 547 to 553 in e37c19d
Same applies to the code above on line 55-56.
Would need to make sure this doesn't apply the
symbolto synced patterns and template parts too, though there's already ablockAttributes?.metadata?.patternNamecheck, maybe that's enough.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.
Good point! I did keep a local diff to do exactly that (
isSectionBlockoriginally suggested to me by LLM), but kept the changes narrow to only deal with the toggle.I can do a follow up to this PR to change it out and test for side effects.