/**
* Internal dependencies
*/
import IsolatedBlockEditor, { DocumentSection } from '../src/index';
/**
* WordPress dependencies
*/
import { useMemo, useState } from '@wordpress/element';
export default {
title: 'Isolated Block Editor',
component: IsolatedBlockEditor,
};
export const Default = () => {
return ;
};
export const Controlled = ( { onInput, onChange, onUndo, onRedo, onSelection } ) => {
console.log('useState about to be called just fine');
const [ blocks, setBlocks ] = useState( [] );
console.log('useState called just fine');
const handleOnInput = ( newBlocks ) => {
onInput( newBlocks );
setBlocks( newBlocks );
};
const handleOnChange = ( newBlocks ) => {
onChange( newBlocks );
setBlocks( newBlocks );
};
const undoManager = useMemo( () => {
return {
undo: onUndo,
redo: onRedo,
undoStack: [ {} ],
redoStack: [ {} ],
};
}, [ onUndo, onRedo ] );
return (
);
};
Controlled.args = {
inserter: true,
inspector: true,
navigation: true,
documentInspector: 'Document',
};
Controlled.argTypes = {
onInput: { action: 'input' },
onChange: { action: 'change' },
onUndo: { action: 'undo' },
onRedo: { action: 'redo' },
onSelection: { action: 'selection' },
};
export const ToolbarSettings = ( toolbarSettings ) => {
return (
Arbitrary content can go here.
);
};
ToolbarSettings.args = {
inserter: true,
inspector: true,
navigation: true,
documentInspector: 'Document',
};
export const MoreMenu = ( moreMenuSettings ) => {
return ;
};
MoreMenu.args = {
editor: true,
fullscreen: true,
preview: true,
topToolbar: true,
};
export const MultipleEditors = ( { count } ) => {
const arr = Array( count ).fill( null );
return (
<>
{ arr.map( ( _, idx ) => (
) ) }
>
);
};
MultipleEditors.args = { count: 2 };