@supernova-studio/client 0.27.0 → 0.28.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.27.0",
3
+ "version": "0.28.1",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -592,19 +592,28 @@ function serializeTextSpanAttribute(spanAttribute: PageBlockTextSpanAttribute):
592
592
  case "Code":
593
593
  return { type: "code", attrs: {} };
594
594
  case "Link":
595
- return {
596
- type: "link",
597
- attrs: {
598
- itemId: spanAttribute.documentationItemId,
599
- href: spanAttribute.link,
600
- target: spanAttribute.openInNewWindow ? "_blank" : "_self",
601
- rel: "noopener noreferrer nofollow",
602
- class: null,
603
- },
604
- };
595
+ if (spanAttribute.link) {
596
+ return serializeLinkMark(spanAttribute.link, spanAttribute.openInNewWindow ?? false);
597
+ } else if (spanAttribute.documentationItemId) {
598
+ return serializeLinkMark(`@page:${spanAttribute.documentationItemId}`, spanAttribute.openInNewWindow ?? false);
599
+ } else {
600
+ return serializeLinkMark("about:blank", spanAttribute.openInNewWindow ?? false);
601
+ }
605
602
  }
606
603
  }
607
604
 
605
+ function serializeLinkMark(href: string, openInNewWindow: boolean): ProsemirrorMark {
606
+ return {
607
+ type: "link",
608
+ attrs: {
609
+ href: href,
610
+ target: openInNewWindow ? "_blank" : "_self",
611
+ rel: "noopener noreferrer nofollow",
612
+ class: "tiptap-link",
613
+ },
614
+ };
615
+ }
616
+
608
617
  export function serializeAsCustomBlock(block: PageBlockEditorModel, definition: PageBlockDefinition): ProsemirrorNode {
609
618
  const items = block.data.items.map(i => {
610
619
  return {
@@ -11,6 +11,7 @@ const blocks: PageBlockDefinition[] = [
11
11
  name: "Text",
12
12
  description: "Plain text",
13
13
  category: "Text",
14
+ icon: "https://cdn-assets.supernova.io/blocks/icons/text.svg",
14
15
  searchKeywords: ["paragraph", "rich text"],
15
16
  item: {
16
17
  properties: [
@@ -72,6 +73,7 @@ const blocks: PageBlockDefinition[] = [
72
73
  name: "Title 1",
73
74
  description: "Main sections within the page",
74
75
  category: "Text",
76
+ icon: "https://cdn-assets.supernova.io/blocks/icons/title-1.svg",
75
77
  searchKeywords: ["heading", "h1"],
76
78
  item: {
77
79
  properties: [
@@ -134,6 +136,7 @@ const blocks: PageBlockDefinition[] = [
134
136
  name: "Title 2",
135
137
  description: "Section subheadings",
136
138
  category: "Text",
139
+ icon: "https://cdn-assets.supernova.io/blocks/icons/title-2.svg",
137
140
  searchKeywords: ["heading", "h2"],
138
141
  item: {
139
142
  properties: [
@@ -196,6 +199,7 @@ const blocks: PageBlockDefinition[] = [
196
199
  name: "Title 3",
197
200
  description: "Further subsections",
198
201
  category: "Text",
202
+ icon: "https://cdn-assets.supernova.io/blocks/icons/title-3.svg",
199
203
  searchKeywords: ["heading", "h3"],
200
204
  item: {
201
205
  properties: [
@@ -258,6 +262,7 @@ const blocks: PageBlockDefinition[] = [
258
262
  name: "Title 4",
259
263
  description: "Details in subsections",
260
264
  category: "Text",
265
+ icon: "https://cdn-assets.supernova.io/blocks/icons/title-4.svg",
261
266
  searchKeywords: ["heading", "h4"],
262
267
  item: {
263
268
  properties: [
@@ -320,6 +325,7 @@ const blocks: PageBlockDefinition[] = [
320
325
  name: "Title 5",
321
326
  description: "Nuanced details or sub-points",
322
327
  category: "Text",
328
+ icon: "https://cdn-assets.supernova.io/blocks/icons/title-5.svg",
323
329
  searchKeywords: ["heading", "h5"],
324
330
  item: {
325
331
  properties: [
@@ -382,6 +388,7 @@ const blocks: PageBlockDefinition[] = [
382
388
  name: "Ordered list",
383
389
  description: "A list with numbers",
384
390
  category: "Text",
391
+ icon: "https://cdn-assets.supernova.io/blocks/icons/list-ordered.svg",
385
392
  searchKeywords: ["ol"],
386
393
  item: {
387
394
  properties: [
@@ -443,6 +450,7 @@ const blocks: PageBlockDefinition[] = [
443
450
  name: "Unordered list",
444
451
  description: "A list with bullet points",
445
452
  category: "Text",
453
+ icon: "https://cdn-assets.supernova.io/blocks/icons/list-unordered.svg",
446
454
  searchKeywords: ["ul", "bullet points"],
447
455
  item: {
448
456
  properties: [
@@ -504,6 +512,7 @@ const blocks: PageBlockDefinition[] = [
504
512
  name: "Divider",
505
513
  description: "A section divider",
506
514
  category: "Layout",
515
+ icon: "https://cdn-assets.supernova.io/blocks/icons/divider.svg",
507
516
  searchKeywords: ["hr", "line", "rule", "separator"],
508
517
  item: {
509
518
  properties: [
@@ -563,6 +572,7 @@ const blocks: PageBlockDefinition[] = [
563
572
  name: "Blockquote",
564
573
  description: "Display a quotation",
565
574
  category: "Text",
575
+ icon: "https://cdn-assets.supernova.io/blocks/icons/blockquote.svg",
566
576
  searchKeywords: ["cite"],
567
577
  item: {
568
578
  properties: [
@@ -625,6 +635,7 @@ const blocks: PageBlockDefinition[] = [
625
635
  name: "Callout",
626
636
  description: "Highlight a section of text",
627
637
  category: "Text",
638
+ icon: "https://cdn-assets.supernova.io/blocks/icons/callout.svg",
628
639
  searchKeywords: ["banner", "alert", "note", "tip", "warning"],
629
640
  item: {
630
641
  properties: [
@@ -687,6 +698,7 @@ const blocks: PageBlockDefinition[] = [
687
698
  name: "Image",
688
699
  description: "Display an image or Figma frame",
689
700
  category: "Media",
701
+ icon: "https://cdn-assets.supernova.io/blocks/icons/image.svg",
690
702
  searchKeywords: ["image", "figma", "frame", "picture", "photo"],
691
703
  item: {
692
704
  properties: [
@@ -749,6 +761,7 @@ const blocks: PageBlockDefinition[] = [
749
761
  name: "Shortcut links",
750
762
  description: "Link to a page or external URL",
751
763
  category: "Media",
764
+ icon: "https://cdn-assets.supernova.io/blocks/icons/shortcuts.svg",
752
765
  searchKeywords: [],
753
766
  item: {
754
767
  properties: [
@@ -765,6 +778,9 @@ const blocks: PageBlockDefinition[] = [
765
778
  width: "Icon",
766
779
  aspectRatio: "Square",
767
780
  },
781
+ imageOnLeft: {
782
+ width: "Medium",
783
+ },
768
784
  iconOnLeft: {
769
785
  width: "Icon",
770
786
  aspectRatio: "Square",
@@ -929,6 +945,7 @@ const blocks: PageBlockDefinition[] = [
929
945
  name: "Accessibility Color Grid",
930
946
  description: "Visualize accessibility of your color tokens.",
931
947
  category: "Tokens",
948
+ icon: "https://cdn-assets.supernova.io/blocks/icons/token-a11y-contrast-grid.svg",
932
949
  searchKeywords: ["color", "accessibility", "grid", "contrast", "blind", "impairment"],
933
950
  item: {
934
951
  properties: [
@@ -992,6 +1009,7 @@ const blocks: PageBlockDefinition[] = [
992
1009
  name: "Embed",
993
1010
  description: "Embed a generic URL",
994
1011
  category: "Media",
1012
+ icon: "https://cdn-assets.supernova.io/blocks/icons/embed.svg",
995
1013
  searchKeywords: ["embed", "url", "iframe", "site", "import"],
996
1014
  item: {
997
1015
  properties: [
@@ -1057,6 +1075,7 @@ const blocks: PageBlockDefinition[] = [
1057
1075
  name: "YouTube",
1058
1076
  description: "Embed a Youtube video",
1059
1077
  category: "Media",
1078
+ icon: "https://cdn-assets.supernova.io/blocks/icons/embed-youtube.svg",
1060
1079
  searchKeywords: ["embed", "video", "player", "upload"],
1061
1080
  item: {
1062
1081
  properties: [
@@ -1122,6 +1141,7 @@ const blocks: PageBlockDefinition[] = [
1122
1141
  name: "Lottie animation",
1123
1142
  description: "Preview a Lottie animation",
1124
1143
  category: "Media",
1144
+ icon: "https://cdn-assets.supernova.io/blocks/icons/lottie.svg",
1125
1145
  searchKeywords: ["embed", "lottie", "animation", "rive", "json"],
1126
1146
  item: {
1127
1147
  properties: [
@@ -1225,6 +1245,7 @@ const blocks: PageBlockDefinition[] = [
1225
1245
  name: "Storybook",
1226
1246
  description: "Embed Storybook canvas",
1227
1247
  category: "Media",
1248
+ icon: "https://cdn-assets.supernova.io/blocks/icons/storybook.svg",
1228
1249
  searchKeywords: ["storybook", "story", "stories", "example", "preview", "code", "react"],
1229
1250
  item: {
1230
1251
  properties: [
@@ -1288,6 +1309,7 @@ const blocks: PageBlockDefinition[] = [
1288
1309
  name: "Figma embed",
1289
1310
  description: "Embed a Figma canvas or prototype",
1290
1311
  category: "Media",
1312
+ icon: "https://cdn-assets.supernova.io/blocks/icons/embed-figma.svg",
1291
1313
  searchKeywords: ["embed", "figma", "design", "prototype", "canvas"],
1292
1314
  item: {
1293
1315
  properties: [
@@ -1352,6 +1374,7 @@ const blocks: PageBlockDefinition[] = [
1352
1374
  name: "Markdown",
1353
1375
  description: "Render Markdown URL",
1354
1376
  category: "Other",
1377
+ icon: "https://cdn-assets.supernova.io/blocks/icons/markdown.svg",
1355
1378
  searchKeywords: ["md", "embed", "api", "table", "mdx"],
1356
1379
  item: {
1357
1380
  properties: [
@@ -1453,6 +1476,7 @@ const blocks: PageBlockDefinition[] = [
1453
1476
  name: "Table",
1454
1477
  description: "Display a simple table",
1455
1478
  category: "Layout",
1479
+ icon: "https://cdn-assets.supernova.io/blocks/icons/table.svg",
1456
1480
  searchKeywords: ["grid", "data", "spreadsheet", "api"],
1457
1481
  item: {
1458
1482
  properties: [
@@ -1512,6 +1536,7 @@ const blocks: PageBlockDefinition[] = [
1512
1536
  name: "Token detail",
1513
1537
  description: "Show a single design tokens",
1514
1538
  category: "Tokens",
1539
+ icon: "https://cdn-assets.supernova.io/blocks/icons/token-detail.svg",
1515
1540
  searchKeywords: ["color", "typography", "spacing", "grid", "material", "theme"],
1516
1541
  item: {
1517
1542
  properties: [
@@ -1615,6 +1640,7 @@ const blocks: PageBlockDefinition[] = [
1615
1640
  name: "Token list",
1616
1641
  description: "Show a list of design tokens",
1617
1642
  category: "Tokens",
1643
+ icon: "https://cdn-assets.supernova.io/blocks/icons/token-list.svg",
1618
1644
  searchKeywords: ["color", "typography", "spacing", "grid", "material", "theme"],
1619
1645
  item: {
1620
1646
  properties: [
@@ -1724,6 +1750,7 @@ const blocks: PageBlockDefinition[] = [
1724
1750
  name: "Token group",
1725
1751
  description: "Show a group of design tokens",
1726
1752
  category: "Tokens",
1753
+ icon: "https://cdn-assets.supernova.io/blocks/icons/token-list.svg",
1727
1754
  searchKeywords: ["color", "typography", "spacing", "grid", "material", "theme"],
1728
1755
  item: {
1729
1756
  properties: [
@@ -1832,6 +1859,7 @@ const blocks: PageBlockDefinition[] = [
1832
1859
  name: "Code",
1833
1860
  description: "Code description",
1834
1861
  category: "Code",
1862
+ icon: "https://cdn-assets.supernova.io/blocks/icons/code.svg",
1835
1863
  searchKeywords: ["code"],
1836
1864
  item: {
1837
1865
  properties: [
@@ -1890,6 +1918,7 @@ const blocks: PageBlockDefinition[] = [
1890
1918
  name: "React code",
1891
1919
  description: "Render React code",
1892
1920
  category: "Code",
1921
+ icon: "https://cdn-assets.supernova.io/blocks/icons/code-react.svg",
1893
1922
  searchKeywords: ["code", "react", "snippet", "storybook", "editor", "example"],
1894
1923
  item: {
1895
1924
  properties: [
@@ -2025,6 +2054,7 @@ const blocks: PageBlockDefinition[] = [
2025
2054
  name: "Link",
2026
2055
  description: "Preview of a link",
2027
2056
  category: "Media",
2057
+ icon: "https://cdn-assets.supernova.io/blocks/icons/shortcut-link.svg",
2028
2058
  searchKeywords: [],
2029
2059
  item: {
2030
2060
  properties: [
@@ -2082,6 +2112,7 @@ const blocks: PageBlockDefinition[] = [
2082
2112
  name: "Assets",
2083
2113
  description: "Display icons or illustrations",
2084
2114
  category: "Assets",
2115
+ icon: "https://cdn-assets.supernova.io/blocks/icons/assets.svg",
2085
2116
  searchKeywords: ["icons", "illustrations", "grid", "svg", "logos", "theme"],
2086
2117
  item: {
2087
2118
  properties: [
@@ -2184,6 +2215,7 @@ const blocks: PageBlockDefinition[] = [
2184
2215
  name: "Figma frames",
2185
2216
  description: "Display Figma frames as images",
2186
2217
  category: "Figma",
2218
+ icon: "https://cdn-assets.supernova.io/blocks/icons/figma-frames.svg",
2187
2219
  searchKeywords: ["figma", "frames", "image"],
2188
2220
  item: {
2189
2221
  properties: [
@@ -2266,6 +2298,7 @@ const blocks: PageBlockDefinition[] = [
2266
2298
  name: "Release notes",
2267
2299
  description: "Show version release notes",
2268
2300
  category: "Other",
2301
+ icon: "https://cdn-assets.supernova.io/blocks/icons/release-notes.svg",
2269
2302
  searchKeywords: ["version", "changelog", "history"],
2270
2303
  item: {
2271
2304
  properties: [],
@@ -2318,6 +2351,7 @@ const blocks: PageBlockDefinition[] = [
2318
2351
  name: "Component checklist",
2319
2352
  description: "Highlight specific features of your components",
2320
2353
  category: "Components",
2354
+ icon: "https://cdn-assets.supernova.io/blocks/icons/component-checklist.svg",
2321
2355
  searchKeywords: ["components", "health", "properties", "overview", "status"],
2322
2356
  item: {
2323
2357
  properties: [
@@ -2397,6 +2431,7 @@ const blocks: PageBlockDefinition[] = [
2397
2431
  name: "Component overview table",
2398
2432
  description: "Show the overview of all your components",
2399
2433
  category: "Components",
2434
+ icon: "https://cdn-assets.supernova.io/blocks/icons/component-overview-table.svg",
2400
2435
  searchKeywords: ["components", "health", "properties", "overview", "status"],
2401
2436
  item: {
2402
2437
  properties: [
@@ -2468,6 +2503,7 @@ const blocks: PageBlockDefinition[] = [
2468
2503
  name: "Component health",
2469
2504
  description: "Show component health and additional attributes",
2470
2505
  category: "Components",
2506
+ icon: "https://cdn-assets.supernova.io/blocks/icons/component-health.svg",
2471
2507
  searchKeywords: ["components", "health", "properties", "overview", "status"],
2472
2508
  item: {
2473
2509
  properties: [
@@ -363,20 +363,34 @@ function parseRichTextAttribute(mark: ProsemirrorMark): PageBlockTextSpanAttribu
363
363
  case "code":
364
364
  return { type: "Code" };
365
365
  case "link":
366
- const itemId = getProsemirrorAttribute(mark, "itemId", z.string().optional());
367
- const href = getProsemirrorAttribute(mark, "href", z.string().optional());
368
-
369
- return {
370
- type: "Link",
371
- openInNewWindow: mark.attrs?.target !== "_self",
372
- documentationItemId: itemId,
373
- link: href,
374
- };
366
+ return parseProsemirrorLink(mark);
375
367
  }
376
368
 
377
369
  return null;
378
370
  }
379
371
 
372
+ function parseProsemirrorLink(mark: ProsemirrorMark): PageBlockTextSpanAttribute | null {
373
+ const href = getProsemirrorAttribute(mark, "href", z.string().optional());
374
+ if (!href) return null;
375
+
376
+ const target = getProsemirrorAttribute(mark, "target", z.string().optional());
377
+ const openInNewWindow = target === "_blank";
378
+
379
+ if (href.startsWith("@")) {
380
+ return {
381
+ type: "Link",
382
+ openInNewWindow: openInNewWindow,
383
+ documentationItemId: href.split(":")[1],
384
+ };
385
+ } else {
386
+ return {
387
+ type: "Link",
388
+ openInNewWindow: openInNewWindow,
389
+ link: href,
390
+ };
391
+ }
392
+ }
393
+
380
394
  //
381
395
  // Embed
382
396
  //