@supernova-studio/client 0.10.2 → 0.12.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 +77 -383
- package/dist/index.d.ts +77 -383
- package/dist/index.js +290 -958
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +290 -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 +5 -54
- package/src/docs-editor/prosemirror/schema.ts +270 -869
- package/src/docs-editor/prosemirror-to-blocks.ts +5 -50
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
import { DocumentationItemConfiguration } from "@supernova-studio/model"
|
|
3
|
+
import { DocumentationItemConfiguration } from "@supernova-studio/model";
|
|
4
4
|
|
|
5
5
|
export const CreateBulkElementsInput = z.object({
|
|
6
|
+
parentPersistentId: z.string().uuid(),
|
|
6
7
|
persistentId: z.string().uuid(),
|
|
7
8
|
title: z.string(),
|
|
8
|
-
configuration: DocumentationItemConfiguration,
|
|
9
|
-
|
|
10
|
-
afterPersistentId: z.string().nullish(),
|
|
9
|
+
configuration: DocumentationItemConfiguration.optional(),
|
|
10
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export type CreateBulkElementsInput = z.infer<typeof CreateBulkElementsInput>;
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
export const UpdateBulkElementsInput = z.object({
|
|
17
16
|
id: z.string(),
|
|
18
17
|
title: z.string().optional(),
|
|
@@ -23,29 +22,26 @@ export const UpdateBulkElementsInput = z.object({
|
|
|
23
22
|
|
|
24
23
|
export type UpdateBulkElementsInput = z.infer<typeof UpdateBulkElementsInput>;
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
export const DeleteBulkElementsInput = z.array(z.string());
|
|
28
26
|
|
|
29
27
|
export type DeleteBulkElementsInput = z.infer<typeof DeleteBulkElementsInput>;
|
|
30
28
|
|
|
31
|
-
|
|
32
29
|
export const DuplicateBulkElementsInput = z.object({
|
|
33
30
|
id: z.string(),
|
|
34
31
|
persistentId: z.string().uuid(),
|
|
35
32
|
parentPersistentId: z.string().uuid(),
|
|
36
|
-
afterPersistentId: z.string().uuid().
|
|
33
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
37
34
|
});
|
|
38
35
|
|
|
39
36
|
export type DuplicateBulkElementsInput = z.infer<typeof DuplicateBulkElementsInput>;
|
|
40
37
|
|
|
41
|
-
|
|
42
38
|
export const BulkEditDocPageElementsInput = z.object({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
documentationPages: z.object({
|
|
40
|
+
create: z.array(CreateBulkElementsInput).optional(),
|
|
41
|
+
update: z.array(UpdateBulkElementsInput).optional(),
|
|
42
|
+
delete: DeleteBulkElementsInput.optional(),
|
|
43
|
+
duplicate: z.array(DuplicateBulkElementsInput).optional(),
|
|
44
|
+
}),
|
|
49
45
|
});
|
|
50
46
|
|
|
51
|
-
export type BulkEditDocPageElementsInput = z.infer<typeof BulkEditDocPageElementsInput>;
|
|
47
|
+
export type BulkEditDocPageElementsInput = z.infer<typeof BulkEditDocPageElementsInput>;
|
|
@@ -114,20 +114,6 @@ export function blockToProsemirrorNode(
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// Embed
|
|
118
|
-
const embedProperty = BlockDefinitionUtils.firstEmbedProperty(definition);
|
|
119
|
-
const embedType = serializeEmbedType(block.data.packageId);
|
|
120
|
-
if (embedProperty && embedType) {
|
|
121
|
-
return serializeAsEmbed(
|
|
122
|
-
{
|
|
123
|
-
block: block,
|
|
124
|
-
definition: definition,
|
|
125
|
-
property: embedProperty,
|
|
126
|
-
},
|
|
127
|
-
embedType
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
117
|
// Divider
|
|
132
118
|
if (block.data.packageId === "io.supernova.block.divider") {
|
|
133
119
|
return serializeAsDivider({
|
|
@@ -241,7 +227,7 @@ function serializeAsMultiRichTextBlock(input: InputWithProperty): ProsemirrorNod
|
|
|
241
227
|
|
|
242
228
|
function serializeAsMultiParagraph(input: MultiRichTextInputWithValue): ProsemirrorNode {
|
|
243
229
|
return {
|
|
244
|
-
type: "
|
|
230
|
+
type: "bulletList",
|
|
245
231
|
attrs: {
|
|
246
232
|
...serializeBlockNodeAttributes(input),
|
|
247
233
|
},
|
|
@@ -251,7 +237,7 @@ function serializeAsMultiParagraph(input: MultiRichTextInputWithValue): Prosemir
|
|
|
251
237
|
|
|
252
238
|
function serializeAsOrderedList(input: MultiRichTextInputWithValue): ProsemirrorNode {
|
|
253
239
|
return {
|
|
254
|
-
type: "
|
|
240
|
+
type: "orderedList",
|
|
255
241
|
attrs: {
|
|
256
242
|
...serializeBlockNodeAttributes(input),
|
|
257
243
|
start: "1",
|
|
@@ -262,7 +248,7 @@ function serializeAsOrderedList(input: MultiRichTextInputWithValue): Prosemirror
|
|
|
262
248
|
|
|
263
249
|
function serializeAsUnorderedList(input: MultiRichTextInputWithValue): ProsemirrorNode {
|
|
264
250
|
return {
|
|
265
|
-
type: "
|
|
251
|
+
type: "bulletList",
|
|
266
252
|
attrs: {
|
|
267
253
|
...serializeBlockNodeAttributes(input),
|
|
268
254
|
},
|
|
@@ -272,7 +258,7 @@ function serializeAsUnorderedList(input: MultiRichTextInputWithValue): Prosemirr
|
|
|
272
258
|
|
|
273
259
|
function serializeAsListItem(text: PageBlockText): ProsemirrorNode {
|
|
274
260
|
return {
|
|
275
|
-
type: "
|
|
261
|
+
type: "listItem",
|
|
276
262
|
content: [
|
|
277
263
|
{
|
|
278
264
|
type: "paragraph",
|
|
@@ -381,41 +367,6 @@ function serializeTableNode(node: PageBlockItemTableNode): ProsemirrorNode {
|
|
|
381
367
|
}
|
|
382
368
|
}
|
|
383
369
|
|
|
384
|
-
//
|
|
385
|
-
// Embeds
|
|
386
|
-
//
|
|
387
|
-
|
|
388
|
-
function serializeAsEmbed(input: InputWithProperty, embedType: string): ProsemirrorNode {
|
|
389
|
-
const { block, definition, property: embedProperty } = input;
|
|
390
|
-
|
|
391
|
-
const blockItem = BlockParsingUtils.singleBlockItem(block);
|
|
392
|
-
const embedValue = BlockParsingUtils.embedPropertyValue(blockItem, embedProperty.id);
|
|
393
|
-
|
|
394
|
-
return {
|
|
395
|
-
type: "embed",
|
|
396
|
-
attrs: {
|
|
397
|
-
...serializeBlockNodeAttributes(input),
|
|
398
|
-
type: embedType,
|
|
399
|
-
url: embedValue.value,
|
|
400
|
-
height: embedValue.height,
|
|
401
|
-
caption: embedValue.caption,
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function serializeEmbedType(blockDefinitionId: string): string | undefined {
|
|
407
|
-
switch (blockDefinitionId) {
|
|
408
|
-
case "io.supernova.block.embed":
|
|
409
|
-
return "generic";
|
|
410
|
-
case "io.supernova.block.embed-youtube":
|
|
411
|
-
return "youtube";
|
|
412
|
-
case "io.supernova.block.embed-figma":
|
|
413
|
-
return "figma";
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return undefined;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
370
|
//
|
|
420
371
|
// Divider
|
|
421
372
|
//
|
|
@@ -562,7 +513,7 @@ export function serializeAsCustomBlock(block: PageBlockEditorModel, definition:
|
|
|
562
513
|
attrs: {
|
|
563
514
|
id: block.id,
|
|
564
515
|
definitionId: block.data.packageId,
|
|
565
|
-
variantId: block.data.variantId,
|
|
516
|
+
...(block.data.variantId && { variantId: block.data.variantId }),
|
|
566
517
|
items: JSON.stringify(items),
|
|
567
518
|
|
|
568
519
|
...(columns && { columns: columns }),
|