@mieweb/ui 0.11.0-dev.42 → 0.11.0-dev.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/agent/evals/selection.md +3 -3
  2. package/agent/skills/mieweb-ui-catalog/SKILL.md +8 -8
  3. package/agent/skills/mieweb-ui-catalog/selection-guidance.md +13 -13
  4. package/dist/{chunk-6L7CTEX2.cjs → chunk-2KK4WZ7Y.cjs} +4 -4
  5. package/dist/{chunk-6L7CTEX2.cjs.map → chunk-2KK4WZ7Y.cjs.map} +1 -1
  6. package/dist/{chunk-EWPNM6OO.js → chunk-3A4N5E6P.js} +19 -4
  7. package/dist/chunk-3A4N5E6P.js.map +1 -0
  8. package/dist/{chunk-S2CJ57BX.cjs → chunk-AHT2HRHC.cjs} +19 -3
  9. package/dist/chunk-AHT2HRHC.cjs.map +1 -0
  10. package/dist/{chunk-AKC677ZF.js → chunk-DIIXY6EB.js} +5 -5
  11. package/dist/chunk-DIIXY6EB.js.map +1 -0
  12. package/dist/{chunk-LLIG4X6M.cjs → chunk-EAAVFTKI.cjs} +7 -7
  13. package/dist/chunk-EAAVFTKI.cjs.map +1 -0
  14. package/dist/{chunk-RCTIPBLU.cjs → chunk-HH7PWD5I.cjs} +173 -6
  15. package/dist/chunk-HH7PWD5I.cjs.map +1 -0
  16. package/dist/{chunk-IALTKN3Y.js → chunk-IPHJQ6CF.js} +171 -4
  17. package/dist/chunk-IPHJQ6CF.js.map +1 -0
  18. package/dist/{chunk-2OTPQPJS.js → chunk-L3CAWGBU.js} +3 -3
  19. package/dist/{chunk-2OTPQPJS.js.map → chunk-L3CAWGBU.js.map} +1 -1
  20. package/dist/{chunk-R4QWCP2T.cjs → chunk-MD55WRGN.cjs} +11 -11
  21. package/dist/{chunk-R4QWCP2T.cjs.map → chunk-MD55WRGN.cjs.map} +1 -1
  22. package/dist/{chunk-LWLHCUDP.js → chunk-ZULFKL3C.js} +3 -3
  23. package/dist/{chunk-LWLHCUDP.js.map → chunk-ZULFKL3C.js.map} +1 -1
  24. package/dist/components/EmailEditor/index.cjs +13 -13
  25. package/dist/components/EmailEditor/index.js +4 -4
  26. package/dist/components/RichTextEditor/index.cjs +4 -4
  27. package/dist/components/RichTextEditor/index.d.cts +9 -0
  28. package/dist/components/RichTextEditor/index.d.ts +9 -0
  29. package/dist/components/RichTextEditor/index.js +1 -1
  30. package/dist/components/Textarea/index.cjs +6 -6
  31. package/dist/components/Textarea/index.js +3 -3
  32. package/dist/esheet.cjs +17 -17
  33. package/dist/esheet.js +4 -4
  34. package/dist/index.cjs +58 -58
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +9 -0
  37. package/dist/index.d.ts +9 -0
  38. package/dist/index.js +9 -9
  39. package/dist/index.js.map +1 -1
  40. package/dist/kerebron.cjs +4 -4
  41. package/dist/kerebron.js +2 -2
  42. package/package.json +1 -1
  43. package/dist/chunk-AKC677ZF.js.map +0 -1
  44. package/dist/chunk-EWPNM6OO.js.map +0 -1
  45. package/dist/chunk-IALTKN3Y.js.map +0 -1
  46. package/dist/chunk-LLIG4X6M.cjs.map +0 -1
  47. package/dist/chunk-RCTIPBLU.cjs.map +0 -1
  48. package/dist/chunk-S2CJ57BX.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/MacroLibrary/MacroLibrary.tsx","../src/components/RichTextEditor/processDictation.ts","../src/components/RichTextEditor/RichTextEditor.tsx"],"names":["React","MacroLibrary","value","jsxs","jsx","Fragment","BookOpen","Plus"],"mappings":";;;;;;;;;;;;;;;AA0EA,IAAM,cAAA,GAAiB;AAAA,EACrB,UAAA,EAAY,aAAA;AAAA,EACZ,MAAA,EAAQ,QAAA;AAAA,EACR,iBAAA,EAAmB,qBAAA;AAAA,EACnB,WAAA,EAAa,eAAA;AAAA,EACb,KAAA,EAAO,cAAA;AAAA,EACP,WAAA,EAAa,eAAA;AAAA,EACb,KAAA,EAAO,qBAAA;AAA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AO,QAAA,KAAa,eAAe,QAAA,CAAS,GAAA,KAAQ,QAChD,MAAA,GACA,OAAA;AAAA,gBAEN,iBAAA,EAAkB,iBAAA;AAAA,gBAClB,SAAA,EAAU,qKAAA;AAAA,gBAEV,QAAA,kBAAAA,GAAAA;AAAA,kBAAC,YAAA;AAAA,kBAAA;AAAA,oBACC,EAAA,EAAI,YAAA;AAAA,oBACJ,MAAA,EAAQ,MAAA;AAAA,oBACR,QAAA,EAAU,WAAA;AAAA,oBACV,aAAa,SAAA,IAAa,WAAA;AAAA,oBAC1B,OAAA;AAAA;AAAA;AAAA,sBAGE,aAAA,GACI,SACA,MAAM;AACJ,wBAAA,aAAA,CAAc,KAAK,CAAA;AAInB,wBAAA,uBAAA,EAAwB;AAAA,sBAC1B;AAAA,qBAAA;AAAA,oBAEN,aAAA;AAAA,oBACA,MAAA,EAAQ,WAAA;AAAA,oBACR,OAAA,EAAS,aAAA;AAAA,oBACT,SAAA,EAAU;AAAA;AAAA;AACZ,eAAA;AAAA,cAzCI;AAAA,aA0CN,EAEJ;AAAA,WAAA,EAEJ;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,cAAA,CAAe,WAAA,GAAc,gBAAA","file":"chunk-EWPNM6OO.js","sourcesContent":["import * as React from 'react';\nimport {\n SearchIcon,\n HistoryIcon,\n BookOpenIcon,\n ChevronDownIcon,\n ChevronRightIcon,\n CloseIcon,\n PlusIcon,\n} from '../Icons';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Input } from '../Input';\n\nexport interface Macro {\n /** Stable identifier. */\n id: string;\n /** Human-readable name shown in the list. */\n label: string;\n /** Plain text inserted into the editor. `\\n` is preserved. */\n content: string;\n /** Optional shortcut identifier shown as a badge (e.g. `.b`). */\n shortcut?: string;\n /** Extra search terms that are not displayed. */\n keywords?: string[];\n}\n\nexport interface MacroGroup {\n /** Stable identifier. */\n id: string;\n /** Group heading (e.g. \"Default library\"). */\n label: string;\n /**\n * `previous` renders the group visually distinct from library macros\n * (history icon, muted header) so prior values are never mistaken for\n * predefined content. Defaults to `library`.\n */\n kind?: 'library' | 'previous';\n /** Macros belonging to the group. */\n macros: Macro[];\n}\n\nexport interface MacroLibraryProps {\n /** Grouped macros supplied by the application. */\n groups: MacroGroup[];\n /** Called with the chosen macro. The caller performs the insertion. */\n onSelect: (macro: Macro) => void;\n /** Id for the panel root (e.g. the target of a toggle's aria-controls). */\n id?: string;\n /**\n * Name of the insertion target shown in the header (e.g. the editor's\n * label), rendered as \"Insert into <target>\".\n */\n targetLabel?: string;\n /** When provided, renders a close button and enables Escape-to-close. */\n onClose?: () => void;\n /** When provided, renders a \"Save as macro\" action in the footer. */\n onCreateMacro?: () => void;\n /** Autofocus the search input on mount. Defaults to false. */\n autoFocusSearch?: boolean;\n /**\n * Minimal chrome for short, space-constrained lists: hides the header,\n * the search input, and library group headings so the panel is just the\n * macro rows. Previous-value groups keep their heading so prior answers\n * stay visually distinct. Escape-to-close still works when `onClose` is\n * provided. Defaults to false.\n */\n compact?: boolean;\n /** Additional class for the panel root. */\n className?: string;\n /** Overridable labels for i18n. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n}\n\nconst DEFAULT_LABELS = {\n insertInto: 'Insert into',\n macros: 'Macros',\n searchPlaceholder: 'Search macros…',\n searchLabel: 'Search macros',\n close: 'Close macros',\n createMacro: 'Save as macro',\n empty: 'No macros available',\n emptyHint: 'The application has not provided a macro list.',\n noResults: 'No macros match',\n clearSearch: 'Clear search',\n showMore: 'Show {count} more',\n};\n\n/** Rows shown per group before the \"show more\" expander. */\nconst PREVIEW_COUNT = 4;\n\n/** Case-insensitive match across label, shortcut, keywords and content. */\nfunction matchesQuery(macro: Macro, query: string): boolean {\n const q = query.toLowerCase();\n return (\n macro.label.toLowerCase().includes(q) ||\n (macro.shortcut ?? '').toLowerCase().includes(q) ||\n (macro.keywords ?? []).some((k) => k.toLowerCase().includes(q)) ||\n macro.content.toLowerCase().includes(q)\n );\n}\n\n/** Query is a prefix of the macro's shortcut identifier. */\nfunction isShortcutHit(macro: Macro, query: string): boolean {\n return (\n query.length > 0 &&\n (macro.shortcut ?? '').toLowerCase().startsWith(query.toLowerCase())\n );\n}\n\n/** Shortcut-prefix matches rank before everything else. */\nfunction rankMacros(macros: Macro[], query: string): Macro[] {\n return [...macros].sort(\n (a, b) => Number(isShortcutHit(b, query)) - Number(isShortcutHit(a, query))\n );\n}\n\n/**\n * Keep the editor focused while picking with a pointer: cancelling mousedown's\n * default stops the button from stealing focus (on touch the compatibility\n * mousedown would otherwise blur the editor and dismiss the keyboard), so a\n * focus-docked panel stays open across multiple picks. Keyboard roving focus\n * is unaffected.\n */\nfunction preservePointerFocus(event: React.MouseEvent) {\n event.preventDefault();\n}\n\n/**\n * Group headings preserve editor focus like macro rows, with one exception:\n * when roving focus is already on a row inside the group, collapsing would\n * unmount that row and strand focus on the body. Letting the heading take\n * pointer focus in that case keeps keyboard navigation anchored in the panel.\n */\nfunction preserveGroupTogglePointerFocus(\n event: React.MouseEvent<HTMLButtonElement>\n) {\n const group = event.currentTarget.closest(\n '[data-slot=\"macro-library-group\"]'\n );\n if (group?.contains(document.activeElement)) return;\n event.preventDefault();\n}\n\n/**\n * A searchable, grouped macro browser designed to dock inside an editor's\n * chrome. Editor-agnostic: selecting a macro calls `onSelect` and the host\n * performs the insertion. Previous-value groups (`kind: 'previous'`) are\n * rendered distinctly from library macros. All rows and controls are real\n * buttons with roving arrow-key focus from the search input.\n */\nexport const MacroLibrary = React.forwardRef<HTMLDivElement, MacroLibraryProps>(\n function MacroLibrary(\n {\n groups,\n onSelect,\n id,\n targetLabel,\n onClose,\n onCreateMacro,\n autoFocusSearch = false,\n compact = false,\n className,\n labels: labelOverrides,\n },\n ref\n ) {\n const labels = { ...DEFAULT_LABELS, ...labelOverrides };\n const [query, setQuery] = React.useState('');\n const [collapsed, setCollapsed] = React.useState<Record<string, boolean>>(\n {}\n );\n const [expanded, setExpanded] = React.useState<Record<string, boolean>>({});\n const listRef = React.useRef<HTMLDivElement>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const panelId = React.useId();\n\n React.useEffect(() => {\n if (autoFocusSearch) searchRef.current?.focus();\n }, [autoFocusSearch]);\n\n const trimmed = query.trim();\n const searching = trimmed.length > 0;\n\n const visibleGroups = groups\n .map((group) => ({\n ...group,\n macros: searching\n ? rankMacros(\n group.macros.filter((m) => matchesQuery(m, trimmed)),\n trimmed\n )\n : group.macros,\n }))\n .filter((group) => group.macros.length > 0)\n // Groups containing shortcut-prefix hits rank first so \".c\" reaches\n // the macro with that shortcut before incidental content matches in\n // earlier groups; the stable sort keeps group context otherwise.\n .sort(\n (a, b) =>\n Number(b.macros.some((m) => isShortcutHit(m, trimmed))) -\n Number(a.macros.some((m) => isShortcutHit(m, trimmed)))\n );\n\n const hasMacros = groups.some((g) => g.macros.length > 0);\n const noResults = hasMacros && searching && visibleGroups.length === 0;\n\n /** Roving focus across visible macro-row buttons. */\n const moveFocus = (delta: 1 | -1) => {\n const rows = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\n '[data-macro-row]'\n ) ?? []\n );\n if (rows.length === 0) return;\n const index = rows.findIndex((row) => row === document.activeElement);\n if (index === -1) {\n rows[delta === 1 ? 0 : rows.length - 1].focus();\n return;\n }\n const next = index + delta;\n if (next < 0) {\n searchRef.current?.focus();\n return;\n }\n rows[Math.min(next, rows.length - 1)].focus();\n };\n\n const handlePanelKeyDown = (event: React.KeyboardEvent) => {\n // Escape during IME composition cancels the composition; never close.\n if (event.nativeEvent.isComposing) return;\n if (event.key === 'Escape' && onClose) {\n event.stopPropagation();\n onClose();\n }\n };\n\n const handleSearchKeyDown = (event: React.KeyboardEvent) => {\n // ArrowDown during IME composition navigates conversion candidates.\n if (event.nativeEvent.isComposing) return;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n }\n };\n\n const handleRowKeyDown = (event: React.KeyboardEvent) => {\n if (event.nativeEvent.isComposing) return;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n moveFocus(-1);\n }\n };\n\n /** Reveal a group's remaining macros, moving focus to the first one. */\n const expandGroup = (groupId: string) => {\n setExpanded((prev) => ({ ...prev, [groupId]: true }));\n requestAnimationFrame(() => {\n const groupEl = Array.from(\n listRef.current?.querySelectorAll<HTMLElement>(\n '[data-slot=\"macro-library-group\"]'\n ) ?? []\n ).find((el) => el.dataset.groupId === groupId);\n const rows =\n groupEl?.querySelectorAll<HTMLButtonElement>('[data-macro-row]');\n rows?.[PREVIEW_COUNT]?.focus();\n });\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- keydown only delegates Escape-to-close from focusable children\n <div\n ref={ref}\n id={id}\n role=\"group\"\n aria-label={\n targetLabel ? `${labels.insertInto} ${targetLabel}` : labels.macros\n }\n data-slot=\"macro-library\"\n className={cn('bg-muted/20 flex min-h-0 flex-col', className)}\n onKeyDown={handlePanelKeyDown}\n >\n {!compact && (\n <div\n data-slot=\"macro-library-header\"\n className=\"border-border flex items-center justify-between gap-2 border-b px-3 py-2\"\n >\n <span className=\"text-muted-foreground min-w-0 truncate text-xs\">\n {targetLabel ? (\n <>\n {labels.insertInto}{' '}\n <span className=\"text-foreground font-semibold\">\n {targetLabel}\n </span>\n </>\n ) : (\n labels.macros\n )}\n </span>\n {onClose && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-6 w-6 shrink-0 p-0\"\n onClick={onClose}\n aria-label={labels.close}\n >\n <CloseIcon className=\"h-3.5 w-3.5\" />\n </Button>\n )}\n </div>\n )}\n\n {hasMacros ? (\n <>\n {!compact && (\n <div className=\"px-3 pt-2\">\n <div className=\"relative\">\n <SearchIcon\n aria-hidden=\"true\"\n className=\"text-muted-foreground pointer-events-none absolute start-2.5 top-1/2 z-10 h-3.5 w-3.5 -translate-y-1/2\"\n />\n <Input\n ref={searchRef}\n label={labels.searchLabel}\n hideLabel\n size=\"sm\"\n type=\"search\"\n placeholder={labels.searchPlaceholder}\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n onKeyDown={handleSearchKeyDown}\n className=\"ps-8\"\n aria-controls={`${panelId}-list`}\n />\n </div>\n </div>\n )}\n\n {/* Persistent polite region so a failed search is announced. */}\n <div role=\"status\" className=\"sr-only\">\n {noResults ? `${labels.noResults} “${trimmed}”` : ''}\n </div>\n\n <div\n ref={listRef}\n id={`${panelId}-list`}\n data-slot=\"macro-library-list\"\n className=\"min-h-0 flex-1 overflow-y-auto p-1.5\"\n >\n {noResults && (\n <div className=\"text-muted-foreground px-2 py-8 text-center text-sm\">\n <p>\n {labels.noResults} “{trimmed}”\n </p>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"mt-2\"\n onClick={() => {\n setQuery('');\n searchRef.current?.focus();\n }}\n >\n {labels.clearSearch}\n </Button>\n </div>\n )}\n\n {visibleGroups.map((group) => {\n const isPrevious = group.kind === 'previous';\n // Strict check: ids like \"constructor\" must not read\n // inherited Object.prototype members as collapsed state.\n const isCollapsed = !searching && collapsed[group.id] === true;\n // Long groups start as a short preview; searching always\n // shows every match.\n const isPreview =\n !searching &&\n expanded[group.id] !== true &&\n group.macros.length > PREVIEW_COUNT;\n const visibleMacros = isPreview\n ? group.macros.slice(0, PREVIEW_COUNT)\n : group.macros;\n const GroupIcon = isPrevious ? HistoryIcon : BookOpenIcon;\n return (\n <div\n key={group.id}\n data-slot=\"macro-library-group\"\n data-group-id={group.id}\n data-kind={group.kind ?? 'library'}\n >\n {/* Compact keeps only previous-value headings: prior\n answers must stay distinct from library content. */}\n {(!compact || isPrevious) && (\n <button\n type=\"button\"\n className={cn(\n 'text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 rounded px-2 pt-2.5 pb-1 text-start text-[11px] font-semibold tracking-wide uppercase',\n isPrevious && 'text-warning-700 dark:text-warning-400'\n )}\n aria-expanded={!isCollapsed}\n disabled={searching}\n onMouseDown={preserveGroupTogglePointerFocus}\n onClick={() =>\n setCollapsed((prev) => ({\n ...prev,\n [group.id]: prev[group.id] !== true,\n }))\n }\n >\n <GroupIcon aria-hidden=\"true\" className=\"h-3 w-3\" />\n <span className=\"min-w-0 flex-1 truncate\">\n {group.label}\n </span>\n {!searching &&\n (isCollapsed ? (\n <ChevronRightIcon\n aria-hidden=\"true\"\n className=\"h-3 w-3\"\n />\n ) : (\n <ChevronDownIcon\n aria-hidden=\"true\"\n className=\"h-3 w-3\"\n />\n ))}\n </button>\n )}\n\n {!isCollapsed &&\n visibleMacros.map((macro) => (\n <button\n key={macro.id}\n type=\"button\"\n data-macro-row\n data-slot=\"macro-library-item\"\n className=\"focus-visible:ring-ring text-foreground hover:bg-muted/60 hover:text-primary flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-start focus-visible:ring-2 focus-visible:outline-none\"\n onMouseDown={preservePointerFocus}\n onClick={() => onSelect(macro)}\n onKeyDown={handleRowKeyDown}\n >\n {macro.shortcut && (\n <span\n // Shortcuts are typed sequences; keep them LTR\n // in RTL locales.\n dir=\"ltr\"\n className={cn(\n 'border-border bg-background text-muted-foreground rounded border px-1 font-mono text-[11px]',\n isPrevious &&\n 'border-warning-300 bg-warning-50 text-warning-800 dark:border-warning-700 dark:bg-warning-950 dark:text-warning-300'\n )}\n >\n {macro.shortcut}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate text-sm font-medium\">\n {macro.label}\n </span>\n </button>\n ))}\n {!isCollapsed && isPreview && (\n <button\n type=\"button\"\n data-macro-row\n data-slot=\"macro-library-show-more\"\n className=\"focus-visible:ring-ring text-muted-foreground hover:bg-muted/60 hover:text-primary flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-start text-xs font-medium focus-visible:ring-2 focus-visible:outline-none\"\n onMouseDown={preservePointerFocus}\n onClick={() => expandGroup(group.id)}\n onKeyDown={handleRowKeyDown}\n >\n <ChevronDownIcon\n aria-hidden=\"true\"\n className=\"h-3 w-3\"\n />\n {labels.showMore.replace(\n '{count}',\n String(group.macros.length - PREVIEW_COUNT)\n )}\n </button>\n )}\n </div>\n );\n })}\n </div>\n </>\n ) : (\n <div className=\"text-muted-foreground flex flex-1 flex-col items-center justify-center gap-1 px-4 py-10 text-center text-sm\">\n <BookOpenIcon aria-hidden=\"true\" className=\"mb-1 h-5 w-5\" />\n <p className=\"text-foreground font-medium\">{labels.empty}</p>\n <p className=\"text-xs\">{labels.emptyHint}</p>\n </div>\n )}\n\n {onCreateMacro && (\n <div\n data-slot=\"macro-library-footer\"\n className=\"border-border border-t px-2 py-1.5\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"w-full justify-start gap-1.5\"\n onClick={onCreateMacro}\n >\n <PlusIcon aria-hidden=\"true\" className=\"h-3.5 w-3.5\" />\n {labels.createMacro}\n </Button>\n </div>\n )}\n </div>\n );\n }\n);\n","/**\n * Converts spoken punctuation words (e.g. \"period\", \"comma\") into the\n * corresponding characters, using lightweight context heuristics so that words\n * like \"time period\" or \"the colon\" are left intact. Pure and side-effect free\n * so it can be unit tested independently of the editor.\n */\nexport function processDictation(text: string): string {\n let result = text;\n\n // \"period\" as a word vs. as punctuation.\n result = result.replace(\n /\\b(the|a|this|that|each|every|same|time|grace|trial|waiting|probationary|pay|billing|accounting)\\s+period\\b/gi,\n '$1 period'\n );\n result = result.replace(\n /\\bperiod\\s+(of|in|for|from|to|during|between|after|before|when|where|is|was|will|has|had)\\b/gi,\n 'period $1'\n );\n result = result.replace(/\\s+period(\\s*$)/gi, '.$1');\n result = result.replace(/\\s+period\\s+(?=[A-Z])/g, '. ');\n\n // \"comma\"\n result = result.replace(/\\bcomma\\s+(separated|delimited)/gi, 'comma $1');\n result = result.replace(/\\s+comma\\b/gi, ',');\n\n // \"colon\"\n result = result.replace(\n /\\b(the|a|my|your|his|her|their|semicolon|ascending|descending|transverse|sigmoid)\\s+colon\\b/gi,\n '$1 colon'\n );\n result = result.replace(\n /\\bcolon\\s+(cancer|surgery|health|polyp|scope|oscopy)/gi,\n 'colon $1'\n );\n result = result.replace(/\\s+colon\\b/gi, ':');\n\n // \"dash\"\n result = result.replace(\n /\\b(yard|meter|hundred|mad|quick|wild)\\s+dash\\b/gi,\n '$1 dash'\n );\n result = result.replace(/\\bdash\\s+(to|for|of)\\b/gi, 'dash $1');\n result = result.replace(/\\s+dash\\b/gi, ' -');\n\n const simplePunctuation: Record<string, string> = {\n ' full stop': '.',\n ' question mark': '?',\n ' exclamation point': '!',\n ' exclamation mark': '!',\n ' semicolon': ';',\n ' semi colon': ';',\n ' hyphen': '-',\n ' open parenthesis': ' (',\n ' close parenthesis': ')',\n ' open bracket': ' [',\n ' close bracket': ']',\n ' open quote': ' \"',\n ' close quote': '\"',\n ' quote': '\"',\n ' apostrophe': \"'\",\n ' new line': '\\n',\n ' newline': '\\n',\n ' new paragraph': '\\n\\n',\n ' tab': '\\t',\n };\n\n for (const [spoken, punctuation] of Object.entries(simplePunctuation)) {\n const regex = new RegExp(spoken, 'gi');\n result = result.replace(regex, punctuation);\n }\n\n // Capitalize after sentence-ending punctuation.\n result = result.replace(\n /([.!?])\\s+([a-z])/g,\n (_match, punct: string, letter: string) =>\n `${punct} ${letter.toUpperCase()}`\n );\n\n return result;\n}\n\n/**\n * Converts `<<field>>` (and the HTML-encoded `&lt;&lt;field&gt;&gt;`) syntax\n * into mustache `{{field}}` syntax. Pure helper operating on an HTML string.\n */\nexport function convertAngleBracketsToMustache(html: string): string {\n return html\n .replace(\n /&lt;&lt;([^&]*)&gt;&gt;/g,\n (_m, field: string) => `{{${field.trim()}}}`\n )\n .replace(/<<([^>]*)>>/g, (_m, field: string) => `{{${field.trim()}}}`);\n}\n\n/**\n * Returns true when an HTML string has no visible text content.\n * Note: This is a visibility check, not a sanitizer. It strips tags to inspect\n * remaining text — do NOT use this for XSS prevention.\n */\nexport { isHtmlEmpty } from '../../utils/html';\n","import { useMessages } from '../../utils/messages';\nimport * as React from 'react';\nimport {\n Bold,\n Italic,\n Underline,\n List,\n ListOrdered,\n AlignLeft,\n AlignCenter,\n AlignRight,\n Braces,\n Replace,\n Mic,\n MicOff,\n BookOpen,\n Plus,\n} from 'lucide-react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Separator } from '../Separator';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { usePrefersReducedMotion } from '../../hooks/usePrefersReducedMotion';\nimport {\n MacroLibrary,\n type Macro,\n type MacroGroup,\n type MacroLibraryProps,\n} from '../MacroLibrary';\nimport { Animated, AnimatedPresence } from '../../motion';\nimport {\n Dropdown,\n DropdownItem,\n DropdownLabel,\n DropdownSeparator,\n DropdownSubmenu,\n} from '../Dropdown';\nimport {\n processDictation,\n convertAngleBracketsToMustache,\n isHtmlEmpty,\n} from './processDictation';\n\nexport interface RichTextVariable {\n /** Human-readable label shown in the variable menu. */\n label: string;\n /** The token displayed for the variable (e.g. `{{employee.name}}`). */\n value: string;\n /** Optional text inserted instead of `value` (e.g. an expanded group). */\n insertValue?: string;\n}\n\nexport interface RichTextVariableGroup {\n /** Group heading shown in the variable menu. */\n label: string;\n /** Variables belonging to the group. */\n variables: RichTextVariable[];\n}\n\nexport interface RichTextEditorBlockMenuLabels {\n /** Accessible label for the gutter `+` button. Defaults to \"Block menu\". */\n blockMenu?: string;\n /** \"Text\" (normal paragraph) menu item. */\n text?: string;\n /** \"Heading 1\" menu item. */\n heading1?: string;\n /** \"Heading 2\" menu item. */\n heading2?: string;\n /** \"Heading 3\" menu item. */\n heading3?: string;\n /** \"Bullet list\" menu item. */\n bulletList?: string;\n /** \"Numbered list\" menu item. */\n numberedList?: string;\n /** \"Quote\" menu item. */\n quote?: string;\n /** \"Insert macro\" submenu parent (shown when `macros` is provided). */\n insertMacro?: string;\n /** \"Show macro library\" menu item (shown when `macros` is provided). */\n showMacroLibrary?: string;\n /** Toolbar toggle item while the toolbar is hidden. */\n showToolbar?: string;\n /** Toolbar toggle item while the toolbar is visible. */\n hideToolbar?: string;\n}\n\nexport interface RichTextEditorProps {\n /** Current HTML value of the editor. */\n value: string;\n /** Called with the updated HTML whenever the content changes. */\n onChange: (value: string) => void;\n /** Placeholder shown when the editor is empty. */\n placeholder?: string;\n /** Additional class for the editor wrapper. */\n className?: string;\n /**\n * Variable groups for the \"Insert variable\" menu. When omitted the variable\n * menu and the `<< >>` → `{{ }}` convert button are hidden.\n */\n variableGroups?: RichTextVariableGroup[];\n /** Enable the speech-to-text dictation button. Defaults to true. */\n enableDictation?: boolean;\n /** Called when dictation cannot start (replaces native alerts). */\n onDictationError?: (message: string) => void;\n /** Disable editing and toolbar actions. */\n disabled?: boolean;\n /**\n * Sanitises HTML introduced by paste or drop before it reaches the editable\n * DOM. Without it, pasted markup is inserted as the browser provides it.\n */\n sanitizeHtml?: (html: string) => string;\n /**\n * Grouped macros for the optional macro addon. When omitted the editor is\n * unchanged. When provided, a \"Macros\" toolbar toggle docks a searchable\n * macro panel inside the editor; selecting a macro inserts its content at\n * the retained caret position. Typing a macro shortcut (e.g. `.b`)\n * followed by a space expands it in place, panel open or not.\n */\n macros?: MacroGroup[];\n /** Open the macro panel initially. Defaults to false. */\n defaultMacrosOpen?: boolean;\n /**\n * Focus-driven macro panel: the field rests as a plain input, the panel\n * animates in while focus is anywhere inside the editor frame (editable,\n * toolbar, gutter or the panel itself) and animates away when focus\n * leaves. Overrides `defaultMacrosOpen`; Escape-to-close is disabled since\n * visibility follows focus. Pairs well with `compactMacros`. Defaults to\n * false.\n */\n macrosOnFocus?: boolean;\n /**\n * Dock the macro panel in `MacroLibrary`'s compact mode (no header,\n * search, or library group headings) and shrink the macros-open working\n * space to match — for short lists in dense forms. Defaults to false.\n */\n compactMacros?: boolean;\n /**\n * Called on any explicit macro invocation: a pick from the macro panel or\n * the block gutter flyout, or a typed `.shortcut` expansion. Return `true`\n * to take over the insertion: the editor skips its caret insertion and the\n * host applies the content through its own value update (e.g. appending a\n * coded finding as its own line). For typed shortcuts the editor removes\n * the typed token (and publishes that edit) before consulting the\n * callback, so a host that takes over computes from a token-free value.\n */\n onMacroInsert?: (macro: Macro) => boolean | void;\n /**\n * Overridable labels for the macro addon (i18n). Panel labels are\n * forwarded to the docked `MacroLibrary`; `macros` doubles as the toolbar\n * toggle text, and `showMacros`/`hideMacros` set the toggle's title.\n */\n macroLabels?: MacroLibraryProps['labels'] & {\n /** Toggle title while the panel is closed. Defaults to \"Show macros\". */\n showMacros?: string;\n /** Toggle title while the panel is open. Defaults to \"Hide macros\". */\n hideMacros?: string;\n };\n /** Forwarded to the macro panel's \"Save as macro\" action. */\n onCreateMacro?: () => void;\n /**\n * Controlled toolbar visibility. `'hidden'` removes the toolbar entirely\n * for chromeless surfaces (typed shortcuts keep working; pair with\n * `markdownShortcuts` or `blockMenu` so formatting stays reachable). When\n * omitted the editor manages visibility itself, starting from\n * `defaultToolbar` — existing consumers are unchanged.\n */\n toolbar?: 'visible' | 'hidden';\n /**\n * Initial toolbar visibility when `toolbar` is uncontrolled. Defaults to\n * `'visible'`.\n */\n defaultToolbar?: 'visible' | 'hidden';\n /**\n * Called when the block gutter menu toggles the toolbar (\"Show toolbar\" /\n * \"Hide toolbar\"), so hosts can persist the preference or drive the\n * controlled `toolbar` prop.\n */\n onToolbarChange?: (toolbar: 'visible' | 'hidden') => void;\n /**\n * Notion-style block gutter menu. Hovering a text row reveals a `+`\n * button in the start gutter whose menu applies block formats to that\n * row, opens the macro panel (when `macros` is provided) and toggles the\n * toolbar. Also reachable from the keyboard with Ctrl/Cmd+/ on the\n * caret's block. Defaults to false.\n */\n blockMenu?: boolean;\n /** Overridable labels for the block gutter menu (i18n). */\n blockMenuLabels?: RichTextEditorBlockMenuLabels;\n /**\n * Expand markdown-style block shortcuts typed at the start of a line and\n * followed by a space: `#`/`##`/`###` → headings, `-`/`*` → bullet list,\n * `1.` → numbered list, `>` → block quote. Inline rules (`**bold**`) are\n * not interpreted. Defaults to false.\n */\n markdownShortcuts?: boolean;\n /**\n * Textarea-like surface: removes the wrapper border/radius and starts the\n * editable at a single Input-row height that auto-grows with content\n * (matching `Textarea`'s `md` metrics). The host supplies the chrome —\n * `TextAreaRich` is the packaged pairing. Defaults to false.\n */\n chromeless?: boolean;\n /** Id applied to the editable region (deep links, `aria-labelledby`). */\n id?: string;\n /**\n * Prevent editing and formatting while keeping the region focusable and\n * its text selectable — the contenteditable analogue of a native\n * textarea's `readOnly`. The block gutter menu is hidden.\n */\n readOnly?: boolean;\n /** Extra class for the editable region itself (fonts, whitespace). */\n editorClassName?: string;\n /** Inline style for the editable region (e.g. a row-derived min-height). */\n editorStyle?: React.CSSProperties;\n /** Accessible label for the editable region. */\n 'aria-label'?: string;\n /** Id(s) of element(s) labelling the editable region. */\n 'aria-labelledby'?: string;\n /** Ids of elements describing the editable region (errors, helper text). */\n 'aria-describedby'?: string;\n /** Marks the editable region invalid for assistive technology. */\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Marks the editable region required for assistive technology. */\n 'aria-required'?: React.AriaAttributes['aria-required'];\n}\n\n// --- Minimal Web Speech API typings (absent from the standard DOM lib) ---\ninterface SpeechRecognitionAlternativeLike {\n transcript: string;\n}\ninterface SpeechRecognitionResultLike {\n isFinal: boolean;\n [index: number]: SpeechRecognitionAlternativeLike;\n}\ninterface SpeechRecognitionResultListLike {\n length: number;\n [index: number]: SpeechRecognitionResultLike;\n}\ninterface SpeechRecognitionEventLike {\n resultIndex: number;\n results: SpeechRecognitionResultListLike;\n}\ninterface SpeechRecognitionErrorEventLike {\n error: string;\n}\ninterface SpeechRecognitionLike {\n continuous: boolean;\n interimResults: boolean;\n lang: string;\n maxAlternatives: number;\n onstart: (() => void) | null;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n start: () => void;\n stop: () => void;\n}\ntype SpeechRecognitionCtor = new () => SpeechRecognitionLike;\ninterface SpeechWindow {\n SpeechRecognition?: SpeechRecognitionCtor;\n webkitSpeechRecognition?: SpeechRecognitionCtor;\n}\n\nfunction getSpeechRecognition(): SpeechRecognitionCtor | undefined {\n const w = window as unknown as SpeechWindow;\n return w.SpeechRecognition || w.webkitSpeechRecognition;\n}\n\n/** Elements that end a visible word, equivalent to whitespace. */\nconst BLOCK_BOUNDARY =\n /^(BR|DIV|P|LI|UL|OL|TABLE|TR|TD|TH|H[1-6]|BLOCKQUOTE|PRE|HR)$/;\n\n/**\n * Markdown-style block tokens expanded on space at the start of a line.\n * Values feed `document.execCommand`; block rules only — inline markdown\n * (e.g. `**bold**`) is intentionally not interpreted.\n */\nconst MARKDOWN_BLOCK_RULES: Record<\n string,\n { command: string; value?: string }\n> = {\n '#': { command: 'formatBlock', value: 'h1' },\n '##': { command: 'formatBlock', value: 'h2' },\n '###': { command: 'formatBlock', value: 'h3' },\n '-': { command: 'insertUnorderedList' },\n '*': { command: 'insertUnorderedList' },\n '1.': { command: 'insertOrderedList' },\n '>': { command: 'formatBlock', value: 'blockquote' },\n};\n\n/**\n * Bounding rect of a top-level editor node. Text nodes (a bare first line\n * has no element wrapper) are measured through a Range.\n */\nfunction nodeRect(node: Node) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n return (node as HTMLElement).getBoundingClientRect();\n }\n if (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').length > 0) {\n const range = document.createRange();\n range.selectNodeContents(node);\n return range.getBoundingClientRect();\n }\n return null;\n}\n\n/**\n * Last non-empty text node rendered inside `node`, or 'boundary' when it\n * ends with a line break or block element.\n */\nfunction lastTextWithin(node: Node): Text | 'boundary' | null {\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent ?? '').length > 0 ? (node as Text) : null;\n }\n if (node.nodeType !== Node.ELEMENT_NODE) return null;\n if (BLOCK_BOUNDARY.test((node as HTMLElement).tagName)) return 'boundary';\n for (let child = node.lastChild; child; child = child.previousSibling) {\n const found = lastTextWithin(child);\n if (found) return found;\n }\n return null;\n}\n\n/**\n * Previous visible text node before `node`, looking across adjacent inline\n * elements (e.g. the \".\" in `.<b>c</b>` precedes the \"c\"). Returns null at\n * a block/line-break boundary or the editor root, where a word cannot\n * continue.\n */\nfunction previousVisibleText(node: Node, root: HTMLElement): Text | null {\n let current: Node = node;\n while (current !== root) {\n let sibling: Node | null = current.previousSibling;\n while (sibling) {\n const found = lastTextWithin(sibling);\n if (found === 'boundary') return null;\n if (found) return found;\n sibling = sibling.previousSibling;\n }\n const parent: Node | null = current.parentNode;\n if (!parent) return null;\n if (\n parent !== root &&\n parent.nodeType === Node.ELEMENT_NODE &&\n BLOCK_BOUNDARY.test((parent as HTMLElement).tagName)\n ) {\n return null;\n }\n current = parent;\n }\n return null;\n}\n\n/**\n * A presentational rich-text editor with formatting, template-variable\n * insertion and optional speech-to-text dictation. Content is supplied and\n * surfaced via `value`/`onChange` so it can be wired to any store. The variable\n * menu is data-agnostic — pass `variableGroups` to populate it.\n */\nconst RichTextEditor = React.forwardRef<HTMLDivElement, RichTextEditorProps>(\n (\n {\n value,\n onChange,\n placeholder,\n className,\n variableGroups,\n enableDictation = true,\n onDictationError,\n disabled = false,\n sanitizeHtml,\n macros,\n defaultMacrosOpen = false,\n macrosOnFocus = false,\n compactMacros = false,\n onMacroInsert,\n macroLabels,\n onCreateMacro,\n toolbar,\n defaultToolbar = 'visible',\n onToolbarChange,\n blockMenu = false,\n blockMenuLabels,\n markdownShortcuts = false,\n chromeless = false,\n id,\n readOnly = false,\n editorClassName,\n editorStyle,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n },\n ref\n ) => {\n const m = useMessages();\n // Shared guard: read-only blocks edits exactly like disabled does, but\n // keeps the region focusable and selectable.\n const inert = disabled || readOnly;\n const editorRef = React.useRef<HTMLDivElement>(null);\n const [isListening, setIsListening] = React.useState(false);\n const [speechSupported, setSpeechSupported] = React.useState(false);\n const recognitionRef = React.useRef<SpeechRecognitionLike | null>(null);\n const isListeningRef = React.useRef(false);\n const shouldRestartRef = React.useRef(false);\n const [macrosOpen, setMacrosOpen] = React.useState(\n defaultMacrosOpen && !macrosOnFocus\n );\n // Last caret/selection inside the editable region, retained while the\n // macro panel has focus so insertion lands where the clinician left off.\n const savedRangeRef = React.useRef<Range | null>(null);\n const macroPanelId = React.useId();\n // The macro panel is an absolute side panel from `md:` up but sits\n // in-flow below the editor on small screens, where it must animate its\n // height so the surrounding layout follows instead of holding full size\n // until the exit finishes and then snapping shut.\n const macroSidePanel = useMediaQuery('(min-width: 768px)');\n const prefersReducedMotion = usePrefersReducedMotion();\n\n const hasVariables = Boolean(variableGroups && variableGroups.length > 0);\n const hasMacros = Boolean(macros);\n // Focus mode at rest: the field is a bare one-line input — no block-menu\n // indent, no gutter `+` on hover — until focus grows it.\n const macrosResting = hasMacros && macrosOnFocus && !macrosOpen;\n const hasMacroEntries = Boolean(\n macros?.some((group) => group.macros.length > 0)\n );\n const isEmpty = isHtmlEmpty(value);\n const [uncontrolledToolbar, setUncontrolledToolbar] =\n React.useState(defaultToolbar);\n const toolbarVisible = (toolbar ?? uncontrolledToolbar) !== 'hidden';\n const setToolbarVisibility = (next: 'visible' | 'hidden') => {\n if (toolbar === undefined) setUncontrolledToolbar(next);\n onToolbarChange?.(next);\n };\n // Mirrored into a ref so async dictation code can read the live value\n // after awaiting microphone permission.\n const toolbarVisibleRef = React.useRef(toolbarVisible);\n // Same for disabled/readOnly: recognition callbacks outlive renders.\n const inertRef = React.useRef(inert);\n\n // --- Block gutter menu state ---\n const [blockMenuOpen, setBlockMenuOpen] = React.useState(false);\n // Offset of the gutter button within the editor body; aligns with the\n // editable region's top padding (p-4 / chromeless py-[7px]) before any\n // row is hovered.\n const [gutterTop, setGutterTop] = React.useState(chromeless ? 7 : 16);\n const gutterWrapperRef = React.useRef<HTMLDivElement>(null);\n // Density styles (condensed-view.css) shrink that padding under the\n // defaults above, which would leave the at-rest trigger hanging below a\n // one-line condensed field — measure it from the live editable.\n const measureRestGutterTop = React.useCallback(() => {\n const fallback = chromeless ? 7 : 16;\n if (!editorRef.current) return fallback;\n const padding = parseFloat(\n getComputedStyle(editorRef.current).paddingTop\n );\n return Number.isNaN(padding) ? fallback : Math.round(padding);\n }, [chromeless]);\n React.useLayoutEffect(() => {\n if (!blockMenu || !editorRef.current) return;\n setGutterTop((current) => {\n const next = measureRestGutterTop();\n return current === next ? current : next;\n });\n }, [blockMenu, measureRestGutterTop]);\n const hoverBlockNodeRef = React.useRef<Node | null>(null);\n /** Park the trigger back at its rest offset and forget the hovered row. */\n const resetGutter = React.useCallback(() => {\n hoverBlockNodeRef.current = null;\n const next = measureRestGutterTop();\n setGutterTop((current) => (current === next ? current : next));\n }, [measureRestGutterTop]);\n /** Content edits can delete the hovered row (or every row) while the\n * trigger still floats at the old offset — below a field that shrank,\n * now that chromeless mode no longer clips the wrapper. */\n const reconcileGutterWithContent = React.useCallback(() => {\n if (!blockMenu || !editorRef.current) return;\n const hovered = hoverBlockNodeRef.current;\n if (\n (hovered && !editorRef.current.contains(hovered)) ||\n !editorRef.current.hasChildNodes()\n ) {\n resetGutter();\n }\n }, [blockMenu, resetGutter]);\n // Where the chosen menu action is applied: the hovered block's start\n // (mouse) or the caret position (Ctrl/Cmd+/), captured at open time.\n const blockTargetRangeRef = React.useRef<Range | null>(null);\n const firstBlockItemRef = React.useRef<HTMLButtonElement>(null);\n\n React.useImperativeHandle(ref, () => editorRef.current as HTMLDivElement);\n\n React.useEffect(() => {\n setSpeechSupported(Boolean(getSpeechRecognition()));\n }, []);\n\n React.useEffect(() => {\n return () => {\n if (recognitionRef.current) {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n recognitionRef.current.stop();\n }\n };\n }, []);\n\n // Hiding the toolbar removes the Stop control and listening indicator,\n // so a running dictation must not keep inserting text (and restarting\n // through onend) with no way to stop it.\n React.useEffect(() => {\n toolbarVisibleRef.current = toolbarVisible;\n if (toolbarVisible) return;\n if (recognitionRef.current && isListeningRef.current) {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n recognitionRef.current.stop();\n setIsListening(false);\n }\n }, [toolbarVisible]);\n\n // Turning disabled/readOnly mid-dictation must stop recognition: the\n // Stop button is disabled while inert, and onresult would otherwise keep\n // editing a field the user can no longer change.\n React.useEffect(() => {\n inertRef.current = inert;\n if (!inert) return;\n if (recognitionRef.current && isListeningRef.current) {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n recognitionRef.current.stop();\n setIsListening(false);\n }\n }, [inert]);\n\n React.useEffect(() => {\n if (editorRef.current && editorRef.current.innerHTML !== value) {\n const hadFocus = document.activeElement === editorRef.current;\n editorRef.current.innerHTML = value;\n if (hadFocus) {\n // The replacement destroyed the nodes holding the caret, which\n // collapses the selection to the top of the document. Park it\n // after the last block instead so typing continues on the next\n // line below the newly applied content (e.g. a host-appended\n // macro line).\n const range = document.createRange();\n range.selectNodeContents(editorRef.current);\n range.collapse(false);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n savedRangeRef.current = range.cloneRange();\n }\n reconcileGutterWithContent();\n }\n }, [value, reconcileGutterWithContent]);\n\n const updateContent = () => {\n if (editorRef.current) onChange(editorRef.current.innerHTML);\n reconcileGutterWithContent();\n };\n\n // Pasted/dropped HTML otherwise lands in the live DOM unfiltered, where\n // hostile markup (position:fixed overlays, host CSS classes) is active.\n const insertSanitized = (html: string) => {\n if (!sanitizeHtml) return false;\n document.execCommand('insertHTML', false, sanitizeHtml(html));\n updateContent();\n return true;\n };\n const handlePaste = (e: React.ClipboardEvent) => {\n const html = e.clipboardData.getData('text/html');\n if (html && sanitizeHtml) {\n e.preventDefault();\n insertSanitized(html);\n }\n };\n const handleDrop = (e: React.DragEvent) => {\n const html = e.dataTransfer.getData('text/html');\n if (!html || !sanitizeHtml) return;\n e.preventDefault();\n const caret = (\n document as Document & {\n caretRangeFromPoint?: (\n x: number,\n y: number\n ) => ReturnType<Document['createRange']> | null;\n }\n ).caretRangeFromPoint?.(e.clientX, e.clientY);\n if (caret) {\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(caret);\n }\n editorRef.current?.focus();\n insertSanitized(html);\n };\n\n const execCommand = (command: string) => {\n if (inert) return;\n document.execCommand(command, false);\n editorRef.current?.focus();\n updateContent();\n };\n\n const handleConvertToMustache = () => {\n if (inert || !editorRef.current) return;\n editorRef.current.innerHTML = convertAngleBracketsToMustache(\n editorRef.current.innerHTML\n );\n updateContent();\n };\n\n const insertVariable = (variable: RichTextVariable) => {\n if (inert || !editorRef.current) return;\n editorRef.current.focus();\n const textToInsert = variable.insertValue ?? variable.value;\n\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n range.deleteContents();\n if (textToInsert.includes('\\n')) {\n const fragment = document.createDocumentFragment();\n const lines = textToInsert.split('\\n');\n lines.forEach((line, index) => {\n fragment.appendChild(document.createTextNode(line));\n if (index < lines.length - 1) {\n fragment.appendChild(document.createElement('br'));\n }\n });\n range.insertNode(fragment);\n range.collapse(false);\n } else {\n const textNode = document.createTextNode(textToInsert);\n range.insertNode(textNode);\n range.setStartAfter(textNode);\n range.setEndAfter(textNode);\n }\n selection.removeAllRanges();\n selection.addRange(range);\n } else {\n editorRef.current.innerHTML += textToInsert.replace(/\\n/g, '<br>');\n }\n updateContent();\n };\n\n const reportError = (message: string) => {\n if (onDictationError) onDictationError(message);\n else if (typeof console !== 'undefined') console.warn(message);\n };\n\n /** Bookmark the selection whenever it lives inside the editable region. */\n const saveSelection = () => {\n const selection = window.getSelection();\n if (!selection || selection.rangeCount === 0 || !editorRef.current)\n return;\n const range = selection.getRangeAt(0);\n if (editorRef.current.contains(range.commonAncestorContainer)) {\n savedRangeRef.current = range.cloneRange();\n }\n };\n\n /** Focus the editor and restore the bookmarked selection if still valid. */\n const focusRestoringSelection = () => {\n if (!editorRef.current) return;\n editorRef.current.focus();\n const saved = savedRangeRef.current;\n const selection = window.getSelection();\n if (\n saved &&\n selection &&\n editorRef.current.contains(saved.commonAncestorContainer)\n ) {\n selection.removeAllRanges();\n selection.addRange(saved);\n }\n };\n\n const insertMacro = (macro: Macro) => {\n if (inert || !editorRef.current) return;\n if (onMacroInsert?.(macro) === true) return;\n focusRestoringSelection();\n insertTextAtSelection(macro.content);\n };\n\n /**\n * Replace the current selection with plain text. execCommand participates\n * in the browser's native undo stack, so an insertion can be reverted\n * with a single undo.\n */\n const insertTextAtSelection = (content: string) => {\n let inserted = false;\n try {\n inserted = document.execCommand('insertText', false, content);\n } catch {\n inserted = false;\n }\n if (!inserted) {\n // Fallback (and jsdom path): manual range insertion. Content is\n // always inserted as text nodes, never parsed as HTML.\n const fragment = document.createDocumentFragment();\n const lines = content.split('\\n');\n lines.forEach((line, index) => {\n fragment.appendChild(document.createTextNode(line));\n if (index < lines.length - 1) {\n fragment.appendChild(document.createElement('br'));\n }\n });\n const sel = window.getSelection();\n if (sel && sel.rangeCount > 0) {\n const range = sel.getRangeAt(0);\n range.deleteContents();\n range.insertNode(fragment);\n range.collapse(false);\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (editorRef.current) {\n editorRef.current.appendChild(fragment);\n }\n }\n saveSelection();\n updateContent();\n };\n\n /**\n * The visible word immediately before the collapsed caret, spanning\n * adjacent inline nodes (`.<b>c</b>` is \".c\"). Returns the token, the\n * range coordinates to replace it, and whether it sits at the start of\n * its line (nothing but a block boundary before it).\n */\n const collectTokenBeforeCaret = () => {\n const selection = window.getSelection();\n if (!selection || selection.rangeCount === 0 || !selection.isCollapsed)\n return null;\n const caret = selection.getRangeAt(0);\n const node = caret.startContainer;\n if (\n node.nodeType !== Node.TEXT_NODE ||\n !editorRef.current?.contains(node)\n )\n return null;\n const typed = /(\\S+)$/.exec(\n (node.textContent ?? '').slice(0, caret.startOffset)\n );\n if (!typed) return null;\n let token = typed[1];\n let startNode: Node = node;\n let startOffset = caret.startOffset - typed[1].length;\n while (startOffset === 0) {\n const prev = previousVisibleText(startNode, editorRef.current);\n if (!prev) break;\n const text = prev.textContent ?? '';\n const continued = /(\\S+)$/.exec(text);\n if (!continued) break;\n token = continued[1] + token;\n startNode = prev;\n startOffset = text.length - continued[1].length;\n }\n const atLineStart =\n startOffset === 0 && !previousVisibleText(startNode, editorRef.current);\n return {\n token,\n startNode,\n startOffset,\n caretNode: node,\n caretOffset: caret.startOffset,\n atLineStart,\n selection,\n };\n };\n\n /** Select `collected`'s token so the next editing command replaces it. */\n const selectCollectedToken = (\n collected: NonNullable<ReturnType<typeof collectTokenBeforeCaret>>\n ) => {\n const replaceRange = document.createRange();\n replaceRange.setStart(collected.startNode, collected.startOffset);\n replaceRange.setEnd(collected.caretNode, collected.caretOffset);\n collected.selection.removeAllRanges();\n collected.selection.addRange(replaceRange);\n return replaceRange;\n };\n\n /**\n * Delete the selected range through execCommand so the removal joins\n * the native undo stack, with a manual fallback for jsdom. Leaves a\n * collapsed caret where the selection started.\n */\n const deleteSelectedRange = (replaceRange: Range) => {\n let deleted = false;\n try {\n deleted = document.execCommand('delete', false);\n } catch {\n deleted = false;\n }\n if (!deleted) {\n replaceRange.deleteContents();\n replaceRange.collapse(true);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(replaceRange);\n }\n };\n\n /**\n * Expand a typed macro shortcut (dot phrase). When the word immediately\n * before the caret matches a macro shortcut and the user presses space,\n * the shortcut is replaced with the macro content in a single undoable\n * edit; the triggering space is consumed.\n */\n const expandTypedShortcut = (\n event: React.KeyboardEvent<HTMLDivElement>\n ) => {\n if (!macros) return;\n const collected = collectTokenBeforeCaret();\n if (!collected) return;\n const lowered = collected.token.toLowerCase();\n const macro = macros\n .flatMap((group) => group.macros)\n .find((candidate) => candidate.shortcut?.toLowerCase() === lowered);\n if (!macro) return;\n\n event.preventDefault();\n if (onMacroInsert) {\n // Remove the typed token and publish that edit first, so a host\n // that takes over the insertion computes from a token-free value.\n deleteSelectedRange(selectCollectedToken(collected));\n saveSelection();\n updateContent();\n if (onMacroInsert(macro) === true) return;\n insertTextAtSelection(macro.content);\n return;\n }\n selectCollectedToken(collected);\n insertTextAtSelection(macro.content);\n };\n\n /**\n * Apply a markdown block rule when the token before the caret starts its\n * line and matches `MARKDOWN_BLOCK_RULES` (`##` + space → heading). The\n * token removal and the block command both run through execCommand so\n * the expansion stays natively undoable. Returns true when handled.\n */\n const applyMarkdownShortcut = (\n event: React.KeyboardEvent<HTMLDivElement>\n ) => {\n const collected = collectTokenBeforeCaret();\n if (!collected || !collected.atLineStart) return false;\n // Own-property check: tokens like \"constructor\" or \"toString\" resolve\n // inherited object members and must not be treated as rules.\n if (!Object.hasOwn(MARKDOWN_BLOCK_RULES, collected.token)) return false;\n const rule = MARKDOWN_BLOCK_RULES[collected.token];\n\n event.preventDefault();\n deleteSelectedRange(selectCollectedToken(collected));\n try {\n document.execCommand(rule.command, false, rule.value);\n } catch {\n // jsdom: no execCommand — the token is still consumed.\n }\n editorRef.current?.focus();\n saveSelection();\n updateContent();\n return true;\n };\n\n /** Space-keydown pipeline: markdown block rules, then macro shortcuts. */\n const handleEditorKeyDown = (\n event: React.KeyboardEvent<HTMLDivElement>\n ) => {\n if (inert) return;\n if (\n blockMenu &&\n event.key === '/' &&\n (event.ctrlKey || event.metaKey) &&\n !event.altKey\n ) {\n event.preventDefault();\n openBlockMenuAtCaret();\n return;\n }\n if (\n event.key !== ' ' ||\n // Space during IME composition selects/converts a candidate; never\n // hijack it for shortcut expansion.\n event.nativeEvent.isComposing ||\n event.ctrlKey ||\n event.metaKey ||\n event.altKey\n )\n return;\n if (markdownShortcuts && applyMarkdownShortcut(event)) return;\n expandTypedShortcut(event);\n };\n\n // --- Block gutter menu ---\n\n /** Track the hovered block and keep the gutter button beside it. */\n const handleGutterMouseMove = (event: React.MouseEvent<HTMLDivElement>) => {\n // While the menu is open its target must not follow the pointer.\n if (blockMenuOpen || !editorRef.current || !gutterWrapperRef.current)\n return;\n let target: Node | null = null;\n let top: number | null = null;\n // Last top-level node starting above the pointer; first node otherwise.\n for (const child of Array.from(editorRef.current.childNodes)) {\n const rect = nodeRect(child);\n if (!rect) continue;\n // Collapsed whitespace between blocks (formatted HTML) measures 0×0\n // at the origin; its top of 0 always passes the comparison below and\n // would steal the target from the visible row. Zero-width nodes that\n // still have a height (an empty rendered line) remain eligible.\n if (rect.width === 0 && rect.height === 0) continue;\n if (target === null || rect.top <= event.clientY) {\n target = child;\n top = rect.top;\n }\n }\n if (!target || top === null) {\n // Every row is gone (e.g. the controlled value was cleared) — don't\n // leave the trigger floating at the deleted row's offset.\n resetGutter();\n return;\n }\n hoverBlockNodeRef.current = target;\n const wrapperTop = gutterWrapperRef.current.getBoundingClientRect().top;\n const next = Math.max(Math.round(top - wrapperTop), 4);\n setGutterTop((current) => (current === next ? current : next));\n };\n\n /** Collapsed range at the very start of `node`. */\n const rangeAtStartOf = (node: Node) => {\n const range = document.createRange();\n range.setStart(node, 0);\n range.collapse(true);\n return range;\n };\n\n /** Dropdown open/close driven by the gutter trigger (mouse path). */\n const handleBlockMenuOpenChange = (open: boolean) => {\n if (open) {\n const block =\n hoverBlockNodeRef.current ?? editorRef.current?.firstChild ?? null;\n blockTargetRangeRef.current = block ? rangeAtStartOf(block) : null;\n } else if (\n editorRef.current &&\n document.activeElement?.closest('[role=\"menu\"]')\n ) {\n // Escape: focus sits on a menu item about to unmount — without a\n // hand-off it falls to <body> and typing stops editing. Outside\n // clicks have already moved focus, so they skip this branch.\n const editor = editorRef.current;\n editor.focus();\n const target = blockTargetRangeRef.current;\n const selection = window.getSelection();\n if (target && selection && editor.contains(target.startContainer)) {\n selection.removeAllRanges();\n selection.addRange(target);\n saveSelection();\n }\n }\n setBlockMenuOpen(open);\n };\n\n /** Ctrl/Cmd+/ — open the menu targeting the caret's block. */\n const openBlockMenuAtCaret = () => {\n const selection = window.getSelection();\n if (\n selection &&\n selection.rangeCount > 0 &&\n editorRef.current?.contains(selection.getRangeAt(0).startContainer)\n ) {\n const caret = selection.getRangeAt(0);\n blockTargetRangeRef.current = caret.cloneRange();\n // Move the gutter button beside the caret's top-level block so the\n // menu opens where the action will land.\n let node: Node = caret.startContainer;\n while (node.parentNode && node.parentNode !== editorRef.current) {\n node = node.parentNode;\n }\n const rect = nodeRect(node);\n const wrapperRect = gutterWrapperRef.current?.getBoundingClientRect();\n if (rect && wrapperRect) {\n setGutterTop(Math.max(Math.round(rect.top - wrapperRect.top), 4));\n }\n } else {\n blockTargetRangeRef.current = null;\n }\n setBlockMenuOpen(true);\n };\n\n /** Apply a block command from the menu to the captured target range. */\n const applyBlockFormat = (command: string, value?: string) => {\n if (inert || !editorRef.current) return;\n setBlockMenuOpen(false);\n editorRef.current.focus();\n const target = blockTargetRangeRef.current;\n const selection = window.getSelection();\n if (\n target &&\n selection &&\n editorRef.current.contains(target.startContainer)\n ) {\n selection.removeAllRanges();\n selection.addRange(target);\n }\n try {\n document.execCommand(command, false, value);\n } catch {\n // jsdom: no execCommand — nothing to apply.\n }\n saveSelection();\n updateContent();\n };\n\n // Menus move focus to their first item on open (WAI-ARIA menu pattern);\n // required for the Ctrl/Cmd+/ path, where focus is still in the editor.\n React.useEffect(() => {\n if (!blockMenuOpen) return;\n const frame = requestAnimationFrame(() =>\n firstBlockItemRef.current?.focus()\n );\n return () => cancelAnimationFrame(frame);\n }, [blockMenuOpen]);\n\n const toggleDictation = async () => {\n const SpeechRecognition = getSpeechRecognition();\n if (!SpeechRecognition) return;\n\n if (isListening && recognitionRef.current) {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n recognitionRef.current.stop();\n setIsListening(false);\n return;\n }\n\n try {\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: true,\n });\n stream.getTracks().forEach((track) => track.stop());\n } catch {\n reportError(\n 'Microphone access is required for dictation. Please allow microphone access in your browser settings and try again.'\n );\n return;\n }\n\n // The toolbar (and its Stop control) may have been hidden — or the\n // editor made disabled/readOnly — while awaiting microphone\n // permission; do not start an unstoppable or read-only session.\n if (!toolbarVisibleRef.current || inertRef.current) return;\n\n const recognition = new SpeechRecognition();\n recognition.continuous = true;\n recognition.interimResults = true;\n recognition.lang = 'en-US';\n recognition.maxAlternatives = 1;\n\n recognition.onstart = () => {\n setIsListening(true);\n isListeningRef.current = true;\n shouldRestartRef.current = true;\n };\n\n recognition.onresult = (event) => {\n if (inertRef.current) return;\n let finalTranscript = '';\n for (let i = event.resultIndex; i < event.results.length; i++) {\n const result = event.results[i];\n if (result.isFinal) finalTranscript += result[0].transcript;\n }\n\n if (finalTranscript && editorRef.current) {\n const processedText = processDictation(finalTranscript);\n editorRef.current.focus();\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n range.deleteContents();\n const textNode = document.createTextNode(processedText + ' ');\n range.insertNode(textNode);\n range.setStartAfter(textNode);\n range.setEndAfter(textNode);\n selection.removeAllRanges();\n selection.addRange(range);\n } else {\n editorRef.current.innerHTML += processedText + ' ';\n }\n updateContent();\n }\n };\n\n recognition.onerror = (event) => {\n if (event.error === 'no-speech' || event.error === 'aborted') return;\n if (event.error === 'not-allowed') {\n reportError(\n 'Microphone access was denied. Please allow microphone access in your browser settings and try again.'\n );\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n setIsListening(false);\n return;\n }\n if (event.error === 'network') return;\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n setIsListening(false);\n };\n\n recognition.onend = () => {\n if (\n shouldRestartRef.current &&\n isListeningRef.current &&\n !inertRef.current\n ) {\n setTimeout(() => {\n if (\n shouldRestartRef.current &&\n isListeningRef.current &&\n !inertRef.current\n ) {\n try {\n recognition.start();\n } catch {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n setIsListening(false);\n }\n }\n }, 100);\n } else {\n setIsListening(false);\n }\n };\n\n recognitionRef.current = recognition;\n try {\n recognition.start();\n } catch {\n reportError('Failed to start speech recognition. Please try again.');\n }\n };\n\n const iconButtonClass = 'h-8 w-8 p-0';\n\n const blockFormatItems: Array<{\n key: keyof RichTextEditorBlockMenuLabels;\n label: string;\n command: string;\n value?: string;\n }> = [\n { key: 'text', label: 'Text', command: 'formatBlock', value: 'p' },\n {\n key: 'heading1',\n label: 'Heading 1',\n command: 'formatBlock',\n value: 'h1',\n },\n {\n key: 'heading2',\n label: 'Heading 2',\n command: 'formatBlock',\n value: 'h2',\n },\n {\n key: 'heading3',\n label: 'Heading 3',\n command: 'formatBlock',\n value: 'h3',\n },\n {\n key: 'bulletList',\n label: 'Bullet list',\n command: 'insertUnorderedList',\n },\n {\n key: 'numberedList',\n label: 'Numbered list',\n command: 'insertOrderedList',\n },\n {\n key: 'quote',\n label: 'Quote',\n command: 'formatBlock',\n value: 'blockquote',\n },\n ];\n\n return (\n <div\n data-slot=\"rich-text-editor\"\n data-chromeless={chromeless || undefined}\n // Focus-driven macros: open while focus is anywhere inside the frame\n // (focus events bubble in React), close only when it truly leaves —\n // a macro pick or a toolbar click moves focus within and stays open.\n onFocus={\n hasMacros && macrosOnFocus ? () => setMacrosOpen(true) : undefined\n }\n onBlur={\n hasMacros && macrosOnFocus\n ? (event) => {\n const related = event.relatedTarget as HTMLElement | null;\n if (related && event.currentTarget.contains(related)) return;\n // The block gutter's dropdown — and its \"Insert macro\"\n // submenu — mount in portals under document.body (outside\n // this frame); focus moving into our own menu tree is an\n // internal move, not leaving the field. Walk each menu back\n // to its trigger (a submenu's trigger sits in the parent\n // menu's portal) until one lands inside this frame.\n let menu = related?.closest<HTMLElement>('[role=\"menu\"]');\n while (menu && menu.id) {\n const trigger = document.querySelector(\n `[aria-controls=\"${globalThis.CSS.escape(menu.id)}\"]`\n );\n if (!trigger) break;\n if (event.currentTarget.contains(trigger)) return;\n menu = trigger.closest<HTMLElement>('[role=\"menu\"]');\n }\n setMacrosOpen(false);\n }\n : undefined\n }\n className={cn(\n 'bg-background flex flex-col',\n !chromeless && 'border-border overflow-hidden rounded-lg border',\n className\n )}\n >\n {toolbarVisible && (\n <div\n data-slot=\"rich-text-editor-toolbar\"\n className=\"border-border bg-muted/30 sticky top-0 z-10 flex flex-wrap items-center gap-1 border-b p-2\"\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('bold')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Bold')}\n title={m('Bold')}\n >\n <Bold className=\"h-4 w-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('italic')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Italic')}\n title={m('Italic')}\n >\n <Italic className=\"h-4 w-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('underline')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Underline')}\n title={m('Underline')}\n >\n <Underline className=\"h-4 w-4\" />\n </Button>\n\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('insertUnorderedList')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Bullet list')}\n title={m('Bullet list')}\n >\n <List className=\"h-4 w-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('insertOrderedList')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Numbered list')}\n title={m('Numbered list')}\n >\n <ListOrdered className=\"h-4 w-4\" />\n </Button>\n\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('justifyLeft')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Align left')}\n title={m('Align left')}\n >\n <AlignLeft className=\"h-4 w-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('justifyCenter')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Align center')}\n title={m('Align center')}\n >\n <AlignCenter className=\"h-4 w-4\" />\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => execCommand('justifyRight')}\n disabled={disabled}\n className={iconButtonClass}\n aria-label={m('Align right')}\n title={m('Align right')}\n >\n <AlignRight className=\"h-4 w-4\" />\n </Button>\n\n {hasVariables && (\n <>\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n <Dropdown\n placement=\"bottom-start\"\n width={240}\n searchable\n searchPlaceholder=\"Search variables…\"\n searchAriaLabel=\"Search template variables\"\n disabled={disabled}\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-8 gap-1 px-2\"\n disabled={disabled}\n title={m('Insert variable')}\n >\n <Braces className=\"h-4 w-4\" />\n <span className=\"ms-1 text-xs\">{m('Variables')}</span>\n </Button>\n }\n >\n {variableGroups!.map((group, groupIndex) => (\n <React.Fragment key={group.label}>\n {groupIndex > 0 && <DropdownSeparator />}\n <DropdownLabel>{group.label}</DropdownLabel>\n {group.variables.map((variable) => (\n <DropdownItem\n key={variable.value}\n onClick={() => insertVariable(variable)}\n >\n {variable.label}\n </DropdownItem>\n ))}\n </React.Fragment>\n ))}\n </Dropdown>\n\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={handleConvertToMustache}\n disabled={disabled}\n className=\"h-8 gap-1 px-2\"\n title={m('Convert <<field>> to {{field}}')}\n >\n <Replace className=\"h-4 w-4\" />\n <span className=\"ms-1 text-xs\">{m('<< >> to {{ }}')}</span>\n </Button>\n </>\n )}\n\n {enableDictation && (\n <>\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n <Button\n type=\"button\"\n variant={isListening ? 'danger' : 'ghost'}\n size=\"sm\"\n onClick={toggleDictation}\n disabled={inert || !speechSupported}\n className={cn(\n 'h-8 gap-1 px-2',\n isListening && 'animate-pulse'\n )}\n title={\n !speechSupported\n ? m('Speech recognition not supported in this browser')\n : isListening\n ? m('Stop dictation')\n : m('Start dictation')\n }\n >\n {isListening ? (\n <MicOff className=\"h-4 w-4\" />\n ) : (\n <Mic className=\"h-4 w-4\" />\n )}\n <span className=\"ms-1 text-xs\">\n {isListening ? m('Stop') : m('Dictate')}\n </span>\n </Button>\n </>\n )}\n\n {hasMacros && (\n <>\n <Separator orientation=\"vertical\" className=\"mx-1 h-6\" />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => setMacrosOpen((open) => !open)}\n disabled={disabled}\n className={cn('h-8 gap-1 px-2', macrosOpen && 'bg-muted')}\n aria-expanded={macrosOpen}\n aria-controls={macrosOpen ? macroPanelId : undefined}\n title={\n macrosOpen\n ? (macroLabels?.hideMacros ?? 'Hide macros')\n : (macroLabels?.showMacros ?? 'Show macros')\n }\n >\n <BookOpen className=\"h-4 w-4\" />\n <span className=\"ms-1 text-xs\">\n {macroLabels?.macros ?? 'Macros'}\n </span>\n </Button>\n </>\n )}\n </div>\n )}\n\n <div className=\"relative flex min-h-0 flex-1 flex-col\">\n <div\n ref={gutterWrapperRef}\n className={cn(\n 'relative flex-1',\n blockMenu && 'group/rte-body',\n hasMacros && macrosOpen && 'md:me-72'\n )}\n onMouseMove={\n blockMenu && !disabled ? handleGutterMouseMove : undefined\n }\n >\n {blockMenu && !inert && !macrosResting && (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- mousedown here only guards editor focus (preventDefault); the real controls inside are native buttons.\n <div\n data-slot=\"rich-text-editor-block-gutter\"\n className=\"absolute start-1 z-10\"\n style={{ top: gutterTop }}\n // Keep the editor focused through gutter interaction. iOS\n // taps never focus buttons, so tapping the trigger or a menu\n // item would first blur the editor with a null relatedTarget,\n // collapsing focus-driven hosts and unmounting this gutter —\n // and its menu — before the click can land. Preventing\n // mousedown's focus default leaves the caret and virtual\n // keyboard in place; clicks still fire. The dropdown portals\n // under document.body, but React portal events bubble through\n // the React tree, so this one handler covers the menu too.\n onMouseDown={(event) => event.preventDefault()}\n >\n <Dropdown\n open={blockMenuOpen}\n onOpenChange={handleBlockMenuOpenChange}\n placement=\"bottom-start\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className={cn(\n 'h-6 w-6 p-0',\n // Revealed on hover/focus; always visible on touch,\n // which has no hover to reveal it with.\n 'opacity-0 transition-opacity',\n 'group-hover/rte-body:opacity-100',\n 'focus-visible:opacity-100',\n '[@media(hover:none)]:opacity-100',\n blockMenuOpen && 'opacity-100'\n )}\n aria-label={blockMenuLabels?.blockMenu ?? 'Block menu'}\n title={blockMenuLabels?.blockMenu ?? 'Block menu'}\n >\n <Plus className=\"h-4 w-4\" />\n </Button>\n }\n >\n {blockFormatItems.map((item, index) => (\n <DropdownItem\n key={item.key}\n ref={index === 0 ? firstBlockItemRef : undefined}\n onClick={() => applyBlockFormat(item.command, item.value)}\n >\n {blockMenuLabels?.[item.key] ?? item.label}\n </DropdownItem>\n ))}\n <DropdownSeparator />\n {hasMacros && macros && (\n <>\n <DropdownSubmenu\n label={blockMenuLabels?.insertMacro ?? 'Insert macro'}\n // No macros to offer — the panel's empty state (via\n // \"Show macro library\") explains the situation.\n disabled={!hasMacroEntries}\n >\n {/* Children are built per render even while closed\n (the menu JSX lives in the editor's tree), so\n skip the catalog walk until the menu is open. */}\n {blockMenuOpen &&\n macros.flatMap((group) => [\n // Group headings only earn their row when there\n // is more than one group to tell apart.\n ...(macros.length > 1\n ? [\n <DropdownLabel key={`h:${group.id}`}>\n {group.label}\n </DropdownLabel>,\n ]\n : []),\n ...group.macros.map((macro) => (\n <DropdownItem\n // Serialized pair: plain `${a}-${b}` joins\n // collide ('a-b','c' vs 'a','b-c') and can\n // alias a heading key.\n key={`m:${JSON.stringify([group.id, macro.id])}`}\n // The item's label slot is a flex item with\n // min-width:auto, so it refuses to shrink and\n // a long macro name overflows instead of\n // hitting the truncate below. Scoped here\n // rather than changed in DropdownItem, whose\n // other consumers size to content.\n className=\"[&>[data-slot=dropdown-item-label]]:min-w-0 [&>[data-slot=dropdown-item-label]]:flex-1\"\n onClick={() => {\n setBlockMenuOpen(false);\n // Insertion lands at the menu's target\n // block, mirroring the panel flow.\n if (blockTargetRangeRef.current) {\n savedRangeRef.current =\n blockTargetRangeRef.current;\n }\n // The menu unmounts with this pick; hand\n // focus back to the editor (host-handled\n // picks skip insertMacro's own focus) so a\n // focus-driven field can rest on the next\n // click away. Panel picks keep focus on\n // their row for keyboard multi-pick.\n focusRestoringSelection();\n insertMacro(macro);\n }}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {macro.shortcut && (\n <span\n // Shortcuts are typed sequences; keep\n // them LTR in RTL locales.\n dir=\"ltr\"\n className=\"border-border bg-background text-muted-foreground rounded border px-1 font-mono text-[11px]\"\n >\n {macro.shortcut}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">\n {macro.label}\n </span>\n </span>\n </DropdownItem>\n )),\n ])}\n </DropdownSubmenu>\n <DropdownItem\n onClick={() => {\n setBlockMenuOpen(false);\n // Macro insertion restores the bookmarked\n // selection; point it at the menu's target block.\n if (blockTargetRangeRef.current) {\n savedRangeRef.current = blockTargetRangeRef.current;\n }\n setMacrosOpen(true);\n // The activated item unmounts with the menu; move\n // focus back AND apply the bookmark to the live\n // selection — a bare focus() would leave the old\n // caret live, and the editor's onBlur (fired when\n // the panel's search field takes focus) would then\n // re-save it over the menu's target.\n focusRestoringSelection();\n }}\n >\n {blockMenuLabels?.showMacroLibrary ??\n 'Show macro library'}\n </DropdownItem>\n {/* The toolbar toggle is editor chrome, not a macro\n action — keep it visually apart. */}\n <DropdownSeparator />\n </>\n )}\n <DropdownItem\n onClick={() => {\n setBlockMenuOpen(false);\n setToolbarVisibility(\n toolbarVisible ? 'hidden' : 'visible'\n );\n // See the macro item: the menu unmounts on close.\n editorRef.current?.focus();\n }}\n >\n {toolbarVisible\n ? (blockMenuLabels?.hideToolbar ?? 'Hide toolbar')\n : (blockMenuLabels?.showToolbar ?? 'Show toolbar')}\n </DropdownItem>\n </Dropdown>\n </div>\n )}\n {isEmpty && placeholder && (\n <div\n aria-hidden=\"true\"\n className={cn(\n 'text-muted-foreground pointer-events-none absolute start-0 top-0',\n // Chromeless hosts drop the wrapper's clipping, so a long\n // placeholder must stay a single ellipsized line (as a\n // native textarea clips its own) instead of wrapping out\n // of the one-row field.\n chromeless ? 'end-0 truncate px-3 py-[7px] text-base' : 'p-4',\n blockMenu && !macrosResting && 'ps-10',\n // Keep the placeholder's font in step with the editable\n // when the host restyles it (e.g. Textarea's `size`).\n editorClassName\n )}\n >\n {placeholder}\n </div>\n )}\n <div\n ref={editorRef}\n id={id}\n role=\"textbox\"\n aria-multiline=\"true\"\n aria-label={ariaLabel ?? placeholder}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-invalid={ariaInvalid}\n aria-required={ariaRequired}\n aria-readonly={readOnly || undefined}\n // A native disabled control announces its state (and axe\n // exempts it from color-contrast); a contenteditable div\n // must say so explicitly.\n aria-disabled={disabled || undefined}\n contentEditable={!inert}\n // Styling hook: condensed-view.css must not pin the editable\n // to its compact single-line minimum while the macro panel\n // (absolutely stretched over this region) needs the md\n // macros-open working space below.\n data-macros-open={hasMacros && macrosOpen ? '' : undefined}\n tabIndex={disabled ? -1 : 0}\n onInput={updateContent}\n onPaste={handlePaste}\n onDrop={handleDrop}\n onBlur={hasMacros ? saveSelection : undefined}\n onKeyDown={\n hasMacros || markdownShortcuts || blockMenu\n ? handleEditorKeyDown\n : undefined\n }\n onKeyUp={hasMacros ? saveSelection : undefined}\n onMouseUp={hasMacros ? saveSelection : undefined}\n className={cn(\n 'overflow-y-auto focus:outline-none',\n // Chromeless surfaces start one Input row tall (Textarea md\n // metrics: 24px line + 7px padding + the host's 1px borders\n // = h-10) and auto-grow with content.\n chromeless\n ? 'min-h-[38px] px-3 py-[7px] text-base'\n : 'min-h-[250px] p-4',\n 'prose prose-sm max-w-none',\n // Baseline block styles: Tailwind preflight strips heading,\n // list and quote styling, and the `prose` classes above only\n // work when the host installs @tailwindcss/typography —\n // without these, block formats would apply invisibly.\n '[&_h1]:my-3 [&_h1]:text-2xl [&_h1]:font-bold',\n '[&_h2]:my-3 [&_h2]:text-xl [&_h2]:font-bold',\n '[&_h3]:my-2 [&_h3]:text-lg [&_h3]:font-semibold',\n '[&_ul]:my-2 [&_ul]:list-disc [&_ul]:ps-6',\n '[&_ol]:my-2 [&_ol]:list-decimal [&_ol]:ps-6',\n '[&_blockquote]:border-border [&_blockquote]:text-muted-foreground [&_blockquote]:my-2 [&_blockquote]:border-s-4 [&_blockquote]:ps-3',\n blockMenu && !macrosResting && 'ps-10',\n // Tall enough for the docked panel's search plus a few rows\n // without forcing the host form to scroll; the compact panel\n // is just rows, so it needs far less.\n hasMacros &&\n macrosOpen &&\n (compactMacros ? 'md:min-h-[140px]' : 'md:min-h-[250px]'),\n // Focus mode grows the field from one row on focus (and, with\n // the block gutter, indents it) — ease the jump instead of\n // snapping.\n hasMacros &&\n macrosOnFocus &&\n 'transition-[min-height,padding] duration-200 ease-out motion-reduce:transition-none',\n disabled &&\n 'bg-muted/20 cursor-not-allowed text-neutral-700 dark:text-neutral-300',\n editorClassName\n )}\n style={editorStyle}\n suppressContentEditableWarning\n />\n </div>\n\n {hasMacros && (\n <AnimatedPresence>\n {macrosOpen && (\n <Animated\n key=\"macro-panel\"\n // In-flow on mobile: `collapse` animates real height so the\n // field shrinks with the panel. `collapse` is a plain value\n // animation that reduced-motion config does not drop, so\n // honor the preference here (the side panel's `menu` nudge\n // is covered by the provider).\n preset={macroSidePanel ? 'menu' : 'collapse'}\n enabled={macroSidePanel || !prefersReducedMotion}\n mode=\"presence\"\n // The side the panel occupies, resolved to a physical edge\n // so the closed nudge retreats toward the editor.\n custom={\n typeof document !== 'undefined' && document.dir === 'rtl'\n ? 'left'\n : 'right'\n }\n fallbackClassName=\"animate-fade-in\"\n className=\"border-border flex max-h-72 flex-col overflow-hidden border-t md:absolute md:inset-y-0 md:end-0 md:max-h-none md:w-72 md:overflow-visible md:border-s md:border-t-0\"\n >\n <MacroLibrary\n id={macroPanelId}\n groups={macros!}\n onSelect={insertMacro}\n targetLabel={ariaLabel ?? placeholder}\n onClose={\n // Focus mode: visibility follows focus; a close that\n // refocuses the editor would just reopen the panel.\n macrosOnFocus\n ? undefined\n : () => {\n setMacrosOpen(false);\n // Selecting text in the panel moves the document\n // selection; put the caret back where the user\n // left it.\n focusRestoringSelection();\n }\n }\n onCreateMacro={onCreateMacro}\n labels={macroLabels}\n compact={compactMacros}\n className=\"min-h-0 flex-1\"\n />\n </Animated>\n )}\n </AnimatedPresence>\n )}\n </div>\n </div>\n );\n }\n);\n\nRichTextEditor.displayName = 'RichTextEditor';\n\nexport { RichTextEditor };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/RichEditor/CodeEditor.tsx","../src/components/TextAreaRich/speech.ts","../src/components/TextAreaRich/TextAreaRichKerebron.tsx"],"names":["view","toolbar","value","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,IAAM,aAAwC,CAAC;AAAA,EAC7C,KAAA,GAAQ,EAAA;AAAA,EACR,QAAA;AAAA,EACA,IAAA,GAAO;AACT,CAAA,KAAM;AACJ,EAAA,MAAM,SAAA,GAAY,OAAuB,IAAI,CAAA;AAC7C,EAAA,MAAM,cAAA,GAAiB,OAA0B,IAAI,CAAA;AACrD,EAAA,MAAM,WAAA,GAAc,OAAO,QAAQ,CAAA;AACnC,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAEtB,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAO,SAAA,CAAU,OAAA;AACvB,IAAA,IAAI,CAAC,IAAA,EAAM;AAEX,IAAA,MAAM,mBAAmB,MAAM;AAC7B,MAAA,IAAA,CAAK,gBAAA,CAAiB,uBAAuB,CAAA,CAAE,OAAA,CAAQ,CAAC,OAAA,KAAY;AAClE,QAAA,IAAI,CAAC,OAAA,CAAQ,YA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reEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n","/**\n * Minimal Web Speech API surface used for dictation. Mirrors the private\n * typings in `RichTextEditor` (the legacy engine keeps its own copy until it\n * is retired) — lib.dom omits these because browser support is uneven.\n */\nexport interface SpeechRecognitionResultLike {\n isFinal: boolean;\n 0: { transcript: string };\n}\nexport interface SpeechRecognitionEventLike {\n resultIndex: number;\n results: ArrayLike<SpeechRecognitionResultLike>;\n}\nexport interface SpeechRecognitionErrorEventLike {\n error: string;\n}\nexport interface SpeechRecognitionLike {\n continuous: boolean;\n interimResults: boolean;\n lang: string;\n maxAlternatives: number;\n onstart: (() => void) | null;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n start: () => void;\n stop: () => void;\n}\nexport type SpeechRecognitionCtor = new () => SpeechRecognitionLike;\ninterface SpeechWindow {\n SpeechRecognition?: SpeechRecognitionCtor;\n webkitSpeechRecognition?: SpeechRecognitionCtor;\n}\n\n/** The browser's SpeechRecognition constructor, when dictation is available. */\nexport function getSpeechRecognition(): SpeechRecognitionCtor | undefined {\n if (typeof window === 'undefined') return undefined;\n const w = window as unknown as SpeechWindow;\n return w.SpeechRecognition || w.webkitSpeechRecognition;\n}\n","import * as React from 'react';\nimport { Plugin, TextSelection } from 'prosemirror-state';\nimport type { Transaction } from 'prosemirror-state';\nimport type { Node as PMNode } from 'prosemirror-model';\nimport type { EditorView } from 'prosemirror-view';\nimport { Extension, type CoreEditor, type EditorKit } from '@kerebron/editor';\nimport { MenuItem } from '@kerebron/extension-menu';\nimport { Plus } from 'lucide-react';\n\nimport { cn } from '../../utils/cn';\nimport { useMessages } from '../../utils/messages';\nimport { Button } from '../Button';\nimport {\n Dropdown,\n DropdownItem,\n DropdownLabel,\n DropdownSeparator,\n DropdownSubmenu,\n} from '../Dropdown';\nimport { MacroLibrary, type Macro } from '../MacroLibrary';\nimport { Animated, AnimatedPresence } from '../../motion';\nimport { useDirection } from '../../hooks/useDirection';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { usePrefersReducedMotion } from '../../hooks/usePrefersReducedMotion';\nimport {\n RichEditor,\n type RichEditorHandle,\n type MenuElement,\n type ModifyMenu,\n} from '../RichEditor';\nimport {\n processDictation,\n type RichTextEditorBlockMenuLabels,\n} from '../RichTextEditor';\nimport type { TextAreaRichProps } from './TextAreaRich';\nimport { getSpeechRecognition, type SpeechRecognitionLike } from './speech';\n\n/**\n * Kerebron-backed TextAreaRich surface: ProseMirror underneath, the stock\n * Kerebron toolbar (hidden until requested), the block gutter menu, docked\n * macro panel, `.shortcut` expansion and dictation — same `TextAreaRichProps`\n * contract (`value`/`onChange` carry HTML) as the legacy surface, but\n * strictly controlled like a native input: an edit that `onChange` does not\n * echo back into `value` reverts (see {@link RichEditorProps.strictValue}).\n *\n * Exported as `TextAreaRich` from `@mieweb/ui/kerebron`, and the engine\n * behind the main bundle's `Textarea` — which is why the `@kerebron/*`\n * runtime peers are required: hosts install them and load\n * `@mieweb/ui/kerebron.css`. (Only the Yjs collab peers remain optional.)\n */\n\n/** Carries our keydown behaviors (macro shortcuts, Ctrl+/) into the editor. */\nclass TextAreaRichExtension extends Extension {\n name = 'textAreaRichShortcuts';\n constructor(\n private readonly onKeyDown: (\n view: EditorView,\n event: KeyboardEvent\n ) => boolean\n ) {\n super({});\n }\n override getProseMirrorPlugins(): Plugin[] {\n return [new Plugin({ props: { handleKeyDown: this.onKeyDown } })];\n }\n}\n\n/**\n * `CoreEditor.view` is typed `EditorView | DummyEditorView` (the dummy exists\n * only until `create()` returns, which is before `onReady` ever fires), so\n * every ready-time consumer can treat it as the real view.\n */\nconst viewOf = (editor: CoreEditor) => editor.view as EditorView;\n\n/**\n * CSS properties whose numeric values are valid without a `px` unit —\n * React's full unitless list, so `editorStyle` keeps the React.CSSProperties\n * contract (`{ flex: 1 }` must not become `flex: 1px`).\n */\nconst UNITLESS_STYLE_PROPS = new Set([\n 'animationIterationCount',\n 'aspectRatio',\n 'borderImageOutset',\n 'borderImageSlice',\n 'borderImageWidth',\n 'boxFlex',\n 'boxFlexGroup',\n 'boxOrdinalGroup',\n 'columnCount',\n 'columns',\n 'flex',\n 'flexGrow',\n 'flexPositive',\n 'flexShrink',\n 'flexNegative',\n 'flexOrder',\n 'fontWeight',\n 'gridArea',\n 'gridRow',\n 'gridRowEnd',\n 'gridRowSpan',\n 'gridRowStart',\n 'gridColumn',\n 'gridColumnEnd',\n 'gridColumnSpan',\n 'gridColumnStart',\n 'lineClamp',\n 'lineHeight',\n 'opacity',\n 'order',\n 'orphans',\n 'tabSize',\n 'widows',\n 'zIndex',\n 'zoom',\n // SVG-related\n 'fillOpacity',\n 'floodOpacity',\n 'stopOpacity',\n 'strokeDasharray',\n 'strokeDashoffset',\n 'strokeMiterlimit',\n 'strokeOpacity',\n 'strokeWidth',\n]);\n\n/**\n * Replace `[from, to]` (defaults: the current selection) with plain text,\n * mapping `\\n` to hard breaks, and put the caret after the insertion.\n */\nfunction insertPlainText(\n view: EditorView,\n text: string,\n from = view.state.selection.from,\n to = view.state.selection.to\n) {\n const { schema, selection, storedMarks } = view.state;\n // Typing at this caret would inherit the active marks (pending toggles\n // or the formatting at the position); composed insertions — dictation,\n // macros, shortcut phrases — must match instead of stripping them.\n const marks =\n (from === selection.from && to === selection.to ? storedMarks : null) ??\n view.state.doc.resolve(from).marks();\n const br = schema.nodes.br ?? schema.nodes.hard_break;\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n');\n const nodes: PMNode[] = [];\n lines.forEach((line, index) => {\n if (index > 0) {\n if (br) nodes.push(br.create(null, null, marks));\n else if (line) nodes.push(schema.text(' ', marks));\n }\n if (line) nodes.push(schema.text(line, marks));\n });\n let tr = view.state.tr.replaceWith(from, to, nodes);\n const end = Math.min(\n from + nodes.reduce((size, node) => size + node.nodeSize, 0),\n tr.doc.content.size\n );\n tr = tr.setSelection(TextSelection.near(tr.doc.resolve(end)));\n view.dispatch(tr.scrollIntoView());\n}\n\n/** One empty textblock — the ProseMirror notion of \"nothing typed yet\". */\nfunction docIsEmpty(view: EditorView) {\n const { doc } = view.state;\n return (\n doc.childCount === 1 &&\n !!doc.firstChild &&\n doc.firstChild.isTextblock &&\n doc.firstChild.content.size === 0\n );\n}\n\n/** Gutter menu rows → Kerebron command names. */\nconst BLOCK_FORMAT_ITEMS: Array<{\n key: keyof RichTextEditorBlockMenuLabels;\n label: string;\n command: string;\n}> = [\n { key: 'text', label: 'Text', command: 'setParagraph' },\n { key: 'heading1', label: 'Heading 1', command: 'setHeading1' },\n { key: 'heading2', label: 'Heading 2', command: 'setHeading2' },\n { key: 'heading3', label: 'Heading 3', command: 'setHeading3' },\n { key: 'bulletList', label: 'Bullet list', command: 'toggleBulletList' },\n { key: 'numberedList', label: 'Numbered list', command: 'toggleOrderedList' },\n { key: 'quote', label: 'Quote', command: 'toggleBlockquote' },\n];\n\nconst TextAreaRichKerebron = React.forwardRef<\n HTMLDivElement,\n TextAreaRichProps\n>(\n (\n {\n value = '',\n onChange,\n placeholder,\n className,\n enableDictation = true,\n onDictationError,\n disabled = false,\n macros,\n defaultMacrosOpen = false,\n macrosOnFocus = false,\n compactMacros = false,\n onMacroInsert,\n macroLabels,\n onCreateMacro,\n toolbar,\n defaultToolbar = 'hidden',\n onToolbarChange,\n blockMenuLabels,\n id,\n readOnly = false,\n editorClassName,\n editorStyle,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n },\n ref\n ) => {\n const inert = disabled || readOnly;\n\n const wrapperRef = React.useRef<HTMLDivElement>(null);\n const gutterWrapperRef = React.useRef<HTMLDivElement>(null);\n const editorHandleRef = React.useRef<RichEditorHandle>(null);\n const editorRef = React.useRef<CoreEditor | null>(null);\n const [ready, setReady] = React.useState(false);\n // Hosts reach the editable region through the ref (focus, `dir`,\n // ARIA attributes), as with the legacy surface's contenteditable; the\n // wrapper only stands in until the editor mounts.\n React.useImperativeHandle(\n ref,\n () =>\n ready && editorRef.current\n ? (viewOf(editorRef.current).dom as HTMLDivElement)\n : wrapperRef.current!,\n [ready]\n );\n\n const [macrosOpen, setMacrosOpen] = React.useState(\n defaultMacrosOpen && !macrosOnFocus\n );\n const [uncontrolledToolbar, setUncontrolledToolbar] =\n React.useState(defaultToolbar);\n const toolbarVisible = (toolbar ?? uncontrolledToolbar) === 'visible';\n const [isListening, setIsListening] = React.useState(false);\n const [speechSupported, setSpeechSupported] = React.useState(false);\n const [isEmpty, setIsEmpty] = React.useState(true);\n // Offset of the editable below the (optional) toolbar, inside the wrapper.\n const [editorTop, setEditorTop] = React.useState(0);\n const [blockMenuOpen, setBlockMenuOpen] = React.useState(false);\n const [gutterTop, setGutterTop] = React.useState(4);\n\n const recognitionRef = React.useRef<SpeechRecognitionLike | null>(null);\n const isListeningRef = React.useRef(false);\n const shouldRestartRef = React.useRef(false);\n // Invalidates dictation starts still awaiting microphone permission.\n const dictationSessionRef = React.useRef(0);\n const hoverBlockRef = React.useRef<HTMLElement | null>(null);\n const blockTargetPosRef = React.useRef<number | null>(null);\n const firstBlockItemRef = React.useRef<HTMLButtonElement>(null);\n const macroPanelId = React.useId();\n\n const macroSidePanel = useMediaQuery('(min-width: 768px)');\n const prefersReducedMotion = usePrefersReducedMotion();\n // The field's inherited direction (not the document's): a local\n // dir=\"rtl\" subtree docks the panel at inline-end = left, so the motion\n // preset must slide it in from the same side.\n const direction = useDirection(wrapperRef);\n\n const hasMacros = Boolean(macros);\n const hasMacroEntries = Boolean(\n macros?.some((group) => group.macros.length > 0)\n );\n // The gutter `+` stays discoverable on hover even while a focus-docked\n // field rests as a one-line input.\n const gutterActive = !inert;\n\n // Mount-time closures (the toolbar and keydown plugin are built once)\n // read the latest props/state through refs.\n const macrosRef = React.useRef(macros);\n macrosRef.current = macros;\n const hasMacrosRef = React.useRef(hasMacros);\n hasMacrosRef.current = hasMacros;\n const onMacroInsertRef = React.useRef(onMacroInsert);\n onMacroInsertRef.current = onMacroInsert;\n const onChangeRef = React.useRef(onChange);\n onChangeRef.current = onChange;\n const inertRef = React.useRef(inert);\n inertRef.current = inert;\n const macrosOpenRef = React.useRef(macrosOpen);\n macrosOpenRef.current = macrosOpen;\n const toolbarVisibleRef = React.useRef(toolbarVisible);\n toolbarVisibleRef.current = toolbarVisible;\n const dictationAvailableRef = React.useRef(false);\n dictationAvailableRef.current = enableDictation && speechSupported;\n const onDictationErrorRef = React.useRef(onDictationError);\n onDictationErrorRef.current = onDictationError;\n // Dictation labels have no prop route (macro labels do), so the host's\n // MessagesProvider is the translation path — like RichTextEditor's.\n const m = useMessages();\n\n const reportError = (message: string) => {\n if (onDictationErrorRef.current) onDictationErrorRef.current(message);\n else if (typeof console !== 'undefined') console.warn(message);\n };\n\n const setToolbarVisibility = (next: 'visible' | 'hidden') => {\n if (toolbar === undefined) setUncontrolledToolbar(next);\n onToolbarChange?.(next);\n };\n\n const focusEditor = () => editorHandleRef.current?.focus();\n\n /** The live ProseMirror view, once the editor is mounted. */\n const currentView = () =>\n editorRef.current ? viewOf(editorRef.current) : null;\n\n // RichEditor publishes edits asynchronously, but a host that takes over\n // macro insertion (`onMacroInsert` returning true) composes from its last\n // published value — so a token-removal edit must reach `onChange` before\n // the hook runs. These waiters bridge that gap.\n const changeWaitersRef = React.useRef<(() => void)[]>([]);\n // The doc as of the last `onChange` emission — when the live doc is ahead\n // of this, a publish is still in flight.\n const publishedDocRef = React.useRef<unknown>(null);\n const handleChange = (next: string) => {\n publishedDocRef.current = currentView()?.state.doc ?? null;\n onChangeRef.current?.(next);\n const waiters = changeWaitersRef.current;\n changeWaitersRef.current = [];\n for (const resolve of waiters) resolve();\n };\n /** Resolves after the next `onChange` emission (or a short fallback). */\n const afterNextChange = () =>\n new Promise<void>((resolve) => {\n const timer = setTimeout(resolve, 250);\n changeWaitersRef.current.push(() => {\n clearTimeout(timer);\n resolve();\n });\n });\n\n // --- Macro insertion ---\n\n const insertMacro = (macro: Macro) => {\n if (inertRef.current) return;\n if (!onMacroInsertRef.current) {\n const view = currentView();\n if (!view) return;\n view.focus();\n insertPlainText(view, macro.content);\n return;\n }\n // A host hook composes from the last *published* value — let any\n // in-flight publish land first, so a pick right after typing doesn't\n // overwrite the unpublished keystrokes.\n const view = currentView();\n const pending = view && view.state.doc !== publishedDocRef.current;\n const invoke = () => {\n if (inertRef.current) return; // went inert (or unmounted) waiting\n const liveView = currentView();\n if (!liveView) return;\n // Focus before composing: a pick must return the caret to the\n // editable even when a host hook handles the insertion itself\n // (mobile keyboards would otherwise dismiss between picks).\n liveView.focus();\n if (onMacroInsertRef.current?.(macro) === true) return;\n insertPlainText(liveView, macro.content);\n };\n if (pending) void afterNextChange().then(invoke);\n else invoke();\n };\n\n /** Typed `.shortcut` + space → macro expansion (space consumed). */\n const expandTypedShortcut = (view: EditorView): boolean => {\n const groups = macrosRef.current;\n if (!groups) return false;\n const { selection } = view.state;\n if (!selection.empty) return false;\n const { $from } = selection;\n // Leaf nodes (hard breaks) read as a newline: still one character, so\n // the position math below holds, and `\\S+` cannot run across a soft\n // line break — `.c` typed after Shift+Enter still expands.\n const textBefore = $from.parent.textBetween(\n 0,\n $from.parentOffset,\n undefined,\n '\\n'\n );\n const match = /(\\S+)$/.exec(textBefore);\n if (!match) return false;\n const lowered = match[1].toLowerCase();\n const macro = groups\n .flatMap((group) => group.macros)\n .find((candidate) => candidate.shortcut?.toLowerCase() === lowered);\n if (!macro) return false;\n\n const from = $from.pos - match[1].length;\n // Without a host hook the whole expansion is one synchronous\n // transaction (token replaced by content — one undo step, no race).\n if (!onMacroInsertRef.current) {\n insertPlainText(view, macro.content, from, $from.pos);\n return true;\n }\n // A host hook composes from the last *published* value, so the token\n // removal must reach `onChange` first. While that publish is pending,\n // further edits (or a moved caret) must not misplace the insertion:\n // map the deletion point through every transaction and give up if it\n // is deleted out from under us.\n const editor = editorRef.current;\n view.dispatch(view.state.tr.delete(from, $from.pos));\n if (!editor) return true;\n let insertAt = from;\n let targetValid = true;\n const trackInsertionPoint = (event: Event) => {\n const tr = (\n event as globalThis.CustomEvent<{ transaction?: Transaction }>\n ).detail?.transaction;\n if (!tr) return;\n const mapped = tr.mapping.mapResult(insertAt);\n if (mapped.deleted) targetValid = false;\n insertAt = mapped.pos;\n };\n editor.addEventListener('transaction', trackInsertionPoint);\n void afterNextChange().then(() => {\n editor.removeEventListener('transaction', trackInsertionPoint);\n // The field may have gone disabled/readOnly (or remounted) while\n // the token-removal publish was pending — `editable: false` does\n // not block programmatic dispatch, so recheck before composing.\n if (inertRef.current || editorRef.current !== editor) return;\n if (onMacroInsertRef.current?.(macro) === true) return;\n if (!targetValid) return;\n const liveView = viewOf(editor);\n liveView.focus();\n const at = Math.min(insertAt, liveView.state.doc.content.size);\n insertPlainText(liveView, macro.content, at, at);\n });\n return true;\n };\n\n // --- Block gutter menu ---\n\n const resetGutter = () => {\n hoverBlockRef.current = null;\n setGutterTop(editorTop + 4);\n };\n\n const handleGutterMouseMove = (event: React.MouseEvent) => {\n if (blockMenuOpen) return;\n const view = currentView();\n const wrapper = gutterWrapperRef.current;\n if (!view || !wrapper) return;\n let target: HTMLElement | null = null;\n let top: number | null = null;\n for (const child of Array.from(view.dom.children)) {\n const rect = child.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) continue;\n if (rect.top <= event.clientY) {\n target = child as HTMLElement;\n top = rect.top;\n }\n }\n if (!target || top === null) {\n resetGutter();\n return;\n }\n hoverBlockRef.current = target;\n const wrapperTop = wrapper.getBoundingClientRect().top;\n const next = Math.max(Math.round(top - wrapperTop), editorTop + 4);\n setGutterTop((current) => (current === next ? current : next));\n };\n\n /** Dropdown open/close driven by the gutter trigger (mouse path). */\n const handleBlockMenuOpenChange = (open: boolean) => {\n const view = currentView();\n if (open) {\n const block = hoverBlockRef.current;\n blockTargetPosRef.current =\n view && block && view.dom.contains(block)\n ? view.posAtDOM(block, 0)\n : null;\n } else if (view && document.activeElement?.closest('[role=\"menu\"]')) {\n // Escape: focus sits on a menu item about to unmount — hand it back\n // to the editor so typing resumes.\n view.focus();\n }\n setBlockMenuOpen(open);\n };\n\n /** Ctrl/Cmd+/ — open the menu targeting the caret's block. */\n const openBlockMenuAtCaret = () => {\n const view = currentView();\n const wrapper = gutterWrapperRef.current;\n if (view && wrapper) {\n const { from } = view.state.selection;\n blockTargetPosRef.current = from;\n try {\n const coords = view.coordsAtPos(from);\n const wrapperTop = wrapper.getBoundingClientRect().top;\n setGutterTop(\n Math.max(Math.round(coords.top - wrapperTop), editorTop + 4)\n );\n } catch {\n // Position lookup can fail mid-update; the menu still opens.\n }\n }\n setBlockMenuOpen(true);\n };\n\n /** Put the selection at the menu's captured target block. */\n const applyBlockTarget = (view: EditorView) => {\n const pos = blockTargetPosRef.current;\n if (pos === null) return;\n const clamped = Math.min(pos, view.state.doc.content.size);\n view.dispatch(\n view.state.tr.setSelection(\n TextSelection.near(view.state.doc.resolve(clamped))\n )\n );\n };\n\n const applyBlockFormat = (command: string) => {\n const editor = editorRef.current;\n if (inert || !editor) return;\n setBlockMenuOpen(false);\n const view = viewOf(editor);\n view.focus();\n applyBlockTarget(view);\n (editor.run as Record<string, undefined | (() => boolean)>)[command]?.();\n };\n\n // Menus move focus to their first item on open (WAI-ARIA menu pattern);\n // required for the Ctrl/Cmd+/ path, where focus is still in the editor.\n React.useEffect(() => {\n if (!blockMenuOpen) return;\n const frame = requestAnimationFrame(() =>\n firstBlockItemRef.current?.focus()\n );\n return () => cancelAnimationFrame(frame);\n }, [blockMenuOpen]);\n\n // --- Dictation ---\n\n const toggleDictation = React.useRef(async () => {\n const SpeechRecognition = getSpeechRecognition();\n if (!SpeechRecognition) return;\n\n // Stop anything live — or still pending between `start()` and\n // `onstart`, when nothing is listening yet.\n if (isListeningRef.current || recognitionRef.current) {\n stopDictation();\n return;\n }\n\n const session = ++dictationSessionRef.current;\n try {\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: true,\n });\n stream.getTracks().forEach((track) => track.stop());\n } catch {\n reportError(\n 'Microphone access is required for dictation. Please allow microphone access in your browser settings and try again.'\n );\n return;\n }\n\n // The toolbar (and its Stop control) may have been hidden — or the\n // editor made disabled/readOnly or unmounted — while awaiting\n // microphone permission; do not start an unstoppable, read-only or\n // orphaned session.\n if (session !== dictationSessionRef.current) return;\n if (!toolbarVisibleRef.current || inertRef.current) return;\n\n const recognition = new SpeechRecognition();\n recognition.continuous = true;\n recognition.interimResults = true;\n recognition.lang = 'en-US';\n recognition.maxAlternatives = 1;\n\n recognition.onstart = () => {\n // A stop issued between `start()` and this callback already tore the\n // session down — do not arm an unstoppable restart loop.\n if (session !== dictationSessionRef.current) {\n try {\n recognition.stop();\n } catch {\n // Already stopped.\n }\n return;\n }\n setIsListening(true);\n isListeningRef.current = true;\n shouldRestartRef.current = true;\n };\n\n recognition.onresult = (event) => {\n // Results landing after Stop retired this session (or after a\n // restart swapped recognitions) must not focus the editor or\n // insert text.\n if (\n session !== dictationSessionRef.current ||\n recognitionRef.current !== recognition\n ) {\n return;\n }\n if (inertRef.current) return;\n let finalTranscript = '';\n for (let i = event.resultIndex; i < event.results.length; i++) {\n const result = event.results[i];\n if (result.isFinal) finalTranscript += result[0].transcript;\n }\n const view = currentView();\n if (finalTranscript && view) {\n view.focus();\n insertPlainText(view, processDictation(finalTranscript) + ' ');\n }\n };\n\n recognition.onerror = (event) => {\n // A retired session's failures must not clear the live session's\n // listening state.\n if (\n session !== dictationSessionRef.current ||\n recognitionRef.current !== recognition\n ) {\n return;\n }\n if (event.error === 'no-speech' || event.error === 'aborted') return;\n if (event.error === 'not-allowed') {\n reportError(\n 'Microphone access was denied. Please allow microphone access in your browser settings and try again.'\n );\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n setIsListening(false);\n return;\n }\n if (event.error === 'network') return;\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n setIsListening(false);\n };\n\n recognition.onend = () => {\n // The listening refs are shared across sessions: a stop + restart\n // inside this callback's window would read the NEW session's flags\n // and resurrect this retired recognition beside it. Only the\n // recognition still owning the session may restart — checked both\n // here and again after the delay.\n if (\n session === dictationSessionRef.current &&\n shouldRestartRef.current &&\n isListeningRef.current &&\n !inertRef.current\n ) {\n setTimeout(() => {\n if (\n session === dictationSessionRef.current &&\n shouldRestartRef.current &&\n isListeningRef.current &&\n !inertRef.current\n ) {\n try {\n recognition.start();\n } catch {\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n if (recognitionRef.current === recognition)\n recognitionRef.current = null;\n setIsListening(false);\n }\n }\n }, 100);\n } else {\n // Ended for good — release the ref so the next toggle starts a\n // fresh session instead of \"stopping\" a dead one. A retired\n // session must not touch the live one's listening state.\n if (recognitionRef.current === recognition)\n recognitionRef.current = null;\n if (session === dictationSessionRef.current) setIsListening(false);\n }\n };\n\n recognitionRef.current = recognition;\n try {\n recognition.start();\n } catch {\n recognitionRef.current = null;\n reportError('Failed to start speech recognition. Please try again.');\n }\n }).current;\n\n const stopDictation = React.useCallback(() => {\n // Invalidate any start still awaiting microphone permission — or a\n // recognition whose `onstart` hasn't fired yet — and tear down\n // unconditionally: `isListeningRef` is false in that pending window,\n // so an early-return would leave the recognition to arm itself with\n // no Stop control visible.\n dictationSessionRef.current += 1;\n shouldRestartRef.current = false;\n isListeningRef.current = false;\n const recognition = recognitionRef.current;\n recognitionRef.current = null;\n try {\n recognition?.stop();\n } catch {\n // Stopping before `onstart` can throw; the session bump above\n // already keeps it from arming.\n }\n setIsListening(false);\n }, []);\n\n React.useEffect(() => {\n setSpeechSupported(Boolean(getSpeechRecognition()));\n }, []);\n\n // Hiding the toolbar hides the Stop control; never leave an orphaned\n // session running. Same when the editor turns disabled/readOnly or the\n // dictation feature itself is switched off (which hides the button).\n React.useEffect(() => {\n if (!toolbarVisible || inert || !enableDictation) stopDictation();\n }, [toolbarVisible, inert, enableDictation, stopDictation]);\n\n // End-of-life cleanup.\n React.useEffect(() => stopDictation, [stopDictation]);\n\n // --- Kerebron toolbar additions (built once, read state through refs) ---\n\n const openBlockMenuAtCaretRef = React.useRef(openBlockMenuAtCaret);\n openBlockMenuAtCaretRef.current = openBlockMenuAtCaret;\n const expandTypedShortcutRef = React.useRef(expandTypedShortcut);\n expandTypedShortcutRef.current = expandTypedShortcut;\n\n const [menuAddon] = React.useState(() => {\n // Icon-only (filled Material-style paths, like Kerebron's stock\n // items): text labels clip to an empty square in the 32px overflow\n // grid and force the popup onto extra rows.\n const macrosItem = new MenuItem({\n icon: {\n width: 24,\n height: 24,\n // Material Symbols \"text snippet\" (Apache-2.0)\n path: 'M20.41 8.41l-4.83-4.83c-.37-.37-.88-.58-1.41-.58H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V9.83c0-.53-.21-1.04-.59-1.42zM7 7h7v2H7V7zm10 10H7v-2h10v2zm0-4H7v-2h10v2z',\n },\n title: macroLabels?.showMacros ?? 'Show macros',\n class: 'tar-menu-macros',\n select: () => hasMacrosRef.current,\n enable: () => !inertRef.current,\n active: () => macrosOpenRef.current,\n run: () => {\n setMacrosOpen((open) => !open);\n return true;\n },\n });\n const dictateItem = new MenuItem({\n icon: {\n width: 24,\n height: 24,\n // Material Symbols \"mic\" (Apache-2.0)\n path: 'M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z',\n },\n title: m('Start dictation'),\n class: 'tar-menu-dictate',\n select: () => dictationAvailableRef.current,\n enable: () => !inertRef.current,\n active: () => isListeningRef.current,\n run: () => {\n void toggleDictation();\n return true;\n },\n });\n const modifyMenu: ModifyMenu = (menus: MenuElement[][]) => [\n ...menus,\n // The patched MenuItem types `render().dom` as nullable, which no\n // longer satisfies MenuElement; our items always render a button.\n [macrosItem, dictateItem] as unknown as MenuElement[],\n ];\n const kit: EditorKit = {\n getExtensions: () => [\n new TextAreaRichExtension((view, event) => {\n if (inertRef.current) return false;\n if (\n event.key === '/' &&\n (event.ctrlKey || event.metaKey) &&\n !event.altKey\n ) {\n openBlockMenuAtCaretRef.current();\n return true;\n }\n if (\n event.key !== ' ' ||\n event.isComposing ||\n event.ctrlKey ||\n event.metaKey ||\n event.altKey\n ) {\n return false;\n }\n return expandTypedShortcutRef.current(view);\n }),\n ],\n };\n return { modifyMenu, kits: [kit] };\n });\n\n // The toolbar only repaints items on document/selection changes, so\n // React-side state (panel open, dictation) is synced into our injected\n // buttons directly. Kerebron's overflow popup builds FRESH buttons each\n // time it opens — construction-time labels and no aria-pressed — so a\n // childList observer re-syncs every rendered copy on arrival.\n React.useEffect(() => {\n const root = wrapperRef.current;\n if (!root || !ready) return;\n const sync = () => {\n // Disabled/readOnly must neutralize the stock toolbar too — its\n // buttons dispatch regardless of the view's `editable` prop. `inert`\n // blocks both pointer and keyboard access.\n for (const toolbar of root.querySelectorAll<HTMLElement>(\n '.kb-custom-menu, .kb-custom-menu__overflow-menu'\n )) {\n toolbar.inert = inert;\n }\n // The menu plugin re-runs item `update` callbacks only on document/\n // selection changes, so a button rendered while disabled/readOnly\n // keeps its disabled state when the field becomes editable without a\n // transaction — reconcile it here for every rendered copy.\n for (const macrosButton of root.querySelectorAll<HTMLElement>(\n '.tar-menu-macros'\n )) {\n macrosButton.style.display = hasMacros ? '' : 'none';\n macrosButton.classList.toggle('kb-menu__button--disabled', inert);\n macrosButton.setAttribute('aria-disabled', String(inert));\n macrosButton.classList.toggle('kb-menu__button--active', macrosOpen);\n macrosButton.setAttribute('aria-pressed', String(macrosOpen));\n const title = macrosOpen\n ? (macroLabels?.hideMacros ?? 'Hide macros')\n : (macroLabels?.showMacros ?? 'Show macros');\n macrosButton.setAttribute('title', title);\n macrosButton.setAttribute('aria-label', title);\n }\n for (const dictateButton of root.querySelectorAll<HTMLElement>(\n '.tar-menu-dictate'\n )) {\n dictateButton.style.display =\n enableDictation && speechSupported ? '' : 'none';\n dictateButton.classList.toggle('kb-menu__button--disabled', inert);\n dictateButton.setAttribute('aria-disabled', String(inert));\n dictateButton.classList.toggle(\n 'kb-menu__button--active',\n isListening\n );\n dictateButton.setAttribute('aria-pressed', String(isListening));\n const title = isListening\n ? m('Stop dictation')\n : m('Start dictation');\n dictateButton.setAttribute('title', title);\n dictateButton.setAttribute('aria-label', title);\n }\n };\n sync();\n // Attribute writes don't retrigger a childList-only observer, so the\n // re-sync cannot loop.\n const observer = new MutationObserver((mutations) => {\n if (mutations.some((mutation) => mutation.addedNodes.length > 0)) {\n sync();\n }\n });\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [\n ready,\n inert,\n hasMacros,\n macrosOpen,\n macroLabels,\n enableDictation,\n speechSupported,\n isListening,\n toolbarVisible,\n m,\n ]);\n\n // --- Editor wiring ---\n\n const handleReady = (editor: CoreEditor) => {\n editorRef.current = editor;\n // The initial load publishes nothing; the loaded doc is the baseline.\n publishedDocRef.current = viewOf(editor).state.doc;\n setIsEmpty(docIsEmpty(viewOf(editor)));\n editor.addEventListener('transaction', () => {\n if (editorRef.current !== editor) return;\n setIsEmpty(docIsEmpty(viewOf(editor)));\n });\n setReady(true);\n };\n\n // The editable region's identity: ARIA naming, validation state and the\n // host-given id all live on the ProseMirror surface, like the legacy\n // contenteditable. setProps merges, so this never clobbers editability.\n React.useEffect(() => {\n const view = currentView();\n if (!view || !ready) return;\n view.setProps({\n attributes: {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(id ? { id } : {}),\n ...((ariaLabel ?? placeholder)\n ? { 'aria-label': (ariaLabel ?? placeholder) as string }\n : {}),\n ...(ariaLabelledBy ? { 'aria-labelledby': ariaLabelledBy } : {}),\n ...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),\n ...(ariaInvalid ? { 'aria-invalid': String(ariaInvalid) } : {}),\n // Booleanish: the string \"false\" must not read as required.\n ...(ariaRequired !== undefined\n ? { 'aria-required': String(ariaRequired) }\n : {}),\n ...(readOnly ? { 'aria-readonly': 'true' } : {}),\n ...(disabled ? { 'aria-disabled': 'true' } : {}),\n // Read-only keeps keyboard focus and text selection available;\n // ProseMirror drops natural tabbability once `editable` is false.\n tabindex: disabled ? '-1' : '0',\n // setProps replaces the create-time attributes, so the base\n // kb-editor class must be restated alongside any custom class.\n class: editorClassName ? `kb-editor ${editorClassName}` : 'kb-editor',\n },\n });\n }, [\n ready,\n id,\n ariaLabel,\n placeholder,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaInvalid,\n ariaRequired,\n readOnly,\n disabled,\n editorClassName,\n ]);\n\n // Read-only keeps the region focusable/selectable but blocks edits —\n // enforced by RichEditor's own `readOnly` prop from creation (so the\n // surface is locked even while the initial document load is in flight).\n\n const appliedEditorStyle = React.useRef<\n Array<[HTMLElement['style'], string]>\n >([]);\n React.useEffect(() => {\n const view = currentView();\n const wrapper = wrapperRef.current;\n if (!view || !wrapper || !ready) return;\n // React style contract: camelCase keys, numbers in px (unless the\n // property is unitless — and custom properties pass through as\n // authored, never gaining a unit), and removed keys actually un-apply.\n const editableStyle = (view.dom as HTMLElement).style;\n for (const [style, property] of appliedEditorStyle.current) {\n style.removeProperty(property);\n }\n appliedEditorStyle.current = [];\n if (!editorStyle) return;\n for (const [key, raw] of Object.entries(editorStyle)) {\n if (raw === null || raw === undefined) continue;\n const isCustomProperty = key.startsWith('--');\n const property = isCustomProperty\n ? key\n : key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n const value =\n typeof raw === 'number' &&\n !isCustomProperty &&\n !UNITLESS_STYLE_PROPS.has(key)\n ? `${raw}px`\n : String(raw);\n // Custom properties land on the wrapper so they inherit to the\n // editable (whose kerebron.css metrics read them) AND the overlaid\n // placeholder; everything else styles the editable directly.\n const style = isCustomProperty ? wrapper.style : editableStyle;\n style.setProperty(property, value);\n appliedEditorStyle.current.push([style, property]);\n }\n }, [ready, editorStyle]);\n\n // The editable sits below the (optional) toolbar inside the gutter\n // wrapper; everything anchored beside it (placeholder, gutter +, docked\n // macro panel) offsets by the toolbar's live height.\n React.useEffect(() => {\n const view = currentView();\n const wrapper = gutterWrapperRef.current;\n if (!view || !wrapper || !ready) return;\n const measure = () => {\n const top = Math.max(\n Math.round(\n view.dom.getBoundingClientRect().top -\n wrapper.getBoundingClientRect().top\n ),\n 0\n );\n setEditorTop((current) => (current === top ? current : top));\n // A hovered block may have been deleted since; a detached node must\n // not pin the gutter button to its old offset. A still-connected one\n // moved with the toolbar's height change, so follow it — leaving the\n // stale offset would park the + button under the new toolbar.\n const hovered = hoverBlockRef.current;\n if (hovered?.isConnected) {\n const next = Math.max(\n Math.round(\n hovered.getBoundingClientRect().top -\n wrapper.getBoundingClientRect().top\n ),\n top + 4\n );\n setGutterTop((current) => (current === next ? current : next));\n } else {\n hoverBlockRef.current = null;\n setGutterTop(top + 4);\n }\n };\n measure();\n // Re-measure when the toolbar wraps to more/fewer rows.\n const observer = new ResizeObserver(measure);\n observer.observe(wrapper);\n return () => observer.disconnect();\n }, [ready, toolbarVisible]);\n\n return (\n <div\n ref={wrapperRef}\n data-slot=\"textarea-rich\"\n data-toolbar={toolbarVisible ? 'visible' : 'hidden'}\n data-inert={inert ? '' : undefined}\n data-macros-open={hasMacros && macrosOpen ? '' : undefined}\n data-compact-macros={compactMacros ? '' : undefined}\n data-gutter={gutterActive ? '' : undefined}\n data-block-menu={blockMenuOpen ? '' : undefined}\n className={cn(\n 'border-input rounded-lg border',\n 'transition-colors duration-200',\n 'focus-within:ring-ring focus-within:border-transparent focus-within:ring-2',\n 'flex flex-col',\n disabled && 'bg-muted/20',\n className\n )}\n onFocus={\n hasMacros && macrosOnFocus ? () => setMacrosOpen(true) : undefined\n }\n onBlur={\n hasMacros && macrosOnFocus\n ? (event) => {\n const related = event.relatedTarget as HTMLElement | null;\n if (related && event.currentTarget.contains(related)) return;\n // The block gutter's dropdown — and its \"Insert macro\"\n // submenu — mount in portals under document.body (outside\n // this frame); focus moving into our own menu tree is an\n // internal move, not leaving the field. Walk each menu back\n // to its trigger (a submenu's trigger sits in the parent\n // menu's portal) until one lands inside this frame.\n let menu = related?.closest<HTMLElement>('[role=\"menu\"]');\n while (menu && menu.id) {\n const trigger = document.querySelector(\n `[aria-controls=\"${globalThis.CSS.escape(menu.id)}\"]`\n );\n if (!trigger) break;\n if (event.currentTarget.contains(trigger)) return;\n menu = trigger.closest<HTMLElement>('[role=\"menu\"]');\n }\n setMacrosOpen(false);\n }\n : undefined\n }\n >\n <div className=\"relative flex min-h-0 flex-1 flex-col\">\n <div\n ref={gutterWrapperRef}\n data-slot=\"textarea-rich-body\"\n className={cn('relative flex-1', 'group/tar-body')}\n onMouseMove={gutterActive ? handleGutterMouseMove : undefined}\n >\n {gutterActive && (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- mousedown here only guards editor focus (preventDefault); the real controls inside are native buttons.\n <div\n data-slot=\"textarea-rich-block-gutter\"\n className=\"absolute start-1 z-10\"\n style={{ top: gutterTop }}\n // Keep the editor focused through gutter interaction (see\n // the legacy surface for the full iOS rationale).\n onMouseDown={(event) => event.preventDefault()}\n >\n <Dropdown\n open={blockMenuOpen}\n onOpenChange={handleBlockMenuOpenChange}\n placement=\"bottom-start\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className={cn(\n 'h-6 w-6 p-0',\n 'opacity-0 transition-opacity',\n 'group-hover/tar-body:opacity-100',\n 'focus-visible:opacity-100',\n '[@media(hover:none)]:opacity-100',\n blockMenuOpen && 'opacity-100'\n )}\n aria-label={blockMenuLabels?.blockMenu ?? 'Block menu'}\n title={blockMenuLabels?.blockMenu ?? 'Block menu'}\n >\n <Plus className=\"h-4 w-4\" />\n </Button>\n }\n >\n {BLOCK_FORMAT_ITEMS.map((item, index) => (\n <DropdownItem\n key={item.key}\n ref={index === 0 ? firstBlockItemRef : undefined}\n onClick={() => applyBlockFormat(item.command)}\n >\n {blockMenuLabels?.[item.key] ?? item.label}\n </DropdownItem>\n ))}\n <DropdownSeparator />\n {hasMacros && macros && (\n <>\n <DropdownSubmenu\n label={blockMenuLabels?.insertMacro ?? 'Insert macro'}\n disabled={!hasMacroEntries}\n >\n {blockMenuOpen &&\n macros.flatMap((group) => [\n ...(macros.length > 1\n ? [\n <DropdownLabel key={`h:${group.id}`}>\n {group.label}\n </DropdownLabel>,\n ]\n : []),\n ...group.macros.map((macro) => (\n <DropdownItem\n key={`m:${JSON.stringify([group.id, macro.id])}`}\n className=\"[&>[data-slot=dropdown-item-label]]:min-w-0 [&>[data-slot=dropdown-item-label]]:flex-1\"\n onClick={() => {\n setBlockMenuOpen(false);\n const view = currentView();\n if (view) {\n view.focus();\n // Insertion lands at the menu's target\n // block, mirroring the panel flow.\n applyBlockTarget(view);\n }\n insertMacro(macro);\n }}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {macro.shortcut && (\n <span\n dir=\"ltr\"\n className=\"border-border bg-background text-muted-foreground rounded border px-1 font-mono text-[11px]\"\n >\n {macro.shortcut}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">\n {macro.label}\n </span>\n </span>\n </DropdownItem>\n )),\n ])}\n </DropdownSubmenu>\n <DropdownItem\n onClick={() => {\n setBlockMenuOpen(false);\n setMacrosOpen(true);\n focusEditor();\n }}\n >\n {blockMenuLabels?.showMacroLibrary ??\n 'Show macro library'}\n </DropdownItem>\n <DropdownSeparator />\n </>\n )}\n <DropdownItem\n onClick={() => {\n setBlockMenuOpen(false);\n setToolbarVisibility(\n toolbarVisible ? 'hidden' : 'visible'\n );\n focusEditor();\n }}\n >\n {toolbarVisible\n ? (blockMenuLabels?.hideToolbar ?? 'Hide toolbar')\n : (blockMenuLabels?.showToolbar ?? 'Show toolbar')}\n </DropdownItem>\n </Dropdown>\n </div>\n )}\n {isEmpty && placeholder && (\n <div\n aria-hidden=\"true\"\n className={cn(\n 'text-muted-foreground pointer-events-none absolute start-0 end-0 z-[1]',\n 'truncate px-3 py-[7px]',\n 'transition-[padding] duration-200 motion-reduce:transition-none',\n // Mirrors the editable's sliding gutter indent (permanent\n // on touch devices, where the + trigger is always visible).\n gutterActive &&\n 'group-focus-within/tar-body:ps-10 group-hover/tar-body:ps-10 [@media(hover:none)]:ps-10',\n gutterActive && blockMenuOpen && 'ps-10',\n hasMacros && macrosOpen && 'md:me-72',\n editorClassName\n )}\n style={{\n top: editorTop,\n // Match the editable's metrics by construction: the same\n // variables (inherited from the wrapper) with the same\n // kerebron.css fallbacks that size the .kb-editor rule.\n fontSize: 'var(--textarea-rich-font-size, 1rem)',\n lineHeight: 'var(--textarea-rich-line-height, 1.5rem)',\n }}\n >\n {placeholder}\n </div>\n )}\n <RichEditor\n ref={editorHandleRef}\n value={value}\n onChange={handleChange}\n valueType=\"text/html\"\n strictValue\n modifyMenu={menuAddon.modifyMenu}\n editorKits={menuAddon.kits}\n onReady={handleReady}\n disabled={disabled}\n readOnly={readOnly}\n />\n </div>\n\n {hasMacros && (\n <AnimatedPresence>\n {macrosOpen && (\n <Animated\n key=\"macro-panel\"\n preset={macroSidePanel ? 'menu' : 'collapse'}\n enabled={macroSidePanel || !prefersReducedMotion}\n mode=\"presence\"\n custom={direction === 'rtl' ? 'left' : 'right'}\n fallbackClassName=\"animate-fade-in\"\n className=\"border-border flex max-h-72 flex-col overflow-hidden border-t md:absolute md:end-0 md:bottom-0 md:max-h-none md:w-72 md:overflow-visible md:border-s md:border-t-0\"\n // Docked below the toolbar (top only applies when the\n // panel goes absolute at md:).\n style={{ top: editorTop }}\n >\n <MacroLibrary\n id={macroPanelId}\n groups={macros!}\n onSelect={insertMacro}\n targetLabel={ariaLabel ?? placeholder}\n onClose={\n macrosOnFocus\n ? undefined\n : () => {\n setMacrosOpen(false);\n focusEditor();\n }\n }\n onCreateMacro={onCreateMacro}\n labels={macroLabels}\n compact={compactMacros}\n className=\"min-h-0 flex-1\"\n />\n </Animated>\n )}\n </AnimatedPresence>\n )}\n </div>\n </div>\n );\n }\n);\n\nTextAreaRichKerebron.displayName = 'TextAreaRichKerebron';\n\nexport { TextAreaRichKerebron };\n"]}