Skip to content

Commit

Permalink
Shortcode Block: fix layout margin override
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed May 12, 2024
1 parent f73d44e commit 8180df0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
30 changes: 13 additions & 17 deletions packages/block-library/src/shortcode/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@
import { __ } from '@wordpress/i18n';
import { PlainText, useBlockProps } from '@wordpress/block-editor';
import { useInstanceId } from '@wordpress/compose';
import { Icon, shortcode } from '@wordpress/icons';
import { Placeholder } from '@wordpress/components';
import { shortcode } from '@wordpress/icons';

export default function ShortcodeEdit( { attributes, setAttributes } ) {
const instanceId = useInstanceId( ShortcodeEdit );
const inputId = `blocks-shortcode-input-${ instanceId }`;

return (
<div { ...useBlockProps( { className: 'components-placeholder' } ) }>
<label
htmlFor={ inputId }
className="components-placeholder__label"
>
<Icon icon={ shortcode } />
{ __( 'Shortcode' ) }
</label>
<PlainText
className="blocks-shortcode__textarea"
id={ inputId }
value={ attributes.text }
aria-label={ __( 'Shortcode text' ) }
placeholder={ __( 'Write shortcode here…' ) }
onChange={ ( text ) => setAttributes( { text } ) }
/>
<div { ...useBlockProps() }>
<Placeholder icon={ shortcode } label={ __( 'Shortcode' ) }>
<PlainText
className="blocks-shortcode__textarea"
id={ inputId }
value={ attributes.text }
aria-label={ __( 'Shortcode text' ) }
placeholder={ __( 'Write shortcode here…' ) }
onChange={ ( text ) => setAttributes( { text } ) }
/>
</Placeholder>
</div>
);
}
6 changes: 0 additions & 6 deletions packages/block-library/src/shortcode/editor.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[data-type="core/shortcode"] {
&.components-placeholder {
min-height: 0;
}
}

// The editing view for the Shortcode block is equivalent to block UI.
// Therefore we increase specificity to avoid theme styles bleeding in.
.blocks-shortcode__textarea {
Expand Down

0 comments on commit 8180df0

Please sign in to comment.