import "./components/ui/tidal.css"; import "./components/ui/rich-text-editor.css"; import { useId, useState, type FormEvent } from "react"; import { TidalRichTextEditor } from "./components/ui/rich-text-editor"; import "./components/ui/toolbar.css"; const tidalExampleStyles = ".tidal-scope .rich-text-editor-demo {\n display: grid;\n gap: 16px;\n inline-size: min(100%, 760px);\n min-inline-size: 0;\n margin-inline: auto;\n}\n\n.tidal-scope .rich-text-editor-link-row {\n display: grid;\n grid-template-columns: minmax(0, 130px) minmax(0, 1fr);\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid var(--t-border);\n border-radius: 10px;\n background: var(--t-subtle);\n}\n\n.tidal-scope .rich-text-editor-link-row label {\n min-inline-size: 0;\n font-size: 11px;\n font-weight: 740;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .rich-text-editor-link-row input {\n box-sizing: border-box;\n inline-size: 100%;\n min-inline-size: 0;\n min-block-size: 44px;\n padding-inline: 12px;\n border: 1px solid var(--t-border);\n border-radius: 10px;\n background: var(--t-surface);\n color: var(--t-ink);\n font: inherit;\n}\n\n.tidal-scope .rich-text-editor-link-row input:focus-visible,\n.tidal-scope .rich-text-editor-demo-footer button:focus-visible,\n.tidal-scope .rich-text-editor-guide summary:focus-visible {\n outline: 3px solid var(--t-accent);\n outline-offset: 2px;\n}\n\n.tidal-scope .rich-text-editor-demo-footer {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: center;\n gap: 12px;\n}\n\n.tidal-scope .rich-text-editor-demo-footer button {\n min-block-size: 44px;\n padding-inline: 16px;\n border: 1px solid var(--t-ink);\n border-radius: 10px;\n background: var(--t-ink);\n color: var(--t-surface);\n font: 750 12px/1 var(--t-font);\n cursor: pointer;\n}\n\n.tidal-scope .rich-text-editor-demo-footer output,\n.tidal-scope .rich-text-editor-guide,\n.tidal-scope .rich-text-editor-sample-note {\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.5;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .rich-text-editor-guide {\n padding-block: 12px;\n border-block: 1px solid var(--t-border);\n}\n\n.tidal-scope .rich-text-editor-guide summary {\n min-block-size: 44px;\n display: flex;\n align-items: center;\n color: var(--t-ink);\n font-weight: 740;\n cursor: pointer;\n}\n\n.tidal-scope .rich-text-editor-guide p,\n.tidal-scope .rich-text-editor-sample-note {\n margin: 0;\n}\n\n@media (max-width: 520px) {\n .tidal-scope .rich-text-editor-link-row,\n .tidal-scope .rich-text-editor-demo-footer {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .tidal-scope .rich-text-editor-link-row input {\n font-size: 16px;\n }\n\n .tidal-scope .rich-text-editor-demo-footer button {\n inline-size: 100%;\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .tidal-scope .rich-text-editor-demo-footer button {\n transition:\n transform 140ms var(--t-ease-out),\n background-color 140ms var(--t-ease-out);\n }\n\n .tidal-scope .rich-text-editor-demo-footer button:active {\n transform: scale(0.98);\n }\n}"; const SAMPLE_DOCUMENT = JSON.stringify({ root: { children: [ { children: [ { detail: 0, format: 0, mode: "normal", style: "", text: "Workspace notifications", type: "text", version: 1, }, ], tag: "h2", direction: null, format: "", indent: 0, type: "heading", version: 1, }, { children: [ { detail: 0, format: 1, mode: "normal", style: "", text: "New:", type: "text", version: 1, }, { detail: 0, format: 0, mode: "normal", style: "", text: " choose which project updates appear in your weekly summary.", type: "text", version: 1, }, ], direction: null, format: "", indent: 0, textFormat: 1, textStyle: "", type: "paragraph", version: 1, }, ], direction: null, format: "", indent: 0, type: "root", version: 1, }, }); function safeFragment(value: string) { return `rich-text-guide-${value.replace(/[^a-zA-Z0-9_-]/g, "")}`; } export function RichTextEditorDemo({ theme = "light", }: { theme?: "light" | "dark"; }) { const guideId = safeFragment(useId()); const [value, setValue] = useState(SAMPLE_DOCUMENT); const [linkHref, setLinkHref] = useState(`#${guideId}`); const [status, setStatus] = useState("Sample content is ready for review."); function review(event: FormEvent) { event.preventDefault(); const submitted = String( new FormData(event.currentTarget).get("product-content") ?? "", ); setStatus( submitted === value ? "The current editor JSON was reviewed locally." : "The submitted document did not match the current value.", ); } return (
{ setValue(next); setStatus("Sample content has local changes."); }} name="product-content" linkHref={linkHref} placeholder="Write a product update…" theme={theme} />
setLinkHref(event.currentTarget.value)} spellCheck={false} />
{status}
Workspace writing guide

Use short headings, plain links and lists that scan clearly.

Local sample only. The editor returns JSON and does not publish, upload, store or execute content.

); } export default function AgentExample() { return (
); }