@supernova-studio/client 0.2.3 → 0.3.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/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +195 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +199 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/docs-editor/blocks-to-prosemirror.ts +4 -4
- package/src/docs-editor/prosemirror/types.ts +2 -2
- package/src/docs-editor/prosemirror-to-blocks.ts +88 -26
- package/src/docs-editor/utils.ts +11 -11
package/dist/index.mjs
CHANGED
|
@@ -883,24 +883,27 @@ var PageBlockImageAlignment = z33.enum(["Left", "Center", "Stretch"]);
|
|
|
883
883
|
var PageBlockAppearanceV2 = z33.object({
|
|
884
884
|
itemBackgroundColor: ColorValue
|
|
885
885
|
});
|
|
886
|
-
var
|
|
886
|
+
var PageBlockItemUntypedValue = z33.object({
|
|
887
887
|
value: z33.any()
|
|
888
888
|
}).and(z33.record(z33.any()));
|
|
889
|
-
var
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
caption: z33.string().optional(),
|
|
896
|
-
height: z33.number().optional()
|
|
889
|
+
var PageBlockLinkV2 = z33.object({
|
|
890
|
+
type: PageBlockLinkType,
|
|
891
|
+
documentationItemId: z33.string().optional(),
|
|
892
|
+
pageHeadingId: z33.string().optional(),
|
|
893
|
+
url: z33.string().optional(),
|
|
894
|
+
openInNewTab: z33.boolean().optional()
|
|
897
895
|
});
|
|
898
|
-
var
|
|
899
|
-
|
|
896
|
+
var PageBlockItemV2 = z33.object({
|
|
897
|
+
id: z33.string(),
|
|
898
|
+
linksTo: PageBlockLinkV2.optional(),
|
|
899
|
+
props: z33.record(PageBlockItemUntypedValue)
|
|
900
900
|
});
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
|
|
901
|
+
var PageBlockDataV2 = z33.object({
|
|
902
|
+
packageId: z33.string(),
|
|
903
|
+
variantId: z33.string().optional(),
|
|
904
|
+
indentLevel: z33.number(),
|
|
905
|
+
appearance: PageBlockAppearanceV2.optional(),
|
|
906
|
+
items: z33.array(PageBlockItemV2)
|
|
904
907
|
});
|
|
905
908
|
var PageBlockItemImageReference = z33.object({
|
|
906
909
|
type: PageBlockImageType,
|
|
@@ -912,30 +915,111 @@ var PageBlockItemImageReference = z33.object({
|
|
|
912
915
|
frameId: z33.string()
|
|
913
916
|
}).optional()
|
|
914
917
|
});
|
|
918
|
+
var PageBlockItemAssetValue = z33.object({
|
|
919
|
+
selectedPropertyIds: z33.array(z33.string()).optional(),
|
|
920
|
+
showSearch: z33.boolean().optional(),
|
|
921
|
+
previewContainerSize: z33.enum(["Centered", "NaturalHeight"]).optional(),
|
|
922
|
+
backgroundColor: z33.string().optional(),
|
|
923
|
+
value: z33.array(
|
|
924
|
+
z33.object({
|
|
925
|
+
entityId: z33.string(),
|
|
926
|
+
entityType: z33.enum(["Asset", "AssetGroup"])
|
|
927
|
+
})
|
|
928
|
+
)
|
|
929
|
+
});
|
|
930
|
+
var PageBlockItemAssetPropertyValue = z33.object({
|
|
931
|
+
value: z33.array(z33.string())
|
|
932
|
+
});
|
|
933
|
+
var PageBlockItemBooleanValue = z33.object({
|
|
934
|
+
value: z33.boolean()
|
|
935
|
+
});
|
|
936
|
+
var PageBlockItemCodeValue = z33.object({
|
|
937
|
+
format: PageBlockCodeLanguage.optional(),
|
|
938
|
+
caption: z33.string().optional(),
|
|
939
|
+
value: z33.string()
|
|
940
|
+
});
|
|
941
|
+
var PageBlockItemSandboxValue = z33.object({
|
|
942
|
+
showCode: z33.boolean().optional(),
|
|
943
|
+
backgroundColor: z33.string().optional(),
|
|
944
|
+
alignPreview: z33.enum(["Left", "Center"]).optional(),
|
|
945
|
+
value: z33.string()
|
|
946
|
+
});
|
|
947
|
+
var PageBlockItemColorValue = z33.record(z33.any());
|
|
948
|
+
var PageBlockItemComponentValue = z33.object({
|
|
949
|
+
selectedPropertyIds: z33.array(z33.string()).optional(),
|
|
950
|
+
value: z33.array(
|
|
951
|
+
z33.object({
|
|
952
|
+
entityId: z33.string(),
|
|
953
|
+
entityType: z33.enum(["Component", "ComponentGroup"])
|
|
954
|
+
})
|
|
955
|
+
)
|
|
956
|
+
});
|
|
957
|
+
var PageBlockItemComponentPropertyValue = z33.object({
|
|
958
|
+
value: z33.string()
|
|
959
|
+
});
|
|
960
|
+
var PageBlockItemDividerValue = z33.object({});
|
|
961
|
+
var PageBlockItemEmbedValue = z33.object({
|
|
962
|
+
value: z33.string().optional(),
|
|
963
|
+
caption: z33.string().optional(),
|
|
964
|
+
height: z33.number().optional()
|
|
965
|
+
});
|
|
915
966
|
var PageBlockItemImageValue = z33.object({
|
|
916
967
|
alt: z33.string().optional(),
|
|
917
968
|
caption: z33.string().optional(),
|
|
918
969
|
alignment: PageBlockImageAlignment.optional(),
|
|
919
970
|
value: PageBlockItemImageReference.optional()
|
|
920
971
|
});
|
|
921
|
-
var
|
|
922
|
-
|
|
923
|
-
documentationItemId: z33.string().optional(),
|
|
924
|
-
pageHeadingId: z33.string().optional(),
|
|
925
|
-
url: z33.string().optional(),
|
|
926
|
-
openInNewTab: z33.boolean().optional()
|
|
972
|
+
var PageBlockItemMarkdownValue = z33.object({
|
|
973
|
+
value: z33.string()
|
|
927
974
|
});
|
|
928
|
-
var
|
|
929
|
-
|
|
930
|
-
linksTo: PageBlockLinkV2.optional(),
|
|
931
|
-
props: z33.record(PageBlockItemUntypedPropertyValue)
|
|
975
|
+
var PageBlockItemMultiRichTextValue = z33.object({
|
|
976
|
+
value: PageBlockText.array()
|
|
932
977
|
});
|
|
933
|
-
var
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
978
|
+
var PageBlockItemMultiSelectValue = z33.object({
|
|
979
|
+
value: z33.array(z33.string())
|
|
980
|
+
});
|
|
981
|
+
var PageBlockItemNumberValue = z33.object({
|
|
982
|
+
value: z33.number()
|
|
983
|
+
});
|
|
984
|
+
var PageBlockItemRichTextValue = z33.object({
|
|
985
|
+
value: PageBlockText,
|
|
986
|
+
calloutType: PageBlockCalloutType.optional()
|
|
987
|
+
});
|
|
988
|
+
var PageBlockItemSingleSelectValue = z33.object({
|
|
989
|
+
value: z33.string()
|
|
990
|
+
});
|
|
991
|
+
var PageBlockItemStorybookValue = z33.object({
|
|
992
|
+
caption: z33.string().optional(),
|
|
993
|
+
height: z33.number().optional(),
|
|
994
|
+
showAddons: z33.boolean().optional(),
|
|
995
|
+
value: z33.string()
|
|
996
|
+
});
|
|
997
|
+
var PageBlockItemTableValue = z33.object({
|
|
998
|
+
value: z33.any()
|
|
999
|
+
});
|
|
1000
|
+
var PageBlockItemTextValue = z33.object({
|
|
1001
|
+
value: z33.string()
|
|
1002
|
+
});
|
|
1003
|
+
var PageBlockItemTokenValue = z33.object({
|
|
1004
|
+
selectedPropertyIds: z33.array(z33.string()).optional(),
|
|
1005
|
+
selectedThemeIds: z33.array(z33.string()).optional(),
|
|
1006
|
+
value: z33.array(
|
|
1007
|
+
z33.object({
|
|
1008
|
+
entityId: z33.string(),
|
|
1009
|
+
entityType: z33.enum(["Token", "TokenGroup"])
|
|
1010
|
+
})
|
|
1011
|
+
)
|
|
1012
|
+
});
|
|
1013
|
+
var PageBlockItemTokenPropertyValue = z33.object({
|
|
1014
|
+
selectedPropertyIds: z33.array(z33.string()).optional(),
|
|
1015
|
+
selectedThemeIds: z33.array(z33.string()).optional(),
|
|
1016
|
+
value: z33.array(z33.string())
|
|
1017
|
+
});
|
|
1018
|
+
var PageBlockItemTokenTypeValue = z33.object({
|
|
1019
|
+
value: z33.array(DesignTokenType)
|
|
1020
|
+
});
|
|
1021
|
+
var PageBlockItemUrlValue = z33.object({
|
|
1022
|
+
value: z33.string()
|
|
939
1023
|
});
|
|
940
1024
|
var DocumentationItemConfiguration = z34.object({
|
|
941
1025
|
showSidebar: z34.boolean(),
|
|
@@ -3690,17 +3774,17 @@ var BlockParsingUtils = {
|
|
|
3690
3774
|
},
|
|
3691
3775
|
richTextPropertyValue(item, propertyKey) {
|
|
3692
3776
|
const objectValue = this.objectPropertyValue(item, propertyKey);
|
|
3693
|
-
const richText =
|
|
3777
|
+
const richText = PageBlockItemRichTextValue.parse(objectValue);
|
|
3694
3778
|
return richText;
|
|
3695
3779
|
},
|
|
3696
3780
|
multiRichTextPropertyValue(item, propertyKey) {
|
|
3697
3781
|
const objectValue = this.objectPropertyValue(item, propertyKey);
|
|
3698
|
-
const richText =
|
|
3782
|
+
const richText = PageBlockItemMultiRichTextValue.parse(objectValue);
|
|
3699
3783
|
return richText;
|
|
3700
3784
|
},
|
|
3701
3785
|
embedPropertyValue(item, propertyKey) {
|
|
3702
3786
|
const objectValue = this.objectPropertyValue(item, propertyKey);
|
|
3703
|
-
const embed =
|
|
3787
|
+
const embed = PageBlockItemEmbedValue.parse(objectValue);
|
|
3704
3788
|
return embed;
|
|
3705
3789
|
},
|
|
3706
3790
|
objectPropertyValue(item, propertyKey) {
|
|
@@ -5657,20 +5741,13 @@ function parseItem(rawItem, definition) {
|
|
|
5657
5741
|
if (!value) {
|
|
5658
5742
|
continue;
|
|
5659
5743
|
}
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
break;
|
|
5667
|
-
case "Image":
|
|
5668
|
-
PageBlockItemImageValue.parse(value);
|
|
5669
|
-
break;
|
|
5670
|
-
default:
|
|
5671
|
-
return null;
|
|
5744
|
+
const valueSchema = valueSchemaForPropertyType(property.type);
|
|
5745
|
+
const validationResult = valueSchema.safeParse(value);
|
|
5746
|
+
if (validationResult.success) {
|
|
5747
|
+
sanitizedProps[property.id] = validationResult.data;
|
|
5748
|
+
} else {
|
|
5749
|
+
console.log(validationResult.error.flatten());
|
|
5672
5750
|
}
|
|
5673
|
-
sanitizedProps[property.id] = value;
|
|
5674
5751
|
}
|
|
5675
5752
|
return {
|
|
5676
5753
|
id: parsedItem.data.id,
|
|
@@ -5678,6 +5755,58 @@ function parseItem(rawItem, definition) {
|
|
|
5678
5755
|
props: sanitizedProps
|
|
5679
5756
|
};
|
|
5680
5757
|
}
|
|
5758
|
+
function valueSchemaForPropertyType(type) {
|
|
5759
|
+
switch (type) {
|
|
5760
|
+
case "RichText":
|
|
5761
|
+
return PageBlockItemRichTextValue;
|
|
5762
|
+
case "MultiRichText":
|
|
5763
|
+
return PageBlockItemMultiRichTextValue;
|
|
5764
|
+
case "Text":
|
|
5765
|
+
return PageBlockItemTextValue;
|
|
5766
|
+
case "Boolean":
|
|
5767
|
+
return PageBlockItemBooleanValue;
|
|
5768
|
+
case "Number":
|
|
5769
|
+
return PageBlockItemNumberValue;
|
|
5770
|
+
case "SingleSelect":
|
|
5771
|
+
return PageBlockItemSingleSelectValue;
|
|
5772
|
+
case "MultiSelect":
|
|
5773
|
+
return PageBlockItemMultiSelectValue;
|
|
5774
|
+
case "Image":
|
|
5775
|
+
return PageBlockItemImageValue;
|
|
5776
|
+
case "Token":
|
|
5777
|
+
return PageBlockItemTokenValue;
|
|
5778
|
+
case "TokenType":
|
|
5779
|
+
return PageBlockItemTokenTypeValue;
|
|
5780
|
+
case "TokenProperty":
|
|
5781
|
+
return PageBlockItemTokenPropertyValue;
|
|
5782
|
+
case "Component":
|
|
5783
|
+
return PageBlockItemComponentValue;
|
|
5784
|
+
case "ComponentProperty":
|
|
5785
|
+
return PageBlockItemComponentPropertyValue;
|
|
5786
|
+
case "Asset":
|
|
5787
|
+
return PageBlockItemAssetValue;
|
|
5788
|
+
case "AssetProperty":
|
|
5789
|
+
return PageBlockItemAssetPropertyValue;
|
|
5790
|
+
case "EmbedURL":
|
|
5791
|
+
return PageBlockItemEmbedValue;
|
|
5792
|
+
case "URL":
|
|
5793
|
+
return PageBlockItemUrlValue;
|
|
5794
|
+
case "Markdown":
|
|
5795
|
+
return PageBlockItemMarkdownValue;
|
|
5796
|
+
case "Code":
|
|
5797
|
+
return PageBlockItemCodeValue;
|
|
5798
|
+
case "CodeSandbox":
|
|
5799
|
+
return PageBlockItemSandboxValue;
|
|
5800
|
+
case "Table":
|
|
5801
|
+
return PageBlockItemTableValue;
|
|
5802
|
+
case "Divider":
|
|
5803
|
+
return PageBlockItemDividerValue;
|
|
5804
|
+
case "Storybook":
|
|
5805
|
+
return PageBlockItemStorybookValue;
|
|
5806
|
+
case "Color":
|
|
5807
|
+
return PageBlockItemColorValue;
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5681
5810
|
function parseProsemirrorBlockAttribute(prosemirrorNode, attributeName) {
|
|
5682
5811
|
const attributeValue = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, attributeName);
|
|
5683
5812
|
if (!attributeValue) {
|
|
@@ -5963,13 +6092,32 @@ export {
|
|
|
5963
6092
|
PageBlockFrameOrigin,
|
|
5964
6093
|
PageBlockImageAlignment,
|
|
5965
6094
|
PageBlockImageType,
|
|
5966
|
-
|
|
6095
|
+
PageBlockItemAssetPropertyValue,
|
|
6096
|
+
PageBlockItemAssetValue,
|
|
6097
|
+
PageBlockItemBooleanValue,
|
|
6098
|
+
PageBlockItemCodeValue,
|
|
6099
|
+
PageBlockItemColorValue,
|
|
6100
|
+
PageBlockItemComponentPropertyValue,
|
|
6101
|
+
PageBlockItemComponentValue,
|
|
6102
|
+
PageBlockItemDividerValue,
|
|
6103
|
+
PageBlockItemEmbedValue,
|
|
5967
6104
|
PageBlockItemImageReference,
|
|
5968
6105
|
PageBlockItemImageValue,
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
6106
|
+
PageBlockItemMarkdownValue,
|
|
6107
|
+
PageBlockItemMultiRichTextValue,
|
|
6108
|
+
PageBlockItemMultiSelectValue,
|
|
6109
|
+
PageBlockItemNumberValue,
|
|
6110
|
+
PageBlockItemRichTextValue,
|
|
6111
|
+
PageBlockItemSandboxValue,
|
|
6112
|
+
PageBlockItemSingleSelectValue,
|
|
6113
|
+
PageBlockItemStorybookValue,
|
|
6114
|
+
PageBlockItemTableValue,
|
|
6115
|
+
PageBlockItemTextValue,
|
|
6116
|
+
PageBlockItemTokenPropertyValue,
|
|
6117
|
+
PageBlockItemTokenTypeValue,
|
|
6118
|
+
PageBlockItemTokenValue,
|
|
6119
|
+
PageBlockItemUntypedValue,
|
|
6120
|
+
PageBlockItemUrlValue,
|
|
5973
6121
|
PageBlockItemV2,
|
|
5974
6122
|
PageBlockLinkPreview,
|
|
5975
6123
|
PageBlockLinkType,
|