Skip to content
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

Fix: Embed blocks: adding captions via toolbar - #64385 #64394

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { embedContentIcon } from './icons';
import EmbedLoading from './embed-loading';
import EmbedPlaceholder from './embed-placeholder';
import EmbedPreview from './embed-preview';
import { Caption } from '../utils/caption';

/**
* External dependencies
Expand Down Expand Up @@ -277,6 +278,14 @@ const EmbedEdit = ( props ) => {
label={ label }
insertBlocksAfter={ insertBlocksAfter }
/>
<Caption
hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
attributes={ attributes }
setAttributes={ setAttributes }
isSelected={ isSelected }
insertBlocksAfter={ insertBlocksAfter }
label={ __( 'Add Caption' ) }
showToolbarButton={ isSelected }
/>
</View>
</>
);
Expand Down
40 changes: 3 additions & 37 deletions packages/block-library/src/embed/embed-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ import clsx from 'clsx';
*/
import { __, sprintf } from '@wordpress/i18n';
import { Placeholder, SandBox } from '@wordpress/components';
import {
RichText,
BlockIcon,
__experimentalGetElementClassName,
} from '@wordpress/block-editor';
import { BlockIcon } from '@wordpress/block-editor';
import { Component } from '@wordpress/element';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { getAuthority } from '@wordpress/url';

/**
Expand Down Expand Up @@ -57,19 +52,8 @@ class EmbedPreview extends Component {
}

render() {
const {
preview,
previewable,
url,
type,
caption,
onCaptionChange,
isSelected,
className,
icon,
label,
insertBlocksAfter,
} = this.props;
const { preview, previewable, url, type, className, icon, label } =
this.props;
const { scripts } = preview;
const { interactive } = this.state;

Expand Down Expand Up @@ -139,24 +123,6 @@ class EmbedPreview extends Component {
</p>
</Placeholder>
) }
{ ( ! RichText.isEmpty( caption ) || isSelected ) && (
<RichText
identifier="caption"
tagName="figcaption"
className={ __experimentalGetElementClassName(
'caption'
) }
placeholder={ __( 'Add caption' ) }
value={ caption }
onChange={ onCaptionChange }
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
</figure>
);
}
Expand Down
Loading