/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/e2e-tests/plugins/hooks-api/index.js
54 строки
1 KB
Jon Surrell
Autoformat e2e-tests package (#62572)
17 июн 2024, 10:17
Не верифицирован
17 июн 2024, 10:17
9c1b097
Код
Авторство
О чём код?
( function () { const el = wp.element.createElement; const Fragment = wp.element.Fragment; const Button = wp.components.Button; const PanelBody = wp.components.PanelBody; const InspectorControls = wp.blockEditor.InspectorControls; const addFilter = wp.hooks.addFilter; const createBlock = wp.blocks.createBlock; const __ = wp.i18n.__; function ResetBlockButton( props ) { return el( PanelBody, {}, el( Button, { className: 'e2e-reset-block-button', variant: 'secondary', onClick() { const emptyBlock = createBlock( props.name ); props.onReplace( emptyBlock ); }, }, __( 'Reset Block' ) ) ); } function addResetBlockButton( BlockEdit ) { return function ( props ) { return el( Fragment, {}, el( InspectorControls, {}, el( ResetBlockButton, { name: props.name, onReplace: props.onReplace, } ) ), el( BlockEdit, props ) ); }; } addFilter( 'editor.BlockEdit', 'e2e/hooks-api/add-reset-block-button', addResetBlockButton, 100 ); } )();