/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/html/transforms.js
25 строк
712 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { createBlock, parse } from '@wordpress/blocks'; import { create } from '@wordpress/rich-text'; const transforms = { from: [ { type: 'block', blocks: [ 'core/code' ], transform: ( { content: html } ) => { // The code block may output HTML formatting, so convert it // to plain text, then parse it so any block delimiters become // editable inner blocks at their positions within the static // HTML, rather than inert comment text. const text = create( { html } ).text; const [ block ] = parse( `<!-- wp:html -->\n${ text }\n<!-- /wp:html -->` ); return block ?? createBlock( 'core/html', {}, [], [ text ] ); }, }, ], }; export default transforms;