Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions packages/e2e-tests/plugins/align-hook/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
( function () {
const registerBlockType = wp.blocks.registerBlockType;
const el = wp.element.createElement;
const { useBlockProps } = wp.blockEditor;

const baseBlock = {
icon: 'cart',
category: 'text',
edit() {
return el(
'div',
{ style: { outline: '1px solid gray', padding: 5 } },
'Test Align Hook'
);
edit: function Edit() {
const blockProps = useBlockProps( {
style: { outline: '1px solid gray', padding: 5 },
} );
return el( 'div', blockProps, 'Test Align Hook' );
},
save() {
return el(
'div',
{ style: { outline: '1px solid gray', padding: 5 } },
'Test Align Hook'
);
const blockProps = useBlockProps.save( {
style: { outline: '1px solid gray', padding: 5 },
} );
return el( 'div', blockProps, 'Test Align Hook' );
},
};

registerBlockType(
'test/test-no-alignment-set',
Object.assign(
{
apiVersion: 3,
title: 'Test No Alignment Set',
},
baseBlock
Expand All @@ -35,6 +35,7 @@
'test/test-align-true',
Object.assign(
{
apiVersion: 3,
title: 'Test Align True',
supports: {
align: true,
Expand All @@ -48,6 +49,7 @@
'test/test-align-array',
Object.assign(
{
apiVersion: 3,
title: 'Test Align Array',
supports: {
align: [ 'left', 'center' ],
Expand All @@ -61,6 +63,7 @@
'test/test-default-align',
Object.assign(
{
apiVersion: 3,
title: 'Test Default Align',
attributes: {
align: {
Expand Down
33 changes: 21 additions & 12 deletions packages/e2e-tests/plugins/block-context/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
( function () {
const { createElement: el, Fragment } = wp.element;
const { createElement: el } = wp.element;
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;

registerBlockType( 'gutenberg/test-context-provider', {
apiVersion: 3,
title: 'Test Context Provider',

icon: 'list-view',
Expand All @@ -17,10 +18,16 @@

category: 'text',

edit( { attributes, setAttributes } ) {
edit: function Edit( { attributes, setAttributes } ) {
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: [ [ 'gutenberg/test-context-consumer', {} ] ],
templateLock: 'all',
templateInsertUpdatesSelection: true,
} );
return el(
Fragment,
null,
'div',
innerBlocksProps,
el( 'input', {
value: attributes.recordId,
onChange( event ) {
Expand All @@ -29,11 +36,7 @@
} );
},
} ),
el( InnerBlocks, {
template: [ [ 'gutenberg/test-context-consumer', {} ] ],
templateLock: 'all',
templateInsertUpdatesSelection: true,
} )
innerBlocksProps.children
);
},

Expand All @@ -43,6 +46,7 @@
} );

registerBlockType( 'gutenberg/test-context-consumer', {
apiVersion: 3,
title: 'Test Context Consumer',

icon: 'list-view',
Expand All @@ -54,8 +58,13 @@

category: 'text',

edit( { context } ) {
return 'The record ID is: ' + context[ 'gutenberg/recordId' ];
edit: function Edit( { context } ) {
const blockProps = useBlockProps();
return el(
'div',
blockProps,
'The record ID is: ' + context[ 'gutenberg/recordId' ]
);
},

save() {
Expand Down
177 changes: 86 additions & 91 deletions packages/e2e-tests/plugins/block-icons/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
( function () {
const registerBlockType = wp.blocks.registerBlockType;
const el = wp.element.createElement;
const InnerBlocks = wp.blockEditor.InnerBlocks;
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
const circle = el( 'circle', {
cx: 10,
cy: 10,
Expand All @@ -17,29 +17,28 @@
);

registerBlockType( 'test/test-single-svg-icon', {
apiVersion: 3,
title: 'TestSimpleSvgIcon',
icon: svg,
category: 'text',

edit() {
return el(
'div',
{
className: 'test-single-svg-icon',
style: { outline: '1px solid gray', padding: 5 },
},
el( InnerBlocks, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestSimpleSvgIcon',
},
],
edit: function Edit() {
const blockProps = useBlockProps( {
className: 'test-single-svg-icon',
style: { outline: '1px solid gray', padding: 5 },
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestSimpleSvgIcon',
},
],
} )
);
],
} );
return el( 'div', innerBlocksProps );
},

save() {
Expand All @@ -55,29 +54,28 @@
} );

registerBlockType( 'test/test-dash-icon', {
apiVersion: 3,
title: 'TestSimpleDashIcon',
icon: 'cart',
category: 'text',

edit() {
return el(
'div',
{
className: 'test-dash-icon',
style: { outline: '1px solid gray', padding: 5 },
},
el( InnerBlocks, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestDashIcon',
},
],
edit: function Edit() {
const blockProps = useBlockProps( {
className: 'test-dash-icon',
style: { outline: '1px solid gray', padding: 5 },
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestDashIcon',
},
],
} )
);
],
} );
return el( 'div', innerBlocksProps );
},

save() {
Expand All @@ -93,31 +91,30 @@
} );

registerBlockType( 'test/test-function-icon', {
apiVersion: 3,
title: 'TestFunctionIcon',
icon() {
return svg;
},
category: 'text',

edit() {
return el(
'div',
{
className: 'test-function-icon',
style: { outline: '1px solid gray', padding: 5 },
},
el( InnerBlocks, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestFunctionIcon',
},
],
edit: function Edit() {
const blockProps = useBlockProps( {
className: 'test-function-icon',
style: { outline: '1px solid gray', padding: 5 },
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestFunctionIcon',
},
],
} )
);
],
} );
return el( 'div', innerBlocksProps );
},

save() {
Expand All @@ -133,6 +130,7 @@
} );

registerBlockType( 'test/test-dash-icon-colors', {
apiVersion: 3,
title: 'TestDashIconColors',
icon: {
background: '#010000',
Expand All @@ -141,25 +139,23 @@
},
category: 'text',

edit() {
return el(
'div',
{
className: 'test-dash-icon-colors',
style: { outline: '1px solid gray', padding: 5 },
},
el( InnerBlocks, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestIconColors',
},
],
edit: function Edit() {
const blockProps = useBlockProps( {
className: 'test-dash-icon-colors',
style: { outline: '1px solid gray', padding: 5 },
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestIconColors',
},
],
} )
);
],
} );
return el( 'div', innerBlocksProps );
},

save() {
Expand All @@ -175,32 +171,31 @@
} );

registerBlockType( 'test/test-svg-icon-background', {
apiVersion: 3,
title: 'TestSvgIconBackground',
icon: {
background: '#010000',
src: svg,
},
category: 'text',

edit() {
return el(
'div',
{
className: 'test-svg-icon-background',
style: { outline: '1px solid gray', padding: 5 },
},
el( InnerBlocks, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestIconColors',
},
],
edit: function Edit() {
const blockProps = useBlockProps( {
className: 'test-svg-icon-background',
style: { outline: '1px solid gray', padding: 5 },
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/paragraph', 'core/image' ],
template: [
[
'core/paragraph',
{
content: 'TestIconColors',
},
],
} )
);
],
} );
return el( 'div', innerBlocksProps );
},

save() {
Expand Down
Loading
Loading