/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/separator/transforms.js
48 строк
881 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { createBlock, getBlockVariations, getDefaultBlockName, } from '@wordpress/blocks'; const transforms = { from: [ { type: 'input', regExp: /^-{3,}$/, transform: () => { // Check for default variation to apply default variation attributes. const defaultVariation = getBlockVariations( 'core/separator' )?.find( ( variation ) => variation.isDefault ); return [ createBlock( 'core/separator', defaultVariation?.attributes ?? {} ), createBlock( getDefaultBlockName() ), ]; }, }, { type: 'raw', selector: 'hr', schema: { hr: {}, }, }, ], to: [ { type: 'block', blocks: [ 'core/spacer' ], // Transform to Spacer. transform: ( { anchor } ) => { return createBlock( 'core/spacer', { anchor: anchor || undefined, } ); }, }, ], }; export default transforms;