import { useState } from 'react' import type { Meta, StoryObj } from '@storybook/react-vite' import { EditorContent, useEditor } from '@tiptap/react' import StarterKit from '@tiptap/starter-kit' import { AttachmentCard } from './AttachmentCard' import { Card } from './Card' import { PastedImages } from './PastedImages' import { richTextClassName } from './RichText' /** * Paste a screenshot into the box: it arrives as a named file under the text, * the way the app's file picker would hand it. Copy some text and paste it: * the text wins. */ const meta = { title: 'Primitives/PastedImages', parameters: { layout: 'padded' }, } satisfies Meta export default meta type Story = StoryObj function Box() { const [files, setFiles] = useState([]) const editor = useEditor({ extensions: [ StarterKit, PastedImages.configure({ onImages: (pasted) => { setFiles((held) => [...held, ...pasted]) return true }, }), ], content: '

Paste a screenshot here.

', editorProps: { attributes: { class: richTextClassName('default', 'outline-none'), 'aria-label': 'Text' } }, }) return ( {files.length > 0 && (
{files.map((file, i) => ( ))}
)}
) } /** A box that attaches what is pasted. Try it with a screenshot on the clipboard. */ export const InAnEditor: Story = { render: () => }