@supernova-studio/client 0.6.0 → 0.7.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 +48 -32
- package/dist/index.d.ts +48 -32
- package/dist/index.js +82 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/docs-editor/blocks-to-prosemirror.ts +1 -0
- package/src/docs-editor/prosemirror-to-blocks.ts +87 -28
package/dist/index.mjs
CHANGED
|
@@ -876,7 +876,8 @@ var PageBlockImageType = z33.enum(["Upload", "Asset", "FigmaFrame"]);
|
|
|
876
876
|
var PageBlockImageAlignment = z33.enum(["Left", "Center", "Stretch"]);
|
|
877
877
|
var PageBlockTableCellAlignment = z33.enum(["Left", "Center", "Right"]);
|
|
878
878
|
var PageBlockAppearanceV2 = z33.object({
|
|
879
|
-
itemBackgroundColor: ColorValue
|
|
879
|
+
itemBackgroundColor: ColorValue.optional(),
|
|
880
|
+
numberOfColumns: z33.number().optional()
|
|
880
881
|
});
|
|
881
882
|
var PageBlockItemUntypedValue = z33.object({
|
|
882
883
|
value: z33.any()
|
|
@@ -2068,6 +2069,14 @@ var WorkspaceMembership = z96.object({
|
|
|
2068
2069
|
workspaceId: z96.string(),
|
|
2069
2070
|
workspaceRole: z96.nativeEnum(WorkspaceRole)
|
|
2070
2071
|
});
|
|
2072
|
+
var UpdateMembershipRolesInput = z96.object({
|
|
2073
|
+
members: z96.array(
|
|
2074
|
+
z96.object({
|
|
2075
|
+
userId: z96.string(),
|
|
2076
|
+
role: z96.nativeEnum(WorkspaceRole)
|
|
2077
|
+
})
|
|
2078
|
+
)
|
|
2079
|
+
});
|
|
2071
2080
|
var WorkspaceIpWhitelistEntry = z97.object({
|
|
2072
2081
|
isEnabled: z97.boolean(),
|
|
2073
2082
|
name: z97.string(),
|
|
@@ -4426,7 +4435,8 @@ function serializeAsCustomBlock(block, definition) {
|
|
|
4426
4435
|
id: block.id,
|
|
4427
4436
|
definitionId: block.data.packageId,
|
|
4428
4437
|
variantId: block.data.variantId,
|
|
4429
|
-
items: JSON.stringify(items)
|
|
4438
|
+
items: JSON.stringify(items),
|
|
4439
|
+
appearance: JSON.stringify(block.data.appearance)
|
|
4430
4440
|
}
|
|
4431
4441
|
};
|
|
4432
4442
|
}
|
|
@@ -5811,7 +5821,7 @@ function prosemirrorDocToPage(prosemirrorDoc, definitions) {
|
|
|
5811
5821
|
const definitionsById = mapByUnique(definitions, (d) => d.id);
|
|
5812
5822
|
return {
|
|
5813
5823
|
blocks: (prosemirrorDoc.content ?? []).map((prosemirrorNode) => {
|
|
5814
|
-
const definitionId = prosemirrorNode
|
|
5824
|
+
const definitionId = parseProsemirrorBlockAttribute(prosemirrorNode, "definitionId");
|
|
5815
5825
|
if (!definitionId)
|
|
5816
5826
|
throw new Error(`Node is missing defintion id`);
|
|
5817
5827
|
if (typeof definitionId !== "string")
|
|
@@ -5847,7 +5857,10 @@ function prosemirrorNodeToBlock(prosemirrorNode, definition) {
|
|
|
5847
5857
|
}
|
|
5848
5858
|
function parseAsRichText(prosemirrorNode, definition, property) {
|
|
5849
5859
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
5850
|
-
|
|
5860
|
+
if (typeof id !== "string")
|
|
5861
|
+
return null;
|
|
5862
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
5863
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
5851
5864
|
const calloutType = parseCalloutType(parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "type"));
|
|
5852
5865
|
return {
|
|
5853
5866
|
// TODO Artem: indent
|
|
@@ -5888,7 +5901,10 @@ function parseCalloutType(prosemirrorCalloutType) {
|
|
|
5888
5901
|
}
|
|
5889
5902
|
function parseAsMultiRichText(prosemirrorNode, definition, property) {
|
|
5890
5903
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
5891
|
-
|
|
5904
|
+
if (typeof id !== "string")
|
|
5905
|
+
return null;
|
|
5906
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
5907
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
5892
5908
|
return {
|
|
5893
5909
|
// TODO Artem: indent
|
|
5894
5910
|
id,
|
|
@@ -5944,8 +5960,10 @@ function parseRichTextAttribute(mark) {
|
|
|
5944
5960
|
case "code":
|
|
5945
5961
|
return { type: "Code" };
|
|
5946
5962
|
case "link":
|
|
5947
|
-
const
|
|
5948
|
-
const
|
|
5963
|
+
const itemIdRaw = parseProsemirrorBlockAttribute(mark, "itemId");
|
|
5964
|
+
const itemId = typeof itemIdRaw === "string" ? itemIdRaw : void 0;
|
|
5965
|
+
const hrefRaw = parseProsemirrorBlockAttribute(mark, "href");
|
|
5966
|
+
const href = typeof hrefRaw === "string" ? hrefRaw : void 0;
|
|
5949
5967
|
return {
|
|
5950
5968
|
type: "Link",
|
|
5951
5969
|
openInNewWindow: mark.attrs?.target !== "_self",
|
|
@@ -5957,7 +5975,10 @@ function parseRichTextAttribute(mark) {
|
|
|
5957
5975
|
}
|
|
5958
5976
|
function parseAsTable(prosemirrorNode, definition, property) {
|
|
5959
5977
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
5960
|
-
|
|
5978
|
+
if (typeof id !== "string")
|
|
5979
|
+
return null;
|
|
5980
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
5981
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
5961
5982
|
const hasBorder = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "hasBorder") !== false;
|
|
5962
5983
|
const tableChild = prosemirrorNode.content?.find((c) => c.type === "table");
|
|
5963
5984
|
if (!tableChild) {
|
|
@@ -5979,7 +6000,7 @@ function parseAsTable(prosemirrorNode, definition, property) {
|
|
|
5979
6000
|
};
|
|
5980
6001
|
tableValue.value = rows.map((row) => {
|
|
5981
6002
|
return {
|
|
5982
|
-
cells: (row.content ?? []).map(parseAsTableCell)
|
|
6003
|
+
cells: (row.content ?? []).map(parseAsTableCell).filter(nonNullFilter2)
|
|
5983
6004
|
};
|
|
5984
6005
|
});
|
|
5985
6006
|
return {
|
|
@@ -6001,6 +6022,8 @@ function parseAsTable(prosemirrorNode, definition, property) {
|
|
|
6001
6022
|
}
|
|
6002
6023
|
function parseAsTableCell(prosemirrorNode) {
|
|
6003
6024
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
6025
|
+
if (typeof id !== "string")
|
|
6026
|
+
return null;
|
|
6004
6027
|
const textAlign = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "textAlign");
|
|
6005
6028
|
let columnWidth;
|
|
6006
6029
|
const columnWidthArray = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "colwidth");
|
|
@@ -6097,7 +6120,10 @@ function emptyTableCellContent() {
|
|
|
6097
6120
|
}
|
|
6098
6121
|
function parseAsEmbed(prosemirrorNode, definition, property) {
|
|
6099
6122
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
6100
|
-
|
|
6123
|
+
if (typeof id !== "string")
|
|
6124
|
+
return null;
|
|
6125
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
6126
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
6101
6127
|
const url = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "url");
|
|
6102
6128
|
const caption = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "caption");
|
|
6103
6129
|
const height = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "height");
|
|
@@ -6124,7 +6150,10 @@ function parseAsEmbed(prosemirrorNode, definition, property) {
|
|
|
6124
6150
|
}
|
|
6125
6151
|
function parseAsDivider(prosemirrorNode, definition) {
|
|
6126
6152
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
6127
|
-
|
|
6153
|
+
if (typeof id !== "string")
|
|
6154
|
+
return null;
|
|
6155
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
6156
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
6128
6157
|
return {
|
|
6129
6158
|
id,
|
|
6130
6159
|
data: {
|
|
@@ -6137,24 +6166,51 @@ function parseAsDivider(prosemirrorNode, definition) {
|
|
|
6137
6166
|
}
|
|
6138
6167
|
function parseAsCustomBlock(prosemirrorNode, definition) {
|
|
6139
6168
|
const id = parseProsemirrorBlockAttribute(prosemirrorNode, "id");
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
const
|
|
6143
|
-
|
|
6144
|
-
|
|
6169
|
+
if (typeof id !== "string")
|
|
6170
|
+
return null;
|
|
6171
|
+
const variantIdRaw = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "variantId");
|
|
6172
|
+
const variantId = typeof variantIdRaw === "string" ? variantIdRaw : void 0;
|
|
6173
|
+
const appearance = parseAppearance(prosemirrorNode);
|
|
6174
|
+
const parsedItems = parseBlockItems(prosemirrorNode, definition);
|
|
6175
|
+
if (!parsedItems)
|
|
6145
6176
|
return null;
|
|
6146
|
-
}
|
|
6147
|
-
const parsedItems = itemsJson.map((i) => parseItem(i, definition)).filter(nonNullFilter2);
|
|
6148
6177
|
return {
|
|
6149
6178
|
id,
|
|
6150
6179
|
data: {
|
|
6151
6180
|
packageId: definition.id,
|
|
6152
6181
|
indentLevel: 0,
|
|
6153
6182
|
...variantId && { variantId },
|
|
6183
|
+
appearance,
|
|
6154
6184
|
items: parsedItems
|
|
6155
6185
|
}
|
|
6156
6186
|
};
|
|
6157
6187
|
}
|
|
6188
|
+
function parseBlockItems(prosemirrorNode, definition) {
|
|
6189
|
+
const itemsString = parseProsemirrorBlockAttribute(prosemirrorNode, "items");
|
|
6190
|
+
if (typeof itemsString !== "string")
|
|
6191
|
+
return null;
|
|
6192
|
+
const itemsJson = JSON.parse(itemsString);
|
|
6193
|
+
if (!Array.isArray(itemsJson)) {
|
|
6194
|
+
console.error("Block `items` property must be a json array");
|
|
6195
|
+
return null;
|
|
6196
|
+
}
|
|
6197
|
+
return itemsJson.map((i) => parseItem(i, definition)).filter(nonNullFilter2);
|
|
6198
|
+
}
|
|
6199
|
+
function parseAppearance(prosemirrorNode) {
|
|
6200
|
+
const appearance = {};
|
|
6201
|
+
const columns = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "columns");
|
|
6202
|
+
if (typeof columns === "number") {
|
|
6203
|
+
appearance.numberOfColumns = columns;
|
|
6204
|
+
}
|
|
6205
|
+
const backgroundColor = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, "backgroundColor");
|
|
6206
|
+
if (typeof backgroundColor === "string") {
|
|
6207
|
+
const parsedColor = ColorValue.safeParse(JSON.parse(backgroundColor));
|
|
6208
|
+
if (parsedColor.success) {
|
|
6209
|
+
appearance.itemBackgroundColor = parsedColor.data;
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
return appearance;
|
|
6213
|
+
}
|
|
6158
6214
|
function parseItem(rawItem, definition) {
|
|
6159
6215
|
const parsedItem = PageBlockItemV2.safeParse(rawItem);
|
|
6160
6216
|
if (!parsedItem.success) {
|