import type { Meta, StoryObj } from '@storybook/react-vite' import { EditorContent, useEditor } from '@tiptap/react' import StarterKit from '@tiptap/starter-kit' import { Card } from './Card' import { CodeBlockColours } from './CodeBlockColours' import { richTextClassName } from './RichText' /** * Type in the code block: each word takes its colour as you write, the same * colours RichText reads it in. Change the theme to see each set. */ const meta = { title: 'Primitives/CodeBlockColours', parameters: { layout: 'padded' }, } satisfies Meta export default meta type Story = StoryObj function Box() { const editor = useEditor({ extensions: [StarterKit.configure({ codeBlock: false }), CodeBlockColours], content: [ '
A code block in a language takes its colours:
', '// Count the items that are done\nexport function countDone(items: Item[]): number {\n const done = items.filter((item) => item.state === \'done\')\n return done.length + 0\n}',
].join(''),
editorProps: { attributes: { class: richTextClassName('default', 'outline-none'), 'aria-label': 'Text' } },
})
return (