/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/annotations/src/block/index.ts
41 строка
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import type { ComponentType } from 'react'; import { addFilter } from '@wordpress/hooks'; import { withSelect } from '@wordpress/data'; import { store } from '../store'; import type { Annotation } from '../types'; interface BlockListBlockProps { clientId: string; className?: string; [ key: string ]: unknown; } /** * Adds annotation className to the block-list-block component. * * @param OriginalComponent The original BlockListBlock component. * @return The enhanced component. */ const addAnnotationClassName = ( OriginalComponent: ComponentType< any > ) => { return withSelect( ( select, ownProps ) => { const { clientId, className } = ownProps as BlockListBlockProps; const annotations: Annotation[] = select( store ).__experimentalGetAnnotationsForBlock( clientId ); return { className: annotations .map( ( annotation ) => { return 'is-annotated-by-' + annotation.source; } ) .concat( className || '' ) .filter( Boolean ) .join( ' ' ), }; } )( OriginalComponent ); }; addFilter( 'editor.BlockListBlock', 'core/annotations', addAnnotationClassName );