@bettercms-ai/kit 3.0.2 → 3.1.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.
Files changed (155) hide show
  1. package/dist/brand/logo.js +18 -67
  2. package/dist/brand/logo.js.map +1 -1
  3. package/dist/context.js +3 -8
  4. package/dist/context.js.map +1 -1
  5. package/dist/controls/button.js +134 -451
  6. package/dist/controls/button.js.map +1 -1
  7. package/dist/controls/choice.js +95 -336
  8. package/dist/controls/choice.js.map +1 -1
  9. package/dist/controls/code.js +72 -245
  10. package/dist/controls/code.js.map +1 -1
  11. package/dist/controls/color.js +31 -108
  12. package/dist/controls/color.js.map +1 -1
  13. package/dist/controls/date.js +83 -268
  14. package/dist/controls/date.js.map +1 -1
  15. package/dist/controls/form-picker.js +9 -26
  16. package/dist/controls/form-picker.js.map +1 -1
  17. package/dist/controls/icon.js +100 -341
  18. package/dist/controls/icon.js.map +1 -1
  19. package/dist/controls/json.js +7 -20
  20. package/dist/controls/json.js.map +1 -1
  21. package/dist/controls/link.js +156 -561
  22. package/dist/controls/link.js.map +1 -1
  23. package/dist/controls/location.js +35 -124
  24. package/dist/controls/location.js.map +1 -1
  25. package/dist/controls/media.js +267 -928
  26. package/dist/controls/media.js.map +1 -1
  27. package/dist/controls/number.js +23 -80
  28. package/dist/controls/number.js.map +1 -1
  29. package/dist/controls/reference.js +155 -516
  30. package/dist/controls/reference.js.map +1 -1
  31. package/dist/controls/rich-text/article-shell.js +86 -327
  32. package/dist/controls/rich-text/article-shell.js.map +1 -1
  33. package/dist/controls/rich-text/author.js +21 -78
  34. package/dist/controls/rich-text/author.js.map +1 -1
  35. package/dist/controls/rich-text/blocks.js +317 -1086
  36. package/dist/controls/rich-text/blocks.js.map +1 -1
  37. package/dist/controls/rich-text/button.js +10 -31
  38. package/dist/controls/rich-text/button.js.map +1 -1
  39. package/dist/controls/rich-text/catalog.js +51 -168
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/columns.js +31 -104
  42. package/dist/controls/rich-text/columns.js.map +1 -1
  43. package/dist/controls/rich-text/component-card.js +209 -790
  44. package/dist/controls/rich-text/component-card.js.map +1 -1
  45. package/dist/controls/rich-text/component-panel.js +40 -102
  46. package/dist/controls/rich-text/component-panel.js.map +1 -1
  47. package/dist/controls/rich-text/control.js +32 -101
  48. package/dist/controls/rich-text/control.js.map +1 -1
  49. package/dist/controls/rich-text/editor.js +108 -369
  50. package/dist/controls/rich-text/editor.js.map +1 -1
  51. package/dist/controls/rich-text/embed.js +51 -184
  52. package/dist/controls/rich-text/embed.js.map +1 -1
  53. package/dist/controls/rich-text/floating.js +42 -171
  54. package/dist/controls/rich-text/floating.js.map +1 -1
  55. package/dist/controls/rich-text/footnote.js +28 -89
  56. package/dist/controls/rich-text/footnote.js.map +1 -1
  57. package/dist/controls/rich-text/gallery.js +27 -88
  58. package/dist/controls/rich-text/gallery.js.map +1 -1
  59. package/dist/controls/rich-text/link-form.d.ts +10 -0
  60. package/dist/controls/rich-text/link-form.js +16 -204
  61. package/dist/controls/rich-text/link-form.js.map +1 -1
  62. package/dist/controls/rich-text/plain.js +3 -8
  63. package/dist/controls/rich-text/plain.js.map +1 -1
  64. package/dist/controls/rich-text/related.js +25 -86
  65. package/dist/controls/rich-text/related.js.map +1 -1
  66. package/dist/controls/rich-text/toc.js +15 -48
  67. package/dist/controls/rich-text/toc.js.map +1 -1
  68. package/dist/controls/rich-text/toolbar.js +105 -402
  69. package/dist/controls/rich-text/toolbar.js.map +1 -1
  70. package/dist/controls/scale.js +52 -169
  71. package/dist/controls/scale.js.map +1 -1
  72. package/dist/controls/slot.js +73 -238
  73. package/dist/controls/slot.js.map +1 -1
  74. package/dist/controls/table/table-editor.js +500 -1766
  75. package/dist/controls/table/table-editor.js.map +1 -1
  76. package/dist/controls/table/table-link.js +41 -121
  77. package/dist/controls/table/table-link.js.map +1 -1
  78. package/dist/controls/table/table.js +9 -26
  79. package/dist/controls/table/table.js.map +1 -1
  80. package/dist/controls/text.js +68 -221
  81. package/dist/controls/text.js.map +1 -1
  82. package/dist/controls/unknown-value.js +22 -79
  83. package/dist/controls/unknown-value.js.map +1 -1
  84. package/dist/engine/array.js +228 -821
  85. package/dist/engine/array.js.map +1 -1
  86. package/dist/engine/bits.js +13 -38
  87. package/dist/engine/bits.js.map +1 -1
  88. package/dist/engine/breadcrumb.js +8 -25
  89. package/dist/engine/breadcrumb.js.map +1 -1
  90. package/dist/engine/expand.js +13 -38
  91. package/dist/engine/expand.js.map +1 -1
  92. package/dist/engine/field-list.js +5 -14
  93. package/dist/engine/field-list.js.map +1 -1
  94. package/dist/engine/field-shell.js +244 -849
  95. package/dist/engine/field-shell.js.map +1 -1
  96. package/dist/engine/frame.js +78 -275
  97. package/dist/engine/frame.js.map +1 -1
  98. package/dist/engine/grouping.js +193 -630
  99. package/dist/engine/grouping.js.map +1 -1
  100. package/dist/engine/item-list.js +50 -187
  101. package/dist/engine/item-list.js.map +1 -1
  102. package/dist/engine/kit-field.js +95 -320
  103. package/dist/engine/kit-field.js.map +1 -1
  104. package/dist/engine/schema-form.js +32 -101
  105. package/dist/engine/schema-form.js.map +1 -1
  106. package/dist/engine/slot.js +45 -146
  107. package/dist/engine/slot.js.map +1 -1
  108. package/dist/lib/icons.js +5 -14
  109. package/dist/lib/icons.js.map +1 -1
  110. package/dist/styles.css +1 -5821
  111. package/dist/table/table-view.js +16 -49
  112. package/dist/table/table-view.js.map +1 -1
  113. package/dist/testing/test-form.js +5 -14
  114. package/dist/testing/test-form.js.map +1 -1
  115. package/dist/theme.js +3 -8
  116. package/dist/theme.js.map +1 -1
  117. package/dist/ui/action-tray.js +24 -97
  118. package/dist/ui/action-tray.js.map +1 -1
  119. package/dist/ui/autocomplete.js +38 -135
  120. package/dist/ui/autocomplete.js.map +1 -1
  121. package/dist/ui/button.js +31 -108
  122. package/dist/ui/button.js.map +1 -1
  123. package/dist/ui/choice-switch.js +5 -14
  124. package/dist/ui/choice-switch.js.map +1 -1
  125. package/dist/ui/controls.js +86 -279
  126. package/dist/ui/controls.js.map +1 -1
  127. package/dist/ui/display.js +116 -401
  128. package/dist/ui/display.js.map +1 -1
  129. package/dist/ui/expanded-editor-modal.js +27 -100
  130. package/dist/ui/expanded-editor-modal.js.map +1 -1
  131. package/dist/ui/floating-panel.js +37 -130
  132. package/dist/ui/floating-panel.js.map +1 -1
  133. package/dist/ui/input.js +59 -196
  134. package/dist/ui/input.js.map +1 -1
  135. package/dist/ui/mode-bar.js +11 -32
  136. package/dist/ui/mode-bar.js.map +1 -1
  137. package/dist/ui/overlay.js +176 -613
  138. package/dist/ui/overlay.js.map +1 -1
  139. package/dist/ui/path-crumbs.js +113 -374
  140. package/dist/ui/path-crumbs.js.map +1 -1
  141. package/dist/ui/select.js +78 -311
  142. package/dist/ui/select.js.map +1 -1
  143. package/dist/ui/shortcut-hint.js +6 -19
  144. package/dist/ui/shortcut-hint.js.map +1 -1
  145. package/dist/ui/spinner.js +7 -20
  146. package/dist/ui/spinner.js.map +1 -1
  147. package/dist/ui/split-button.js +10 -35
  148. package/dist/ui/split-button.js.map +1 -1
  149. package/dist/ui/tab.js +17 -50
  150. package/dist/ui/tab.js.map +1 -1
  151. package/dist/ui/toast.js +30 -107
  152. package/dist/ui/toast.js.map +1 -1
  153. package/dist/ui/tooltip-root.js +7 -24
  154. package/dist/ui/tooltip-root.js.map +1 -1
  155. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"article-shell.js","names":[],"sources":["../../../src/controls/rich-text/article-shell.tsx"],"sourcesContent":["/**\n * RICH TEXT · the article-block shell (V2 article-blocks.tsx ArticleBlock), shared by every article block: the one-open\n * store (one panel or popover open at a time), the card the block draws in (a focusable group: Enter opens it, Escape\n * closes it then leaves, ⌘Z / ⌘⇧Z, ⌘D, ⌥↑/↓, Backspace), the edit / remove chip on its top edge, the empty state, the\n * schema form a panel or popover holds, and the floating properties panel (D54).\n *\n * surface \"panel\" ArticlePanelBlock: ArticleCard + useArticleOpen + ArticlePanel(ArticleForm) (pull quote, gallery,\n * related posts)\n * surface \"popover\" ArticlePopoverBlock: ArticleCard + useArticleOpen + a Popover of ArticleForm (embed, table of\n * contents, author bio)\n * surface \"inline\" ArticleCard without onOpen: the block edits in the text itself (key takeaways)\n */\nimport * as React from \"react\";\nimport { IconArrowsMove, IconCopy, IconDimensions, IconDots, IconLayoutSidebar, IconLayoutSidebarRight, IconSettings, IconTrash, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { Button, IconButton } from \"../../ui/button\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverAnchor, PopoverContent, Tooltip } from \"../../ui/overlay\";\nimport { FloatingPanel, type FloatingPanelHandle } from \"../../ui/floating-panel\";\nimport { SchemaForm } from \"../../engine/schema-form\";\nimport { useKitEnv } from \"../../context\";\nimport type { TypeSchema } from \"../../schema/types\";\nimport type { IslandEl } from \"./dom\";\nimport type { IslandCtx } from \"./blocks\";\n\n/* ── one article panel open at a time (V2 useOpenArticle) ── */\nexport interface OpenArticle {\n id: string;\n /** the field the panel focuses when it opens (a click on the preview's `data-field`), null = the first */\n focusKey: string | null;\n /** bumps on every open, so re-opening the open block refocuses */\n nonce: number;\n}\nlet openArticle: OpenArticle | null = null;\nconst articleSubs = new Set<() => void>();\nconst setOpenArticle = (next: OpenArticle | null) => {\n openArticle = next;\n articleSubs.forEach((f) => f());\n};\n/** The article block open now, if any. */\nexport const currentOpenArticle = () => openArticle;\nexport function useOpenArticle() {\n return React.useSyncExternalStore(\n (cb) => (articleSubs.add(cb), () => void articleSubs.delete(cb)),\n () => openArticle,\n () => openArticle,\n );\n}\n\n/**\n * One block's place in the one-open store: `open(field?)` opens it (closing any other), `close()` closes it if it is\n * the open one. It closes when the block unmounts, and a fresh insert (`autoFocus`) opens its form.\n */\nexport function useArticleOpen({ ro, autoFocus }: { ro: boolean; autoFocus: boolean }) {\n const uid = React.useId();\n const open = useOpenArticle();\n const editing = open?.id === uid;\n const openPanel = React.useCallback((k?: string | null) => {\n if (!ro) setOpenArticle({ id: uid, focusKey: k ?? null, nonce: (openArticle?.nonce ?? 0) + 1 });\n }, [uid, ro]);\n const close = React.useCallback(() => {\n if (openArticle?.id === uid) setOpenArticle(null);\n }, [uid]);\n React.useEffect(() => () => {\n if (openArticle?.id === uid) setOpenArticle(null);\n }, [uid]);\n React.useEffect(() => {\n // a fresh insert opens its form\n if (autoFocus && !ro) openPanel();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n return { open, editing, openPanel, close };\n}\n\nconst controlOf = (el: HTMLElement) =>\n Array.from(el.querySelectorAll<HTMLElement>(\"textarea, input:not([type=hidden]), [contenteditable=true], [role=combobox]\")).find((n) => n.getClientRects().length) ??\n Array.from(el.querySelectorAll<HTMLElement>(\":scope > :not(:first-child) button\")).find((n) => n.getClientRects().length);\n/** Focus the form row `key` names (`data-field-key`), else the first row. */\nexport function focusField(root: HTMLElement | null, key: string | null) {\n if (!root) return;\n const rows = Array.from(root.querySelectorAll<HTMLElement>(\"[data-field-key]\"));\n const row = (key && rows.find((r) => r.getAttribute(\"data-field-key\") === key)) || rows[0];\n if (!row) return;\n row.scrollIntoView({ block: \"nearest\" });\n controlOf(row)?.focus({ preventScroll: true });\n}\n\n/**\n * V2 ArticleBlock onKeyDown, on the card itself (its own fields handle their own keys). With `onOpen` (a panel or\n * popover block) Enter / Space open it and Escape closes it first; without (an inline block) Escape leaves the block.\n */\nexport function articleCardKeyDown({\n card, ctx, el, ro, editing = false, onOpen, onClose, focusCard,\n}: {\n card: React.RefObject<HTMLElement | null>;\n ctx: IslandCtx;\n el: IslandEl;\n ro: boolean;\n editing?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n focusCard: () => void;\n}) {\n return (e: React.KeyboardEvent) => {\n if (e.defaultPrevented || e.target !== card.current) return;\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n if (mod && k === \"z\") {\n e.preventDefault();\n e.stopPropagation();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n return;\n }\n if (onOpen && (e.key === \"Enter\" || e.key === \" \")) {\n e.preventDefault();\n onOpen();\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n if (editing) onClose?.();\n else ctx.exit(el);\n return;\n }\n if (ro) return;\n if (mod && k === \"d\" && ctx.duplicate) {\n e.preventDefault();\n e.stopPropagation();\n ctx.duplicate(el);\n } else if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") && ctx.move) {\n e.preventDefault();\n ctx.move(el, e.key === \"ArrowUp\" ? -1 : 1);\n focusCard();\n } else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n ctx.remove(el);\n }\n };\n}\n\n/** The chip on the block's top edge (so it never covers the block's own text): Edit (with `onEdit`) and Remove. */\nexport function ArticleActions({\n label, ctx, el, editing = false, onEdit, tooltips = false,\n}: {\n label: string;\n ctx: IslandCtx;\n el: IslandEl;\n editing?: boolean;\n /** toggles the block's panel or popover; absent on an inline block */\n onEdit?: () => void;\n /** each button also says what it does in a tooltip */\n tooltips?: boolean;\n}) {\n if (ctx.readOnly) return null;\n const tip = (content: string, button: React.ReactElement) => (tooltips ? <Tooltip content={content}>{button}</Tooltip> : button);\n return (\n <div\n className={cn(\n \"absolute -top-3.5 right-2 z-[2] flex items-center gap-0.5 rounded-kit-md border border-kit-line bg-kit-surface-raised p-0.5 opacity-0 shadow-kit-sm transition-opacity\",\n \"group-hover/art:opacity-100 group-focus-within/art:opacity-100 pointer-coarse:opacity-100\",\n editing && \"opacity-100\",\n )}\n >\n {onEdit\n ? tip(\n `Edit ${label.toLowerCase()}`,\n <IconButton size=\"xs\" label={`Edit ${label.toLowerCase()}`} onClick={onEdit}>\n <IconSettings stroke={1.5} />\n </IconButton>,\n )\n : null}\n {tip(\n `Remove ${label.toLowerCase()}`,\n <IconButton size=\"xs\" label={`Remove ${label.toLowerCase()}`} onClick={() => ctx.remove(el)} className=\"hover:text-kit-danger-fg\">\n <IconTrash stroke={1.5} />\n </IconButton>,\n )}\n </div>\n );\n}\n\n/**\n * The card an article block draws in. With `onOpen` (panel / popover) it is pressable: a click opens it on the field\n * clicked (`data-field`), and it shows the open ring while `editing`. Without, it is the inline block's quiet group.\n */\nexport const ArticleCard = React.forwardRef<\n HTMLDivElement,\n { label: string; kind: string; ro: boolean; editing?: boolean; onOpen?: (field: string | null) => void; onKeyDown: (e: React.KeyboardEvent) => void; children: React.ReactNode }\n>(function ArticleCard({ label, kind, ro, editing = false, onOpen, onKeyDown, children }, ref) {\n if (!onOpen)\n return (\n <div\n ref={ref}\n role=\"group\"\n tabIndex={0}\n aria-label={label}\n aria-roledescription=\"block\"\n data-rt-isolate=\"\"\n data-article-block={kind}\n onKeyDown={onKeyDown}\n className=\"group/art relative rounded-kit-lg outline-none transition-shadow duration-150 focus-visible:shadow-[0_0_0_1px_var(--kit-line-strong)]\"\n >\n {children}\n </div>\n );\n return (\n <div\n ref={ref}\n role=\"group\"\n tabIndex={0}\n aria-label={`${label}${editing ? \", editing\" : \"\"}`}\n aria-roledescription=\"block\"\n aria-haspopup=\"dialog\"\n aria-expanded={editing}\n data-rt-isolate=\"\"\n data-article-block={kind}\n onKeyDown={onKeyDown}\n onClick={(e) => {\n if (ro || !e.currentTarget.contains(e.target as Node)) return;\n const t = e.target as HTMLElement;\n if (t.closest(\"button,a,[role=menuitem]\")) return;\n onOpen(t.closest<HTMLElement>(\"[data-field]\")?.getAttribute(\"data-field\") ?? null);\n }}\n className={cn(\n \"group/art relative rounded-kit-lg outline-none transition-shadow duration-150\",\n !ro && \"cursor-pointer\",\n \"focus-visible:shadow-[0_0_0_1px_var(--kit-line-strong)]\",\n editing ? \"shadow-[0_0_0_2px_var(--kit-accent)] focus-visible:shadow-[0_0_0_2px_var(--kit-accent)]\" : !ro && \"hover:shadow-[0_0_0_1px_var(--kit-line)]\",\n )}\n >\n {children}\n </div>\n );\n});\n\n/** The block's settings, built from its schema (V2 ArticleForm: the kit SchemaForm, flush to the panel's top). */\nexport function ArticleForm({\n schema, label, value, onChange, ro,\n}: {\n schema: TypeSchema;\n label: string;\n value: Record<string, unknown>;\n onChange: (v: Record<string, unknown>) => void;\n ro: boolean;\n}) {\n // a form of its own (its docId keys its expand and full-screen state), but the host's way to open a reference is the\n // outer form's: Open on a picked author or story, and on a picker-made draft's toast\n const { onOpenReference } = useKitEnv();\n return (\n <div data-article-form=\"\" className=\"min-w-0\">\n <SchemaForm schema={schema} value={value} onChange={onChange} variant=\"panel\" scroll={false} readOnly={ro} rootLabel={label} env={{ docId: `article:${schema.name}`, docTitle: label }} onOpenReference={onOpenReference} />\n <style>{`[data-article-form] [data-kit-form] section:first-of-type { border-top-width: 0; margin-top: 0; padding-top: 0; }`}</style>\n </div>\n );\n}\n\n/** V2 article-blocks.tsx Empty: a block with nothing to show yet. */\nexport const ArticleEmpty = ({ icon, title, action, onAction, ro }: { icon: React.ReactNode; title: string; action: string; onAction: () => void; ro: boolean }) => (\n <div className=\"flex items-center gap-3 rounded-kit-lg border border-dashed border-kit-line-strong bg-kit-subtle px-4 py-3.5\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-kit-md border border-kit-line bg-kit-control-bg text-kit-fg-2 [&_svg]:size-4\">{icon}</span>\n <span className=\"min-w-0 flex-1 text-kit-sm font-medium text-kit-fg\">{title}</span>\n {ro ? null : (\n <Button size=\"sm\" onClick={onAction}>\n {action}\n </Button>\n )}\n </div>\n);\n\n/* ── Floating properties panel (D54 primitive; V2 ArticlePanel) ─────────────── */\nexport function ArticlePanel({\n label, anchor, nonce, focusKey, onClose, focusBack, ctx, el, children,\n}: {\n label: string;\n anchor: HTMLElement | null;\n nonce: number;\n focusKey: string | null;\n onClose: () => void;\n focusBack: () => void;\n ctx: IslandCtx;\n el: IslandEl;\n children: React.ReactNode;\n}) {\n const panel = React.useRef<FloatingPanelHandle>(null);\n const titleId = React.useId();\n const container = anchor?.closest<HTMLElement>(\"[data-expanded-editor]\") ?? null;\n React.useEffect(() => {\n // the panel mounts (and, inside the expanded editor, docks) over a few frames; focus lands on the field asked for,\n // and is put back while it is lost (never taken from somewhere the person went)\n const timers: number[] = [];\n let landed = false;\n for (const ms of [40, 90, 160, 260, 420, 640]) {\n timers.push(\n window.setTimeout(() => {\n const root = panel.current?.el() ?? null;\n if (!root?.querySelector(\"[data-field-key]\")) return;\n const a = document.activeElement as HTMLElement | null;\n const lost = !a || a === document.body || a.hasAttribute(\"data-expanded-editor\") || a.hasAttribute(\"data-article-block\");\n if (root.contains(a)) return void (landed = true);\n if (!landed || lost) focusField(root, focusKey);\n if (root.contains(document.activeElement)) landed = true;\n }, ms),\n );\n }\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [nonce]); // eslint-disable-line react-hooks/exhaustive-deps\n React.useEffect(() => panel.current?.announce(`${label} properties.`), [label]);\n const header = (\n <>\n <span id={titleId} className=\"min-w-0 flex-1 truncate text-kit-sm font-medium text-kit-fg\">{label}</span>\n <Menu>\n <MenuTrigger\n render={\n <IconButton size=\"sm\" label={`${label} actions`}>\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n <MenuContent align=\"end\" className=\"w-52\">\n {ctx.readOnly || !ctx.duplicate ? null : (\n <>\n <MenuItem icon={<IconCopy stroke={1.5} />} onClick={() => ctx.duplicate?.(el)}>Duplicate</MenuItem>\n <MenuSeparator />\n </>\n )}\n <MenuItem icon={<IconArrowsMove stroke={1.5} />} onClick={() => panel.current?.keyboard(\"move\")}>Move panel</MenuItem>\n <MenuItem icon={<IconDimensions stroke={1.5} />} onClick={() => panel.current?.keyboard(\"resize\")}>Resize panel</MenuItem>\n <MenuItem icon={<IconLayoutSidebar stroke={1.5} />} onClick={() => panel.current?.dock(\"left\")}>Dock left</MenuItem>\n <MenuItem icon={<IconLayoutSidebarRight stroke={1.5} />} onClick={() => panel.current?.dock(\"right\")}>Dock right</MenuItem>\n {ctx.readOnly ? null : (\n <>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => ctx.remove(el)}>Remove</MenuItem>\n </>\n )}\n </MenuContent>\n </Menu>\n <IconButton size=\"sm\" label=\"Close properties\" tooltip=\"Close\" onClick={() => (onClose(), focusBack())}>\n <IconX stroke={1.5} />\n </IconButton>\n </>\n );\n return (\n <FloatingPanel\n ref={panel}\n id=\"article-properties\"\n labelledBy={titleId}\n anchor={anchor}\n container={container}\n header={header}\n onClose={onClose}\n focusBack={focusBack}\n onPanelKeyDown={(e) => {\n if ((e.metaKey || e.ctrlKey) && !e.altKey && eventKey(e) === \"z\" && !e.defaultPrevented) {\n e.preventDefault();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n }\n }}\n sheetFooter={\n <Button size=\"sm\" variant=\"primary\" onClick={() => (onClose(), focusBack())}>\n Done\n </Button>\n }\n >\n <div className=\"pb-3 pt-1\">{children}</div>\n </FloatingPanel>\n );\n}\n\n/* ── The two article block surfaces ────────────────────────────────── */\n/**\n * A panel article block (V2 ArticleBlock surface \"panel\": Gallery, Related posts): the shell's card + chip, its\n * settings in the floating properties panel, one undo step per field edit.\n */\nexport function ArticlePanelBlock<M extends object>({\n label, kind, schema, m, set, el, ctx, autoFocus, openOnInsert = true, toForm, fromForm, children,\n}: {\n label: string;\n kind: string;\n schema: TypeSchema;\n m: M;\n set: (fn: (m: M) => M, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** V2 article-blocks.tsx:127-133: a fresh insert opens the panel, except Related posts, which focuses the card */\n openOnInsert?: boolean;\n toForm: (m: M) => Record<string, unknown>;\n fromForm: (v: Record<string, unknown>, prev: M) => M;\n children: (open: (field?: string | null) => void, ro: boolean) => React.ReactNode;\n}) {\n const card = React.useRef<HTMLDivElement | null>(null);\n const [cardEl, setCardEl] = React.useState<HTMLDivElement | null>(null);\n const ro = !!ctx.readOnly;\n const { open, editing, openPanel, close } = useArticleOpen({ ro, autoFocus: autoFocus && openOnInsert });\n // a stable ref: a new callback each render would pass null for a moment and remount the panel\n const cardRef = React.useCallback((n: HTMLDivElement | null) => {\n card.current = n;\n if (n) setCardEl(n);\n }, []);\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n React.useEffect(() => {\n if (autoFocus && !openOnInsert && !ro) focusCard();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n const modelRef = React.useRef(m);\n modelRef.current = m;\n\n /** a form edit joins the body's one undo history (D54); typing coalesces per field */\n const commit = (v: Record<string, unknown>) => {\n const prev = modelRef.current;\n const before = toForm(prev);\n const field = Object.keys(v).find((k) => JSON.stringify(v[k]) !== JSON.stringify(before[k])) ?? \"\";\n set(() => fromForm(v, prev), `Edit ${label.toLowerCase()} ${field}`);\n };\n\n return (\n <>\n <ArticleCard\n ref={cardRef}\n label={label}\n kind={kind}\n ro={ro}\n editing={editing}\n onOpen={openPanel}\n onKeyDown={articleCardKeyDown({ card, ctx, el, ro, editing, onOpen: openPanel, onClose: close, focusCard })}\n >\n {children(openPanel, ro)}\n <ArticleActions label={label} ctx={ctx} el={el} editing={editing} onEdit={() => (editing ? close() : openPanel())} tooltips />\n </ArticleCard>\n {editing ? (\n <ArticlePanel label={label} anchor={cardEl} nonce={open!.nonce} focusKey={open!.focusKey} onClose={close} focusBack={focusCard} ctx={ctx} el={el}>\n <ArticleForm schema={schema} label={label} value={toForm(m)} onChange={commit} ro={ro} />\n </ArticlePanel>\n ) : null}\n </>\n );\n}\n\n/**\n * A popover article block (V2 ArticleBlock surface \"popover\": TOC, Embed, Author bio): the shell's card + chip, its\n * settings in a popover from the card's top-right corner, one undo step per field edit.\n */\nexport function ArticlePopoverBlock<M extends object>({\n label, kind, schema, m, set, el, ctx, autoFocus, openOnInsert = true, toForm, fromForm, children,\n}: {\n label: string;\n kind: string;\n schema: TypeSchema;\n m: M;\n set: (fn: (m: M) => M, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** V2 article-blocks.tsx:127-133: a fresh insert opens the form, except TOC and Related, which focus the card */\n openOnInsert?: boolean;\n toForm: (m: M) => Record<string, unknown>;\n fromForm: (v: Record<string, unknown>, prev: M) => M;\n /** the preview; `open(field)` opens the popover on that field (the empty state's action) */\n children: (open: (field?: string | null) => void, ro: boolean) => React.ReactNode;\n}) {\n const card = React.useRef<HTMLDivElement | null>(null);\n const form = React.useRef<HTMLDivElement | null>(null);\n const ro = !!ctx.readOnly;\n const { open, editing, openPanel: openPopover, close } = useArticleOpen({ ro, autoFocus: autoFocus && openOnInsert });\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n React.useEffect(() => {\n if (autoFocus && !openOnInsert && !ro) focusCard();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n const modelRef = React.useRef(m);\n modelRef.current = m;\n const nonce = editing ? open!.nonce : 0;\n React.useEffect(() => {\n if (!nonce) return;\n const id = requestAnimationFrame(() => focusField(form.current, currentOpenArticle()?.focusKey ?? null));\n return () => cancelAnimationFrame(id);\n }, [nonce]);\n\n /** a form edit joins the body's one undo history (D54); typing coalesces per field */\n const commit = (v: Record<string, unknown>) => {\n const prev = modelRef.current;\n const before = toForm(prev);\n const field = Object.keys(v).find((k) => JSON.stringify(v[k]) !== JSON.stringify(before[k])) ?? \"\";\n set(() => fromForm(v, prev), `Edit ${label.toLowerCase()} ${field}`);\n };\n\n return (\n <Popover\n open={editing}\n onOpenChange={(o, d) => {\n if (o) return;\n close();\n // V2 onCloseAutoFocus: back on the block, unless the press that closed it went somewhere else\n if (d?.reason !== \"outside-press\") focusCard();\n }}\n >\n <ArticleCard\n ref={card}\n label={label}\n kind={kind}\n ro={ro}\n editing={editing}\n onOpen={openPopover}\n onKeyDown={articleCardKeyDown({ card, ctx, el, ro, editing, onOpen: openPopover, onClose: close, focusCard })}\n >\n {children(openPopover, ro)}\n <ArticleActions label={label} ctx={ctx} el={el} editing={editing} onEdit={() => (editing ? close() : openPopover())} tooltips />\n {/* the popover opens from the block's top-right corner, over the block, wherever the block sits */}\n <PopoverAnchor render={<span aria-hidden className=\"pointer-events-none absolute right-2 top-2 size-px\" />} />\n </ArticleCard>\n {editing ? (\n <PopoverContent\n align=\"end\"\n side=\"bottom\"\n // the anchor is a 1px dot at the card's top-right: no arrow inset, so the popup's edge sits on it (V2 AB:259-300)\n arrowPadding={0}\n className=\"w-[340px] p-0\"\n initialFocus={false}\n finalFocus={false}\n onKeyDown={(e) => {\n if ((e.metaKey || e.ctrlKey) && !e.altKey && eventKey(e) === \"z\" && !e.defaultPrevented) {\n e.preventDefault();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n }\n }}\n >\n <div className=\"flex h-10 items-center gap-2 border-b border-kit-line-subtle pl-4 pr-1.5\">\n <span className=\"flex-1 truncate text-kit-sm font-medium text-kit-fg\">{label}</span>\n <IconButton size=\"sm\" label=\"Close\" onClick={() => (close(), focusCard())}>\n <IconX stroke={1.5} />\n </IconButton>\n </div>\n <div ref={form} className=\"max-h-[min(480px,70vh)] overflow-y-auto pb-2\">\n <ArticleForm schema={schema} label={label} value={toForm(m)} onChange={commit} ro={ro} />\n </div>\n </PopoverContent>\n ) : null}\n </Popover>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAI,cAAkC;AACtC,IAAM,8BAAc,IAAI,IAAgB;AACxC,IAAM,kBAAkB,SAA6B;CACnD,cAAc;CACd,YAAY,SAAS,MAAM,EAAE,CAAC;AAChC;;AAEA,IAAa,2BAA2B;AACxC,SAAgB,iBAAiB;CAC/B,OAAO,MAAM,sBACV,QAAQ,YAAY,IAAI,EAAE,SAAS,KAAK,YAAY,OAAO,EAAE,UACxD,mBACA,WACR;AACF;;;;;AAMA,SAAgB,eAAe,EAAE,IAAI,aAAkD;CACrF,MAAM,MAAM,MAAM,MAAM;CACxB,MAAM,OAAO,eAAe;CAC5B,MAAM,UAAU,MAAM,OA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OAAD;IAAK,KAAK;IAAM,WAAU;IACxB,UAAA,uBAAC,aAAD;KAAqB;KAAe;KAAO,OAAO,OAAO,CAAC;KAAG,UAAU;KAAY;IAAK,GAAA,KAAA,GAAA,OAAA;;;;;GACrF,GAAA,KAAA,GAAA,OAAA;;;;GACS,GAAA,IAAA,CAAA;;;;;EACd,GAAA,IAAA,IAAA,IACG;;;;;;AAEb"}
1
+ {"version":3,"file":"article-shell.js","names":[],"sources":["../../../src/controls/rich-text/article-shell.tsx"],"sourcesContent":["/**\n * RICH TEXT · the article-block shell (V2 article-blocks.tsx ArticleBlock), shared by every article block: the one-open\n * store (one panel or popover open at a time), the card the block draws in (a focusable group: Enter opens it, Escape\n * closes it then leaves, ⌘Z / ⌘⇧Z, ⌘D, ⌥↑/↓, Backspace), the edit / remove chip on its top edge, the empty state, the\n * schema form a panel or popover holds, and the floating properties panel (D54).\n *\n * surface \"panel\" ArticlePanelBlock: ArticleCard + useArticleOpen + ArticlePanel(ArticleForm) (pull quote, gallery,\n * related posts)\n * surface \"popover\" ArticlePopoverBlock: ArticleCard + useArticleOpen + a Popover of ArticleForm (embed, table of\n * contents, author bio)\n * surface \"inline\" ArticleCard without onOpen: the block edits in the text itself (key takeaways)\n */\nimport * as React from \"react\";\nimport { IconArrowsMove, IconCopy, IconDimensions, IconDots, IconLayoutSidebar, IconLayoutSidebarRight, IconSettings, IconTrash, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { Button, IconButton } from \"../../ui/button\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverAnchor, PopoverContent, Tooltip } from \"../../ui/overlay\";\nimport { FloatingPanel, type FloatingPanelHandle } from \"../../ui/floating-panel\";\nimport { SchemaForm } from \"../../engine/schema-form\";\nimport { useKitEnv } from \"../../context\";\nimport type { TypeSchema } from \"../../schema/types\";\nimport type { IslandEl } from \"./dom\";\nimport type { IslandCtx } from \"./blocks\";\n\n/* ── one article panel open at a time (V2 useOpenArticle) ── */\nexport interface OpenArticle {\n id: string;\n /** the field the panel focuses when it opens (a click on the preview's `data-field`), null = the first */\n focusKey: string | null;\n /** bumps on every open, so re-opening the open block refocuses */\n nonce: number;\n}\nlet openArticle: OpenArticle | null = null;\nconst articleSubs = new Set<() => void>();\nconst setOpenArticle = (next: OpenArticle | null) => {\n openArticle = next;\n articleSubs.forEach((f) => f());\n};\n/** The article block open now, if any. */\nexport const currentOpenArticle = () => openArticle;\nexport function useOpenArticle() {\n return React.useSyncExternalStore(\n (cb) => (articleSubs.add(cb), () => void articleSubs.delete(cb)),\n () => openArticle,\n () => openArticle,\n );\n}\n\n/**\n * One block's place in the one-open store: `open(field?)` opens it (closing any other), `close()` closes it if it is\n * the open one. It closes when the block unmounts, and a fresh insert (`autoFocus`) opens its form.\n */\nexport function useArticleOpen({ ro, autoFocus }: { ro: boolean; autoFocus: boolean }) {\n const uid = React.useId();\n const open = useOpenArticle();\n const editing = open?.id === uid;\n const openPanel = React.useCallback((k?: string | null) => {\n if (!ro) setOpenArticle({ id: uid, focusKey: k ?? null, nonce: (openArticle?.nonce ?? 0) + 1 });\n }, [uid, ro]);\n const close = React.useCallback(() => {\n if (openArticle?.id === uid) setOpenArticle(null);\n }, [uid]);\n React.useEffect(() => () => {\n if (openArticle?.id === uid) setOpenArticle(null);\n }, [uid]);\n React.useEffect(() => {\n // a fresh insert opens its form\n if (autoFocus && !ro) openPanel();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n return { open, editing, openPanel, close };\n}\n\nconst controlOf = (el: HTMLElement) =>\n Array.from(el.querySelectorAll<HTMLElement>(\"textarea, input:not([type=hidden]), [contenteditable=true], [role=combobox]\")).find((n) => n.getClientRects().length) ??\n Array.from(el.querySelectorAll<HTMLElement>(\":scope > :not(:first-child) button\")).find((n) => n.getClientRects().length);\n/** Focus the form row `key` names (`data-field-key`), else the first row. */\nexport function focusField(root: HTMLElement | null, key: string | null) {\n if (!root) return;\n const rows = Array.from(root.querySelectorAll<HTMLElement>(\"[data-field-key]\"));\n const row = (key && rows.find((r) => r.getAttribute(\"data-field-key\") === key)) || rows[0];\n if (!row) return;\n row.scrollIntoView({ block: \"nearest\" });\n controlOf(row)?.focus({ preventScroll: true });\n}\n\n/**\n * V2 ArticleBlock onKeyDown, on the card itself (its own fields handle their own keys). With `onOpen` (a panel or\n * popover block) Enter / Space open it and Escape closes it first; without (an inline block) Escape leaves the block.\n */\nexport function articleCardKeyDown({\n card, ctx, el, ro, editing = false, onOpen, onClose, focusCard,\n}: {\n card: React.RefObject<HTMLElement | null>;\n ctx: IslandCtx;\n el: IslandEl;\n ro: boolean;\n editing?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n focusCard: () => void;\n}) {\n return (e: React.KeyboardEvent) => {\n if (e.defaultPrevented || e.target !== card.current) return;\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n if (mod && k === \"z\") {\n e.preventDefault();\n e.stopPropagation();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n return;\n }\n if (onOpen && (e.key === \"Enter\" || e.key === \" \")) {\n e.preventDefault();\n onOpen();\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n if (editing) onClose?.();\n else ctx.exit(el);\n return;\n }\n if (ro) return;\n if (mod && k === \"d\" && ctx.duplicate) {\n e.preventDefault();\n e.stopPropagation();\n ctx.duplicate(el);\n } else if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") && ctx.move) {\n e.preventDefault();\n ctx.move(el, e.key === \"ArrowUp\" ? -1 : 1);\n focusCard();\n } else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n ctx.remove(el);\n }\n };\n}\n\n/** The chip on the block's top edge (so it never covers the block's own text): Edit (with `onEdit`) and Remove. */\nexport function ArticleActions({\n label, ctx, el, editing = false, onEdit, tooltips = false,\n}: {\n label: string;\n ctx: IslandCtx;\n el: IslandEl;\n editing?: boolean;\n /** toggles the block's panel or popover; absent on an inline block */\n onEdit?: () => void;\n /** each button also says what it does in a tooltip */\n tooltips?: boolean;\n}) {\n if (ctx.readOnly) return null;\n const tip = (content: string, button: React.ReactElement) => (tooltips ? <Tooltip content={content}>{button}</Tooltip> : button);\n return (\n <div\n className={cn(\n \"absolute -top-3.5 right-2 z-[2] flex items-center gap-0.5 rounded-kit-md border border-kit-line bg-kit-surface-raised p-0.5 opacity-0 shadow-kit-sm transition-opacity\",\n \"group-hover/art:opacity-100 group-focus-within/art:opacity-100 pointer-coarse:opacity-100\",\n editing && \"opacity-100\",\n )}\n >\n {onEdit\n ? tip(\n `Edit ${label.toLowerCase()}`,\n <IconButton size=\"xs\" label={`Edit ${label.toLowerCase()}`} onClick={onEdit}>\n <IconSettings stroke={1.5} />\n </IconButton>,\n )\n : null}\n {tip(\n `Remove ${label.toLowerCase()}`,\n <IconButton size=\"xs\" label={`Remove ${label.toLowerCase()}`} onClick={() => ctx.remove(el)} className=\"hover:text-kit-danger-fg\">\n <IconTrash stroke={1.5} />\n </IconButton>,\n )}\n </div>\n );\n}\n\n/**\n * The card an article block draws in. With `onOpen` (panel / popover) it is pressable: a click opens it on the field\n * clicked (`data-field`), and it shows the open ring while `editing`. Without, it is the inline block's quiet group.\n */\nexport const ArticleCard = React.forwardRef<\n HTMLDivElement,\n { label: string; kind: string; ro: boolean; editing?: boolean; onOpen?: (field: string | null) => void; onKeyDown: (e: React.KeyboardEvent) => void; children: React.ReactNode }\n>(function ArticleCard({ label, kind, ro, editing = false, onOpen, onKeyDown, children }, ref) {\n if (!onOpen)\n return (\n <div\n ref={ref}\n role=\"group\"\n tabIndex={0}\n aria-label={label}\n aria-roledescription=\"block\"\n data-rt-isolate=\"\"\n data-article-block={kind}\n onKeyDown={onKeyDown}\n className=\"group/art relative rounded-kit-lg outline-none transition-shadow duration-150 focus-visible:shadow-[0_0_0_1px_var(--kit-line-strong)]\"\n >\n {children}\n </div>\n );\n return (\n <div\n ref={ref}\n role=\"group\"\n tabIndex={0}\n aria-label={`${label}${editing ? \", editing\" : \"\"}`}\n aria-roledescription=\"block\"\n aria-haspopup=\"dialog\"\n aria-expanded={editing}\n data-rt-isolate=\"\"\n data-article-block={kind}\n onKeyDown={onKeyDown}\n onClick={(e) => {\n if (ro || !e.currentTarget.contains(e.target as Node)) return;\n const t = e.target as HTMLElement;\n if (t.closest(\"button,a,[role=menuitem]\")) return;\n onOpen(t.closest<HTMLElement>(\"[data-field]\")?.getAttribute(\"data-field\") ?? null);\n }}\n className={cn(\n \"group/art relative rounded-kit-lg outline-none transition-shadow duration-150\",\n !ro && \"cursor-pointer\",\n \"focus-visible:shadow-[0_0_0_1px_var(--kit-line-strong)]\",\n editing ? \"shadow-[0_0_0_2px_var(--kit-accent)] focus-visible:shadow-[0_0_0_2px_var(--kit-accent)]\" : !ro && \"hover:shadow-[0_0_0_1px_var(--kit-line)]\",\n )}\n >\n {children}\n </div>\n );\n});\n\n/** The block's settings, built from its schema (V2 ArticleForm: the kit SchemaForm, flush to the panel's top). */\nexport function ArticleForm({\n schema, label, value, onChange, ro,\n}: {\n schema: TypeSchema;\n label: string;\n value: Record<string, unknown>;\n onChange: (v: Record<string, unknown>) => void;\n ro: boolean;\n}) {\n // a form of its own (its docId keys its expand and full-screen state), but the host's way to open a reference is the\n // outer form's: Open on a picked author or story, and on a picker-made draft's toast\n const { onOpenReference } = useKitEnv();\n return (\n <div data-article-form=\"\" className=\"min-w-0\">\n <SchemaForm schema={schema} value={value} onChange={onChange} variant=\"panel\" scroll={false} readOnly={ro} rootLabel={label} env={{ docId: `article:${schema.name}`, docTitle: label }} onOpenReference={onOpenReference} />\n <style>{`[data-article-form] [data-kit-form] section:first-of-type { border-top-width: 0; margin-top: 0; padding-top: 0; }`}</style>\n </div>\n );\n}\n\n/** V2 article-blocks.tsx Empty: a block with nothing to show yet. */\nexport const ArticleEmpty = ({ icon, title, action, onAction, ro }: { icon: React.ReactNode; title: string; action: string; onAction: () => void; ro: boolean }) => (\n <div className=\"flex items-center gap-3 rounded-kit-lg border border-dashed border-kit-line-strong bg-kit-subtle px-4 py-3.5\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-kit-md border border-kit-line bg-kit-control-bg text-kit-fg-2 [&_svg]:size-4\">{icon}</span>\n <span className=\"min-w-0 flex-1 text-kit-sm font-medium text-kit-fg\">{title}</span>\n {ro ? null : (\n <Button size=\"sm\" onClick={onAction}>\n {action}\n </Button>\n )}\n </div>\n);\n\n/* ── Floating properties panel (D54 primitive; V2 ArticlePanel) ─────────────── */\nexport function ArticlePanel({\n label, anchor, nonce, focusKey, onClose, focusBack, ctx, el, children,\n}: {\n label: string;\n anchor: HTMLElement | null;\n nonce: number;\n focusKey: string | null;\n onClose: () => void;\n focusBack: () => void;\n ctx: IslandCtx;\n el: IslandEl;\n children: React.ReactNode;\n}) {\n const panel = React.useRef<FloatingPanelHandle>(null);\n const titleId = React.useId();\n const container = anchor?.closest<HTMLElement>(\"[data-expanded-editor]\") ?? null;\n React.useEffect(() => {\n // the panel mounts (and, inside the expanded editor, docks) over a few frames; focus lands on the field asked for,\n // and is put back while it is lost (never taken from somewhere the person went)\n const timers: number[] = [];\n let landed = false;\n for (const ms of [40, 90, 160, 260, 420, 640]) {\n timers.push(\n window.setTimeout(() => {\n const root = panel.current?.el() ?? null;\n if (!root?.querySelector(\"[data-field-key]\")) return;\n const a = document.activeElement as HTMLElement | null;\n const lost = !a || a === document.body || a.hasAttribute(\"data-expanded-editor\") || a.hasAttribute(\"data-article-block\");\n if (root.contains(a)) return void (landed = true);\n if (!landed || lost) focusField(root, focusKey);\n if (root.contains(document.activeElement)) landed = true;\n }, ms),\n );\n }\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [nonce]); // eslint-disable-line react-hooks/exhaustive-deps\n React.useEffect(() => panel.current?.announce(`${label} properties.`), [label]);\n const header = (\n <>\n <span id={titleId} className=\"min-w-0 flex-1 truncate text-kit-sm font-medium text-kit-fg\">{label}</span>\n <Menu>\n <MenuTrigger\n render={\n <IconButton size=\"sm\" label={`${label} actions`}>\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n <MenuContent align=\"end\" className=\"w-52\">\n {ctx.readOnly || !ctx.duplicate ? null : (\n <>\n <MenuItem icon={<IconCopy stroke={1.5} />} onClick={() => ctx.duplicate?.(el)}>Duplicate</MenuItem>\n <MenuSeparator />\n </>\n )}\n <MenuItem icon={<IconArrowsMove stroke={1.5} />} onClick={() => panel.current?.keyboard(\"move\")}>Move panel</MenuItem>\n <MenuItem icon={<IconDimensions stroke={1.5} />} onClick={() => panel.current?.keyboard(\"resize\")}>Resize panel</MenuItem>\n <MenuItem icon={<IconLayoutSidebar stroke={1.5} />} onClick={() => panel.current?.dock(\"left\")}>Dock left</MenuItem>\n <MenuItem icon={<IconLayoutSidebarRight stroke={1.5} />} onClick={() => panel.current?.dock(\"right\")}>Dock right</MenuItem>\n {ctx.readOnly ? null : (\n <>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => ctx.remove(el)}>Remove</MenuItem>\n </>\n )}\n </MenuContent>\n </Menu>\n <IconButton size=\"sm\" label=\"Close properties\" tooltip=\"Close\" onClick={() => (onClose(), focusBack())}>\n <IconX stroke={1.5} />\n </IconButton>\n </>\n );\n return (\n <FloatingPanel\n ref={panel}\n id=\"article-properties\"\n labelledBy={titleId}\n anchor={anchor}\n container={container}\n header={header}\n onClose={onClose}\n focusBack={focusBack}\n onPanelKeyDown={(e) => {\n if ((e.metaKey || e.ctrlKey) && !e.altKey && eventKey(e) === \"z\" && !e.defaultPrevented) {\n e.preventDefault();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n }\n }}\n sheetFooter={\n <Button size=\"sm\" variant=\"primary\" onClick={() => (onClose(), focusBack())}>\n Done\n </Button>\n }\n >\n <div className=\"pb-3 pt-1\">{children}</div>\n </FloatingPanel>\n );\n}\n\n/* ── The two article block surfaces ────────────────────────────────── */\n/**\n * A panel article block (V2 ArticleBlock surface \"panel\": Gallery, Related posts): the shell's card + chip, its\n * settings in the floating properties panel, one undo step per field edit.\n */\nexport function ArticlePanelBlock<M extends object>({\n label, kind, schema, m, set, el, ctx, autoFocus, openOnInsert = true, toForm, fromForm, children,\n}: {\n label: string;\n kind: string;\n schema: TypeSchema;\n m: M;\n set: (fn: (m: M) => M, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** V2 article-blocks.tsx:127-133: a fresh insert opens the panel, except Related posts, which focuses the card */\n openOnInsert?: boolean;\n toForm: (m: M) => Record<string, unknown>;\n fromForm: (v: Record<string, unknown>, prev: M) => M;\n children: (open: (field?: string | null) => void, ro: boolean) => React.ReactNode;\n}) {\n const card = React.useRef<HTMLDivElement | null>(null);\n const [cardEl, setCardEl] = React.useState<HTMLDivElement | null>(null);\n const ro = !!ctx.readOnly;\n const { open, editing, openPanel, close } = useArticleOpen({ ro, autoFocus: autoFocus && openOnInsert });\n // a stable ref: a new callback each render would pass null for a moment and remount the panel\n const cardRef = React.useCallback((n: HTMLDivElement | null) => {\n card.current = n;\n if (n) setCardEl(n);\n }, []);\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n React.useEffect(() => {\n if (autoFocus && !openOnInsert && !ro) focusCard();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n const modelRef = React.useRef(m);\n modelRef.current = m;\n\n /** a form edit joins the body's one undo history (D54); typing coalesces per field */\n const commit = (v: Record<string, unknown>) => {\n const prev = modelRef.current;\n const before = toForm(prev);\n const field = Object.keys(v).find((k) => JSON.stringify(v[k]) !== JSON.stringify(before[k])) ?? \"\";\n set(() => fromForm(v, prev), `Edit ${label.toLowerCase()} ${field}`);\n };\n\n return (\n <>\n <ArticleCard\n ref={cardRef}\n label={label}\n kind={kind}\n ro={ro}\n editing={editing}\n onOpen={openPanel}\n onKeyDown={articleCardKeyDown({ card, ctx, el, ro, editing, onOpen: openPanel, onClose: close, focusCard })}\n >\n {children(openPanel, ro)}\n <ArticleActions label={label} ctx={ctx} el={el} editing={editing} onEdit={() => (editing ? close() : openPanel())} tooltips />\n </ArticleCard>\n {editing ? (\n <ArticlePanel label={label} anchor={cardEl} nonce={open!.nonce} focusKey={open!.focusKey} onClose={close} focusBack={focusCard} ctx={ctx} el={el}>\n <ArticleForm schema={schema} label={label} value={toForm(m)} onChange={commit} ro={ro} />\n </ArticlePanel>\n ) : null}\n </>\n );\n}\n\n/**\n * A popover article block (V2 ArticleBlock surface \"popover\": TOC, Embed, Author bio): the shell's card + chip, its\n * settings in a popover from the card's top-right corner, one undo step per field edit.\n */\nexport function ArticlePopoverBlock<M extends object>({\n label, kind, schema, m, set, el, ctx, autoFocus, openOnInsert = true, toForm, fromForm, children,\n}: {\n label: string;\n kind: string;\n schema: TypeSchema;\n m: M;\n set: (fn: (m: M) => M, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** V2 article-blocks.tsx:127-133: a fresh insert opens the form, except TOC and Related, which focus the card */\n openOnInsert?: boolean;\n toForm: (m: M) => Record<string, unknown>;\n fromForm: (v: Record<string, unknown>, prev: M) => M;\n /** the preview; `open(field)` opens the popover on that field (the empty state's action) */\n children: (open: (field?: string | null) => void, ro: boolean) => React.ReactNode;\n}) {\n const card = React.useRef<HTMLDivElement | null>(null);\n const form = React.useRef<HTMLDivElement | null>(null);\n const ro = !!ctx.readOnly;\n const { open, editing, openPanel: openPopover, close } = useArticleOpen({ ro, autoFocus: autoFocus && openOnInsert });\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n React.useEffect(() => {\n if (autoFocus && !openOnInsert && !ro) focusCard();\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n const modelRef = React.useRef(m);\n modelRef.current = m;\n const nonce = editing ? open!.nonce : 0;\n React.useEffect(() => {\n if (!nonce) return;\n const id = requestAnimationFrame(() => focusField(form.current, currentOpenArticle()?.focusKey ?? null));\n return () => cancelAnimationFrame(id);\n }, [nonce]);\n\n /** a form edit joins the body's one undo history (D54); typing coalesces per field */\n const commit = (v: Record<string, unknown>) => {\n const prev = modelRef.current;\n const before = toForm(prev);\n const field = Object.keys(v).find((k) => JSON.stringify(v[k]) !== JSON.stringify(before[k])) ?? \"\";\n set(() => fromForm(v, prev), `Edit ${label.toLowerCase()} ${field}`);\n };\n\n return (\n <Popover\n open={editing}\n onOpenChange={(o, d) => {\n if (o) return;\n close();\n // V2 onCloseAutoFocus: back on the block, unless the press that closed it went somewhere else\n if (d?.reason !== \"outside-press\") focusCard();\n }}\n >\n <ArticleCard\n ref={card}\n label={label}\n kind={kind}\n ro={ro}\n editing={editing}\n onOpen={openPopover}\n onKeyDown={articleCardKeyDown({ card, ctx, el, ro, editing, onOpen: openPopover, onClose: close, focusCard })}\n >\n {children(openPopover, ro)}\n <ArticleActions label={label} ctx={ctx} el={el} editing={editing} onEdit={() => (editing ? close() : openPopover())} tooltips />\n {/* the popover opens from the block's top-right corner, over the block, wherever the block sits */}\n <PopoverAnchor render={<span aria-hidden className=\"pointer-events-none absolute right-2 top-2 size-px\" />} />\n </ArticleCard>\n {editing ? (\n <PopoverContent\n align=\"end\"\n side=\"bottom\"\n // the anchor is a 1px dot at the card's top-right: no arrow inset, so the popup's edge sits on it (V2 AB:259-300)\n arrowPadding={0}\n className=\"w-[340px] p-0\"\n initialFocus={false}\n finalFocus={false}\n onKeyDown={(e) => {\n if ((e.metaKey || e.ctrlKey) && !e.altKey && eventKey(e) === \"z\" && !e.defaultPrevented) {\n e.preventDefault();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n }\n }}\n >\n <div className=\"flex h-10 items-center gap-2 border-b border-kit-line-subtle pl-4 pr-1.5\">\n <span className=\"flex-1 truncate text-kit-sm font-medium text-kit-fg\">{label}</span>\n <IconButton size=\"sm\" label=\"Close\" onClick={() => (close(), focusCard())}>\n <IconX stroke={1.5} />\n </IconButton>\n </div>\n <div ref={form} className=\"max-h-[min(480px,70vh)] overflow-y-auto pb-2\">\n <ArticleForm schema={schema} label={label} value={toForm(m)} onChange={commit} ro={ro} />\n </div>\n </PopoverContent>\n ) : null}\n </Popover>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAI,cAAkC;AACtC,IAAM,8BAAc,IAAI,IAAgB;AACxC,IAAM,kBAAkB,SAA6B;CACnD,cAAc;CACd,YAAY,SAAS,MAAM,EAAE,CAAC;AAChC;;AAEA,IAAa,2BAA2B;AACxC,SAAgB,iBAAiB;CAC/B,OAAO,MAAM,sBACV,QAAQ,YAAY,IAAI,EAAE,SAAS,KAAK,YAAY,OAAO,EAAE,UACxD,mBACA,WACR;AACF;;;;;AAMA,SAAgB,eAAe,EAAE,IAAI,aAAkD;CACrF,MAAM,MAAM,MAAM,MAAM;CACxB,MAAM,OAAO,eAAe;CAC5B,MAAM,UAAU,MAAM,OAAO;CAC7B,MAAM,YAAY,MAAM,aAAa,MAAsB;EACzD,IAAI,CAAC,IAAI,eAAe;GAAE,IAAI;GAAK,UAAU,KAAK;GAAM,QAAQ,aAAa,SAAS,KAAK;EAAE,CAAC;CAChG,GAAG,CAAC,KAAK,EAAE,CAAC;CACZ,MAAM,QAAQ,MAAM,kBAAkB;EACpC,IAAI,aAAa,OAAO,KAAK,eAAe,IAAI;CAClD,GAAG,CAAC,GAAG,CAAC;CACR,MAAM,sBAAsB;EAC1B,IAAI,aAAa,OAAO,KAAK,eAAe,IAAI;CAClD,GAAG,CAAC,GAAG,CAAC;CACR,MAAM,gBAAgB;EAEpB,IAAI,aAAa,CAAC,IAAI,UAAU;CAClC,GAAG,CAAC,CAAC;CACL,OAAO;EAAE;EAAM;EAAS;EAAW;CAAM;AAC3C;AAEA,IAAM,aAAa,OACjB,MAAM,KAAK,GAAG,iBAA8B,6EAA6E,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,eAAe,CAAC,CAAC,MAAM,KACjK,MAAM,KAAK,G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BAAkB;KACvF,EAAE,eAAe;KACjB,IAAI,EAAE,UAAU,IAAI,OAAO;UACtB,IAAI,OAAO;IAClB;GACF;GAdF,UAAA,CAgBE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAuD,UAAA;IAAY,CAAA,GACnF,oBAAC,YAAD;KAAY,MAAK;KAAK,OAAM;KAAQ,gBAAgB,MAAM,GAAG,UAAU;KACrE,UAAA,oBAAC,OAAD,EAAO,QAAQ,IAAM,CAAA;IACX,CAAA,CACT;GACL,CAAA,GAAA,oBAAC,OAAD;IAAK,KAAK;IAAM,WAAU;IACxB,UAAA,oBAAC,aAAD;KAAqB;KAAe;KAAO,OAAO,OAAO,CAAC;KAAG,UAAU;KAAY;IAAK,CAAA;GACrF,CAAA,CACS;EACd,CAAA,IAAA,IACG;;AAEb"}
@@ -1,7 +1,7 @@
1
1
  import { useRichTextRefs } from "../../context.js";
2
2
  import { ArticleEmpty, ArticlePopoverBlock } from "./article-shell.js";
3
3
  import * as React from "react";
4
- import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { IconUserCircle } from "@tabler/icons-react";
6
6
  //#region src/controls/rich-text/author.tsx
7
7
  /**
@@ -14,7 +14,6 @@ import { IconUserCircle } from "@tabler/icons-react";
14
14
  * data KitServices.resolveRichTextRefs through useRichTextRefs. V2 read a local store synchronously; the kit asks
15
15
  * the host, so a resolving card keeps the card's shape (no "Choose an author" flash) and a failure is named.
16
16
  */
17
- var _jsxFileName = "D:/Github/bettercms/bettercms-backend/packages/kit/src/controls/rich-text/author.tsx";
18
17
  var AUTHOR_LABEL = "Author bio";
19
18
  var authorDefault = () => ({ author: "" });
20
19
  /** The popover form; `to` is the authors collection from the field's config. */
@@ -40,99 +39,51 @@ function AuthorPreview({ m, onPick, ro }) {
40
39
  ids: [m.author]
41
40
  } : null);
42
41
  const a = items.find((x) => x.id === m.author);
43
- if (!m.author || !loading && !error && !a) return /* @__PURE__ */ jsxDEV(ArticleEmpty, {
44
- icon: /* @__PURE__ */ jsxDEV(IconUserCircle, { stroke: 1.5 }, void 0, false, {
45
- fileName: _jsxFileName,
46
- lineNumber: 40,
47
- columnNumber: 32
48
- }, this),
42
+ if (!m.author || !loading && !error && !a) return /* @__PURE__ */ jsx(ArticleEmpty, {
43
+ icon: /* @__PURE__ */ jsx(IconUserCircle, { stroke: 1.5 }),
49
44
  title: AUTHOR_LABEL,
50
45
  action: "Choose an author",
51
46
  onAction: onPick,
52
47
  ro
53
- }, void 0, false, {
54
- fileName: _jsxFileName,
55
- lineNumber: 40,
56
- columnNumber: 12
57
- }, this);
58
- return /* @__PURE__ */ jsxDEV("aside", {
48
+ });
49
+ return /* @__PURE__ */ jsxs("aside", {
59
50
  className: "flex items-start gap-3.5 rounded-kit-lg border border-kit-line bg-kit-surface px-4 py-3.5",
60
51
  "aria-label": a ? `About ${a.title}` : AUTHOR_LABEL,
61
52
  "aria-busy": loading || void 0,
62
53
  "data-field": "author",
63
- children: [a?.avatar ? /* @__PURE__ */ jsxDEV("img", {
54
+ children: [a?.avatar ? /* @__PURE__ */ jsx("img", {
64
55
  src: a.avatar,
65
56
  alt: "",
66
57
  draggable: false,
67
58
  className: "size-12 shrink-0 rounded-full border border-kit-line object-cover"
68
- }, void 0, false, {
69
- fileName: _jsxFileName,
70
- lineNumber: 49,
71
- columnNumber: 9
72
- }, this) : /* @__PURE__ */ jsxDEV("span", {
59
+ }) : /* @__PURE__ */ jsx("span", {
73
60
  className: "flex size-12 shrink-0 items-center justify-center rounded-full bg-kit-muted text-kit-fg-3",
74
- children: /* @__PURE__ */ jsxDEV(IconUserCircle, {
61
+ children: /* @__PURE__ */ jsx(IconUserCircle, {
75
62
  className: "size-6",
76
63
  stroke: 1.5
77
- }, void 0, false, {
78
- fileName: _jsxFileName,
79
- lineNumber: 52,
80
- columnNumber: 11
81
- }, this)
82
- }, void 0, false, {
83
- fileName: _jsxFileName,
84
- lineNumber: 51,
85
- columnNumber: 9
86
- }, this), /* @__PURE__ */ jsxDEV("div", {
64
+ })
65
+ }), /* @__PURE__ */ jsx("div", {
87
66
  className: "min-w-0 flex-1",
88
- children: a ? /* @__PURE__ */ jsxDEV(Fragment, { children: [/* @__PURE__ */ jsxDEV("p", {
67
+ children: a ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
89
68
  className: "text-kit-sm font-semibold text-kit-fg",
90
69
  children: a.title
91
- }, void 0, false, {
92
- fileName: _jsxFileName,
93
- lineNumber: 58,
94
- columnNumber: 13
95
- }, this), a.bio ? /* @__PURE__ */ jsxDEV("p", {
70
+ }), a.bio ? /* @__PURE__ */ jsx("p", {
96
71
  className: "mt-0.5 text-kit-sm leading-relaxed text-kit-fg-2",
97
72
  children: a.bio
98
- }, void 0, false, {
99
- fileName: _jsxFileName,
100
- lineNumber: 59,
101
- columnNumber: 22
102
- }, this) : null] }, void 0, true, {
103
- fileName: _jsxFileName,
104
- lineNumber: 57,
105
- columnNumber: 11
106
- }, this) : error ? /* @__PURE__ */ jsxDEV("p", {
73
+ }) : null] }) : error ? /* @__PURE__ */ jsxs("p", {
107
74
  role: "status",
108
75
  className: "text-kit-sm text-kit-warning-fg",
109
76
  children: ["The author couldn't load: ", error]
110
- }, void 0, true, {
111
- fileName: _jsxFileName,
112
- lineNumber: 62,
113
- columnNumber: 11
114
- }, this) : /* @__PURE__ */ jsxDEV("p", {
77
+ }) : /* @__PURE__ */ jsx("p", {
115
78
  className: "text-kit-sm text-kit-fg-3",
116
79
  children: "Loading the author…"
117
- }, void 0, false, {
118
- fileName: _jsxFileName,
119
- lineNumber: 66,
120
- columnNumber: 11
121
- }, this)
122
- }, void 0, false, {
123
- fileName: _jsxFileName,
124
- lineNumber: 55,
125
- columnNumber: 7
126
- }, this)]
127
- }, void 0, true, {
128
- fileName: _jsxFileName,
129
- lineNumber: 42,
130
- columnNumber: 5
131
- }, this);
80
+ })
81
+ })]
82
+ });
132
83
  }
133
84
  function AuthorBlock({ m, set, el, ctx, autoFocus, collection }) {
134
85
  const schema = React.useMemo(() => authorSchema([collection]), [collection]);
135
- return /* @__PURE__ */ jsxDEV(ArticlePopoverBlock, {
86
+ return /* @__PURE__ */ jsx(ArticlePopoverBlock, {
136
87
  label: AUTHOR_LABEL,
137
88
  kind: "author",
138
89
  schema,
@@ -143,20 +94,12 @@ function AuthorBlock({ m, set, el, ctx, autoFocus, collection }) {
143
94
  autoFocus,
144
95
  toForm: (x) => ({ author: x.author || void 0 }),
145
96
  fromForm: (v) => ({ author: typeof v.author === "string" ? v.author : "" }),
146
- children: (open, ro) => /* @__PURE__ */ jsxDEV(AuthorPreview, {
97
+ children: (open, ro) => /* @__PURE__ */ jsx(AuthorPreview, {
147
98
  m,
148
99
  onPick: () => open("author"),
149
100
  ro
150
- }, void 0, false, {
151
- fileName: _jsxFileName,
152
- lineNumber: 98,
153
- columnNumber: 22
154
- }, this)
155
- }, void 0, false, {
156
- fileName: _jsxFileName,
157
- lineNumber: 86,
158
- columnNumber: 5
159
- }, this);
101
+ })
102
+ });
160
103
  }
161
104
  //#endregion
162
105
  export { AUTHOR_LABEL, AuthorBlock, AuthorPreview, authorDefault, authorSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"author.js","names":[],"sources":["../../../src/controls/rich-text/author.tsx"],"sourcesContent":["/**\n * RICH TEXT · Author bio (kit-richtext-ui-spec.md §7): V2's article block, stored as the PT block object\n * `{ _type: \"authorBio\", author: { _ref } }`. Name, avatar and bio are derived from the referenced entry, never stored.\n *\n * form V2 article.ts:196-202: one required reference, \"Author\"; its collection comes from the field's config\n * (V2 hard-codes col_authors). One setting → the shell's popover (D54); a fresh insert opens it.\n * preview V2 article-blocks.tsx:599-612: avatar, name and bio as the reader sees them; \"Choose an author\" when none\n * data KitServices.resolveRichTextRefs through useRichTextRefs. V2 read a local store synchronously; the kit asks\n * the host, so a resolving card keeps the card's shape (no \"Choose an author\" flash) and a failure is named.\n */\nimport * as React from \"react\";\nimport { IconUserCircle } from \"@tabler/icons-react\";\nimport { useRichTextRefs } from \"../../context\";\nimport type { TypeSchema } from \"../../schema/types\";\nimport { ArticleEmpty, ArticlePopoverBlock } from \"./article-shell\";\nimport type { IslandCtx } from \"./blocks\";\nimport type { IslandEl } from \"./dom\";\n\n/** The editor's model: the referenced entry's id (\"\" = none picked). The PT form wraps it as `{ _ref }`. */\nexport interface AuthorModel {\n author: string;\n}\nexport const AUTHOR_LABEL = \"Author bio\";\nexport const authorDefault = (): AuthorModel => ({ author: \"\" });\n\n/** The popover form; `to` is the authors collection from the field's config. */\nexport const authorSchema = (to: string[]): TypeSchema => ({\n name: \"authorBio\",\n title: AUTHOR_LABEL,\n kind: \"object\",\n icon: \"user\",\n // V2 ART:196-202 names the picker's record an author: \"Select an author\", \"Create new author\"\n fields: [{ name: \"author\", title: \"Author\", type: \"reference\", reference: { to, noun: \"author\" }, validation: { required: true } }],\n});\n\nexport function AuthorPreview({ m, onPick, ro }: { m: AuthorModel; onPick: () => void; ro: boolean }) {\n const { items, loading, error } = useRichTextRefs(m.author ? { kind: \"authorBio\", ids: [m.author] } : null);\n const a = items.find((x) => x.id === m.author);\n if (!m.author || (!loading && !error && !a))\n return <ArticleEmpty icon={<IconUserCircle stroke={1.5} />} title={AUTHOR_LABEL} action=\"Choose an author\" onAction={onPick} ro={ro} />;\n return (\n <aside\n className=\"flex items-start gap-3.5 rounded-kit-lg border border-kit-line bg-kit-surface px-4 py-3.5\"\n aria-label={a ? `About ${a.title}` : AUTHOR_LABEL}\n aria-busy={loading || undefined}\n data-field=\"author\"\n >\n {a?.avatar ? (\n <img src={a.avatar} alt=\"\" draggable={false} className=\"size-12 shrink-0 rounded-full border border-kit-line object-cover\" />\n ) : (\n <span className=\"flex size-12 shrink-0 items-center justify-center rounded-full bg-kit-muted text-kit-fg-3\">\n <IconUserCircle className=\"size-6\" stroke={1.5} />\n </span>\n )}\n <div className=\"min-w-0 flex-1\">\n {a ? (\n <>\n <p className=\"text-kit-sm font-semibold text-kit-fg\">{a.title}</p>\n {a.bio ? <p className=\"mt-0.5 text-kit-sm leading-relaxed text-kit-fg-2\">{a.bio}</p> : null}\n </>\n ) : error ? (\n <p role=\"status\" className=\"text-kit-sm text-kit-warning-fg\">\n The author couldn't load: {error}\n </p>\n ) : (\n <p className=\"text-kit-sm text-kit-fg-3\">Loading the author…</p>\n )}\n </div>\n </aside>\n );\n}\n\nexport function AuthorBlock({\n m, set, el, ctx, autoFocus, collection,\n}: {\n m: AuthorModel;\n set: (fn: (m: AuthorModel) => AuthorModel, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** the authors collection the reference picks from (the field's config) */\n collection: string;\n}) {\n const schema = React.useMemo(() => authorSchema([collection]), [collection]);\n return (\n <ArticlePopoverBlock<AuthorModel>\n label={AUTHOR_LABEL}\n kind=\"author\"\n schema={schema}\n m={m}\n set={set}\n el={el}\n ctx={ctx}\n autoFocus={autoFocus}\n toForm={(x) => ({ author: x.author || undefined })}\n fromForm={(v) => ({ author: typeof v.author === \"string\" ? v.author : \"\" })}\n >\n {(open, ro) => <AuthorPreview m={m} onPick={() => open(\"author\")} ro={ro} />}\n </ArticlePopoverBlock>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAa,eAAe;AAC5B,IAAa,uBAAoC,EAAE,QAAQ,GAAG;;AAG9D,IAAa,gBAAgB,QAA8B;CACzD,MAAM;CACN,OAAO;CACP,MAAM;CACN,MAAM;CAEN,QAAQ,CAAC;EAAE,MAAM;EAAU,OAAO;EAAU,MAAM;EAAa,WAAW;GAAE;GAAI,MAAM;EAAS;EAAG,YAAY,EAAE,UAAU,KAAK;CAAE,CAAC;AACpI;AAEA,SAAgB,cAAc,EAAE,GAAG,QAAQ,MAA2D;CACpG,MAAM,EAAE,OAAO,SAAS,UAAU,gBAAgB,EAAE,SAAS;EAAE,MAAM;EAAa,KAAK,CAAC,EAAE,MAA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WAAU;IAA4B,UAAA;GAAsB,GAAA,KAAA,GAAA,OAAA;;;;;EAE9D,GAAA,KAAA,GAAA,OAAA;;;;EACA,GAAA,IAAA,CAAA;;;;;;AAEX;AAEA,SAAgB,YAAY,EAC1B,GAAG,KAAK,IAAI,KAAK,WAAW,cAS3B;CACD,MAAM,SAAS,MAAM,cAAc,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC;CAC3E,OACE,uBAAC,qBAAD;EACE,OAAO;EACP,MAAK;EACG;EACL;EACE;EACD;EACC;EACM;EACX,SAAS,OAAO,EAAE,QAAQ,EAAE,UAAU,KAAA,EAAU;EAChD,WAAW,OAAO,EAAE,QAAQ,OAAO,EAAE,WAAW,WAAW,EAAE,SAAS,GAAG;EAEvE,WAAA,MAAM,OAAO,uBAAC,eAAD;GAAkB;GAAG,cAAc,KAAK,QAAQ;GAAO;EAAK,GAAA,KAAA,GAAA,OAAA;;;;;CACxD,GAAA,KAAA,GAAA,OAAA;;;;;AAEzB"}
1
+ {"version":3,"file":"author.js","names":[],"sources":["../../../src/controls/rich-text/author.tsx"],"sourcesContent":["/**\n * RICH TEXT · Author bio (kit-richtext-ui-spec.md §7): V2's article block, stored as the PT block object\n * `{ _type: \"authorBio\", author: { _ref } }`. Name, avatar and bio are derived from the referenced entry, never stored.\n *\n * form V2 article.ts:196-202: one required reference, \"Author\"; its collection comes from the field's config\n * (V2 hard-codes col_authors). One setting → the shell's popover (D54); a fresh insert opens it.\n * preview V2 article-blocks.tsx:599-612: avatar, name and bio as the reader sees them; \"Choose an author\" when none\n * data KitServices.resolveRichTextRefs through useRichTextRefs. V2 read a local store synchronously; the kit asks\n * the host, so a resolving card keeps the card's shape (no \"Choose an author\" flash) and a failure is named.\n */\nimport * as React from \"react\";\nimport { IconUserCircle } from \"@tabler/icons-react\";\nimport { useRichTextRefs } from \"../../context\";\nimport type { TypeSchema } from \"../../schema/types\";\nimport { ArticleEmpty, ArticlePopoverBlock } from \"./article-shell\";\nimport type { IslandCtx } from \"./blocks\";\nimport type { IslandEl } from \"./dom\";\n\n/** The editor's model: the referenced entry's id (\"\" = none picked). The PT form wraps it as `{ _ref }`. */\nexport interface AuthorModel {\n author: string;\n}\nexport const AUTHOR_LABEL = \"Author bio\";\nexport const authorDefault = (): AuthorModel => ({ author: \"\" });\n\n/** The popover form; `to` is the authors collection from the field's config. */\nexport const authorSchema = (to: string[]): TypeSchema => ({\n name: \"authorBio\",\n title: AUTHOR_LABEL,\n kind: \"object\",\n icon: \"user\",\n // V2 ART:196-202 names the picker's record an author: \"Select an author\", \"Create new author\"\n fields: [{ name: \"author\", title: \"Author\", type: \"reference\", reference: { to, noun: \"author\" }, validation: { required: true } }],\n});\n\nexport function AuthorPreview({ m, onPick, ro }: { m: AuthorModel; onPick: () => void; ro: boolean }) {\n const { items, loading, error } = useRichTextRefs(m.author ? { kind: \"authorBio\", ids: [m.author] } : null);\n const a = items.find((x) => x.id === m.author);\n if (!m.author || (!loading && !error && !a))\n return <ArticleEmpty icon={<IconUserCircle stroke={1.5} />} title={AUTHOR_LABEL} action=\"Choose an author\" onAction={onPick} ro={ro} />;\n return (\n <aside\n className=\"flex items-start gap-3.5 rounded-kit-lg border border-kit-line bg-kit-surface px-4 py-3.5\"\n aria-label={a ? `About ${a.title}` : AUTHOR_LABEL}\n aria-busy={loading || undefined}\n data-field=\"author\"\n >\n {a?.avatar ? (\n <img src={a.avatar} alt=\"\" draggable={false} className=\"size-12 shrink-0 rounded-full border border-kit-line object-cover\" />\n ) : (\n <span className=\"flex size-12 shrink-0 items-center justify-center rounded-full bg-kit-muted text-kit-fg-3\">\n <IconUserCircle className=\"size-6\" stroke={1.5} />\n </span>\n )}\n <div className=\"min-w-0 flex-1\">\n {a ? (\n <>\n <p className=\"text-kit-sm font-semibold text-kit-fg\">{a.title}</p>\n {a.bio ? <p className=\"mt-0.5 text-kit-sm leading-relaxed text-kit-fg-2\">{a.bio}</p> : null}\n </>\n ) : error ? (\n <p role=\"status\" className=\"text-kit-sm text-kit-warning-fg\">\n The author couldn't load: {error}\n </p>\n ) : (\n <p className=\"text-kit-sm text-kit-fg-3\">Loading the author…</p>\n )}\n </div>\n </aside>\n );\n}\n\nexport function AuthorBlock({\n m, set, el, ctx, autoFocus, collection,\n}: {\n m: AuthorModel;\n set: (fn: (m: AuthorModel) => AuthorModel, label?: string) => void;\n el: IslandEl;\n ctx: IslandCtx;\n autoFocus: boolean;\n /** the authors collection the reference picks from (the field's config) */\n collection: string;\n}) {\n const schema = React.useMemo(() => authorSchema([collection]), [collection]);\n return (\n <ArticlePopoverBlock<AuthorModel>\n label={AUTHOR_LABEL}\n kind=\"author\"\n schema={schema}\n m={m}\n set={set}\n el={el}\n ctx={ctx}\n autoFocus={autoFocus}\n toForm={(x) => ({ author: x.author || undefined })}\n fromForm={(v) => ({ author: typeof v.author === \"string\" ? v.author : \"\" })}\n >\n {(open, ro) => <AuthorPreview m={m} onPick={() => open(\"author\")} ro={ro} />}\n </ArticlePopoverBlock>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAa,eAAe;AAC5B,IAAa,uBAAoC,EAAE,QAAQ,GAAG;;AAG9D,IAAa,gBAAgB,QAA8B;CACzD,MAAM;CACN,OAAO;CACP,MAAM;CACN,MAAM;CAEN,QAAQ,CAAC;EAAE,MAAM;EAAU,OAAO;EAAU,MAAM;EAAa,WAAW;GAAE;GAAI,MAAM;EAAS;EAAG,YAAY,EAAE,UAAU,KAAK;CAAE,CAAC;AACpI;AAEA,SAAgB,cAAc,EAAE,GAAG,QAAQ,MAA2D;CACpG,MAAM,EAAE,OAAO,SAAS,UAAU,gBAAgB,EAAE,SAAS;EAAE,MAAM;EAAa,KAAK,CAAC,EAAE,MAAM;CAAE,IAAI,IAAI;CAC1G,MAAM,IAAI,MAAM,MAAM,MAAM,EAAE,OAAO,EAAE,MAAM;CAC7C,IAAI,CAAC,EAAE,UAAW,CAAC,WAAW,CAAC,SAAS,CAAC,GACvC,OAAO,oBAAC,c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