import { IconPencil } from "@tabler/icons-react"; import { cn } from "../../utils.js"; import { defineBlock } from "../types.js"; import type { BlockReadProps, BlockEditProps } from "../types.js"; import { CALLOUT_TONES, calloutMdx, calloutSchema, type CalloutData, type CalloutTone, } from "./callout.config.js"; /** * Standard `callout` block — an emphasized note with a tone (info / decision / * risk / warning / success) and a markdown body. Lives in core so any app can * register it (it originated in the plan template). * * The section carries BOTH the app-neutral `an-callout` classes (styled by * core's `blocks.css` with shadcn theme tokens, so it looks right in any app) * and the legacy `plan-callout` classes (styled by the plan template's own * stylesheet). Plan therefore renders byte-identically to before; content (and * any other app) gets the theme-token treatment. `data-tone` drives the accent * in both. The body renders through `ctx.renderMarkdown` so each app supplies * its own GFM renderer (plan's react-markdown reader, content's, etc.). */ export function CalloutBlock({ data, blockId, title, ctx, }: BlockReadProps) { return (
{title &&
{title}
} {ctx.renderMarkdown?.(data.body) ?? (
{data.body}
)}
); } export function CalloutBlockEdit({ data, onChange, editable, blockId, title, summary, ctx, }: BlockEditProps) { const activeTone = data.tone ?? "info"; const setTone = (tone: CalloutTone) => onChange({ ...data, tone }); const toneSettings = editable ? ctx.renderEditSurface?.({ title: "Callout", blockId, blockType: "callout", blockTitle: title, blockSummary: summary, blockData: data, trigger: ( ), children: (
Type
{CALLOUT_TONES.map((tone) => ( ))}
), }) : null; return (
{title &&
{title}
} {toneSettings && (
{toneSettings}
)} {ctx.renderMarkdownEditor?.({ value: data.body, onChange: (body) => onChange({ ...data, body }), editable, blockId, }) ?? (