import { playgroundParameters } from "@charcuterie/storybook-config/story-parameters" import type { Meta, StoryObj } from "@storybook/react" import { useState } from "react" import { Button } from "../Button/Button.tsx" import { ContainerBoard, StoryCell, StoryGrid, } from "../board.storyHelpers.tsx" import { Field } from "../Field/Field.tsx" import { HtmlEditor } from "./HtmlEditor.tsx" import { HtmlView } from "./HtmlView.tsx" import { HOSTILE_HTML, HTML_DOCUMENT, ORIGINAL_HTML, } from "./htmlDocument.storyHelpers.ts" const meta = { title: "Components/Controls/HtmlEditor", component: HtmlEditor, parameters: { layout: "padded" }, args: { defaultValue: HTML_DOCUMENT, label: "Notes", isDisabled: false, isReadOnly: false, }, argTypes: { icons: { control: false } }, } satisfies Meta export default meta type Story = StoryObj export const Playground: Story = { parameters: playgroundParameters, } export const AllVariants: Story = { render: () => ( ), } export const AllStates: Story = { render: () => ( ), } export const Responsive: Story = { render: () => ( {(width) => ( )} ), } export const Interactive: Story = { render: () => { const [value, setValue] = useState(ORIGINAL_HTML) const [defaultValue, setDefaultValue] = useState(ORIGINAL_HTML) const [changes, setChanges] = useState(0) const [submitted, setSubmitted] = useState("") return (
{ event.preventDefault() setSubmitted( String( new FormData(event.currentTarget).get( "notes", ), ), ) }} > { setValue(next) setChanges((count) => count + 1) }} />

Document edits: {changes}

            {value}
          
            {submitted}
          
) }, } export const Hostile: Story = { args: { defaultValue: HOSTILE_HTML, label: "Untrusted notes", }, } export const Blank: Story = { args: { defaultValue: "", label: "New notes" }, }