export type ToolbarExec = (cmd: string, val?: string) => void; const BoldIcon = () => ( ); const ItalicIcon = () => ( ); const UnderlineIcon = () => ( ); const StrikeIcon = () => ( ); const HeadingIcon = () => ( ); const QuoteIcon = () => ( ); const BulletIcon = () => ( ); const NumberedIcon = () => ( ); const RuleIcon = () => ( ); function applyBold(exec: ToolbarExec) { exec("bold"); } function applyItalic(exec: ToolbarExec) { exec("italic"); } function applyUnderline(exec: ToolbarExec) { exec("underline"); } function applyStrike(exec: ToolbarExec) { exec("strikeThrough"); } function applyHeading(exec: ToolbarExec) { const val = document.queryCommandValue("formatBlock").toLowerCase(); exec("formatBlock", val === "h2" ? "p" : "h2"); } function applyQuote(exec: ToolbarExec) { const val = document.queryCommandValue("formatBlock").toLowerCase(); exec("formatBlock", val === "blockquote" ? "p" : "blockquote"); } function applyBullet(exec: ToolbarExec) { exec("insertUnorderedList"); } function applyNumbered(exec: ToolbarExec) { exec("insertOrderedList"); } function applyRule(exec: ToolbarExec) { exec("insertHorizontalRule"); } interface ToolbarProps { exec: ToolbarExec; class?: string; } export function NoteToolbar(props: ToolbarProps) { return (
); }