@bettercms-ai/kit 3.2.0 → 4.1.1

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 (135) hide show
  1. package/dist/adapters/lossy.d.ts +4 -0
  2. package/dist/adapters/lossy.js +4 -0
  3. package/dist/adapters/lossy.js.map +1 -1
  4. package/dist/adapters/prod-types.d.ts +4 -0
  5. package/dist/adapters/prod-types.js +4 -1
  6. package/dist/adapters/prod-types.js.map +1 -1
  7. package/dist/adapters/schema.js +7 -0
  8. package/dist/adapters/schema.js.map +1 -1
  9. package/dist/context.d.ts +81 -4
  10. package/dist/context.js +58 -1
  11. package/dist/context.js.map +1 -1
  12. package/dist/controls/choice.d.ts +1 -1
  13. package/dist/controls/choice.js +21 -2
  14. package/dist/controls/choice.js.map +1 -1
  15. package/dist/controls/index.d.ts +1 -0
  16. package/dist/controls/index.js +3 -2
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.d.ts +23 -2
  19. package/dist/controls/link.js +456 -4
  20. package/dist/controls/link.js.map +1 -1
  21. package/dist/controls/media-v16.d.ts +27 -0
  22. package/dist/controls/media-v16.js +261 -0
  23. package/dist/controls/media-v16.js.map +1 -0
  24. package/dist/controls/media.js +63 -1
  25. package/dist/controls/media.js.map +1 -1
  26. package/dist/controls/reference-services.d.ts +8 -0
  27. package/dist/controls/reference.js +78 -2
  28. package/dist/controls/reference.js.map +1 -1
  29. package/dist/controls/rich-text/ai-runs.d.ts +13 -0
  30. package/dist/controls/rich-text/ai-runs.js +71 -0
  31. package/dist/controls/rich-text/ai-runs.js.map +1 -0
  32. package/dist/controls/rich-text/block-tool.d.ts +31 -0
  33. package/dist/controls/rich-text/block-tool.js +62 -0
  34. package/dist/controls/rich-text/block-tool.js.map +1 -0
  35. package/dist/controls/rich-text/blocks.d.ts +6 -1
  36. package/dist/controls/rich-text/blocks.js +404 -24
  37. package/dist/controls/rich-text/blocks.js.map +1 -1
  38. package/dist/controls/rich-text/catalog.d.ts +21 -6
  39. package/dist/controls/rich-text/catalog.js +312 -23
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/code-head.d.ts +30 -0
  42. package/dist/controls/rich-text/code-head.js +230 -0
  43. package/dist/controls/rich-text/code-head.js.map +1 -0
  44. package/dist/controls/rich-text/codec.d.ts +3 -3
  45. package/dist/controls/rich-text/codec.js +3 -1
  46. package/dist/controls/rich-text/codec.js.map +1 -1
  47. package/dist/controls/rich-text/control.d.ts +1 -1
  48. package/dist/controls/rich-text/control.js +11 -29
  49. package/dist/controls/rich-text/control.js.map +1 -1
  50. package/dist/controls/rich-text/dom.d.ts +27 -0
  51. package/dist/controls/rich-text/dom.js +69 -4
  52. package/dist/controls/rich-text/dom.js.map +1 -1
  53. package/dist/controls/rich-text/editor.js +212 -50
  54. package/dist/controls/rich-text/editor.js.map +1 -1
  55. package/dist/controls/rich-text/ops.js +1 -0
  56. package/dist/controls/rich-text/ops.js.map +1 -1
  57. package/dist/controls/rich-text/slash-preview.d.ts +8 -0
  58. package/dist/controls/rich-text/slash-preview.js +287 -0
  59. package/dist/controls/rich-text/slash-preview.js.map +1 -0
  60. package/dist/controls/rich-text/table-grid.d.ts +22 -0
  61. package/dist/controls/rich-text/table-grid.js +1052 -0
  62. package/dist/controls/rich-text/table-grid.js.map +1 -0
  63. package/dist/controls/rich-text/toolbar.js +60 -18
  64. package/dist/controls/rich-text/toolbar.js.map +1 -1
  65. package/dist/controls/text.d.ts +6 -0
  66. package/dist/controls/text.js +95 -5
  67. package/dist/controls/text.js.map +1 -1
  68. package/dist/core/facets.d.ts +1 -0
  69. package/dist/core/facets.js +1 -0
  70. package/dist/core/facets.js.map +1 -1
  71. package/dist/engine/array.d.ts +7 -0
  72. package/dist/engine/array.js +164 -45
  73. package/dist/engine/array.js.map +1 -1
  74. package/dist/engine/expand.d.ts +1 -1
  75. package/dist/engine/expand.js +1 -1
  76. package/dist/engine/expand.js.map +1 -1
  77. package/dist/engine/field-shell.d.ts +12 -0
  78. package/dist/engine/field-shell.js +217 -63
  79. package/dist/engine/field-shell.js.map +1 -1
  80. package/dist/engine/frame.js +39 -2
  81. package/dist/engine/frame.js.map +1 -1
  82. package/dist/engine/grouping.d.ts +71 -10
  83. package/dist/engine/grouping.js +223 -26
  84. package/dist/engine/grouping.js.map +1 -1
  85. package/dist/engine/held.d.ts +2 -2
  86. package/dist/engine/held.js +2 -2
  87. package/dist/engine/held.js.map +1 -1
  88. package/dist/engine/kit-field.d.ts +0 -10
  89. package/dist/engine/kit-field.js +40 -72
  90. package/dist/engine/kit-field.js.map +1 -1
  91. package/dist/engine/schema-form.js +7 -2
  92. package/dist/engine/schema-form.js.map +1 -1
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +14 -7
  95. package/dist/index.js.map +1 -1
  96. package/dist/kit.css +85 -0
  97. package/dist/schema/table.d.ts +2 -1
  98. package/dist/schema/table.js +5 -0
  99. package/dist/schema/table.js.map +1 -1
  100. package/dist/schema/types.d.ts +6 -0
  101. package/dist/schema/types.js.map +1 -1
  102. package/dist/styles.css +1 -1
  103. package/dist/theme.css +115 -0
  104. package/dist/tokens.css +268 -0
  105. package/dist/ui/block-icon-picker.d.ts +38 -0
  106. package/dist/ui/block-icon-picker.js +141 -0
  107. package/dist/ui/block-icon-picker.js.map +1 -0
  108. package/dist/ui/button.js +1 -0
  109. package/dist/ui/button.js.map +1 -1
  110. package/dist/ui/code-language-menu.d.ts +24 -0
  111. package/dist/ui/code-language-menu.js +123 -0
  112. package/dist/ui/code-language-menu.js.map +1 -0
  113. package/dist/ui/content-fields.d.ts +47 -0
  114. package/dist/ui/content-fields.js +278 -0
  115. package/dist/ui/content-fields.js.map +1 -0
  116. package/dist/ui/foundations.d.ts +118 -0
  117. package/dist/ui/foundations.js +564 -0
  118. package/dist/ui/foundations.js.map +1 -0
  119. package/dist/ui/index.d.ts +6 -0
  120. package/dist/ui/index.js +7 -1
  121. package/dist/ui/inspector.d.ts +394 -0
  122. package/dist/ui/inspector.js +1173 -0
  123. package/dist/ui/inspector.js.map +1 -0
  124. package/dist/ui/overlay.d.ts +7 -2
  125. package/dist/ui/overlay.js +55 -20
  126. package/dist/ui/overlay.js.map +1 -1
  127. package/dist/ui/shortcut-hint.js +1 -1
  128. package/dist/ui/shortcut-hint.js.map +1 -1
  129. package/dist/ui/toast.d.ts +5 -3
  130. package/dist/ui/toast.js +83 -11
  131. package/dist/ui/toast.js.map +1 -1
  132. package/dist/ui/tooltip-card.d.ts +45 -0
  133. package/dist/ui/tooltip-card.js +135 -0
  134. package/dist/ui/tooltip-card.js.map +1 -0
  135. package/package.json +1 -1
@@ -13,7 +13,7 @@ type Opened = {
13
13
  };
14
14
  /**
15
15
  * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).
16
- * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.
16
+ * A codec that throws, or a value that does not survive, is held with the reason.
17
17
  */
18
18
  export declare function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec["read"]>[1]): Opened;
19
19
  export declare function RichTextControl(props: ControlProps): import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,6 @@ import { Textarea } from "../../ui/input.js";
7
7
  import { resolveFrames } from "../../lib/frames.js";
8
8
  import { editorRoundTrip } from "./dom.js";
9
9
  import { HeldValue } from "../../engine/held.js";
10
- import { LegacyFallback } from "../../engine/kit-field.js";
11
10
  import { TEXT_FOCUS } from "../text.js";
12
11
  import { UnknownValueNote } from "../unknown-value.js";
13
12
  import { RichTextEditor } from "./editor.js";
@@ -29,8 +28,7 @@ import { IconArrowsMaximize } from "@tabler/icons-react";
29
28
  * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,
30
29
  * named, and nothing is stored
31
30
  * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it
32
- * is HELD (read-only, its HTML shown, the reason above it; kit 3.2.0), or, while the host still provides
33
- * KitServices.LegacyControl (removed in 4.0.0), the host's own control edits it. Opening never writes.
31
+ * is HELD (read-only, its HTML shown, the reason above it). Opening never writes.
34
32
  */
35
33
  var openKey = null;
36
34
  var subs = /* @__PURE__ */ new Set();
@@ -69,7 +67,7 @@ function useExpandCrumbs(fieldTitle) {
69
67
  var holdsPullQuote = (seed) => Array.isArray(seed) ? seed.some((b) => !!b && typeof b === "object" && b._type === "pullQuote") : !!seed && typeof seed === "object" && holdsPullQuote(seed.content ?? seed.value);
70
68
  /**
71
69
  * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).
72
- * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.
70
+ * A codec that throws, or a value that does not survive, is held with the reason.
73
71
  */
74
72
  function openValue(codec, value, at) {
75
73
  let read;
@@ -83,7 +81,7 @@ function openValue(codec, value, at) {
83
81
  }
84
82
  if (holdsPullQuote(read.seed) && (!/data-rt="pullquote"/.test(read.html) || !read.features.includes("pullquote"))) return {
85
83
  ok: false,
86
- reason: "it holds a pull quote, which the standard editor edits",
84
+ reason: "it holds a pull quote, which this field has no place for",
87
85
  html: read.html
88
86
  };
89
87
  const html = editorRoundTrip(read.html);
@@ -114,7 +112,12 @@ function openValue(codec, value, at) {
114
112
  }
115
113
  function RichTextControl(props) {
116
114
  const { richText } = useKitServices();
117
- if (!richText) return /* @__PURE__ */ jsx(LegacyFallback, { ...props });
115
+ if (!richText) return /* @__PURE__ */ jsx(HeldValue, {
116
+ field: props.field,
117
+ value: props.value,
118
+ id: props.id,
119
+ reason: "this view has no rich text editor"
120
+ });
118
121
  return /* @__PURE__ */ jsx(CodecRichText, {
119
122
  codec: richText,
120
123
  ...props
@@ -131,7 +134,7 @@ function CodecRichText({ codec, field, value, onChange, readOnly, path, id, inva
131
134
  field,
132
135
  path
133
136
  }), [field, path]);
134
- const { useInsertableComponents, LegacyControl } = useKitServices();
137
+ const { useInsertableComponents } = useKitServices();
135
138
  const insertable = useInsertableComponents?.(at);
136
139
  const mine = React.useRef(null);
137
140
  const [refusal, setRefusal] = React.useState(null);
@@ -158,34 +161,13 @@ function CodecRichText({ codec, field, value, onChange, readOnly, path, id, inva
158
161
  setHandedOff(docKey, !opened.ok);
159
162
  if (!opened.ok && openKey === docKey) setFullEditor(null);
160
163
  }, [docKey, opened.ok]);
161
- if (!opened.ok && !LegacyControl) return /* @__PURE__ */ jsx(HeldValue, {
164
+ if (!opened.ok) return /* @__PURE__ */ jsx(HeldValue, {
162
165
  field,
163
166
  value,
164
167
  id,
165
168
  reason: opened.reason,
166
169
  html: opened.html
167
170
  });
168
- if (!opened.ok) return /* @__PURE__ */ jsxs("div", {
169
- className: "flex min-w-0 flex-col gap-1.5",
170
- children: [/* @__PURE__ */ jsxs("p", {
171
- role: "note",
172
- "data-slot": "kit-richtext-handoff",
173
- className: "rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2",
174
- children: [
175
- "Edited with the standard editor: ",
176
- opened.reason,
177
- "."
178
- ]
179
- }), /* @__PURE__ */ jsx(LegacyFallback, {
180
- field,
181
- value,
182
- onChange,
183
- readOnly,
184
- path,
185
- id,
186
- invalid
187
- })]
188
- });
189
171
  const { read, html } = opened;
190
172
  const write = (next) => {
191
173
  let res;
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","names":[],"sources":["../../../src/controls/rich-text/control.tsx"],"sourcesContent":["/**\n * Rich text field (V2 HEAD controls/richtext.tsx, CPO D49).\n * - The editor stays in place: the document variant is the full editor in the column, the panel variant (inspector)\n * the same editor height-capped.\n * - Expanding (the toolbar's expand button, ⌘↵, or the expand icon in the field's label row at rest) opens the shared\n * ExpandedEditorModal: breadcrumb \"Section › Item › Field\", word count, Done. Esc closes and focus returns.\n *\n * STORAGE. The editor edits HTML; the stored value stays what production stores for the field, through the host's\n * codec (KitServices.richText, see ./codec.ts):\n * - read: stored value → the HTML the editor opens on (+ what the field accepts)\n * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,\n * named, and nothing is stored\n * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it\n * is HELD (read-only, its HTML shown, the reason above it; kit 3.2.0), or, while the host still provides\n * KitServices.LegacyControl (removed in 4.0.0), the host's own control edits it. Opening never writes.\n */\nimport * as React from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { useForm, useKitEnv, useKitServices } from \"../../context\";\nimport { resolveFrames } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { ControlProps } from \"../../types\";\nimport { Tooltip } from \"../../ui/overlay\";\nimport { LegacyFallback } from \"../../engine/kit-field\";\nimport { HeldValue } from \"../../engine/held\";\nimport { FieldCommentRequest } from \"../../engine/field-shell\";\nimport type { KitRichTextCodec, RichTextRead } from \"./codec\";\nimport { editorRoundTrip } from \"./dom\";\nimport { RichTextEditor } from \"./editor\";\nimport { paragraphsHtml, plainParagraphs, usePlainRichText } from \"./plain\";\nimport { Textarea } from \"../../ui/input\";\nimport { TEXT_FOCUS } from \"../text\";\nimport { UnknownValueNote } from \"../unknown-value\";\n\n/* ── which rich-text field (docKey) has its full editor open — shared with the label-row action ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function setFullEditor(key: string | null) {\n openKey = key;\n subs.forEach((s) => s());\n}\nfunction useFullEditorKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/* ── fields whose value went to the host's own control: the label-row expand button is not theirs to draw ── */\nconst handedOff = new Set<string>();\nfunction setHandedOff(key: string, on: boolean) {\n if (handedOff.has(key) === on) return;\n if (on) handedOff.add(key);\n else handedOff.delete(key);\n subs.forEach((s) => s());\n}\nfunction useHandedOff(key: string) {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => handedOff.has(key),\n () => handedOff.has(key),\n );\n}\n\n/** The expanded editor's breadcrumb: the form's frames (root › drilled items) and this field. */\nfunction useExpandCrumbs(fieldTitle: string): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, fieldTitle].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, form.path, form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, fieldTitle];\n}\n\n/** A stored block array, or the `{ content }` / `{ format, value }` envelope around one, holding a pull quote block. */\nconst holdsPullQuote = (seed: unknown): boolean =>\n Array.isArray(seed)\n ? seed.some((b) => !!b && typeof b === \"object\" && (b as { _type?: unknown })._type === \"pullQuote\")\n : !!seed && typeof seed === \"object\" && holdsPullQuote((seed as { content?: unknown; value?: unknown }).content ?? (seed as { value?: unknown }).value);\n\n/** What the control decided for one stored value. */\ntype Opened =\n | { ok: true; read: RichTextRead; html: string }\n | { ok: false; reason: string; /** the HTML the codec read, when it could: what a held field shows */ html?: string };\n\n/**\n * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).\n * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.\n */\nexport function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec[\"read\"]>[1]): Opened {\n let read: RichTextRead;\n try {\n read = codec.read(value, at);\n } catch (err) {\n return { ok: false, reason: `the stored text could not be read (${err instanceof Error ? err.message : String(err)})` };\n }\n // a pull quote (V2 D55 article block) opens as the editor's pull-quote island, but only when the codec renders the\n // stored block as its markup in a field that offers it: a codec that renders nothing for it, or a field with no place\n // for one (a single paragraph), would lose it, so the standard editor edits it\n if (holdsPullQuote(read.seed) && (!/data-rt=\"pullquote\"/.test(read.html) || !read.features.includes(\"pullquote\")))\n return { ok: false, reason: \"it holds a pull quote, which the standard editor edits\", html: read.html };\n // tables and pull quotes are islands (V2 TableBlock, PullQuote); the probe below proves they survive unchanged\n const html = editorRoundTrip(read.html);\n try {\n const back = codec.write(html, at, value);\n if (back.losses.length) return { ok: false, reason: `this editor would drop ${back.losses.join(\", \")}`, html: read.html };\n if (!codec.same(back.value, read.seed)) return { ok: false, reason: \"it holds formatting this editor cannot keep\", html: read.html };\n } catch (err) {\n return { ok: false, reason: `the text could not be checked (${err instanceof Error ? err.message : String(err)})`, html: read.html };\n }\n return { ok: true, read, html };\n}\n\nexport function RichTextControl(props: ControlProps) {\n const { richText } = useKitServices();\n if (!richText) return <LegacyFallback {...props} />;\n return <CodecRichText codec={richText} {...props} />;\n}\n\nfunction CodecRichText({ codec, field, value, onChange, readOnly, path, id, invalid }: ControlProps & { codec: KitRichTextCodec }) {\n const env = useKitEnv();\n /* GAP-004: with no comments panel (env.onComment), the field's own comments popover takes the selected words */\n const requestComment = React.useContext(FieldCommentRequest);\n const docKey = `${env.docId}:${pathKey(path)}`;\n const open = useFullEditorKey() === docKey;\n const crumbs = useExpandCrumbs(field.title);\n const plainScope = usePlainRichText();\n const at = React.useMemo(() => ({ field, path }), [field, path]);\n // the components this field may embed (More components): a hook with one identity for the form's life, so calling it\n // only when the host provides it keeps the hook order fixed\n const { useInsertableComponents, LegacyControl } = useKitServices();\n const insertable = useInsertableComponents?.(at);\n /* our own last write: its value comes back as `value`, and the editor keeps the HTML it emitted (no reload, no probe).\n Compared by content (NEW-RT5): a host hands it back as a new object (the dock re-reads its stored values), and the\n reload that followed replaced the body under an open footnote popover or block form after its first keystroke */\n const mine = React.useRef<{ value: unknown; html: string } | null>(null);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const opened = React.useMemo<Opened>(() => {\n if (mine.current && (mine.current.value === value || codec.same(mine.current.value, value))) {\n try {\n return { ok: true, read: codec.read(value, at), html: mine.current.html };\n } catch {\n /* judged afresh below, which names the failure */\n }\n }\n return openValue(codec, value, at);\n // `at` changes identity with the field object; the field's content is what matters\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [codec, value, JSON.stringify(field), pathKey(path)]);\n\n // close when this field goes away (block deselected, drilled elsewhere)\n React.useEffect(\n () => () => {\n if (openKey === docKey) setFullEditor(null);\n setHandedOff(docKey, false);\n },\n [docKey],\n );\n React.useLayoutEffect(() => {\n setHandedOff(docKey, !opened.ok);\n if (!opened.ok && openKey === docKey) setFullEditor(null);\n }, [docKey, opened.ok]);\n\n // kit 3.2.0: with no host control to hand it to, the value is held (shown read-only with the reason, never written)\n if (!opened.ok && !LegacyControl) return <HeldValue field={field} value={value} id={id} reason={opened.reason} html={opened.html} />;\n if (!opened.ok)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <p role=\"note\" data-slot=\"kit-richtext-handoff\" className=\"rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2\">\n Edited with the standard editor: {opened.reason}.\n </p>\n <LegacyFallback field={field} value={value} onChange={onChange} readOnly={readOnly} path={path} id={id} invalid={invalid} />\n </div>\n );\n\n const { read, html } = opened;\n const write = (next: string) => {\n let res;\n try {\n res = codec.write(next, at, value);\n } catch (err) {\n setRefusal(`Not saved: the text could not be stored (${err instanceof Error ? err.message : String(err)}). Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n if (res.losses.length) {\n setRefusal(`Not saved: this field cannot keep ${res.losses.join(\", \")}. Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n setRefusal(null);\n if (codec.same(res.value, value)) return;\n mine.current = { value: res.value, html: next };\n onChange(res.value);\n };\n\n // The Values popover (PlainRichTextScope): plain paragraphs are V2's growing textarea (its `text` control), written\n // back through the same codec, one `<p>` per line. Anything richer keeps the editor below.\n const plain = plainScope && !read.losses.length ? plainParagraphs(html) : null;\n if (plain !== null)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <Textarea\n id={id}\n rows={3}\n value={plain}\n readOnly={readOnly}\n aria-invalid={invalid || !!refusal}\n placeholder={field.placeholder}\n onChange={(e) => write(paragraphsHtml(e.target.value))}\n className={cn(TEXT_FOCUS, \"leading-5\")}\n />\n {refusal ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n\n /* V2 richtext.tsx:57: the editor sits in a plain <div>; the dash-only notes keep the 6px gap as their own margin */\n return (\n <div>\n {read.losses.length ? (\n <p role=\"status\" className=\"mb-1.5 rounded-kit-md bg-kit-warning-soft px-2.5 py-1.5 text-kit-xs text-kit-warning-fg\">\n Saved by an earlier editor. Editing here would drop {read.losses.join(\", \")}. Nothing changes until you edit.\n </p>\n ) : null}\n {read.undeclared?.length && codec.remap ? (\n <div className=\"mb-1.5\">\n <UnknownValueNote\n items={read.undeclared}\n onRemap={(key, to) => onChange(codec.remap!(value, at, key, to))}\n onRemove={(key) => onChange(codec.remap!(value, at, key, null))}\n readOnly={readOnly}\n />\n </div>\n ) : null}\n <RichTextEditor\n value={html}\n onChange={write}\n readOnly={readOnly}\n placeholder={field.placeholder}\n docKey={docKey}\n id={id}\n invalid={invalid || !!refusal}\n features={read.features}\n references={read.references}\n single={read.single}\n allowNewTab={read.newTab}\n components={insertable && !read.single && !readOnly ? insertable : undefined}\n variant={env.variant === \"document\" ? \"document\" : \"panel\"}\n maxHeight={env.variant === \"document\" ? undefined : 320}\n expandCrumbs={crumbs}\n expandedOpen={open}\n onExpandedOpenChange={(o) => setFullEditor(o ? docKey : null)}\n // select words → Comment in the toolbar: the host's comment popover opens on this field, quoting them\n onComment={\n env.onComment ? (quote) => env.onComment?.(path, field, quote) : requestComment ? (quote, around) => requestComment({ quote, ...around }) : undefined\n }\n // the field's popover sits under the field, behind the expanded editor's focus trap: no Comment in there\n commentInPlace={!env.onComment && !!requestComment}\n />\n {refusal ? (\n <p role=\"alert\" className=\"mt-1.5 text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** Label-row action (at rest): the field's toolbar holds the same button while it's open. */\nfunction readsPlain(codec: KitRichTextCodec, value: unknown, field: ControlProps[\"field\"], path: ControlProps[\"path\"]) {\n try {\n const read = codec.read(value, { field, path });\n return !read.losses.length && plainParagraphs(editorRoundTrip(read.html)) !== null;\n } catch {\n return false; // the control names the failure itself\n }\n}\n\nexport function RichTextExpandAction({ path, field, value }: ControlProps) {\n const env = useKitEnv();\n const { richText } = useKitServices();\n const handed = useHandedOff(`${env.docId}:${pathKey(path)}`);\n const plainScope = usePlainRichText();\n // the host's own control (no codec, or a value handed to it) has its own full-screen button\n if (env.variant === \"document\" || !richText || handed) return null;\n // drawn as a plain textarea (V2's `text` control has no ⤢)\n if (plainScope && readsPlain(richText, value, field, path)) return null;\n return (\n <Tooltip content=\"Expand editor\" shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={`Expand ${field.title}`}\n onClick={() => setFullEditor(`${env.docId}:${pathKey(path)}`)}\n className={cn(\n \"-my-0.5 hidden size-6 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n \"group-hover/field:inline-flex group-focus-within/field:!hidden [@media(pointer:coarse)]:inline-flex\",\n )}\n >\n <IconArrowsMaximize className=\"size-3.5\" stroke={1.5} aria-hidden />\n </button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAI,UAAyB;AAC7B,IAAM,uBAAO,IAAI,IAAgB;AACjC,SAAgB,cAAc,KAAoB;CAChD,UAAU;CACV,KAAK,SAAS,MAAM,EAAE,CAAC;AACzB;AACA,SAAS,mBAAmB;CAC1B,OAAO,MAAM,sBACV,OAAO;EACN,KAAK,IAAI,EAAE;EACX,aAAa,KAAK,OAAO,EAAE;CAC7B,SACM,eACA,OACR;AACF;AAGA,IAAM,4BAAY,IAAI,IAAY;AAClC,SAAS,aAAa,KAAa,IAAa;CAC9C,IAAI,UAAU,IAAI,GAAG,MAAM,IAAI;CAC/B,IAAI,IAAI,UAAU,IAAI,GAAG;MACpB,UAAU,OAAO,GAAG;CACzB,KAAK,SAAS,MAAM,EAAE,CAAC;AACzB;AACA,SAAS,aAAa,KAAa;CACjC,OAA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uHACA,qGACF;GAEA,UAAA,oBAAC,oBAAD;IAAoB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA;EAC7D,CAAA;CACD,CAAA;AAEb"}
1
+ {"version":3,"file":"control.js","names":[],"sources":["../../../src/controls/rich-text/control.tsx"],"sourcesContent":["/**\n * Rich text field (V2 HEAD controls/richtext.tsx, CPO D49).\n * - The editor stays in place: the document variant is the full editor in the column, the panel variant (inspector)\n * the same editor height-capped.\n * - Expanding (the toolbar's expand button, ⌘↵, or the expand icon in the field's label row at rest) opens the shared\n * ExpandedEditorModal: breadcrumb \"Section › Item › Field\", word count, Done. Esc closes and focus returns.\n *\n * STORAGE. The editor edits HTML; the stored value stays what production stores for the field, through the host's\n * codec (KitServices.richText, see ./codec.ts):\n * - read: stored value → the HTML the editor opens on (+ what the field accepts)\n * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,\n * named, and nothing is stored\n * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it\n * is HELD (read-only, its HTML shown, the reason above it). Opening never writes.\n */\nimport * as React from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { useForm, useKitEnv, useKitServices } from \"../../context\";\nimport { resolveFrames } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { ControlProps } from \"../../types\";\nimport { Tooltip } from \"../../ui/overlay\";\nimport { HeldValue } from \"../../engine/held\";\nimport { FieldCommentRequest } from \"../../engine/field-shell\";\nimport type { KitRichTextCodec, RichTextRead } from \"./codec\";\nimport { editorRoundTrip } from \"./dom\";\nimport { RichTextEditor } from \"./editor\";\nimport { paragraphsHtml, plainParagraphs, usePlainRichText } from \"./plain\";\nimport { Textarea } from \"../../ui/input\";\nimport { TEXT_FOCUS } from \"../text\";\nimport { UnknownValueNote } from \"../unknown-value\";\n\n/* ── which rich-text field (docKey) has its full editor open — shared with the label-row action ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function setFullEditor(key: string | null) {\n openKey = key;\n subs.forEach((s) => s());\n}\nfunction useFullEditorKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/* ── fields whose value went to the host's own control: the label-row expand button is not theirs to draw ── */\nconst handedOff = new Set<string>();\nfunction setHandedOff(key: string, on: boolean) {\n if (handedOff.has(key) === on) return;\n if (on) handedOff.add(key);\n else handedOff.delete(key);\n subs.forEach((s) => s());\n}\nfunction useHandedOff(key: string) {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => handedOff.has(key),\n () => handedOff.has(key),\n );\n}\n\n/** The expanded editor's breadcrumb: the form's frames (root › drilled items) and this field. */\nfunction useExpandCrumbs(fieldTitle: string): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, fieldTitle].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, form.path, form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, fieldTitle];\n}\n\n/** A stored block array, or the `{ content }` / `{ format, value }` envelope around one, holding a pull quote block. */\nconst holdsPullQuote = (seed: unknown): boolean =>\n Array.isArray(seed)\n ? seed.some((b) => !!b && typeof b === \"object\" && (b as { _type?: unknown })._type === \"pullQuote\")\n : !!seed && typeof seed === \"object\" && holdsPullQuote((seed as { content?: unknown; value?: unknown }).content ?? (seed as { value?: unknown }).value);\n\n/** What the control decided for one stored value. */\ntype Opened =\n | { ok: true; read: RichTextRead; html: string }\n | { ok: false; reason: string; /** the HTML the codec read, when it could: what a held field shows */ html?: string };\n\n/**\n * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).\n * A codec that throws, or a value that does not survive, is held with the reason.\n */\nexport function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec[\"read\"]>[1]): Opened {\n let read: RichTextRead;\n try {\n read = codec.read(value, at);\n } catch (err) {\n return { ok: false, reason: `the stored text could not be read (${err instanceof Error ? err.message : String(err)})` };\n }\n // a pull quote (V2 D55 article block) opens as the editor's pull-quote island, but only when the codec renders the\n // stored block as its markup in a field that offers it: a codec that renders nothing for it, or a field with no place\n // for one (a single paragraph), would lose it, so it is held\n if (holdsPullQuote(read.seed) && (!/data-rt=\"pullquote\"/.test(read.html) || !read.features.includes(\"pullquote\")))\n return { ok: false, reason: \"it holds a pull quote, which this field has no place for\", html: read.html };\n // tables and pull quotes are islands (V2 TableBlock, PullQuote); the probe below proves they survive unchanged\n const html = editorRoundTrip(read.html);\n try {\n const back = codec.write(html, at, value);\n if (back.losses.length) return { ok: false, reason: `this editor would drop ${back.losses.join(\", \")}`, html: read.html };\n if (!codec.same(back.value, read.seed)) return { ok: false, reason: \"it holds formatting this editor cannot keep\", html: read.html };\n } catch (err) {\n return { ok: false, reason: `the text could not be checked (${err instanceof Error ? err.message : String(err)})`, html: read.html };\n }\n return { ok: true, read, html };\n}\n\nexport function RichTextControl(props: ControlProps) {\n const { richText } = useKitServices();\n if (!richText) return <HeldValue field={props.field} value={props.value} id={props.id} reason=\"this view has no rich text editor\" />;\n return <CodecRichText codec={richText} {...props} />;\n}\n\nfunction CodecRichText({ codec, field, value, onChange, readOnly, path, id, invalid }: ControlProps & { codec: KitRichTextCodec }) {\n const env = useKitEnv();\n /* GAP-004: with no comments panel (env.onComment), the field's own comments popover takes the selected words */\n const requestComment = React.useContext(FieldCommentRequest);\n const docKey = `${env.docId}:${pathKey(path)}`;\n const open = useFullEditorKey() === docKey;\n const crumbs = useExpandCrumbs(field.title);\n const plainScope = usePlainRichText();\n const at = React.useMemo(() => ({ field, path }), [field, path]);\n // the components this field may embed (More components): a hook with one identity for the form's life, so calling it\n // only when the host provides it keeps the hook order fixed\n const { useInsertableComponents } = useKitServices();\n const insertable = useInsertableComponents?.(at);\n /* our own last write: its value comes back as `value`, and the editor keeps the HTML it emitted (no reload, no probe).\n Compared by content (NEW-RT5): a host hands it back as a new object (the dock re-reads its stored values), and the\n reload that followed replaced the body under an open footnote popover or block form after its first keystroke */\n const mine = React.useRef<{ value: unknown; html: string } | null>(null);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const opened = React.useMemo<Opened>(() => {\n if (mine.current && (mine.current.value === value || codec.same(mine.current.value, value))) {\n try {\n return { ok: true, read: codec.read(value, at), html: mine.current.html };\n } catch {\n /* judged afresh below, which names the failure */\n }\n }\n return openValue(codec, value, at);\n // `at` changes identity with the field object; the field's content is what matters\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [codec, value, JSON.stringify(field), pathKey(path)]);\n\n // close when this field goes away (block deselected, drilled elsewhere)\n React.useEffect(\n () => () => {\n if (openKey === docKey) setFullEditor(null);\n setHandedOff(docKey, false);\n },\n [docKey],\n );\n React.useLayoutEffect(() => {\n setHandedOff(docKey, !opened.ok);\n if (!opened.ok && openKey === docKey) setFullEditor(null);\n }, [docKey, opened.ok]);\n\n // a value the editor cannot carry unchanged is held: shown read-only with the reason, never written\n if (!opened.ok) return <HeldValue field={field} value={value} id={id} reason={opened.reason} html={opened.html} />;\n\n const { read, html } = opened;\n const write = (next: string) => {\n let res;\n try {\n res = codec.write(next, at, value);\n } catch (err) {\n setRefusal(`Not saved: the text could not be stored (${err instanceof Error ? err.message : String(err)}). Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n if (res.losses.length) {\n setRefusal(`Not saved: this field cannot keep ${res.losses.join(\", \")}. Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n setRefusal(null);\n if (codec.same(res.value, value)) return;\n mine.current = { value: res.value, html: next };\n onChange(res.value);\n };\n\n // The Values popover (PlainRichTextScope): plain paragraphs are V2's growing textarea (its `text` control), written\n // back through the same codec, one `<p>` per line. Anything richer keeps the editor below.\n const plain = plainScope && !read.losses.length ? plainParagraphs(html) : null;\n if (plain !== null)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <Textarea\n id={id}\n rows={3}\n value={plain}\n readOnly={readOnly}\n aria-invalid={invalid || !!refusal}\n placeholder={field.placeholder}\n onChange={(e) => write(paragraphsHtml(e.target.value))}\n className={cn(TEXT_FOCUS, \"leading-5\")}\n />\n {refusal ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n\n /* V2 richtext.tsx:57: the editor sits in a plain <div>; the dash-only notes keep the 6px gap as their own margin */\n return (\n <div>\n {read.losses.length ? (\n <p role=\"status\" className=\"mb-1.5 rounded-kit-md bg-kit-warning-soft px-2.5 py-1.5 text-kit-xs text-kit-warning-fg\">\n Saved by an earlier editor. Editing here would drop {read.losses.join(\", \")}. Nothing changes until you edit.\n </p>\n ) : null}\n {read.undeclared?.length && codec.remap ? (\n <div className=\"mb-1.5\">\n <UnknownValueNote\n items={read.undeclared}\n onRemap={(key, to) => onChange(codec.remap!(value, at, key, to))}\n onRemove={(key) => onChange(codec.remap!(value, at, key, null))}\n readOnly={readOnly}\n />\n </div>\n ) : null}\n <RichTextEditor\n value={html}\n onChange={write}\n readOnly={readOnly}\n placeholder={field.placeholder}\n docKey={docKey}\n id={id}\n invalid={invalid || !!refusal}\n features={read.features}\n references={read.references}\n single={read.single}\n allowNewTab={read.newTab}\n components={insertable && !read.single && !readOnly ? insertable : undefined}\n variant={env.variant === \"document\" ? \"document\" : \"panel\"}\n maxHeight={env.variant === \"document\" ? undefined : 320}\n expandCrumbs={crumbs}\n expandedOpen={open}\n onExpandedOpenChange={(o) => setFullEditor(o ? docKey : null)}\n // select words → Comment in the toolbar: the host's comment popover opens on this field, quoting them\n onComment={\n env.onComment ? (quote) => env.onComment?.(path, field, quote) : requestComment ? (quote, around) => requestComment({ quote, ...around }) : undefined\n }\n // the field's popover sits under the field, behind the expanded editor's focus trap: no Comment in there\n commentInPlace={!env.onComment && !!requestComment}\n />\n {refusal ? (\n <p role=\"alert\" className=\"mt-1.5 text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** Label-row action (at rest): the field's toolbar holds the same button while it's open. */\nfunction readsPlain(codec: KitRichTextCodec, value: unknown, field: ControlProps[\"field\"], path: ControlProps[\"path\"]) {\n try {\n const read = codec.read(value, { field, path });\n return !read.losses.length && plainParagraphs(editorRoundTrip(read.html)) !== null;\n } catch {\n return false; // the control names the failure itself\n }\n}\n\nexport function RichTextExpandAction({ path, field, value }: ControlProps) {\n const env = useKitEnv();\n const { richText } = useKitServices();\n const handed = useHandedOff(`${env.docId}:${pathKey(path)}`);\n const plainScope = usePlainRichText();\n // the host's own control (no codec, or a value handed to it) has its own full-screen button\n if (env.variant === \"document\" || !richText || handed) return null;\n // drawn as a plain textarea (V2's `text` control has no ⤢)\n if (plainScope && readsPlain(richText, value, field, path)) return null;\n return (\n <Tooltip content=\"Expand editor\" shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={`Expand ${field.title}`}\n onClick={() => setFullEditor(`${env.docId}:${pathKey(path)}`)}\n className={cn(\n \"-my-0.5 hidden size-6 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n \"group-hover/field:inline-flex group-focus-within/field:!hidden [@media(pointer:coarse)]:inline-flex\",\n )}\n >\n <IconArrowsMaximize className=\"size-3.5\" stroke={1.5} aria-hidden />\n </button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAI,UAAyB;AAC7B,IAAM,uBAAO,IAAI,IAAgB;AACjC,SAAgB,cAAc,KAAoB;CAChD,UAAU;CACV,KAAK,SAAS,MAAM,EAAE,CAAC;AACzB;AACA,SAAS,mBAAmB;CAC1B,OAAO,MAAM,sBACV,OAAO;EACN,KAAK,IAAI,EAAE;EACX,aAAa,KAAK,OAAO,EAAE;CAC7B,SACM,eACA,OACR;AACF;AAGA,I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A,qGACF;GAEA,UAAA,oBAAC,oBAAD;IAAoB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA;EAC7D,CAAA;CACD,CAAA;AAEb"}
@@ -38,6 +38,10 @@
38
38
  * `data-detached="true" data-props data-blocks data-source-published-at`, and carries no overrides.
39
39
  * "Show on site" is {visible} (`data-visible`): false keeps the place in the body and off the published
40
40
  * page; absent reads as shown.
41
+ * stats prototype editor-v16 Stats (content.jsx:194, 1162-1163, content.css:348-352, 585): a row of cards, each
42
+ * {label, value, note}, in 2-4 columns, outlined or filled: `<div data-rt="stats" data-cols data-style>
43
+ * <div data-stat><small>…</small><b>…</b><span>…</span></div>…` (feature "stats"; the host stores it as
44
+ * `bcmsBlock` builtin:stats {columns, style, items}, REQ-KIT-1).
41
45
  * A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched
42
46
  * block reads back exactly as stored.
43
47
  * V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are
@@ -111,8 +115,15 @@ export interface CalloutModel {
111
115
  title?: string;
112
116
  /** plain text: paragraphs split by a blank line, line breaks kept */
113
117
  body?: string;
118
+ /** look v16 (prototype content.jsx:1183): "No icon" stores `data-icon="none"`; absent = the tone's icon (REQ-KIT-1) */
119
+ icon?: "none";
114
120
  extra?: string;
115
121
  }
122
+ /** look v16 (prototype content.jsx:1164): Note (stored "note"), Info, Tip, Warning */
123
+ export declare const V16_CALLOUT_TONES: readonly {
124
+ tone: string;
125
+ label: string;
126
+ }[];
116
127
  export interface ToggleModel {
117
128
  title?: string;
118
129
  body?: string;
@@ -217,6 +228,21 @@ export interface ComponentModel {
217
228
  visible?: boolean;
218
229
  extra?: string;
219
230
  }
231
+ /** Prototype editor-v16 Stats block: cards of {label, value, note}; 3 columns and outlined when absent. */
232
+ export interface StatsModel {
233
+ cols?: 2 | 3 | 4;
234
+ style?: "outlined" | "filled";
235
+ /** `_key` is the editor's own */
236
+ items: {
237
+ _key: string;
238
+ label: string;
239
+ value: string;
240
+ note: string;
241
+ }[];
242
+ extra?: string;
243
+ }
244
+ /** content.jsx:194: a new card reads "Label / 0 / What it measures" */
245
+ export declare const newStat: () => StatsModel["items"][number];
220
246
  export interface IslandModels {
221
247
  image: ImageModel;
222
248
  table: TableModel;
@@ -233,6 +259,7 @@ export interface IslandModels {
233
259
  columns: ColumnsIslandModel;
234
260
  author: AuthorIslandModel;
235
261
  related: RelatedIslandModel;
262
+ stats: StatsModel;
236
263
  }
237
264
  export type IslandKind = keyof IslandModels;
238
265
  export declare const ISLAND_KINDS: IslandKind[];
@@ -40,6 +40,10 @@ import { boolLabels, cellText, cellValue, emptyTable, formatNumber, isCellObject
40
40
  * `data-detached="true" data-props data-blocks data-source-published-at`, and carries no overrides.
41
41
  * "Show on site" is {visible} (`data-visible`): false keeps the place in the body and off the published
42
42
  * page; absent reads as shown.
43
+ * stats prototype editor-v16 Stats (content.jsx:194, 1162-1163, content.css:348-352, 585): a row of cards, each
44
+ * {label, value, note}, in 2-4 columns, outlined or filled: `<div data-rt="stats" data-cols data-style>
45
+ * <div data-stat><small>…</small><b>…</b><span>…</span></div>…` (feature "stats"; the host stores it as
46
+ * `bcmsBlock` builtin:stats {columns, style, items}, REQ-KIT-1).
43
47
  * A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched
44
48
  * block reads back exactly as stored.
45
49
  * V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are
@@ -98,6 +102,25 @@ var CALLOUT_TONES = [
98
102
  "tip",
99
103
  "warning"
100
104
  ];
105
+ /** look v16 (prototype content.jsx:1164): Note (stored "note"), Info, Tip, Warning */
106
+ var V16_CALLOUT_TONES = [
107
+ {
108
+ tone: "note",
109
+ label: "Note"
110
+ },
111
+ {
112
+ tone: "info",
113
+ label: "Info"
114
+ },
115
+ {
116
+ tone: "tip",
117
+ label: "Tip"
118
+ },
119
+ {
120
+ tone: "warning",
121
+ label: "Warning"
122
+ }
123
+ ];
101
124
  var EMBED_ASPECT_VALUES = [
102
125
  "16:9",
103
126
  "4:3",
@@ -176,6 +199,13 @@ function detectEmbed(url) {
176
199
  host
177
200
  };
178
201
  }
202
+ /** content.jsx:194: a new card reads "Label / 0 / What it measures" */
203
+ var newStat = () => ({
204
+ _key: rid("st"),
205
+ label: "Label",
206
+ value: "0",
207
+ note: "What it measures"
208
+ });
179
209
  var ISLAND_KINDS = [
180
210
  "image",
181
211
  "table",
@@ -191,7 +221,8 @@ var ISLAND_KINDS = [
191
221
  "toc",
192
222
  "columns",
193
223
  "author",
194
- "related"
224
+ "related",
225
+ "stats"
195
226
  ];
196
227
  function defaultModel(kind, extra) {
197
228
  const base = {
@@ -258,7 +289,15 @@ function defaultModel(kind, extra) {
258
289
  mode: "topic",
259
290
  count: 3,
260
291
  posts: []
261
- })
292
+ }),
293
+ stats: () => ({ items: [
294
+ {
295
+ ...newStat(),
296
+ value: "0%"
297
+ },
298
+ newStat(),
299
+ newStat()
300
+ ] })
262
301
  };
263
302
  if (kind === "table") return {
264
303
  ...base.table(),
@@ -318,7 +357,7 @@ function renderStatic(kind, model) {
318
357
  const m = model;
319
358
  const title = m.title !== void 0 ? `<p data-title="true">${esc(m.title)}</p>` : "";
320
359
  const body = m.body !== void 0 ? `<div data-body="true">${textToParas(m.body)}</div>` : "";
321
- return `<div data-rt="callout"${attr("data-callout", m.tone)}${xAttr(m.extra)}>${title}${body}</div>`;
360
+ return `<div data-rt="callout"${attr("data-callout", m.tone)}${attr("data-icon", m.icon)}${xAttr(m.extra)}>${title}${body}</div>`;
322
361
  }
323
362
  case "toggle": {
324
363
  const m = model;
@@ -356,6 +395,11 @@ function renderStatic(kind, model) {
356
395
  const m = model;
357
396
  return `<aside data-rt="related"${attr("data-mode", m.mode)}${attr("data-count", m.count)} data-posts="${escAttr(m.posts.join(","))}"${xAttr(m.extra)}>${m.title ? `<p data-title>${esc(m.title)}</p>` : ""}</aside>`;
358
397
  }
398
+ case "stats": {
399
+ const m = model;
400
+ const card = (c) => `<div data-stat="true"><small>${esc(c.label)}</small><b>${esc(c.value)}</b><span>${esc(c.note)}</span></div>`;
401
+ return `<div data-rt="stats"${attr("data-cols", m.cols)}${attr("data-style", m.style)}${xAttr(m.extra)}>${m.items.map(card).join("")}</div>`;
402
+ }
359
403
  case "file": {
360
404
  const m = model;
361
405
  const link = m.url && m.name ? `<a href="${escAttr(m.url)}" download>${esc(m.name)}</a>` : "";
@@ -877,6 +921,7 @@ function parseIsland(kind, el) {
877
921
  const m = {};
878
922
  const tone = attrOf(el, "data-callout");
879
923
  if (tone !== void 0) m.tone = tone;
924
+ if (attrOf(el, "data-icon") === "none") m.icon = "none";
880
925
  if (title) m.title = (title.textContent ?? "").replace(/\u200b/g, "");
881
926
  if (body) m.body = parasToText(body);
882
927
  const extra = attrOf(el, "data-extra");
@@ -979,6 +1024,23 @@ function parseIsland(kind, el) {
979
1024
  if (extra) m.extra = extra;
980
1025
  return m;
981
1026
  }
1027
+ case "stats": {
1028
+ const text = (n) => (n?.textContent ?? "").replace(/\u200b/g, "").replace(/\s+/g, " ").trim();
1029
+ const items = Array.from(el.querySelectorAll(":scope > [data-stat]")).map((c) => ({
1030
+ _key: rid("st"),
1031
+ label: text(c.querySelector(":scope > small")),
1032
+ value: text(c.querySelector(":scope > b")),
1033
+ note: text(c.querySelector(":scope > span"))
1034
+ }));
1035
+ const m = { items: items.length ? items : [newStat()] };
1036
+ const cols = Number(attrOf(el, "data-cols"));
1037
+ if (cols === 2 || cols === 3 || cols === 4) m.cols = cols;
1038
+ const style = attrOf(el, "data-style");
1039
+ if (style === "outlined" || style === "filled") m.style = style;
1040
+ const extra = attrOf(el, "data-extra");
1041
+ if (extra) m.extra = extra;
1042
+ return m;
1043
+ }
982
1044
  case "file": {
983
1045
  const m = {};
984
1046
  const url = attrOf(el, "data-url");
@@ -1090,6 +1152,9 @@ function serialize(root) {
1090
1152
  c.replaceWith(tpl.content);
1091
1153
  });
1092
1154
  clone.querySelectorAll("[data-hint]").forEach((n) => n.removeAttribute("data-hint"));
1155
+ clone.querySelectorAll("[data-rt-wrap]").forEach((n) => n.removeAttribute("data-rt-wrap"));
1156
+ clone.querySelectorAll("span[data-rt-hl]").forEach((n) => n.replaceWith(n.textContent ?? ""));
1157
+ clone.querySelectorAll("pre").forEach((n) => n.normalize());
1093
1158
  clone.querySelectorAll("ul[data-task] > li").forEach((li) => (li.removeAttribute("role"), li.removeAttribute("aria-checked")));
1094
1159
  while (clone.children.length > 1 && clone.lastElementChild && isEmptyP(clone.lastElementChild)) clone.lastElementChild.remove();
1095
1160
  const html = clone.innerHTML.replace(/​/g, "");
@@ -1185,6 +1250,6 @@ function ownsMenu(menu, roots) {
1185
1250
  }
1186
1251
  var isEmptyHtml = (html) => !html.replace(/<(?!img|hr|figure|table|details|div data-rt)[^>]*>/g, "").replace(/&nbsp;/g, "").trim();
1187
1252
  //#endregion
1188
- export { CALLOUT_TONES, IMAGE_ALIGNS, IMAGE_SIZES, ISLAND_KINDS, STORED_COLUMN_TYPES, TEXT_BLOCKS, cloneModel, closestBlock, colAttrs, colSettingsOf, columnSettings, createIsland, defaultModel, detectEmbed, detectKind, editingHost, editorRoundTrip, esc, escAttr, hydrate, isEmptyHtml, isValueType, ownsMenu, parasToText, parseIsland, parseStoredTable, placeCaret, rangeRect, readImageFrame, renderStatic, renderStoredTable, rid, sanitize, serialize, textBeforeCaret, textToParas, topBlock, typeAttrOf, typedCellView, typedValueOf, typedWords };
1253
+ export { CALLOUT_TONES, IMAGE_ALIGNS, IMAGE_SIZES, ISLAND_KINDS, STORED_COLUMN_TYPES, TEXT_BLOCKS, V16_CALLOUT_TONES, cloneModel, closestBlock, colAttrs, colSettingsOf, columnSettings, createIsland, defaultModel, detectEmbed, detectKind, editingHost, editorRoundTrip, esc, escAttr, hydrate, isEmptyHtml, isValueType, newStat, ownsMenu, parasToText, parseIsland, parseStoredTable, placeCaret, rangeRect, readImageFrame, renderStatic, renderStoredTable, rid, sanitize, serialize, textBeforeCaret, textToParas, topBlock, typeAttrOf, typedCellView, typedValueOf, typedWords };
1189
1254
 
1190
1255
  //# sourceMappingURL=dom.js.map