@supernova-studio/client 0.23.0 → 0.25.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.
@@ -48,6 +48,7 @@ import { DocumentationPageEditorModel } from "./model/page";
48
48
  import { BlockDefinitionUtils } from "./utils";
49
49
  import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
50
50
  import { ZodAnyDef, ZodSchema, ZodTypeDef, z } from "zod";
51
+ import { o } from "vitest/dist/types-198fd1d9";
51
52
 
52
53
  export function yDocToPage(yDoc: Y.Doc, definitions: PageBlockDefinition[]): DocumentationPageEditorModel {
53
54
  return yXmlFragmentToPage(yDoc.getXmlFragment("default"), definitions);
@@ -378,26 +379,34 @@ function parseTableCellAlignment(alignment: unknown): PageBlockTableCellAlignmen
378
379
  }
379
380
 
380
381
  function parseAsTableNode(prosemirrorNode: ProsemirrorNode): PageBlockItemTableNode | null {
382
+ const id = getProsemirrorBlockId(prosemirrorNode);
383
+ if (!id) return null;
384
+
381
385
  switch (prosemirrorNode.type) {
382
386
  case "paragraph":
383
387
  return {
384
388
  type: "RichText",
389
+ id: id,
385
390
  value: parseRichText(prosemirrorNode.content ?? []),
386
391
  };
387
392
 
388
393
  case "image":
389
- const url = getProsemirrorAttribute(prosemirrorNode, "src", z.string().optional());
390
- if (!url) return null;
394
+ const items = getProsemirrorAttribute(prosemirrorNode, "items", z.string());
395
+ if (!items) return null;
396
+
397
+ const parsedItems = PageBlockItemV2.array().safeParse(JSON.parse(items));
398
+ if (!parsedItems.success) return null;
399
+
400
+ const rawImagePropertyValue = parsedItems.data[0]?.props.image;
401
+ if (!rawImagePropertyValue) return null;
402
+
403
+ const imagePropertyValueParseResult = PageBlockItemImageValue.safeParse(rawImagePropertyValue);
404
+ if (!imagePropertyValueParseResult.success) return null;
391
405
 
392
406
  return {
393
407
  type: "Image",
394
- value: {
395
- type: "Resource",
396
- resource: {
397
- resourceId: "",
398
- url: url,
399
- },
400
- },
408
+ id: id,
409
+ value: imagePropertyValueParseResult.data.value,
401
410
  };
402
411
 
403
412
  default:
@@ -449,6 +458,7 @@ function emptyTableCellContent(): PageBlockItemTableNode[] {
449
458
  return [
450
459
  {
451
460
  type: "RichText",
461
+ id: "",
452
462
  value: { spans: [] },
453
463
  },
454
464
  ];