:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import type { Meta, StoryObj } from '@storybook/react'
import { Placeholder } from '@tiptap/extension-placeholder'
import { useState } from 'react'
import { TEXT_CARD_MARKDOWN_EXTENSIONS, textCardConverter } from 'lib/components/Cards/TextCard/textCardMarkdown'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { RichMarkdownEditor, type RichMarkdownEditorProps } from './RichMarkdownEditor'
/** Same stack as dashboard text cards: markdown round-trip + placeholder. */
const TEXT_CARD_LIKE_EXTENSIONS = [
...TEXT_CARD_MARKDOWN_EXTENSIONS,
Placeholder.configure({ placeholder: 'Write here. Use the toolbar for formatting…' }),
]
const storyDefaults = {
extensions: TEXT_CARD_LIKE_EXTENSIONS,
markdownToDoc: textCardConverter.markdownToDoc,
docToMarkdown: textCardConverter.docToMarkdown,
renderPreview: (markdown: string): JSX.Element => <LemonMarkdown>{markdown}</LemonMarkdown>,
dataAttr: 'story-rich-markdown-editor',
}
type Story = StoryObj<RichMarkdownEditorProps>
const meta: Meta<RichMarkdownEditorProps> = {
title: 'Components/Markdown editor/Rich',
component: RichMarkdownEditor,
tags: ['autodocs'],
render: (props) => {
const [value, setValue] = useState(props.value ?? '')
return <RichMarkdownEditor {...storyDefaults} {...props} value={value} onChange={setValue} />
},
}
export default meta
export const WithMarkdown: Story = {
args: {
value: `## Week notes
**Bold** and *italic* and ~~strikethrough~~ and a [link](https://posthog.com).
- Bullet one
- Bullet two
> A blockquote worth keeping.`,
},
}