@supernova-studio/client 0.10.2 → 0.12.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.
@@ -41,6 +41,7 @@ import {
41
41
  ColorValue,
42
42
  nullishToOptional,
43
43
  PageBlockItemFigmaNodeValue,
44
+ PageBlockColorV2,
44
45
  } from "@supernova-studio/model";
45
46
  import { PageBlockEditorModel } from "./model/block";
46
47
  import { DocumentationPageEditorModel } from "./model/page";
@@ -107,11 +108,6 @@ export function prosemirrorNodeToBlock(
107
108
  return parseAsMultiRichText(prosemirrorNode, definition, multiRichTextProperty);
108
109
  }
109
110
 
110
- const embedProperty = BlockDefinitionUtils.firstEmbedProperty(definition);
111
- if (prosemirrorNode.type === "embed" && embedProperty) {
112
- return parseAsEmbed(prosemirrorNode, definition, embedProperty);
113
- }
114
-
115
111
  const tableProperty = BlockDefinitionUtils.firstTableProperty(definition);
116
112
  if (tableProperty) {
117
113
  return parseAsTable(prosemirrorNode, definition, tableProperty);
@@ -214,7 +210,7 @@ function parseAsMultiRichText(
214
210
  // Required
215
211
  value: (prosemirrorNode.content ?? [])
216
212
  .map(listItem => {
217
- if (listItem.type !== "listitem") return null;
213
+ if (listItem.type !== "listItem") return null;
218
214
  if (!listItem.content?.length) return parseRichText([]);
219
215
 
220
216
  const paragraph = listItem.content[0];
@@ -327,6 +323,7 @@ function parseAsTable(
327
323
  data: {
328
324
  packageId: "io.supernova.block.table",
329
325
  indentLevel: 0,
326
+ variantId: "default",
330
327
 
331
328
  ...(variantId && { variantId: variantId }),
332
329
 
@@ -454,48 +451,6 @@ function emptyTableCellContent(): PageBlockItemTableNode[] {
454
451
  ];
455
452
  }
456
453
 
457
- //
458
- // Embed
459
- //
460
-
461
- function parseAsEmbed(
462
- prosemirrorNode: ProsemirrorNode,
463
- definition: PageBlockDefinition,
464
- property: PageBlockDefinitionProperty
465
- ): PageBlockEditorModel | null {
466
- const id = getProsemirrorBlockId(prosemirrorNode);
467
- if (!id) return null;
468
-
469
- const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
470
-
471
- const url = getProsemirrorAttribute(prosemirrorNode, "url", z.string().optional());
472
- const caption = getProsemirrorAttribute(prosemirrorNode, "caption", z.string().optional());
473
- const height = getProsemirrorAttribute(prosemirrorNode, "height", z.number().optional());
474
-
475
- return {
476
- id: id,
477
- data: {
478
- packageId: definition.id,
479
- indentLevel: 0,
480
-
481
- ...(variantId && { variantId: variantId }),
482
-
483
- items: [
484
- {
485
- id: id,
486
- props: {
487
- [property.id]: {
488
- value: url,
489
- caption: caption,
490
- height: height ?? 200,
491
- } as PageBlockItemEmbedValue,
492
- },
493
- },
494
- ],
495
- },
496
- };
497
- }
498
-
499
454
  //
500
455
  // Divider
501
456
  //
@@ -576,7 +531,7 @@ function parseAppearance(prosemirrorNode: ProsemirrorNode): PageBlockAppearanceV
576
531
 
577
532
  const backgroundColor = getProsemirrorAttribute(prosemirrorNode, "backgroundColor", z.string().optional());
578
533
  if (backgroundColor) {
579
- const parsedColor = ColorValue.safeParse(JSON.parse(backgroundColor));
534
+ const parsedColor = PageBlockColorV2.safeParse(JSON.parse(backgroundColor));
580
535
  if (parsedColor.success) {
581
536
  appearance.itemBackgroundColor = parsedColor.data;
582
537
  }
@@ -613,7 +568,7 @@ function parseItem(rawItem: unknown, definition: PageBlockDefinition): PageBlock
613
568
 
614
569
  return {
615
570
  id: parsedItem.data.id,
616
- linksTo: parsedItem.data.linksTo,
571
+ ...(parsedItem.data.linksTo && { linksTo: parsedItem.data.linksTo }),
617
572
  props: sanitizedProps,
618
573
  };
619
574
  }