@bettercms-ai/ui 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/blocks.d.ts CHANGED
@@ -49,7 +49,12 @@ interface PortableTextProps {
49
49
  value: unknown;
50
50
  /** `<blockId>__<prop>`. Present ⇒ stamp a per-block address. Absent ⇒ published output. */
51
51
  bindingBase?: string;
52
+ /**
53
+ * Renders an embedded block this renderer cannot resolve (a component — it has no project).
54
+ * Anything but `undefined` replaces the marker; `null` renders nothing.
55
+ */
56
+ renderBlock?: (value: Record<string, unknown>) => React.ReactNode;
52
57
  }
53
- declare function PortableText({ value, bindingBase }: PortableTextProps): react_jsx_runtime.JSX.Element | null;
58
+ declare function PortableText({ value, bindingBase, renderBlock }: PortableTextProps): react_jsx_runtime.JSX.Element | null;
54
59
 
55
60
  export { ComponentInstance, Footer, FormPlaceholder, Navbar, PortableText, type PortableTextProps, Section, Slider, Tabs };
package/dist/blocks.js CHANGED
@@ -78,7 +78,30 @@ var STORABLE_BLOCK_TYPES = /* @__PURE__ */ new Set([
78
78
  ]);
79
79
 
80
80
  // ../richtext/src/styled.ts
81
- var STYLED_TAGS = ["span", "small", "sup", "sub", "kbd", "abbr", "time"];
81
+ var STYLED_TAGS = [
82
+ "span",
83
+ "small",
84
+ "sup",
85
+ "sub",
86
+ "kbd",
87
+ "abbr",
88
+ "time",
89
+ "strong",
90
+ "b",
91
+ "em",
92
+ "i",
93
+ "u",
94
+ "s",
95
+ "mark",
96
+ "code",
97
+ "q",
98
+ "cite",
99
+ "dfn",
100
+ "var",
101
+ "samp",
102
+ "ins",
103
+ "del"
104
+ ];
82
105
  var TAG_SET = new Set(STYLED_TAGS);
83
106
  var isStyledTag = (tag) => typeof tag === "string" && TAG_SET.has(tag);
84
107
  var ATTR_NAMES = /* @__PURE__ */ new Set(["title", "datetime", "style", "aria-label"]);
@@ -356,7 +379,7 @@ function Table({ value }) {
356
379
  head < rows.length && /* @__PURE__ */ jsx2("tbody", { children: rendered.slice(head) })
357
380
  ] });
358
381
  }
359
- function buildComponents() {
382
+ function buildComponents(renderBlock) {
360
383
  return {
361
384
  types: {
362
385
  [PT_TYPES.divider]: () => /* @__PURE__ */ jsx2("hr", {}),
@@ -370,9 +393,12 @@ function buildComponents() {
370
393
  * A generic embedded block renders as a marker, not as content: its payload references
371
394
  * something (a component, a media id) that has to be RESOLVED against the project, and
372
395
  * this renderer has no project. A marker keeps the node visible and addressable rather
373
- * than rendering nothing at all, which is how embedded content used to vanish.
396
+ * than rendering nothing at all, which is how embedded content used to vanish. A caller
397
+ * that CAN resolve it passes `renderBlock`.
374
398
  */
375
399
  [PT_TYPES.block]: ({ value }) => {
400
+ const rendered = renderBlock?.(value);
401
+ if (rendered !== void 0) return /* @__PURE__ */ jsx2(Fragment, { children: rendered });
376
402
  const v = value;
377
403
  const key = typeof v.schemaKey === "string" ? v.schemaKey : "block";
378
404
  return /* @__PURE__ */ jsx2("div", { className: "bcms-block", "data-bcms-schema-key": key });
@@ -452,9 +478,9 @@ function runsOf(blocks) {
452
478
  }
453
479
  return runs;
454
480
  }
455
- function PortableText({ value, bindingBase }) {
481
+ function PortableText({ value, bindingBase, renderBlock }) {
456
482
  const blocks = React.useMemo(() => normalizePortableText(readValue(value)), [value]);
457
- const components = React.useMemo(buildComponents, []);
483
+ const components = React.useMemo(() => buildComponents(renderBlock), [renderBlock]);
458
484
  const listComponents = React.useMemo(() => {
459
485
  if (!bindingBase) return null;
460
486
  const keys = new Set(blocks.map((b) => b._key));