@supernova-studio/client 0.26.0 → 0.27.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/index.d.mts +98 -6
- package/dist/index.d.ts +98 -6
- package/dist/index.js +37 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +1 -0
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +49 -22
package/dist/index.d.mts
CHANGED
|
@@ -11666,7 +11666,49 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11666
11666
|
name: z.ZodString;
|
|
11667
11667
|
description: z.ZodString;
|
|
11668
11668
|
category: z.ZodEnum<["Text", "Layout", "Media", "Embed", "Figma", "Code", "Guidelines", "Tokens", "Components", "Assets", "Data", "Other"]>;
|
|
11669
|
-
icon: z.ZodOptional<z.ZodObject<{
|
|
11669
|
+
icon: z.ZodOptional<z.ZodObject<{
|
|
11670
|
+
type: z.ZodEnum<["Resource", "FigmaNode"]>;
|
|
11671
|
+
resource: z.ZodOptional<z.ZodObject<{
|
|
11672
|
+
url: z.ZodString;
|
|
11673
|
+
resourceId: z.ZodString;
|
|
11674
|
+
}, "strip", z.ZodTypeAny, {
|
|
11675
|
+
url: string;
|
|
11676
|
+
resourceId: string;
|
|
11677
|
+
}, {
|
|
11678
|
+
url: string;
|
|
11679
|
+
resourceId: string;
|
|
11680
|
+
}>>;
|
|
11681
|
+
figmaFile: z.ZodOptional<z.ZodObject<{
|
|
11682
|
+
sourceId: z.ZodString;
|
|
11683
|
+
frameReferenceId: z.ZodString;
|
|
11684
|
+
}, "strip", z.ZodTypeAny, {
|
|
11685
|
+
sourceId: string;
|
|
11686
|
+
frameReferenceId: string;
|
|
11687
|
+
}, {
|
|
11688
|
+
sourceId: string;
|
|
11689
|
+
frameReferenceId: string;
|
|
11690
|
+
}>>;
|
|
11691
|
+
}, "strip", z.ZodTypeAny, {
|
|
11692
|
+
type: "FigmaNode" | "Resource";
|
|
11693
|
+
resource?: {
|
|
11694
|
+
url: string;
|
|
11695
|
+
resourceId: string;
|
|
11696
|
+
} | undefined;
|
|
11697
|
+
figmaFile?: {
|
|
11698
|
+
sourceId: string;
|
|
11699
|
+
frameReferenceId: string;
|
|
11700
|
+
} | undefined;
|
|
11701
|
+
}, {
|
|
11702
|
+
type: "FigmaNode" | "Resource";
|
|
11703
|
+
resource?: {
|
|
11704
|
+
url: string;
|
|
11705
|
+
resourceId: string;
|
|
11706
|
+
} | undefined;
|
|
11707
|
+
figmaFile?: {
|
|
11708
|
+
sourceId: string;
|
|
11709
|
+
frameReferenceId: string;
|
|
11710
|
+
} | undefined;
|
|
11711
|
+
}>>;
|
|
11670
11712
|
documentationLink: z.ZodOptional<z.ZodString>;
|
|
11671
11713
|
searchKeywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11672
11714
|
item: z.ZodObject<{
|
|
@@ -11984,7 +12026,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11984
12026
|
documentationLink?: string | undefined;
|
|
11985
12027
|
} | undefined;
|
|
11986
12028
|
};
|
|
11987
|
-
icon?: {
|
|
12029
|
+
icon?: {
|
|
12030
|
+
type: "FigmaNode" | "Resource";
|
|
12031
|
+
resource?: {
|
|
12032
|
+
url: string;
|
|
12033
|
+
resourceId: string;
|
|
12034
|
+
} | undefined;
|
|
12035
|
+
figmaFile?: {
|
|
12036
|
+
sourceId: string;
|
|
12037
|
+
frameReferenceId: string;
|
|
12038
|
+
} | undefined;
|
|
12039
|
+
} | undefined;
|
|
11988
12040
|
documentationLink?: string | undefined;
|
|
11989
12041
|
searchKeywords?: string[] | undefined;
|
|
11990
12042
|
appearance?: {
|
|
@@ -12052,7 +12104,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12052
12104
|
documentationLink?: string | undefined;
|
|
12053
12105
|
} | undefined;
|
|
12054
12106
|
};
|
|
12055
|
-
icon?: {
|
|
12107
|
+
icon?: {
|
|
12108
|
+
type: "FigmaNode" | "Resource";
|
|
12109
|
+
resource?: {
|
|
12110
|
+
url: string;
|
|
12111
|
+
resourceId: string;
|
|
12112
|
+
} | undefined;
|
|
12113
|
+
figmaFile?: {
|
|
12114
|
+
sourceId: string;
|
|
12115
|
+
frameReferenceId: string;
|
|
12116
|
+
} | undefined;
|
|
12117
|
+
} | undefined;
|
|
12056
12118
|
documentationLink?: string | undefined;
|
|
12057
12119
|
searchKeywords?: string[] | undefined;
|
|
12058
12120
|
appearance?: {
|
|
@@ -12122,7 +12184,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12122
12184
|
documentationLink?: string | undefined;
|
|
12123
12185
|
} | undefined;
|
|
12124
12186
|
};
|
|
12125
|
-
icon?: {
|
|
12187
|
+
icon?: {
|
|
12188
|
+
type: "FigmaNode" | "Resource";
|
|
12189
|
+
resource?: {
|
|
12190
|
+
url: string;
|
|
12191
|
+
resourceId: string;
|
|
12192
|
+
} | undefined;
|
|
12193
|
+
figmaFile?: {
|
|
12194
|
+
sourceId: string;
|
|
12195
|
+
frameReferenceId: string;
|
|
12196
|
+
} | undefined;
|
|
12197
|
+
} | undefined;
|
|
12126
12198
|
documentationLink?: string | undefined;
|
|
12127
12199
|
searchKeywords?: string[] | undefined;
|
|
12128
12200
|
appearance?: {
|
|
@@ -12192,7 +12264,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12192
12264
|
documentationLink?: string | undefined;
|
|
12193
12265
|
} | undefined;
|
|
12194
12266
|
};
|
|
12195
|
-
icon?: {
|
|
12267
|
+
icon?: {
|
|
12268
|
+
type: "FigmaNode" | "Resource";
|
|
12269
|
+
resource?: {
|
|
12270
|
+
url: string;
|
|
12271
|
+
resourceId: string;
|
|
12272
|
+
} | undefined;
|
|
12273
|
+
figmaFile?: {
|
|
12274
|
+
sourceId: string;
|
|
12275
|
+
frameReferenceId: string;
|
|
12276
|
+
} | undefined;
|
|
12277
|
+
} | undefined;
|
|
12196
12278
|
documentationLink?: string | undefined;
|
|
12197
12279
|
searchKeywords?: string[] | undefined;
|
|
12198
12280
|
appearance?: {
|
|
@@ -14431,7 +14513,17 @@ declare function blockDefinitionForBlock(block: PageBlockEditorModel, definition
|
|
|
14431
14513
|
documentationLink?: string | undefined;
|
|
14432
14514
|
} | undefined;
|
|
14433
14515
|
};
|
|
14434
|
-
icon?: {
|
|
14516
|
+
icon?: {
|
|
14517
|
+
type: "FigmaNode" | "Resource";
|
|
14518
|
+
resource?: {
|
|
14519
|
+
url: string;
|
|
14520
|
+
resourceId: string;
|
|
14521
|
+
} | undefined;
|
|
14522
|
+
figmaFile?: {
|
|
14523
|
+
sourceId: string;
|
|
14524
|
+
frameReferenceId: string;
|
|
14525
|
+
} | undefined;
|
|
14526
|
+
} | undefined;
|
|
14435
14527
|
documentationLink?: string | undefined;
|
|
14436
14528
|
searchKeywords?: string[] | undefined;
|
|
14437
14529
|
appearance?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -11666,7 +11666,49 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11666
11666
|
name: z.ZodString;
|
|
11667
11667
|
description: z.ZodString;
|
|
11668
11668
|
category: z.ZodEnum<["Text", "Layout", "Media", "Embed", "Figma", "Code", "Guidelines", "Tokens", "Components", "Assets", "Data", "Other"]>;
|
|
11669
|
-
icon: z.ZodOptional<z.ZodObject<{
|
|
11669
|
+
icon: z.ZodOptional<z.ZodObject<{
|
|
11670
|
+
type: z.ZodEnum<["Resource", "FigmaNode"]>;
|
|
11671
|
+
resource: z.ZodOptional<z.ZodObject<{
|
|
11672
|
+
url: z.ZodString;
|
|
11673
|
+
resourceId: z.ZodString;
|
|
11674
|
+
}, "strip", z.ZodTypeAny, {
|
|
11675
|
+
url: string;
|
|
11676
|
+
resourceId: string;
|
|
11677
|
+
}, {
|
|
11678
|
+
url: string;
|
|
11679
|
+
resourceId: string;
|
|
11680
|
+
}>>;
|
|
11681
|
+
figmaFile: z.ZodOptional<z.ZodObject<{
|
|
11682
|
+
sourceId: z.ZodString;
|
|
11683
|
+
frameReferenceId: z.ZodString;
|
|
11684
|
+
}, "strip", z.ZodTypeAny, {
|
|
11685
|
+
sourceId: string;
|
|
11686
|
+
frameReferenceId: string;
|
|
11687
|
+
}, {
|
|
11688
|
+
sourceId: string;
|
|
11689
|
+
frameReferenceId: string;
|
|
11690
|
+
}>>;
|
|
11691
|
+
}, "strip", z.ZodTypeAny, {
|
|
11692
|
+
type: "FigmaNode" | "Resource";
|
|
11693
|
+
resource?: {
|
|
11694
|
+
url: string;
|
|
11695
|
+
resourceId: string;
|
|
11696
|
+
} | undefined;
|
|
11697
|
+
figmaFile?: {
|
|
11698
|
+
sourceId: string;
|
|
11699
|
+
frameReferenceId: string;
|
|
11700
|
+
} | undefined;
|
|
11701
|
+
}, {
|
|
11702
|
+
type: "FigmaNode" | "Resource";
|
|
11703
|
+
resource?: {
|
|
11704
|
+
url: string;
|
|
11705
|
+
resourceId: string;
|
|
11706
|
+
} | undefined;
|
|
11707
|
+
figmaFile?: {
|
|
11708
|
+
sourceId: string;
|
|
11709
|
+
frameReferenceId: string;
|
|
11710
|
+
} | undefined;
|
|
11711
|
+
}>>;
|
|
11670
11712
|
documentationLink: z.ZodOptional<z.ZodString>;
|
|
11671
11713
|
searchKeywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11672
11714
|
item: z.ZodObject<{
|
|
@@ -11984,7 +12026,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11984
12026
|
documentationLink?: string | undefined;
|
|
11985
12027
|
} | undefined;
|
|
11986
12028
|
};
|
|
11987
|
-
icon?: {
|
|
12029
|
+
icon?: {
|
|
12030
|
+
type: "FigmaNode" | "Resource";
|
|
12031
|
+
resource?: {
|
|
12032
|
+
url: string;
|
|
12033
|
+
resourceId: string;
|
|
12034
|
+
} | undefined;
|
|
12035
|
+
figmaFile?: {
|
|
12036
|
+
sourceId: string;
|
|
12037
|
+
frameReferenceId: string;
|
|
12038
|
+
} | undefined;
|
|
12039
|
+
} | undefined;
|
|
11988
12040
|
documentationLink?: string | undefined;
|
|
11989
12041
|
searchKeywords?: string[] | undefined;
|
|
11990
12042
|
appearance?: {
|
|
@@ -12052,7 +12104,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12052
12104
|
documentationLink?: string | undefined;
|
|
12053
12105
|
} | undefined;
|
|
12054
12106
|
};
|
|
12055
|
-
icon?: {
|
|
12107
|
+
icon?: {
|
|
12108
|
+
type: "FigmaNode" | "Resource";
|
|
12109
|
+
resource?: {
|
|
12110
|
+
url: string;
|
|
12111
|
+
resourceId: string;
|
|
12112
|
+
} | undefined;
|
|
12113
|
+
figmaFile?: {
|
|
12114
|
+
sourceId: string;
|
|
12115
|
+
frameReferenceId: string;
|
|
12116
|
+
} | undefined;
|
|
12117
|
+
} | undefined;
|
|
12056
12118
|
documentationLink?: string | undefined;
|
|
12057
12119
|
searchKeywords?: string[] | undefined;
|
|
12058
12120
|
appearance?: {
|
|
@@ -12122,7 +12184,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12122
12184
|
documentationLink?: string | undefined;
|
|
12123
12185
|
} | undefined;
|
|
12124
12186
|
};
|
|
12125
|
-
icon?: {
|
|
12187
|
+
icon?: {
|
|
12188
|
+
type: "FigmaNode" | "Resource";
|
|
12189
|
+
resource?: {
|
|
12190
|
+
url: string;
|
|
12191
|
+
resourceId: string;
|
|
12192
|
+
} | undefined;
|
|
12193
|
+
figmaFile?: {
|
|
12194
|
+
sourceId: string;
|
|
12195
|
+
frameReferenceId: string;
|
|
12196
|
+
} | undefined;
|
|
12197
|
+
} | undefined;
|
|
12126
12198
|
documentationLink?: string | undefined;
|
|
12127
12199
|
searchKeywords?: string[] | undefined;
|
|
12128
12200
|
appearance?: {
|
|
@@ -12192,7 +12264,17 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12192
12264
|
documentationLink?: string | undefined;
|
|
12193
12265
|
} | undefined;
|
|
12194
12266
|
};
|
|
12195
|
-
icon?: {
|
|
12267
|
+
icon?: {
|
|
12268
|
+
type: "FigmaNode" | "Resource";
|
|
12269
|
+
resource?: {
|
|
12270
|
+
url: string;
|
|
12271
|
+
resourceId: string;
|
|
12272
|
+
} | undefined;
|
|
12273
|
+
figmaFile?: {
|
|
12274
|
+
sourceId: string;
|
|
12275
|
+
frameReferenceId: string;
|
|
12276
|
+
} | undefined;
|
|
12277
|
+
} | undefined;
|
|
12196
12278
|
documentationLink?: string | undefined;
|
|
12197
12279
|
searchKeywords?: string[] | undefined;
|
|
12198
12280
|
appearance?: {
|
|
@@ -14431,7 +14513,17 @@ declare function blockDefinitionForBlock(block: PageBlockEditorModel, definition
|
|
|
14431
14513
|
documentationLink?: string | undefined;
|
|
14432
14514
|
} | undefined;
|
|
14433
14515
|
};
|
|
14434
|
-
icon?: {
|
|
14516
|
+
icon?: {
|
|
14517
|
+
type: "FigmaNode" | "Resource";
|
|
14518
|
+
resource?: {
|
|
14519
|
+
url: string;
|
|
14520
|
+
resourceId: string;
|
|
14521
|
+
} | undefined;
|
|
14522
|
+
figmaFile?: {
|
|
14523
|
+
sourceId: string;
|
|
14524
|
+
frameReferenceId: string;
|
|
14525
|
+
} | undefined;
|
|
14526
|
+
} | undefined;
|
|
14435
14527
|
documentationLink?: string | undefined;
|
|
14436
14528
|
searchKeywords?: string[] | undefined;
|
|
14437
14529
|
appearance?: {
|
package/dist/index.js
CHANGED
|
@@ -2116,7 +2116,7 @@ var PageBlockDefinition = _zod.z.object({
|
|
|
2116
2116
|
name: _zod.z.string(),
|
|
2117
2117
|
description: _zod.z.string(),
|
|
2118
2118
|
category: PageBlockCategory,
|
|
2119
|
-
icon:
|
|
2119
|
+
icon: PageBlockImageReference.optional(),
|
|
2120
2120
|
documentationLink: _zod.z.string().optional(),
|
|
2121
2121
|
searchKeywords: _zod.z.array(_zod.z.string()).optional(),
|
|
2122
2122
|
item: PageBlockDefinitionItem,
|
|
@@ -5380,6 +5380,7 @@ function serializeAsCustomBlock(block, definition) {
|
|
|
5380
5380
|
definitionId: block.data.packageId,
|
|
5381
5381
|
...block.data.variantId && { variantId: block.data.variantId },
|
|
5382
5382
|
items: JSON.stringify(items),
|
|
5383
|
+
...block.data.appearance && { appearance: JSON.stringify(block.data.appearance) },
|
|
5383
5384
|
...columns && { columns }
|
|
5384
5385
|
}
|
|
5385
5386
|
};
|
|
@@ -7920,7 +7921,7 @@ function yXmlFragmentToPage(fragment, definitions) {
|
|
|
7920
7921
|
function prosemirrorDocToPage(prosemirrorDoc, definitions) {
|
|
7921
7922
|
const definitionsById = mapByUnique2(definitions, (d) => d.id);
|
|
7922
7923
|
return {
|
|
7923
|
-
blocks:
|
|
7924
|
+
blocks: internalProsemirrorNodesToPageItems(_nullishCoalesce(prosemirrorDoc.content, () => ( [])), definitionsById)
|
|
7924
7925
|
};
|
|
7925
7926
|
}
|
|
7926
7927
|
function prosemirrorNodeToSection(prosemirrorNode, definitions) {
|
|
@@ -7966,24 +7967,36 @@ function prosemirrorNodesToBlocks(prosemirrorNodes, definitions) {
|
|
|
7966
7967
|
const definitionsById = mapByUnique2(definitions, (d) => d.id);
|
|
7967
7968
|
return internalProsemirrorNodesToBlocks(prosemirrorNodes, definitionsById);
|
|
7968
7969
|
}
|
|
7969
|
-
function
|
|
7970
|
+
function internalProsemirrorNodesToPageItems(prosemirrorNodes, definitionsMap) {
|
|
7970
7971
|
return prosemirrorNodes.map((prosemirrorNode) => {
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
return
|
|
7975
|
-
}
|
|
7976
|
-
const definition = definitionsMap.get(definitionId);
|
|
7977
|
-
if (!definition) {
|
|
7978
|
-
console.warn(
|
|
7979
|
-
`Block definitionId "${definitionId}" (prosemirror node ${prosemirrorNode.type}) is not among available definitions`
|
|
7980
|
-
);
|
|
7981
|
-
console.warn(prosemirrorNode);
|
|
7982
|
-
return null;
|
|
7972
|
+
if (prosemirrorNode.type === "tabsSection") {
|
|
7973
|
+
return prosemirrorNodeToSection(prosemirrorNode, Array.from(definitionsMap.values()));
|
|
7974
|
+
} else {
|
|
7975
|
+
return internalProsemirrorNodeToBlock(prosemirrorNode, definitionsMap);
|
|
7983
7976
|
}
|
|
7984
|
-
return prosemirrorNodeToBlock(prosemirrorNode, definition);
|
|
7985
7977
|
}).filter(nonNullFilter2);
|
|
7986
7978
|
}
|
|
7979
|
+
function internalProsemirrorNodesToBlocks(prosemirrorNodes, definitionsMap) {
|
|
7980
|
+
return prosemirrorNodes.map((prosemirrorNode) => {
|
|
7981
|
+
return internalProsemirrorNodeToBlock(prosemirrorNode, definitionsMap);
|
|
7982
|
+
}).filter(nonNullFilter2);
|
|
7983
|
+
}
|
|
7984
|
+
function internalProsemirrorNodeToBlock(prosemirrorNode, definitionsMap) {
|
|
7985
|
+
const definitionId = getProsemirrorAttribute(prosemirrorNode, "definitionId", _zod.z.string());
|
|
7986
|
+
if (!definitionId) {
|
|
7987
|
+
console.warn(`definitionId on ${prosemirrorNode.type} is required to be interpreted as a block, skipping node`);
|
|
7988
|
+
return null;
|
|
7989
|
+
}
|
|
7990
|
+
const definition = definitionsMap.get(definitionId);
|
|
7991
|
+
if (!definition) {
|
|
7992
|
+
console.warn(
|
|
7993
|
+
`Block definitionId "${definitionId}" (prosemirror node ${prosemirrorNode.type}) is not among available definitions`
|
|
7994
|
+
);
|
|
7995
|
+
console.warn(prosemirrorNode);
|
|
7996
|
+
return null;
|
|
7997
|
+
}
|
|
7998
|
+
return prosemirrorNodeToBlock(prosemirrorNode, definition);
|
|
7999
|
+
}
|
|
7987
8000
|
function prosemirrorNodeToBlock(prosemirrorNode, definition) {
|
|
7988
8001
|
const richTextProperty = BlockDefinitionUtils.firstRichTextProperty(definition);
|
|
7989
8002
|
if (richTextProperty) {
|
|
@@ -8328,7 +8341,14 @@ function parseBlockItems(prosemirrorNode, definition) {
|
|
|
8328
8341
|
return itemsJson.map((i) => parseItem(i, definition)).filter(nonNullFilter2);
|
|
8329
8342
|
}
|
|
8330
8343
|
function parseAppearance(prosemirrorNode) {
|
|
8331
|
-
|
|
8344
|
+
let appearance = {};
|
|
8345
|
+
const rawAppearanceString = getProsemirrorAttribute(prosemirrorNode, "appearance", _zod.z.string().optional());
|
|
8346
|
+
if (rawAppearanceString) {
|
|
8347
|
+
const parsedAppearance = PageBlockAppearanceV2.safeParse(JSON.parse(rawAppearanceString));
|
|
8348
|
+
if (parsedAppearance.success) {
|
|
8349
|
+
appearance = parsedAppearance.data;
|
|
8350
|
+
}
|
|
8351
|
+
}
|
|
8332
8352
|
const columns = getProsemirrorAttribute(prosemirrorNode, "columns", _zod.z.number().optional());
|
|
8333
8353
|
if (columns) {
|
|
8334
8354
|
appearance.numberOfColumns = columns;
|