diff --git a/packages/block-library/src/quote/v2/edit.js b/packages/block-library/src/quote/v2/edit.js
index b4153b8d6dd1fe..44be35f18de00b 100644
--- a/packages/block-library/src/quote/v2/edit.js
+++ b/packages/block-library/src/quote/v2/edit.js
@@ -3,24 +3,21 @@
*/
import { __ } from '@wordpress/i18n';
import {
- BlockControls,
RichText,
useBlockProps,
useInnerBlocksProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
-import {
- BlockQuotation,
- ToolbarGroup,
- ToolbarButton,
-} from '@wordpress/components';
+import { BlockQuotation } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { createBlock } from '@wordpress/blocks';
+import { Platform } from '@wordpress/element';
+const isWebPlatform = Platform.OS === 'web';
const TEMPLATE = [ [ 'core/paragraph', {} ] ];
export default function QuoteEdit( {
- attributes: { attribution },
+ attributes: { citation },
setAttributes,
isSelected,
insertBlocksAfter,
@@ -29,64 +26,42 @@ export default function QuoteEdit( {
const isAncestorOfSelectedBlock = useSelect( ( select ) =>
select( blockEditorStore ).hasSelectedInnerBlock( clientId )
);
- const hasAttribution = attribution !== null;
- const isEditingQuote = isSelected || isAncestorOfSelectedBlock;
- const showAttribution =
- ( isEditingQuote && hasAttribution ) ||
- ! RichText.isEmpty( attribution );
-
+ const hasSelection = isSelected || isAncestorOfSelectedBlock;
const blockProps = useBlockProps();
- const innerBlocksProps = useInnerBlocksProps(
- showAttribution ? blockProps : {},
- {
- template: TEMPLATE,
- templateInsertUpdatesSelection: true,
- }
- );
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
+ template: TEMPLATE,
+ templateInsertUpdatesSelection: true,
+ } );
return (
<>
-
-
-
); } diff --git a/packages/block-library/src/quote/v2/transforms.js b/packages/block-library/src/quote/v2/transforms.js index e23c38bd7be11e..90d1b3273b8df1 100644 --- a/packages/block-library/src/quote/v2/transforms.js +++ b/packages/block-library/src/quote/v2/transforms.js @@ -17,7 +17,7 @@ const transforms = { return createBlock( 'core/quote', { - attribution: citation, + citation, anchor, fontSize, style, @@ -54,31 +54,23 @@ const transforms = { }, { type: 'raw', - schema: ( { phrasingContentSchema } ) => ( { - figure: { - require: [ 'blockquote' ], - children: { - blockquote: { - children: '*', - }, - figcaption: { - children: phrasingContentSchema, - }, - }, + schema: () => ( { + blockquote: { + children: '*', }, } ), - isMatch: ( node ) => - node.nodeName === 'FIGURE' && - !! node.querySelector( 'blockquote' ), + selector: 'blockquote', transform: ( node ) => { return createBlock( 'core/quote', - { - attribution: node.querySelector( 'figcaption' ) - ?.innerHTML, - }, + // Don't try to parse any `cite` out of this content. + // * There may be more than one cite. + // * There may be more attribution text than just the cite. + // * If the cite is nested in the quoted text, it's wrong to + // remove it. + {}, rawHandler( { - HTML: node.querySelector( 'blockquote' ).innerHTML, + HTML: node.innerHTML, mode: 'BLOCKS', } ) ); @@ -115,12 +107,12 @@ const transforms = { ); }, transform: ( - { attribution, anchor, fontSize, style }, + { citation, anchor, fontSize, style }, innerBlocks ) => { return createBlock( 'core/pullquote', { value: serialize( innerBlocks ), - citation: attribution, + citation, anchor, fontSize, style, @@ -130,15 +122,15 @@ const transforms = { { type: 'block', blocks: [ 'core/group' ], - transform: ( { attribution, anchor }, innerBlocks ) => + transform: ( { citation, anchor }, innerBlocks ) => createBlock( 'core/group', { anchor }, - attribution + citation ? [ ...innerBlocks, createBlock( 'core/paragraph', { - content: attribution, + content: citation, } ), ] : innerBlocks @@ -147,12 +139,12 @@ const transforms = { { type: 'block', blocks: [ '*' ], - transform: ( { attribution }, innerBlocks ) => - attribution + transform: ( { citation }, innerBlocks ) => + citation ? [ ...innerBlocks, createBlock( 'core/paragraph', { - content: attribution, + content: citation, } ), ] : innerBlocks,+ { ! RichText.isEmpty( citation ) && ( + + ) }