@supernova-studio/client 0.26.0 → 0.28.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 +6 -6
- package/dist/index.d.ts +6 -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,7 @@ 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.
|
|
11669
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
11670
11670
|
documentationLink: z.ZodOptional<z.ZodString>;
|
|
11671
11671
|
searchKeywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11672
11672
|
item: z.ZodObject<{
|
|
@@ -11984,7 +11984,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11984
11984
|
documentationLink?: string | undefined;
|
|
11985
11985
|
} | undefined;
|
|
11986
11986
|
};
|
|
11987
|
-
icon?:
|
|
11987
|
+
icon?: string | undefined;
|
|
11988
11988
|
documentationLink?: string | undefined;
|
|
11989
11989
|
searchKeywords?: string[] | undefined;
|
|
11990
11990
|
appearance?: {
|
|
@@ -12052,7 +12052,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12052
12052
|
documentationLink?: string | undefined;
|
|
12053
12053
|
} | undefined;
|
|
12054
12054
|
};
|
|
12055
|
-
icon?:
|
|
12055
|
+
icon?: string | undefined;
|
|
12056
12056
|
documentationLink?: string | undefined;
|
|
12057
12057
|
searchKeywords?: string[] | undefined;
|
|
12058
12058
|
appearance?: {
|
|
@@ -12122,7 +12122,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12122
12122
|
documentationLink?: string | undefined;
|
|
12123
12123
|
} | undefined;
|
|
12124
12124
|
};
|
|
12125
|
-
icon?:
|
|
12125
|
+
icon?: string | undefined;
|
|
12126
12126
|
documentationLink?: string | undefined;
|
|
12127
12127
|
searchKeywords?: string[] | undefined;
|
|
12128
12128
|
appearance?: {
|
|
@@ -12192,7 +12192,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12192
12192
|
documentationLink?: string | undefined;
|
|
12193
12193
|
} | undefined;
|
|
12194
12194
|
};
|
|
12195
|
-
icon?:
|
|
12195
|
+
icon?: string | undefined;
|
|
12196
12196
|
documentationLink?: string | undefined;
|
|
12197
12197
|
searchKeywords?: string[] | undefined;
|
|
12198
12198
|
appearance?: {
|
|
@@ -14431,7 +14431,7 @@ declare function blockDefinitionForBlock(block: PageBlockEditorModel, definition
|
|
|
14431
14431
|
documentationLink?: string | undefined;
|
|
14432
14432
|
} | undefined;
|
|
14433
14433
|
};
|
|
14434
|
-
icon?:
|
|
14434
|
+
icon?: string | undefined;
|
|
14435
14435
|
documentationLink?: string | undefined;
|
|
14436
14436
|
searchKeywords?: string[] | undefined;
|
|
14437
14437
|
appearance?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -11666,7 +11666,7 @@ 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.
|
|
11669
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
11670
11670
|
documentationLink: z.ZodOptional<z.ZodString>;
|
|
11671
11671
|
searchKeywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11672
11672
|
item: z.ZodObject<{
|
|
@@ -11984,7 +11984,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
11984
11984
|
documentationLink?: string | undefined;
|
|
11985
11985
|
} | undefined;
|
|
11986
11986
|
};
|
|
11987
|
-
icon?:
|
|
11987
|
+
icon?: string | undefined;
|
|
11988
11988
|
documentationLink?: string | undefined;
|
|
11989
11989
|
searchKeywords?: string[] | undefined;
|
|
11990
11990
|
appearance?: {
|
|
@@ -12052,7 +12052,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12052
12052
|
documentationLink?: string | undefined;
|
|
12053
12053
|
} | undefined;
|
|
12054
12054
|
};
|
|
12055
|
-
icon?:
|
|
12055
|
+
icon?: string | undefined;
|
|
12056
12056
|
documentationLink?: string | undefined;
|
|
12057
12057
|
searchKeywords?: string[] | undefined;
|
|
12058
12058
|
appearance?: {
|
|
@@ -12122,7 +12122,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12122
12122
|
documentationLink?: string | undefined;
|
|
12123
12123
|
} | undefined;
|
|
12124
12124
|
};
|
|
12125
|
-
icon?:
|
|
12125
|
+
icon?: string | undefined;
|
|
12126
12126
|
documentationLink?: string | undefined;
|
|
12127
12127
|
searchKeywords?: string[] | undefined;
|
|
12128
12128
|
appearance?: {
|
|
@@ -12192,7 +12192,7 @@ declare const DTOGetBlockDefinitionsOutput: z.ZodObject<{
|
|
|
12192
12192
|
documentationLink?: string | undefined;
|
|
12193
12193
|
} | undefined;
|
|
12194
12194
|
};
|
|
12195
|
-
icon?:
|
|
12195
|
+
icon?: string | undefined;
|
|
12196
12196
|
documentationLink?: string | undefined;
|
|
12197
12197
|
searchKeywords?: string[] | undefined;
|
|
12198
12198
|
appearance?: {
|
|
@@ -14431,7 +14431,7 @@ declare function blockDefinitionForBlock(block: PageBlockEditorModel, definition
|
|
|
14431
14431
|
documentationLink?: string | undefined;
|
|
14432
14432
|
} | undefined;
|
|
14433
14433
|
};
|
|
14434
|
-
icon?:
|
|
14434
|
+
icon?: string | undefined;
|
|
14435
14435
|
documentationLink?: string | undefined;
|
|
14436
14436
|
searchKeywords?: string[] | undefined;
|
|
14437
14437
|
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: _zod.z.string().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;
|