/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/embed/deprecated.js
62 строки
2 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import clsx from 'clsx'; import { RichText, useBlockProps } from '@wordpress/block-editor'; import metadata from './block.json'; const { attributes: blockAttributes } = metadata; // In #41140 support was added to global styles for caption elements which added a `wp-element-caption` classname // to the embed figcaption element. const v2 = { attributes: blockAttributes, save( { attributes } ) { const { url, caption, type, providerNameSlug } = attributes; if ( ! url ) { return null; } const className = clsx( 'wp-block-embed', { [ `is-type-${ type }` ]: type, [ `is-provider-${ providerNameSlug }` ]: providerNameSlug, [ `wp-block-embed-${ providerNameSlug }` ]: providerNameSlug, } ); return ( <figure { ...useBlockProps.save( { className } ) }> <div className="wp-block-embed__wrapper"> { `\n${ url }\n` /* URL needs to be on its own line. */ } </div> { ! RichText.isEmpty( caption ) && ( <RichText.Content tagName="figcaption" value={ caption } /> ) } </figure> ); }, }; const v1 = { attributes: blockAttributes, save( { attributes: { url, caption, type, providerNameSlug } } ) { if ( ! url ) { return null; } const embedClassName = clsx( 'wp-block-embed', { [ `is-type-${ type }` ]: type, [ `is-provider-${ providerNameSlug }` ]: providerNameSlug, } ); return ( <figure className={ embedClassName }> { `\n${ url }\n` /* URL needs to be on its own line. */ } { ! RichText.isEmpty( caption ) && ( <RichText.Content tagName="figcaption" value={ caption } /> ) } </figure> ); }, }; const deprecated = [ v2, v1 ]; export default deprecated;