-
Notifications
You must be signed in to change notification settings - Fork 4.8k
POC: Filter toolbar items by prop in contentOnly #71469
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
9d99bdd
eec43dc
c16e98b
be7e1b2
ee6b550
e79ee55
2c48aee
b15e32e
e28f37b
a85db5e
49024a8
4232366
df2028f
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 |
|---|---|---|
|
|
@@ -714,8 +714,7 @@ export default function Image( { | |
| const mediaReplaceFlow = isSingleSelected && | ||
| ! isEditingImage && | ||
| ! lockUrlControls && ( | ||
| // For contentOnly mode, put this button in its own area so it has borders around it. | ||
| <BlockControls group={ isContentOnlyMode ? 'inline' : 'other' }> | ||
| <BlockControls group="other"> | ||
| <MediaReplaceFlow | ||
| mediaId={ id } | ||
| mediaURL={ url } | ||
|
|
@@ -726,6 +725,7 @@ export default function Image( { | |
| onError={ onUploadError } | ||
| name={ ! url ? __( 'Add image' ) : __( 'Replace' ) } | ||
| onReset={ () => onSelectImage( undefined ) } | ||
| category="content" | ||
|
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. Obviously we can make this a private API for now via
Contributor
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. Yeah, I'm not worried about that specific quite yet. I want to see about the overall approach first and then get into the details. |
||
| /> | ||
| </BlockControls> | ||
| ); | ||
|
|
@@ -777,21 +777,18 @@ export default function Image( { | |
| </ToolbarGroup> | ||
| </BlockControls> | ||
| ) } | ||
| { isContentOnlyMode && ( | ||
| // Add some extra controls for content attributes when content only mode is active. | ||
| // With content only mode active, the inspector is hidden, so users need another way | ||
| // to edit these attributes. | ||
| <BlockControls group="block"> | ||
| <ContentOnlyControls | ||
| attributes={ attributes } | ||
| setAttributes={ setAttributes } | ||
| lockAltControls={ lockAltControls } | ||
| lockAltControlsMessage={ lockAltControlsMessage } | ||
| lockTitleControls={ lockTitleControls } | ||
| lockTitleControlsMessage={ lockTitleControlsMessage } | ||
| /> | ||
| </BlockControls> | ||
| ) } | ||
| { /* Content-only controls - automatically filtered by category="content" */ } | ||
| <BlockControls group="block"> | ||
| <ContentOnlyControls | ||
| category="content" | ||
| attributes={ attributes } | ||
| setAttributes={ setAttributes } | ||
| lockAltControls={ lockAltControls } | ||
| lockAltControlsMessage={ lockAltControlsMessage } | ||
| lockTitleControls={ lockTitleControls } | ||
| lockTitleControlsMessage={ lockTitleControlsMessage } | ||
| /> | ||
| </BlockControls> | ||
| <InspectorControls> | ||
| <ToolsPanel | ||
| label={ __( 'Settings' ) } | ||
|
|
||
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.
Note the approach in #71058 for restricting formatting controls. If your approach is better and we can have one unified mechanism then we'd need to revert that.
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 think they work alongside each other. This
category="content"says "we want this component to show when in contentOnly mode" and yours is filtering which format controls should be shown within it.