Skip to content

Commit

Permalink
image
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 9, 2020
1 parent 912378b commit 974e776
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
12 changes: 8 additions & 4 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
MediaPlaceholder,
MediaReplaceFlow,
RichText,
__experimentalBlock as Block,
__experimentalUseBlock as useBlock,
__experimentalImageSizeControl as ImageSizeControl,
__experimentalImageURLInputUI as ImageURLInputUI,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -120,6 +120,7 @@ export function ImageEdit( {
onReplace,
} ) {
const ref = useRef();
const blockProps = useBlock( ref );
const { image, maxWidth, isRTL, imageSizes, mediaUpload } = useSelect(
( select ) => {
const { getMedia } = select( 'core' );
Expand Down Expand Up @@ -408,7 +409,7 @@ export function ImageEdit( {
return (
<>
{ controls }
<Block.div>{ mediaPlaceholder }</Block.div>
<figure { ...blockProps }>{ mediaPlaceholder }</figure>
</>
);
}
Expand Down Expand Up @@ -594,7 +595,10 @@ export function ImageEdit( {
return (
<>
{ controls }
<Block.figure ref={ ref } className={ classes }>
<figure
{ ...blockProps }
className={ classnames( blockProps.className, classes ) }
>
{ img }
{ ( ! RichText.isEmpty( caption ) || isSelected ) && (
<RichText
Expand All @@ -613,7 +617,7 @@ export function ImageEdit( {
/>
) }
{ mediaPlaceholder }
</Block.figure>
</figure>
</>
);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RichText,
BlockControls,
RichTextShortcut,
__experimentalBlock as Block,
__experimentalUseBlock as useBlock,
} from '@wordpress/block-editor';
import { ToolbarGroup } from '@wordpress/components';
import {
Expand All @@ -30,6 +30,7 @@ import {
formatOutdentRTL,
} from '@wordpress/icons';
import { useSelect } from '@wordpress/data';
import { useRef } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -44,6 +45,8 @@ export default function ListEdit( {
onReplace,
isSelected,
} ) {
const ref = useRef();
const blockProps = useBlock( ref );
const { ordered, values, type, reversed, start } = attributes;
const tagName = ordered ? 'ol' : 'ul';

Expand Down Expand Up @@ -160,7 +163,7 @@ export default function ListEdit( {
identifier="values"
multiline="li"
__unstableMultilineRootTag={ tagName }
tagName={ Block[ tagName ] }
tagName={ tagName }
onChange={ ( nextValues ) =>
setAttributes( { values: nextValues } )
}
Expand All @@ -178,6 +181,8 @@ export default function ListEdit( {
start={ start }
reversed={ reversed }
type={ type }
ref={ ref }
{ ...blockProps }
>
{ controls }
</RichText>
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/quote/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"align": {
"type": "string"
}
},
"supports": {
"lightBlockWrapper": true
}
}
8 changes: 7 additions & 1 deletion packages/block-library/src/quote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
AlignmentToolbar,
BlockControls,
RichText,
__experimentalUseBlock as useBlock,
} from '@wordpress/block-editor';
import { BlockQuotation } from '@wordpress/components';
import { createBlock } from '@wordpress/blocks';
import { useRef } from '@wordpress/element';

export default function QuoteEdit( {
attributes,
Expand All @@ -24,6 +26,8 @@ export default function QuoteEdit( {
className,
insertBlocksAfter,
} ) {
const ref = useRef();
const blockProps = useBlock( ref );
const { align, value, citation } = attributes;

return (
Expand All @@ -37,7 +41,9 @@ export default function QuoteEdit( {
/>
</BlockControls>
<BlockQuotation
className={ classnames( className, {
ref={ ref }
{ ...blockProps }
className={ classnames( blockProps.className, className, {
[ `has-text-align-${ align }` ]: align,
} ) }
>
Expand Down

0 comments on commit 974e776

Please sign in to comment.