@supernova-studio/client 0.10.1 → 0.11.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 +61 -61
- package/dist/index.d.ts +61 -61
- package/dist/index.js +293 -958
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +293 -958
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/requests/post-bulk-doc-page-elements.ts +13 -17
- package/src/api/requests/post-liveblocks-auth.ts +0 -2
- package/src/docs-editor/blocks-to-prosemirror.ts +9 -56
- package/src/docs-editor/prosemirror/schema.ts +270 -869
- package/src/docs-editor/prosemirror-to-blocks.ts +7 -51
|
@@ -107,11 +107,6 @@ export function prosemirrorNodeToBlock(
|
|
|
107
107
|
return parseAsMultiRichText(prosemirrorNode, definition, multiRichTextProperty);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const embedProperty = BlockDefinitionUtils.firstEmbedProperty(definition);
|
|
111
|
-
if (prosemirrorNode.type === "embed" && embedProperty) {
|
|
112
|
-
return parseAsEmbed(prosemirrorNode, definition, embedProperty);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
110
|
const tableProperty = BlockDefinitionUtils.firstTableProperty(definition);
|
|
116
111
|
if (tableProperty) {
|
|
117
112
|
return parseAsTable(prosemirrorNode, definition, tableProperty);
|
|
@@ -170,14 +165,16 @@ function parseCalloutType(prosemirrorCalloutType: unknown): PageBlockCalloutType
|
|
|
170
165
|
if (!prosemirrorCalloutType) return undefined;
|
|
171
166
|
|
|
172
167
|
switch (prosemirrorCalloutType) {
|
|
173
|
-
case "
|
|
168
|
+
case "critical":
|
|
174
169
|
return "Error";
|
|
175
170
|
case "neutral":
|
|
176
171
|
return "Info";
|
|
177
|
-
case "
|
|
172
|
+
case "positive":
|
|
178
173
|
return "Success";
|
|
179
174
|
case "warning":
|
|
180
175
|
return "Warning";
|
|
176
|
+
case "primary":
|
|
177
|
+
return "Primary";
|
|
181
178
|
}
|
|
182
179
|
}
|
|
183
180
|
|
|
@@ -212,7 +209,7 @@ function parseAsMultiRichText(
|
|
|
212
209
|
// Required
|
|
213
210
|
value: (prosemirrorNode.content ?? [])
|
|
214
211
|
.map(listItem => {
|
|
215
|
-
if (listItem.type !== "
|
|
212
|
+
if (listItem.type !== "listItem") return null;
|
|
216
213
|
if (!listItem.content?.length) return parseRichText([]);
|
|
217
214
|
|
|
218
215
|
const paragraph = listItem.content[0];
|
|
@@ -325,6 +322,7 @@ function parseAsTable(
|
|
|
325
322
|
data: {
|
|
326
323
|
packageId: "io.supernova.block.table",
|
|
327
324
|
indentLevel: 0,
|
|
325
|
+
variantId: "default",
|
|
328
326
|
|
|
329
327
|
...(variantId && { variantId: variantId }),
|
|
330
328
|
|
|
@@ -452,48 +450,6 @@ function emptyTableCellContent(): PageBlockItemTableNode[] {
|
|
|
452
450
|
];
|
|
453
451
|
}
|
|
454
452
|
|
|
455
|
-
//
|
|
456
|
-
// Embed
|
|
457
|
-
//
|
|
458
|
-
|
|
459
|
-
function parseAsEmbed(
|
|
460
|
-
prosemirrorNode: ProsemirrorNode,
|
|
461
|
-
definition: PageBlockDefinition,
|
|
462
|
-
property: PageBlockDefinitionProperty
|
|
463
|
-
): PageBlockEditorModel | null {
|
|
464
|
-
const id = getProsemirrorBlockId(prosemirrorNode);
|
|
465
|
-
if (!id) return null;
|
|
466
|
-
|
|
467
|
-
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
468
|
-
|
|
469
|
-
const url = getProsemirrorAttribute(prosemirrorNode, "url", z.string().optional());
|
|
470
|
-
const caption = getProsemirrorAttribute(prosemirrorNode, "caption", z.string().optional());
|
|
471
|
-
const height = getProsemirrorAttribute(prosemirrorNode, "height", z.number().optional());
|
|
472
|
-
|
|
473
|
-
return {
|
|
474
|
-
id: id,
|
|
475
|
-
data: {
|
|
476
|
-
packageId: definition.id,
|
|
477
|
-
indentLevel: 0,
|
|
478
|
-
|
|
479
|
-
...(variantId && { variantId: variantId }),
|
|
480
|
-
|
|
481
|
-
items: [
|
|
482
|
-
{
|
|
483
|
-
id: id,
|
|
484
|
-
props: {
|
|
485
|
-
[property.id]: {
|
|
486
|
-
value: url,
|
|
487
|
-
caption: caption,
|
|
488
|
-
height: height ?? 200,
|
|
489
|
-
} as PageBlockItemEmbedValue,
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
},
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
453
|
//
|
|
498
454
|
// Divider
|
|
499
455
|
//
|
|
@@ -611,7 +567,7 @@ function parseItem(rawItem: unknown, definition: PageBlockDefinition): PageBlock
|
|
|
611
567
|
|
|
612
568
|
return {
|
|
613
569
|
id: parsedItem.data.id,
|
|
614
|
-
linksTo: parsedItem.data.linksTo,
|
|
570
|
+
...(parsedItem.data.linksTo && { linksTo: parsedItem.data.linksTo }),
|
|
615
571
|
props: sanitizedProps,
|
|
616
572
|
};
|
|
617
573
|
}
|