From fcfabd9dc718219e294981690d3fb7b028c7c047 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:39:58 +0530 Subject: [PATCH] Update block-canvas component with BlockToolbar --- .../block-canvas/stories/index.story.js | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/packages/block-editor/src/components/block-canvas/stories/index.story.js b/packages/block-editor/src/components/block-canvas/stories/index.story.js index 276999f7565606..1722ee47674b77 100644 --- a/packages/block-editor/src/components/block-canvas/stories/index.story.js +++ b/packages/block-editor/src/components/block-canvas/stories/index.story.js @@ -1,14 +1,13 @@ /** * WordPress dependencies */ -import { useState } from '@wordpress/element'; +import { useState, useEffect } from '@wordpress/element'; import { registerCoreBlocks } from '@wordpress/block-library'; -/** - * Internal dependencies - */ -import { BlockCanvas, BlockEditorProvider } from '../..'; - -registerCoreBlocks(); +import { + BlockCanvas, + BlockEditorProvider, + BlockToolbar, +} from '@wordpress/block-editor'; const meta = { title: 'BlockEditor/BlockCanvas', @@ -22,6 +21,26 @@ const meta = { }, }, }, + decorators: [ + ( Story ) => { + const [ blocks, updateBlocks ] = useState( [] ); + + useEffect( () => { + registerCoreBlocks(); + }, [] ); + + return ( + updateBlocks( newBlocks ) } + onChange={ ( newBlocks ) => updateBlocks( newBlocks ) } + > + + + + ); + }, + ], argTypes: { children: { control: false, @@ -43,10 +62,7 @@ const meta = { control: 'object', description: 'The styles to apply to the canvas.', table: { - type: { - summary: - '{ css?: string; assets?: string; isGlobalStyles?: boolean; __unstableType: string; }[]', - }, + type: { summary: 'Array' }, }, }, }, @@ -55,17 +71,5 @@ const meta = { export default meta; export const Default = { - render: function Template( args ) { - const [ blocks, updateBlocks ] = useState( [] ); - - return ( - updateBlocks( newBlocks ) } - onChange={ ( newBlocks ) => updateBlocks( newBlocks ) } - > - - - ); - }, + render: ( args ) => , };