import type { Meta, StoryObj } from "@storybook/react"; import { fn } from "@storybook/test"; import { EditorPanel } from "./editor-panel"; const sampleContent = `--- title: "Hello World" description: "A sample MDX document" --- # Welcome to the Editor This is a sample MDX document that you can edit. ## Features - **Real-time preview** - See your changes instantly - **Monaco Editor** - VS Code-like editing experience - **Keyboard shortcuts** - ⌘S to save, ⌘I to toggle ## Code Example \`\`\`tsx function Button({ children }: { children: React.ReactNode }) { return ( ) } \`\`\` ## Try It Out Click the pencil button or press **⌘I** to open the editor. > "The best way to learn is by doing." `; const saveAction = fn(); const mockSave = async (content: string) => { saveAction(content.slice(0, 100) + "..."); await new Promise((resolve) => setTimeout(resolve, 500)); }; const meta: Meta = { title: "Widgets/Editor/EditorPanel", component: EditorPanel, parameters: { layout: "fullscreen", }, tags: ["autodocs"], argTypes: { path: { control: "text" }, initialContent: { control: "text" }, shortcut: { control: "text" }, }, decorators: [ (Story) => (

EditorPanel Story

Click the pencil icon in the corner or press{" "} ⌘I {" "} to open the editor panel.

), ], }; export default meta; type Story = StoryObj; /** * Default configuration with sample MDX content. * Click the pencil icon in the bottom-right corner to open. */ export const Default: Story = { args: { path: "/docs/sample", initialContent: sampleContent, onSave: mockSave, }, }; /** * Custom keyboard shortcut to toggle the editor. */ export const CustomShortcut: Story = { args: { path: "/docs/sample", initialContent: sampleContent, onSave: mockSave, shortcut: "meta+e", }, };