/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/paragraph/transforms.js
43 строки
932 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { createBlock, getBlockAttributes } from '@wordpress/blocks'; import metadata from './block.json'; const { name } = metadata; const transforms = { from: [ { type: 'raw', // Paragraph is a fallback and should be matched last. priority: 20, selector: 'p', schema: ( { phrasingContentSchema, isPaste } ) => ( { p: { children: phrasingContentSchema, attributes: isPaste ? [] : [ 'style', 'id' ], }, } ), transform( node ) { const attributes = getBlockAttributes( name, node.outerHTML ); const { textAlign } = node.style || {}; if ( textAlign === 'left' || textAlign === 'center' || textAlign === 'right' ) { attributes.style = { ...attributes.style, typography: { ...attributes.style?.typography, textAlign, }, }; } return createBlock( name, attributes ); }, }, ], }; export default transforms;