cms-renderer 0.7.0 → 0.8.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.
@@ -32,12 +32,12 @@ function isArticlePublished(article) {
32
32
  var BLOCK_METADATA = {
33
33
  "hero-block": {
34
34
  name: "Hero",
35
- description: "Full-width hero section with headline, subheadline, and CTA",
35
+ description: "Full-width hero section with headline, description, and CTA",
36
36
  category: "Marketing",
37
37
  icon: "image",
38
38
  fields: [
39
39
  { name: "headline", label: "Headline", type: "Text" },
40
- { name: "subheadline", label: "Subheadline", type: "Text" },
40
+ { name: "subheadline", label: "Description", type: "Text" },
41
41
  { name: "ctaText", label: "CTA Label", type: "Text" },
42
42
  { name: "ctaUrl", label: "CTA URL", type: "URL" },
43
43
  { name: "backgroundImage", label: "Background Image", type: "Image" }
@@ -248,7 +248,7 @@ var fileSchema = z5.object({
248
248
  var HeroAlignment = ["left", "center", "right"];
249
249
  var HeroBlockContentSchema = z6.object({
250
250
  headline: z6.string().min(1, "Headline is required").max(100, "Headline too long"),
251
- subheadline: z6.string().max(200, "Subheadline too long").optional(),
251
+ subheadline: z6.string().max(200, "Description too long").optional(),
252
252
  ctaText: z6.string().max(50, "CTA text too long").optional(),
253
253
  ctaUrl: z6.string().refine(
254
254
  (val) => {
@@ -687,7 +687,11 @@ function generateCmsOverlayScript(cmsParentOrigin) {
687
687
  setTimeout(sendReadySignal, 1500);
688
688
 
689
689
  function getBlockElement(blockId) {
690
- return document.querySelector('[data-block-id="' + blockId + '"]');
690
+ // Match the real block element, not the hidden sentinel <span> that shares
691
+ // the same data-block-id and precedes it in the DOM. The sentinel is
692
+ // display:none (a 0x0 rect), so selecting it would paint the outline at the
693
+ // top-left corner. Only the stamped block carries data-cms-block.
694
+ return document.querySelector('[data-cms-block][data-block-id="' + blockId + '"]');
691
695
  }
692
696
 
693
697
  function getAllBlocks() {
@@ -717,6 +721,14 @@ function generateCmsOverlayScript(cmsParentOrigin) {
717
721
  return;
718
722
  }
719
723
  var rect = el.getBoundingClientRect();
724
+ // A 0x0 rect means the element isn't laid out yet (or is hidden). Hide the
725
+ // outline instead of drawing a zero-size box with a floating label at the
726
+ // top-left corner.
727
+ if (rect.width === 0 && rect.height === 0) {
728
+ outlineEl.style.display = 'none';
729
+ if (label) label.classList.remove('cms-label-visible');
730
+ return;
731
+ }
720
732
  outlineEl.style.display = 'block';
721
733
  outlineEl.style.top = rect.top + 'px';
722
734
  outlineEl.style.left = rect.left + 'px';
@@ -1026,7 +1038,7 @@ function BlockRenderer({
1026
1038
  return null;
1027
1039
  }
1028
1040
  const language = routeParams ? Object.values(routeParams).find((p) => p.schemaName === "language")?.value : void 0;
1029
- const component = /* @__PURE__ */ jsx(Component, { content: block.content, routeParams, language });
1041
+ const component = /* @__PURE__ */ jsx(Component, { content: block.content, routeParams, language, path });
1030
1042
  if (disableEditable) {
1031
1043
  return component;
1032
1044
  }
@@ -1180,7 +1192,7 @@ async function renderParametricRoute({
1180
1192
  const blocks = [];
1181
1193
  for (const block of blockResults) {
1182
1194
  if (!block) continue;
1183
- const blockContent = previewMode ? block.draft_content : block.published_content;
1195
+ const blockContent = previewMode ? block.draft_content ?? block.published_content : block.published_content;
1184
1196
  if (blockContent == null) continue;
1185
1197
  let content = null;
1186
1198
  if (aiPreviewIndex !== null) {