import type { Meta, StoryObj } from '@storybook/react'; import { useState } from 'react'; import { PlateEditor } from '@plone/plate/components/editor'; import plateBlockEditorConfig from '@plone/plate/config/presets/block-editor'; import { DetachedTextBlockEditor } from '@plone/volto-slate/blocks/Text/DetachedTextBlockEditor'; import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook'; import config from '@plone/volto/registry'; const meta = { title: 'Slate & Plate', component: DetachedTextBlockEditor, args: { editorConfig: plateBlockEditorConfig, onChange: () => {}, value: [ { type: 'paragraph', children: [{ text: 'A line of text in a paragraph.' }], }, ], }, } satisfies Meta; export default meta; type Story = StoryObj; const SlateAndPlateStory = ( props: React.ComponentProps, ) => { const [value, setValue] = useState(props.value); const [slateValue, setSlateValue] = useState(); return (
setValue(options.value)} />
setSlateValue(data)} slateSettings={config.settings.slate} selected={true} />

Slate Value

{JSON.stringify(slateValue?.value, null, 2)}

Plate Value

{JSON.stringify(value, null, 2)}
); }; export const MultiEditorPlate: Story = { render: (args: any) => , args: { value: [ { children: [ { text: '', }, { children: [ { text: 'Plone community website', }, ], type: 'link', data: { url: 'https://plone.org' }, }, { text: ' ', }, ], type: 'p', }, ], }, };