@bettercms-ai/kit 4.1.1 → 4.2.0
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.
- package/dist/adapters/lossy.d.ts +1 -1
- package/dist/adapters/lossy.js +1 -1
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/schema.js +1 -1
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.js.map +1 -1
- package/dist/controls/index.js +2 -2
- package/dist/controls/media-v16.d.ts +3 -1
- package/dist/controls/media-v16.js +3 -1
- package/dist/controls/media-v16.js.map +1 -1
- package/dist/controls/media.d.ts +5 -1
- package/dist/controls/media.js +25 -7
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/rich-text/block-tool.d.ts +1 -1
- package/dist/controls/rich-text/block-tool.js +1 -1
- package/dist/controls/rich-text/block-tool.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +3 -1
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +26 -3
- package/dist/controls/rich-text/catalog.js +239 -58
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/codec.d.ts +7 -1
- package/dist/controls/rich-text/codec.js +2 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.js +2 -1
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/dom.js +8 -3
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.d.ts +3 -1
- package/dist/controls/rich-text/editor.js +160 -44
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/rewriteSelection.d.ts +25 -0
- package/dist/controls/rich-text/rewriteSelection.js +28 -0
- package/dist/controls/rich-text/rewriteSelection.js.map +1 -0
- package/dist/controls/rich-text/slash-preview.js +18 -5
- package/dist/controls/rich-text/slash-preview.js.map +1 -1
- package/dist/controls/rich-text/table-grid.js +28 -21
- package/dist/controls/rich-text/table-grid.js.map +1 -1
- package/dist/controls/rich-text/toolbar.d.ts +6 -2
- package/dist/controls/rich-text/toolbar.js +205 -4
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +1 -1
- package/dist/controls/text.js +10 -7
- package/dist/controls/text.js.map +1 -1
- package/dist/engine/field-shell.js +8 -4
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +9 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +4 -3
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +2 -2
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/schema-form.d.ts +2 -0
- package/dist/engine/schema-form.js +2 -0
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/kit.css +6 -32
- package/dist/lib/reduced-motion.d.ts +1 -0
- package/dist/lib/reduced-motion.js +19 -0
- package/dist/lib/reduced-motion.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme.css +101 -0
- package/dist/tokens.css +9 -0
- package/dist/ui/content-fields.js +3 -2
- package/dist/ui/content-fields.js.map +1 -1
- package/dist/ui/controls.js +3 -2
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/floating-panel.js +3 -2
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/foundations.js +3 -2
- package/dist/ui/foundations.js.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/inspector.d.ts +23 -5
- package/dist/ui/inspector.js +75 -30
- package/dist/ui/inspector.js.map +1 -1
- package/dist/ui/overlay.js +2 -2
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/tab.js +3 -2
- package/dist/ui/tab.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","names":[],"sources":["../../../src/controls/rich-text/editor.tsx"],"sourcesContent":["/**\n * RICH TEXT — the boxed rich-text editor (V2 HEAD controls/rich-text-editor.tsx, Figma 60995-5431, CPO D49 / D54 / D55).\n *\n * contentEditable + execCommand keeps it dependency-free; the value is clean HTML, which the field's control turns into\n * the stored value through the host's codec (./codec.ts). Rich blocks (an image) are React \"islands\" rendered into\n * contenteditable=false nodes and written back as static HTML, so a re-mount restores them (./dom.ts).\n *\n * ./toolbar.tsx the field toolbar (no room at rest, folds into the chevron by width)\n * ./catalog.tsx Insert menu, slash menu and the shared block catalogue\n * ./blocks.tsx the rich blocks (an image)\n * ./markdown.ts HTML ⇄ Markdown for the Markdown toggle and pasting\n * ./ops.ts pure DOM block operations (insert, turn into, move, duplicate, live Markdown, field rules)\n * ./floating.tsx the selection bubble\n * ./dom.ts hydrate / serialize / sanitize and selection helpers\n *\n * Everything the editor offers is limited to what the field accepts (`features`): a toolbar button, a slash command, a\n * Markdown shortcut or pasted markup the field cannot hold is not offered, or is turned into what it can hold and said so.\n */\nimport * as React from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { IconArrowBarToDown, IconArrowBarToUp, IconCode, IconCopy, IconGripVertical, IconPlus, IconTransform, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { AI_REWRITE_COMMANDS, AI_RUN_SEPARATOR, useKitEnv, useKitLook, useKitServices, type AiCommandContext, type AiCommandKind, type AiPreset } from \"../../context\";\nimport { aiCommandsOffered, mapRewriteOntoRuns, textRuns } from \"./ai-runs\";\nimport { Button } from \"../../ui/button\";\nimport { Input, Textarea } from \"../../ui/input\";\nimport { ExpandedEditorModal } from \"../../ui/expanded-editor-modal\";\nimport {\n Menu, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip,\n} from \"../../ui/overlay\";\nimport { platformKeys, shortcutHintsOn } from \"../../ui/shortcut-hint\";\nimport { ALL_FEATURES, type RichTextFeature, type RichTextRead } from \"./codec\";\nimport { COMPONENT_INSERT_TOAST, type KitHistoryStep } from \"../component-services\";\nimport { Island, type IslandCtx } from \"./blocks\";\nimport { openComponentPanel } from \"./component-panel\";\nimport { CatalogComponentsProvider, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, noteRecent, useCatalog, type CatalogComponents, type CatalogItem } from \"./catalog\";\nimport {\n closestBlock, createIsland, defaultModel, editingHost, esc, hydrate, isEmptyHtml, ownsMenu, placeCaret, rangeRect, rid, sanitize,\n serialize, textBeforeCaret, textToParas, topBlock, type IslandEl, type IslandModels, type IslandKind,\n} from \"./dom\";\nimport { htmlToMarkdown, looksLikeMarkdown, markdownToHtml } from \"./markdown\";\nimport * as ops from \"./ops\";\nimport { SelectionBubble } from \"./floating\";\nimport { LinkPopoverBody } from \"../link\";\nimport { applyTextLink, fromLinkValue, textLinkOf, toLinkValue, type TextLink } from \"./link-form\";\nimport { checklistShortcut, insertChecklist, syncTaskA11y, toggleTaskAtPointer, toggleTaskFromKey } from \"./checklist\";\nimport { createOutlineStore, outlineOf } from \"./toc\";\nimport { CodeHead, V16_CODE_CLASS, measureCodes, recolourCodes, sameCodes, type CodeHeadState } from \"./code-head\";\nimport { backToMarker, caretAfterMarker, FN_MARK, FOOTNOTE_POPOVER_CLASS, FOOTNOTE_REFUSED, FootnoteEditor, FootnotesList, insertFootnote, renumberFootnotes } from \"./footnote\";\nimport { applyButton, ButtonLinkPanel, buttonAt, buttonInitial, insertButton, removeButton } from \"./button\";\nimport { EMPTY_FMT, FormatToolbar, MARK_FEATURE, stylesFor, type Fmt, type MarkCmd } from \"./toolbar\";\n\n/* ── Prose styles for the editable surface (kit tokens only) ──\n * Every descendant rule skips `[data-rt-isolate]` subtrees, as V2's (rich-text-editor.tsx:46-58): a block's own UI inside\n * the writing surface (a table island's column headers, a component card's form) is app UI, not prose. */\n/* look v16 (prototype content.css:340): a body quote is 17/28 #3B3B3B italic behind a 2px violet rule, 2/0/2/16 */\nconst V16_QUOTE_CLASS =\n \"[&_blockquote:not([data-rt-isolate]_*)]:border-kit-insp-accent [&_blockquote:not([data-rt-isolate]_*)]:py-0.5 [&_blockquote:not([data-rt-isolate]_*)]:text-[17px] [&_blockquote:not([data-rt-isolate]_*)]:leading-7 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-insp-tip-body\";\nexport const RT_PROSE =\n \"text-kit-base leading-[1.6] text-kit-fg [&>*+*]:mt-3 \" +\n // BUG-7: a styled run keeps the SITE's class (the stored design), but the site's stylesheet is not here. Only the\n // utilities the dashboard happens to build apply: `text-transparent` without its `bg-clip-text` gradient drew the\n // words invisible. The run's text is drawn as text; the class itself is kept, so a save writes it back unchanged.\n \"[&_span[class]:not([data-rt-isolate]_*)]:!text-inherit [&_span[class]:not([data-rt-isolate]_*)]:![-webkit-text-fill-color:currentColor] [&_span[class]:not([data-rt-isolate]_*)]:!bg-none [&_span[class]:not([data-rt-isolate]_*)]:!opacity-100 [&_span[class]:not([data-rt-isolate]_*)]:!visible \" +\n \"[&_h1:not([data-rt-isolate]_*)]:text-[28px] [&_h1:not([data-rt-isolate]_*)]:font-semibold [&_h1:not([data-rt-isolate]_*)]:leading-9 [&_h1:not([data-rt-isolate]_*)]:tracking-[-0.01em] [&_h2:not([data-rt-isolate]_*)]:text-[22px] [&_h2:not([data-rt-isolate]_*)]:font-semibold [&_h2:not([data-rt-isolate]_*)]:leading-8 [&_h2:not([data-rt-isolate]_*)]:tracking-[-0.01em] \" +\n \"[&_h3:not([data-rt-isolate]_*)]:text-kit-lg [&_h3:not([data-rt-isolate]_*)]:font-semibold [&_h4:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:font-semibold [&_h5:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:uppercase [&_h6:not([data-rt-isolate]_*)]:tracking-wide [&_h6:not([data-rt-isolate]_*)]:text-kit-fg-2 [&>h1]:mt-6 [&>h2]:mt-6 [&>h3]:mt-5 [&>*:first-child]:mt-0 \" +\n // a block's own list (key takeaways, V2 data-rt-isolate) is app UI, not body prose: V2 rich-text-editor.tsx skips it\n \"[&_ul:not([data-rt-isolate]_*)]:list-disc [&_ul:not([data-rt-isolate]_*)]:pl-5 [&_ol:not([data-rt-isolate]_*)]:list-decimal [&_ol:not([data-rt-isolate]_*)]:pl-5 [&_li:not([data-rt-isolate]_*)]:pl-1 [&_li+li:not([data-rt-isolate]_*)]:mt-1 [&_li:not([data-rt-isolate]_*)]:marker:text-kit-fg-3 \" +\n \"[&_ul[data-task]:not([data-rt-isolate]_*)]:list-none [&_ul[data-task]:not([data-rt-isolate]_*)]:pl-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:relative [&_ul[data-task]>li:not([data-rt-isolate]_*)]:pl-7 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:absolute [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:left-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:top-[0.2em] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:flex [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:size-4 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:items-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:justify-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:rounded-kit-md [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border-kit-line-strong [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:bg-kit-surface [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:text-[11px] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:font-semibold [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:leading-none [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:content-[''] \" +\n \"[&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:text-kit-fg-3 [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:line-through [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:border-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:bg-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:text-kit-fg-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:content-['✓'] \" +\n \"[&_blockquote:not([data-rt-isolate]_*)]:border-l-2 [&_blockquote:not([data-rt-isolate]_*)]:border-kit-line-strong [&_blockquote:not([data-rt-isolate]_*)]:pl-4 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-fg-2 [&_blockquote:not([data-rt-isolate]_*)]:italic \" +\n \"[&_a:not([data-rt-isolate]_*)]:text-kit-accent-fg [&_a:not([data-rt-isolate]_*)]:underline [&_a:not([data-rt-isolate]_*)]:decoration-kit-accent-line [&_a:not([data-rt-isolate]_*)]:underline-offset-2 \" +\n \"[&_a[data-button]:not([data-rt-isolate]_*)]:inline-flex [&_a[data-button]:not([data-rt-isolate]_*)]:h-9 [&_a[data-button]:not([data-rt-isolate]_*)]:items-center [&_a[data-button]:not([data-rt-isolate]_*)]:rounded-kit-md [&_a[data-button]:not([data-rt-isolate]_*)]:bg-kit-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:px-3.5 [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-sm [&_a[data-button]:not([data-rt-isolate]_*)]:font-medium [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-fg-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:no-underline \" +\n // a glossary term (`<abbr data-term title>`) reads as a dotted underline; a footnote marker as a small superscript\n \"[&_abbr:not([data-rt-isolate]_*)]:cursor-help [&_abbr:not([data-rt-isolate]_*)]:underline [&_abbr:not([data-rt-isolate]_*)]:decoration-dotted [&_abbr:not([data-rt-isolate]_*)]:underline-offset-2 [&_sup:not([data-rt-isolate]_*)]:text-[0.7em] [&_sup:not([data-rt-isolate]_*)]:leading-none \" +\n \"[&_code:not([data-rt-isolate]_*)]:rounded-kit-md [&_code:not([data-rt-isolate]_*)]:bg-kit-muted [&_code:not([data-rt-isolate]_*)]:px-1 [&_code:not([data-rt-isolate]_*)]:py-px [&_code:not([data-rt-isolate]_*)]:font-kit-mono [&_code:not([data-rt-isolate]_*)]:text-[0.9em] \" +\n \"[&_pre:not([data-rt-isolate]_*)]:overflow-x-auto [&_pre:not([data-rt-isolate]_*)]:whitespace-pre [&_pre:not([data-rt-isolate]_*)]:rounded-kit-lg [&_pre:not([data-rt-isolate]_*)]:bg-kit-code [&_pre:not([data-rt-isolate]_*)]:text-kit-code-fg [&_pre:not([data-rt-isolate]_*)]:p-3 [&_pre:not([data-rt-isolate]_*)]:font-kit-mono [&_pre:not([data-rt-isolate]_*)]:text-kit-sm [&_pre:not([data-rt-isolate]_*)]:border [&_pre:not([data-rt-isolate]_*)]:border-kit-line \" +\n \"[&_pre_code:not([data-rt-isolate]_*)]:rounded-none [&_pre_code:not([data-rt-isolate]_*)]:bg-transparent [&_pre_code:not([data-rt-isolate]_*)]:p-0 [&_pre_code:not([data-rt-isolate]_*)]:text-[1em] \" +\n \"[&_hr:not([data-rt-isolate]_*)]:my-6 [&_hr:not([data-rt-isolate]_*)]:border-kit-line \" +\n // V2 rich-text-editor.tsx 64-65: an image's figure sits 16px off its neighbours (my-4), the picture framed\n \"[&_figure:not([data-rt-isolate]_*)]:my-4 [&_img:not([data-rt-isolate]_*)]:rounded-kit-lg [&_img:not([data-rt-isolate]_*)]:border [&_img:not([data-rt-isolate]_*)]:border-kit-line [&_figcaption:not([data-rt-isolate]_*)]:mt-1.5 [&_figcaption:not([data-rt-isolate]_*)]:text-center [&_figcaption:not([data-rt-isolate]_*)]:text-kit-sm [&_figcaption:not([data-rt-isolate]_*)]:text-kit-fg-3 \" +\n \"[&_figure_img:not([data-rt-isolate]_*)]:block [&_figure[data-size=s]_img:not([data-rt-isolate]_*)]:w-1/3 [&_figure[data-size=m]_img:not([data-rt-isolate]_*)]:w-1/2 [&_figure[data-size=l]_img:not([data-rt-isolate]_*)]:w-3/4 [&_figure[data-align=center]_img:not([data-rt-isolate]_*)]:mx-auto [&_figure[data-align=right]_img:not([data-rt-isolate]_*)]:ml-auto [&_figure[data-align=full]_img:not([data-rt-isolate]_*)]:w-full \" +\n \"[&_div[data-callout]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-callout]:not([data-rt-isolate]_*)]:border [&_div[data-callout]:not([data-rt-isolate]_*)]:border-kit-info-line [&_div[data-callout]:not([data-rt-isolate]_*)]:bg-kit-info-soft [&_div[data-callout]:not([data-rt-isolate]_*)]:px-4 [&_div[data-callout]:not([data-rt-isolate]_*)]:py-3 [&_div[data-callout]:not([data-rt-isolate]_*)]:text-kit-fg \" +\n \"[&_div[data-callout=tip]:not([data-rt-isolate]_*)]:border-kit-success-line [&_div[data-callout=tip]:not([data-rt-isolate]_*)]:bg-kit-success-soft [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:border-kit-warning-line [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:bg-kit-warning-soft [&_div[data-callout]>p[data-title]:not([data-rt-isolate]_*)]:font-medium \" +\n \"[&_details:not([data-rt-isolate]_*)]:rounded-kit-md [&_summary:not([data-rt-isolate]_*)]:cursor-pointer [&_summary:not([data-rt-isolate]_*)]:font-medium [&_details>div:not([data-rt-isolate]_*)]:mt-1 [&_details>div:not([data-rt-isolate]_*)]:border-l [&_details>div:not([data-rt-isolate]_*)]:border-kit-line [&_details>div:not([data-rt-isolate]_*)]:pl-4 [&_details>div:not([data-rt-isolate]_*)]:ml-1 \" +\n \"[&_div[data-rt=columns]:not([data-rt-isolate]_*)]:grid [&_div[data-rt=columns]:not([data-rt-isolate]_*)]:gap-4 [&_div[data-cols='2']:not([data-rt-isolate]_*)]:grid-cols-2 [&_div[data-cols='3']:not([data-rt-isolate]_*)]:grid-cols-3 [&_div[data-cols='4']:not([data-rt-isolate]_*)]:grid-cols-4 [&_div[data-gap=s]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-gap=l]:not([data-rt-isolate]_*)]:gap-7 \" +\n \"[&_div[data-rt=file]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-rt=file]:not([data-rt-isolate]_*)]:px-3 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:py-2.5 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:text-kit-sm \" +\n \"[&_div[data-embed]:not([data-rt-isolate]_*)]:flex [&_div[data-embed]:not([data-rt-isolate]_*)]:aspect-video [&_div[data-embed]:not([data-rt-isolate]_*)]:items-center [&_div[data-embed]:not([data-rt-isolate]_*)]:justify-center [&_div[data-embed]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-embed]:not([data-rt-isolate]_*)]:border [&_div[data-embed]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-embed]:not([data-rt-isolate]_*)]:bg-kit-subtle [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-fg-3 \" +\n \"[&_div[data-block]:not([data-rt-isolate]_*)]:flex [&_div[data-block]:not([data-rt-isolate]_*)]:items-center [&_div[data-block]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-block]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-block]:not([data-rt-isolate]_*)]:border [&_div[data-block]:not([data-rt-isolate]_*)]:border-dashed [&_div[data-block]:not([data-rt-isolate]_*)]:border-kit-accent-line [&_div[data-block]:not([data-rt-isolate]_*)]:bg-kit-accent-softer [&_div[data-block]:not([data-rt-isolate]_*)]:px-3 [&_div[data-block]:not([data-rt-isolate]_*)]:py-3 [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-accent-fg \" +\n \"[&_table:not([data-rt-isolate]_*)]:w-full [&_table:not([data-rt-isolate]_*)]:border-collapse [&_table:not([data-rt-isolate]_*)]:text-kit-sm [&_td:not([data-rt-isolate]_*)]:border [&_td:not([data-rt-isolate]_*)]:border-kit-line [&_td:not([data-rt-isolate]_*)]:px-2.5 [&_td:not([data-rt-isolate]_*)]:py-1.5 [&_td:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:border [&_th:not([data-rt-isolate]_*)]:border-kit-line [&_th:not([data-rt-isolate]_*)]:bg-kit-subtle [&_th:not([data-rt-isolate]_*)]:px-2.5 [&_th:not([data-rt-isolate]_*)]:py-1.5 [&_th:not([data-rt-isolate]_*)]:text-left [&_th:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:font-medium\";\n\n/** Panel density (≈340px inspector): 13px text, smaller headings. */\nexport const RT_PANEL = \"text-kit-sm leading-[1.6] [&_h1:not([data-rt-isolate]_*)]:text-kit-xl [&_h1:not([data-rt-isolate]_*)]:leading-7 [&_h2:not([data-rt-isolate]_*)]:text-kit-lg [&_h2:not([data-rt-isolate]_*)]:leading-7 [&_h3:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:text-kit-xs\";\n\n/** execCommand, where the engine has it (it returns false where it does not). */\nconst exec = (cmd: string, arg?: string): boolean => {\n try {\n return typeof document.execCommand === \"function\" && document.execCommand(cmd, false, arg);\n } catch {\n return false;\n }\n};\n/** A footnote marker (`<sup data-footnote>`, or the table's `<sup><a href=\"#…-fn-n\">`): never an x² mark. */\nconst FOOTNOTE_SUP = \"sup[data-footnote], sup:has(> a[href*='-fn-'])\";\n/** x² / x₂ (V2): on inside the same mark takes it off (unwrap, keeping the words selected); inside the other one swaps;\n * otherwise the browser wraps the selection. Footnote markers are never touched. */\nfunction toggleScript(root: HTMLElement, tag: \"sup\" | \"sub\") {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const at = (n: Node | null) => (n?.nodeType === 1 ? (n as HTMLElement) : (n?.parentElement ?? null));\n const find = (t: \"sup\" | \"sub\") => {\n const el = at(s.anchorNode)?.closest<HTMLElement>(t === \"sup\" ? `sup:not(${FOOTNOTE_SUP})` : \"sub\");\n return el && root.contains(el) ? el : null;\n };\n const unwrap = (el: HTMLElement) => {\n const first = el.firstChild;\n const last = el.lastChild;\n el.replaceWith(...Array.from(el.childNodes));\n if (first && last) {\n const r = document.createRange();\n r.setStartBefore(first);\n r.setEndAfter(last);\n s.removeAllRanges();\n s.addRange(r);\n }\n };\n const same = find(tag);\n if (same) return unwrap(same);\n const other = find(tag === \"sup\" ? \"sub\" : \"sup\");\n if (other) unwrap(other);\n exec(tag === \"sup\" ? \"superscript\" : \"subscript\");\n}\n\n/**\n * RP-012: underline inside a link. The browser reads a link's own decoration as the mark, so its underline command\n * there turns nothing on and the mark was dropped in silence. Inside one link the mark is ours: an explicit `<u>` around\n * the selection, taken off again when the selection sits in one. False when the selection is not inside one link (the\n * browser's own command runs).\n */\nfunction toggleLinkUnderline(root: HTMLElement): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n const at = (n: Node | null) => (n?.nodeType === 1 ? (n as HTMLElement) : (n?.parentElement ?? null));\n const link = at(r.startContainer)?.closest(\"a\");\n if (!link || !root.contains(link) || at(r.endContainer)?.closest(\"a\") !== link) return false;\n const select = (first: Node, last: Node) => {\n const nr = document.createRange();\n nr.setStartBefore(first);\n nr.setEndAfter(last);\n s.removeAllRanges();\n s.addRange(nr);\n };\n // in a mark, or around exactly one (the selection the wrap below leaves can be read either way)\n const inside = at(r.startContainer)?.closest(\"u\");\n const around = r.startContainer === r.endContainer && r.endOffset - r.startOffset === 1 ? r.startContainer.childNodes[r.startOffset] : null;\n const on = inside && link.contains(inside) ? inside : around instanceof HTMLElement && around.tagName === \"U\" ? around : null;\n if (on) {\n const kids = Array.from(on.childNodes);\n on.replaceWith(...kids);\n if (kids.length) select(kids[0]!, kids[kids.length - 1]!);\n return true;\n }\n const u = document.createElement(\"u\");\n u.append(r.extractContents());\n r.insertNode(u);\n s.selectAllChildren(u);\n return true;\n}\n/** The underline mark at `el`: inside a link only an explicit `<u>` counts (the link's own decoration is not the mark). */\nconst underlineAt = (el: HTMLElement | null | undefined) => (el?.closest(\"a\") ? !!el.closest(\"u\") : queryState(\"underline\"));\n\n/** Focus is in another text field (the comment composer, a link input) while the page's selection stays in this editor. */\nconst typingElsewhere = (el: HTMLElement | null) => {\n const ae = document.activeElement;\n return !!el && !!ae && ae !== el && !el.contains(ae) && ae.matches(\"input, textarea, [contenteditable='true']\");\n};\nconst queryState = (c: string) => {\n try {\n return typeof document.queryCommandState === \"function\" && document.queryCommandState(c);\n } catch {\n return false;\n }\n};\n/** Insert HTML at the caret: the browser's own insert (undoable), else by hand. */\nfunction insertHtmlAtCaret(html: string) {\n if (exec(\"insertHTML\", html)) return;\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const r = s.getRangeAt(0);\n r.deleteContents();\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = sanitize(html);\n const last = tpl.content.lastChild;\n r.insertNode(tpl.content);\n if (last) {\n r.setStartAfter(last);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n}\n/* ── Word count (V2 rich-text-editor.tsx:115-128 + article.ts countWords, CPO D54 / D55) ──\n * Words = what the writer wrote once, in the flow a reader follows: text, headings, lists, quotes, callouts, toggles,\n * table cells and image captions. Not counted: components (counted apart), a pull quote (it repeats a line of the\n * story), key takeaways (they restate it), a table of contents, related reading, the author card, embeds, video and\n * file links, the footnotes list and a footnote mark (V2 article.ts NOT_COUNTED, verbatim: D2, 278 → 262 words on\n * rich-blog-post). */\nconst NOT_COUNTED = [\n \"[data-rt=component]\", \"[data-rt=pullquote]\", \"[data-rt=takeaways]\", \"[data-rt=toc]\", \"[data-rt=related]\", \"[data-rt=author]\",\n \"[data-rt=embed]\", \"[data-rt=video]\", \"[data-rt=file]\", \"[data-rt=footnotes]\", \"sup[data-rt=fn]\",\n].join(\",\");\nconst WORDS = (s: string) => s.replace(/\\u200b/g, \"\").trim().split(/\\s+/).filter(Boolean).length;\nexport function countWords(html: string): number {\n if (!html) return 0;\n if (!/data-rt=\"(?:component|pullquote|takeaways|toc|related|author|embed|video|file|footnotes|fn)\"/.test(html) || typeof DOMParser === \"undefined\")\n // V2 article.ts, verbatim (owner rule: V2 exact): every tag parts words, so a mark inside a word counts it twice\n return WORDS(html.replace(/<[^>]+>/g, \" \").replace(/ |&[a-z]+;/g, \" \"));\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(NOT_COUNTED).forEach((n) => n.remove());\n doc.body.querySelectorAll(\"p,li,h1,h2,h3,h4,h5,h6,td,th,figcaption,summary,pre,blockquote,div\").forEach((n) => n.append(\" \"));\n return WORDS(doc.body.textContent ?? \"\");\n}\n/** Linked component instances in the body. */\nexport const countComponents = (html: string) => (html.match(/data-rt=\"component\"/g) ?? []).length;\n\nfunction insertTextAtCaret(text: string) {\n if (exec(\"insertText\", text)) return;\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const r = s.getRangeAt(0);\n r.deleteContents();\n const t = document.createTextNode(text);\n r.insertNode(t);\n r.setStartAfter(t);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n}\n\n/** The slash menu at full height (header 32, list 300, footer 28, borders), the least it shrinks to, and the gap it keeps from the window's edge. */\nconst SLASH_MENU_H = 362;\nconst SLASH_MIN_H = 160;\nconst SLASH_EDGE = 8;\n\n/**\n * Where the slash menu goes, collision-aware: below the caret when the whole menu fits there, else on the side with\n * more room, and never taller than that room (its list scrolls), so the last row (More components) stays reachable in\n * a short window.\n */\nexport function slashPlacement(caret: { top: number; bottom: number }, viewportH: number): { flipUp: boolean; maxHeight: number } {\n const below = viewportH - caret.bottom - 6 - SLASH_EDGE;\n const above = caret.top - 6 - SLASH_EDGE;\n const flipUp = below < SLASH_MENU_H && above > below;\n return { flipUp, maxHeight: Math.max(SLASH_MIN_H, Math.min(SLASH_MENU_H, flipUp ? above : below)) };\n}\n\n/** RP-043: Block options › Language. Stored as the token (`language-typescript`); \"None\" stores no language. */\nconst CODE_LANGUAGES: { v: string; label: string }[] = [\n { v: \"bash\", label: \"Bash\" },\n { v: \"css\", label: \"CSS\" },\n { v: \"html\", label: \"HTML\" },\n { v: \"javascript\", label: \"JavaScript\" },\n { v: \"json\", label: \"JSON\" },\n { v: \"markdown\", label: \"Markdown\" },\n { v: \"python\", label: \"Python\" },\n { v: \"sql\", label: \"SQL\" },\n { v: \"typescript\", label: \"TypeScript\" },\n { v: \"yaml\", label: \"YAML\" },\n];\n// never a language token (those are [a-z0-9-])\n/** Look \"v16\": one half of the block handle pill (prototype content.css:488-491): 22×24, radius 5, a quiet grey that darkens with the pill. */\nconst V16_HANDLE_BTN =\n \"flex h-6 w-[22px] items-center justify-center rounded-[5px] text-kit-insp-faint outline-none transition-colors duration-100 group-hover/bh:text-kit-insp-quiet hover:!bg-kit-insp-card-hover hover:!text-kit-insp-tip-title focus-visible:bg-kit-insp-card-hover focus-visible:text-kit-insp-tip-title data-[popup-open]:bg-kit-insp-card-hover data-[popup-open]:text-kit-insp-tip-title [&_svg]:size-3.5\";\nconst LANG_NONE = \"_none\";\nconst LANG_OTHER = \"_other\";\nconst CODE_LANGUAGE_REASON = \"Use letters, numbers and hyphens, like cpp or csharp.\";\n\ntype IslandStep = { el: IslandEl; before: IslandModels[IslandKind]; label: string; at: number };\n/** A step the host's history holds (KitServices.historyStep); its undo and redo are the host's, while it is next. */\ntype HostStep = { label: string; step: KitHistoryStep };\ntype GutterState = { el: HTMLElement; top: number; height: number };\ntype SlashState = { rect: DOMRect; node: Text; offset: number; query: string; folder: boolean; active: number; /** look v16: the BetterCMS AI view */ ai?: boolean };\ntype LinkState = { rect: DOMRect; initial: TextLink; existing: HTMLAnchorElement | null; button?: { a: HTMLAnchorElement; label: string } };\ntype Notice = { message: string; description?: string; action?: { label: string; onClick: () => void } };\n\nexport interface RichTextEditorProps {\n value: string;\n onChange: (html: string) => void;\n readOnly?: boolean;\n placeholder?: string;\n docKey: string;\n /** what the field accepts; the editor offers nothing else (default: everything) */\n features?: readonly RichTextFeature[];\n /** where an author bio and related posts point (the host codec's RichTextRead.references) */\n references?: RichTextRead[\"references\"];\n /** a one-paragraph field: Enter starts no new block */\n single?: boolean;\n /** links may open in a new tab */\n allowNewTab?: boolean;\n /** the writing surface's id (the field label's `for`; its label is `${id}-label`) */\n id?: string;\n invalid?: boolean;\n /** panel = narrow (~340px) inspector, document = the full editor column. */\n variant?: \"panel\" | \"document\";\n /** CPO D49: the expanded editor's breadcrumb, root → this field (\"Alternating feature rows\", \"Thin walls\", \"Body\"). */\n expandCrumbs?: string[];\n /** Controlled expanded modal (a host's label-row action opens it too). */\n expandedOpen?: boolean;\n onExpandedOpenChange?: (open: boolean) => void;\n /** This editor IS the body of the expanded modal: toolbar always shown, tall writing surface. */\n inModal?: boolean;\n /** Already the full editor: no Expand button. */\n hideFullscreen?: boolean;\n /** Scroll the writing surface beyond this height (px). */\n maxHeight?: number;\n autoFocus?: boolean;\n /** Shows the toolbar Comment button. `around`: up to 32 characters of the text before and after the words (GAP-004). */\n onComment?: (quote: string, around?: { prefix: string; suffix: string }) => void;\n /** GAP-004: Comment opens the field's own popover (under the field), so the expanded editor offers none */\n commentInPlace?: boolean;\n /** the components this field may embed (the insert menus' More components); absent → none offered */\n components?: CatalogComponents;\n}\n\n/**\n * True while a `<fieldset>` around `el` is disabled. A host holds a form that way (a locked section's dock form, a save\n * in flight): the fieldset disables every form control in it, but a contenteditable is no form control, so the editor\n * reads the fence itself (NEW-Q40-LOCKRTE).\n */\nfunction useDisabledFieldset(el: React.RefObject<HTMLElement | null>): boolean {\n const [fenced, setFenced] = React.useState(false);\n React.useLayoutEffect(() => {\n const node = el.current;\n if (!node) return;\n const read = () => setFenced(!!node.closest(\"fieldset:disabled\"));\n read();\n const watch = new MutationObserver(read);\n for (let f = node.closest(\"fieldset\"); f; f = f.parentElement?.closest(\"fieldset\") ?? null) watch.observe(f, { attributes: true, attributeFilter: [\"disabled\"] });\n return () => watch.disconnect();\n }, [el]);\n return fenced;\n}\n\n/* ── Editor ────────────────────────────────────────────────────────── */\nexport function RichTextEditor({\n value,\n onChange,\n readOnly: readOnlyProp,\n placeholder,\n docKey,\n features = ALL_FEATURES,\n references,\n single,\n allowNewTab = true,\n id,\n invalid,\n variant = \"document\",\n expandCrumbs,\n expandedOpen,\n onExpandedOpenChange,\n inModal,\n hideFullscreen,\n maxHeight,\n autoFocus,\n onComment,\n commentInPlace,\n components,\n}: RichTextEditorProps) {\n const hints = shortcutHintsOn();\n const ph = placeholder ?? (hints ? \"Type '/' for commands\" : \"Write something…\");\n const dense = variant === \"panel\";\n const ref = React.useRef<HTMLDivElement>(null);\n const wrap = React.useRef<HTMLDivElement>(null);\n /* a disabled fieldset around the editor holds it like the form controls beside it: read-only, no toolbar */\n const fenced = useDisabledFieldset(wrap);\n const readOnly = !!readOnlyProp || fenced;\n const scroller = React.useRef<HTMLDivElement>(null);\n const saved = React.useRef<Range | null>(null);\n const known = React.useRef<string | null>(null);\n const pending = React.useRef<string | null>(null);\n /** a host undo just ran: its value is loaded even while the editor has focus (⌘Z here) */\n const forceLoad = React.useRef(false);\n const prevDoc = React.useRef<string | null>(null);\n const onChangeRef = React.useRef(onChange);\n onChangeRef.current = onChange;\n const valueRef = React.useRef(value);\n valueRef.current = value;\n const services = useKitServices();\n const env = useKitEnv();\n /* Look \"v16\" (prototype content.jsx:1142-1177, content.css:486-492): the block handle is one 49×26 pill (+ · grip,\n white with a hairline on hover), its menu is 200 wide with \"Delete block\", and a move says \"Block moved\". */\n const v16 = useKitLook() === \"v16\";\n const featureKey = features.join(\",\");\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const allows = React.useCallback((f: RichTextFeature) => features.includes(f), [featureKey]);\n\n const [empty, setEmpty] = React.useState(isEmptyHtml(value));\n const [words, setWords] = React.useState(() => countWords(value));\n const [comps, setComps] = React.useState(() => countComponents(value));\n const [fmt, setFmt] = React.useState<Fmt>(EMPTY_FMT);\n const [modalOwn, setModalOwn] = React.useState(false);\n const modalOpen = expandedOpen ?? modalOwn;\n const setModalOpen = (o: boolean) => (onExpandedOpenChange ? onExpandedOpenChange(o) : setModalOwn(o));\n const [md, setMd] = React.useState<{ text: string; original: string } | null>(null);\n const [mdConfirm, setMdConfirm] = React.useState(false);\n // Reduced motion: the Markdown confirm fades only (no slide).\n const reduceMotion = useReducedMotion();\n const [bubble, setBubble] = React.useState<DOMRect | null>(null);\n /** Comment was picked: the toolbar stays away until the next click or key inside this editor */\n const [quiet, setQuiet] = React.useState(false);\n React.useEffect(() => {\n const el = ref.current;\n if (!quiet || !el) return;\n const wake = () => setQuiet(false);\n el.addEventListener(\"mousedown\", wake);\n el.addEventListener(\"keydown\", wake);\n return () => {\n el.removeEventListener(\"mousedown\", wake);\n el.removeEventListener(\"keydown\", wake);\n };\n }, [quiet]);\n const [slash, setSlash] = React.useState<SlashState | null>(null);\n const [gutter, setGutter] = React.useState<GutterState | null>(null);\n const [blockMenu, setBlockMenu] = React.useState(false);\n const [gutterInsert, setGutterInsert] = React.useState(false);\n const gutterTarget = React.useRef<HTMLElement | null>(null);\n /** RP-043: Block options › Language › Other…, a typed language for this code block (`top`/`height`: where it sits) */\n const [langOther, setLangOther] = React.useState<{ pre: HTMLElement; value: string; error: string | null; top: number; height: number } | null>(null);\n const langId = React.useId();\n // D58: AI writing help follows ai.use and needs the host's AI service; without both no AI entry point is drawn.\n const canAI = env.can(\"ai.use\") && !!services.aiRewrite;\n // look v16: the slash menu's \"BetterCMS AI\" view, drawn only when the host can run its commands\n const canAiCommand = aiCommandsOffered(v16, env.can(\"ai.use\"), services.aiCommand);\n const aiAttempt = React.useRef(0);\n const [link, setLink] = React.useState<LinkState | null>(null);\n const [drag, setDrag] = React.useState<{ from: HTMLElement; line: number | null; target: Element | null } | null>(null);\n const [focused, setFocused] = React.useState(false);\n const [menus, setMenus] = React.useState({ style: false, more: false });\n const [insertOpen, setInsertOpen] = React.useState(false);\n const inserted = React.useRef(false);\n const [islands, setIslands] = React.useState<{ id: string; el: IslandEl }[]>([]);\n const hist = React.useRef<{ past: IslandStep[]; future: IslandStep[]; textAt: number; hosts: HostStep[] }>({ past: [], future: [], textAt: 0, hosts: [] });\n const [width, setWidth] = React.useState(720);\n /* The block gutter (+ / grip) never reserves room inside the field: it floats in the space LEFT of the box when the\n host leaves ≥ 48px there (document columns), and sits in the box's padding otherwise. */\n const [gutterRoom, setGutterRoom] = React.useState(false);\n const blurTimer = React.useRef<number | undefined>(undefined);\n const [notice, setNotice] = React.useState<Notice | null>(null);\n /* look v16: each code block's header + gutter overlay (code-head.tsx), placed after every render and on resize */\n const [codes, setCodes] = React.useState<CodeHeadState[]>([]);\n const v16Ref = React.useRef(v16);\n v16Ref.current = v16;\n const placeCodes = React.useCallback((force?: boolean) => {\n const next = v16Ref.current ? measureCodes(ref.current, scroller.current) : [];\n setCodes((p) => (!force && sameCodes(p, next) ? p : next));\n }, []);\n\n const expanded = !!inModal;\n const toolbarOpen = !readOnly && (focused || menus.style || menus.more || insertOpen || expanded || !!md || !!link);\n const scrollable = !!maxHeight && !expanded;\n\n /** A refusal or a result the author must see: the host's toaster, else a line under the editor. Never silent. */\n const notify = React.useCallback(\n (message: string, opts: { description?: string; action?: Notice[\"action\"] } = {}) => {\n if (services.toast) services.toast(message, opts);\n else setNotice({ message, ...opts });\n },\n [services],\n );\n React.useEffect(() => {\n if (!notice) return;\n const t = window.setTimeout(() => setNotice(null), 8000);\n return () => window.clearTimeout(t);\n }, [notice]);\n\n /* ── islands ─────────────────────────────────────────────────────── */\n /** V2 article-blocks.tsx:45-66: one live outline per editor, so every table of contents follows the headings */\n const outline = React.useRef(createOutlineStore());\n /** V2 rich-text-editor.tsx:271-276: the body's markers in text order, and the one whose note is open */\n const [footnotes, setFootnotes] = React.useState<{ el: HTMLElement; note: string }[]>([]);\n const [fnEdit, setFnEdit] = React.useState<{ el: HTMLElement; rect: DOMRect; fresh: boolean } | null>(null);\n const syncIslands = React.useCallback(() => {\n const el = ref.current;\n if (!el) return setIslands((p) => (p.length ? [] : p));\n const list = Array.from(el.querySelectorAll<IslandEl>(\":scope > [data-rt-island]\"));\n const seen = new Set<string>();\n for (const x of list) {\n if (!x.__rt) {\n // a copy the browser made (drag/drop, native undo of a clone): start it fresh\n x.innerHTML = \"\";\n x.__rt = defaultModel(x.getAttribute(\"data-rt-island\") as IslandKind);\n delete x.dataset.rtId;\n }\n if (!x.dataset.rtId || seen.has(x.dataset.rtId)) x.dataset.rtId = rid(\"i\");\n seen.add(x.dataset.rtId);\n }\n setIslands((prev) => (prev.length === list.length && prev.every((p, i) => p.el === list[i]) ? prev : list.map((x) => ({ id: x.dataset.rtId!, el: x }))));\n }, []);\n\n /* ── value in / out ──────────────────────────────────────────────── */\n const load = React.useCallback(\n (html: string) => {\n const el = ref.current;\n if (!el) return;\n el.innerHTML = sanitize(html || \"\") || \"<p><br></p>\";\n // the notes list is derived from the markers (V2: dropped on load, written on render); a marker is not text\n el.querySelectorAll(':scope > ol[data-rt=\"footnotes\"]').forEach((n) => n.remove());\n el.querySelectorAll<HTMLElement>(FN_MARK).forEach((m) => m.setAttribute(\"contenteditable\", \"false\"));\n hydrate(el);\n if (v16Ref.current) recolourCodes(el);\n syncTaskA11y(el);\n setFootnotes(renumberFootnotes(el));\n outline.current.set(outlineOf(el));\n known.current = html;\n setEmpty(isEmptyHtml(html));\n setWords(countWords(html));\n setComps(countComponents(html));\n syncIslands();\n },\n [syncIslands],\n );\n\n const emit = React.useCallback(() => {\n const el = ref.current;\n if (!el) return;\n syncIslands();\n syncTaskA11y(el);\n outline.current.set(outlineOf(el));\n setFootnotes(renumberFootnotes(el));\n const html = serialize(el);\n setEmpty(isEmptyHtml(html) && !el.querySelector(\":scope > [data-rt-island], :scope > hr\"));\n setWords(countWords(html));\n setComps(countComponents(html));\n if (html === known.current) return;\n forceLoad.current = false;\n known.current = html;\n onChangeRef.current(html);\n }, [syncIslands]);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const docChanged = prevDoc.current !== null && prevDoc.current !== docKey;\n prevDoc.current = docKey;\n if (pending.current !== null) {\n const h = pending.current;\n pending.current = null;\n load(h);\n return;\n }\n if (forceLoad.current && value !== known.current) {\n forceLoad.current = false;\n load(value);\n return;\n }\n if (docChanged || !el.firstChild || (value !== known.current && !wrap.current?.contains(document.activeElement))) load(value);\n }, [value, docKey, md, load]);\n\n React.useEffect(() => {\n setMd(null);\n setMdConfirm(false);\n setSlash(null);\n setLink(null);\n setGutter(null);\n }, [docKey]);\n\n React.useEffect(() => {\n exec(\"defaultParagraphSeparator\", \"p\");\n if (autoFocus && ref.current && !readOnly) {\n ref.current.focus({ preventScroll: true });\n placeCaret(ref.current.lastElementChild ?? ref.current);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n const w = wrap.current;\n if (!w || typeof ResizeObserver === \"undefined\") return;\n const measureRoom = () => {\n let a = w.parentElement;\n while (a && a !== document.body) {\n const cs = getComputedStyle(a);\n if (cs.overflowX !== \"visible\" || cs.overflowY !== \"visible\") break;\n a = a.parentElement;\n }\n const left = w.getBoundingClientRect().left - (a ? a.getBoundingClientRect().left : 0);\n setGutterRoom(left >= 48);\n };\n const ro = new ResizeObserver(([e]) => {\n setWidth(Math.round(e.contentRect.width));\n measureRoom();\n });\n ro.observe(w);\n return () => ro.disconnect();\n }, []);\n\n /* look v16: code block overlays follow every render (typing, islands) and the body's own size (an image loading) */\n React.useLayoutEffect(() => placeCodes());\n React.useEffect(() => {\n const el = ref.current;\n if (!v16 || !el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => placeCodes());\n ro.observe(el);\n return () => ro.disconnect();\n }, [v16, placeCodes]);\n\n /* the toolbar sticks below any sticky header (e.g. field tabs) in the same scroll area */\n const [stickyTop, setStickyTop] = React.useState(0);\n React.useEffect(() => {\n const w = wrap.current;\n if (!toolbarOpen || dense || !w) return;\n let sp = w.parentElement;\n while (sp && !/(auto|scroll)/.test(getComputedStyle(sp).overflowY)) sp = sp.parentElement;\n if (!sp) return setStickyTop(0);\n let top = 0;\n sp.querySelectorAll<HTMLElement>(\".sticky\").forEach((h) => {\n if (h.contains(w) || w.contains(h) || !(h.compareDocumentPosition(w) & Node.DOCUMENT_POSITION_FOLLOWING)) return;\n const cs = getComputedStyle(h);\n if (cs.position !== \"sticky\") return;\n top = Math.max(top, (parseFloat(cs.top) || 0) + h.offsetHeight);\n });\n setStickyTop(top);\n }, [toolbarOpen, dense]);\n\n // the slash menu follows the caret when anything scrolls; it closes only when the caret has left the \"/\" it was opened for\n const hasSlash = !!slash;\n // BL-540: the \"/query\" typed while the menu was open is saved once, when it closes (onInput holds it back)\n const slashWasOpen = React.useRef(false);\n React.useEffect(() => {\n if (hasSlash) slashWasOpen.current = true;\n else if (slashWasOpen.current) {\n slashWasOpen.current = false;\n emit();\n }\n }, [hasSlash, emit]);\n React.useEffect(() => {\n if (!hasSlash) return;\n let raf = 0;\n const on = (e: Event) => {\n if (e.target instanceof Element && e.target.closest(\"[role=listbox]\")) return;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() =>\n setSlash((sl) => {\n const s = window.getSelection();\n if (!sl || !s || !s.rangeCount || s.getRangeAt(0).startContainer !== sl.node) return null;\n const rect = rangeRect(s.getRangeAt(0), sl.node.parentElement ?? ref.current);\n return rect.top === sl.rect.top && rect.left === sl.rect.left ? sl : { ...sl, rect };\n }),\n );\n };\n window.addEventListener(\"scroll\", on, true);\n return () => {\n cancelAnimationFrame(raf);\n window.removeEventListener(\"scroll\", on, true);\n };\n }, [hasSlash]);\n\n // keep the bubble on the selection while anything scrolls (incl. the toolbar sliding open)\n const hasBubble = !!bubble;\n React.useEffect(() => {\n if (!hasBubble) return;\n let raf = 0;\n const on = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() => {\n const s = window.getSelection();\n const ok = s && s.rangeCount && !s.isCollapsed && ref.current?.contains(s.anchorNode) && !typingElsewhere(ref.current);\n setBubble(ok ? rangeRect(s!.getRangeAt(0), ref.current) : null);\n });\n };\n window.addEventListener(\"scroll\", on, true);\n window.addEventListener(\"resize\", on);\n // The toolbar sliding open moves the words without a scroll: the bubble sat on the selected word.\n const box = new ResizeObserver(on);\n if (wrap.current) box.observe(wrap.current);\n return () => {\n cancelAnimationFrame(raf);\n box.disconnect();\n window.removeEventListener(\"scroll\", on, true);\n window.removeEventListener(\"resize\", on);\n };\n }, [hasBubble]);\n\n /* ── selection ───────────────────────────────────────────────────── */\n const saveSel = () => {\n const s = window.getSelection();\n if (s && s.rangeCount && ref.current?.contains(s.anchorNode)) saved.current = s.getRangeAt(0).cloneRange();\n };\n const restoreSel = () => {\n const el = ref.current;\n if (!el) return;\n const r = saved.current;\n const s = window.getSelection();\n if (r && el.contains(r.startContainer) && s) {\n (editingHost(r.startContainer) ?? el).focus({ preventScroll: true });\n s.removeAllRanges();\n s.addRange(r);\n } else {\n el.focus({ preventScroll: true });\n placeCaret(el.lastElementChild ?? el);\n }\n };\n\n const refresh = React.useCallback(() => {\n const el = ref.current;\n const s = window.getSelection();\n if (!el || !s || !s.rangeCount || !el.contains(s.anchorNode)) return;\n // typing somewhere else (the comment composer, a link field) keeps the page's selection here: no toolbar over it\n if (typingElsewhere(el)) {\n setBubble(null);\n return;\n }\n saved.current = s.getRangeAt(0).cloneRange();\n const anchorEl = s.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode?.parentElement;\n const inIsland = !!anchorEl?.closest(\"[data-rt-island]\");\n const tb = topBlock(el, s.anchorNode);\n const r = s.getRangeAt(0);\n const hasSel = !s.isCollapsed && !!r.toString().trim();\n const next: Fmt = {\n bold: queryState(\"bold\") && !/^H[1-6]$/.test(tb?.tagName ?? \"\"),\n italic: queryState(\"italic\"),\n underline: underlineAt(anchorEl),\n strike: queryState(\"strikeThrough\"),\n // our own check: the base CSS resets sup/sub alignment, so the browser's own state for them always reads false\n sup: !!anchorEl?.closest(`sup:not(${FOOTNOTE_SUP})`),\n sub: !!anchorEl?.closest(\"sub\"),\n ul: !inIsland && tb?.tagName === \"UL\",\n ol: !inIsland && tb?.tagName === \"OL\",\n block: inIsland ? \"island\" : (tb?.tagName.toLowerCase() ?? \"p\"),\n hasSel,\n onLink: !!anchorEl?.closest(\"a\"),\n };\n setFmt((p) => (JSON.stringify(p) === JSON.stringify(next) ? p : next));\n setBubble(hasSel ? rangeRect(r, el) : null);\n el.querySelectorAll(\":scope > [data-hint]\").forEach((n) => (n !== tb || n.textContent) && n.removeAttribute(\"data-hint\"));\n if (tb && tb.tagName === \"P\" && s.isCollapsed && !tb.textContent && !tb.querySelector(\"img\") && document.activeElement === el && shortcutHintsOn()) tb.setAttribute(\"data-hint\", \"Type '/' for commands\");\n }, []);\n\n React.useEffect(() => {\n const on = () => refresh();\n // focus moving into another text field (the comment composer opening) fires no selectionchange: hide on focusin too\n const away = () => typingElsewhere(ref.current) && setBubble(null);\n document.addEventListener(\"selectionchange\", on);\n document.addEventListener(\"focusin\", away);\n return () => {\n document.removeEventListener(\"selectionchange\", on);\n document.removeEventListener(\"focusin\", away);\n };\n }, [refresh]);\n\n const run = (fn: () => void) => {\n restoreSel();\n fn();\n emit();\n refresh();\n };\n\n /* ── gutter ──────────────────────────────────────────────────────── */\n const placeGutter = (b: HTMLElement | null) => {\n const sc = scroller.current;\n if (!b || !sc) return setGutter(null);\n const sr = sc.getBoundingClientRect();\n const br = b.getBoundingClientRect();\n setGutter((g) => {\n const top = br.top - sr.top + sc.scrollTop;\n return g && g.el === b && g.top === top ? g : { el: b, top, height: br.height };\n });\n };\n const currentBlock = (): HTMLElement | null => {\n const el = ref.current;\n if (!el) return null;\n const s = window.getSelection();\n return topBlock(el, s && s.rangeCount && el.contains(s.anchorNode) ? s.anchorNode : document.activeElement);\n };\n\n /* ── block operations (DOM work lives in ./ops) ─────────── */\n const deleteBlock = (b: HTMLElement, label = \"Block deleted\") => {\n const el = ref.current;\n if (!el || !el.contains(b)) return;\n const next = b.nextSibling;\n b.remove();\n let filler: HTMLElement | null = null;\n if (!el.firstElementChild) {\n filler = document.createElement(\"p\");\n filler.innerHTML = \"<br>\";\n el.append(filler);\n }\n setGutter(null);\n setBlockMenu(false);\n emit();\n notify(label, {\n action: {\n label: \"Undo\",\n onClick: () => {\n const root = ref.current;\n if (!root) return;\n if (filler?.isConnected && !filler.textContent) filler.remove();\n if (next && next.parentNode === root) root.insertBefore(b, next);\n else root.append(b);\n emit();\n },\n },\n });\n };\n\n /** look v16 \"Turn into\" on a block island: the block becomes `nodes`, the caret goes to the first, Undo puts it back */\n const replaceBlock = (b: HTMLElement, nodes: HTMLElement[], label: string) => {\n const el = ref.current;\n if (!el || !el.contains(b) || !nodes.length) return;\n b.replaceWith(...nodes);\n setGutter(null);\n emit();\n placeCaret(nodes[0]);\n notify(label, {\n action: {\n label: \"Undo\",\n onClick: () => {\n if (!nodes[0].isConnected) return;\n nodes[0].before(b);\n nodes.forEach((n) => n.remove());\n emit();\n },\n },\n });\n };\n\n const duplicateBlock = (b: HTMLElement) => {\n const c = ops.duplicateBlock(b);\n emit();\n if (gutter) placeGutter(c);\n };\n\n const moveBlock = (b: HTMLElement, dir: -1 | 1) => {\n if (!ops.moveBlock(b, dir)) return false;\n emit();\n if (gutter) requestAnimationFrame(() => placeGutter(b));\n return true;\n };\n\n const turnInto = (b: HTMLElement | null, tag: string) => {\n const el = ref.current;\n if (el && ops.turnInto(el, b, tag)) emit();\n };\n\n /** RP-043: a code block's language from Block options (one change, one emit; ⌘Z right after it takes it back). */\n const setCodeLanguage = (pre: HTMLElement, lang: string | null) => {\n const el = ref.current;\n if (!el || !el.contains(pre) || ops.codeLanguage(pre) === lang) return;\n run(() => ops.changeCodeLanguage(el, pre, lang));\n };\n const submitOtherLanguage = () => {\n if (!langOther) return;\n const v = langOther.value.trim().toLowerCase();\n if (!ops.CODE_LANGUAGE.test(v)) return setLangOther({ ...langOther, error: CODE_LANGUAGE_REASON });\n setLangOther(null);\n setCodeLanguage(langOther.pre, v);\n };\n\n const exitIsland = (x: HTMLElement) => {\n const el = ref.current;\n if (!el || !el.contains(x)) return;\n const next = ops.ensureLineAfter(x);\n el.focus({ preventScroll: true });\n placeCaret(next, false);\n emit();\n };\n\n const insertBlock = (it: CatalogItem) => {\n const el = ref.current;\n if (!el || readOnly) return;\n if (it.kind === \"component\" && it.component) {\n // V2 insert: a fresh linked instance, ONE undo step\n const c = it.component;\n noteRecent(it);\n const made: { el: IslandEl | null } = { el: null };\n oneStep(`Insert ${c.name}`, () => {\n const isl = (made.el = ops.insertIsland(el, \"component\", { ...defaultModel(\"component\"), ref: c.id, name: c.name }));\n emit();\n return isl;\n });\n refresh();\n // V2 insert: its properties open beside it, and the toast says what a shared component is\n if (made.el && services.useComponentInfo) openComponentPanel(made.el);\n services.toast?.(`${c.name} added`, { description: COMPONENT_INSERT_TOAST });\n return;\n }\n if (!it.id || !blockAllowed(it.id, allows)) return;\n noteRecent(it);\n if (it.id === \"footnote\") {\n // V2 rich-text-editor.tsx:610-615: at the caret in the text, else said why\n const m = insertFootnote(el);\n if (!m) return void notify(FOOTNOTE_REFUSED.title, { description: FOOTNOTE_REFUSED.description });\n emit();\n openFootnote(m, true);\n return;\n }\n if (it.id === \"task\") insertChecklist(el);\n else if (it.id === \"button\") {\n // V2 rich-text-editor.tsx:627: a new button opens its popover\n const a = insertButton(el);\n emit();\n refresh();\n openButton(a);\n return;\n } else if (it.id === \"related\" && references?.topic === false) {\n // no topic field to rank by: a new block is Newest (Same topic would be refused on save, no_topic_field)\n ops.insertIsland(el, \"related\", { ...defaultModel(\"related\"), mode: \"newest\" });\n } else ops.insertBasic(el, it.id);\n emit();\n refresh();\n };\n\n /* ── slash menu ──────────────────────────────────────────────────── */\n const slashCat = useCatalog(slash?.query ?? \"\", allows, slash?.folder ?? false, components ?? null, canAiCommand, !!slash?.ai);\n const caretRect = () => {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return null;\n return rangeRect(s.getRangeAt(0), topBlock(ref.current, s.anchorNode) ?? ref.current);\n };\n const pickSlash = (it: CatalogItem) => {\n if (it.kind === \"folder\") return setSlash((s) => s && { ...s, folder: true, active: 1 });\n if (it.kind === \"ai\") return setSlash((s) => s && { ...s, ai: true, folder: false, active: 1 });\n if (it.kind === \"back\") return setSlash((s) => s && { ...s, folder: false, ai: false, active: 0 });\n const sl = slash;\n setSlash(null);\n if (sl) {\n try {\n const r = document.createRange();\n r.setStart(sl.node, sl.offset);\n r.setEnd(sl.node, Math.min(sl.node.length, sl.offset + 1 + sl.query.length));\n r.deleteContents();\n const c = document.createRange();\n c.setStart(sl.node, Math.min(sl.offset, sl.node.length));\n c.collapse(true);\n const s = window.getSelection();\n s?.removeAllRanges();\n s?.addRange(c);\n } catch {\n /* the text moved */\n }\n // A component is ONE step of the host's history, recorded from the body as it stands when the step starts: the\n // typed \"/query\" goes first, flushed, so an undo of the insert never brings it back as a paragraph.\n if (it.kind === \"component\") flushSync(() => emit());\n }\n if (it.ai) {\n emit();\n return runAiCommand(it.ai, it.label, sl ? topBlock(ref.current, sl.node) : null);\n }\n insertBlock(it);\n };\n\n /**\n * Look v16, a \"BetterCMS AI\" command picked in the slash menu (prototype content.jsx:1210, F2115-F2121). The host's\n * `aiCommand` service writes; a rewrite command replaces the text block right above the caret's line, the others\n * write new paragraphs at that line. Every write carries an Undo; a refusal and a failure are named.\n */\n const runAiCommand = (kind: AiCommandKind, label: string, at: HTMLElement | null) => {\n const run = services.aiCommand;\n const root = ref.current;\n if (!run || !root) return;\n const words = (n: Element) => (n.textContent ?? \"\").replace(/\\u200b/g, \"\");\n const above: Element[] = [];\n for (const k of Array.from(root.children)) {\n if (k === at) break;\n above.push(k);\n }\n const rewrite = AI_REWRITE_COMMANDS.includes(kind);\n // the nearest block above with words in it; a rewrite takes it only when it is plain running text\n const near = [...above].reverse().find((n) => words(n).trim());\n const target = rewrite && near instanceof HTMLElement && /^(P|H[1-6]|BLOCKQUOTE)$/.test(near.tagName) ? near : null;\n if (rewrite && !target) {\n notify(`Nothing above to ${kind === \"translate\" ? \"translate\" : kind === \"spelling\" ? \"check\" : \"rewrite\"}`, { description: \"Put the caret on the line under a paragraph, heading or quote, then pick the command again.\" });\n return;\n }\n const before = target ? target.innerHTML : \"\";\n // the target's text runs: the answer keeps their formatting where it lines up (ai-runs.ts)\n target?.normalize();\n const runs = target ? textRuns(target) : [];\n const context: AiCommandContext = {\n text: Array.from(root.children).map(words).filter((t) => t.trim()).join(\"\\n\\n\"),\n before: above.map(words).filter((t) => t.trim()).join(\"\\n\\n\"),\n target: target ? words(target) : \"\",\n line: at ? words(at).trim() : \"\",\n runs: runs.length > 1 ? runs.map((r) => r.run.text) : [],\n };\n notify(`BetterCMS AI · ${label}`);\n Promise.resolve()\n .then(() => run(kind, context))\n .then(\n (out) => {\n const el = ref.current;\n const text = typeof out === \"string\" ? out.trim() : \"\";\n if (!el || !text) return;\n if (target) {\n if (!el.contains(target) || words(target) !== context.target) {\n notify(\"The text changed before BetterCMS AI came back\", { description: \"Nothing was replaced. Pick the command again to retry.\" });\n return;\n }\n const flat = (s: string) => s.replace(/\\s*\\n+\\s*/g, \" \");\n const pieces = mapRewriteOntoRuns(\n runs.map((r) => r.run),\n text,\n );\n const marked = runs.some((r) => r.run.marked);\n if (pieces && runs.every((r) => r.node.isConnected && target.contains(r.node))) runs.forEach((r, i) => (r.node.data = flat(pieces[i]!)));\n else target.textContent = flat(text.split(AI_RUN_SEPARATOR).join(\"\"));\n const kept = !!pieces;\n emit();\n notify(`${label}: done`, {\n ...(marked && !kept ? { description: \"Its formatting was removed: the new text did not line up with the old.\" } : {}),\n action: {\n label: \"Undo\",\n onClick: () => {\n if (!target.isConnected) return;\n target.innerHTML = before;\n emit();\n },\n },\n });\n return;\n }\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = textToParas(text.replace(/\\n{3,}/g, \"\\n\\n\"));\n const nodes = Array.from(tpl.content.children) as HTMLElement[];\n if (!nodes.length) return;\n // an empty line the \"/\" was typed on is replaced by the text; a line with words keeps them and the text follows\n const line = at && el.contains(at) ? at : null;\n const emptyLine = line && line.tagName === \"P\" && !words(line).trim() ? line : null;\n if (emptyLine) emptyLine.replaceWith(...nodes);\n else if (line) line.after(...nodes);\n else el.append(...nodes);\n placeCaret(nodes[nodes.length - 1]);\n emit();\n notify(`${label}: done`, {\n action: {\n label: \"Undo\",\n onClick: () => {\n if (!nodes[0].isConnected) return;\n if (emptyLine) nodes[0].before(emptyLine);\n nodes.forEach((n) => n.remove());\n emit();\n },\n },\n });\n },\n (err: unknown) => notify(\"BetterCMS AI could not finish\", { description: err instanceof Error ? err.message : String(err) }),\n );\n };\n\n const toggleInlineCode = () => {\n const el = ref.current;\n const s = window.getSelection();\n if (!el || !s || !s.rangeCount || !allows(\"code\")) return;\n const anchorEl = s.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode?.parentElement;\n const code = anchorEl?.closest(\"code\");\n if (code && el.contains(code) && !code.closest(\"pre\")) {\n code.replaceWith(...Array.from(code.childNodes));\n emit();\n return;\n }\n const text = s.toString();\n if (!text) return void notify(\"Select some text first\", { description: \"Or wrap words in backticks to format them as code.\" });\n insertHtmlAtCaret(`<code>${esc(text)}</code>`);\n // RP-006: Chrome's insertHTML turns the spaces either side of what it inserts into ; a plain space shows the\n // same between a word and the code, so the text keeps the spaces it had\n const at = s.anchorNode && topBlock(el, s.anchorNode);\n at?.querySelectorAll(\"code\").forEach((c) => {\n if (c.textContent !== text) return;\n const prev = c.previousSibling;\n const next = c.nextSibling;\n if (prev instanceof Text && /[^\\s ] $/.test(prev.data)) prev.data = `${prev.data.slice(0, -1)} `;\n if (next instanceof Text && /^ [^\\s ]/.test(next.data)) next.data = ` ${next.data.slice(1)}`;\n });\n emit();\n };\n\n /* ── keyboard ────────────────────────────────────────────────────── */\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (slash) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setSlash(slash.folder || slash.ai ? { ...slash, folder: false, ai: false, active: 0 } : null);\n return;\n }\n if (catalogKey(e, slashCat.flat, slash.active, (a) => setSlash((s) => s && { ...s, active: a }), pickSlash, false)) {\n e.preventDefault();\n return;\n }\n }\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n // RT-028: in a list item Tab nests it and Shift+Tab brings it back; the key stays in the editor even when the item\n // cannot move (the first item, the top level). Anywhere else Tab is the browser's: focus moves on.\n if (e.key === \"Tab\" && !mod && !e.altKey && !readOnly && !single && ref.current) {\n const s = window.getSelection();\n const at = s?.anchorNode ? (s.anchorNode.nodeType === 1 ? (s.anchorNode as Element) : s.anchorNode.parentElement) : null;\n const li = at?.closest(\"li\");\n if (li && ref.current.contains(li) && !li.closest(\"[data-rt-island]\")) {\n e.preventDefault();\n if (e.shiftKey ? ops.outdentListItem(li) : ops.indentListItem(li)) emit();\n return;\n }\n }\n if (!mod && !e.altKey && !readOnly && ref.current && toggleTaskFromKey(ref.current, e.key)) {\n e.preventDefault();\n emit();\n return;\n }\n if (mod && !e.altKey && k === \"k\") {\n e.preventDefault();\n saveSel();\n openLink();\n return;\n }\n if (mod && !e.altKey && !e.shiftKey && k === \"e\") {\n e.preventDefault();\n toggleInlineCode();\n return;\n }\n // RP-012: inside a link the underline is ours (the browser reads the link's own decoration as the mark)\n if (mod && !e.altKey && !e.shiftKey && k === \"u\" && allows(\"underline\") && ref.current && toggleLinkUnderline(ref.current)) {\n e.preventDefault();\n emit();\n refresh();\n return;\n }\n // the browser's own mark shortcuts, only for the marks the field keeps\n if (mod && !e.altKey && !e.shiftKey && ((k === \"b\" && !allows(\"bold\")) || (k === \"i\" && !allows(\"italic\")) || (k === \"u\" && !allows(\"underline\")))) {\n e.preventDefault();\n return;\n }\n if (mod && e.altKey && /^Digit[0-6]$/.test(e.code)) {\n e.preventDefault();\n const n = Number(e.code.slice(5));\n const tag = n === 0 ? \"p\" : `h${n}`;\n if (tag === \"p\" || allows(tag as RichTextFeature)) turnInto(currentBlock(), tag);\n return;\n }\n if (e.key === \"Enter\" && !mod && !e.shiftKey) {\n // a one-paragraph field has no second block to start\n if (single) {\n e.preventDefault();\n return;\n }\n const cb = currentBlock();\n // RP-043: \"```\" or \"```ts\" alone on a line, then Enter, is a code block (with that language)\n if (cb && ref.current && ops.enterCodeFence(ref.current, cb, allows)) {\n e.preventDefault();\n setSlash(null);\n emit();\n return;\n }\n // Enter on an empty quote or heading line leaves it for a paragraph\n if (cb && /^(BLOCKQUOTE|H[1-6])$/.test(cb.tagName) && !cb.textContent?.replace(//g, \"\").trim()) {\n e.preventDefault();\n turnInto(cb, \"p\");\n return;\n }\n // Enter at the end of a quote starts a paragraph (not another quote)\n const sel = window.getSelection();\n if (cb?.tagName === \"BLOCKQUOTE\" && sel?.isCollapsed && sel.rangeCount && !cb.querySelector(\"p\")) {\n const rest = document.createRange();\n rest.selectNodeContents(cb);\n rest.setStart(sel.anchorNode!, sel.anchorOffset);\n if (!rest.toString().trim()) {\n e.preventDefault();\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n cb.after(p);\n placeCaret(p);\n emit();\n return;\n }\n }\n const s = window.getSelection();\n const pre = s?.anchorNode && (s.anchorNode.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode.parentElement)?.closest(\"pre\");\n if (pre && ref.current?.contains(pre)) {\n e.preventDefault();\n exec(\"insertLineBreak\");\n return;\n }\n }\n if (e.key === \"ArrowDown\" && !mod && !e.shiftKey && !single) {\n // leave a trailing heading / quote / code block / list\n const b = currentBlock();\n const s = window.getSelection();\n if (b && !b.nextElementSibling && b.tagName !== \"P\" && !b.hasAttribute(\"data-rt-island\") && s?.isCollapsed && s.rangeCount) {\n const rest = document.createRange();\n rest.selectNodeContents(b);\n rest.setStart(s.anchorNode!, s.anchorOffset);\n if (!rest.toString().trim()) {\n e.preventDefault();\n const p = ops.ensureLineAfter(b);\n placeCaret(p, false);\n emit();\n }\n }\n }\n };\n\n /** Block-level shortcuts; runs for the surface and for text inside rich blocks. */\n const onWrapKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented) return;\n const mod = e.metaKey || e.ctrlKey;\n // look v16: Focus mode is ⇧⌘F (prototype content.jsx:1020); ⌘↵ keeps working\n if (mod && !hideFullscreen && (e.key === \"Enter\" || (v16 && e.shiftKey && e.key.toLowerCase() === \"f\"))) {\n e.preventDefault();\n setModalOpen(true);\n return;\n }\n if (md || readOnly) return;\n const t = e.target as HTMLElement;\n if (!ref.current?.contains(t) || t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\") return;\n if (undoKey(e)) return;\n if (single) return;\n if (mod && !e.shiftKey && !e.altKey && eventKey(e) === \"d\") {\n e.preventDefault();\n const b = currentBlock();\n if (b) duplicateBlock(b);\n return;\n }\n if (mod && e.shiftKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n e.preventDefault();\n const b = currentBlock();\n if (b) moveBlock(b, e.key === \"ArrowUp\" ? -1 : 1);\n }\n };\n\n const onInput = (e: React.FormEvent<HTMLDivElement>) => {\n if (e.target !== ref.current) return;\n const ne = e.nativeEvent as InputEvent;\n if (ne.inputType !== \"historyUndo\" && ne.inputType !== \"historyRedo\") {\n hist.current.textAt = Date.now();\n hist.current.future = [];\n }\n // RT-030: a live Markdown conversion is taken back by ⌘Z only right after it\n ops.forgetLiveMarkdown(ref.current!);\n if (!single && ne.inputType === \"insertText\" && allows(\"checklist\") && checklistShortcut(ref.current!, ne.data)) {\n setSlash(null);\n emit();\n return;\n }\n if (!single && ne.inputType === \"insertText\" && (ne.data === \" \" || ne.data === \"-\") && ops.liveMarkdown(ref.current!, ne.data, allows)) {\n setSlash(null);\n emit();\n return;\n }\n if (ne.inputType === \"insertText\" && ne.data === \"`\" && allows(\"code\")) ops.liveInlineCode(ref.current!);\n // RT-030: **bold**, *italic*, _italic_ as their closing marker is typed\n else if (ne.inputType === \"insertText\" && (ne.data === \"*\" || ne.data === \"_\")) ops.liveInlineEmphasis(ne.data, allows, ref.current!);\n // BL-540: while the \"/\" menu is open (and for the \"/\" that opens it) the typed query is not saved: closing the menu\n // saves once (the effect on `hasSlash`), whether a command ran or the menu was cancelled\n const s = window.getSelection();\n if (!s || !s.rangeCount) {\n emit();\n return setSlash(null);\n }\n const r = s.getRangeAt(0);\n const opensAt = (n: Node) => {\n const blk = closestBlock(ref.current!, n);\n return !!blk && textBeforeCaret(blk) === \"/\";\n };\n if (!slash) {\n // \"/\" opens the menu only at the very start of a block, and only in a field that takes more than one block\n const opens = !single && ne.inputType === \"insertText\" && ne.data === \"/\" && r.startContainer.nodeType === 3 && opensAt(r.startContainer);\n const rect = opens ? caretRect() : null;\n if (rect) setSlash({ rect, node: r.startContainer as Text, offset: r.startOffset - 1, query: \"\", folder: false, active: 0 });\n else emit();\n return;\n }\n if (r.startContainer !== slash.node || r.startOffset <= slash.offset || slash.node.data[slash.offset] !== \"/\") return setSlash(null);\n const q = slash.node.data.slice(slash.offset + 1, r.startOffset);\n // A query is words (\"/table of\"): only a space right after \"/\", two in a row, or a long run closes the menu.\n if (/^\\s|\\s\\s/.test(q) || q.length > 24) return setSlash(null);\n setSlash({ ...slash, query: q, active: slash.folder || slash.ai ? 1 : 0 });\n };\n\n /* ── links ───────────────────────────────────────────────────────── */\n const openLink = () => {\n if (!allows(\"link\")) return;\n restoreSel();\n const s = window.getSelection();\n const anchorEl = s?.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s?.anchorNode?.parentElement;\n const anchor = (anchorEl?.closest(\"a\") as HTMLAnchorElement | null) ?? null;\n if (anchor && ref.current && buttonAt(ref.current, anchor)) return openButton(anchor);\n if (!anchor && (!s || s.isCollapsed || !s.toString().trim())) {\n notify(\"Select some text first\", { description: hints ? platformKeys(\"Then press ⌘K to link it.\") : \"Then link it.\" });\n return;\n }\n const rect = s && s.rangeCount ? rangeRect(s.getRangeAt(0), ref.current) : ref.current!.getBoundingClientRect();\n // The panel takes focus: the selection it links is kept, so closing it can give it back (BL-539).\n saveSel();\n setBubble(null);\n setLink({ rect, existing: anchor, initial: anchor ? textLinkOf(anchor) : { href: \"\" } });\n };\n /** BL-539: the link panel closed without a save (Esc, Cancel, Remove): the caret goes back to the editor, on its text. */\n const closeLink = () => {\n setLink(null);\n restoreSel();\n };\n /* ── footnotes (V2 rich-text-editor.tsx:1081-1130) ───────────────── */\n const openFootnote = (m: HTMLElement, fresh = false) => {\n if (readOnly) return;\n setBubble(null);\n setFnEdit({ el: m, rect: m.getBoundingClientRect(), fresh });\n };\n const removeFootnote = (m: HTMLElement) => {\n setFnEdit(null);\n m.remove();\n emit();\n };\n /** closed: a new footnote with no note is taken back out (V2), else the caret goes back after its marker */\n const closeFootnote = () => {\n const f = fnEdit;\n setFnEdit(null);\n if (!f || !ref.current) return;\n if (f.fresh && !(f.el.getAttribute(\"data-note\") ?? \"\").trim()) return removeFootnote(f.el);\n caretAfterMarker(ref.current, f.el);\n };\n\n /** V2 rich-text-editor.tsx:865-873: a button's popover, its label above the link form */\n const openButton = (a: HTMLAnchorElement) => {\n if (readOnly) return;\n const { link: initial, label } = buttonInitial(a);\n setBubble(null);\n setLink({ rect: a.getBoundingClientRect(), existing: a, initial, button: { a, label } });\n };\n const saveButton = (v: TextLink, label: string) => {\n const b = link?.button;\n setLink(null);\n if (!b) return;\n applyButton(b.a, v, label);\n emit();\n };\n const saveLink = (v: TextLink) => {\n const l = link;\n setLink(null);\n if (!l) return;\n if (l.existing) {\n applyTextLink(l.existing, v);\n emit();\n return;\n }\n run(() => {\n // BL-537: a selection keeps its own nodes (bold, underline, the spaces around it): the browser's createLink\n // wraps them, else they are moved into the anchor by hand. Only a caret inserts the address as the link's text.\n const s = window.getSelection();\n const el = ref.current;\n if (el && s && s.rangeCount && !s.isCollapsed) {\n const sentinel = `https://bcms-link.invalid/${rid()}`;\n if (exec(\"createLink\", sentinel)) {\n el.querySelectorAll<HTMLAnchorElement>(\"a[href]\").forEach((a) => a.getAttribute(\"href\") === sentinel && applyTextLink(a, v));\n return;\n }\n const r = s.getRangeAt(0);\n const blk = closestBlock(el, r.startContainer);\n if (blk && blk === closestBlock(el, r.endContainer)) {\n const a = document.createElement(\"a\");\n applyTextLink(a, v);\n a.append(r.extractContents());\n r.insertNode(a);\n r.selectNodeContents(a);\n s.removeAllRanges();\n s.addRange(r);\n return;\n }\n }\n const text = s?.toString() || v.href;\n const attr = (s: string) => esc(s).replace(/\"/g, \""\");\n insertHtmlAtCaret(`<a href=\"${attr(v.href)}\"${v.newTab ? ` target=\"_blank\"` : \"\"}${v.rel ? ` rel=\"${attr(v.rel)}\"` : \"\"}>${esc(text)}</a>`);\n });\n };\n\n /* ── AI rewrite of the selection (the host's service) ────────────── */\n const aiRewrite = (preset: AiPreset) => {\n const rewrite = services.aiRewrite;\n restoreSel();\n const range = saved.current?.cloneRange();\n const text = range?.toString() ?? \"\";\n if (!rewrite || !range || !text.trim()) return;\n setBubble(null);\n Promise.resolve()\n .then(() => rewrite(text, preset, aiAttempt.current++))\n .then(\n (out) => {\n const el = ref.current;\n if (!el || !el.contains(range.startContainer) || range.toString() !== text) {\n notify(\"The text changed before the rewrite came back\", { description: \"Nothing was replaced. Select it again to retry.\" });\n return;\n }\n el.focus({ preventScroll: true });\n const s = window.getSelection();\n s?.removeAllRanges();\n s?.addRange(range);\n insertTextAtCaret(out);\n emit();\n notify(\"Rewritten with AI\", { description: hints ? platformKeys(\"Press ⌘Z to undo\") : undefined });\n },\n (err: unknown) => notify(\"Could not rewrite the selection\", { description: err instanceof Error ? err.message : String(err) }),\n );\n };\n\n /* ── drag to reorder via the grip ────────────────────────────────── */\n const onGripDown = (e: React.PointerEvent) => {\n if (!gutter) return;\n startDrag(gutter.el, e, () => setBlockMenu(true));\n };\n /** Drag a top-level block (the gutter grip) to a new position; a tap calls `onTap`. */\n const startDrag = (from: HTMLElement, e: React.PointerEvent, onTap?: () => void) => {\n if (readOnly || e.button !== 0) return;\n e.preventDefault();\n const start = e.clientY;\n let moved = false;\n const kids = () => Array.from(ref.current?.children ?? []);\n const move = (ev: PointerEvent) => {\n if (!moved && Math.abs(ev.clientY - start) < 4) return;\n moved = true;\n const sc = scroller.current!;\n const sr = sc.getBoundingClientRect();\n let target: Element | null = null;\n let line = 0;\n for (const k of kids()) {\n const r = k.getBoundingClientRect();\n if (ev.clientY < r.top + r.height / 2) {\n target = k;\n line = r.top - sr.top + sc.scrollTop - 4;\n break;\n }\n line = r.bottom - sr.top + sc.scrollTop + 4;\n }\n setDrag({ from, line, target });\n };\n const up = () => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n if (!moved) {\n onTap?.();\n return;\n }\n setDrag((d) => {\n if (d && d.target !== d.from) {\n // dropped where it already stood (before its own next block, or last and appended): not a move\n const same = d.target ? d.target === d.from.nextElementSibling : d.from === ref.current?.lastElementChild;\n if (d.target) d.target.before(d.from);\n else ref.current?.append(d.from);\n setTimeout(() => {\n emit();\n // look v16 (F2031): a drag-drop move says so, as Move up / Move down do\n if (v16 && !same) services.toast?.(\"Block moved\");\n }, 0);\n }\n return null;\n });\n };\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", up);\n };\n\n /* ── pasted and converted markup keeps to the field's rules ──────── */\n const conform = (html: string): string => {\n const r = ops.restrictHtml(html, allows);\n if (r.dropped.length) notify(`This field keeps no ${r.dropped.join(\" or \")}`, { description: \"They were left out; the text around them was kept.\" });\n return r.html;\n };\n\n /* ── Markdown mode ───────────────────────────────────────────────── */\n const toggleMarkdown = () => {\n if (!md) {\n const html = ref.current ? serialize(ref.current) : value;\n const text = htmlToMarkdown(html);\n setMd({ text, original: text });\n setSlash(null);\n setGutter(null);\n setBubble(null);\n setLink(null);\n return;\n }\n if (md.text === md.original) {\n setMd(null);\n setMdConfirm(false);\n return;\n }\n setMdConfirm(true);\n };\n const convertMarkdown = () => {\n if (!md) return;\n let html: string;\n try {\n html = conform(markdownToHtml(md.text));\n } catch (err) {\n notify(\"Could not convert this Markdown\", { description: `${err instanceof Error ? err.message : String(err)}. Your rich text is unchanged.` });\n return;\n }\n pending.current = html;\n known.current = html;\n onChangeRef.current(html);\n setMd(null);\n setMdConfirm(false);\n };\n\n /* ── One undo history (CPO D54): typing is the browser's own undo; an island write (an image's address or alt text)\n is a step on this stack. ⌘Z takes whichever happened last. ── */\n /** A host step's undo or redo; its value then loads even here, with the caret in the editor. */\n const runHost = (run: () => true | string): true | string => {\n forceLoad.current = true;\n const r = run();\n if (r !== true) forceLoad.current = false;\n return r;\n };\n /**\n * This body's host step that is the host's next undo (or redo) NOW. The host's toolbar moves these steps too: after\n * its Undo then Redo, the step is the latest change again, so ⌘Z here undoes it. Any later change in this body is a\n * host step of its own (the body's value is the host's), so a host step that is next is the latest change here.\n */\n const hostNext = (way: \"undo\" | \"redo\"): HostStep | null => {\n const hs = hist.current.hosts;\n for (let i = hs.length - 1; i >= 0; i--) if (hs[i].step.next() === way) return hs[i];\n return null;\n };\n const islandUndo = (): boolean => {\n const host = hostNext(\"undo\");\n if (host) {\n const r = runHost(host.step.undo);\n if (r !== true) notify(\"Nothing was undone\", { description: r });\n return true;\n }\n const h = hist.current;\n // a step whose island is gone has nothing to undo\n while (h.past.length && !h.past[h.past.length - 1].el.isConnected) h.past.pop();\n const step = h.past[h.past.length - 1];\n if (!step || step.at < h.textAt) return false;\n if (!step.el.__rtSet) return false;\n h.past.pop();\n h.future.push({ ...step, before: step.el.__rt!, at: Date.now() });\n step.el.__rtSet(step.before);\n return true;\n };\n const islandRedo = (): boolean => {\n const host = hostNext(\"redo\");\n if (host) {\n const r = runHost(host.step.redo);\n if (r !== true) notify(\"Nothing was redone\", { description: r });\n return true;\n }\n const h = hist.current;\n const step = h.future.pop();\n if (!step || !step.el.isConnected || !step.el.__rtSet) return false;\n h.past.push({ ...step, before: step.el.__rt!, at: Date.now() });\n step.el.__rtSet(step.before);\n return true;\n };\n /**\n * One action as ONE undo step (a separate copy, \"use shared version again\", a component inserted): in the host's\n * history when it keeps one (KitServices.historyStep: its toolbar Undo, an Undo toast and ⌘Z here are the same\n * undo), else in this editor's own (`before`: the model the island had; an insert has none, and stays as undoable\n * as any block inserted here). `write` makes the change and answers the island it changed. Answers its undo.\n */\n const oneStep = (label: string, write: () => IslandEl | null, before?: IslandModels[IslandKind]): (() => true | string) => {\n const h = hist.current;\n const made: { el: IslandEl | null } = { el: null };\n const historyStep = services.historyStep;\n const step = historyStep\n ? historyStep(() => {\n made.el = write();\n })\n : ((made.el = write()), null);\n const el = made.el;\n if (step) {\n h.hosts = [...h.hosts, { label, step }].slice(-100);\n return () => runHost(step.undo);\n }\n if (!el || !before) return () => \"This change has no undo step here.\";\n const s: IslandStep = { el, before, label, at: Date.now() };\n h.past = [...h.past, s].slice(-100);\n h.future = [];\n return () => {\n if (!h.past.includes(s)) return \"It was undone already.\";\n if (h.past[h.past.length - 1] !== s || s.at < h.textAt) return \"Changes made after it come first. Press ⌘Z to undo them.\";\n return islandUndo() ? true : \"The block was removed, so there is nothing to undo.\";\n };\n };\n const record = (el: IslandEl, before: IslandModels[IslandKind], label: string, coalesce?: boolean) => {\n const h = hist.current;\n const now = Date.now();\n const top = h.past[h.past.length - 1];\n // typing in one field coalesces (~500ms), unless the text was edited in between\n if (coalesce && top && top.el === el && top.label === label && now - top.at < 500 && top.at > h.textAt) top.at = now;\n else h.past = [...h.past, { el, before, label, at: now }].slice(-100);\n h.future = [];\n };\n const undoKey = (e: React.KeyboardEvent): boolean => {\n const mod = e.metaKey || e.ctrlKey;\n if (!mod || e.altKey || eventKey(e) !== \"z\") return false;\n if (e.shiftKey) {\n e.preventDefault();\n // RT-013: the text's own redo, as ⌘Z runs its undo; the browser's ⌘⇧Z default is not dependable here.\n if (!islandRedo()) exec(\"redo\");\n return true;\n }\n // RT-030: right after \"## \" made a heading (a list, a quote, a divider) or \"**x**\" a bold run, ⌘Z puts the typed text back\n if (ref.current && ops.undoLiveMarkdown(ref.current)) {\n e.preventDefault();\n emit();\n return true;\n }\n if (islandUndo()) {\n e.preventDefault();\n return true;\n }\n if (!hist.current.past.length || !ref.current) return false;\n e.preventDefault();\n const before = ref.current.innerHTML;\n exec(\"undo\");\n if (ref.current.innerHTML === before) {\n hist.current.textAt = 0;\n islandUndo();\n }\n return true;\n };\n\n /* ── API for islands (stable) ────────────────────────────────────── */\n const api = React.useRef({ emit, deleteBlock, replaceBlock, exitIsland, record, oneStep, notify, duplicateBlock, moveBlock, islandUndo, islandRedo, startDrag, allows });\n api.current = { emit, deleteBlock, replaceBlock, exitIsland, record, oneStep, notify, duplicateBlock, moveBlock, islandUndo, islandRedo, startDrag, allows };\n const islandCtx = React.useMemo<IslandCtx>(\n () => ({\n readOnly,\n dense,\n emit: () => api.current.emit(),\n remove: (x, label) => api.current.deleteBlock(x, label),\n replace: (x, nodes, label) => api.current.replaceBlock(x, nodes, label),\n exit: (x) => api.current.exitIsland(x),\n record: (x, before, label, coalesce) => api.current.record(x, before, label, coalesce),\n step: (label, write, before) => api.current.oneStep(label, write, before),\n notify: (message, description) => api.current.notify(message, { description }),\n duplicate: (x) => api.current.duplicateBlock(x),\n move: (x, dir) => api.current.moveBlock(x, dir),\n undo: () => api.current.islandUndo(),\n redo: () => api.current.islandRedo(),\n drag: (x, e) => api.current.startDrag(x, e),\n allows: (f) => api.current.allows(f),\n outline: outline.current,\n references,\n }),\n [readOnly, dense, references],\n );\n\n const commentSel = onComment\n ? () => {\n restoreSel();\n const s = window.getSelection();\n const raw = s?.toString() ?? \"\";\n const q = raw.trim();\n // the comment popover takes over: the selection toolbar steps away so it never sits on the composer\n setBubble(null);\n setQuiet(true);\n if (!q) return;\n // GAP-004: the text around the words (TextQuoteSelector), so the host finds this occurrence and not the first\n const root = ref.current;\n const r = s && s.rangeCount ? s.getRangeAt(0) : null;\n if (!root || !r || !root.contains(r.commonAncestorContainer)) return onComment(q);\n const before = document.createRange();\n before.selectNodeContents(root);\n before.setEnd(r.startContainer, r.startOffset);\n const after = document.createRange();\n after.selectNodeContents(root);\n after.setStart(r.endContainer, r.endOffset);\n // the spaces trimmed off the selection belong to the text around it\n const lead = raw.slice(0, raw.length - raw.trimStart().length);\n const trail = raw.slice(raw.trimEnd().length);\n onComment(q, { prefix: (before.toString() + lead).slice(-32), suffix: (trail + after.toString()).slice(0, 32) });\n }\n : undefined;\n const onMark = (cmd: MarkCmd) =>\n allows(MARK_FEATURE[cmd]) &&\n run(() => {\n if (cmd === \"superscript\" || cmd === \"subscript\") ref.current && toggleScript(ref.current, cmd === \"superscript\" ? \"sup\" : \"sub\");\n else if (!(cmd === \"underline\" && ref.current && toggleLinkUnderline(ref.current))) exec(cmd);\n });\n const onStyle = (tag: string) => {\n restoreSel();\n turnInto(currentBlock(), tag);\n refresh();\n };\n\n /* ── render ──────────────────────────────────────────────────────── */\n const { flipUp, maxHeight: slashMaxH } = slash ? slashPlacement(slash.rect, window.innerHeight) : { flipUp: false, maxHeight: SLASH_MENU_H };\n const gBlock = gutter?.el;\n const gIsText = !!gBlock && !gBlock.hasAttribute(\"data-rt-island\") && gBlock.tagName !== \"HR\";\n const gLang = gBlock?.tagName === \"PRE\" ? ops.codeLanguage(gBlock) : null;\n const btn = dense ? \"size-5 [&_svg:not([data-rt-isolate]_*)]:size-3.5\" : \"size-[22px] [&_svg:not([data-rt-isolate]_*)]:size-3.5\";\n /* outside: + and grip float left of the box · inset: a slim grip sits in the 16px padding (insert via / or the\n toolbar) · none: compact inspector fields and one-paragraph fields */\n const gutterMode: \"outside\" | \"inset\" | \"none\" = readOnly || dense || single ? \"none\" : gutterRoom ? \"outside\" : \"inset\";\n const showGutter = gutterMode !== \"none\";\n /** BL-540: a one-line or panel field counts no words; the expanded modal shows no stamp (owner 2026-11-08, KP-134) */\n const counts = !single && !dense && !inModal;\n const minH = expanded ? \"min-h-[60vh]\" : single ? \"min-h-9\" : dense ? \"min-h-[120px]\" : \"min-h-[190px]\";\n const turnStyles = stylesFor(allows).filter((s) => [\"p\", \"h1\", \"h2\", \"h3\", \"blockquote\"].includes(s.tag));\n\n return (\n <CatalogComponentsProvider value={components ?? null}>\n <div\n ref={wrap}\n data-rt-editor=\"\"\n className={cn(\n \"relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]\",\n \"rounded-kit-lg border transition-colors duration-150\",\n /* the expanded modal is raised: the editor sits level with it, never below (D56) */\n /* held by a disabled fieldset: drawn like a disabled input (ui/input.tsx) */\n fenced ? \"cursor-not-allowed bg-kit-subtle opacity-60\" : expanded ? \"bg-[var(--kit-surface-raised)]\" : \"bg-kit-surface\",\n /* V2 rich-text-editor.tsx:1152: line at rest, line-strong while the toolbar is open; an invalid value (dash) keeps its edge */\n invalid ? \"border-[var(--kit-field-invalid)]\" : toolbarOpen ? \"border-[var(--kit-field-border-focus)]\" : \"border-kit-line-strong\", // 4B (2026-11-10): the box edge meets 3:1\n )}\n /* what the sticky toolbar covers at the top of the scroll area */\n style={{ \"--rt-sticky-top\": toolbarOpen && !dense ? `calc(${stickyTop}px + var(--rt-toolbar-h))` : \"var(--kit-sticky-top, 0px)\" } as React.CSSProperties}\n onMouseLeave={() => !blockMenu && !gutterInsert && !drag && setGutter(null)}\n onKeyDown={onWrapKeyDown}\n onFocus={() => {\n window.clearTimeout(blurTimer.current);\n setFocused(true);\n }}\n onBlur={() => {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = window.setTimeout(() => {\n const a = document.activeElement;\n if (wrap.current?.contains(a) || a?.closest(\"[role=dialog],[role=listbox],[data-floating-layer]\")) return;\n // NEW-Q11-TB1: only the editor's own menus (toolbar, block, bubble) keep it; a host menu would open under the bubble\n const menu = a?.closest(\"[role=menu]\");\n if (menu && ownsMenu(menu, [wrap.current, document.querySelector('[data-floating-layer][aria-label=\"Selection formatting\"]')])) return;\n setFocused(false);\n setBubble(null);\n ref.current?.querySelectorAll(\"[data-hint]\").forEach((n) => n.removeAttribute(\"data-hint\"));\n // F2016: the prototype recolours code when the caret leaves it\n if (v16) recolourCodes(ref.current);\n if (valueRef.current !== known.current && !md) load(valueRef.current);\n }, 400);\n }}\n >\n {readOnly ? null : (\n <FormatToolbar\n open={toolbarOpen}\n sticky={!dense}\n stickyTop={stickyTop}\n width={width}\n dense={dense}\n fmt={fmt}\n md={!!md}\n allows={allows}\n hideFullscreen={hideFullscreen}\n insertOpen={insertOpen}\n setInsertOpen={(o) => {\n if (o) inserted.current = false;\n setInsertOpen(o);\n }}\n onMenuOpen={(name, o) => {\n setMenus((m) => ({ ...m, [name]: o }));\n // BL-538: a closing menu (finalFocus={false}) drops focus on <body> after its item ran: give the caret back\n // to the text, but only when focus is truly lost (an item may have opened a field of its own)\n if (!o)\n requestAnimationFrame(() => {\n const ae = document.activeElement;\n if (!ae || ae === document.body) restoreSel();\n });\n }}\n onStyle={onStyle}\n onMark={onMark}\n onList={(kind) =>\n allows(kind) &&\n run(() => {\n // Chrome nests the list inside a heading/quote (<h2><ul>…) — turn the line into a paragraph first.\n const b = currentBlock();\n if (b && /^(H[1-6]|BLOCKQUOTE)$/.test(b.tagName)) turnInto(b, \"p\");\n exec(kind === \"ul\" ? \"insertUnorderedList\" : \"insertOrderedList\");\n // …and it can still leave <p><ul>…</ul></p>; lift the list out of any text block.\n ref.current?.querySelectorAll(\":is(p,h1,h2,h3,h4,h5,h6,blockquote) > :is(ul,ol)\").forEach((list) => {\n const host = list.parentElement!;\n host.replaceWith(...Array.from(host.childNodes).filter((n) => n.nodeType === 1 || n.textContent?.trim()));\n });\n })\n }\n onLink={openLink}\n onClear={() =>\n run(() => {\n // RT-019: clear formatting strips styling marks; a link is content, not formatting, so it stays.\n exec(\"removeFormat\");\n })\n }\n onComment={commentSel}\n onInlineCode={() => {\n restoreSel();\n toggleInlineCode();\n }}\n onCodeBlock={() => {\n restoreSel();\n if (allows(\"pre\")) turnInto(currentBlock(), \"pre\");\n }}\n onInsert={(it) => {\n inserted.current = true;\n restoreSel();\n insertBlock(it);\n setInsertOpen(false);\n }}\n keepFocusOnInsertClose={() => inserted.current}\n onFullscreen={() => setModalOpen(true)}\n onMarkdown={toggleMarkdown}\n saveSel={saveSel}\n />\n )}\n\n {md ? (\n <div className=\"px-3 pb-2.5 pt-2.5\">\n <Textarea\n aria-label=\"Field content as Markdown\"\n spellCheck={false}\n value={md.text}\n readOnly={readOnly}\n onChange={(e) => {\n setMd({ ...md, text: e.target.value });\n setMdConfirm(false);\n }}\n className={cn(\"font-kit-mono text-kit-xs leading-5\", expanded ? \"min-h-[60vh]\" : dense ? \"min-h-[120px]\" : \"min-h-[190px]\")}\n style={scrollable ? { maxHeight } : undefined}\n />\n <p className=\"mt-1.5 text-kit-2xs text-kit-fg-3\">Markdown. Switching back converts it to blocks.</p>\n <AnimatePresence initial={false}>\n {mdConfirm ? (\n <motion.div\n key=\"confirm\"\n initial={{ opacity: 0, y: reduceMotion ? 0 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduceMotion ? 0 : 4 }}\n transition={{ duration: 0.15 }}\n role=\"alertdialog\"\n aria-label=\"Convert edited Markdown?\"\n className=\"mt-2 flex flex-wrap items-center gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle px-3 py-2\"\n >\n <span className=\"flex-1 text-kit-sm font-medium text-kit-fg\">Convert edited Markdown?</span>\n <Button size=\"xs\" variant=\"ghost\" onClick={() => setMdConfirm(false)}>\n Keep editing Markdown\n </Button>\n <Button size=\"xs\" variant=\"primary\" autoFocus onClick={convertMarkdown}>\n Convert to rich text\n </Button>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n ) : (\n <div\n ref={scroller}\n className={cn(\"relative\", scrollable && \"overflow-y-auto\")}\n style={scrollable ? { maxHeight } : undefined}\n onMouseMove={(e) => {\n if (drag || blockMenu || gutterInsert || !showGutter) return;\n const t = e.target as HTMLElement;\n if (t.closest(\"[data-rt-gutter]\")) return;\n const b = topBlock(ref.current, t);\n // a component card carries its own handle and ⋯ menu (V2 rich-text-editor.tsx:1297-1298): no second grip beside it\n placeGutter(b?.getAttribute(\"data-rt-island\") === \"component\" ? null : b);\n }}\n >\n <div\n ref={ref}\n id={inModal ? undefined : id}\n role=\"textbox\"\n aria-multiline={!single}\n aria-labelledby={!inModal && id ? `${id}-label` : undefined}\n aria-label=\"Rich text\"\n aria-placeholder={ph}\n aria-readonly={readOnly || undefined}\n aria-invalid={invalid || undefined}\n contentEditable={!readOnly}\n suppressContentEditableWarning\n spellCheck\n tabIndex={readOnly ? 0 : undefined}\n onInput={onInput}\n onKeyDown={onKeyDown}\n onKeyUp={refresh}\n onMouseUp={refresh}\n onMouseDown={(e) => {\n // V2 rich-text-editor.tsx:1314-1321: a press on a task's box ticks it (the caret stays where it was)\n if (readOnly || !ref.current || !toggleTaskAtPointer(ref.current, e.target, e.clientX)) return;\n e.preventDefault();\n emit();\n }}\n onClick={(e) => {\n const fn = (e.target as HTMLElement).closest?.<HTMLElement>(FN_MARK);\n if (fn && ref.current?.contains(fn) && !fn.closest(\"[data-rt-island]\") && !readOnly) {\n e.preventDefault();\n return openFootnote(fn);\n }\n const a = ref.current ? buttonAt(ref.current, e.target) : null;\n if (!a || readOnly) return;\n e.preventDefault();\n openButton(a);\n }}\n onPaste={(e) => {\n if (readOnly) return;\n const files = Array.from(e.clipboardData.files).filter((f) => f.type.startsWith(\"image/\"));\n if (files.length) {\n e.preventDefault();\n notify(allows(\"image\") ? \"Add images from the media library\" : \"This field keeps no images\", {\n description: allows(\"image\") ? \"A pasted file has no address the page can show it from. Use Insert › Image.\" : undefined,\n });\n return;\n }\n const text = e.clipboardData.getData(\"text/plain\");\n e.preventDefault();\n // RT-016: a paste with HTML (a web page, a document) keeps what the field accepts, and says what it\n // leaves out; only the plain text was read before, so a heading and bold became one plain paragraph and\n // a picture vanished in silence. A one-line field keeps the plain-text path below.\n const pasted = single ? \"\" : e.clipboardData.getData(\"text/html\");\n if (pasted) {\n const clean = ops.pastedHtml(pasted, allows(\"image\"));\n if (clean.images) {\n notify(\"Add images from the media library\", {\n // QA q18: the picture had an address; what it lacks is a place in the media library\n description: \"Pictures from another page are left out. Only media library images are kept. Use Insert › Image.\",\n });\n }\n if (clean.html.replace(/<[^>]*>/g, \"\").trim()) {\n insertHtmlAtCaret(conform(clean.html));\n if (ref.current) hydrate(ref.current);\n emit();\n return;\n }\n }\n if (!text) return;\n if (single || (!/\\n/.test(text.trim()) && !looksLikeMarkdown(text))) {\n insertTextAtCaret(single ? text.replace(/\\s*\\n\\s*/g, \" \") : text);\n emit();\n return;\n }\n let html: string;\n try {\n html = markdownToHtml(text);\n } catch {\n html = text.split(/\\n{2,}/).map((p) => `<p>${esc(p.trim()).replace(/\\n/g, \"<br>\")}</p>`).join(\"\");\n }\n insertHtmlAtCaret(conform(html));\n if (ref.current) hydrate(ref.current);\n emit();\n }}\n onDragOver={(e) => {\n if (e.dataTransfer.types.includes(\"application/x-bcms-asset\") && allows(\"image\")) e.preventDefault();\n }}\n onDrop={(e) => {\n const asset = e.dataTransfer.getData(\"application/x-bcms-asset\");\n if (!asset || readOnly || !allows(\"image\")) return;\n e.preventDefault();\n try {\n const a = JSON.parse(asset) as { url: string; alt?: string; name: string };\n const b = topBlock(ref.current, e.target as Node);\n const isl = createIsland(\"image\", defaultModel(\"image\", { src: a.url, alt: a.alt ?? \"\" }));\n if (b) b.after(isl);\n else ref.current?.append(isl);\n ops.ensureLineAfter(isl);\n emit();\n } catch {\n notify(\"That drop is not an image from the media library\");\n }\n }}\n className={cn(\n RT_PROSE,\n dense && RT_PANEL,\n v16 && V16_CODE_CLASS,\n v16 && V16_QUOTE_CLASS,\n \"peer relative outline-none focus-visible:shadow-none [&_*:not([data-rt-isolate]_*)]:outline-none\",\n \"[&>p[data-hint]]:before:pointer-events-none [&>p[data-hint]]:before:float-left [&>p[data-hint]]:before:h-0 [&>p[data-hint]]:before:text-kit-fg-4 [&>p[data-hint]]:before:content-[attr(data-hint)]\",\n \"[&_a[data-button]:not([data-rt-isolate]_*)]:cursor-pointer [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:cursor-pointer\",\n // line-height 0 after the size (tailwind-merge drops a leading before a text size): V2 gets it from preflight (RTE:1387)\n \"[&_sup[data-rt=fn]]:mx-px [&_sup[data-rt=fn]]:cursor-pointer [&_sup[data-rt=fn]]:rounded-kit-sm [&_sup[data-rt=fn]]:px-0.5 [&_sup[data-rt=fn]]:text-[0.72em] [&_sup[data-rt=fn]]:leading-[0] [&_sup[data-rt=fn]]:font-semibold [&_sup[data-rt=fn]]:text-kit-accent-fg [&_sup[data-rt=fn]:hover]:bg-kit-accent-soft\",\n dense ? \"px-2.5 py-2\" : \"px-4 py-3.5\",\n minH,\n )}\n />\n {empty ? (\n <div aria-hidden className={cn(\"pointer-events-none absolute text-kit-fg-4 peer-focus:hidden\", dense ? \"text-kit-sm\" : \"text-kit-base\", dense ? \"left-2.5 top-2\" : \"left-4 top-3.5\")}>\n {ph}\n </div>\n ) : null}\n\n {v16\n ? codes.map((s, i) => (\n <CodeHead key={i} s={s} readOnly={readOnly} onLanguage={setCodeLanguage} onLayout={() => requestAnimationFrame(() => placeCodes(true))} notify={(m) => notify(m)} />\n ))\n : null}\n\n {/* Block gutter (+ / grip) */}\n {gutter && showGutter ? (\n <div\n data-rt-gutter=\"\"\n /* z-3: under the sticky toolbar (z-4), so a tall block's grip never paints over it */\n className={cn(\n \"absolute z-[3] flex\",\n gutterMode === \"outside\" ? \"-left-12 pr-1\" : \"left-0\",\n v16 && gutterMode === \"outside\"\n ? // a table's handle stands 78 out (prototype content.jsx:1171), clear of the grid's row chips\n (gBlock?.getAttribute(\"data-rt-island\") === \"table\" ? \"-left-[78px] \" : \"-left-[54px] \") +\n \"group/bh items-center gap-px rounded-[7px] p-px pr-px transition-[background-color,box-shadow] duration-100 hover:bg-kit-insp-tip-bg hover:shadow-[0_0_0_1px_var(--kit-insp-tip-line),0_1px_2px_rgb(0_0_0/0.06),0_2px_8px_-2px_rgb(0_0_0/0.06)]\"\n : \"items-start\",\n )}\n style={{ top: gutter.top + Math.max(-2, Math.min(4, gutter.height / 2 - 12)) }}\n >\n {gutterMode === \"outside\" ? (\n <Popover\n open={gutterInsert}\n onOpenChange={(o) => {\n if (o) {\n gutterTarget.current = gutter.el;\n inserted.current = false;\n }\n setGutterInsert(o);\n }}\n >\n <Tooltip content=\"Add a block below\" disabled={gutterInsert}>\n <PopoverTrigger\n aria-label=\"Add a block below\"\n className={v16 ? V16_HANDLE_BTN : cn(\"flex items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover data-[popup-open]:text-kit-fg\", btn)}\n >\n <IconPlus stroke={1.5} aria-hidden />\n </PopoverTrigger>\n </Tooltip>\n {v16 ? <i aria-hidden className=\"h-3.5 w-px bg-transparent transition-colors duration-100 group-hover/bh:bg-kit-insp-tip-line\" /> : null}\n {gutterInsert ? (\n <InsertMenuContent\n side=\"bottom\"\n align=\"start\"\n allows={allows}\n keepFocusOnClose={() => inserted.current}\n onInsert={(it) => {\n const b = gutterTarget.current;\n const el = ref.current;\n inserted.current = true;\n setGutterInsert(false);\n if (!b || !el || !el.contains(b)) return;\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n b.after(p);\n el.focus({ preventScroll: true });\n placeCaret(p);\n insertBlock(it);\n }}\n />\n ) : null}\n </Popover>\n ) : null}\n <Menu open={blockMenu} onOpenChange={setBlockMenu}>\n <Tooltip content={v16 ? \"Drag to move · click for menu\" : \"Drag to move, click for options\"} disabled={blockMenu || !!drag}>\n <MenuTrigger\n aria-label=\"Block options\"\n onPointerDown={onGripDown}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setBlockMenu(true);\n }\n }}\n className={\n v16 && gutterMode !== \"inset\"\n ? cn(V16_HANDLE_BTN, \"cursor-grab active:cursor-grabbing\", (blockMenu || drag) && \"bg-kit-insp-tip-line text-kit-insp-tip-title\")\n : cn(\n \"flex cursor-grab items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg active:cursor-grabbing\",\n gutterMode === \"inset\" ? \"h-[22px] w-4 rounded-kit-sm [&_svg:not([data-rt-isolate]_*)]:size-3.5\" : btn,\n (blockMenu || drag) && \"bg-kit-hover text-kit-fg\",\n )\n }\n >\n <IconGripVertical stroke={1.5} aria-hidden />\n </MenuTrigger>\n </Tooltip>\n <MenuContent className={v16 ? \"w-[200px] min-w-[200px] rounded-[10px]\" : \"w-56\"} align=\"start\" finalFocus={false}>\n {turnStyles.length > 1 && !v16 ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconTransform stroke={1.5} />} disabled={!gIsText}>\n Turn into\n </MenuSubTrigger>\n <MenuSubContent className=\"w-48\">\n {turnStyles.map((t) => (\n <MenuItem key={t.tag} icon={t.icon} onClick={() => turnInto(gBlock ?? null, t.tag)}>\n {t.label}\n </MenuItem>\n ))}\n </MenuSubContent>\n </MenuSub>\n ) : null}\n {/* look v16: the language lives on the code block's own header (code-head.tsx) */}\n {gBlock?.tagName === \"PRE\" && allows(\"pre\") && !v16 ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconCode stroke={1.5} />}>Language</MenuSubTrigger>\n <MenuSubContent className=\"w-48\">\n <MenuRadioGroup\n value={gLang == null ? LANG_NONE : CODE_LANGUAGES.some((l) => l.v === gLang) ? gLang : LANG_OTHER}\n onValueChange={(v: string) => v !== LANG_OTHER && setCodeLanguage(gBlock, v === LANG_NONE ? null : v)}\n >\n <MenuRadioItem value={LANG_NONE}>None</MenuRadioItem>\n <MenuSeparator />\n {CODE_LANGUAGES.map((l) => (\n <MenuRadioItem key={l.v} value={l.v}>\n {l.label}\n </MenuRadioItem>\n ))}\n <MenuSeparator />\n <MenuRadioItem\n value={LANG_OTHER}\n onClick={() => gutter && setLangOther({ pre: gBlock, value: gLang ?? \"\", error: null, top: gutter.top, height: gutter.height })}\n >\n Other…\n </MenuRadioItem>\n </MenuRadioGroup>\n </MenuSubContent>\n </MenuSub>\n ) : null}\n <MenuItem icon={<IconCopy stroke={1.5} />} shortcut=\"⌘D\" onClick={() => gBlock && duplicateBlock(gBlock)}>\n Duplicate\n </MenuItem>\n <MenuItem icon={<IconArrowBarToUp stroke={1.5} />} shortcut=\"⌘⇧↑\" disabled={!gBlock?.previousElementSibling} onClick={() => gBlock && moveBlock(gBlock, -1) && v16 && services.toast?.(\"Block moved\")}>\n Move up\n </MenuItem>\n <MenuItem icon={<IconArrowBarToDown stroke={1.5} />} shortcut=\"⌘⇧↓\" disabled={!gBlock?.nextElementSibling} onClick={() => gBlock && moveBlock(gBlock, 1) && v16 && services.toast?.(\"Block moved\")}>\n Move down\n </MenuItem>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => gBlock && deleteBlock(gBlock)}>\n {v16 ? \"Delete block\" : \"Delete\"}\n </MenuItem>\n </MenuContent>\n </Menu>\n </div>\n ) : null}\n {drag?.line != null ? <div className=\"pointer-events-none absolute inset-x-3 z-[6] h-0.5 rounded-full bg-kit-info\" style={{ top: drag.line }} /> : null}\n {/* RP-043: Language › Other…, under the code block it names (mounted closed, so its anchor is in place on open) */}\n {showGutter && allows(\"pre\") ? (\n <Popover open={!!langOther} onOpenChange={(o) => !o && setLangOther(null)}>\n <PopoverAnchor\n render={<span aria-hidden className=\"pointer-events-none absolute left-4 w-px\" style={{ top: langOther?.top ?? 0, height: langOther?.height ?? 0 }} />}\n />\n <PopoverContent className=\"w-64\" side=\"bottom\" align=\"start\">\n <form\n className=\"flex flex-col gap-2\"\n onSubmit={(e) => {\n e.preventDefault();\n submitOtherLanguage();\n }}\n >\n <label className=\"text-kit-xs font-medium text-kit-fg-2\" htmlFor={langId}>\n Language\n </label>\n <Input\n id={langId}\n autoFocus\n size=\"sm\"\n value={langOther?.value ?? \"\"}\n spellCheck={false}\n autoComplete=\"off\"\n placeholder=\"cpp\"\n aria-invalid={langOther?.error ? true : undefined}\n aria-describedby={langOther?.error ? `${langId}-error` : undefined}\n onChange={(e) => langOther && setLangOther({ ...langOther, value: e.target.value, error: null })}\n className=\"font-kit-mono [&_input]:font-kit-mono\"\n />\n {langOther?.error ? (\n <p id={`${langId}-error`} role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {langOther.error}\n </p>\n ) : null}\n <div className=\"flex justify-end\">\n <Button size=\"xs\" variant=\"primary\" type=\"submit\">\n Set language\n </Button>\n </div>\n </form>\n </PopoverContent>\n </Popover>\n ) : null}\n\n {/* Rich blocks render into their contenteditable=false hosts */}\n {islands.map(({ id: key, el }) => createPortal(<Island el={el} ctx={islandCtx} />, el, key))}\n </div>\n )}\n\n {/* Footnotes (V2 rich-text-editor.tsx:1533-1560): the notes in text order, each a way to edit it and back to it */}\n <FootnotesList\n notes={footnotes}\n readOnly={readOnly}\n density={dense ? \"dense\" : \"default\"}\n onEdit={(m) => openFootnote(m)}\n onBack={(m) => ref.current && backToMarker(ref.current, m)}\n />\n\n {/* Footer meta (V2 rich-text-editor.tsx:1563-1571), and any refusal said in place when the host has no toaster.\n BL-540: a one-line or panel field draws no word count; its footer shows only when it has something to say. */}\n {counts || notice ? (\n <div className=\"flex h-7 items-center justify-end gap-3 rounded-b-kit-lg border-t border-kit-line-subtle px-3 text-kit-2xs text-kit-fg-3\">\n {notice ? (\n <span role=\"status\" aria-live=\"polite\" className=\"mr-auto min-w-0 truncate text-kit-fg-2\">\n {notice.message}\n {notice.description ? ` ${notice.description}` : \"\"}\n {notice.action ? (\n <button\n type=\"button\"\n className=\"ml-1.5 font-medium text-kit-fg underline underline-offset-2\"\n onClick={() => {\n notice.action!.onClick();\n setNotice(null);\n }}\n >\n {notice.action.label}\n </button>\n ) : null}\n </span>\n ) : null}\n {counts ? (\n <span className=\"tabular-nums\">\n {words.toLocaleString(\"en-US\")} {words === 1 ? \"word\" : \"words\"}\n {comps ? ` · ${comps} ${comps === 1 ? \"component\" : \"components\"}` : \"\"} · {Math.max(1, Math.round(words / 220))} min read\n </span>\n ) : null}\n </div>\n ) : null}\n\n {/* Bubble toolbar on selection: a toolbar menu owns the moment, so the bubble steps aside while one is open */}\n {bubble && !quiet && !readOnly && !slash && !link && !md && !menus.style && !menus.more && !insertOpen ? (\n <SelectionBubble\n rect={bubble}\n avoid={toolbarOpen ? wrap.current?.querySelector<HTMLElement>('[role=\"toolbar\"][aria-label=\"Text formatting\"]')?.getBoundingClientRect() : null}\n fmt={fmt}\n allows={allows}\n saveSel={saveSel}\n onAi={canAI ? aiRewrite : undefined}\n onStyle={onStyle}\n onMark={onMark}\n onInlineCode={() => {\n restoreSel();\n toggleInlineCode();\n }}\n onLink={openLink}\n onComment={commentSel}\n />\n ) : null}\n\n {/* Slash menu (opens only at the start of a block; never takes focus) */}\n {slash && !md\n ? createPortal(\n <>\n <div data-floating-layer=\"\" className=\"pointer-events-auto fixed inset-0 z-[var(--kit-z-popover,84)]\" onMouseDown={() => setSlash(null)} />\n <motion.div\n initial={{ opacity: 0, y: flipUp ? -4 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ duration: 0.14 }}\n style={{\n left: Math.min(window.innerWidth - 330, Math.max(8, slash.rect.left)),\n ...(flipUp ? { bottom: window.innerHeight - slash.rect.top + 6 } : { top: slash.rect.bottom + 6 }),\n }}\n data-floating-layer=\"\"\n className=\"pointer-events-auto fixed z-[calc(var(--kit-z-popover,84)_+_1)]\"\n >\n <SlashMenuPanel query={slash.query} folder={slash.folder} aiOffered={canAiCommand} aiView={!!slash.ai} active={slash.active} allows={allows} setActive={(a) => setSlash((s) => s && { ...s, active: a })} onPick={pickSlash} maxHeight={slashMaxH} />\n </motion.div>\n </>,\n document.body,\n )\n : null}\n\n {/* Footnote note: a small popover at its marker (V2 rich-text-editor.tsx:1644-1680, one setting) */}\n <Popover open={!!fnEdit} onOpenChange={(o) => !o && closeFootnote()}>\n <PopoverAnchor\n render={<span className=\"pointer-events-none fixed\" style={fnEdit ? { top: fnEdit.rect.bottom, left: fnEdit.rect.left, width: Math.max(1, fnEdit.rect.width), height: 1 } : { top: 0, left: 0 }} />}\n />\n <PopoverContent className={FOOTNOTE_POPOVER_CLASS} finalFocus={false}>\n {fnEdit ? (\n <FootnoteEditor\n key={footnotes.findIndex((f) => f.el === fnEdit.el)}\n n={footnotes.findIndex((f) => f.el === fnEdit.el) + 1}\n note={fnEdit.el.getAttribute(\"data-note\") ?? \"\"}\n onChange={(v) => {\n fnEdit.el.setAttribute(\"data-note\", v);\n emit();\n }}\n onRemove={() => removeFootnote(fnEdit.el)}\n onDone={closeFootnote}\n />\n ) : null}\n </PopoverContent>\n </Popover>\n\n {/* Link popover anchored to the selection */}\n <Popover open={!!link} onOpenChange={(o) => !o && closeLink()}>\n <PopoverAnchor\n render={<span className=\"pointer-events-none fixed\" style={link ? { top: link.rect.bottom, left: link.rect.left, width: Math.max(1, link.rect.width), height: 1 } : { top: 0, left: 0 }} />}\n />\n <PopoverContent className=\"w-[340px] rounded-kit-lg p-3\" finalFocus={false}>\n {link?.button ? (\n <ButtonLinkPanel\n initial={link.initial}\n label={link.button.label}\n allowNewTab={allowNewTab}\n onSave={saveButton}\n onCancel={closeLink}\n onDetach={() => {\n const a = link.button!.a;\n if (ref.current) removeButton(ref.current, a);\n emit();\n closeLink();\n }}\n />\n ) : link ? (\n <div className=\"flex flex-col gap-2\">\n <LinkPopoverBody\n initial={toLinkValue(link.initial)}\n hideNewTab={!allowNewTab}\n onSave={(v) => saveLink(fromLinkValue(v, allowNewTab))}\n onCancel={closeLink}\n onDetach={\n link.existing\n ? () => {\n const a = link.existing!;\n const kids = Array.from(a.childNodes);\n a.replaceWith(...kids);\n // Moving the text out collapsed the kept range: it selects the words the link held.\n if (kids.length) {\n const r = document.createRange();\n r.setStartBefore(kids[0]!);\n r.setEndAfter(kids[kids.length - 1]!);\n saved.current = r;\n }\n emit();\n closeLink();\n }\n : undefined\n }\n />\n </div>\n ) : null}\n </PopoverContent>\n </Popover>\n {!hideFullscreen ? (\n <ExpandedEditorModal open={modalOpen} onOpenChange={setModalOpen} crumbs={expandCrumbs?.length ? expandCrumbs : [\"Text\"]} returnFocus={() => ref.current}>\n {modalOpen ? (\n <RichTextEditor\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n docKey={`${docKey}:expanded`}\n features={features}\n references={references}\n single={single}\n allowNewTab={allowNewTab}\n expandCrumbs={expandCrumbs}\n variant=\"document\"\n hideFullscreen\n inModal\n autoFocus\n onComment={commentInPlace ? undefined : onComment}\n components={components}\n />\n ) : null}\n </ExpandedEditorModal>\n ) : null}\n </div>\n </CatalogComponentsProvider>\n );\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAM,kBACJ;AACF,IAAa,WACX;;AAiCF,IAAa,WAAW;;AAGxB,IAAM,QAAQ,KAAa,QAA0B;CACnD,IAAI;EACF,OAAO,OAAO,SAAS,gBAAgB,cAAc,SAAS,YAAY,KAAK,OAAO,GAAG;CAC3F,QAAQ;EACN,OAAO;CACT;AACF;;AAEA,IAAM,eAAe;;;AAGrB,SAAS,aAAa,MAAmB,KAAoB;CAC3D,MAAM,IAAI,OAAO,aAAa;CAC9B,IAAI,CAAC,KAAK,CAAC,EAAE,YAAY;CACzB,MAAM,MAAM,MAAoB,GAAG,aAAa,IAAK,IAAqB,GAAG,iBAAiB;CAC9F,MAAM,QAAQ,MAAqB;EACjC,MAAM,KAAK,GAAG,EAAE,UAAU,CAAC,EAAE,QAAqB,MAAM,QAAQ,WAAW,aAAa,KAAK,KAAK;EAClG,OAAO,MAAM,KAAK,SAAS,EAAE,IAAI,KAAK;CACxC;CACA,MAAM,U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;QACrD,UAAU;QACV,UACE,KAAK,iBACK;SACJ,MAAM,IAAI,KAAK;SACf,MAAM,OAAO,MAAM,KAAK,EAAE,UAAU;SACpC,EAAE,YAAY,GAAG,IAAI;SAErB,IAAI,KAAK,QAAQ;UACf,MAAM,IAAI,SAAS,YAAY;UAC/B,EAAE,eAAe,KAAK,EAAG;UACzB,EAAE,YAAY,KAAK,KAAK,SAAS,EAAG;UACpC,MAAM,UAAU;SAClB;SACA,KAAK;SACL,UAAU;QACZ,IACA,KAAA;OAEP,CAAA;MACE,CAAA,IACH;KACU,CAAA,CACT;;IACR,CAAC,iBACA,oBAAC,qBAAD;KAAqB,MAAM;KAAW,cAAc;KAAc,QAAQ,cAAc,SAAS,eAAe,CAAC,MAAM;KAAG,mBAAmB,IAAI;KAC9I,UAAA,YACC,oBAAC,gBAAD;MACS;MACG;MACA;MACG;MACb,QAAQ,GAAG,OAAO;MACR;MACE;MACJ;MACK;MACC;MACd,SAAQ;MACR,gBAAA;MACA,SAAA;MACA,WAAA;MACA,WAAW,iBAAiB,KAAA,IAAY;MAC5B;KACb,CAAA,IACC;IACe,CAAA,IACnB;GACD;;CACsB,CAAA;AAE/B"}
|
|
1
|
+
{"version":3,"file":"editor.js","names":[],"sources":["../../../src/controls/rich-text/editor.tsx"],"sourcesContent":["/**\n * RICH TEXT — the boxed rich-text editor (V2 HEAD controls/rich-text-editor.tsx, Figma 60995-5431, CPO D49 / D54 / D55).\n *\n * contentEditable + execCommand keeps it dependency-free; the value is clean HTML, which the field's control turns into\n * the stored value through the host's codec (./codec.ts). Rich blocks (an image) are React \"islands\" rendered into\n * contenteditable=false nodes and written back as static HTML, so a re-mount restores them (./dom.ts).\n *\n * ./toolbar.tsx the field toolbar (no room at rest, folds into the chevron by width)\n * ./catalog.tsx Insert menu, slash menu and the shared block catalogue\n * ./blocks.tsx the rich blocks (an image)\n * ./markdown.ts HTML ⇄ Markdown for the Markdown toggle and pasting\n * ./ops.ts pure DOM block operations (insert, turn into, move, duplicate, live Markdown, field rules)\n * ./floating.tsx the selection bubble\n * ./dom.ts hydrate / serialize / sanitize and selection helpers\n *\n * Everything the editor offers is limited to what the field accepts (`features`): a toolbar button, a slash command, a\n * Markdown shortcut or pasted markup the field cannot hold is not offered, or is turned into what it can hold and said so.\n */\nimport * as React from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { IconArrowBarToDown, IconArrowBarToUp, IconCode, IconCopy, IconGripVertical, IconPlus, IconTransform, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { AI_REWRITE_COMMANDS, AI_RUN_SEPARATOR, useKitEnv, useKitLook, useKitServices, type AiCommandContext, type AiCommandKind, type AiPreset } from \"../../context\";\nimport { aiCommandsOffered, mapRewriteOntoRuns, textRuns } from \"./ai-runs\";\nimport { Button } from \"../../ui/button\";\nimport { Input, Textarea } from \"../../ui/input\";\nimport { ExpandedEditorModal } from \"../../ui/expanded-editor-modal\";\nimport {\n Menu, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip,\n} from \"../../ui/overlay\";\nimport { platformKeys, shortcutHintsOn } from \"../../ui/shortcut-hint\";\nimport { ALL_FEATURES, type RichTextFeature, type RichTextRead } from \"./codec\";\nimport { FORMATTING_REMOVED, LINK_SENTINEL, linkAttrs, selectionShape, unwrapLinkSentinels } from \"./rewriteSelection\";\nimport { COMPONENT_INSERT_TOAST, type KitHistoryStep } from \"../component-services\";\nimport { Island, type IslandCtx } from \"./blocks\";\nimport { openComponentPanel } from \"./component-panel\";\nimport { CatalogComponentsProvider, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, noteRecent, useCatalog, type CatalogComponents, type CatalogItem } from \"./catalog\";\nimport {\n closestBlock, createIsland, defaultModel, editingHost, esc, hydrate, isEmptyHtml, ownsMenu, placeCaret, rangeRect, rid, sanitize,\n serialize, textBeforeCaret, textToParas, topBlock, type IslandEl, type IslandModels, type IslandKind,\n} from \"./dom\";\nimport { htmlToMarkdown, looksLikeMarkdown, markdownToHtml } from \"./markdown\";\nimport * as ops from \"./ops\";\nimport { SelectionBubble } from \"./floating\";\nimport { LinkPopoverBody } from \"../link\";\nimport { applyTextLink, fromLinkValue, textLinkOf, toLinkValue, type TextLink } from \"./link-form\";\nimport { checklistShortcut, insertChecklist, syncTaskA11y, toggleTaskAtPointer, toggleTaskFromKey } from \"./checklist\";\nimport { createOutlineStore, outlineOf } from \"./toc\";\nimport { CodeHead, V16_CODE_CLASS, measureCodes, recolourCodes, sameCodes, type CodeHeadState } from \"./code-head\";\nimport { backToMarker, caretAfterMarker, FN_MARK, FOOTNOTE_POPOVER_CLASS, FOOTNOTE_REFUSED, FootnoteEditor, FootnotesList, insertFootnote, renumberFootnotes } from \"./footnote\";\nimport { applyButton, ButtonLinkPanel, buttonAt, buttonInitial, insertButton, removeButton } from \"./button\";\nimport { EMPTY_FMT, FormatToolbar, MARK_FEATURE, stylesFor, type Fmt, type MarkCmd } from \"./toolbar\";\nimport { useKitReducedMotion } from \"../../lib/reduced-motion\";\n\n/* ── Prose styles for the editable surface (kit tokens only) ──\n * Every descendant rule skips `[data-rt-isolate]` subtrees, as V2's (rich-text-editor.tsx:46-58): a block's own UI inside\n * the writing surface (a table island's column headers, a component card's form) is app UI, not prose. */\n/* look v16 (prototype content.css:340): a body quote is 17/28 #3B3B3B italic behind a 2px violet rule, 2/0/2/16 */\nconst V16_QUOTE_CLASS =\n \"[&_blockquote:not([data-rt-isolate]_*)]:border-kit-insp-accent [&_blockquote:not([data-rt-isolate]_*)]:py-0.5 [&_blockquote:not([data-rt-isolate]_*)]:text-[17px] [&_blockquote:not([data-rt-isolate]_*)]:leading-7 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-insp-tip-body\";\n/** Look \"v16\" body (prototype content.css:210 .ce-body .rtx-body, kit.css:281 .rtx-body a): 16/26 text, links #1D51A0 with a same-colour underline. */\nconst V16_BODY_CLASS =\n \"text-[16px] leading-[26px] [&_a:not([data-rt-isolate]_*)]:text-kit-insp-link [&_a:not([data-rt-isolate]_*)]:decoration-current\";\nexport const RT_PROSE =\n \"text-kit-base leading-[1.6] text-kit-fg [&>*+*]:mt-3 \" +\n // BUG-7: a styled run keeps the SITE's class (the stored design), but the site's stylesheet is not here. Only the\n // utilities the dashboard happens to build apply: `text-transparent` without its `bg-clip-text` gradient drew the\n // words invisible. The run's text is drawn as text; the class itself is kept, so a save writes it back unchanged.\n \"[&_span[class]:not([data-rt-isolate]_*)]:!text-inherit [&_span[class]:not([data-rt-isolate]_*)]:![-webkit-text-fill-color:currentColor] [&_span[class]:not([data-rt-isolate]_*)]:!bg-none [&_span[class]:not([data-rt-isolate]_*)]:!opacity-100 [&_span[class]:not([data-rt-isolate]_*)]:!visible \" +\n \"[&_h1:not([data-rt-isolate]_*)]:text-[28px] [&_h1:not([data-rt-isolate]_*)]:font-semibold [&_h1:not([data-rt-isolate]_*)]:leading-9 [&_h1:not([data-rt-isolate]_*)]:tracking-[-0.01em] [&_h2:not([data-rt-isolate]_*)]:text-[22px] [&_h2:not([data-rt-isolate]_*)]:font-semibold [&_h2:not([data-rt-isolate]_*)]:leading-8 [&_h2:not([data-rt-isolate]_*)]:tracking-[-0.01em] \" +\n \"[&_h3:not([data-rt-isolate]_*)]:text-kit-lg [&_h3:not([data-rt-isolate]_*)]:font-semibold [&_h4:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:font-semibold [&_h5:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:uppercase [&_h6:not([data-rt-isolate]_*)]:tracking-wide [&_h6:not([data-rt-isolate]_*)]:text-kit-fg-2 [&>h1]:mt-6 [&>h2]:mt-6 [&>h3]:mt-5 [&>*:first-child]:mt-0 \" +\n // a block's own list (key takeaways, V2 data-rt-isolate) is app UI, not body prose: V2 rich-text-editor.tsx skips it\n \"[&_ul:not([data-rt-isolate]_*)]:list-disc [&_ul:not([data-rt-isolate]_*)]:pl-5 [&_ol:not([data-rt-isolate]_*)]:list-decimal [&_ol:not([data-rt-isolate]_*)]:pl-5 [&_li:not([data-rt-isolate]_*)]:pl-1 [&_li+li:not([data-rt-isolate]_*)]:mt-1 [&_li:not([data-rt-isolate]_*)]:marker:text-kit-fg-3 \" +\n \"[&_ul[data-task]:not([data-rt-isolate]_*)]:list-none [&_ul[data-task]:not([data-rt-isolate]_*)]:pl-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:relative [&_ul[data-task]>li:not([data-rt-isolate]_*)]:pl-7 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:absolute [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:left-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:top-[0.2em] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:flex [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:size-4 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:items-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:justify-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:rounded-kit-md [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border-kit-line-strong [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:bg-kit-surface [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:text-[11px] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:font-semibold [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:leading-none [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:content-[''] \" +\n \"[&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:text-kit-fg-3 [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:line-through [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:border-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:bg-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:text-kit-fg-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:content-['✓'] \" +\n \"[&_blockquote:not([data-rt-isolate]_*)]:border-l-2 [&_blockquote:not([data-rt-isolate]_*)]:border-kit-line-strong [&_blockquote:not([data-rt-isolate]_*)]:pl-4 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-fg-2 [&_blockquote:not([data-rt-isolate]_*)]:italic \" +\n \"[&_a:not([data-rt-isolate]_*)]:text-kit-accent-fg [&_a:not([data-rt-isolate]_*)]:underline [&_a:not([data-rt-isolate]_*)]:decoration-kit-accent-line [&_a:not([data-rt-isolate]_*)]:underline-offset-2 \" +\n \"[&_a[data-button]:not([data-rt-isolate]_*)]:inline-flex [&_a[data-button]:not([data-rt-isolate]_*)]:h-9 [&_a[data-button]:not([data-rt-isolate]_*)]:items-center [&_a[data-button]:not([data-rt-isolate]_*)]:rounded-kit-md [&_a[data-button]:not([data-rt-isolate]_*)]:bg-kit-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:px-3.5 [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-sm [&_a[data-button]:not([data-rt-isolate]_*)]:font-medium [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-fg-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:no-underline \" +\n // a glossary term (`<abbr data-term title>`) reads as a dotted underline; a footnote marker as a small superscript\n \"[&_abbr:not([data-rt-isolate]_*)]:cursor-help [&_abbr:not([data-rt-isolate]_*)]:underline [&_abbr:not([data-rt-isolate]_*)]:decoration-dotted [&_abbr:not([data-rt-isolate]_*)]:underline-offset-2 [&_sup:not([data-rt-isolate]_*)]:text-[0.7em] [&_sup:not([data-rt-isolate]_*)]:leading-none \" +\n \"[&_code:not([data-rt-isolate]_*)]:rounded-kit-md [&_code:not([data-rt-isolate]_*)]:bg-kit-muted [&_code:not([data-rt-isolate]_*)]:px-1 [&_code:not([data-rt-isolate]_*)]:py-px [&_code:not([data-rt-isolate]_*)]:font-kit-mono [&_code:not([data-rt-isolate]_*)]:text-[0.9em] \" +\n \"[&_pre:not([data-rt-isolate]_*)]:overflow-x-auto [&_pre:not([data-rt-isolate]_*)]:whitespace-pre [&_pre:not([data-rt-isolate]_*)]:rounded-kit-lg [&_pre:not([data-rt-isolate]_*)]:bg-kit-code [&_pre:not([data-rt-isolate]_*)]:text-kit-code-fg [&_pre:not([data-rt-isolate]_*)]:p-3 [&_pre:not([data-rt-isolate]_*)]:font-kit-mono [&_pre:not([data-rt-isolate]_*)]:text-kit-sm [&_pre:not([data-rt-isolate]_*)]:border [&_pre:not([data-rt-isolate]_*)]:border-kit-line \" +\n \"[&_pre_code:not([data-rt-isolate]_*)]:rounded-none [&_pre_code:not([data-rt-isolate]_*)]:bg-transparent [&_pre_code:not([data-rt-isolate]_*)]:p-0 [&_pre_code:not([data-rt-isolate]_*)]:text-[1em] \" +\n \"[&_hr:not([data-rt-isolate]_*)]:my-6 [&_hr:not([data-rt-isolate]_*)]:border-kit-line \" +\n // V2 rich-text-editor.tsx 64-65: an image's figure sits 16px off its neighbours (my-4), the picture framed\n \"[&_figure:not([data-rt-isolate]_*)]:my-4 [&_img:not([data-rt-isolate]_*)]:rounded-kit-lg [&_img:not([data-rt-isolate]_*)]:border [&_img:not([data-rt-isolate]_*)]:border-kit-line [&_figcaption:not([data-rt-isolate]_*)]:mt-1.5 [&_figcaption:not([data-rt-isolate]_*)]:text-center [&_figcaption:not([data-rt-isolate]_*)]:text-kit-sm [&_figcaption:not([data-rt-isolate]_*)]:text-kit-fg-3 \" +\n \"[&_figure_img:not([data-rt-isolate]_*)]:block [&_figure[data-size=s]_img:not([data-rt-isolate]_*)]:w-1/3 [&_figure[data-size=m]_img:not([data-rt-isolate]_*)]:w-1/2 [&_figure[data-size=l]_img:not([data-rt-isolate]_*)]:w-3/4 [&_figure[data-align=center]_img:not([data-rt-isolate]_*)]:mx-auto [&_figure[data-align=right]_img:not([data-rt-isolate]_*)]:ml-auto [&_figure[data-align=full]_img:not([data-rt-isolate]_*)]:w-full \" +\n \"[&_div[data-callout]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-callout]:not([data-rt-isolate]_*)]:border [&_div[data-callout]:not([data-rt-isolate]_*)]:border-kit-info-line [&_div[data-callout]:not([data-rt-isolate]_*)]:bg-kit-info-soft [&_div[data-callout]:not([data-rt-isolate]_*)]:px-4 [&_div[data-callout]:not([data-rt-isolate]_*)]:py-3 [&_div[data-callout]:not([data-rt-isolate]_*)]:text-kit-fg \" +\n \"[&_div[data-callout=tip]:not([data-rt-isolate]_*)]:border-kit-success-line [&_div[data-callout=tip]:not([data-rt-isolate]_*)]:bg-kit-success-soft [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:border-kit-warning-line [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:bg-kit-warning-soft [&_div[data-callout]>p[data-title]:not([data-rt-isolate]_*)]:font-medium \" +\n \"[&_details:not([data-rt-isolate]_*)]:rounded-kit-md [&_summary:not([data-rt-isolate]_*)]:cursor-pointer [&_summary:not([data-rt-isolate]_*)]:font-medium [&_details>div:not([data-rt-isolate]_*)]:mt-1 [&_details>div:not([data-rt-isolate]_*)]:border-l [&_details>div:not([data-rt-isolate]_*)]:border-kit-line [&_details>div:not([data-rt-isolate]_*)]:pl-4 [&_details>div:not([data-rt-isolate]_*)]:ml-1 \" +\n \"[&_div[data-rt=columns]:not([data-rt-isolate]_*)]:grid [&_div[data-rt=columns]:not([data-rt-isolate]_*)]:gap-4 [&_div[data-cols='2']:not([data-rt-isolate]_*)]:grid-cols-2 [&_div[data-cols='3']:not([data-rt-isolate]_*)]:grid-cols-3 [&_div[data-cols='4']:not([data-rt-isolate]_*)]:grid-cols-4 [&_div[data-gap=s]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-gap=l]:not([data-rt-isolate]_*)]:gap-7 \" +\n \"[&_div[data-rt=file]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-rt=file]:not([data-rt-isolate]_*)]:px-3 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:py-2.5 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:text-kit-sm \" +\n \"[&_div[data-embed]:not([data-rt-isolate]_*)]:flex [&_div[data-embed]:not([data-rt-isolate]_*)]:aspect-video [&_div[data-embed]:not([data-rt-isolate]_*)]:items-center [&_div[data-embed]:not([data-rt-isolate]_*)]:justify-center [&_div[data-embed]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-embed]:not([data-rt-isolate]_*)]:border [&_div[data-embed]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-embed]:not([data-rt-isolate]_*)]:bg-kit-subtle [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-fg-3 \" +\n \"[&_div[data-block]:not([data-rt-isolate]_*)]:flex [&_div[data-block]:not([data-rt-isolate]_*)]:items-center [&_div[data-block]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-block]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-block]:not([data-rt-isolate]_*)]:border [&_div[data-block]:not([data-rt-isolate]_*)]:border-dashed [&_div[data-block]:not([data-rt-isolate]_*)]:border-kit-accent-line [&_div[data-block]:not([data-rt-isolate]_*)]:bg-kit-accent-softer [&_div[data-block]:not([data-rt-isolate]_*)]:px-3 [&_div[data-block]:not([data-rt-isolate]_*)]:py-3 [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-accent-fg \" +\n \"[&_table:not([data-rt-isolate]_*)]:w-full [&_table:not([data-rt-isolate]_*)]:border-collapse [&_table:not([data-rt-isolate]_*)]:text-kit-sm [&_td:not([data-rt-isolate]_*)]:border [&_td:not([data-rt-isolate]_*)]:border-kit-line [&_td:not([data-rt-isolate]_*)]:px-2.5 [&_td:not([data-rt-isolate]_*)]:py-1.5 [&_td:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:border [&_th:not([data-rt-isolate]_*)]:border-kit-line [&_th:not([data-rt-isolate]_*)]:bg-kit-subtle [&_th:not([data-rt-isolate]_*)]:px-2.5 [&_th:not([data-rt-isolate]_*)]:py-1.5 [&_th:not([data-rt-isolate]_*)]:text-left [&_th:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:font-medium\";\n\n/** Panel density (≈340px inspector): 13px text, smaller headings. */\nexport const RT_PANEL = \"text-kit-sm leading-[1.6] [&_h1:not([data-rt-isolate]_*)]:text-kit-xl [&_h1:not([data-rt-isolate]_*)]:leading-7 [&_h2:not([data-rt-isolate]_*)]:text-kit-lg [&_h2:not([data-rt-isolate]_*)]:leading-7 [&_h3:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:text-kit-xs\";\n\n/** execCommand, where the engine has it (it returns false where it does not). */\nconst exec = (cmd: string, arg?: string): boolean => {\n try {\n return typeof document.execCommand === \"function\" && document.execCommand(cmd, false, arg);\n } catch {\n return false;\n }\n};\n/** A footnote marker (`<sup data-footnote>`, or the table's `<sup><a href=\"#…-fn-n\">`): never an x² mark. */\nconst FOOTNOTE_SUP = \"sup[data-footnote], sup:has(> a[href*='-fn-'])\";\n/** x² / x₂ (V2): on inside the same mark takes it off (unwrap, keeping the words selected); inside the other one swaps;\n * otherwise the browser wraps the selection. Footnote markers are never touched. */\nfunction toggleScript(root: HTMLElement, tag: \"sup\" | \"sub\") {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const at = (n: Node | null) => (n?.nodeType === 1 ? (n as HTMLElement) : (n?.parentElement ?? null));\n const find = (t: \"sup\" | \"sub\") => {\n const el = at(s.anchorNode)?.closest<HTMLElement>(t === \"sup\" ? `sup:not(${FOOTNOTE_SUP})` : \"sub\");\n return el && root.contains(el) ? el : null;\n };\n const unwrap = (el: HTMLElement) => {\n const first = el.firstChild;\n const last = el.lastChild;\n el.replaceWith(...Array.from(el.childNodes));\n if (first && last) {\n const r = document.createRange();\n r.setStartBefore(first);\n r.setEndAfter(last);\n s.removeAllRanges();\n s.addRange(r);\n }\n };\n const same = find(tag);\n if (same) return unwrap(same);\n const other = find(tag === \"sup\" ? \"sub\" : \"sup\");\n if (other) unwrap(other);\n exec(tag === \"sup\" ? \"superscript\" : \"subscript\");\n}\n\n/**\n * RP-012: underline inside a link. The browser reads a link's own decoration as the mark, so its underline command\n * there turns nothing on and the mark was dropped in silence. Inside one link the mark is ours: an explicit `<u>` around\n * the selection, taken off again when the selection sits in one. False when the selection is not inside one link (the\n * browser's own command runs).\n */\nfunction toggleLinkUnderline(root: HTMLElement): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n const at = (n: Node | null) => (n?.nodeType === 1 ? (n as HTMLElement) : (n?.parentElement ?? null));\n const link = at(r.startContainer)?.closest(\"a\");\n if (!link || !root.contains(link) || at(r.endContainer)?.closest(\"a\") !== link) return false;\n const select = (first: Node, last: Node) => {\n const nr = document.createRange();\n nr.setStartBefore(first);\n nr.setEndAfter(last);\n s.removeAllRanges();\n s.addRange(nr);\n };\n // in a mark, or around exactly one (the selection the wrap below leaves can be read either way)\n const inside = at(r.startContainer)?.closest(\"u\");\n const around = r.startContainer === r.endContainer && r.endOffset - r.startOffset === 1 ? r.startContainer.childNodes[r.startOffset] : null;\n const on = inside && link.contains(inside) ? inside : around instanceof HTMLElement && around.tagName === \"U\" ? around : null;\n if (on) {\n const kids = Array.from(on.childNodes);\n on.replaceWith(...kids);\n if (kids.length) select(kids[0]!, kids[kids.length - 1]!);\n return true;\n }\n const u = document.createElement(\"u\");\n u.append(r.extractContents());\n r.insertNode(u);\n s.selectAllChildren(u);\n return true;\n}\n/** The underline mark at `el`: inside a link only an explicit `<u>` counts (the link's own decoration is not the mark). */\nconst underlineAt = (el: HTMLElement | null | undefined) => (el?.closest(\"a\") ? !!el.closest(\"u\") : queryState(\"underline\"));\n\n/** Focus is in another text field (the comment composer, a link input) while the page's selection stays in this editor. */\nconst typingElsewhere = (el: HTMLElement | null) => {\n const ae = document.activeElement;\n return !!el && !!ae && ae !== el && !el.contains(ae) && ae.matches(\"input, textarea, [contenteditable='true']\");\n};\nconst queryState = (c: string) => {\n try {\n return typeof document.queryCommandState === \"function\" && document.queryCommandState(c);\n } catch {\n return false;\n }\n};\n/** Insert HTML at the caret: the browser's own insert (undoable), else by hand. */\nfunction insertHtmlAtCaret(html: string) {\n if (exec(\"insertHTML\", html)) return;\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const r = s.getRangeAt(0);\n r.deleteContents();\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = sanitize(html);\n const last = tpl.content.lastChild;\n r.insertNode(tpl.content);\n if (last) {\n r.setStartAfter(last);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n}\n/* ── Word count (V2 rich-text-editor.tsx:115-128 + article.ts countWords, CPO D54 / D55) ──\n * Words = what the writer wrote once, in the flow a reader follows: text, headings, lists, quotes, callouts, toggles,\n * table cells and image captions. Not counted: components (counted apart), a pull quote (it repeats a line of the\n * story), key takeaways (they restate it), a table of contents, related reading, the author card, embeds, video and\n * file links, the footnotes list and a footnote mark (V2 article.ts NOT_COUNTED, verbatim: D2, 278 → 262 words on\n * rich-blog-post). */\nconst NOT_COUNTED = [\n \"[data-rt=component]\", \"[data-rt=pullquote]\", \"[data-rt=takeaways]\", \"[data-rt=toc]\", \"[data-rt=related]\", \"[data-rt=author]\",\n \"[data-rt=embed]\", \"[data-rt=video]\", \"[data-rt=file]\", \"[data-rt=footnotes]\", \"sup[data-rt=fn]\",\n].join(\",\");\nconst WORDS = (s: string) => s.replace(/\\u200b/g, \"\").trim().split(/\\s+/).filter(Boolean).length;\nexport function countWords(html: string): number {\n if (!html) return 0;\n if (!/data-rt=\"(?:component|pullquote|takeaways|toc|related|author|embed|video|file|footnotes|fn)\"/.test(html) || typeof DOMParser === \"undefined\")\n // V2 article.ts, verbatim (owner rule: V2 exact): every tag parts words, so a mark inside a word counts it twice\n return WORDS(html.replace(/<[^>]+>/g, \" \").replace(/ |&[a-z]+;/g, \" \"));\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(NOT_COUNTED).forEach((n) => n.remove());\n doc.body.querySelectorAll(\"p,li,h1,h2,h3,h4,h5,h6,td,th,figcaption,summary,pre,blockquote,div\").forEach((n) => n.append(\" \"));\n return WORDS(doc.body.textContent ?? \"\");\n}\n/** Linked component instances in the body. */\nexport const countComponents = (html: string) => (html.match(/data-rt=\"component\"/g) ?? []).length;\n\nfunction insertTextAtCaret(text: string) {\n if (exec(\"insertText\", text)) return;\n const s = window.getSelection();\n if (!s || !s.rangeCount) return;\n const r = s.getRangeAt(0);\n r.deleteContents();\n const t = document.createTextNode(text);\n r.insertNode(t);\n r.setStartAfter(t);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n}\n\n/** The slash menu at full height (header 32, list 300, footer 28, borders), the least it shrinks to, and the gap it keeps from the window's edge. */\nconst SLASH_MENU_H = 362;\nconst SLASH_MIN_H = 160;\nconst SLASH_EDGE = 8;\n\n/**\n * Where the slash menu goes, collision-aware: below the caret when the whole menu fits there, else on the side with\n * more room, and never taller than that room (its list scrolls), so the last row (More components) stays reachable in\n * a short window.\n */\nexport function slashPlacement(caret: { top: number; bottom: number }, viewportH: number): { flipUp: boolean; maxHeight: number } {\n const below = viewportH - caret.bottom - 6 - SLASH_EDGE;\n const above = caret.top - 6 - SLASH_EDGE;\n const flipUp = below < SLASH_MENU_H && above > below;\n return { flipUp, maxHeight: Math.max(SLASH_MIN_H, Math.min(SLASH_MENU_H, flipUp ? above : below)) };\n}\n\n/** RP-043: Block options › Language. Stored as the token (`language-typescript`); \"None\" stores no language. */\nconst CODE_LANGUAGES: { v: string; label: string }[] = [\n { v: \"bash\", label: \"Bash\" },\n { v: \"css\", label: \"CSS\" },\n { v: \"html\", label: \"HTML\" },\n { v: \"javascript\", label: \"JavaScript\" },\n { v: \"json\", label: \"JSON\" },\n { v: \"markdown\", label: \"Markdown\" },\n { v: \"python\", label: \"Python\" },\n { v: \"sql\", label: \"SQL\" },\n { v: \"typescript\", label: \"TypeScript\" },\n { v: \"yaml\", label: \"YAML\" },\n];\n// never a language token (those are [a-z0-9-])\n/** Look \"v16\": one half of the block handle pill (prototype content.css:488-491): 22×24, radius 5, a quiet grey that darkens with the pill. */\nconst V16_HANDLE_BTN =\n \"flex h-6 w-[22px] items-center justify-center rounded-[5px] text-kit-insp-faint outline-none transition-colors duration-100 group-hover/bh:text-kit-insp-quiet hover:!bg-kit-insp-card-hover hover:!text-kit-insp-tip-title focus-visible:bg-kit-insp-card-hover focus-visible:text-kit-insp-tip-title data-[popup-open]:bg-kit-insp-card-hover data-[popup-open]:text-kit-insp-tip-title [&_svg]:size-3.5\";\nconst LANG_NONE = \"_none\";\nconst LANG_OTHER = \"_other\";\nconst CODE_LANGUAGE_REASON = \"Use letters, numbers and hyphens, like cpp or csharp.\";\n\n/** An island's model change, or (`dom`) a block deleted or turned into others: undone and redone in place by index. */\ntype IslandStep =\n | { el: IslandEl; before: IslandModels[IslandKind]; label: string; at: number; dom?: undefined }\n | { dom: { undo: () => boolean; redo: () => boolean }; label: string; at: number; el?: undefined; before?: undefined };\n/** A step the host's history holds (KitServices.historyStep); its undo and redo are the host's, while it is next. */\ntype HostStep = { label: string; step: KitHistoryStep };\ntype GutterState = { el: HTMLElement; top: number; height: number };\ntype SlashState = { rect: DOMRect; node: Text; offset: number; query: string; folder: boolean; active: number; /** look v16: the BetterCMS AI view */ ai?: boolean };\ntype LinkState = { rect: DOMRect; initial: TextLink; existing: HTMLAnchorElement | null; button?: { a: HTMLAnchorElement; label: string } };\ntype Notice = { message: string; description?: string; action?: { label: string; onClick: () => void } };\n\nexport interface RichTextEditorProps {\n value: string;\n onChange: (html: string) => void;\n readOnly?: boolean;\n placeholder?: string;\n docKey: string;\n /** what the field accepts; the editor offers nothing else (default: everything) */\n features?: readonly RichTextFeature[];\n /** where an author bio and related posts point (the host codec's RichTextRead.references) */\n references?: RichTextRead[\"references\"];\n /** a one-paragraph field: Enter starts no new block */\n single?: boolean;\n /** links may open in a new tab */\n allowNewTab?: boolean;\n /** the writing surface's id (the field label's `for`; its label is `${id}-label`) */\n id?: string;\n invalid?: boolean;\n /** panel = narrow (~340px) inspector, document = the full editor column. */\n variant?: \"panel\" | \"document\";\n /** CPO D49: the expanded editor's breadcrumb, root → this field (\"Alternating feature rows\", \"Thin walls\", \"Body\"). */\n expandCrumbs?: string[];\n /** Controlled expanded modal (a host's label-row action opens it too). */\n expandedOpen?: boolean;\n onExpandedOpenChange?: (open: boolean) => void;\n /** Look \"v16\" Focus mode (⇧⌘F, the toolbar's Focus): the host's full-screen view. Answers false (or absent) → the expanded editor opens. */\n onFocusMode?: () => boolean | void;\n /** This editor IS the body of the expanded modal: toolbar always shown, tall writing surface. */\n inModal?: boolean;\n /** Already the full editor: no Expand button. */\n hideFullscreen?: boolean;\n /** Scroll the writing surface beyond this height (px). */\n maxHeight?: number;\n autoFocus?: boolean;\n /** Shows the toolbar Comment button. `around`: up to 32 characters of the text before and after the words (GAP-004). */\n onComment?: (quote: string, around?: { prefix: string; suffix: string }) => void;\n /** GAP-004: Comment opens the field's own popover (under the field), so the expanded editor offers none */\n commentInPlace?: boolean;\n /** the components this field may embed (the insert menus' More components); absent → none offered */\n components?: CatalogComponents;\n}\n\n/**\n * True while a `<fieldset>` around `el` is disabled. A host holds a form that way (a locked section's dock form, a save\n * in flight): the fieldset disables every form control in it, but a contenteditable is no form control, so the editor\n * reads the fence itself (NEW-Q40-LOCKRTE).\n */\nfunction useDisabledFieldset(el: React.RefObject<HTMLElement | null>): boolean {\n const [fenced, setFenced] = React.useState(false);\n React.useLayoutEffect(() => {\n const node = el.current;\n if (!node) return;\n const read = () => setFenced(!!node.closest(\"fieldset:disabled\"));\n read();\n const watch = new MutationObserver(read);\n for (let f = node.closest(\"fieldset\"); f; f = f.parentElement?.closest(\"fieldset\") ?? null) watch.observe(f, { attributes: true, attributeFilter: [\"disabled\"] });\n return () => watch.disconnect();\n }, [el]);\n return fenced;\n}\n\n/* ── Editor ────────────────────────────────────────────────────────── */\nexport function RichTextEditor({\n value,\n onChange,\n readOnly: readOnlyProp,\n placeholder,\n docKey,\n features = ALL_FEATURES,\n references,\n single,\n allowNewTab = true,\n id,\n invalid,\n variant = \"document\",\n expandCrumbs,\n expandedOpen,\n onExpandedOpenChange,\n onFocusMode,\n inModal,\n hideFullscreen,\n maxHeight,\n autoFocus,\n onComment,\n commentInPlace,\n components,\n}: RichTextEditorProps) {\n const hints = shortcutHintsOn();\n const ph = placeholder ?? (hints ? \"Type '/' for commands\" : \"Write something…\");\n const dense = variant === \"panel\";\n const ref = React.useRef<HTMLDivElement>(null);\n const wrap = React.useRef<HTMLDivElement>(null);\n /* a disabled fieldset around the editor holds it like the form controls beside it: read-only, no toolbar */\n const fenced = useDisabledFieldset(wrap);\n const readOnly = !!readOnlyProp || fenced;\n const scroller = React.useRef<HTMLDivElement>(null);\n const saved = React.useRef<Range | null>(null);\n const known = React.useRef<string | null>(null);\n const pending = React.useRef<string | null>(null);\n /** a host undo just ran: its value is loaded even while the editor has focus (⌘Z here) */\n const forceLoad = React.useRef(false);\n const prevDoc = React.useRef<string | null>(null);\n const onChangeRef = React.useRef(onChange);\n onChangeRef.current = onChange;\n const valueRef = React.useRef(value);\n valueRef.current = value;\n const services = useKitServices();\n const env = useKitEnv();\n /* Look \"v16\" (prototype content.jsx:1142-1177, content.css:486-492): the block handle is one 49×26 pill (+ · grip,\n white with a hairline on hover), its menu is 200 wide with \"Delete block\", and a move says \"Block moved\". */\n const v16 = useKitLook() === \"v16\";\n const featureKey = features.join(\",\");\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const allows = React.useCallback((f: RichTextFeature) => features.includes(f), [featureKey]);\n\n const [empty, setEmpty] = React.useState(isEmptyHtml(value));\n const [words, setWords] = React.useState(() => countWords(value));\n const [comps, setComps] = React.useState(() => countComponents(value));\n const [fmt, setFmt] = React.useState<Fmt>(EMPTY_FMT);\n const [modalOwn, setModalOwn] = React.useState(false);\n const modalOpen = expandedOpen ?? modalOwn;\n const setModalOpen = (o: boolean) => (onExpandedOpenChange ? onExpandedOpenChange(o) : setModalOwn(o));\n /** r7 #4: Focus mode is the host's full-screen writing view when it has one, else the expanded editor */\n const openFocus = () => {\n if (onFocusMode && onFocusMode() !== false) return;\n setModalOpen(true);\n };\n const [md, setMd] = React.useState<{ text: string; original: string } | null>(null);\n const [mdConfirm, setMdConfirm] = React.useState(false);\n // Reduced motion: the Markdown confirm fades only (no slide).\n const reduceMotion = useKitReducedMotion();\n // the slash menu's appear (every look): framer's config reading, so a host <MotionConfig reducedMotion=\"always\"> counts\n const slashReduce = !!useKitReducedMotion();\n const [bubble, setBubble] = React.useState<DOMRect | null>(null);\n /** Comment was picked: the toolbar stays away until the next click or key inside this editor */\n const [quiet, setQuiet] = React.useState(false);\n React.useEffect(() => {\n const el = ref.current;\n if (!quiet || !el) return;\n const wake = () => setQuiet(false);\n el.addEventListener(\"mousedown\", wake);\n el.addEventListener(\"keydown\", wake);\n return () => {\n el.removeEventListener(\"mousedown\", wake);\n el.removeEventListener(\"keydown\", wake);\n };\n }, [quiet]);\n const [slash, setSlash] = React.useState<SlashState | null>(null);\n const [gutter, setGutter] = React.useState<GutterState | null>(null);\n const [blockMenu, setBlockMenu] = React.useState(false);\n const [gutterInsert, setGutterInsert] = React.useState(false);\n const gutterTarget = React.useRef<HTMLElement | null>(null);\n /** RP-043: Block options › Language › Other…, a typed language for this code block (`top`/`height`: where it sits) */\n const [langOther, setLangOther] = React.useState<{ pre: HTMLElement; value: string; error: string | null; top: number; height: number } | null>(null);\n const langId = React.useId();\n // D58: AI writing help follows ai.use and needs the host's AI service; without both no AI entry point is drawn.\n const canAI = env.can(\"ai.use\") && !!services.aiRewrite;\n // look v16: the slash menu's \"BetterCMS AI\" view, drawn only when the host can run its commands\n const canAiCommand = aiCommandsOffered(v16, env.can(\"ai.use\"), services.aiCommand);\n const aiAttempt = React.useRef(0);\n const [link, setLink] = React.useState<LinkState | null>(null);\n const [drag, setDrag] = React.useState<{ from: HTMLElement; line: number | null; target: Element | null } | null>(null);\n const [focused, setFocused] = React.useState(false);\n const [menus, setMenus] = React.useState({ style: false, more: false });\n const [insertOpen, setInsertOpen] = React.useState(false);\n const inserted = React.useRef(false);\n const [islands, setIslands] = React.useState<{ id: string; el: IslandEl }[]>([]);\n const hist = React.useRef<{ past: IslandStep[]; future: IslandStep[]; textAt: number; hosts: HostStep[] }>({ past: [], future: [], textAt: 0, hosts: [] });\n const [width, setWidth] = React.useState(720);\n /* The block gutter (+ / grip) never reserves room inside the field: it floats in the space LEFT of the box when the\n host leaves ≥ 48px there (document columns), and sits in the box's padding otherwise. */\n const [gutterRoom, setGutterRoom] = React.useState(false);\n const blurTimer = React.useRef<number | undefined>(undefined);\n const [notice, setNotice] = React.useState<Notice | null>(null);\n /* look v16: each code block's header + gutter overlay (code-head.tsx), placed after every render and on resize */\n const [codes, setCodes] = React.useState<CodeHeadState[]>([]);\n const v16Ref = React.useRef(v16);\n v16Ref.current = v16;\n const placeCodes = React.useCallback((force?: boolean) => {\n const next = v16Ref.current ? measureCodes(ref.current, scroller.current) : [];\n setCodes((p) => (!force && sameCodes(p, next) ? p : next));\n }, []);\n\n const expanded = !!inModal;\n // look v16 (prototype content.css .ce-tb / richtext.jsx .rtx-bar): the toolbar is always there, not only while the field has focus\n const toolbarOpen = !readOnly && (v16 || focused || menus.style || menus.more || insertOpen || expanded || !!md || !!link);\n const fieldActive = focused || menus.style || menus.more || insertOpen || expanded || !!md || !!link;\n const scrollable = !!maxHeight && !expanded;\n\n /** A refusal or a result the author must see: the host's toaster, else a line under the editor. Never silent. */\n const notify = React.useCallback(\n (message: string, opts: { description?: string; action?: Notice[\"action\"] } = {}) => {\n if (services.toast) services.toast(message, opts);\n else setNotice({ message, ...opts });\n },\n [services],\n );\n React.useEffect(() => {\n if (!notice) return;\n const t = window.setTimeout(() => setNotice(null), 8000);\n return () => window.clearTimeout(t);\n }, [notice]);\n\n /* ── islands ─────────────────────────────────────────────────────── */\n /** V2 article-blocks.tsx:45-66: one live outline per editor, so every table of contents follows the headings */\n const outline = React.useRef(createOutlineStore());\n /** V2 rich-text-editor.tsx:271-276: the body's markers in text order, and the one whose note is open */\n const [footnotes, setFootnotes] = React.useState<{ el: HTMLElement; note: string }[]>([]);\n const [fnEdit, setFnEdit] = React.useState<{ el: HTMLElement; rect: DOMRect; fresh: boolean } | null>(null);\n const syncIslands = React.useCallback(() => {\n const el = ref.current;\n if (!el) return setIslands((p) => (p.length ? [] : p));\n const list = Array.from(el.querySelectorAll<IslandEl>(\":scope > [data-rt-island]\"));\n const seen = new Set<string>();\n for (const x of list) {\n if (!x.__rt) {\n // a copy the browser made (drag/drop, native undo of a clone): start it fresh\n x.innerHTML = \"\";\n x.__rt = defaultModel(x.getAttribute(\"data-rt-island\") as IslandKind);\n delete x.dataset.rtId;\n }\n if (!x.dataset.rtId || seen.has(x.dataset.rtId)) x.dataset.rtId = rid(\"i\");\n seen.add(x.dataset.rtId);\n }\n setIslands((prev) => (prev.length === list.length && prev.every((p, i) => p.el === list[i]) ? prev : list.map((x) => ({ id: x.dataset.rtId!, el: x }))));\n }, []);\n\n /* ── value in / out ──────────────────────────────────────────────── */\n const load = React.useCallback(\n (html: string) => {\n const el = ref.current;\n if (!el) return;\n el.innerHTML = sanitize(html || \"\") || \"<p><br></p>\";\n // the notes list is derived from the markers (V2: dropped on load, written on render); a marker is not text\n el.querySelectorAll(':scope > ol[data-rt=\"footnotes\"]').forEach((n) => n.remove());\n el.querySelectorAll<HTMLElement>(FN_MARK).forEach((m) => m.setAttribute(\"contenteditable\", \"false\"));\n hydrate(el);\n if (v16Ref.current) recolourCodes(el);\n syncTaskA11y(el);\n setFootnotes(renumberFootnotes(el));\n outline.current.set(outlineOf(el));\n known.current = html;\n setEmpty(isEmptyHtml(html));\n setWords(countWords(html));\n setComps(countComponents(html));\n syncIslands();\n },\n [syncIslands],\n );\n\n const emit = React.useCallback(() => {\n const el = ref.current;\n if (!el) return;\n syncIslands();\n syncTaskA11y(el);\n outline.current.set(outlineOf(el));\n setFootnotes(renumberFootnotes(el));\n const html = serialize(el);\n setEmpty(isEmptyHtml(html) && !el.querySelector(\":scope > [data-rt-island], :scope > hr\"));\n setWords(countWords(html));\n setComps(countComponents(html));\n if (html === known.current) return;\n forceLoad.current = false;\n known.current = html;\n onChangeRef.current(html);\n }, [syncIslands]);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const docChanged = prevDoc.current !== null && prevDoc.current !== docKey;\n prevDoc.current = docKey;\n if (pending.current !== null) {\n const h = pending.current;\n pending.current = null;\n load(h);\n return;\n }\n if (forceLoad.current && value !== known.current) {\n forceLoad.current = false;\n load(value);\n return;\n }\n if (docChanged || !el.firstChild || (value !== known.current && !wrap.current?.contains(document.activeElement))) load(value);\n }, [value, docKey, md, load]);\n\n React.useEffect(() => {\n setMd(null);\n setMdConfirm(false);\n setSlash(null);\n setLink(null);\n setGutter(null);\n }, [docKey]);\n\n React.useEffect(() => {\n exec(\"defaultParagraphSeparator\", \"p\");\n if (autoFocus && ref.current && !readOnly) {\n ref.current.focus({ preventScroll: true });\n placeCaret(ref.current.lastElementChild ?? ref.current);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n const w = wrap.current;\n if (!w || typeof ResizeObserver === \"undefined\") return;\n const measureRoom = () => {\n let a = w.parentElement;\n while (a && a !== document.body) {\n const cs = getComputedStyle(a);\n if (cs.overflowX !== \"visible\" || cs.overflowY !== \"visible\") break;\n a = a.parentElement;\n }\n const left = w.getBoundingClientRect().left - (a ? a.getBoundingClientRect().left : 0);\n setGutterRoom(left >= 48);\n };\n const ro = new ResizeObserver(([e]) => {\n setWidth(Math.round(e.contentRect.width));\n measureRoom();\n });\n ro.observe(w);\n return () => ro.disconnect();\n }, []);\n\n /* look v16: code block overlays follow every render (typing, islands) and the body's own size (an image loading) */\n React.useLayoutEffect(() => placeCodes());\n React.useEffect(() => {\n const el = ref.current;\n if (!v16 || !el || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => placeCodes());\n ro.observe(el);\n return () => ro.disconnect();\n }, [v16, placeCodes]);\n\n /* the toolbar sticks below any sticky header (e.g. field tabs) in the same scroll area */\n const [stickyTop, setStickyTop] = React.useState(0);\n React.useEffect(() => {\n const w = wrap.current;\n if (!toolbarOpen || dense || !w) return;\n let sp = w.parentElement;\n while (sp && !/(auto|scroll)/.test(getComputedStyle(sp).overflowY)) sp = sp.parentElement;\n if (!sp) return setStickyTop(0);\n let top = 0;\n sp.querySelectorAll<HTMLElement>(\".sticky\").forEach((h) => {\n if (h.contains(w) || w.contains(h) || !(h.compareDocumentPosition(w) & Node.DOCUMENT_POSITION_FOLLOWING)) return;\n const cs = getComputedStyle(h);\n if (cs.position !== \"sticky\") return;\n top = Math.max(top, (parseFloat(cs.top) || 0) + h.offsetHeight);\n });\n setStickyTop(top);\n }, [toolbarOpen, dense]);\n\n // the slash menu follows the caret when anything scrolls; it closes only when the caret has left the \"/\" it was opened for\n const hasSlash = !!slash;\n // BL-540: the \"/query\" typed while the menu was open is saved once, when it closes (onInput holds it back)\n const slashWasOpen = React.useRef(false);\n React.useEffect(() => {\n if (hasSlash) slashWasOpen.current = true;\n else if (slashWasOpen.current) {\n slashWasOpen.current = false;\n emit();\n }\n }, [hasSlash, emit]);\n React.useEffect(() => {\n if (!hasSlash) return;\n let raf = 0;\n const on = (e: Event) => {\n if (e.target instanceof Element && e.target.closest(\"[role=listbox]\")) return;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() =>\n setSlash((sl) => {\n const s = window.getSelection();\n if (!sl || !s || !s.rangeCount || s.getRangeAt(0).startContainer !== sl.node) return null;\n const rect = rangeRect(s.getRangeAt(0), sl.node.parentElement ?? ref.current);\n return rect.top === sl.rect.top && rect.left === sl.rect.left ? sl : { ...sl, rect };\n }),\n );\n };\n window.addEventListener(\"scroll\", on, true);\n return () => {\n cancelAnimationFrame(raf);\n window.removeEventListener(\"scroll\", on, true);\n };\n }, [hasSlash]);\n\n // keep the bubble on the selection while anything scrolls (incl. the toolbar sliding open)\n const hasBubble = !!bubble;\n React.useEffect(() => {\n if (!hasBubble) return;\n let raf = 0;\n const on = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() => {\n const s = window.getSelection();\n const ok = s && s.rangeCount && !s.isCollapsed && ref.current?.contains(s.anchorNode) && !typingElsewhere(ref.current);\n setBubble(ok ? rangeRect(s!.getRangeAt(0), ref.current) : null);\n });\n };\n window.addEventListener(\"scroll\", on, true);\n window.addEventListener(\"resize\", on);\n // The toolbar sliding open moves the words without a scroll: the bubble sat on the selected word.\n const box = new ResizeObserver(on);\n if (wrap.current) box.observe(wrap.current);\n return () => {\n cancelAnimationFrame(raf);\n box.disconnect();\n window.removeEventListener(\"scroll\", on, true);\n window.removeEventListener(\"resize\", on);\n };\n }, [hasBubble]);\n\n /* ── selection ───────────────────────────────────────────────────── */\n const saveSel = () => {\n const s = window.getSelection();\n if (s && s.rangeCount && ref.current?.contains(s.anchorNode)) saved.current = s.getRangeAt(0).cloneRange();\n };\n const restoreSel = () => {\n const el = ref.current;\n if (!el) return;\n const r = saved.current;\n const s = window.getSelection();\n if (r && el.contains(r.startContainer) && s) {\n (editingHost(r.startContainer) ?? el).focus({ preventScroll: true });\n s.removeAllRanges();\n s.addRange(r);\n } else {\n el.focus({ preventScroll: true });\n placeCaret(el.lastElementChild ?? el);\n }\n };\n\n const refresh = React.useCallback(() => {\n const el = ref.current;\n const s = window.getSelection();\n if (!el || !s || !s.rangeCount || !el.contains(s.anchorNode)) return;\n // typing somewhere else (the comment composer, a link field) keeps the page's selection here: no toolbar over it\n if (typingElsewhere(el)) {\n setBubble(null);\n return;\n }\n saved.current = s.getRangeAt(0).cloneRange();\n const anchorEl = s.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode?.parentElement;\n const inIsland = !!anchorEl?.closest(\"[data-rt-island]\");\n const tb = topBlock(el, s.anchorNode);\n const r = s.getRangeAt(0);\n const hasSel = !s.isCollapsed && !!r.toString().trim();\n const next: Fmt = {\n bold: queryState(\"bold\") && !/^H[1-6]$/.test(tb?.tagName ?? \"\"),\n italic: queryState(\"italic\"),\n underline: underlineAt(anchorEl),\n strike: queryState(\"strikeThrough\"),\n // our own check: the base CSS resets sup/sub alignment, so the browser's own state for them always reads false\n sup: !!anchorEl?.closest(`sup:not(${FOOTNOTE_SUP})`),\n sub: !!anchorEl?.closest(\"sub\"),\n ul: !inIsland && tb?.tagName === \"UL\",\n ol: !inIsland && tb?.tagName === \"OL\",\n block: inIsland ? \"island\" : (tb?.tagName.toLowerCase() ?? \"p\"),\n hasSel,\n onLink: !!anchorEl?.closest(\"a\"),\n };\n setFmt((p) => (JSON.stringify(p) === JSON.stringify(next) ? p : next));\n setBubble(hasSel ? rangeRect(r, el) : null);\n el.querySelectorAll(\":scope > [data-hint]\").forEach((n) => (n !== tb || n.textContent) && n.removeAttribute(\"data-hint\"));\n if (tb && tb.tagName === \"P\" && s.isCollapsed && !tb.textContent && !tb.querySelector(\"img\") && document.activeElement === el && shortcutHintsOn()) tb.setAttribute(\"data-hint\", \"Type '/' for commands\");\n }, []);\n\n React.useEffect(() => {\n const on = () => refresh();\n // focus moving into another text field (the comment composer opening) fires no selectionchange: hide on focusin too\n const away = () => typingElsewhere(ref.current) && setBubble(null);\n document.addEventListener(\"selectionchange\", on);\n document.addEventListener(\"focusin\", away);\n return () => {\n document.removeEventListener(\"selectionchange\", on);\n document.removeEventListener(\"focusin\", away);\n };\n }, [refresh]);\n\n const run = (fn: () => void) => {\n restoreSel();\n fn();\n emit();\n refresh();\n };\n\n /* ── gutter ──────────────────────────────────────────────────────── */\n const placeGutter = (b: HTMLElement | null) => {\n const sc = scroller.current;\n if (!b || !sc) return setGutter(null);\n const sr = sc.getBoundingClientRect();\n const br = b.getBoundingClientRect();\n setGutter((g) => {\n const top = br.top - sr.top + sc.scrollTop;\n return g && g.el === b && g.top === top ? g : { el: b, top, height: br.height };\n });\n };\n const currentBlock = (): HTMLElement | null => {\n const el = ref.current;\n if (!el) return null;\n const s = window.getSelection();\n return topBlock(el, s && s.rangeCount && el.contains(s.anchorNode) ? s.anchorNode : document.activeElement);\n };\n\n /* ── block operations (DOM work lives in ./ops) ─────────── */\n /**\n * r7 P0: a block deleted (or turned into others) is ONE undo step: the host's history when it keeps one, else this\n * editor's. ⌘Z and the toast's Undo run that same undo, which puts the block back at its index (the body may have\n * been reloaded since, so the old neighbours are not trusted), and a refusal is said, never a silent no-op.\n */\n const structuralStep = (label: string, change: () => void, undo: () => boolean, redo: () => boolean) => {\n const h = hist.current;\n const historyStep = services.historyStep;\n const host = historyStep\n ? historyStep(() => {\n change();\n emit();\n })\n : null;\n let undoIt: () => true | string;\n if (host) {\n h.hosts = [...h.hosts, { label, step: host }].slice(-100);\n undoIt = () => runHost(host.undo);\n } else {\n if (!historyStep) {\n change();\n emit();\n }\n const s: IslandStep = { dom: { undo, redo }, label, at: Date.now() };\n h.past = [...h.past, s].slice(-100);\n h.future = [];\n undoIt = () => {\n if (!h.past.includes(s)) return \"It was undone already.\";\n if (!undo()) return \"The editor was closed, so there is nothing to undo here.\";\n h.past = h.past.filter((x) => x !== s);\n s.at = Date.now();\n h.future = [...h.future, s];\n return true;\n };\n }\n notify(label, {\n action: {\n label: \"Undo\",\n onClick: () => {\n const r = undoIt();\n if (r !== true) notify(\"Nothing was undone\", { description: r });\n },\n },\n });\n };\n /** puts `b` back at `index` among the body's blocks (after a reload too), dropping the filler a delete left */\n const reinsert = (b: HTMLElement, index: number, filler: HTMLElement | null): boolean => {\n const root = ref.current;\n if (!root) return false;\n if (filler?.isConnected && !filler.textContent) filler.remove();\n else if (!filler && root.children.length === 1 && isEmptyHtml(root.innerHTML)) root.firstElementChild?.remove();\n const at = root.children[index];\n if (at) root.insertBefore(b, at);\n else root.append(b);\n emit();\n return true;\n };\n\n const deleteBlock = (b: HTMLElement, label = \"Block deleted\") => {\n const el = ref.current;\n if (!el || !el.contains(b)) return;\n const index = Array.prototype.indexOf.call(el.children, b);\n let filler: HTMLElement | null = null;\n const remove = () => {\n const root = ref.current;\n if (!root) return false;\n b.remove();\n filler = null;\n if (!root.firstElementChild) {\n filler = document.createElement(\"p\");\n filler.innerHTML = \"<br>\";\n root.append(filler);\n }\n return true;\n };\n setGutter(null);\n setBlockMenu(false);\n structuralStep(\n label,\n () => void remove(),\n () => reinsert(b, index, filler),\n () => {\n if (!remove()) return false;\n emit();\n return true;\n },\n );\n };\n\n /** look v16 \"Turn into\" on a block island: the block becomes `nodes`, the caret goes to the first, Undo puts it back */\n const replaceBlock = (b: HTMLElement, nodes: HTMLElement[], label: string) => {\n const el = ref.current;\n if (!el || !el.contains(b) || !nodes.length) return;\n const index = Array.prototype.indexOf.call(el.children, b);\n setGutter(null);\n structuralStep(\n label,\n () => b.replaceWith(...nodes),\n () => {\n const root = ref.current;\n if (!root) return false;\n // the new blocks, or (after a reload) whatever now stands in their place\n const now = nodes[0].isConnected ? nodes : Array.from(root.children).slice(index, index + nodes.length);\n now.forEach((n) => n.remove());\n return reinsert(b, index, null);\n },\n () => {\n const root = ref.current;\n if (!root || !b.isConnected) return false;\n b.replaceWith(...nodes);\n emit();\n return true;\n },\n );\n if (nodes[0].isConnected) placeCaret(nodes[0]);\n };\n\n const duplicateBlock = (b: HTMLElement) => {\n const c = ops.duplicateBlock(b);\n emit();\n if (gutter) placeGutter(c);\n };\n\n const moveBlock = (b: HTMLElement, dir: -1 | 1) => {\n if (!ops.moveBlock(b, dir)) return false;\n emit();\n if (gutter) requestAnimationFrame(() => placeGutter(b));\n return true;\n };\n\n const turnInto = (b: HTMLElement | null, tag: string) => {\n const el = ref.current;\n if (el && ops.turnInto(el, b, tag)) emit();\n };\n\n /** RP-043: a code block's language from Block options (one change, one emit; ⌘Z right after it takes it back). */\n const setCodeLanguage = (pre: HTMLElement, lang: string | null) => {\n const el = ref.current;\n if (!el || !el.contains(pre) || ops.codeLanguage(pre) === lang) return;\n run(() => ops.changeCodeLanguage(el, pre, lang));\n };\n const submitOtherLanguage = () => {\n if (!langOther) return;\n const v = langOther.value.trim().toLowerCase();\n if (!ops.CODE_LANGUAGE.test(v)) return setLangOther({ ...langOther, error: CODE_LANGUAGE_REASON });\n setLangOther(null);\n setCodeLanguage(langOther.pre, v);\n };\n\n const exitIsland = (x: HTMLElement) => {\n const el = ref.current;\n if (!el || !el.contains(x)) return;\n const next = ops.ensureLineAfter(x);\n el.focus({ preventScroll: true });\n placeCaret(next, false);\n emit();\n };\n\n const insertBlock = (it: CatalogItem) => {\n const el = ref.current;\n if (!el || readOnly) return;\n if (it.kind === \"component\" && it.component) {\n // V2 insert: a fresh linked instance, ONE undo step\n const c = it.component;\n noteRecent(it);\n const made: { el: IslandEl | null } = { el: null };\n oneStep(`Insert ${c.name}`, () => {\n const isl = (made.el = ops.insertIsland(el, \"component\", { ...defaultModel(\"component\"), ref: c.id, name: c.name }));\n emit();\n return isl;\n });\n refresh();\n // V2 insert: its properties open beside it, and the toast says what a shared component is\n if (made.el && services.useComponentInfo) openComponentPanel(made.el);\n services.toast?.(`${c.name} added`, { description: COMPONENT_INSERT_TOAST });\n return;\n }\n if (!it.id || !blockAllowed(it.id, allows)) return;\n noteRecent(it);\n if (it.id === \"footnote\") {\n // V2 rich-text-editor.tsx:610-615: at the caret in the text, else said why\n const m = insertFootnote(el);\n if (!m) return void notify(FOOTNOTE_REFUSED.title, { description: FOOTNOTE_REFUSED.description });\n emit();\n openFootnote(m, true);\n return;\n }\n if (it.id === \"task\") insertChecklist(el);\n else if (it.id === \"button\") {\n // V2 rich-text-editor.tsx:627: a new button opens its popover\n const a = insertButton(el);\n emit();\n refresh();\n openButton(a);\n return;\n } else if (it.id === \"related\" && references?.topic === false) {\n // no topic field to rank by: a new block is Newest (Same topic would be refused on save, no_topic_field)\n ops.insertIsland(el, \"related\", { ...defaultModel(\"related\"), mode: \"newest\" });\n } else ops.insertBasic(el, it.id);\n emit();\n refresh();\n };\n\n /* ── slash menu ──────────────────────────────────────────────────── */\n const slashCat = useCatalog(slash?.query ?? \"\", allows, slash?.folder ?? false, components ?? null, canAiCommand, !!slash?.ai);\n const caretRect = () => {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return null;\n return rangeRect(s.getRangeAt(0), topBlock(ref.current, s.anchorNode) ?? ref.current);\n };\n const pickSlash = (it: CatalogItem) => {\n if (it.kind === \"folder\") return setSlash((s) => s && { ...s, folder: true, active: 1 });\n if (it.kind === \"ai\") return setSlash((s) => s && { ...s, ai: true, folder: false, active: 1 });\n if (it.kind === \"back\") return setSlash((s) => s && { ...s, folder: false, ai: false, active: 0 });\n const sl = slash;\n setSlash(null);\n if (sl) {\n try {\n const r = document.createRange();\n r.setStart(sl.node, sl.offset);\n r.setEnd(sl.node, Math.min(sl.node.length, sl.offset + 1 + sl.query.length));\n r.deleteContents();\n const c = document.createRange();\n c.setStart(sl.node, Math.min(sl.offset, sl.node.length));\n c.collapse(true);\n const s = window.getSelection();\n s?.removeAllRanges();\n s?.addRange(c);\n } catch {\n /* the text moved */\n }\n // A component is ONE step of the host's history, recorded from the body as it stands when the step starts: the\n // typed \"/query\" goes first, flushed, so an undo of the insert never brings it back as a paragraph.\n if (it.kind === \"component\") flushSync(() => emit());\n }\n if (it.ai) {\n emit();\n return runAiCommand(it.ai, it.label, sl ? topBlock(ref.current, sl.node) : null);\n }\n insertBlock(it);\n };\n\n /**\n * Look v16, a \"BetterCMS AI\" command picked in the slash menu (prototype content.jsx:1210, F2115-F2121). The host's\n * `aiCommand` service writes; a rewrite command replaces the text block right above the caret's line, the others\n * write new paragraphs at that line. Every write carries an Undo; a refusal and a failure are named.\n */\n const runAiCommand = (kind: AiCommandKind, label: string, at: HTMLElement | null) => {\n const run = services.aiCommand;\n const root = ref.current;\n if (!run || !root) return;\n const words = (n: Element) => (n.textContent ?? \"\").replace(/\\u200b/g, \"\");\n const above: Element[] = [];\n for (const k of Array.from(root.children)) {\n if (k === at) break;\n above.push(k);\n }\n const rewrite = AI_REWRITE_COMMANDS.includes(kind);\n // the nearest block above with words in it; a rewrite takes it only when it is plain running text\n const near = [...above].reverse().find((n) => words(n).trim());\n const target = rewrite && near instanceof HTMLElement && /^(P|H[1-6]|BLOCKQUOTE)$/.test(near.tagName) ? near : null;\n if (rewrite && !target) {\n notify(`Nothing above to ${kind === \"translate\" ? \"translate\" : kind === \"spelling\" ? \"check\" : \"rewrite\"}`, { description: \"Put the caret on the line under a paragraph, heading or quote, then pick the command again.\" });\n return;\n }\n const before = target ? target.innerHTML : \"\";\n // the target's text runs: the answer keeps their formatting where it lines up (ai-runs.ts)\n target?.normalize();\n const runs = target ? textRuns(target) : [];\n const context: AiCommandContext = {\n text: Array.from(root.children).map(words).filter((t) => t.trim()).join(\"\\n\\n\"),\n before: above.map(words).filter((t) => t.trim()).join(\"\\n\\n\"),\n target: target ? words(target) : \"\",\n line: at ? words(at).trim() : \"\",\n runs: runs.length > 1 ? runs.map((r) => r.run.text) : [],\n };\n notify(`BetterCMS AI · ${label}`);\n Promise.resolve()\n .then(() => run(kind, context))\n .then(\n (out) => {\n const el = ref.current;\n const text = typeof out === \"string\" ? out.trim() : \"\";\n if (!el || !text) return;\n if (target) {\n if (!el.contains(target) || words(target) !== context.target) {\n notify(\"The text changed before BetterCMS AI came back\", { description: \"Nothing was replaced. Pick the command again to retry.\" });\n return;\n }\n const flat = (s: string) => s.replace(/\\s*\\n+\\s*/g, \" \");\n const pieces = mapRewriteOntoRuns(\n runs.map((r) => r.run),\n text,\n );\n const marked = runs.some((r) => r.run.marked);\n if (pieces && runs.every((r) => r.node.isConnected && target.contains(r.node))) runs.forEach((r, i) => (r.node.data = flat(pieces[i]!)));\n else target.textContent = flat(text.split(AI_RUN_SEPARATOR).join(\"\"));\n const kept = !!pieces;\n emit();\n notify(`${label}: done`, {\n ...(marked && !kept ? { description: \"Its formatting was removed: the new text did not line up with the old.\" } : {}),\n action: {\n label: \"Undo\",\n onClick: () => {\n if (!target.isConnected) return;\n target.innerHTML = before;\n emit();\n },\n },\n });\n return;\n }\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = textToParas(text.replace(/\\n{3,}/g, \"\\n\\n\"));\n const nodes = Array.from(tpl.content.children) as HTMLElement[];\n if (!nodes.length) return;\n // an empty line the \"/\" was typed on is replaced by the text; a line with words keeps them and the text follows\n const line = at && el.contains(at) ? at : null;\n const emptyLine = line && line.tagName === \"P\" && !words(line).trim() ? line : null;\n if (emptyLine) emptyLine.replaceWith(...nodes);\n else if (line) line.after(...nodes);\n else el.append(...nodes);\n placeCaret(nodes[nodes.length - 1]);\n emit();\n notify(`${label}: done`, {\n action: {\n label: \"Undo\",\n onClick: () => {\n if (!nodes[0].isConnected) return;\n if (emptyLine) nodes[0].before(emptyLine);\n nodes.forEach((n) => n.remove());\n emit();\n },\n },\n });\n },\n (err: unknown) => notify(\"BetterCMS AI could not finish\", { description: err instanceof Error ? err.message : String(err) }),\n );\n };\n\n const toggleInlineCode = () => {\n const el = ref.current;\n const s = window.getSelection();\n if (!el || !s || !s.rangeCount || !allows(\"code\")) return;\n const anchorEl = s.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode?.parentElement;\n const code = anchorEl?.closest(\"code\");\n if (code && el.contains(code) && !code.closest(\"pre\")) {\n code.replaceWith(...Array.from(code.childNodes));\n emit();\n return;\n }\n const text = s.toString();\n if (!text) return void notify(\"Select some text first\", { description: \"Or wrap words in backticks to format them as code.\" });\n insertHtmlAtCaret(`<code>${esc(text)}</code>`);\n // RP-006: Chrome's insertHTML turns the spaces either side of what it inserts into ; a plain space shows the\n // same between a word and the code, so the text keeps the spaces it had\n const at = s.anchorNode && topBlock(el, s.anchorNode);\n at?.querySelectorAll(\"code\").forEach((c) => {\n if (c.textContent !== text) return;\n const prev = c.previousSibling;\n const next = c.nextSibling;\n if (prev instanceof Text && /[^\\s ] $/.test(prev.data)) prev.data = `${prev.data.slice(0, -1)} `;\n if (next instanceof Text && /^ [^\\s ]/.test(next.data)) next.data = ` ${next.data.slice(1)}`;\n });\n emit();\n };\n\n /* ── keyboard ────────────────────────────────────────────────────── */\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (slash) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setSlash(slash.folder || slash.ai ? { ...slash, folder: false, ai: false, active: 0 } : null);\n return;\n }\n if (catalogKey(e, slashCat.flat, slash.active, (a) => setSlash((s) => s && { ...s, active: a }), pickSlash, false)) {\n e.preventDefault();\n return;\n }\n }\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n // RT-028: in a list item Tab nests it and Shift+Tab brings it back; the key stays in the editor even when the item\n // cannot move (the first item, the top level). Anywhere else Tab is the browser's: focus moves on.\n if (e.key === \"Tab\" && !mod && !e.altKey && !readOnly && !single && ref.current) {\n const s = window.getSelection();\n const at = s?.anchorNode ? (s.anchorNode.nodeType === 1 ? (s.anchorNode as Element) : s.anchorNode.parentElement) : null;\n const li = at?.closest(\"li\");\n if (li && ref.current.contains(li) && !li.closest(\"[data-rt-island]\")) {\n e.preventDefault();\n if (e.shiftKey ? ops.outdentListItem(li) : ops.indentListItem(li)) emit();\n return;\n }\n }\n if (!mod && !e.altKey && !readOnly && ref.current && toggleTaskFromKey(ref.current, e.key)) {\n e.preventDefault();\n emit();\n return;\n }\n if (mod && !e.altKey && k === \"k\") {\n e.preventDefault();\n saveSel();\n openLink();\n return;\n }\n if (mod && !e.altKey && !e.shiftKey && k === \"e\") {\n e.preventDefault();\n toggleInlineCode();\n return;\n }\n // RP-012: inside a link the underline is ours (the browser reads the link's own decoration as the mark)\n if (mod && !e.altKey && !e.shiftKey && k === \"u\" && allows(\"underline\") && ref.current && toggleLinkUnderline(ref.current)) {\n e.preventDefault();\n emit();\n refresh();\n return;\n }\n // the browser's own mark shortcuts, only for the marks the field keeps\n if (mod && !e.altKey && !e.shiftKey && ((k === \"b\" && !allows(\"bold\")) || (k === \"i\" && !allows(\"italic\")) || (k === \"u\" && !allows(\"underline\")))) {\n e.preventDefault();\n return;\n }\n if (mod && e.altKey && /^Digit[0-6]$/.test(e.code)) {\n e.preventDefault();\n const n = Number(e.code.slice(5));\n const tag = n === 0 ? \"p\" : `h${n}`;\n if (tag === \"p\" || allows(tag as RichTextFeature)) turnInto(currentBlock(), tag);\n return;\n }\n if (e.key === \"Enter\" && !mod && !e.shiftKey) {\n // a one-paragraph field has no second block to start\n if (single) {\n e.preventDefault();\n return;\n }\n const cb = currentBlock();\n // RP-043: \"```\" or \"```ts\" alone on a line, then Enter, is a code block (with that language)\n if (cb && ref.current && ops.enterCodeFence(ref.current, cb, allows)) {\n e.preventDefault();\n setSlash(null);\n emit();\n return;\n }\n // Enter on an empty quote or heading line leaves it for a paragraph\n if (cb && /^(BLOCKQUOTE|H[1-6])$/.test(cb.tagName) && !cb.textContent?.replace(//g, \"\").trim()) {\n e.preventDefault();\n turnInto(cb, \"p\");\n return;\n }\n // Enter at the end of a quote starts a paragraph (not another quote)\n const sel = window.getSelection();\n if (cb?.tagName === \"BLOCKQUOTE\" && sel?.isCollapsed && sel.rangeCount && !cb.querySelector(\"p\")) {\n const rest = document.createRange();\n rest.selectNodeContents(cb);\n rest.setStart(sel.anchorNode!, sel.anchorOffset);\n if (!rest.toString().trim()) {\n e.preventDefault();\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n cb.after(p);\n placeCaret(p);\n emit();\n return;\n }\n }\n const s = window.getSelection();\n const pre = s?.anchorNode && (s.anchorNode.nodeType === 1 ? (s.anchorNode as HTMLElement) : s.anchorNode.parentElement)?.closest(\"pre\");\n if (pre && ref.current?.contains(pre)) {\n e.preventDefault();\n exec(\"insertLineBreak\");\n return;\n }\n }\n if (e.key === \"ArrowDown\" && !mod && !e.shiftKey && !single) {\n // leave a trailing heading / quote / code block / list\n const b = currentBlock();\n const s = window.getSelection();\n if (b && !b.nextElementSibling && b.tagName !== \"P\" && !b.hasAttribute(\"data-rt-island\") && s?.isCollapsed && s.rangeCount) {\n const rest = document.createRange();\n rest.selectNodeContents(b);\n rest.setStart(s.anchorNode!, s.anchorOffset);\n if (!rest.toString().trim()) {\n e.preventDefault();\n const p = ops.ensureLineAfter(b);\n placeCaret(p, false);\n emit();\n }\n }\n }\n };\n\n /** Block-level shortcuts; runs for the surface and for text inside rich blocks. */\n const onWrapKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented) return;\n const mod = e.metaKey || e.ctrlKey;\n // look v16: Focus mode is ⇧⌘F (prototype content.jsx:1020), the host's full-screen view when it has one; the expanded\n // editor stays ⌘↵ and (prototype richtext.jsx:322) ⇧⌘E\n if (mod && !hideFullscreen && v16 && e.shiftKey && e.key.toLowerCase() === \"f\") {\n e.preventDefault();\n openFocus();\n return;\n }\n if (mod && !hideFullscreen && (e.key === \"Enter\" || (v16 && e.shiftKey && e.key.toLowerCase() === \"e\"))) {\n e.preventDefault();\n setModalOpen(true);\n return;\n }\n if (md || readOnly) return;\n const t = e.target as HTMLElement;\n if (!ref.current?.contains(t) || t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\") return;\n if (undoKey(e)) return;\n if (single) return;\n if (mod && !e.shiftKey && !e.altKey && eventKey(e) === \"d\") {\n e.preventDefault();\n const b = currentBlock();\n if (b) duplicateBlock(b);\n return;\n }\n if (mod && e.shiftKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n e.preventDefault();\n const b = currentBlock();\n if (b) moveBlock(b, e.key === \"ArrowUp\" ? -1 : 1);\n }\n };\n\n const onInput = (e: React.FormEvent<HTMLDivElement>) => {\n if (e.target !== ref.current) return;\n const ne = e.nativeEvent as InputEvent;\n if (ne.inputType !== \"historyUndo\" && ne.inputType !== \"historyRedo\") {\n hist.current.textAt = Date.now();\n hist.current.future = [];\n }\n // RT-030: a live Markdown conversion is taken back by ⌘Z only right after it\n ops.forgetLiveMarkdown(ref.current!);\n if (!single && ne.inputType === \"insertText\" && allows(\"checklist\") && checklistShortcut(ref.current!, ne.data)) {\n setSlash(null);\n emit();\n return;\n }\n if (!single && ne.inputType === \"insertText\" && (ne.data === \" \" || ne.data === \"-\") && ops.liveMarkdown(ref.current!, ne.data, allows)) {\n setSlash(null);\n emit();\n return;\n }\n if (ne.inputType === \"insertText\" && ne.data === \"`\" && allows(\"code\")) ops.liveInlineCode(ref.current!);\n // RT-030: **bold**, *italic*, _italic_ as their closing marker is typed\n else if (ne.inputType === \"insertText\" && (ne.data === \"*\" || ne.data === \"_\")) ops.liveInlineEmphasis(ne.data, allows, ref.current!);\n // BL-540: while the \"/\" menu is open (and for the \"/\" that opens it) the typed query is not saved: closing the menu\n // saves once (the effect on `hasSlash`), whether a command ran or the menu was cancelled\n const s = window.getSelection();\n if (!s || !s.rangeCount) {\n emit();\n return setSlash(null);\n }\n const r = s.getRangeAt(0);\n const opensAt = (n: Node) => {\n const blk = closestBlock(ref.current!, n);\n return !!blk && textBeforeCaret(blk) === \"/\";\n };\n if (!slash) {\n // \"/\" opens the menu only at the very start of a block, and only in a field that takes more than one block\n const opens = !single && ne.inputType === \"insertText\" && ne.data === \"/\" && r.startContainer.nodeType === 3 && opensAt(r.startContainer);\n const rect = opens ? caretRect() : null;\n if (rect) setSlash({ rect, node: r.startContainer as Text, offset: r.startOffset - 1, query: \"\", folder: false, active: 0 });\n else emit();\n return;\n }\n if (r.startContainer !== slash.node || r.startOffset <= slash.offset || slash.node.data[slash.offset] !== \"/\") return setSlash(null);\n const q = slash.node.data.slice(slash.offset + 1, r.startOffset);\n // A query is words (\"/table of\"): only a space right after \"/\", two in a row, or a long run closes the menu.\n if (/^\\s|\\s\\s/.test(q) || q.length > 24) return setSlash(null);\n setSlash({ ...slash, query: q, active: slash.folder || slash.ai ? 1 : 0 });\n };\n\n /* ── links ───────────────────────────────────────────────────────── */\n const openLink = () => {\n if (!allows(\"link\")) return;\n restoreSel();\n const s = window.getSelection();\n const anchorEl = s?.anchorNode?.nodeType === 1 ? (s.anchorNode as HTMLElement) : s?.anchorNode?.parentElement;\n const anchor = (anchorEl?.closest(\"a\") as HTMLAnchorElement | null) ?? null;\n if (anchor && ref.current && buttonAt(ref.current, anchor)) return openButton(anchor);\n if (!anchor && (!s || s.isCollapsed || !s.toString().trim())) {\n notify(\"Select some text first\", { description: hints ? platformKeys(\"Then press ⌘K to link it.\") : \"Then link it.\" });\n return;\n }\n const rect = s && s.rangeCount ? rangeRect(s.getRangeAt(0), ref.current) : ref.current!.getBoundingClientRect();\n // The panel takes focus: the selection it links is kept, so closing it can give it back (BL-539).\n saveSel();\n setBubble(null);\n setLink({ rect, existing: anchor, initial: anchor ? textLinkOf(anchor) : { href: \"\" } });\n };\n /** BL-539: the link panel closed without a save (Esc, Cancel, Remove): the caret goes back to the editor, on its text. */\n const closeLink = () => {\n setLink(null);\n restoreSel();\n };\n /* ── footnotes (V2 rich-text-editor.tsx:1081-1130) ───────────────── */\n const openFootnote = (m: HTMLElement, fresh = false) => {\n if (readOnly) return;\n setBubble(null);\n setFnEdit({ el: m, rect: m.getBoundingClientRect(), fresh });\n };\n const removeFootnote = (m: HTMLElement) => {\n setFnEdit(null);\n m.remove();\n emit();\n };\n /** closed: a new footnote with no note is taken back out (V2), else the caret goes back after its marker */\n const closeFootnote = () => {\n const f = fnEdit;\n setFnEdit(null);\n if (!f || !ref.current) return;\n if (f.fresh && !(f.el.getAttribute(\"data-note\") ?? \"\").trim()) return removeFootnote(f.el);\n caretAfterMarker(ref.current, f.el);\n };\n\n /** V2 rich-text-editor.tsx:865-873: a button's popover, its label above the link form */\n const openButton = (a: HTMLAnchorElement) => {\n if (readOnly) return;\n const { link: initial, label } = buttonInitial(a);\n setBubble(null);\n setLink({ rect: a.getBoundingClientRect(), existing: a, initial, button: { a, label } });\n };\n const saveButton = (v: TextLink, label: string) => {\n const b = link?.button;\n setLink(null);\n if (!b) return;\n applyButton(b.a, v, label);\n emit();\n };\n const saveLink = (v: TextLink) => {\n const l = link;\n setLink(null);\n if (!l) return;\n if (l.existing) {\n applyTextLink(l.existing, v);\n emit();\n return;\n }\n run(() => {\n // BL-537: a selection keeps its own nodes (bold, underline, the spaces around it): the browser's createLink\n // wraps them, else they are moved into the anchor by hand. Only a caret inserts the address as the link's text.\n const s = window.getSelection();\n const el = ref.current;\n if (el && s && s.rangeCount && !s.isCollapsed) {\n const sentinel = `https://bcms-link.invalid/${rid()}`;\n if (exec(\"createLink\", sentinel)) {\n el.querySelectorAll<HTMLAnchorElement>(\"a[href]\").forEach((a) => a.getAttribute(\"href\") === sentinel && applyTextLink(a, v));\n return;\n }\n const r = s.getRangeAt(0);\n const blk = closestBlock(el, r.startContainer);\n if (blk && blk === closestBlock(el, r.endContainer)) {\n const a = document.createElement(\"a\");\n applyTextLink(a, v);\n a.append(r.extractContents());\n r.insertNode(a);\n r.selectNodeContents(a);\n s.removeAllRanges();\n s.addRange(r);\n return;\n }\n }\n const text = s?.toString() || v.href;\n const attr = (s: string) => esc(s).replace(/\"/g, \""\");\n insertHtmlAtCaret(`<a href=\"${attr(v.href)}\"${v.newTab ? ` target=\"_blank\"` : \"\"}${v.rel ? ` rel=\"${attr(v.rel)}\"` : \"\"}>${esc(text)}</a>`);\n });\n };\n\n /* ── AI rewrite of the selection (the host's service) ────────────── */\n const aiRewrite = (preset: AiPreset) => {\n const rewrite = services.aiRewrite;\n restoreSel();\n const range = saved.current?.cloneRange();\n const text = range?.toString() ?? \"\";\n if (!rewrite || !range || !text.trim()) return;\n setBubble(null);\n Promise.resolve()\n .then(() => rewrite(text, preset, aiAttempt.current++))\n .then(\n (out) => {\n const el = ref.current;\n if (!el || !el.contains(range.startContainer) || range.toString() !== text) {\n notify(\"The text changed before the rewrite came back\", { description: \"Nothing was replaced. Select it again to retry.\" });\n return;\n }\n el.focus({ preventScroll: true });\n // F66: a link the whole selection sits in is kept; formatting the plain text cannot carry is reported.\n const shape = selectionShape(range, el);\n const attrs = shape.link ? linkAttrs(shape.link) : null;\n const s = window.getSelection();\n s?.removeAllRanges();\n s?.addRange(range);\n // Always the editor's own insert (one undo step, an input event for the save path).\n insertTextAtCaret(out);\n if (shape.link && attrs && (!el.contains(shape.link) || !shape.link.textContent?.includes(out))) {\n // The browser dropped the link with its text: put it back over exactly the inserted words.\n const node = s?.focusNode;\n const off = s?.focusOffset ?? 0;\n if (s && node && node.nodeType === Node.TEXT_NODE && off >= out.length) {\n const r = document.createRange();\n r.setStart(node, off - out.length);\n r.setEnd(node, off);\n s.removeAllRanges();\n s.addRange(r);\n const sentinel = `${LINK_SENTINEL}${rid()}`;\n if (exec(\"createLink\", sentinel)) {\n el.querySelectorAll<HTMLAnchorElement>(\"a[href]\").forEach((a) => {\n if (a.getAttribute(\"href\") !== sentinel) return;\n for (const [k, v] of attrs) a.setAttribute(k, v);\n });\n }\n s.collapseToEnd();\n }\n }\n // a throwaway link the restore made but did not rewrite never reaches the content (its text stays)\n unwrapLinkSentinels(el);\n emit();\n notify(shape.loses ? FORMATTING_REMOVED : \"Rewritten with AI\", { description: hints ? platformKeys(\"Press ⌘Z to undo\") : undefined });\n },\n (err: unknown) => notify(\"Could not rewrite the selection\", { description: err instanceof Error ? err.message : String(err) }),\n );\n };\n\n /* ── drag to reorder via the grip ────────────────────────────────── */\n const onGripDown = (e: React.PointerEvent) => {\n if (!gutter) return;\n startDrag(gutter.el, e, () => setBlockMenu(true));\n };\n /** Drag a top-level block (the gutter grip) to a new position; a tap calls `onTap`. */\n const startDrag = (from: HTMLElement, e: React.PointerEvent, onTap?: () => void) => {\n if (readOnly || e.button !== 0) return;\n e.preventDefault();\n const start = e.clientY;\n let moved = false;\n const kids = () => Array.from(ref.current?.children ?? []);\n const move = (ev: PointerEvent) => {\n if (!moved && Math.abs(ev.clientY - start) < 4) return;\n moved = true;\n const sc = scroller.current!;\n const sr = sc.getBoundingClientRect();\n let target: Element | null = null;\n let line = 0;\n for (const k of kids()) {\n const r = k.getBoundingClientRect();\n if (ev.clientY < r.top + r.height / 2) {\n target = k;\n line = r.top - sr.top + sc.scrollTop - 4;\n break;\n }\n line = r.bottom - sr.top + sc.scrollTop + 4;\n }\n setDrag({ from, line, target });\n };\n const up = () => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n if (!moved) {\n onTap?.();\n return;\n }\n setDrag((d) => {\n if (d && d.target !== d.from) {\n // dropped where it already stood (before its own next block, or last and appended): not a move\n const same = d.target ? d.target === d.from.nextElementSibling : d.from === ref.current?.lastElementChild;\n if (d.target) d.target.before(d.from);\n else ref.current?.append(d.from);\n setTimeout(() => {\n emit();\n // look v16 (F2031): a drag-drop move says so, as Move up / Move down do\n if (v16 && !same) services.toast?.(\"Block moved\");\n }, 0);\n }\n return null;\n });\n };\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", up);\n };\n\n /* ── pasted and converted markup keeps to the field's rules ──────── */\n const conform = (html: string): string => {\n const r = ops.restrictHtml(html, allows);\n if (r.dropped.length) notify(`This field keeps no ${r.dropped.join(\" or \")}`, { description: \"They were left out; the text around them was kept.\" });\n return r.html;\n };\n\n /* ── Markdown mode ───────────────────────────────────────────────── */\n const toggleMarkdown = () => {\n if (!md) {\n const html = ref.current ? serialize(ref.current) : value;\n const text = htmlToMarkdown(html);\n setMd({ text, original: text });\n setSlash(null);\n setGutter(null);\n setBubble(null);\n setLink(null);\n return;\n }\n if (md.text === md.original) {\n setMd(null);\n setMdConfirm(false);\n return;\n }\n setMdConfirm(true);\n };\n const convertMarkdown = () => {\n if (!md) return;\n let html: string;\n try {\n html = conform(markdownToHtml(md.text));\n } catch (err) {\n notify(\"Could not convert this Markdown\", { description: `${err instanceof Error ? err.message : String(err)}. Your rich text is unchanged.` });\n return;\n }\n pending.current = html;\n known.current = html;\n onChangeRef.current(html);\n setMd(null);\n setMdConfirm(false);\n };\n\n /* ── One undo history (CPO D54): typing is the browser's own undo; an island write (an image's address or alt text)\n is a step on this stack. ⌘Z takes whichever happened last. ── */\n /** A host step's undo or redo; its value then loads even here, with the caret in the editor. */\n const runHost = (run: () => true | string): true | string => {\n forceLoad.current = true;\n const r = run();\n if (r !== true) forceLoad.current = false;\n return r;\n };\n /**\n * This body's host step that is the host's next undo (or redo) NOW. The host's toolbar moves these steps too: after\n * its Undo then Redo, the step is the latest change again, so ⌘Z here undoes it. Any later change in this body is a\n * host step of its own (the body's value is the host's), so a host step that is next is the latest change here.\n */\n const hostNext = (way: \"undo\" | \"redo\"): HostStep | null => {\n const hs = hist.current.hosts;\n for (let i = hs.length - 1; i >= 0; i--) if (hs[i].step.next() === way) return hs[i];\n return null;\n };\n const islandUndo = (): boolean => {\n const host = hostNext(\"undo\");\n if (host) {\n const r = runHost(host.step.undo);\n if (r !== true) notify(\"Nothing was undone\", { description: r });\n return true;\n }\n const h = hist.current;\n // a step whose island is gone has nothing to undo\n while (h.past.length && !h.past[h.past.length - 1].dom && !h.past[h.past.length - 1].el?.isConnected) h.past.pop();\n const step = h.past[h.past.length - 1];\n if (!step || step.at < h.textAt) return false;\n if (step.dom) {\n if (!step.dom.undo()) return false;\n h.past.pop();\n step.at = Date.now();\n h.future.push(step);\n return true;\n }\n if (!step.el.__rtSet) return false;\n h.past.pop();\n h.future.push({ ...step, before: step.el.__rt!, at: Date.now() });\n step.el.__rtSet(step.before);\n return true;\n };\n const islandRedo = (): boolean => {\n const host = hostNext(\"redo\");\n if (host) {\n const r = runHost(host.step.redo);\n if (r !== true) notify(\"Nothing was redone\", { description: r });\n return true;\n }\n const h = hist.current;\n const step = h.future.pop();\n if (step?.dom) {\n if (!step.dom.redo()) return false;\n step.at = Date.now();\n h.past.push(step);\n return true;\n }\n if (!step || !step.el.isConnected || !step.el.__rtSet) return false;\n h.past.push({ ...step, before: step.el.__rt!, at: Date.now() });\n step.el.__rtSet(step.before);\n return true;\n };\n /**\n * One action as ONE undo step (a separate copy, \"use shared version again\", a component inserted): in the host's\n * history when it keeps one (KitServices.historyStep: its toolbar Undo, an Undo toast and ⌘Z here are the same\n * undo), else in this editor's own (`before`: the model the island had; an insert has none, and stays as undoable\n * as any block inserted here). `write` makes the change and answers the island it changed. Answers its undo.\n */\n const oneStep = (label: string, write: () => IslandEl | null, before?: IslandModels[IslandKind]): (() => true | string) => {\n const h = hist.current;\n const made: { el: IslandEl | null } = { el: null };\n const historyStep = services.historyStep;\n const step = historyStep\n ? historyStep(() => {\n made.el = write();\n })\n : ((made.el = write()), null);\n const el = made.el;\n if (step) {\n h.hosts = [...h.hosts, { label, step }].slice(-100);\n return () => runHost(step.undo);\n }\n if (!el || !before) return () => \"This change has no undo step here.\";\n const s: IslandStep = { el, before, label, at: Date.now() };\n h.past = [...h.past, s].slice(-100);\n h.future = [];\n return () => {\n if (!h.past.includes(s)) return \"It was undone already.\";\n if (h.past[h.past.length - 1] !== s || s.at < h.textAt) return \"Changes made after it come first. Press ⌘Z to undo them.\";\n return islandUndo() ? true : \"The block was removed, so there is nothing to undo.\";\n };\n };\n const record = (el: IslandEl, before: IslandModels[IslandKind], label: string, coalesce?: boolean) => {\n const h = hist.current;\n const now = Date.now();\n const top = h.past[h.past.length - 1];\n // typing in one field coalesces (~500ms), unless the text was edited in between\n if (coalesce && top && top.el === el && top.label === label && now - top.at < 500 && top.at > h.textAt) top.at = now;\n else h.past = [...h.past, { el, before, label, at: now }].slice(-100);\n h.future = [];\n };\n const undoKey = (e: React.KeyboardEvent): boolean => {\n const mod = e.metaKey || e.ctrlKey;\n if (!mod || e.altKey || eventKey(e) !== \"z\") return false;\n if (e.shiftKey) {\n e.preventDefault();\n // RT-013: the text's own redo, as ⌘Z runs its undo; the browser's ⌘⇧Z default is not dependable here.\n if (!islandRedo()) exec(\"redo\");\n return true;\n }\n // RT-030: right after \"## \" made a heading (a list, a quote, a divider) or \"**x**\" a bold run, ⌘Z puts the typed text back\n if (ref.current && ops.undoLiveMarkdown(ref.current)) {\n e.preventDefault();\n emit();\n return true;\n }\n if (islandUndo()) {\n e.preventDefault();\n return true;\n }\n if (!hist.current.past.length || !ref.current) return false;\n e.preventDefault();\n const before = ref.current.innerHTML;\n exec(\"undo\");\n if (ref.current.innerHTML === before) {\n hist.current.textAt = 0;\n islandUndo();\n }\n return true;\n };\n\n /* ── API for islands (stable) ────────────────────────────────────── */\n const api = React.useRef({ emit, deleteBlock, replaceBlock, exitIsland, record, oneStep, notify, duplicateBlock, moveBlock, islandUndo, islandRedo, startDrag, allows });\n api.current = { emit, deleteBlock, replaceBlock, exitIsland, record, oneStep, notify, duplicateBlock, moveBlock, islandUndo, islandRedo, startDrag, allows };\n const islandCtx = React.useMemo<IslandCtx>(\n () => ({\n readOnly,\n dense,\n emit: () => api.current.emit(),\n remove: (x, label) => api.current.deleteBlock(x, label),\n replace: (x, nodes, label) => api.current.replaceBlock(x, nodes, label),\n exit: (x) => api.current.exitIsland(x),\n record: (x, before, label, coalesce) => api.current.record(x, before, label, coalesce),\n step: (label, write, before) => api.current.oneStep(label, write, before),\n notify: (message, description) => api.current.notify(message, { description }),\n duplicate: (x) => api.current.duplicateBlock(x),\n move: (x, dir) => api.current.moveBlock(x, dir),\n undo: () => api.current.islandUndo(),\n redo: () => api.current.islandRedo(),\n drag: (x, e) => api.current.startDrag(x, e),\n allows: (f) => api.current.allows(f),\n outline: outline.current,\n references,\n }),\n [readOnly, dense, references],\n );\n\n const commentSel = onComment\n ? () => {\n restoreSel();\n const s = window.getSelection();\n const raw = s?.toString() ?? \"\";\n const q = raw.trim();\n // the comment popover takes over: the selection toolbar steps away so it never sits on the composer\n setBubble(null);\n setQuiet(true);\n if (!q) return;\n // GAP-004: the text around the words (TextQuoteSelector), so the host finds this occurrence and not the first\n const root = ref.current;\n const r = s && s.rangeCount ? s.getRangeAt(0) : null;\n if (!root || !r || !root.contains(r.commonAncestorContainer)) return onComment(q);\n const before = document.createRange();\n before.selectNodeContents(root);\n before.setEnd(r.startContainer, r.startOffset);\n const after = document.createRange();\n after.selectNodeContents(root);\n after.setStart(r.endContainer, r.endOffset);\n // the spaces trimmed off the selection belong to the text around it\n const lead = raw.slice(0, raw.length - raw.trimStart().length);\n const trail = raw.slice(raw.trimEnd().length);\n onComment(q, { prefix: (before.toString() + lead).slice(-32), suffix: (trail + after.toString()).slice(0, 32) });\n }\n : undefined;\n const onMark = (cmd: MarkCmd) =>\n allows(MARK_FEATURE[cmd]) &&\n run(() => {\n if (cmd === \"superscript\" || cmd === \"subscript\") ref.current && toggleScript(ref.current, cmd === \"superscript\" ? \"sup\" : \"sub\");\n else if (!(cmd === \"underline\" && ref.current && toggleLinkUnderline(ref.current))) exec(cmd);\n });\n const onStyle = (tag: string) => {\n restoreSel();\n turnInto(currentBlock(), tag);\n refresh();\n };\n\n /* ── render ──────────────────────────────────────────────────────── */\n const { flipUp, maxHeight: slashMaxH } = slash ? slashPlacement(slash.rect, window.innerHeight) : { flipUp: false, maxHeight: SLASH_MENU_H };\n const gBlock = gutter?.el;\n const gIsText = !!gBlock && !gBlock.hasAttribute(\"data-rt-island\") && gBlock.tagName !== \"HR\";\n const gLang = gBlock?.tagName === \"PRE\" ? ops.codeLanguage(gBlock) : null;\n const btn = dense ? \"size-5 [&_svg:not([data-rt-isolate]_*)]:size-3.5\" : \"size-[22px] [&_svg:not([data-rt-isolate]_*)]:size-3.5\";\n /* outside: + and grip float left of the box · inset: a slim grip sits in the 16px padding (insert via / or the\n toolbar) · none: compact inspector fields and one-paragraph fields */\n const gutterMode: \"outside\" | \"inset\" | \"none\" = readOnly || dense || single ? \"none\" : gutterRoom ? \"outside\" : \"inset\";\n const showGutter = gutterMode !== \"none\";\n /** BL-540: a one-line or panel field counts no words; the expanded modal shows no stamp (owner 2026-11-08, KP-134) */\n const counts = !single && !dense && !inModal;\n const minH = expanded ? \"min-h-[60vh]\" : single ? \"min-h-9\" : dense ? \"min-h-[120px]\" : \"min-h-[190px]\";\n const turnStyles = stylesFor(allows).filter((s) => [\"p\", \"h1\", \"h2\", \"h3\", \"blockquote\"].includes(s.tag));\n\n return (\n <CatalogComponentsProvider value={components ?? null}>\n <div\n ref={wrap}\n data-rt-editor=\"\"\n className={cn(\n \"relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]\",\n \"rounded-kit-lg border transition-colors duration-150\",\n v16 && \"[--rt-toolbar-h:2.75rem]\",\n v16 && !dense && \"rounded-[10px]\",\n /* the expanded modal is raised: the editor sits level with it, never below (D56) */\n /* held by a disabled fieldset: drawn like a disabled input (ui/input.tsx) */\n fenced ? \"cursor-not-allowed bg-kit-subtle opacity-60\" : expanded ? \"bg-[var(--kit-surface-raised)]\" : \"bg-kit-surface\",\n /* V2 rich-text-editor.tsx:1152: line at rest, line-strong while the toolbar is open; an invalid value (dash) keeps its edge */\n invalid ? \"border-[var(--kit-field-invalid)]\" : (v16 ? fieldActive : toolbarOpen) ? \"border-[var(--kit-field-border-focus)]\" : v16 ? \"border-kit-insp-line\" : \"border-kit-line-strong\", // 4B (2026-11-10): the box edge meets 3:1\n )}\n /* what the sticky toolbar covers at the top of the scroll area */\n style={{ \"--rt-sticky-top\": toolbarOpen && !dense ? `calc(${stickyTop}px + var(--rt-toolbar-h))` : \"var(--kit-sticky-top, 0px)\" } as React.CSSProperties}\n onMouseLeave={() => !blockMenu && !gutterInsert && !drag && setGutter(null)}\n onKeyDown={onWrapKeyDown}\n onFocus={() => {\n window.clearTimeout(blurTimer.current);\n setFocused(true);\n }}\n onBlur={() => {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = window.setTimeout(() => {\n const a = document.activeElement;\n if (wrap.current?.contains(a) || a?.closest(\"[role=dialog],[role=listbox],[data-floating-layer]\")) return;\n // NEW-Q11-TB1: only the editor's own menus (toolbar, block, bubble) keep it; a host menu would open under the bubble\n const menu = a?.closest(\"[role=menu]\");\n if (menu && ownsMenu(menu, [wrap.current, document.querySelector('[data-floating-layer][aria-label=\"Selection formatting\"]')])) return;\n setFocused(false);\n setBubble(null);\n ref.current?.querySelectorAll(\"[data-hint]\").forEach((n) => n.removeAttribute(\"data-hint\"));\n // F2016: the prototype recolours code when the caret leaves it\n if (v16) recolourCodes(ref.current);\n if (valueRef.current !== known.current && !md) load(valueRef.current);\n }, 400);\n }}\n >\n {readOnly ? null : (\n <FormatToolbar\n open={toolbarOpen}\n sticky={!dense}\n stickyTop={stickyTop}\n width={width}\n dense={dense}\n fmt={fmt}\n md={!!md}\n allows={allows}\n hideFullscreen={hideFullscreen}\n insertOpen={insertOpen}\n setInsertOpen={(o) => {\n if (o) inserted.current = false;\n setInsertOpen(o);\n }}\n onMenuOpen={(name, o) => {\n setMenus((m) => ({ ...m, [name]: o }));\n // BL-538: a closing menu (finalFocus={false}) drops focus on <body> after its item ran: give the caret back\n // to the text, but only when focus is truly lost (an item may have opened a field of its own)\n if (!o)\n requestAnimationFrame(() => {\n const ae = document.activeElement;\n if (!ae || ae === document.body) restoreSel();\n });\n }}\n onStyle={onStyle}\n onMark={onMark}\n onList={(kind) =>\n allows(kind) &&\n run(() => {\n // Chrome nests the list inside a heading/quote (<h2><ul>…) — turn the line into a paragraph first.\n const b = currentBlock();\n if (b && /^(H[1-6]|BLOCKQUOTE)$/.test(b.tagName)) turnInto(b, \"p\");\n exec(kind === \"ul\" ? \"insertUnorderedList\" : \"insertOrderedList\");\n // …and it can still leave <p><ul>…</ul></p>; lift the list out of any text block.\n ref.current?.querySelectorAll(\":is(p,h1,h2,h3,h4,h5,h6,blockquote) > :is(ul,ol)\").forEach((list) => {\n const host = list.parentElement!;\n host.replaceWith(...Array.from(host.childNodes).filter((n) => n.nodeType === 1 || n.textContent?.trim()));\n });\n })\n }\n onLink={openLink}\n onClear={() =>\n run(() => {\n // RT-019: clear formatting strips styling marks; a link is content, not formatting, so it stays.\n exec(\"removeFormat\");\n })\n }\n onComment={commentSel}\n onInlineCode={() => {\n restoreSel();\n toggleInlineCode();\n }}\n onCodeBlock={() => {\n restoreSel();\n if (allows(\"pre\")) turnInto(currentBlock(), \"pre\");\n }}\n onInsert={(it) => {\n inserted.current = true;\n restoreSel();\n insertBlock(it);\n setInsertOpen(false);\n }}\n keepFocusOnInsertClose={() => inserted.current}\n onFullscreen={() => setModalOpen(true)}\n onFocusMode={openFocus}\n onMarkdown={toggleMarkdown}\n saveSel={saveSel}\n />\n )}\n\n {md ? (\n <div className=\"px-3 pb-2.5 pt-2.5\">\n <Textarea\n aria-label=\"Field content as Markdown\"\n spellCheck={false}\n value={md.text}\n readOnly={readOnly}\n onChange={(e) => {\n setMd({ ...md, text: e.target.value });\n setMdConfirm(false);\n }}\n className={cn(\"font-kit-mono text-kit-xs leading-5\", expanded ? \"min-h-[60vh]\" : dense ? \"min-h-[120px]\" : \"min-h-[190px]\")}\n style={scrollable ? { maxHeight } : undefined}\n />\n <p className=\"mt-1.5 text-kit-2xs text-kit-fg-3\">Markdown. Switching back converts it to blocks.</p>\n <AnimatePresence initial={false}>\n {mdConfirm ? (\n <motion.div\n key=\"confirm\"\n initial={{ opacity: 0, y: reduceMotion ? 0 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduceMotion ? 0 : 4 }}\n transition={{ duration: 0.15 }}\n role=\"alertdialog\"\n aria-label=\"Convert edited Markdown?\"\n className=\"mt-2 flex flex-wrap items-center gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle px-3 py-2\"\n >\n <span className=\"flex-1 text-kit-sm font-medium text-kit-fg\">Convert edited Markdown?</span>\n <Button size=\"xs\" variant=\"ghost\" onClick={() => setMdConfirm(false)}>\n Keep editing Markdown\n </Button>\n <Button size=\"xs\" variant=\"primary\" autoFocus onClick={convertMarkdown}>\n Convert to rich text\n </Button>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n ) : (\n <div\n ref={scroller}\n className={cn(\"relative\", scrollable && \"overflow-y-auto\")}\n style={scrollable ? { maxHeight } : undefined}\n onMouseMove={(e) => {\n if (drag || blockMenu || gutterInsert || !showGutter) return;\n const t = e.target as HTMLElement;\n if (t.closest(\"[data-rt-gutter]\")) return;\n const b = topBlock(ref.current, t);\n // a component card carries its own handle and ⋯ menu (V2 rich-text-editor.tsx:1297-1298): no second grip beside it\n placeGutter(b?.getAttribute(\"data-rt-island\") === \"component\" ? null : b);\n }}\n >\n <div\n ref={ref}\n id={inModal ? undefined : id}\n role=\"textbox\"\n aria-multiline={!single}\n aria-labelledby={!inModal && id ? `${id}-label` : undefined}\n aria-label=\"Rich text\"\n aria-placeholder={ph}\n aria-readonly={readOnly || undefined}\n aria-invalid={invalid || undefined}\n contentEditable={!readOnly}\n suppressContentEditableWarning\n spellCheck\n tabIndex={readOnly ? 0 : undefined}\n onInput={onInput}\n onKeyDown={onKeyDown}\n onKeyUp={refresh}\n onMouseUp={refresh}\n onMouseDown={(e) => {\n // V2 rich-text-editor.tsx:1314-1321: a press on a task's box ticks it (the caret stays where it was)\n if (readOnly || !ref.current || !toggleTaskAtPointer(ref.current, e.target, e.clientX)) return;\n e.preventDefault();\n emit();\n }}\n onClick={(e) => {\n const fn = (e.target as HTMLElement).closest?.<HTMLElement>(FN_MARK);\n if (fn && ref.current?.contains(fn) && !fn.closest(\"[data-rt-island]\") && !readOnly) {\n e.preventDefault();\n return openFootnote(fn);\n }\n const a = ref.current ? buttonAt(ref.current, e.target) : null;\n if (!a || readOnly) return;\n e.preventDefault();\n openButton(a);\n }}\n onPaste={(e) => {\n if (readOnly) return;\n const files = Array.from(e.clipboardData.files).filter((f) => f.type.startsWith(\"image/\"));\n if (files.length) {\n e.preventDefault();\n notify(allows(\"image\") ? \"Add images from the media library\" : \"This field keeps no images\", {\n description: allows(\"image\") ? \"A pasted file has no address the page can show it from. Use Insert › Image.\" : undefined,\n });\n return;\n }\n const text = e.clipboardData.getData(\"text/plain\");\n e.preventDefault();\n // RT-016: a paste with HTML (a web page, a document) keeps what the field accepts, and says what it\n // leaves out; only the plain text was read before, so a heading and bold became one plain paragraph and\n // a picture vanished in silence. A one-line field keeps the plain-text path below.\n const pasted = single ? \"\" : e.clipboardData.getData(\"text/html\");\n if (pasted) {\n const clean = ops.pastedHtml(pasted, allows(\"image\"));\n if (clean.images) {\n notify(\"Add images from the media library\", {\n // QA q18: the picture had an address; what it lacks is a place in the media library\n description: \"Pictures from another page are left out. Only media library images are kept. Use Insert › Image.\",\n });\n }\n if (clean.html.replace(/<[^>]*>/g, \"\").trim()) {\n insertHtmlAtCaret(conform(clean.html));\n if (ref.current) hydrate(ref.current);\n emit();\n return;\n }\n }\n if (!text) return;\n if (single || (!/\\n/.test(text.trim()) && !looksLikeMarkdown(text))) {\n insertTextAtCaret(single ? text.replace(/\\s*\\n\\s*/g, \" \") : text);\n emit();\n return;\n }\n let html: string;\n try {\n html = markdownToHtml(text);\n } catch {\n html = text.split(/\\n{2,}/).map((p) => `<p>${esc(p.trim()).replace(/\\n/g, \"<br>\")}</p>`).join(\"\");\n }\n insertHtmlAtCaret(conform(html));\n if (ref.current) hydrate(ref.current);\n emit();\n }}\n onDragOver={(e) => {\n if (e.dataTransfer.types.includes(\"application/x-bcms-asset\") && allows(\"image\")) e.preventDefault();\n }}\n onDrop={(e) => {\n const asset = e.dataTransfer.getData(\"application/x-bcms-asset\");\n if (!asset || readOnly || !allows(\"image\")) return;\n e.preventDefault();\n try {\n const a = JSON.parse(asset) as { url: string; alt?: string; name: string };\n const b = topBlock(ref.current, e.target as Node);\n const isl = createIsland(\"image\", defaultModel(\"image\", { src: a.url, alt: a.alt ?? \"\" }));\n if (b) b.after(isl);\n else ref.current?.append(isl);\n ops.ensureLineAfter(isl);\n emit();\n } catch {\n notify(\"That drop is not an image from the media library\");\n }\n }}\n className={cn(\n RT_PROSE,\n dense && RT_PANEL,\n v16 && V16_CODE_CLASS,\n v16 && V16_QUOTE_CLASS,\n v16 && !dense && V16_BODY_CLASS,\n \"peer relative outline-none focus-visible:shadow-none [&_*:not([data-rt-isolate]_*)]:outline-none\",\n \"[&>p[data-hint]]:before:pointer-events-none [&>p[data-hint]]:before:float-left [&>p[data-hint]]:before:h-0 [&>p[data-hint]]:before:text-kit-fg-4 [&>p[data-hint]]:before:content-[attr(data-hint)]\",\n \"[&_a[data-button]:not([data-rt-isolate]_*)]:cursor-pointer [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:cursor-pointer\",\n // line-height 0 after the size (tailwind-merge drops a leading before a text size): V2 gets it from preflight (RTE:1387)\n \"[&_sup[data-rt=fn]]:mx-px [&_sup[data-rt=fn]]:cursor-pointer [&_sup[data-rt=fn]]:rounded-kit-sm [&_sup[data-rt=fn]]:px-0.5 [&_sup[data-rt=fn]]:text-[0.72em] [&_sup[data-rt=fn]]:leading-[0] [&_sup[data-rt=fn]]:font-semibold [&_sup[data-rt=fn]]:text-kit-accent-fg [&_sup[data-rt=fn]:hover]:bg-kit-accent-soft\",\n dense ? \"px-2.5 py-2\" : v16 ? \"px-8 pb-7 pt-6\" : \"px-4 py-3.5\",\n minH,\n )}\n />\n {empty ? (\n <div aria-hidden className={cn(\"pointer-events-none absolute text-kit-fg-4 peer-focus:hidden\", dense ? \"text-kit-sm\" : v16 ? \"text-[16px] leading-[26px]\" : \"text-kit-base\", dense ? \"left-2.5 top-2\" : v16 ? \"left-8 top-6\" : \"left-4 top-3.5\")}>\n {ph}\n </div>\n ) : null}\n\n {v16\n ? codes.map((s, i) => (\n <CodeHead key={i} s={s} readOnly={readOnly} onLanguage={setCodeLanguage} onLayout={() => requestAnimationFrame(() => placeCodes(true))} notify={(m) => notify(m)} />\n ))\n : null}\n\n {/* Block gutter (+ / grip) */}\n {gutter && showGutter ? (\n <div\n data-rt-gutter=\"\"\n /* z-3: under the sticky toolbar (z-4), so a tall block's grip never paints over it */\n className={cn(\n \"absolute z-[3] flex\",\n gutterMode === \"outside\" ? \"-left-12 pr-1\" : \"left-0\",\n v16 && gutterMode === \"outside\"\n ? // a table's handle stands 78 out (prototype content.jsx:1171), clear of the grid's row chips\n (gBlock?.getAttribute(\"data-rt-island\") === \"table\" ? \"-left-[78px] \" : \"-left-[54px] \") +\n \"group/bh items-center gap-px rounded-[7px] p-px pr-px transition-[background-color,box-shadow] duration-100 hover:bg-kit-insp-tip-bg hover:shadow-[0_0_0_1px_var(--kit-insp-tip-line),0_1px_2px_rgb(0_0_0/0.06),0_2px_8px_-2px_rgb(0_0_0/0.06)] \" +\n // M30: the handle appears with a 120ms fade (opacity only), on hover devices and with motion allowed\n \"[@media(hover:hover)]:motion-safe:animate-[kit-fade-in_120ms_ease-out]\"\n : \"items-start\",\n )}\n style={{ top: gutter.top + Math.max(-2, Math.min(4, gutter.height / 2 - 12)) }}\n >\n {gutterMode === \"outside\" ? (\n <Popover\n open={gutterInsert}\n onOpenChange={(o) => {\n if (o) {\n gutterTarget.current = gutter.el;\n inserted.current = false;\n }\n setGutterInsert(o);\n }}\n >\n <Tooltip content=\"Add a block below\" disabled={gutterInsert}>\n <PopoverTrigger\n aria-label=\"Add a block below\"\n className={v16 ? V16_HANDLE_BTN : cn(\"flex items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover data-[popup-open]:text-kit-fg\", btn)}\n >\n <IconPlus stroke={1.5} aria-hidden />\n </PopoverTrigger>\n </Tooltip>\n {v16 ? <i aria-hidden className=\"h-3.5 w-px bg-transparent transition-colors duration-100 group-hover/bh:bg-kit-insp-tip-line\" /> : null}\n {gutterInsert ? (\n <InsertMenuContent\n side=\"bottom\"\n align=\"start\"\n allows={allows}\n keepFocusOnClose={() => inserted.current}\n onInsert={(it) => {\n const b = gutterTarget.current;\n const el = ref.current;\n inserted.current = true;\n setGutterInsert(false);\n if (!b || !el || !el.contains(b)) return;\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n b.after(p);\n el.focus({ preventScroll: true });\n placeCaret(p);\n insertBlock(it);\n }}\n />\n ) : null}\n </Popover>\n ) : null}\n <Menu open={blockMenu} onOpenChange={setBlockMenu}>\n <Tooltip content={v16 ? \"Drag to move · click for menu\" : \"Drag to move, click for options\"} disabled={blockMenu || !!drag}>\n <MenuTrigger\n aria-label=\"Block options\"\n onPointerDown={onGripDown}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setBlockMenu(true);\n }\n }}\n className={\n v16 && gutterMode !== \"inset\"\n ? cn(V16_HANDLE_BTN, \"cursor-grab active:cursor-grabbing\", (blockMenu || drag) && \"bg-kit-insp-tip-line text-kit-insp-tip-title\")\n : cn(\n \"flex cursor-grab items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg active:cursor-grabbing\",\n gutterMode === \"inset\" ? \"h-[22px] w-4 rounded-kit-sm [&_svg:not([data-rt-isolate]_*)]:size-3.5\" : btn,\n (blockMenu || drag) && \"bg-kit-hover text-kit-fg\",\n )\n }\n >\n <IconGripVertical stroke={1.5} aria-hidden />\n </MenuTrigger>\n </Tooltip>\n <MenuContent className={v16 ? \"w-[200px] min-w-[200px] rounded-[10px]\" : \"w-56\"} align=\"start\" finalFocus={false}>\n {turnStyles.length > 1 && !v16 ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconTransform stroke={1.5} />} disabled={!gIsText}>\n Turn into\n </MenuSubTrigger>\n <MenuSubContent className=\"w-48\">\n {turnStyles.map((t) => (\n <MenuItem key={t.tag} icon={t.icon} onClick={() => turnInto(gBlock ?? null, t.tag)}>\n {t.label}\n </MenuItem>\n ))}\n </MenuSubContent>\n </MenuSub>\n ) : null}\n {/* look v16: the language lives on the code block's own header (code-head.tsx) */}\n {gBlock?.tagName === \"PRE\" && allows(\"pre\") && !v16 ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconCode stroke={1.5} />}>Language</MenuSubTrigger>\n <MenuSubContent className=\"w-48\">\n <MenuRadioGroup\n value={gLang == null ? LANG_NONE : CODE_LANGUAGES.some((l) => l.v === gLang) ? gLang : LANG_OTHER}\n onValueChange={(v: string) => v !== LANG_OTHER && setCodeLanguage(gBlock, v === LANG_NONE ? null : v)}\n >\n <MenuRadioItem value={LANG_NONE}>None</MenuRadioItem>\n <MenuSeparator />\n {CODE_LANGUAGES.map((l) => (\n <MenuRadioItem key={l.v} value={l.v}>\n {l.label}\n </MenuRadioItem>\n ))}\n <MenuSeparator />\n <MenuRadioItem\n value={LANG_OTHER}\n onClick={() => gutter && setLangOther({ pre: gBlock, value: gLang ?? \"\", error: null, top: gutter.top, height: gutter.height })}\n >\n Other…\n </MenuRadioItem>\n </MenuRadioGroup>\n </MenuSubContent>\n </MenuSub>\n ) : null}\n <MenuItem icon={<IconCopy stroke={1.5} />} shortcut=\"⌘D\" onClick={() => gBlock && duplicateBlock(gBlock)}>\n Duplicate\n </MenuItem>\n <MenuItem icon={<IconArrowBarToUp stroke={1.5} />} shortcut=\"⌘⇧↑\" disabled={!gBlock?.previousElementSibling} onClick={() => gBlock && moveBlock(gBlock, -1) && v16 && services.toast?.(\"Block moved\")}>\n Move up\n </MenuItem>\n <MenuItem icon={<IconArrowBarToDown stroke={1.5} />} shortcut=\"⌘⇧↓\" disabled={!gBlock?.nextElementSibling} onClick={() => gBlock && moveBlock(gBlock, 1) && v16 && services.toast?.(\"Block moved\")}>\n Move down\n </MenuItem>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => gBlock && deleteBlock(gBlock)}>\n {v16 ? \"Delete block\" : \"Delete\"}\n </MenuItem>\n </MenuContent>\n </Menu>\n </div>\n ) : null}\n {drag?.line != null ? <div className=\"pointer-events-none absolute inset-x-3 z-[6] h-0.5 rounded-full bg-kit-info\" style={{ top: drag.line }} /> : null}\n {/* RP-043: Language › Other…, under the code block it names (mounted closed, so its anchor is in place on open) */}\n {showGutter && allows(\"pre\") ? (\n <Popover open={!!langOther} onOpenChange={(o) => !o && setLangOther(null)}>\n <PopoverAnchor\n render={<span aria-hidden className=\"pointer-events-none absolute left-4 w-px\" style={{ top: langOther?.top ?? 0, height: langOther?.height ?? 0 }} />}\n />\n <PopoverContent className=\"w-64\" side=\"bottom\" align=\"start\">\n <form\n className=\"flex flex-col gap-2\"\n onSubmit={(e) => {\n e.preventDefault();\n submitOtherLanguage();\n }}\n >\n <label className=\"text-kit-xs font-medium text-kit-fg-2\" htmlFor={langId}>\n Language\n </label>\n <Input\n id={langId}\n autoFocus\n size=\"sm\"\n value={langOther?.value ?? \"\"}\n spellCheck={false}\n autoComplete=\"off\"\n placeholder=\"cpp\"\n aria-invalid={langOther?.error ? true : undefined}\n aria-describedby={langOther?.error ? `${langId}-error` : undefined}\n onChange={(e) => langOther && setLangOther({ ...langOther, value: e.target.value, error: null })}\n className=\"font-kit-mono [&_input]:font-kit-mono\"\n />\n {langOther?.error ? (\n <p id={`${langId}-error`} role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {langOther.error}\n </p>\n ) : null}\n <div className=\"flex justify-end\">\n <Button size=\"xs\" variant=\"primary\" type=\"submit\">\n Set language\n </Button>\n </div>\n </form>\n </PopoverContent>\n </Popover>\n ) : null}\n\n {/* Rich blocks render into their contenteditable=false hosts */}\n {islands.map(({ id: key, el }) => createPortal(<Island el={el} ctx={islandCtx} />, el, key))}\n </div>\n )}\n\n {/* Footnotes (V2 rich-text-editor.tsx:1533-1560): the notes in text order, each a way to edit it and back to it */}\n <FootnotesList\n notes={footnotes}\n readOnly={readOnly}\n density={dense ? \"dense\" : \"default\"}\n onEdit={(m) => openFootnote(m)}\n onBack={(m) => ref.current && backToMarker(ref.current, m)}\n />\n\n {/* Footer meta (V2 rich-text-editor.tsx:1563-1571), and any refusal said in place when the host has no toaster.\n BL-540: a one-line or panel field draws no word count; its footer shows only when it has something to say. */}\n {counts || notice ? (\n <div className=\"flex h-7 items-center justify-end gap-3 rounded-b-kit-lg border-t border-kit-line-subtle px-3 text-kit-2xs text-kit-fg-3\">\n {notice ? (\n <span role=\"status\" aria-live=\"polite\" className=\"mr-auto min-w-0 truncate text-kit-fg-2\">\n {notice.message}\n {notice.description ? ` ${notice.description}` : \"\"}\n {notice.action ? (\n <button\n type=\"button\"\n className=\"ml-1.5 font-medium text-kit-fg underline underline-offset-2\"\n onClick={() => {\n notice.action!.onClick();\n setNotice(null);\n }}\n >\n {notice.action.label}\n </button>\n ) : null}\n </span>\n ) : null}\n {counts ? (\n <span className=\"tabular-nums\">\n {words.toLocaleString(\"en-US\")} {words === 1 ? \"word\" : \"words\"}\n {comps ? ` · ${comps} ${comps === 1 ? \"component\" : \"components\"}` : \"\"} · {Math.max(1, Math.round(words / 220))} min read\n </span>\n ) : null}\n </div>\n ) : null}\n\n {/* Bubble toolbar on selection: a toolbar menu owns the moment, so the bubble steps aside while one is open */}\n {bubble && !quiet && !readOnly && !slash && !link && !md && !menus.style && !menus.more && !insertOpen ? (\n <SelectionBubble\n rect={bubble}\n avoid={toolbarOpen ? wrap.current?.querySelector<HTMLElement>('[role=\"toolbar\"][aria-label=\"Text formatting\"]')?.getBoundingClientRect() : null}\n fmt={fmt}\n allows={allows}\n saveSel={saveSel}\n onAi={canAI ? aiRewrite : undefined}\n onStyle={onStyle}\n onMark={onMark}\n onInlineCode={() => {\n restoreSel();\n toggleInlineCode();\n }}\n onLink={openLink}\n onComment={commentSel}\n />\n ) : null}\n\n {/* Slash menu (opens only at the start of a block; never takes focus) */}\n {slash && !md\n ? createPortal(\n <>\n <div data-floating-layer=\"\" className=\"pointer-events-auto fixed inset-0 z-[var(--kit-z-popover,84)]\" onMouseDown={() => setSlash(null)} />\n <motion.div\n // every look; reduced motion (the OS, or a host MotionConfig \"always\"): a fade with no travel\n initial={{ opacity: 0, y: slashReduce ? 0 : flipUp ? -4 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ duration: 0.14, ease: \"easeOut\" }}\n style={{\n left: Math.min(window.innerWidth - 330, Math.max(8, slash.rect.left)),\n ...(flipUp ? { bottom: window.innerHeight - slash.rect.top + 6 } : { top: slash.rect.bottom + 6 }),\n }}\n data-floating-layer=\"\"\n className=\"pointer-events-auto fixed z-[calc(var(--kit-z-popover,84)_+_1)]\"\n >\n <SlashMenuPanel query={slash.query} folder={slash.folder} aiOffered={canAiCommand} aiView={!!slash.ai} active={slash.active} allows={allows} setActive={(a) => setSlash((s) => s && { ...s, active: a })} onPick={pickSlash} maxHeight={slashMaxH} />\n </motion.div>\n </>,\n document.body,\n )\n : null}\n\n {/* Footnote note: a small popover at its marker (V2 rich-text-editor.tsx:1644-1680, one setting) */}\n <Popover open={!!fnEdit} onOpenChange={(o) => !o && closeFootnote()}>\n <PopoverAnchor\n render={<span className=\"pointer-events-none fixed\" style={fnEdit ? { top: fnEdit.rect.bottom, left: fnEdit.rect.left, width: Math.max(1, fnEdit.rect.width), height: 1 } : { top: 0, left: 0 }} />}\n />\n <PopoverContent className={FOOTNOTE_POPOVER_CLASS} finalFocus={false}>\n {fnEdit ? (\n <FootnoteEditor\n key={footnotes.findIndex((f) => f.el === fnEdit.el)}\n n={footnotes.findIndex((f) => f.el === fnEdit.el) + 1}\n note={fnEdit.el.getAttribute(\"data-note\") ?? \"\"}\n onChange={(v) => {\n fnEdit.el.setAttribute(\"data-note\", v);\n emit();\n }}\n onRemove={() => removeFootnote(fnEdit.el)}\n onDone={closeFootnote}\n />\n ) : null}\n </PopoverContent>\n </Popover>\n\n {/* Link popover anchored to the selection */}\n <Popover open={!!link} onOpenChange={(o) => !o && closeLink()}>\n <PopoverAnchor\n render={<span className=\"pointer-events-none fixed\" style={link ? { top: link.rect.bottom, left: link.rect.left, width: Math.max(1, link.rect.width), height: 1 } : { top: 0, left: 0 }} />}\n />\n <PopoverContent className=\"w-[340px] rounded-kit-lg p-3\" finalFocus={false}>\n {link?.button ? (\n <ButtonLinkPanel\n initial={link.initial}\n label={link.button.label}\n allowNewTab={allowNewTab}\n onSave={saveButton}\n onCancel={closeLink}\n onDetach={() => {\n const a = link.button!.a;\n if (ref.current) removeButton(ref.current, a);\n emit();\n closeLink();\n }}\n />\n ) : link ? (\n <div className=\"flex flex-col gap-2\">\n <LinkPopoverBody\n initial={toLinkValue(link.initial)}\n hideNewTab={!allowNewTab}\n onSave={(v) => saveLink(fromLinkValue(v, allowNewTab))}\n onCancel={closeLink}\n onDetach={\n link.existing\n ? () => {\n const a = link.existing!;\n const kids = Array.from(a.childNodes);\n a.replaceWith(...kids);\n // Moving the text out collapsed the kept range: it selects the words the link held.\n if (kids.length) {\n const r = document.createRange();\n r.setStartBefore(kids[0]!);\n r.setEndAfter(kids[kids.length - 1]!);\n saved.current = r;\n }\n emit();\n closeLink();\n }\n : undefined\n }\n />\n </div>\n ) : null}\n </PopoverContent>\n </Popover>\n {!hideFullscreen ? (\n <ExpandedEditorModal open={modalOpen} onOpenChange={setModalOpen} crumbs={expandCrumbs?.length ? expandCrumbs : [\"Text\"]} returnFocus={() => ref.current}>\n {modalOpen ? (\n <RichTextEditor\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n docKey={`${docKey}:expanded`}\n features={features}\n references={references}\n single={single}\n allowNewTab={allowNewTab}\n expandCrumbs={expandCrumbs}\n variant=\"document\"\n hideFullscreen\n inModal\n autoFocus\n onComment={commentInPlace ? undefined : onComment}\n components={components}\n />\n ) : null}\n </ExpandedEditorModal>\n ) : null}\n </div>\n </CatalogComponentsProvider>\n );\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAM,kBACJ;;AAEF,IAAM,iBACJ;AACF,IAAa,WACX;;AAiCF,IAAa,WAAW;;AAGxB,IAA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