@bettercms-ai/kit 3.1.6 → 3.1.7

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.
@@ -252,6 +252,7 @@ function ButtonScreen({ value, onChange, readOnly, title = "Button" }) {
252
252
  const set = (p) => onChange(nextButton(value, p));
253
253
  const [iconOpen, setIconOpen] = React.useState(false);
254
254
  const labelId = React.useId();
255
+ const noLabel = !readOnly && !(v.label ?? "").trim();
255
256
  const arrowId = React.useId();
256
257
  const fullId = React.useId();
257
258
  return /* @__PURE__ */ jsxs("fieldset", {
@@ -263,15 +264,21 @@ function ButtonScreen({ value, onChange, readOnly, title = "Button" }) {
263
264
  className: "flex min-h-20 items-center justify-center rounded-kit-lg bg-kit-preview-paper px-4 py-5 [filter:var(--kit-paper-filter)]",
264
265
  children: /* @__PURE__ */ jsx(ButtonPreview, { v })
265
266
  }),
266
- /* @__PURE__ */ jsx(Row, {
267
+ /* @__PURE__ */ jsxs(Row, {
267
268
  label: "Label",
268
269
  htmlFor: labelId,
269
- children: /* @__PURE__ */ jsx(Input, {
270
+ children: [/* @__PURE__ */ jsx(Input, {
270
271
  id: labelId,
271
272
  value: v.label ?? "",
272
273
  onChange: (e) => set({ label: e.target.value }),
273
- placeholder: "Shop now"
274
- })
274
+ placeholder: "Shop now",
275
+ "aria-invalid": noLabel || void 0,
276
+ "aria-describedby": noLabel ? `${labelId}-msg` : void 0
277
+ }), noLabel ? /* @__PURE__ */ jsx("p", {
278
+ id: `${labelId}-msg`,
279
+ className: "text-kit-xs text-kit-danger-fg",
280
+ children: "Add a label. Without one the button shows no text on the page."
281
+ }) : null]
275
282
  }),
276
283
  /* @__PURE__ */ jsxs("div", {
277
284
  className: "flex flex-col gap-1.5",
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":[],"sources":["../../src/controls/button.tsx"],"sourcesContent":["/**\n * BUTTON — label + link + look as ONE unit (V2 HEAD kit/controls/link.tsx \"Button\", DESIGN §8.8, CPO D43 · D45 · D46).\n *\n * - <ButtonControl> at rest: one FieldUnit, two rows. The label row drills into the button screen (form.navigate → the\n * \"button\" frame); the link row edits the link in place (LinkQuickEdit).\n * - <ButtonScreen> the one button screen (the frame body): preview · label · link (LinkForm) · appearance (style grid,\n * size, leading icon, arrow).\n * - <ButtonStyleGrid>, <ButtonPreview>, <StyleGlyph> — the pieces both draw.\n *\n * Stored shape (prod `button`, adapters/values.ts buttonToProd / buttonFromProd; backend buttonValueProblem). The kit\n * value is the flattened V2 button the adapter hands in. What this control writes keeps that value's keys:\n * - the look goes in the key the value already uses — `style` when it has one, else `variant` (what prod renderers\n * read) — and never both (buttonToProd names an equal pair as lost, so the dock would refuse the write);\n * - `rel: \"follow\"` is never written (prod's rel list is nofollow · sponsored · ugc) and `newTab: false`/`target` only\n * where the stored value had that key (storedLink);\n * - `icon` is a dock icon name (DOCK_ICON_NAMES): the picker offers only icons that are dock names.\n *\n * \"Full width\" writes `fullWidth: true`, and off writes `false` only where the stored value had the key (as Show arrow);\n * every renderer draws it (hosted `bcms-btn-full`, the SDKs' and in-place publishing's `data-full-width`).\n *\n * Deviation from V2, because prod has nothing behind it: an unset look reads \"Default\" (V2 drew Primary, and guessed\n * Outline for a field named \"secondary\"). The preview is V2's: the site palette (--kit-preview-paper / -ink / -primary /\n * -primary-on / -contrast / -contrast-on / -outline, which a host may set to the project's colours) on the paper, and the\n * chrome swatches in the style grid.\n */\nimport * as React from \"react\";\nimport { IconArrowRight, IconChevronDown, IconChevronRight, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { KIT_ICONS, KitIcon, iconLabel } from \"../lib/icons\";\nimport { BUTTON_VARIANTS, DOCK_ICON_NAME_SET } from \"../adapters/prod-types\";\nimport { useForm, useKitEnv } from \"../context\";\nimport { FieldUnit } from \"../engine/grouping\";\nimport { Input } from \"../ui/input\";\nimport { Segmented, Switch } from \"../ui/controls\";\nimport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { LinkForm, LinkLine, LinkQuickEdit, TARGET_KEYS, finalizeLink, findTarget, hasLink, linkText, normLink, storedLink, useLinkTargets, type ButtonStyle, type LinkValue } from \"./link\";\n\nexport const STYLE_ITEMS: { value: ButtonStyle; label: string }[] = [\n { value: \"primary\", label: \"Primary\" },\n { value: \"secondary\", label: \"Secondary\" },\n { value: \"outline\", label: \"Outline\" },\n { value: \"link\", label: \"Text link\" },\n];\nconst SIZE_LABEL = { sm: \"Small\", md: \"Medium\", lg: \"Large\" } as const;\nconst isVariant = (x: unknown): x is string => typeof x === \"string\" && (BUTTON_VARIANTS as readonly string[]).includes(x);\n\n/** The look prod renders: the first valid of variant, style (buttonToProd's rule). */\nexport function lookOf(v: Pick<LinkValue, \"variant\" | \"style\">): string | undefined {\n return [v.variant, v.style].find(isVariant);\n}\n/** \"Brand\" for a stored look outside the four styles; undefined when unset. */\nexport function lookLabel(look: string | undefined): string {\n if (!look) return \"Default\";\n return STYLE_ITEMS.find((s) => s.value === look)?.label ?? look.charAt(0).toUpperCase() + look.slice(1);\n}\n\n/**\n * The next stored button: `raw` (the value as the field holds it) with `patch` applied, keyed like `raw`. A look in the\n * patch (`style`) lands in the key `raw` uses for it.\n */\nexport function nextButton(raw: unknown, patch: Partial<LinkValue>): LinkValue {\n const base: LinkValue = isObj(raw) ? ({ ...(raw as object) } as LinkValue) : { href: \"\" };\n const { style, ...rest } = patch;\n const out: LinkValue = { ...base, ...rest };\n // prod requires both strings (buttonToProd names a missing one as lost, and the dock refuses the write)\n if (typeof out.href !== \"string\") out.href = \"\";\n if (typeof out.label !== \"string\") out.label = \"\";\n if (style !== undefined) {\n const key = isObj(raw) && raw.style !== undefined ? \"style\" : \"variant\";\n delete out.style;\n delete out.variant;\n out[key] = style;\n }\n return storedLink(out, raw);\n}\n\n/** The icons a button can carry: the kit's drawn icons that are also dock names (the backend checks the name). */\nexport const BUTTON_ICONS: string[] = Object.keys(KIT_ICONS).filter((n) => DOCK_ICON_NAME_SET.has(n));\n\n/** D46: four styles never sit in a row of tabs. The option IS the visual, so it is a 2×2 grid of live previews (one\n * radiogroup: Tab enters on the checked style, arrows move and pick). A stored look outside the four is listed too. */\nexport function ButtonStyleGrid({\n v,\n onPick,\n \"aria-label\": ariaLabel,\n size = \"md\",\n}: {\n v: LinkValue;\n onPick: (s: ButtonStyle) => void;\n \"aria-label\": string;\n size?: \"sm\" | \"md\";\n}) {\n const cur = lookOf(v);\n const items: { value: string; label: string }[] = cur && !STYLE_ITEMS.some((s) => s.value === cur) ? [...STYLE_ITEMS, { value: cur, label: lookLabel(cur) }] : STYLE_ITEMS;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const d = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n if (!d) return;\n e.preventDefault();\n const next = items[(i + d + items.length) % items.length];\n onPick(next.value as ButtonStyle);\n const group = (e.currentTarget as HTMLElement).parentElement;\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-style=\"${next.value}\"]`)?.focus());\n };\n return (\n <div className=\"grid grid-cols-2 gap-1.5\" role=\"radiogroup\" aria-label={ariaLabel}>\n {items.map((s, i) => {\n const on = cur === s.value;\n return (\n <button\n key={s.value}\n type=\"button\"\n role=\"radio\"\n data-style={s.value}\n aria-checked={on}\n tabIndex={on || (!items.some((x) => x.value === cur) && i === 0) ? 0 : -1}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onPick(s.value as ButtonStyle)}\n className={cn(\n \"flex min-w-0 items-center gap-2 rounded-kit-md border px-2 transition-colors\",\n size === \"sm\" ? \"h-8 text-kit-xs\" : \"h-9 text-kit-sm\",\n on ? \"border-[var(--kit-emphasis-line)] bg-kit-selected text-kit-fg\" : \"border-kit-line text-kit-fg-2 hover:border-kit-line-strong hover:text-kit-fg\",\n )}\n >\n <ButtonPreview v={{ ...v, style: s.value as ButtonStyle, variant: undefined, label: \"Aa\", icon: undefined, arrow: false }} small chrome />\n <span className=\"truncate\">{s.label}</span>\n </button>\n );\n })}\n </div>\n );\n}\n\n/**\n * The site's button as the site draws it (V2 link.tsx ButtonPreview: the site palette, not app tokens). On the preview\n * paper it keeps the site's own colours in both themes; `chrome` = drawn on app chrome (the style grid), where the\n * dark-ink styles flip so they still read on a dark panel. Prod looks beyond the four: brand as primary, dark as\n * secondary, any other in the muted kit fill.\n */\nexport function ButtonPreview({ v, className, small, chrome }: { v: LinkValue; className?: string; small?: boolean; chrome?: boolean }) {\n const look = lookOf(v) ?? \"primary\";\n const style = look === \"brand\" ? \"primary\" : look === \"dark\" ? \"secondary\" : look;\n const size = small ? \"sm\" : v.size ?? \"md\";\n return (\n <span\n className={cn(\n \"inline-flex max-w-full items-center justify-center gap-1.5 truncate font-medium transition-colors\",\n size === \"sm\" ? \"h-6 rounded-kit-md px-2 text-kit-xs\" : size === \"lg\" ? \"h-10 rounded-kit-lg px-4 text-kit-base\" : \"h-8 rounded-kit-lg px-3 text-kit-sm\",\n style === \"primary\" && \"bg-kit-preview-primary text-kit-preview-primary-on\",\n style === \"secondary\" && (chrome ? \"bg-kit-preview-contrast text-kit-preview-contrast-on\" : \"bg-kit-preview-ink text-kit-preview-paper\"),\n style === \"outline\" && (chrome ? \"border border-kit-preview-outline text-kit-fg\" : \"border border-kit-preview-ink/25 text-kit-preview-ink\"),\n style === \"link\" && \"h-auto px-0 text-kit-preview-primary underline underline-offset-4\",\n !STYLE_ITEMS.some((x) => x.value === style) && \"bg-kit-muted text-kit-fg\",\n v.fullWidth && !small && \"w-full\",\n className,\n )}\n >\n {v.icon ? <KitIcon name={v.icon} className=\"size-3.5 shrink-0\" /> : null}\n <span className=\"truncate\">{v.label || \"Button\"}</span>\n {v.arrow ? <IconArrowRight className=\"size-3.5 shrink-0\" stroke={1.75} /> : null}\n </span>\n );\n}\n\n/** A 16px neutral glyph of the style (filled · outlined · underlined) — brand-free, so the field stays calm. */\nexport function StyleGlyph({ style, className }: { style?: string; className?: string }) {\n return (\n <span aria-hidden className={cn(\"flex size-4 shrink-0 items-center justify-center\", className)}>\n {style === \"link\" ? (\n <span className=\"h-[2px] w-3.5 rounded-full bg-kit-fg-2\" />\n ) : (\n <span className={cn(\"h-2.5 w-4 rounded-[3px]\", style === \"outline\" ? \"border-[1.5px] border-kit-fg-2\" : style === \"secondary\" || style === \"light\" || style === \"tertiary\" ? \"bg-kit-fg-3\" : \"bg-kit-fg\")} />\n )}\n </span>\n );\n}\n\n/** The leading-icon picker over BUTTON_ICONS, \"No icon\" first: V2's IconPickerGrid (icon.tsx) — search box, 8-column\n * grid in a 224px scroll. The tiles stay one radiogroup (the dash's semantics; V2 draws a listbox). */\nexport function ButtonIconPicker({ value, onPick }: { value?: string; onPick: (icon: string | undefined) => void }) {\n const [q, setQ] = React.useState(\"\");\n const query = q.trim().toLowerCase();\n const shown = query ? BUTTON_ICONS.filter((n) => n.includes(query.replace(/\\s+/g, \"-\"))) : BUTTON_ICONS;\n const tile = (on: boolean) =>\n cn(\"flex aspect-square items-center justify-center rounded-kit-md text-kit-fg-2 transition-colors hover:bg-kit-hover hover:text-kit-fg\", on && \"bg-kit-selected text-kit-fg ring-1 ring-inset ring-kit-line-strong\");\n return (\n <div data-icon-picker className=\"flex flex-col gap-2\">\n <label className=\"flex h-8 items-center gap-2 rounded-kit-md bg-kit-muted px-2.5 text-kit-fg-3 focus-within:bg-kit-field-bg focus-within:ring-1 focus-within:ring-kit-line-strong\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n value={q}\n onChange={(e) => setQ(e.target.value)}\n placeholder=\"Search icons\"\n aria-label=\"Search icons\"\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div className=\"max-h-56 overflow-y-auto pr-0.5\">\n <div role=\"radiogroup\" aria-label=\"Leading icon\" className=\"grid gap-0.5\" style={{ gridTemplateColumns: \"repeat(8, minmax(0, 1fr))\" }}>\n {query ? null : (\n <button type=\"button\" role=\"radio\" aria-checked={!value} aria-label=\"No icon\" onClick={() => onPick(undefined)} className={tile(!value)}>\n <IconX className=\"size-4\" stroke={1.5} aria-hidden />\n </button>\n )}\n {shown.map((n) => (\n <button key={n} type=\"button\" role=\"radio\" aria-checked={value === n} aria-label={iconLabel(n)} onClick={() => onPick(n)} className={tile(value === n)}>\n <KitIcon name={n} className=\"size-[18px]\" />\n </button>\n ))}\n </div>\n {shown.length === 0 ? <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No icons match “{q}”</p> : null}\n </div>\n </div>\n );\n}\n\n/** The ONE button screen: preview · label · link (+ new tab, rel) · appearance (style, size, icon, arrow). */\nexport function ButtonScreen({ value, onChange, readOnly, title = \"Button\" }: { value: unknown; onChange: (v: LinkValue) => void; readOnly?: boolean; title?: string }) {\n const v = normLink(value);\n const set = (p: Partial<LinkValue>) => onChange(nextButton(value, p));\n const [iconOpen, setIconOpen] = React.useState(false);\n const labelId = React.useId();\n const arrowId = React.useId();\n const fullId = React.useId();\n return (\n <fieldset disabled={readOnly} className=\"flex min-w-0 flex-col gap-5\">\n <div data-button-preview=\"\" className=\"flex min-h-20 items-center justify-center rounded-kit-lg bg-kit-preview-paper px-4 py-5 [filter:var(--kit-paper-filter)]\">\n <ButtonPreview v={v} />\n </div>\n <Row label=\"Label\" htmlFor={labelId}>\n <Input id={labelId} value={v.label ?? \"\"} onChange={(e) => set({ label: e.target.value })} placeholder=\"Shop now\" />\n </Row>\n <div className=\"flex flex-col gap-1.5\" role=\"group\" aria-label={`${title} link`}>\n <span className=\"text-kit-sm font-medium text-kit-fg-2\">Link</span>\n <LinkForm\n readOnly={readOnly}\n value={v}\n onChange={(n) => {\n // a script link is never written; LinkForm says why under the target\n const out = finalizeLink(n);\n if (out) set(linkPart(out));\n }}\n />\n </div>\n <div className=\"flex flex-col gap-4 border-t border-kit-line pt-4\">\n <span className=\"text-kit-xs font-medium text-kit-fg-3\">Appearance</span>\n <Row label=\"Style\">\n <ButtonStyleGrid v={v} aria-label={`${title} style`} onPick={(style) => set({ style })} />\n </Row>\n <Row label=\"Size\">\n <Segmented<\"sm\" | \"md\" | \"lg\">\n aria-label={`${title} size`}\n value={v.size ?? \"md\"}\n onChange={(s) => set({ size: s })}\n items={[\n { value: \"sm\", label: \"Small\" },\n { value: \"md\", label: \"Medium\" },\n { value: \"lg\", label: \"Large\" },\n ]}\n className=\"w-full [&>button]:flex-1\"\n />\n </Row>\n <Row label=\"Leading icon\">\n <Popover open={iconOpen} onOpenChange={setIconOpen}>\n <PopoverTrigger\n render={\n <button\n type=\"button\"\n className=\"flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg hover:border-kit-field-border-hover\"\n />\n }\n >\n {v.icon ? <KitIcon name={v.icon} className=\"size-4 text-kit-fg-2\" /> : <span className=\"size-4 rounded-kit-md border border-dashed border-[var(--kit-emphasis-line)]\" />}\n <span className={cn(\"flex-1 truncate\", !v.icon && \"text-kit-fg-3\")}>{v.icon ? iconLabel(v.icon) : \"No icon\"}</span>\n <IconChevronDown className=\"size-3.5 text-kit-fg-3\" stroke={1.5} />\n </PopoverTrigger>\n <PopoverContent className=\"w-[300px] p-2\">\n <ButtonIconPicker\n value={v.icon}\n onPick={(k) => {\n set({ icon: k });\n setIconOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n </Row>\n <div className=\"flex flex-col gap-2\">\n <label htmlFor={arrowId} className=\"flex min-h-7 cursor-pointer items-center justify-between gap-3\">\n <span className=\"text-kit-sm text-kit-fg-2\">Show arrow</span>\n <Switch disabled={readOnly} id={arrowId} size=\"sm\" checked={!!v.arrow} onCheckedChange={(c) => set({ arrow: c ? true : isObj(value) && \"arrow\" in value ? false : undefined })} />\n </label>\n <label htmlFor={fullId} className=\"flex min-h-7 cursor-pointer items-center justify-between gap-3\">\n <span className=\"text-kit-sm text-kit-fg-2\">Full width</span>\n <Switch\n disabled={readOnly}\n id={fullId}\n size=\"sm\"\n checked={v.fullWidth === true}\n onCheckedChange={(c) => set({ fullWidth: c ? true : isObj(value) && \"fullWidth\" in value ? false : undefined })}\n />\n </label>\n </div>\n </div>\n </fieldset>\n );\n}\n\n/** The link half of a link value (what LinkForm / the quick edit own); the label and the look stay the button's. */\nfunction linkPart(n: LinkValue): Partial<LinkValue> {\n const { label: _l, style: _s, variant: _v, size: _z, arrow: _a, icon: _i, fullWidth: _f, ...link } = n;\n // a key the new link no longer has (a picked page drops the typed email) is cleared, not kept from before\n return { ...TARGET_KEYS, email: undefined, phone: undefined, subject: undefined, ...link };\n}\n\nfunction Row({ label, children, htmlFor }: { label: string; children: React.ReactNode; htmlFor?: string }) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={htmlFor} className=\"text-kit-sm font-medium text-kit-fg-2\">\n {label}\n </label>\n {children}\n </div>\n );\n}\n\n/**\n * Button field at rest: ONE unit between two hairlines (fieldset-like).\n * [style glyph] Label ……………… Primary · Medium › → drills into the button screen (\"… › Button\")\n * [page icon] Title /path → edits the link in place\n */\nexport function ButtonControl({ value, onChange, readOnly, id, path, field }: ControlProps) {\n const v = normLink(value);\n const form = useForm();\n const { variant } = useKitEnv();\n const [open, setOpen] = React.useState(false);\n const [editingLink, setEditingLink] = React.useState(false);\n const { targets } = useLinkTargets();\n const target = findTarget(targets, v);\n const linkBtn = React.useRef<HTMLButtonElement>(null);\n const look = lookOf(v);\n const openSettings = () => (form ? form.navigate(path) : setOpen(true));\n const h = variant === \"document\" ? \"h-10\" : \"h-9\";\n const head = (\n <button\n id={id}\n type=\"button\"\n onClick={readOnly && !form ? undefined : openSettings}\n aria-label={`${field.title}: ${v.label || \"no label\"}. Open button settings`}\n className={cn(\"group/bhead flex w-full min-w-0 items-center gap-2.5 px-2.5 text-left outline-none transition-colors hover:bg-kit-hover focus-visible:bg-kit-hover\", h)}\n >\n <StyleGlyph style={look} />\n <span className={cn(\"min-w-0 flex-1 truncate text-kit-sm font-medium\", v.label ? \"text-kit-fg\" : \"text-kit-fg-3\")}>{v.label || \"Add a label\"}</span>\n <span className=\"shrink-0 text-kit-xs text-kit-fg-3\">\n {lookLabel(look)}\n {v.size && v.size !== \"md\" ? ` · ${SIZE_LABEL[v.size]}` : \"\"}\n </span>\n <IconChevronRight className=\"size-4 shrink-0 text-kit-fg-3 transition-transform group-hover/bhead:translate-x-0.5\" stroke={1.5} aria-hidden />\n </button>\n );\n const linkRow =\n editingLink && !readOnly ? (\n <div>\n <LinkQuickEdit\n value={v}\n ariaLabel={`${field.title} link`}\n size=\"sm\"\n bare\n onCommit={(n) => onChange(nextButton(value, n ? linkPart(n) : { ...linkPart({ href: \"\" }), type: \"page\", href: \"\" }))}\n onDone={() => {\n setEditingLink(false);\n requestAnimationFrame(() => linkBtn.current?.focus({ preventScroll: true }));\n }}\n />\n </div>\n ) : (\n <button\n ref={linkBtn}\n type=\"button\"\n disabled={readOnly}\n onClick={() => setEditingLink(true)}\n // V2 link.tsx:1263: the name reads the link's own text (its title, else its address), not the picked target's title\n aria-label={hasLink(v) ? `${field.title} link: ${linkText(v)}. Edit link` : `Add a link to ${field.title.toLowerCase()}`}\n className={cn(\"flex w-full min-w-0 items-center px-2.5 text-left outline-none transition-colors hover:bg-kit-hover focus-visible:bg-kit-hover disabled:cursor-default disabled:hover:bg-transparent\", h)}\n >\n <LinkLine v={v} target={target} />\n </button>\n );\n // CPO D43 + D45: label + link are ONE unit — one border, a hairline between the label row and the link row\n const unit = (\n <FieldUnit data-button-unit=\"\" aria-label={field.title} className=\"overflow-hidden\">\n {head}\n {linkRow}\n </FieldUnit>\n );\n if (form) return unit;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverAnchor render={unit} />\n <PopoverContent className=\"w-[360px] p-4\" align=\"start\">\n <ButtonScreen value={value} onChange={onChange} readOnly={readOnly} title={field.title} />\n </PopoverContent>\n </Popover>\n );\n}\n\n/* ── Compact button editor for small surfaces (the canvas popover) ──\n * V2 kit/controls/link.tsx ButtonLinkEditor, ported as is: label + the link element (LinkForm, same Type · target ·\n * options as everywhere) as one unit, then the button's Style. Here beside STYLE_ITEMS, which link.tsx cannot import.\n */\nexport function ButtonLinkEditor({\n value,\n onChange,\n onSubmit,\n styles = STYLE_ITEMS,\n labelFirst = true,\n}: {\n value: LinkValue;\n onChange: (v: LinkValue) => void;\n onSubmit?: () => void;\n /** null = a plain text link (nav, footer and legal links): no style row. */\n styles?: { value: ButtonStyle; label: string }[] | null;\n labelFirst?: boolean;\n}) {\n const v = normLink(value);\n const labelId = React.useId();\n const setStyle = (s: ButtonStyle) => onChange({ ...v, style: s, variant: s });\n return (\n <div className=\"flex flex-col gap-3\">\n {labelFirst ? (\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={labelId} className=\"text-kit-xs font-medium text-kit-fg-2\">Label</label>\n <Input id={labelId} size=\"sm\" autoFocus value={v.label ?? \"\"} onChange={(e) => onChange({ ...v, label: e.target.value })} onKeyDown={(e) => e.key === \"Enter\" && (e.preventDefault(), onSubmit?.())} placeholder=\"Shop cookware\" />\n </div>\n ) : null}\n <div className=\"flex flex-col gap-2.5\" role=\"group\" aria-label=\"Link\">\n <span className=\"text-kit-xs font-medium text-kit-fg-2\">Link</span>\n <LinkForm value={v} onChange={(n) => onChange({ ...v, ...n, label: v.label, style: v.style, variant: v.variant })} onEnter={() => onSubmit?.()} />\n </div>\n {styles ? (\n <div className=\"flex items-center justify-between gap-3 border-t border-kit-line pt-2.5\">\n <span className=\"text-kit-xs text-kit-fg-2\">Style</span>\n <Segmented size=\"sm\" aria-label=\"Button style\" value={v.style ?? \"primary\"} onChange={(s) => setStyle(s as ButtonStyle)} items={styles} />\n </div>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,cAAuD;CAClE;EAAE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,cAAW;IAA/D,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAwC,UAAA;IAAU,CAAA,GAClE,oBAAC,UAAD;KAAU,OAAO;KAAG,WAAW,MAAM,SAAS;MAAE,GAAG;MAAG,GAAG;MAAG,OAAO,EAAE;MAAO,OAAO,EAAE;MAAO,SAAS,EAAE;KAAQ,CAAC;KAAG,eAAe,WAAW;IAAI,CAAA,CAC9I;;GACJ,SACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAA4B,UAAA;IAAW,CAAA,GACvD,oBAAC,WAAD;KAAW,MAAK;KAAK,cAAW;KAAe,OAAO,EAAE,SAAS;KAAW,WAAW,MAAM,SAAS,CAAgB;KAAG,OAAO;IAAS,CAAA,CACtI;GACH,CAAA,IAAA;EACD;;AAET"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../src/controls/button.tsx"],"sourcesContent":["/**\n * BUTTON — label + link + look as ONE unit (V2 HEAD kit/controls/link.tsx \"Button\", DESIGN §8.8, CPO D43 · D45 · D46).\n *\n * - <ButtonControl> at rest: one FieldUnit, two rows. The label row drills into the button screen (form.navigate → the\n * \"button\" frame); the link row edits the link in place (LinkQuickEdit).\n * - <ButtonScreen> the one button screen (the frame body): preview · label · link (LinkForm) · appearance (style grid,\n * size, leading icon, arrow).\n * - <ButtonStyleGrid>, <ButtonPreview>, <StyleGlyph> — the pieces both draw.\n *\n * Stored shape (prod `button`, adapters/values.ts buttonToProd / buttonFromProd; backend buttonValueProblem). The kit\n * value is the flattened V2 button the adapter hands in. What this control writes keeps that value's keys:\n * - the look goes in the key the value already uses — `style` when it has one, else `variant` (what prod renderers\n * read) — and never both (buttonToProd names an equal pair as lost, so the dock would refuse the write);\n * - `rel: \"follow\"` is never written (prod's rel list is nofollow · sponsored · ugc) and `newTab: false`/`target` only\n * where the stored value had that key (storedLink);\n * - `icon` is a dock icon name (DOCK_ICON_NAMES): the picker offers only icons that are dock names.\n *\n * \"Full width\" writes `fullWidth: true`, and off writes `false` only where the stored value had the key (as Show arrow);\n * every renderer draws it (hosted `bcms-btn-full`, the SDKs' and in-place publishing's `data-full-width`).\n *\n * Deviation from V2, because prod has nothing behind it: an unset look reads \"Default\" (V2 drew Primary, and guessed\n * Outline for a field named \"secondary\"). The preview is V2's: the site palette (--kit-preview-paper / -ink / -primary /\n * -primary-on / -contrast / -contrast-on / -outline, which a host may set to the project's colours) on the paper, and the\n * chrome swatches in the style grid.\n */\nimport * as React from \"react\";\nimport { IconArrowRight, IconChevronDown, IconChevronRight, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { KIT_ICONS, KitIcon, iconLabel } from \"../lib/icons\";\nimport { BUTTON_VARIANTS, DOCK_ICON_NAME_SET } from \"../adapters/prod-types\";\nimport { useForm, useKitEnv } from \"../context\";\nimport { FieldUnit } from \"../engine/grouping\";\nimport { Input } from \"../ui/input\";\nimport { Segmented, Switch } from \"../ui/controls\";\nimport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { LinkForm, LinkLine, LinkQuickEdit, TARGET_KEYS, finalizeLink, findTarget, hasLink, linkText, normLink, storedLink, useLinkTargets, type ButtonStyle, type LinkValue } from \"./link\";\n\nexport const STYLE_ITEMS: { value: ButtonStyle; label: string }[] = [\n { value: \"primary\", label: \"Primary\" },\n { value: \"secondary\", label: \"Secondary\" },\n { value: \"outline\", label: \"Outline\" },\n { value: \"link\", label: \"Text link\" },\n];\nconst SIZE_LABEL = { sm: \"Small\", md: \"Medium\", lg: \"Large\" } as const;\nconst isVariant = (x: unknown): x is string => typeof x === \"string\" && (BUTTON_VARIANTS as readonly string[]).includes(x);\n\n/** The look prod renders: the first valid of variant, style (buttonToProd's rule). */\nexport function lookOf(v: Pick<LinkValue, \"variant\" | \"style\">): string | undefined {\n return [v.variant, v.style].find(isVariant);\n}\n/** \"Brand\" for a stored look outside the four styles; undefined when unset. */\nexport function lookLabel(look: string | undefined): string {\n if (!look) return \"Default\";\n return STYLE_ITEMS.find((s) => s.value === look)?.label ?? look.charAt(0).toUpperCase() + look.slice(1);\n}\n\n/**\n * The next stored button: `raw` (the value as the field holds it) with `patch` applied, keyed like `raw`. A look in the\n * patch (`style`) lands in the key `raw` uses for it.\n */\nexport function nextButton(raw: unknown, patch: Partial<LinkValue>): LinkValue {\n const base: LinkValue = isObj(raw) ? ({ ...(raw as object) } as LinkValue) : { href: \"\" };\n const { style, ...rest } = patch;\n const out: LinkValue = { ...base, ...rest };\n // prod requires both strings (buttonToProd names a missing one as lost, and the dock refuses the write)\n if (typeof out.href !== \"string\") out.href = \"\";\n if (typeof out.label !== \"string\") out.label = \"\";\n if (style !== undefined) {\n const key = isObj(raw) && raw.style !== undefined ? \"style\" : \"variant\";\n delete out.style;\n delete out.variant;\n out[key] = style;\n }\n return storedLink(out, raw);\n}\n\n/** The icons a button can carry: the kit's drawn icons that are also dock names (the backend checks the name). */\nexport const BUTTON_ICONS: string[] = Object.keys(KIT_ICONS).filter((n) => DOCK_ICON_NAME_SET.has(n));\n\n/** D46: four styles never sit in a row of tabs. The option IS the visual, so it is a 2×2 grid of live previews (one\n * radiogroup: Tab enters on the checked style, arrows move and pick). A stored look outside the four is listed too. */\nexport function ButtonStyleGrid({\n v,\n onPick,\n \"aria-label\": ariaLabel,\n size = \"md\",\n}: {\n v: LinkValue;\n onPick: (s: ButtonStyle) => void;\n \"aria-label\": string;\n size?: \"sm\" | \"md\";\n}) {\n const cur = lookOf(v);\n const items: { value: string; label: string }[] = cur && !STYLE_ITEMS.some((s) => s.value === cur) ? [...STYLE_ITEMS, { value: cur, label: lookLabel(cur) }] : STYLE_ITEMS;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const d = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n if (!d) return;\n e.preventDefault();\n const next = items[(i + d + items.length) % items.length];\n onPick(next.value as ButtonStyle);\n const group = (e.currentTarget as HTMLElement).parentElement;\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-style=\"${next.value}\"]`)?.focus());\n };\n return (\n <div className=\"grid grid-cols-2 gap-1.5\" role=\"radiogroup\" aria-label={ariaLabel}>\n {items.map((s, i) => {\n const on = cur === s.value;\n return (\n <button\n key={s.value}\n type=\"button\"\n role=\"radio\"\n data-style={s.value}\n aria-checked={on}\n tabIndex={on || (!items.some((x) => x.value === cur) && i === 0) ? 0 : -1}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onPick(s.value as ButtonStyle)}\n className={cn(\n \"flex min-w-0 items-center gap-2 rounded-kit-md border px-2 transition-colors\",\n size === \"sm\" ? \"h-8 text-kit-xs\" : \"h-9 text-kit-sm\",\n on ? \"border-[var(--kit-emphasis-line)] bg-kit-selected text-kit-fg\" : \"border-kit-line text-kit-fg-2 hover:border-kit-line-strong hover:text-kit-fg\",\n )}\n >\n <ButtonPreview v={{ ...v, style: s.value as ButtonStyle, variant: undefined, label: \"Aa\", icon: undefined, arrow: false }} small chrome />\n <span className=\"truncate\">{s.label}</span>\n </button>\n );\n })}\n </div>\n );\n}\n\n/**\n * The site's button as the site draws it (V2 link.tsx ButtonPreview: the site palette, not app tokens). On the preview\n * paper it keeps the site's own colours in both themes; `chrome` = drawn on app chrome (the style grid), where the\n * dark-ink styles flip so they still read on a dark panel. Prod looks beyond the four: brand as primary, dark as\n * secondary, any other in the muted kit fill.\n */\nexport function ButtonPreview({ v, className, small, chrome }: { v: LinkValue; className?: string; small?: boolean; chrome?: boolean }) {\n const look = lookOf(v) ?? \"primary\";\n const style = look === \"brand\" ? \"primary\" : look === \"dark\" ? \"secondary\" : look;\n const size = small ? \"sm\" : v.size ?? \"md\";\n return (\n <span\n className={cn(\n \"inline-flex max-w-full items-center justify-center gap-1.5 truncate font-medium transition-colors\",\n size === \"sm\" ? \"h-6 rounded-kit-md px-2 text-kit-xs\" : size === \"lg\" ? \"h-10 rounded-kit-lg px-4 text-kit-base\" : \"h-8 rounded-kit-lg px-3 text-kit-sm\",\n style === \"primary\" && \"bg-kit-preview-primary text-kit-preview-primary-on\",\n style === \"secondary\" && (chrome ? \"bg-kit-preview-contrast text-kit-preview-contrast-on\" : \"bg-kit-preview-ink text-kit-preview-paper\"),\n style === \"outline\" && (chrome ? \"border border-kit-preview-outline text-kit-fg\" : \"border border-kit-preview-ink/25 text-kit-preview-ink\"),\n style === \"link\" && \"h-auto px-0 text-kit-preview-primary underline underline-offset-4\",\n !STYLE_ITEMS.some((x) => x.value === style) && \"bg-kit-muted text-kit-fg\",\n v.fullWidth && !small && \"w-full\",\n className,\n )}\n >\n {v.icon ? <KitIcon name={v.icon} className=\"size-3.5 shrink-0\" /> : null}\n <span className=\"truncate\">{v.label || \"Button\"}</span>\n {v.arrow ? <IconArrowRight className=\"size-3.5 shrink-0\" stroke={1.75} /> : null}\n </span>\n );\n}\n\n/** A 16px neutral glyph of the style (filled · outlined · underlined) — brand-free, so the field stays calm. */\nexport function StyleGlyph({ style, className }: { style?: string; className?: string }) {\n return (\n <span aria-hidden className={cn(\"flex size-4 shrink-0 items-center justify-center\", className)}>\n {style === \"link\" ? (\n <span className=\"h-[2px] w-3.5 rounded-full bg-kit-fg-2\" />\n ) : (\n <span className={cn(\"h-2.5 w-4 rounded-[3px]\", style === \"outline\" ? \"border-[1.5px] border-kit-fg-2\" : style === \"secondary\" || style === \"light\" || style === \"tertiary\" ? \"bg-kit-fg-3\" : \"bg-kit-fg\")} />\n )}\n </span>\n );\n}\n\n/** The leading-icon picker over BUTTON_ICONS, \"No icon\" first: V2's IconPickerGrid (icon.tsx) — search box, 8-column\n * grid in a 224px scroll. The tiles stay one radiogroup (the dash's semantics; V2 draws a listbox). */\nexport function ButtonIconPicker({ value, onPick }: { value?: string; onPick: (icon: string | undefined) => void }) {\n const [q, setQ] = React.useState(\"\");\n const query = q.trim().toLowerCase();\n const shown = query ? BUTTON_ICONS.filter((n) => n.includes(query.replace(/\\s+/g, \"-\"))) : BUTTON_ICONS;\n const tile = (on: boolean) =>\n cn(\"flex aspect-square items-center justify-center rounded-kit-md text-kit-fg-2 transition-colors hover:bg-kit-hover hover:text-kit-fg\", on && \"bg-kit-selected text-kit-fg ring-1 ring-inset ring-kit-line-strong\");\n return (\n <div data-icon-picker className=\"flex flex-col gap-2\">\n <label className=\"flex h-8 items-center gap-2 rounded-kit-md bg-kit-muted px-2.5 text-kit-fg-3 focus-within:bg-kit-field-bg focus-within:ring-1 focus-within:ring-kit-line-strong\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n value={q}\n onChange={(e) => setQ(e.target.value)}\n placeholder=\"Search icons\"\n aria-label=\"Search icons\"\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div className=\"max-h-56 overflow-y-auto pr-0.5\">\n <div role=\"radiogroup\" aria-label=\"Leading icon\" className=\"grid gap-0.5\" style={{ gridTemplateColumns: \"repeat(8, minmax(0, 1fr))\" }}>\n {query ? null : (\n <button type=\"button\" role=\"radio\" aria-checked={!value} aria-label=\"No icon\" onClick={() => onPick(undefined)} className={tile(!value)}>\n <IconX className=\"size-4\" stroke={1.5} aria-hidden />\n </button>\n )}\n {shown.map((n) => (\n <button key={n} type=\"button\" role=\"radio\" aria-checked={value === n} aria-label={iconLabel(n)} onClick={() => onPick(n)} className={tile(value === n)}>\n <KitIcon name={n} className=\"size-[18px]\" />\n </button>\n ))}\n </div>\n {shown.length === 0 ? <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No icons match “{q}”</p> : null}\n </div>\n </div>\n );\n}\n\n/** The ONE button screen: preview · label · link (+ new tab, rel) · appearance (style, size, icon, arrow). */\nexport function ButtonScreen({ value, onChange, readOnly, title = \"Button\" }: { value: unknown; onChange: (v: LinkValue) => void; readOnly?: boolean; title?: string }) {\n const v = normLink(value);\n const set = (p: Partial<LinkValue>) => onChange(nextButton(value, p));\n const [iconOpen, setIconOpen] = React.useState(false);\n const labelId = React.useId();\n const noLabel = !readOnly && !(v.label ?? \"\").trim();\n const arrowId = React.useId();\n const fullId = React.useId();\n return (\n <fieldset disabled={readOnly} className=\"flex min-w-0 flex-col gap-5\">\n <div data-button-preview=\"\" className=\"flex min-h-20 items-center justify-center rounded-kit-lg bg-kit-preview-paper px-4 py-5 [filter:var(--kit-paper-filter)]\">\n <ButtonPreview v={v} />\n </div>\n <Row label=\"Label\" htmlFor={labelId}>\n <Input\n id={labelId}\n value={v.label ?? \"\"}\n onChange={(e) => set({ label: e.target.value })}\n placeholder=\"Shop now\"\n aria-invalid={noLabel || undefined}\n aria-describedby={noLabel ? `${labelId}-msg` : undefined}\n />\n {/* DK-018: an empty label leaves the reader nothing to press (the preview's \"Button\" is only a placeholder) */}\n {noLabel ? (\n <p id={`${labelId}-msg`} className=\"text-kit-xs text-kit-danger-fg\">\n Add a label. Without one the button shows no text on the page.\n </p>\n ) : null}\n </Row>\n <div className=\"flex flex-col gap-1.5\" role=\"group\" aria-label={`${title} link`}>\n <span className=\"text-kit-sm font-medium text-kit-fg-2\">Link</span>\n <LinkForm\n readOnly={readOnly}\n value={v}\n onChange={(n) => {\n // a script link is never written; LinkForm says why under the target\n const out = finalizeLink(n);\n if (out) set(linkPart(out));\n }}\n />\n </div>\n <div className=\"flex flex-col gap-4 border-t border-kit-line pt-4\">\n <span className=\"text-kit-xs font-medium text-kit-fg-3\">Appearance</span>\n <Row label=\"Style\">\n <ButtonStyleGrid v={v} aria-label={`${title} style`} onPick={(style) => set({ style })} />\n </Row>\n <Row label=\"Size\">\n <Segmented<\"sm\" | \"md\" | \"lg\">\n aria-label={`${title} size`}\n value={v.size ?? \"md\"}\n onChange={(s) => set({ size: s })}\n items={[\n { value: \"sm\", label: \"Small\" },\n { value: \"md\", label: \"Medium\" },\n { value: \"lg\", label: \"Large\" },\n ]}\n className=\"w-full [&>button]:flex-1\"\n />\n </Row>\n <Row label=\"Leading icon\">\n <Popover open={iconOpen} onOpenChange={setIconOpen}>\n <PopoverTrigger\n render={\n <button\n type=\"button\"\n className=\"flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg hover:border-kit-field-border-hover\"\n />\n }\n >\n {v.icon ? <KitIcon name={v.icon} className=\"size-4 text-kit-fg-2\" /> : <span className=\"size-4 rounded-kit-md border border-dashed border-[var(--kit-emphasis-line)]\" />}\n <span className={cn(\"flex-1 truncate\", !v.icon && \"text-kit-fg-3\")}>{v.icon ? iconLabel(v.icon) : \"No icon\"}</span>\n <IconChevronDown className=\"size-3.5 text-kit-fg-3\" stroke={1.5} />\n </PopoverTrigger>\n <PopoverContent className=\"w-[300px] p-2\">\n <ButtonIconPicker\n value={v.icon}\n onPick={(k) => {\n set({ icon: k });\n setIconOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n </Row>\n <div className=\"flex flex-col gap-2\">\n <label htmlFor={arrowId} className=\"flex min-h-7 cursor-pointer items-center justify-between gap-3\">\n <span className=\"text-kit-sm text-kit-fg-2\">Show arrow</span>\n <Switch disabled={readOnly} id={arrowId} size=\"sm\" checked={!!v.arrow} onCheckedChange={(c) => set({ arrow: c ? true : isObj(value) && \"arrow\" in value ? false : undefined })} />\n </label>\n <label htmlFor={fullId} className=\"flex min-h-7 cursor-pointer items-center justify-between gap-3\">\n <span className=\"text-kit-sm text-kit-fg-2\">Full width</span>\n <Switch\n disabled={readOnly}\n id={fullId}\n size=\"sm\"\n checked={v.fullWidth === true}\n onCheckedChange={(c) => set({ fullWidth: c ? true : isObj(value) && \"fullWidth\" in value ? false : undefined })}\n />\n </label>\n </div>\n </div>\n </fieldset>\n );\n}\n\n/** The link half of a link value (what LinkForm / the quick edit own); the label and the look stay the button's. */\nfunction linkPart(n: LinkValue): Partial<LinkValue> {\n const { label: _l, style: _s, variant: _v, size: _z, arrow: _a, icon: _i, fullWidth: _f, ...link } = n;\n // a key the new link no longer has (a picked page drops the typed email) is cleared, not kept from before\n return { ...TARGET_KEYS, email: undefined, phone: undefined, subject: undefined, ...link };\n}\n\nfunction Row({ label, children, htmlFor }: { label: string; children: React.ReactNode; htmlFor?: string }) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={htmlFor} className=\"text-kit-sm font-medium text-kit-fg-2\">\n {label}\n </label>\n {children}\n </div>\n );\n}\n\n/**\n * Button field at rest: ONE unit between two hairlines (fieldset-like).\n * [style glyph] Label ……………… Primary · Medium › → drills into the button screen (\"… › Button\")\n * [page icon] Title /path → edits the link in place\n */\nexport function ButtonControl({ value, onChange, readOnly, id, path, field }: ControlProps) {\n const v = normLink(value);\n const form = useForm();\n const { variant } = useKitEnv();\n const [open, setOpen] = React.useState(false);\n const [editingLink, setEditingLink] = React.useState(false);\n const { targets } = useLinkTargets();\n const target = findTarget(targets, v);\n const linkBtn = React.useRef<HTMLButtonElement>(null);\n const look = lookOf(v);\n const openSettings = () => (form ? form.navigate(path) : setOpen(true));\n const h = variant === \"document\" ? \"h-10\" : \"h-9\";\n const head = (\n <button\n id={id}\n type=\"button\"\n onClick={readOnly && !form ? undefined : openSettings}\n aria-label={`${field.title}: ${v.label || \"no label\"}. Open button settings`}\n className={cn(\"group/bhead flex w-full min-w-0 items-center gap-2.5 px-2.5 text-left outline-none transition-colors hover:bg-kit-hover focus-visible:bg-kit-hover\", h)}\n >\n <StyleGlyph style={look} />\n <span className={cn(\"min-w-0 flex-1 truncate text-kit-sm font-medium\", v.label ? \"text-kit-fg\" : \"text-kit-fg-3\")}>{v.label || \"Add a label\"}</span>\n <span className=\"shrink-0 text-kit-xs text-kit-fg-3\">\n {lookLabel(look)}\n {v.size && v.size !== \"md\" ? ` · ${SIZE_LABEL[v.size]}` : \"\"}\n </span>\n <IconChevronRight className=\"size-4 shrink-0 text-kit-fg-3 transition-transform group-hover/bhead:translate-x-0.5\" stroke={1.5} aria-hidden />\n </button>\n );\n const linkRow =\n editingLink && !readOnly ? (\n <div>\n <LinkQuickEdit\n value={v}\n ariaLabel={`${field.title} link`}\n size=\"sm\"\n bare\n onCommit={(n) => onChange(nextButton(value, n ? linkPart(n) : { ...linkPart({ href: \"\" }), type: \"page\", href: \"\" }))}\n onDone={() => {\n setEditingLink(false);\n requestAnimationFrame(() => linkBtn.current?.focus({ preventScroll: true }));\n }}\n />\n </div>\n ) : (\n <button\n ref={linkBtn}\n type=\"button\"\n disabled={readOnly}\n onClick={() => setEditingLink(true)}\n // V2 link.tsx:1263: the name reads the link's own text (its title, else its address), not the picked target's title\n aria-label={hasLink(v) ? `${field.title} link: ${linkText(v)}. Edit link` : `Add a link to ${field.title.toLowerCase()}`}\n className={cn(\"flex w-full min-w-0 items-center px-2.5 text-left outline-none transition-colors hover:bg-kit-hover focus-visible:bg-kit-hover disabled:cursor-default disabled:hover:bg-transparent\", h)}\n >\n <LinkLine v={v} target={target} />\n </button>\n );\n // CPO D43 + D45: label + link are ONE unit — one border, a hairline between the label row and the link row\n const unit = (\n <FieldUnit data-button-unit=\"\" aria-label={field.title} className=\"overflow-hidden\">\n {head}\n {linkRow}\n </FieldUnit>\n );\n if (form) return unit;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverAnchor render={unit} />\n <PopoverContent className=\"w-[360px] p-4\" align=\"start\">\n <ButtonScreen value={value} onChange={onChange} readOnly={readOnly} title={field.title} />\n </PopoverContent>\n </Popover>\n );\n}\n\n/* ── Compact button editor for small surfaces (the canvas popover) ──\n * V2 kit/controls/link.tsx ButtonLinkEditor, ported as is: label + the link element (LinkForm, same Type · target ·\n * options as everywhere) as one unit, then the button's Style. Here beside STYLE_ITEMS, which link.tsx cannot import.\n */\nexport function ButtonLinkEditor({\n value,\n onChange,\n onSubmit,\n styles = STYLE_ITEMS,\n labelFirst = true,\n}: {\n value: LinkValue;\n onChange: (v: LinkValue) => void;\n onSubmit?: () => void;\n /** null = a plain text link (nav, footer and legal links): no style row. */\n styles?: { value: ButtonStyle; label: string }[] | null;\n labelFirst?: boolean;\n}) {\n const v = normLink(value);\n const labelId = React.useId();\n const setStyle = (s: ButtonStyle) => onChange({ ...v, style: s, variant: s });\n return (\n <div className=\"flex flex-col gap-3\">\n {labelFirst ? (\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={labelId} className=\"text-kit-xs font-medium text-kit-fg-2\">Label</label>\n <Input id={labelId} size=\"sm\" autoFocus value={v.label ?? \"\"} onChange={(e) => onChange({ ...v, label: e.target.value })} onKeyDown={(e) => e.key === \"Enter\" && (e.preventDefault(), onSubmit?.())} placeholder=\"Shop cookware\" />\n </div>\n ) : null}\n <div className=\"flex flex-col gap-2.5\" role=\"group\" aria-label=\"Link\">\n <span className=\"text-kit-xs font-medium text-kit-fg-2\">Link</span>\n <LinkForm value={v} onChange={(n) => onChange({ ...v, ...n, label: v.label, style: v.style, variant: v.variant })} onEnter={() => onSubmit?.()} />\n </div>\n {styles ? (\n <div className=\"flex items-center justify-between gap-3 border-t border-kit-line pt-2.5\">\n <span className=\"text-kit-xs text-kit-fg-2\">Style</span>\n <Segmented size=\"sm\" aria-label=\"Button style\" value={v.style ?? \"primary\"} onChange={(s) => setStyle(s as ButtonStyle)} items={styles} />\n </div>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,cAAuD;CAClE;EAAE,OAAO;EAAW,OAAO;CAAU;CACrC;EAAE,OAAO;EAAa,OAAO;CAAY;CACzC;EAAE,OAAO;EAAW,OAAO;CAAU;CACrC;EAAE,OAAO;EAAQ,OAAO;CAAY;AACtC;AACA,IAAM,aAAa;CAAE,IAAI;CAAS,IAAI;CAAU,IAAI;AAAQ;AAC5D,IAAM,aAAa,MAA4B,OAAO,MAAM,YAAa,gBAAsC,SAAS,CAAC;;AAGzH,SAAgB,OAAO,GAA6D;CAClF,OAAO,CAAC,EAAE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,UAAD;KAAU,OAAO;KAAG,WAAW,MAAM,SAAS;MAAE,GAAG;MAAG,GAAG;MAAG,OAAO,EAAE;MAAO,OAAO,EAAE;MAAO,SAAS,EAAE;KAAQ,CAAC;KAAG,eAAe,WAAW;IAAI,CAAA,CAC9I;;GACJ,SACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAA4B,UAAA;IAAW,CAAA,GACvD,oBAAC,WAAD;KAAW,MAAK;KAAK,cAAW;KAAe,OAAO,EAAE,SAAS;KAAW,WAAW,MAAM,SAAS,CAAgB;KAAG,OAAO;IAAS,CAAA,CACtI;GACH,CAAA,IAAA;EACD;;AAET"}
@@ -366,6 +366,10 @@ var FEATURE_WORD = {
366
366
  function pastedHtml(html, dropImages) {
367
367
  const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
368
368
  doc.body.querySelectorAll("script,style,meta,link,title,iframe,object,embed,form,input,button,textarea,select,noscript,template").forEach((n) => n.remove());
369
+ const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_COMMENT);
370
+ const comments = [];
371
+ while (walker.nextNode()) comments.push(walker.currentNode);
372
+ comments.forEach((c) => c.parentNode?.removeChild(c));
369
373
  let images = 0;
370
374
  if (dropImages) doc.body.querySelectorAll("picture,figure,img").forEach((n) => {
371
375
  if (!n.isConnected) return;
@@ -1 +1 @@
1
- {"version":3,"file":"ops.js","names":[],"sources":["../../../src/controls/rich-text/ops.ts"],"sourcesContent":["/**\n * RICH TEXT · pure DOM block operations on the editor surface (V2 HEAD controls/rich-text/ops.ts; no React, no\n * emitting). The editor wraps each one, then serializes and emits the new value.\n */\nimport { closestBlock, cloneModel, createIsland, defaultModel, esc, placeCaret, textBeforeCaret, topBlock, type IslandEl, type IslandKind, type IslandModels } from \"./dom\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { BasicId } from \"./catalog\";\n\nconst emptyP = () => {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n return p;\n};\nconst isWritable = (el: Element | null): el is HTMLElement => !!el && !el.hasAttribute(\"data-rt-island\") && el.tagName !== \"HR\";\n\n/** The writable line after a block, created when the block is last or followed by another rich block. */\nexport function ensureLineAfter(b: Element): HTMLElement {\n const next = b.nextElementSibling;\n if (isWritable(next)) return next;\n const p = emptyP();\n b.after(p);\n return p;\n}\n\nexport function duplicateBlock(b: HTMLElement): HTMLElement {\n let c: HTMLElement;\n if (b.hasAttribute(\"data-rt-island\")) {\n const k = b.getAttribute(\"data-rt-island\") as IslandKind;\n c = createIsland(k, cloneModel(k, (b as IslandEl).__rt as never));\n } else {\n c = b.cloneNode(true) as HTMLElement;\n c.removeAttribute(\"data-hint\");\n }\n b.after(c);\n return c;\n}\n\n/** Moves a block one step, keeping the caret where it was. Returns false at the edge. */\nexport function moveBlock(b: HTMLElement, dir: -1 | 1): boolean {\n const sib = dir < 0 ? b.previousElementSibling : b.nextElementSibling;\n if (!sib) return false;\n const s = window.getSelection();\n // ranges are live (a move collapses them), so keep the raw caret position\n const at = s && s.rangeCount ? { n: s.getRangeAt(0).startContainer, o: s.getRangeAt(0).startOffset } : null;\n const host = document.activeElement as HTMLElement | null;\n if (dir < 0) sib.before(b);\n else sib.after(b);\n if (at && s && b.contains(at.n)) {\n host?.focus({ preventScroll: true });\n const r = document.createRange();\n r.setStart(at.n, Math.min(at.o, at.n.nodeType === 3 ? (at.n as Text).length : at.n.childNodes.length));\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n return true;\n}\n\n/** Text / Heading / Quote / Code. Returns the new element, or null when nothing changed. */\nexport function turnInto(root: HTMLElement, b: HTMLElement | null, tag: string): HTMLElement | null {\n if (!b || b.parentNode !== root || b.hasAttribute(\"data-rt-island\") || b.tagName === \"HR\") return null;\n if (b.tagName.toLowerCase() === tag) return null;\n const inner =\n b.tagName === \"UL\" || b.tagName === \"OL\"\n ? Array.from(b.children).map((c) => c.innerHTML).join(\"<br>\")\n : b.tagName === \"PRE\"\n ? esc(b.textContent ?? \"\").replace(/\\n/g, \"<br>\")\n : b.innerHTML;\n const n = document.createElement(tag);\n n.innerHTML = tag === \"pre\" ? esc((b.textContent ?? \"\").replace(/​/g, \"\")) || \"<br>\" : inner || \"<br>\";\n b.replaceWith(n);\n root.focus({ preventScroll: true });\n placeCaret(n);\n return n;\n}\n\n/** An empty paragraph at the caret to build a block from (reuses the current one when it is empty). */\nexport function takeEmptyBlock(root: HTMLElement): HTMLElement {\n const s = window.getSelection();\n const anchor = s && s.rangeCount && root.contains(s.anchorNode) ? s.anchorNode : null;\n const li = anchor ? closestBlock(root, anchor) : null;\n let b = topBlock(root, anchor);\n if (li && li.tagName === \"LI\" && !li.textContent?.trim()) {\n const list = li.parentElement!;\n li.remove();\n if (!list.children.length) {\n const p = emptyP();\n list.replaceWith(p);\n b = p;\n } else b = list;\n }\n root.focus({ preventScroll: true });\n if (b && b.tagName === \"P\" && !b.textContent?.replace(/​/g, \"\").trim() && !b.querySelector(\"img\")) {\n b.innerHTML = \"<br>\";\n placeCaret(b);\n return b;\n }\n // an empty heading, quote or code line (e.g. \"/\" typed on one) is reused too, so no empty block is left behind\n if (b && /^(H[1-6]|BLOCKQUOTE|PRE)$/.test(b.tagName) && !b.textContent?.replace(/​/g, \"\").trim()) {\n const p = emptyP();\n b.replaceWith(p);\n placeCaret(p);\n return p;\n }\n const p = emptyP();\n if (b) b.after(p);\n else root.append(p);\n placeCaret(p);\n return p;\n}\n\nexport function insertIsland<K extends IslandKind>(root: HTMLElement, kind: K, model: IslandModels[K] = defaultModel(kind)): IslandEl {\n const target = takeEmptyBlock(root);\n const isl = createIsland(kind, model);\n // A table of contents is built from the headings: nothing in it is typed first, so the caret goes on in the\n // paragraph after it (RP-054: it sat in the title, and the next \"/pull\" was typed into \"In this article\").\n isl.__rtFocus = kind !== \"toc\";\n target.before(isl);\n // keep the document tidy: reuse the line that already follows instead of leaving an empty one\n const next = target.nextElementSibling;\n if (isWritable(next)) {\n target.remove();\n placeCaret(next, false);\n } else placeCaret(target);\n return isl;\n}\n\n/** Inserts a basic block at the caret. */\nexport function insertBasic(root: HTMLElement, id: BasicId) {\n switch (id) {\n case \"p\":\n takeEmptyBlock(root);\n return;\n case \"h1\": case \"h2\": case \"h3\": case \"h4\": case \"h5\": case \"h6\":\n turnInto(root, takeEmptyBlock(root), id);\n return;\n case \"quote\":\n turnInto(root, takeEmptyBlock(root), \"blockquote\");\n return;\n case \"code\":\n turnInto(root, takeEmptyBlock(root), \"pre\");\n return;\n case \"ul\": case \"ol\": {\n const t = takeEmptyBlock(root);\n const l = document.createElement(id);\n l.innerHTML = \"<li><br></li>\";\n t.replaceWith(l);\n placeCaret(l.firstElementChild!);\n return;\n }\n case \"hr\": {\n const t = takeEmptyBlock(root);\n t.before(document.createElement(\"hr\"));\n placeCaret(t);\n return;\n }\n case \"image\": case \"table\": case \"pullquote\": case \"takeaways\": case \"callout\": case \"toggle\": case \"video\": case \"file\":\n case \"gallery\": case \"embed\": case \"toc\": case \"columns\": case \"related\": case \"author\":\n insertIsland(root, id);\n return;\n }\n}\n\n/**\n * \"# \", \"> \", \"- \", \"1. \" and \"---\" at the start of a paragraph, each only when the field accepts what it makes.\n * Returns true when it converted.\n */\nexport function liveMarkdown(root: HTMLElement, data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const blk = topBlock(root, s.anchorNode);\n if (!blk || blk.tagName !== \"P\") return false;\n const before = textBeforeCaret(blk)?.replace(/ /g, \" \");\n if (before == null) return false;\n if (data === \"-\" && before === \"---\" && (blk.textContent ?? \"\").replace(/ /g, \" \") === \"---\") {\n if (!allows(\"hr\")) return false;\n const p = emptyP();\n blk.replaceWith(document.createElement(\"hr\"), p);\n placeCaret(p);\n return true;\n }\n if (data !== \" \") return false;\n const h = before.match(/^(#{1,6}) $/);\n let tag = h ? `h${h[1].length}` : before === \"> \" ? \"blockquote\" : null;\n let list = before === \"- \" || before === \"* \" ? \"ul\" : /^1[.)] $/.test(before) ? \"ol\" : null;\n if (tag && !allows(tag as RichTextFeature)) tag = null;\n if (list && !allows(list as RichTextFeature)) list = null;\n if (!tag && !list) return false;\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n const html = blk.textContent || blk.querySelector(\"img\") ? blk.innerHTML : \"<br>\";\n let target: HTMLElement;\n if (tag) {\n target = document.createElement(tag);\n target.innerHTML = html;\n blk.replaceWith(target);\n } else {\n const l = document.createElement(list!);\n target = document.createElement(\"li\");\n target.innerHTML = html;\n l.append(target);\n blk.replaceWith(l);\n }\n placeCaret(target, false);\n return true;\n}\n\n/** `text` typed between backticks becomes inline code. */\nexport function liveInlineCode(): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const m = node.data.slice(0, r.startOffset).match(/`([^`\\n]+)`$/);\n if (!m) return false;\n wrapTypedRun(s, node, r.startOffset, m[0].length, \"code\", m[1]);\n return true;\n}\n\n/**\n * RT-030: `**text**` becomes bold and `*text*` / `_text_` italic, run as the closing marker is typed (as\n * `liveInlineCode` is for the backtick), each only where the field accepts the mark. The first closing `*` of a\n * `**bold**` being typed is not an italic (its run starts with another `*`), and `_` inside a word (`snake_case_`)\n * stays as typed. Nothing inside code converts.\n */\nexport function liveInlineEmphasis(data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n if (data !== \"*\" && data !== \"_\") return false;\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const before = node.data.slice(0, r.startOffset);\n const bold = data === \"*\" && allows(\"bold\") ? before.match(/\\*\\*([^*\\n]+)\\*\\*$/) : null;\n if (bold) {\n wrapTypedRun(s, node, r.startOffset, bold[0].length, \"strong\", bold[1]);\n return true;\n }\n if (!allows(\"italic\")) return false;\n const italic = data === \"*\" ? before.match(/(?:^|[^*])\\*([^*\\n]+)\\*$/) : before.match(/(?:^|[^\\w_])_([^_\\n]+)_$/);\n if (!italic) return false;\n // the match may start with the character before the opening marker: only the marked run is replaced\n const run = italic[0].replace(/^[^*_]/, \"\");\n wrapTypedRun(s, node, r.startOffset, run.length, \"em\", italic[1]);\n return true;\n}\n\n/* ── RT-028: list levels (Tab / Shift+Tab in a list item) ── */\n\n/**\n * Run `move` and put the caret back where it was. Moving a node takes the selection out of it, and a cloned Range is\n * live too (the DOM moves it to the old parent on removal), so the caret is kept as its plain node and offsets.\n */\nfunction keepingCaret(move: () => void): void {\n const s = window.getSelection();\n const at = s && s.rangeCount && s.anchorNode && s.focusNode ? [s.anchorNode, s.anchorOffset, s.focusNode, s.focusOffset] as const : null;\n move();\n if (s && at) s.setBaseAndExtent(at[0], at[1], at[2], at[3]);\n}\n\n/**\n * Tab: nest `li` one level deeper, under the item before it, in a list of the same kind (`ul` / `ol`). The\n * previous item's own nested list of that kind takes it when it has one. False (nothing moves) for the first item:\n * there is no item to nest under.\n */\nexport function indentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const prev = li.previousElementSibling as HTMLElement | null;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !prev || prev.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const last = prev.lastElementChild;\n const nested = last && last.tagName === list.tagName ? last : prev.appendChild(document.createElement(list.tagName.toLowerCase()));\n nested.append(li);\n });\n return true;\n}\n\n/**\n * Shift+Tab: bring a nested `li` up one level, right after the item that held it. The items after it in its list stay\n * after it, nested under it, so the reading order never changes; an emptied nested list goes. False for an item\n * already at the top level.\n */\nexport function outdentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const parentLi = list?.parentElement;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !parentLi || parentLi.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const after: Element[] = [];\n for (let n = li.nextElementSibling; n; n = n.nextElementSibling) after.push(n);\n if (after.length) {\n const own = li.lastElementChild && li.lastElementChild.tagName === list.tagName ? li.lastElementChild : li.appendChild(document.createElement(list.tagName.toLowerCase()));\n own.append(...after);\n }\n parentLi.after(li);\n if (!list.children.length) list.remove();\n });\n return true;\n}\n\n/** Replace the `length` characters typed before `end` in `node` with `<tag>text</tag>`, the caret after it. */\nfunction wrapTypedRun(s: Selection, node: Text, end: number, length: number, tag: \"code\" | \"strong\" | \"em\", text: string): void {\n const del = document.createRange();\n del.setStart(node, end - length);\n del.setEnd(node, end);\n del.deleteContents();\n const el = document.createElement(tag);\n el.textContent = text;\n del.insertNode(el);\n const next = el.nextSibling;\n if (next && next.nodeType === 3 && next.textContent) {\n const c = document.createRange();\n c.setStart(next, 0);\n c.collapse(true);\n s.removeAllRanges();\n s.addRange(c);\n } else {\n const after = document.createTextNode(\"​\");\n el.after(after);\n placeCaret(after);\n }\n}\n\n/* ── What a field accepts, applied to HTML that arrives from outside (paste, Markdown) ── */\nconst MARK_FEATURE: Record<string, RichTextFeature> = {\n STRONG: \"bold\", B: \"bold\", EM: \"italic\", I: \"italic\", U: \"underline\", S: \"strike\", STRIKE: \"strike\", DEL: \"strike\", CODE: \"code\", A: \"link\",\n};\nconst BLOCK_FEATURE: Record<string, RichTextFeature> = {\n H1: \"h1\", H2: \"h2\", H3: \"h3\", H4: \"h4\", H5: \"h5\", H6: \"h6\", BLOCKQUOTE: \"blockquote\", UL: \"ul\", OL: \"ol\", PRE: \"pre\", HR: \"hr\", FIGURE: \"image\", IMG: \"image\",\n};\nconst FEATURE_WORD: Partial<Record<RichTextFeature, string>> = {\n image: \"images\", hr: \"dividers\", pre: \"code blocks\", ul: \"bulleted lists\", ol: \"numbered lists\", blockquote: \"quotes\", link: \"links\",\n};\n\n/**\n * HTML with every element the field does not accept turned into what it does: a heading / quote / code block becomes a\n * paragraph, a list becomes one paragraph per item, a mark or link is unwrapped to its text, a divider or image is\n * removed. `dropped` names what was taken out entirely (said to the author, never silent).\n */\n/**\n * RT-016: HTML from another page as this editor takes it, before `restrictHtml` keeps it to the field. Classes, inline\n * styles and ids are the source page's look, not content: only a link's address is kept. A wrapper that is only styling\n * (a span, a font, Google Docs' `<b style=\"font-weight:normal\">` around a whole paste) is unwrapped to its contents. A\n * picture is taken out when `dropImages` (the field holds images, but a pasted address is not a media-library image);\n * otherwise it is left for `restrictHtml`, which removes it and says so. `images` counts what was taken out here.\n */\nexport function pastedHtml(html: string, dropImages: boolean): { html: string; images: number } {\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,meta,link,title,iframe,object,embed,form,input,button,textarea,select,noscript,template\").forEach((n) => n.remove());\n let images = 0;\n if (dropImages) {\n doc.body.querySelectorAll(\"picture,figure,img\").forEach((n) => {\n if (!n.isConnected) return;\n if (n.tagName === \"IMG\" || n.querySelector(\"img\")) images++;\n n.remove();\n });\n }\n for (const el of Array.from(doc.body.querySelectorAll(\"*\")).reverse()) {\n if (el.tagName === \"SPAN\" || el.tagName === \"FONT\" || ((el.tagName === \"B\" || el.tagName === \"STRONG\") && /font-weight\\s*:\\s*(normal|400)/i.test(el.getAttribute(\"style\") ?? \"\"))) {\n // RT-015: Google Docs writes bold / italic / underline / strike as a span's inline style, not a tag.\n const style = el.tagName === \"SPAN\" ? (el.getAttribute(\"style\") ?? \"\") : \"\";\n let inner: Node[] = Array.from(el.childNodes);\n const wrap = (tag: string) => {\n const w = doc.createElement(tag);\n w.append(...inner);\n inner = [w];\n };\n if (/font-weight\\s*:\\s*(bold|[6-9]00)/i.test(style)) wrap(\"strong\");\n if (/font-style\\s*:\\s*italic/i.test(style)) wrap(\"em\");\n if (/text-decoration[^;]*underline/i.test(style)) wrap(\"u\");\n if (/text-decoration[^;]*line-through/i.test(style)) wrap(\"s\");\n el.replaceWith(...inner);\n continue;\n }\n for (const a of Array.from(el.attributes)) {\n const keep = (el.tagName === \"A\" && a.name === \"href\") || (el.tagName === \"IMG\" && (a.name === \"src\" || a.name === \"alt\"));\n if (!keep) el.removeAttribute(a.name);\n }\n }\n return { html: doc.body.innerHTML.trim(), images };\n}\n\nexport function restrictHtml(html: string, allows: (f: RichTextFeature) => boolean): { html: string; dropped: string[] } {\n if (!html) return { html, dropped: [] };\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n const dropped = new Set<string>();\n const walk = (el: Element) => {\n for (const ch of Array.from(el.children)) {\n walk(ch);\n const mark = MARK_FEATURE[ch.tagName];\n const block = BLOCK_FEATURE[ch.tagName];\n if (mark && !allows(mark)) ch.replaceWith(...Array.from(ch.childNodes));\n else if (block && !allows(block)) {\n if (block === \"hr\" || block === \"image\") {\n dropped.add(FEATURE_WORD[block]!);\n ch.remove();\n } else if (block === \"ul\" || block === \"ol\") {\n const ps = Array.from(ch.children).map((li) => {\n const p = doc.createElement(\"p\");\n p.innerHTML = li.innerHTML;\n return p;\n });\n ch.replaceWith(...ps);\n } else {\n const p = doc.createElement(\"p\");\n p.innerHTML = block === \"pre\" ? esc(ch.textContent ?? \"\").replace(/\\n/g, \"<br>\") : ch.innerHTML;\n ch.replaceWith(p);\n }\n }\n }\n };\n walk(doc.body);\n return { html: doc.body.innerHTML, dropped: [...dropped] };\n}\n"],"mappings":";;;;;;AAQA,IAAM,eAAe;CACnB,MAAM,IAAI,SAAS,cAAc,GAAG;CACpC,EAAE,YAAY;CACd,OAAO;AACT;AACA,IAAM,cAAc,OAA0C,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa,gBAAgB,KAAK,GAAG,YAAY;;AAG3H,SAAgB,gBAAgB,GAAyB;CACvD,MAAM,OAAO,EAAE;CACf,IAAI,WAAW,IAAI,GAAG,OAAO;CAC7B,MAAM,IAAI,OAAO;CACjB,EAAE,MAAM,CAAC;CACT,OAAO;AACT;AAEA,SA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ACtF,GAAG,YAAY,CAAC;IAClB;GACF;EACF;CACF;CACA,KAAK,IAAI,IAAI;CACb,OAAO;EAAE,MAAM,IAAI,KAAK;EAAW,SAAS,CAAC,GAAG,OAAO;CAAE;AAC3D"}
1
+ {"version":3,"file":"ops.js","names":[],"sources":["../../../src/controls/rich-text/ops.ts"],"sourcesContent":["/**\n * RICH TEXT · pure DOM block operations on the editor surface (V2 HEAD controls/rich-text/ops.ts; no React, no\n * emitting). The editor wraps each one, then serializes and emits the new value.\n */\nimport { closestBlock, cloneModel, createIsland, defaultModel, esc, placeCaret, textBeforeCaret, topBlock, type IslandEl, type IslandKind, type IslandModels } from \"./dom\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { BasicId } from \"./catalog\";\n\nconst emptyP = () => {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n return p;\n};\nconst isWritable = (el: Element | null): el is HTMLElement => !!el && !el.hasAttribute(\"data-rt-island\") && el.tagName !== \"HR\";\n\n/** The writable line after a block, created when the block is last or followed by another rich block. */\nexport function ensureLineAfter(b: Element): HTMLElement {\n const next = b.nextElementSibling;\n if (isWritable(next)) return next;\n const p = emptyP();\n b.after(p);\n return p;\n}\n\nexport function duplicateBlock(b: HTMLElement): HTMLElement {\n let c: HTMLElement;\n if (b.hasAttribute(\"data-rt-island\")) {\n const k = b.getAttribute(\"data-rt-island\") as IslandKind;\n c = createIsland(k, cloneModel(k, (b as IslandEl).__rt as never));\n } else {\n c = b.cloneNode(true) as HTMLElement;\n c.removeAttribute(\"data-hint\");\n }\n b.after(c);\n return c;\n}\n\n/** Moves a block one step, keeping the caret where it was. Returns false at the edge. */\nexport function moveBlock(b: HTMLElement, dir: -1 | 1): boolean {\n const sib = dir < 0 ? b.previousElementSibling : b.nextElementSibling;\n if (!sib) return false;\n const s = window.getSelection();\n // ranges are live (a move collapses them), so keep the raw caret position\n const at = s && s.rangeCount ? { n: s.getRangeAt(0).startContainer, o: s.getRangeAt(0).startOffset } : null;\n const host = document.activeElement as HTMLElement | null;\n if (dir < 0) sib.before(b);\n else sib.after(b);\n if (at && s && b.contains(at.n)) {\n host?.focus({ preventScroll: true });\n const r = document.createRange();\n r.setStart(at.n, Math.min(at.o, at.n.nodeType === 3 ? (at.n as Text).length : at.n.childNodes.length));\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n return true;\n}\n\n/** Text / Heading / Quote / Code. Returns the new element, or null when nothing changed. */\nexport function turnInto(root: HTMLElement, b: HTMLElement | null, tag: string): HTMLElement | null {\n if (!b || b.parentNode !== root || b.hasAttribute(\"data-rt-island\") || b.tagName === \"HR\") return null;\n if (b.tagName.toLowerCase() === tag) return null;\n const inner =\n b.tagName === \"UL\" || b.tagName === \"OL\"\n ? Array.from(b.children).map((c) => c.innerHTML).join(\"<br>\")\n : b.tagName === \"PRE\"\n ? esc(b.textContent ?? \"\").replace(/\\n/g, \"<br>\")\n : b.innerHTML;\n const n = document.createElement(tag);\n n.innerHTML = tag === \"pre\" ? esc((b.textContent ?? \"\").replace(/​/g, \"\")) || \"<br>\" : inner || \"<br>\";\n b.replaceWith(n);\n root.focus({ preventScroll: true });\n placeCaret(n);\n return n;\n}\n\n/** An empty paragraph at the caret to build a block from (reuses the current one when it is empty). */\nexport function takeEmptyBlock(root: HTMLElement): HTMLElement {\n const s = window.getSelection();\n const anchor = s && s.rangeCount && root.contains(s.anchorNode) ? s.anchorNode : null;\n const li = anchor ? closestBlock(root, anchor) : null;\n let b = topBlock(root, anchor);\n if (li && li.tagName === \"LI\" && !li.textContent?.trim()) {\n const list = li.parentElement!;\n li.remove();\n if (!list.children.length) {\n const p = emptyP();\n list.replaceWith(p);\n b = p;\n } else b = list;\n }\n root.focus({ preventScroll: true });\n if (b && b.tagName === \"P\" && !b.textContent?.replace(/​/g, \"\").trim() && !b.querySelector(\"img\")) {\n b.innerHTML = \"<br>\";\n placeCaret(b);\n return b;\n }\n // an empty heading, quote or code line (e.g. \"/\" typed on one) is reused too, so no empty block is left behind\n if (b && /^(H[1-6]|BLOCKQUOTE|PRE)$/.test(b.tagName) && !b.textContent?.replace(/​/g, \"\").trim()) {\n const p = emptyP();\n b.replaceWith(p);\n placeCaret(p);\n return p;\n }\n const p = emptyP();\n if (b) b.after(p);\n else root.append(p);\n placeCaret(p);\n return p;\n}\n\nexport function insertIsland<K extends IslandKind>(root: HTMLElement, kind: K, model: IslandModels[K] = defaultModel(kind)): IslandEl {\n const target = takeEmptyBlock(root);\n const isl = createIsland(kind, model);\n // A table of contents is built from the headings: nothing in it is typed first, so the caret goes on in the\n // paragraph after it (RP-054: it sat in the title, and the next \"/pull\" was typed into \"In this article\").\n isl.__rtFocus = kind !== \"toc\";\n target.before(isl);\n // keep the document tidy: reuse the line that already follows instead of leaving an empty one\n const next = target.nextElementSibling;\n if (isWritable(next)) {\n target.remove();\n placeCaret(next, false);\n } else placeCaret(target);\n return isl;\n}\n\n/** Inserts a basic block at the caret. */\nexport function insertBasic(root: HTMLElement, id: BasicId) {\n switch (id) {\n case \"p\":\n takeEmptyBlock(root);\n return;\n case \"h1\": case \"h2\": case \"h3\": case \"h4\": case \"h5\": case \"h6\":\n turnInto(root, takeEmptyBlock(root), id);\n return;\n case \"quote\":\n turnInto(root, takeEmptyBlock(root), \"blockquote\");\n return;\n case \"code\":\n turnInto(root, takeEmptyBlock(root), \"pre\");\n return;\n case \"ul\": case \"ol\": {\n const t = takeEmptyBlock(root);\n const l = document.createElement(id);\n l.innerHTML = \"<li><br></li>\";\n t.replaceWith(l);\n placeCaret(l.firstElementChild!);\n return;\n }\n case \"hr\": {\n const t = takeEmptyBlock(root);\n t.before(document.createElement(\"hr\"));\n placeCaret(t);\n return;\n }\n case \"image\": case \"table\": case \"pullquote\": case \"takeaways\": case \"callout\": case \"toggle\": case \"video\": case \"file\":\n case \"gallery\": case \"embed\": case \"toc\": case \"columns\": case \"related\": case \"author\":\n insertIsland(root, id);\n return;\n }\n}\n\n/**\n * \"# \", \"> \", \"- \", \"1. \" and \"---\" at the start of a paragraph, each only when the field accepts what it makes.\n * Returns true when it converted.\n */\nexport function liveMarkdown(root: HTMLElement, data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const blk = topBlock(root, s.anchorNode);\n if (!blk || blk.tagName !== \"P\") return false;\n const before = textBeforeCaret(blk)?.replace(/ /g, \" \");\n if (before == null) return false;\n if (data === \"-\" && before === \"---\" && (blk.textContent ?? \"\").replace(/ /g, \" \") === \"---\") {\n if (!allows(\"hr\")) return false;\n const p = emptyP();\n blk.replaceWith(document.createElement(\"hr\"), p);\n placeCaret(p);\n return true;\n }\n if (data !== \" \") return false;\n const h = before.match(/^(#{1,6}) $/);\n let tag = h ? `h${h[1].length}` : before === \"> \" ? \"blockquote\" : null;\n let list = before === \"- \" || before === \"* \" ? \"ul\" : /^1[.)] $/.test(before) ? \"ol\" : null;\n if (tag && !allows(tag as RichTextFeature)) tag = null;\n if (list && !allows(list as RichTextFeature)) list = null;\n if (!tag && !list) return false;\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n const html = blk.textContent || blk.querySelector(\"img\") ? blk.innerHTML : \"<br>\";\n let target: HTMLElement;\n if (tag) {\n target = document.createElement(tag);\n target.innerHTML = html;\n blk.replaceWith(target);\n } else {\n const l = document.createElement(list!);\n target = document.createElement(\"li\");\n target.innerHTML = html;\n l.append(target);\n blk.replaceWith(l);\n }\n placeCaret(target, false);\n return true;\n}\n\n/** `text` typed between backticks becomes inline code. */\nexport function liveInlineCode(): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const m = node.data.slice(0, r.startOffset).match(/`([^`\\n]+)`$/);\n if (!m) return false;\n wrapTypedRun(s, node, r.startOffset, m[0].length, \"code\", m[1]);\n return true;\n}\n\n/**\n * RT-030: `**text**` becomes bold and `*text*` / `_text_` italic, run as the closing marker is typed (as\n * `liveInlineCode` is for the backtick), each only where the field accepts the mark. The first closing `*` of a\n * `**bold**` being typed is not an italic (its run starts with another `*`), and `_` inside a word (`snake_case_`)\n * stays as typed. Nothing inside code converts.\n */\nexport function liveInlineEmphasis(data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n if (data !== \"*\" && data !== \"_\") return false;\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const before = node.data.slice(0, r.startOffset);\n const bold = data === \"*\" && allows(\"bold\") ? before.match(/\\*\\*([^*\\n]+)\\*\\*$/) : null;\n if (bold) {\n wrapTypedRun(s, node, r.startOffset, bold[0].length, \"strong\", bold[1]);\n return true;\n }\n if (!allows(\"italic\")) return false;\n const italic = data === \"*\" ? before.match(/(?:^|[^*])\\*([^*\\n]+)\\*$/) : before.match(/(?:^|[^\\w_])_([^_\\n]+)_$/);\n if (!italic) return false;\n // the match may start with the character before the opening marker: only the marked run is replaced\n const run = italic[0].replace(/^[^*_]/, \"\");\n wrapTypedRun(s, node, r.startOffset, run.length, \"em\", italic[1]);\n return true;\n}\n\n/* ── RT-028: list levels (Tab / Shift+Tab in a list item) ── */\n\n/**\n * Run `move` and put the caret back where it was. Moving a node takes the selection out of it, and a cloned Range is\n * live too (the DOM moves it to the old parent on removal), so the caret is kept as its plain node and offsets.\n */\nfunction keepingCaret(move: () => void): void {\n const s = window.getSelection();\n const at = s && s.rangeCount && s.anchorNode && s.focusNode ? [s.anchorNode, s.anchorOffset, s.focusNode, s.focusOffset] as const : null;\n move();\n if (s && at) s.setBaseAndExtent(at[0], at[1], at[2], at[3]);\n}\n\n/**\n * Tab: nest `li` one level deeper, under the item before it, in a list of the same kind (`ul` / `ol`). The\n * previous item's own nested list of that kind takes it when it has one. False (nothing moves) for the first item:\n * there is no item to nest under.\n */\nexport function indentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const prev = li.previousElementSibling as HTMLElement | null;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !prev || prev.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const last = prev.lastElementChild;\n const nested = last && last.tagName === list.tagName ? last : prev.appendChild(document.createElement(list.tagName.toLowerCase()));\n nested.append(li);\n });\n return true;\n}\n\n/**\n * Shift+Tab: bring a nested `li` up one level, right after the item that held it. The items after it in its list stay\n * after it, nested under it, so the reading order never changes; an emptied nested list goes. False for an item\n * already at the top level.\n */\nexport function outdentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const parentLi = list?.parentElement;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !parentLi || parentLi.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const after: Element[] = [];\n for (let n = li.nextElementSibling; n; n = n.nextElementSibling) after.push(n);\n if (after.length) {\n const own = li.lastElementChild && li.lastElementChild.tagName === list.tagName ? li.lastElementChild : li.appendChild(document.createElement(list.tagName.toLowerCase()));\n own.append(...after);\n }\n parentLi.after(li);\n if (!list.children.length) list.remove();\n });\n return true;\n}\n\n/** Replace the `length` characters typed before `end` in `node` with `<tag>text</tag>`, the caret after it. */\nfunction wrapTypedRun(s: Selection, node: Text, end: number, length: number, tag: \"code\" | \"strong\" | \"em\", text: string): void {\n const del = document.createRange();\n del.setStart(node, end - length);\n del.setEnd(node, end);\n del.deleteContents();\n const el = document.createElement(tag);\n el.textContent = text;\n del.insertNode(el);\n const next = el.nextSibling;\n if (next && next.nodeType === 3 && next.textContent) {\n const c = document.createRange();\n c.setStart(next, 0);\n c.collapse(true);\n s.removeAllRanges();\n s.addRange(c);\n } else {\n const after = document.createTextNode(\"​\");\n el.after(after);\n placeCaret(after);\n }\n}\n\n/* ── What a field accepts, applied to HTML that arrives from outside (paste, Markdown) ── */\nconst MARK_FEATURE: Record<string, RichTextFeature> = {\n STRONG: \"bold\", B: \"bold\", EM: \"italic\", I: \"italic\", U: \"underline\", S: \"strike\", STRIKE: \"strike\", DEL: \"strike\", CODE: \"code\", A: \"link\",\n};\nconst BLOCK_FEATURE: Record<string, RichTextFeature> = {\n H1: \"h1\", H2: \"h2\", H3: \"h3\", H4: \"h4\", H5: \"h5\", H6: \"h6\", BLOCKQUOTE: \"blockquote\", UL: \"ul\", OL: \"ol\", PRE: \"pre\", HR: \"hr\", FIGURE: \"image\", IMG: \"image\",\n};\nconst FEATURE_WORD: Partial<Record<RichTextFeature, string>> = {\n image: \"images\", hr: \"dividers\", pre: \"code blocks\", ul: \"bulleted lists\", ol: \"numbered lists\", blockquote: \"quotes\", link: \"links\",\n};\n\n/**\n * HTML with every element the field does not accept turned into what it does: a heading / quote / code block becomes a\n * paragraph, a list becomes one paragraph per item, a mark or link is unwrapped to its text, a divider or image is\n * removed. `dropped` names what was taken out entirely (said to the author, never silent).\n */\n/**\n * RT-016: HTML from another page as this editor takes it, before `restrictHtml` keeps it to the field. Classes, inline\n * styles and ids are the source page's look, not content: only a link's address is kept. A wrapper that is only styling\n * (a span, a font, Google Docs' `<b style=\"font-weight:normal\">` around a whole paste) is unwrapped to its contents. A\n * picture is taken out when `dropImages` (the field holds images, but a pasted address is not a media-library image);\n * otherwise it is left for `restrictHtml`, which removes it and says so. `images` counts what was taken out here.\n */\nexport function pastedHtml(html: string, dropImages: boolean): { html: string; images: number } {\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,meta,link,title,iframe,object,embed,form,input,button,textarea,select,noscript,template\").forEach((n) => n.remove());\n // the Windows clipboard wraps a paste in <!--StartFragment--> / <!--EndFragment--> comments: never content\n const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_COMMENT);\n const comments: Node[] = [];\n while (walker.nextNode()) comments.push(walker.currentNode);\n comments.forEach((c) => c.parentNode?.removeChild(c));\n let images = 0;\n if (dropImages) {\n doc.body.querySelectorAll(\"picture,figure,img\").forEach((n) => {\n if (!n.isConnected) return;\n if (n.tagName === \"IMG\" || n.querySelector(\"img\")) images++;\n n.remove();\n });\n }\n for (const el of Array.from(doc.body.querySelectorAll(\"*\")).reverse()) {\n if (el.tagName === \"SPAN\" || el.tagName === \"FONT\" || ((el.tagName === \"B\" || el.tagName === \"STRONG\") && /font-weight\\s*:\\s*(normal|400)/i.test(el.getAttribute(\"style\") ?? \"\"))) {\n // RT-015: Google Docs writes bold / italic / underline / strike as a span's inline style, not a tag.\n const style = el.tagName === \"SPAN\" ? (el.getAttribute(\"style\") ?? \"\") : \"\";\n let inner: Node[] = Array.from(el.childNodes);\n const wrap = (tag: string) => {\n const w = doc.createElement(tag);\n w.append(...inner);\n inner = [w];\n };\n if (/font-weight\\s*:\\s*(bold|[6-9]00)/i.test(style)) wrap(\"strong\");\n if (/font-style\\s*:\\s*italic/i.test(style)) wrap(\"em\");\n if (/text-decoration[^;]*underline/i.test(style)) wrap(\"u\");\n if (/text-decoration[^;]*line-through/i.test(style)) wrap(\"s\");\n el.replaceWith(...inner);\n continue;\n }\n for (const a of Array.from(el.attributes)) {\n const keep = (el.tagName === \"A\" && a.name === \"href\") || (el.tagName === \"IMG\" && (a.name === \"src\" || a.name === \"alt\"));\n if (!keep) el.removeAttribute(a.name);\n }\n }\n return { html: doc.body.innerHTML.trim(), images };\n}\n\nexport function restrictHtml(html: string, allows: (f: RichTextFeature) => boolean): { html: string; dropped: string[] } {\n if (!html) return { html, dropped: [] };\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n const dropped = new Set<string>();\n const walk = (el: Element) => {\n for (const ch of Array.from(el.children)) {\n walk(ch);\n const mark = MARK_FEATURE[ch.tagName];\n const block = BLOCK_FEATURE[ch.tagName];\n if (mark && !allows(mark)) ch.replaceWith(...Array.from(ch.childNodes));\n else if (block && !allows(block)) {\n if (block === \"hr\" || block === \"image\") {\n dropped.add(FEATURE_WORD[block]!);\n ch.remove();\n } else if (block === \"ul\" || block === \"ol\") {\n const ps = Array.from(ch.children).map((li) => {\n const p = doc.createElement(\"p\");\n p.innerHTML = li.innerHTML;\n return p;\n });\n ch.replaceWith(...ps);\n } else {\n const p = doc.createElement(\"p\");\n p.innerHTML = block === \"pre\" ? esc(ch.textContent ?? \"\").replace(/\\n/g, \"<br>\") : ch.innerHTML;\n ch.replaceWith(p);\n }\n }\n }\n };\n walk(doc.body);\n return { html: doc.body.innerHTML, dropped: [...dropped] };\n}\n"],"mappings":";;;;;;AAQA,IAAM,eAAe;CACnB,MAAM,IAAI,SAAS,cAAc,GAAG;CACpC,EAAE,YAAY;CACd,OAAO;AACT;AACA,IAAM,cAAc,OAA0C,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa,gBAAgB,KAAK,GAAG,YAAY;;AAG3H,SAAgB,gBAAgB,GAAyB;CACvD,MAAM,OAAO,EAAE;CACf,IAAI,WAAW,IAAI,GAAG,OAAO;CAC7B,MAAM,IAAI,OAAO;CACjB,EAAE,MAAM,CAAC;CACT,OAAO;AACT;AAEA,SAAgB,eAAe,GAA6B;CAC1D,IAAI;CACJ,IAAI,EAAE,aAAa,gBAAgB,GAAG;EACpC,MAAM,IAAI,EAAE,aAAa,gBAAgB;EACzC,IAAI,aAAa,GAAG,WAAW,GAAI,EAAe,IAAa,CAAC;CAClE,OAAO;EACL,IAAI,EAAE,UAAU,IAAI;EACpB,EAAE,gBAAgB,WAAW;CAC/B;CACA,EAAE,MAAM,CAAC;CACT,OAAO;AACT;;AAGA,SAAgB,UAAU,GAAgB,KAAsB;CAC9D,MAAM,MAAM,MAAM,IAAI,EAAE,yBAAyB,EAAE;CACnD,IAAI,CAAC,KAAK,OAAO;CACjB,MAAM,IAAI,OAAO,aAAa;CAE9B,MAAM,KAAK,KAAK,EAAE,aAAa;EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;EAAgB,GAAG,EAAE,WAAW,CAAC,CAA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AAM,SAAS,CAAC;CAAE;CACtC,MAAM,MAAM,IAAI,UAAU,CAAC,CAAC,gBAAgB,SAAS,KAAK,UAAU,WAAW;CAC/E,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,OAAgB;EAC5B,KAAK,MAAM,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG;GACxC,KAAK,EAAE;GACP,MAAM,OAAO,aAAa,GAAG;GAC7B,MAAM,QAAQ,cAAc,GAAG;GAC/B,IAAI,QAAQ,CAAC,OAAO,IAAI,GAAG,GAAG,YAAY,GAAG,MAAM,KAAK,GAAG,UAAU,CAAC;QACjE,IAAI,SAAS,CAAC,OAAO,KAAK,GAAG;IAChC,IAAI,UAAU,QAAQ,UAAU,SAAS;KACvC,QAAQ,IAAI,aAAa,MAAO;KAChC,GAAG,OAAO;IACZ,OAAO,IAAI,UAAU,QAAQ,UAAU,MAAM;KAC3C,MAAM,KAAK,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,KAAK,OAAO;MAC7C,MAAM,IAAI,IAAI,cAAc,GAAG;MAC/B,EAAE,YAAY,GAAG;MACjB,OAAO;KACT,CAAC;KACD,GAAG,YAAY,GAAG,EAAE;IACtB,OAAO;KACL,MAAM,IAAI,IAAI,cAAc,GAAG;KAC/B,EAAE,YAAY,UAAU,QAAQ,IAAI,GAAG,eAAe,EAAE,CAAC,CAAC,QAAQ,OAAO,MAAM,IAAI,GAAG;KACtF,GAAG,YAAY,CAAC;IAClB;GACF;EACF;CACF;CACA,KAAK,IAAI,IAAI;CACb,OAAO;EAAE,MAAM,IAAI,KAAK;EAAW,SAAS,CAAC,GAAG,OAAO;CAAE;AAC3D"}
@@ -445,7 +445,12 @@ var ENTRIES = [
445
445
  title: "Consent wording",
446
446
  type: "richtext",
447
447
  group: "form",
448
- validation: { required: true }
448
+ validation: { required: true },
449
+ features: [
450
+ "bold",
451
+ "italic",
452
+ "link"
453
+ ]
449
454
  },
450
455
  {
451
456
  name: "successMessage",