/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/preformatted/transforms.js
50 строк
1014 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { createBlock } from '@wordpress/blocks'; const transforms = { from: [ { type: 'block', blocks: [ 'core/code', 'core/paragraph', 'core/verse' ], transform: ( { content, anchor } ) => createBlock( 'core/preformatted', { content, anchor, } ), }, { type: 'raw', isMatch: ( node ) => node.nodeName === 'PRE' && ! ( node.children.length === 1 && node.firstChild.nodeName === 'CODE' ), schema: ( { phrasingContentSchema } ) => ( { pre: { children: phrasingContentSchema, }, } ), }, ], to: [ { type: 'block', blocks: [ 'core/paragraph' ], transform: ( attributes ) => createBlock( 'core/paragraph', attributes ), }, { type: 'block', blocks: [ 'core/code' ], transform: ( attributes ) => createBlock( 'core/code', attributes ), }, { type: 'block', blocks: [ 'core/verse' ], transform: ( attributes ) => createBlock( 'core/verse', attributes ), }, ], }; export default transforms;