@supernova-studio/client 0.39.0 → 0.42.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 +6672 -2394
- package/dist/index.d.ts +6672 -2394
- package/dist/index.js +355 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1097 -816
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/design-systems/elements/properties/property-definition.ts +1 -1
- package/src/api/conversion/design-systems/elements/properties/property-value.ts +1 -1
- package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +3 -11
- package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +4 -0
- package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +32 -0
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +3 -5
- package/src/api/conversion/documentation/index.ts +1 -0
- package/src/api/dto/design-systems/brand.ts +5 -0
- package/src/api/dto/design-systems/design-system.ts +2 -0
- package/src/api/dto/design-systems/exporter-property.ts +8 -0
- package/src/api/dto/design-systems/index.ts +1 -0
- package/src/api/dto/documentation/anchor.ts +15 -0
- package/src/api/dto/documentation/index.ts +1 -0
- package/src/api/dto/elements/documentation/group-v2.ts +8 -7
- package/src/api/dto/elements/documentation/index.ts +2 -0
- package/src/api/dto/elements/documentation/item-configuration-v1.ts +2 -0
- package/src/api/dto/elements/documentation/item-configuration-v2.ts +14 -0
- package/src/api/dto/elements/documentation/page-content.ts +15 -0
- package/src/api/dto/elements/documentation/page-v2.ts +8 -7
- package/src/api/dto/elements/elements-action-v2.ts +30 -12
- package/src/api/dto/elements/properties/index.ts +1 -0
- package/src/api/dto/elements/properties/property-definitions-actions-v2.ts +53 -0
- package/src/api/dto/elements/properties/property-definitions.ts +38 -3
- package/src/api/dto/workspaces/index.ts +1 -0
- package/src/api/dto/workspaces/integrations.ts +16 -0
- package/src/api/payloads/design-systems/brand.ts +11 -0
- package/src/api/payloads/design-systems/index.ts +2 -0
- package/src/api/payloads/design-systems/version.ts +18 -0
- package/src/api/payloads/index.ts +1 -0
- package/src/api/payloads/workspaces/index.ts +1 -0
- package/src/api/payloads/workspaces/workspace-integrations.ts +8 -0
- package/src/yjs/design-system-content/item-configuration.ts +14 -9
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +31 -23
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +9 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentationItemHeaderV2 } from "@supernova-studio/model";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { DTODocumentationItemConfigurationV2 } from "../../api/dto/elements/documentation/item-configuration-v2";
|
|
4
5
|
|
|
5
6
|
//
|
|
6
7
|
// Types
|
|
@@ -8,12 +9,12 @@ import { z } from "zod";
|
|
|
8
9
|
|
|
9
10
|
export const DTODocumentationPageRoomHeaderData = z.object({
|
|
10
11
|
title: z.string(),
|
|
11
|
-
configuration:
|
|
12
|
+
configuration: DTODocumentationItemConfigurationV2,
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
|
|
15
16
|
title: z.string().optional(),
|
|
16
|
-
configuration:
|
|
17
|
+
configuration: DTODocumentationItemConfigurationV2.omit({ header: true })
|
|
17
18
|
.extend({ header: DocumentationItemHeaderV2.partial() })
|
|
18
19
|
.optional(),
|
|
19
20
|
});
|
|
@@ -52,10 +53,11 @@ export function itemConfigurationToYjs(yDoc: Y.Doc, item: DTODocumentationPageRo
|
|
|
52
53
|
header.minHeight !== undefined && headerYMap.set("minHeight", header.minHeight);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const configYMap = trx.doc.getMap("itemConfiguration");
|
|
57
|
+
|
|
58
|
+
configuration?.showSidebar !== undefined && configYMap.set("showSidebar", configuration.showSidebar);
|
|
59
|
+
configuration?.isHidden !== undefined && configYMap.set("isHidden", configuration.isHidden);
|
|
60
|
+
configuration?.isPrivate !== undefined && configYMap.set("isPrivate", configuration.isPrivate);
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -76,13 +78,16 @@ export function yjsToItemConfiguration(yDoc: Y.Doc): DTODocumentationPageRoomHea
|
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
const configYMap = yDoc.getMap("itemConfiguration");
|
|
81
|
+
|
|
79
82
|
const rawConfig = {
|
|
80
83
|
showSidebar: configYMap.get("showSidebar"),
|
|
84
|
+
isHidden: configYMap.get("isHidden") ?? false,
|
|
85
|
+
isPrivate: configYMap.get("isPrivate") ?? false,
|
|
81
86
|
header: rawHeader,
|
|
82
|
-
}
|
|
87
|
+
} satisfies Record<keyof DTODocumentationItemConfigurationV2, unknown>;
|
|
83
88
|
|
|
84
89
|
return {
|
|
85
90
|
title: z.string().parse(title),
|
|
86
|
-
configuration:
|
|
91
|
+
configuration: DTODocumentationItemConfigurationV2.parse(rawConfig),
|
|
87
92
|
};
|
|
88
93
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
1
|
import {
|
|
2
|
+
PageBlockCalloutType,
|
|
3
3
|
PageBlockDefinition,
|
|
4
4
|
PageBlockDefinitionProperty,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
PageBlockTextSpanAttribute,
|
|
5
|
+
PageBlockDefinitionRichTextOptions,
|
|
6
|
+
PageBlockItemImageValue,
|
|
8
7
|
PageBlockItemRichTextValue,
|
|
9
|
-
PageBlockCalloutType,
|
|
10
|
-
PageBlockTableCellAlignment,
|
|
11
|
-
PageBlockItemTableNode,
|
|
12
8
|
PageBlockItemTableCell,
|
|
13
|
-
|
|
9
|
+
PageBlockItemTableNode,
|
|
14
10
|
PageBlockItemTableRow,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
PageBlockItemTableValue,
|
|
12
|
+
PageBlockTableCellAlignment,
|
|
13
|
+
PageBlockText,
|
|
14
|
+
PageBlockTextSpan,
|
|
15
|
+
PageBlockTextSpanAttribute,
|
|
19
16
|
PageSectionColumnV2,
|
|
17
|
+
PageSectionItemV2,
|
|
18
|
+
SupernovaException,
|
|
20
19
|
mapByUnique,
|
|
21
20
|
} from "@supernova-studio/model";
|
|
22
|
-
import { PageBlockEditorModel, PageSectionEditorModel } from "./model/block";
|
|
23
|
-
import { ProsemirrorNode, ProsemirrorMark } from "./prosemirror/types";
|
|
24
|
-
import { BlockDefinitionUtils, BlockParsingUtils } from "./utils";
|
|
25
|
-
import { DocumentationPageEditorModel } from "./model";
|
|
26
21
|
import { prosemirrorJSONToYXmlFragment } from "y-prosemirror";
|
|
27
|
-
import
|
|
22
|
+
import * as Y from "yjs";
|
|
28
23
|
import { ListNode, ListTreeBuilder } from "./list-tree-builder";
|
|
24
|
+
import { DocumentationPageEditorModel } from "./model";
|
|
25
|
+
import { PageBlockEditorModel, PageSectionEditorModel } from "./model/block";
|
|
26
|
+
import { pmSchema } from "./prosemirror";
|
|
27
|
+
import { ProsemirrorMark, ProsemirrorNode } from "./prosemirror/types";
|
|
28
|
+
import { BlockDefinitionUtils, BlockParsingUtils } from "./utils";
|
|
29
29
|
|
|
30
30
|
//
|
|
31
31
|
// Types
|
|
@@ -94,7 +94,9 @@ export function blockToProsemirrorNode(
|
|
|
94
94
|
block: PageBlockEditorModel,
|
|
95
95
|
definition: PageBlockDefinition
|
|
96
96
|
): ProsemirrorNode | null {
|
|
97
|
-
|
|
97
|
+
const definitionsMap = new Map<string, PageBlockDefinition>([[definition.id, definition]]);
|
|
98
|
+
const nodes = internalBlocksToProsemirrorNodes([block], definitionsMap);
|
|
99
|
+
return nodes[0] ?? null;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
//
|
|
@@ -623,21 +625,27 @@ function serializeTextSpanAttribute(spanAttribute: PageBlockTextSpanAttribute):
|
|
|
623
625
|
return { type: "code", attrs: {} };
|
|
624
626
|
case "Link":
|
|
625
627
|
if (spanAttribute.link) {
|
|
626
|
-
return serializeLinkMark(
|
|
628
|
+
return serializeLinkMark(
|
|
629
|
+
spanAttribute.link,
|
|
630
|
+
spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
|
|
631
|
+
);
|
|
627
632
|
} else if (spanAttribute.documentationItemId) {
|
|
628
|
-
return serializeLinkMark(
|
|
633
|
+
return serializeLinkMark(
|
|
634
|
+
`@page:${spanAttribute.documentationItemId}`,
|
|
635
|
+
spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
|
|
636
|
+
);
|
|
629
637
|
} else {
|
|
630
|
-
return serializeLinkMark("about:blank", spanAttribute.openInNewWindow ?? false);
|
|
638
|
+
return serializeLinkMark("about:blank", spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false);
|
|
631
639
|
}
|
|
632
640
|
}
|
|
633
641
|
}
|
|
634
642
|
|
|
635
|
-
function serializeLinkMark(href: string,
|
|
643
|
+
function serializeLinkMark(href: string, openInNewTab: boolean): ProsemirrorMark {
|
|
636
644
|
return {
|
|
637
645
|
type: "link",
|
|
638
646
|
attrs: {
|
|
639
647
|
href: href,
|
|
640
|
-
target:
|
|
648
|
+
target: openInNewTab ? "_blank" : "_self",
|
|
641
649
|
rel: "noopener noreferrer nofollow",
|
|
642
650
|
class: "tiptap-link",
|
|
643
651
|
},
|
|
@@ -396,6 +396,10 @@ function parseRichText(spans: ProsemirrorNode[]): PageBlockText {
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
function parseRichTextSpan(span: ProsemirrorNode): PageBlockTextSpan | null {
|
|
399
|
+
if (span.type === "hardBreak") {
|
|
400
|
+
return { text: "\n", attributes: [] };
|
|
401
|
+
}
|
|
402
|
+
|
|
399
403
|
if (span.type !== "text" || !span.text) return null;
|
|
400
404
|
|
|
401
405
|
const marks = span.marks ?? [];
|
|
@@ -428,18 +432,20 @@ function parseProsemirrorLink(mark: ProsemirrorMark): PageBlockTextSpanAttribute
|
|
|
428
432
|
if (!href) return null;
|
|
429
433
|
|
|
430
434
|
const target = getProsemirrorAttribute(mark, "target", z.string().optional());
|
|
431
|
-
const
|
|
435
|
+
const openInNewTab = target === "_blank";
|
|
432
436
|
|
|
433
437
|
if (href.startsWith("@")) {
|
|
434
438
|
return {
|
|
435
439
|
type: "Link",
|
|
436
|
-
openInNewWindow:
|
|
440
|
+
openInNewWindow: openInNewTab,
|
|
441
|
+
openInNewTab: openInNewTab,
|
|
437
442
|
documentationItemId: href.split(":")[1],
|
|
438
443
|
};
|
|
439
444
|
} else {
|
|
440
445
|
return {
|
|
441
446
|
type: "Link",
|
|
442
|
-
openInNewWindow:
|
|
447
|
+
openInNewWindow: openInNewTab,
|
|
448
|
+
openInNewTab: openInNewTab,
|
|
443
449
|
link: href,
|
|
444
450
|
};
|
|
445
451
|
}
|