@supernova-studio/client 0.58.18 → 1.0.0-alpha.2
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 +1349 -1323
- package/dist/index.d.ts +1349 -1323
- package/dist/index.js +462 -329
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +764 -631
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/api/client.ts +0 -31
- package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +0 -114
- package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +0 -92
- package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +0 -52
- package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +0 -34
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +0 -131
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +0 -69
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +0 -72
- package/src/api/conversion/documentation/index.ts +0 -7
- package/src/api/conversion/export/index.ts +0 -1
- package/src/api/conversion/export/pipeline.ts +0 -25
- package/src/api/conversion/index.ts +0 -3
- package/src/api/conversion/integrations/git.ts +0 -37
- package/src/api/conversion/integrations/index.ts +0 -2
- package/src/api/conversion/integrations/integration.ts +0 -37
- package/src/api/dto/aux/color.ts +0 -7
- package/src/api/dto/aux/index.ts +0 -3
- package/src/api/dto/aux/meta.ts +0 -8
- package/src/api/dto/aux/pagination.ts +0 -8
- package/src/api/dto/bff/app-bootstrap-data.ts +0 -20
- package/src/api/dto/bff/index.ts +0 -1
- package/src/api/dto/collections/index.ts +0 -1
- package/src/api/dto/collections/token-collection.ts +0 -24
- package/src/api/dto/design-systems/brand.ts +0 -44
- package/src/api/dto/design-systems/component.ts +0 -40
- package/src/api/dto/design-systems/contact.ts +0 -11
- package/src/api/dto/design-systems/data-source.ts +0 -141
- package/src/api/dto/design-systems/design-system.ts +0 -68
- package/src/api/dto/design-systems/elements-diff.ts +0 -14
- package/src/api/dto/design-systems/figma-variables.ts +0 -108
- package/src/api/dto/design-systems/import-job.ts +0 -61
- package/src/api/dto/design-systems/index.ts +0 -13
- package/src/api/dto/design-systems/members.ts +0 -50
- package/src/api/dto/design-systems/role.ts +0 -11
- package/src/api/dto/design-systems/stats.ts +0 -19
- package/src/api/dto/design-systems/version.ts +0 -56
- package/src/api/dto/design-systems/view.ts +0 -45
- package/src/api/dto/design-tokens/design-token.ts +0 -78
- package/src/api/dto/design-tokens/index.ts +0 -1
- package/src/api/dto/documentation/anchor.ts +0 -15
- package/src/api/dto/documentation/approvals.ts +0 -15
- package/src/api/dto/documentation/block-definition.ts +0 -28
- package/src/api/dto/documentation/block.ts +0 -6
- package/src/api/dto/documentation/documentation-page-snapshot.ts +0 -18
- package/src/api/dto/documentation/index.ts +0 -8
- package/src/api/dto/documentation/link-preview.ts +0 -23
- package/src/api/dto/documentation/publish.ts +0 -23
- package/src/api/dto/documentation/room.ts +0 -12
- package/src/api/dto/elements/components/figma-component-group.ts +0 -19
- package/src/api/dto/elements/components/figma-component.ts +0 -56
- package/src/api/dto/elements/components/index.ts +0 -2
- package/src/api/dto/elements/documentation/draft-state.ts +0 -37
- package/src/api/dto/elements/documentation/group-action.ts +0 -108
- package/src/api/dto/elements/documentation/group-v1.ts +0 -35
- package/src/api/dto/elements/documentation/group-v2.ts +0 -117
- package/src/api/dto/elements/documentation/hierarchy.ts +0 -22
- package/src/api/dto/elements/documentation/index.ts +0 -13
- package/src/api/dto/elements/documentation/item-configuration-v1.ts +0 -24
- package/src/api/dto/elements/documentation/item-configuration-v2.ts +0 -14
- package/src/api/dto/elements/documentation/metadata.ts +0 -8
- package/src/api/dto/elements/documentation/page-actions-v2.ts +0 -121
- package/src/api/dto/elements/documentation/page-content.ts +0 -15
- package/src/api/dto/elements/documentation/page-v1.ts +0 -21
- package/src/api/dto/elements/documentation/page-v2.ts +0 -120
- package/src/api/dto/elements/documentation/structure.ts +0 -37
- package/src/api/dto/elements/elements-action-v2.ts +0 -104
- package/src/api/dto/elements/figma-nodes/figma-node.ts +0 -106
- package/src/api/dto/elements/figma-nodes/index.ts +0 -2
- package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +0 -24
- package/src/api/dto/elements/frame-node-structures/frame-node-structure.ts +0 -17
- package/src/api/dto/elements/frame-node-structures/index.ts +0 -1
- package/src/api/dto/elements/get-elements-v2.ts +0 -21
- package/src/api/dto/elements/index.ts +0 -7
- package/src/api/dto/elements/properties/index.ts +0 -2
- package/src/api/dto/elements/properties/property-definitions.ts +0 -75
- package/src/api/dto/elements/properties/property-values.ts +0 -38
- package/src/api/dto/export/exporter-property.ts +0 -95
- package/src/api/dto/export/exporter.ts +0 -87
- package/src/api/dto/export/filter.ts +0 -6
- package/src/api/dto/export/index.ts +0 -5
- package/src/api/dto/export/job.ts +0 -87
- package/src/api/dto/export/pipeline.ts +0 -43
- package/src/api/dto/figma-components/assets/download.ts +0 -30
- package/src/api/dto/figma-components/assets/index.ts +0 -1
- package/src/api/dto/figma-components/index.ts +0 -1
- package/src/api/dto/index.ts +0 -13
- package/src/api/dto/liveblocks/auth-response.ts +0 -7
- package/src/api/dto/liveblocks/index.ts +0 -1
- package/src/api/dto/themes/index.ts +0 -2
- package/src/api/dto/themes/override.ts +0 -27
- package/src/api/dto/themes/theme.ts +0 -45
- package/src/api/dto/users/authenticated-user.ts +0 -43
- package/src/api/dto/users/index.ts +0 -3
- package/src/api/dto/users/update.ts +0 -8
- package/src/api/dto/users/user.ts +0 -31
- package/src/api/dto/workspaces/git.ts +0 -32
- package/src/api/dto/workspaces/index.ts +0 -6
- package/src/api/dto/workspaces/integrations.ts +0 -34
- package/src/api/dto/workspaces/invitations.ts +0 -30
- package/src/api/dto/workspaces/membership.ts +0 -41
- package/src/api/dto/workspaces/npm-registry.ts +0 -35
- package/src/api/dto/workspaces/workspace.ts +0 -34
- package/src/api/endpoints/codegen/codegen.ts +0 -13
- package/src/api/endpoints/codegen/exporters.ts +0 -13
- package/src/api/endpoints/codegen/index.ts +0 -3
- package/src/api/endpoints/codegen/pipelines.ts +0 -37
- package/src/api/endpoints/design-system/bff.ts +0 -13
- package/src/api/endpoints/design-system/contact.ts +0 -12
- package/src/api/endpoints/design-system/design-systems.ts +0 -55
- package/src/api/endpoints/design-system/index.ts +0 -6
- package/src/api/endpoints/design-system/members.ts +0 -24
- package/src/api/endpoints/design-system/sources.ts +0 -35
- package/src/api/endpoints/design-system/versions/brands.ts +0 -45
- package/src/api/endpoints/design-system/versions/documentation.ts +0 -27
- package/src/api/endpoints/design-system/versions/ds-components.ts +0 -28
- package/src/api/endpoints/design-system/versions/elements-action.ts +0 -55
- package/src/api/endpoints/design-system/versions/elements.ts +0 -13
- package/src/api/endpoints/design-system/versions/figma-component-groups.ts +0 -13
- package/src/api/endpoints/design-system/versions/figma-components.ts +0 -13
- package/src/api/endpoints/design-system/versions/figma-frame-structures.ts +0 -13
- package/src/api/endpoints/design-system/versions/import-jobs.ts +0 -13
- package/src/api/endpoints/design-system/versions/index.ts +0 -18
- package/src/api/endpoints/design-system/versions/overrides.ts +0 -17
- package/src/api/endpoints/design-system/versions/property-definitions.ts +0 -43
- package/src/api/endpoints/design-system/versions/property-values.ts +0 -25
- package/src/api/endpoints/design-system/versions/stats.ts +0 -12
- package/src/api/endpoints/design-system/versions/themes.ts +0 -35
- package/src/api/endpoints/design-system/versions/token-collections.ts +0 -13
- package/src/api/endpoints/design-system/versions/token-groups.ts +0 -28
- package/src/api/endpoints/design-system/versions/tokens.ts +0 -27
- package/src/api/endpoints/design-system/versions/versions.ts +0 -79
- package/src/api/endpoints/index.ts +0 -5
- package/src/api/endpoints/liveblocks.ts +0 -14
- package/src/api/endpoints/users.ts +0 -26
- package/src/api/endpoints/workspaces/index.ts +0 -3
- package/src/api/endpoints/workspaces/workspace-invites.ts +0 -34
- package/src/api/endpoints/workspaces/workspace-members.ts +0 -31
- package/src/api/endpoints/workspaces/workspaces.ts +0 -47
- package/src/api/index.ts +0 -6
- package/src/api/payloads/design-systems/index.ts +0 -2
- package/src/api/payloads/design-systems/update-design-system.ts +0 -29
- package/src/api/payloads/design-systems/version.ts +0 -29
- package/src/api/payloads/documentation/block-definitions.ts +0 -12
- package/src/api/payloads/documentation/design-data-doc-diff.ts +0 -7
- package/src/api/payloads/documentation/index.ts +0 -2
- package/src/api/payloads/export/index.ts +0 -1
- package/src/api/payloads/export/pipeline.ts +0 -50
- package/src/api/payloads/index.ts +0 -6
- package/src/api/payloads/liveblocks/auth.ts +0 -7
- package/src/api/payloads/liveblocks/index.ts +0 -1
- package/src/api/payloads/users/index.ts +0 -2
- package/src/api/payloads/users/notifications/index.ts +0 -1
- package/src/api/payloads/users/notifications/notification-settings.ts +0 -17
- package/src/api/payloads/users/profile/index.ts +0 -1
- package/src/api/payloads/users/profile/update.ts +0 -4
- package/src/api/payloads/workspaces/index.ts +0 -3
- package/src/api/payloads/workspaces/transfer-ownership.ts +0 -7
- package/src/api/payloads/workspaces/workspace-configuration.ts +0 -50
- package/src/api/payloads/workspaces/workspace-integrations.ts +0 -26
- package/src/api/transport/index.ts +0 -2
- package/src/api/transport/request-executor-error.ts +0 -66
- package/src/api/transport/request-executor.ts +0 -87
- package/src/index.ts +0 -3
- package/src/utils/figma.ts +0 -53
- package/src/utils/hash.ts +0 -62
- package/src/utils/index.ts +0 -3
- package/src/utils/query.ts +0 -18
- package/src/yjs/design-system-content/documentation-hierarchy.ts +0 -35
- package/src/yjs/design-system-content/index.ts +0 -2
- package/src/yjs/design-system-content/item-configuration.ts +0 -93
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +0 -764
- package/src/yjs/docs-editor/index.ts +0 -7
- package/src/yjs/docs-editor/list-tree-builder.ts +0 -127
- package/src/yjs/docs-editor/mock.ts +0 -2104
- package/src/yjs/docs-editor/model/block.ts +0 -8
- package/src/yjs/docs-editor/model/index.ts +0 -2
- package/src/yjs/docs-editor/model/page.ts +0 -8
- package/src/yjs/docs-editor/prosemirror/index.ts +0 -3
- package/src/yjs/docs-editor/prosemirror/inner-editor-schema.ts +0 -145
- package/src/yjs/docs-editor/prosemirror/main-editor-schema.ts +0 -577
- package/src/yjs/docs-editor/prosemirror/types.ts +0 -19
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +0 -975
- package/src/yjs/docs-editor/utils.ts +0 -115
- package/src/yjs/index.ts +0 -3
- package/src/yjs/version-room/backend.ts +0 -78
- package/src/yjs/version-room/base.ts +0 -211
- package/src/yjs/version-room/frontend.ts +0 -461
- package/src/yjs/version-room/index.ts +0 -4
- package/src/yjs/version-room/utils.ts +0 -109
|
@@ -1,764 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PageBlockCalloutType,
|
|
3
|
-
PageBlockDefinition,
|
|
4
|
-
PageBlockDefinitionProperty,
|
|
5
|
-
PageBlockDefinitionRichTextOptions,
|
|
6
|
-
PageBlockItemImageValue,
|
|
7
|
-
PageBlockItemRichTextEditorListNode,
|
|
8
|
-
PageBlockItemRichTextEditorNode,
|
|
9
|
-
PageBlockItemRichTextEditorParagraphNode,
|
|
10
|
-
PageBlockItemRichTextEditorValue,
|
|
11
|
-
PageBlockItemRichTextValue,
|
|
12
|
-
PageBlockItemTableCell,
|
|
13
|
-
PageBlockItemTableNode,
|
|
14
|
-
PageBlockItemTableRow,
|
|
15
|
-
PageBlockItemTableValue,
|
|
16
|
-
PageBlockTableCellAlignment,
|
|
17
|
-
PageBlockText,
|
|
18
|
-
PageBlockTextSpan,
|
|
19
|
-
PageBlockTextSpanAttribute,
|
|
20
|
-
PageSectionColumnV2,
|
|
21
|
-
PageSectionItemV2,
|
|
22
|
-
SupernovaException,
|
|
23
|
-
mapByUnique,
|
|
24
|
-
} from "@supernova-studio/model";
|
|
25
|
-
import { prosemirrorJSONToYXmlFragment } from "y-prosemirror";
|
|
26
|
-
import * as Y from "yjs";
|
|
27
|
-
import { ListNode, ListTreeBuilder } from "./list-tree-builder";
|
|
28
|
-
import { DocumentationPageEditorModel } from "./model";
|
|
29
|
-
import { PageBlockEditorModel, PageSectionEditorModel } from "./model/block";
|
|
30
|
-
import { mainEditorProsemirrorSchema } from "./prosemirror";
|
|
31
|
-
import { ProsemirrorMark, ProsemirrorNode } from "./prosemirror/types";
|
|
32
|
-
import { BlockDefinitionUtils, BlockParsingUtils } from "./utils";
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
// Types
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
type BaseInput = {
|
|
39
|
-
block: PageBlockEditorModel;
|
|
40
|
-
definition: PageBlockDefinition;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type InputWithProperty = BaseInput & {
|
|
44
|
-
property: PageBlockDefinitionProperty;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type RichTextInputWithValue = InputWithProperty & {
|
|
48
|
-
richTextPropertyValue: PageBlockItemRichTextValue;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
// Implementation
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
export function pageToYDoc(doc: Y.Doc, page: DocumentationPageEditorModel, definitions: PageBlockDefinition[]) {
|
|
56
|
-
pageToYXmlFragment(page, definitions, doc.getXmlFragment("default"));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function pageToYXmlFragment(
|
|
60
|
-
page: DocumentationPageEditorModel,
|
|
61
|
-
definitions: PageBlockDefinition[],
|
|
62
|
-
fragment: Y.XmlFragment
|
|
63
|
-
): Y.XmlFragment {
|
|
64
|
-
const doc = pageToProsemirrorDoc(page, definitions);
|
|
65
|
-
// console.log(JSON.stringify(doc, null, 2));
|
|
66
|
-
return prosemirrorJSONToYXmlFragment(mainEditorProsemirrorSchema, doc, fragment);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function pageToProsemirrorDoc(
|
|
70
|
-
page: DocumentationPageEditorModel,
|
|
71
|
-
definitions: PageBlockDefinition[]
|
|
72
|
-
): ProsemirrorNode {
|
|
73
|
-
const definitionsMap = mapByUnique(definitions, d => d.id);
|
|
74
|
-
|
|
75
|
-
const children: ProsemirrorNode[] = [];
|
|
76
|
-
let blockBuffer: PageBlockEditorModel[] = [];
|
|
77
|
-
|
|
78
|
-
page.blocks.forEach(b => {
|
|
79
|
-
if (b.type === "Block") {
|
|
80
|
-
blockBuffer.push(b);
|
|
81
|
-
} else if (b.type === "Section") {
|
|
82
|
-
if (blockBuffer.length) {
|
|
83
|
-
children.push(...internalBlocksToProsemirrorNodes(blockBuffer, definitionsMap));
|
|
84
|
-
blockBuffer = [];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
children.push(internalSectionToProsemirrorNode(b, definitionsMap));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
if (blockBuffer.length) {
|
|
92
|
-
children.push(...internalBlocksToProsemirrorNodes(blockBuffer, definitionsMap));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
type: "doc",
|
|
97
|
-
content: children,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function blockToProsemirrorNode(
|
|
102
|
-
block: PageBlockEditorModel,
|
|
103
|
-
definition: PageBlockDefinition
|
|
104
|
-
): ProsemirrorNode | null {
|
|
105
|
-
const definitionsMap = new Map<string, PageBlockDefinition>([[definition.id, definition]]);
|
|
106
|
-
const nodes = internalBlocksToProsemirrorNodes([block], definitionsMap);
|
|
107
|
-
return nodes[0] ?? null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function richTextPropertyValueToProsemirror(
|
|
111
|
-
richTextEditorValue: PageBlockItemRichTextEditorValue
|
|
112
|
-
): ProsemirrorNode {
|
|
113
|
-
return {
|
|
114
|
-
type: "doc",
|
|
115
|
-
content: richTextEditorValue.value.map(node => {
|
|
116
|
-
return serializeRichTextEditorNode(node);
|
|
117
|
-
}),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function serializeRichTextEditorNode(node: PageBlockItemRichTextEditorNode): ProsemirrorNode {
|
|
122
|
-
switch (node.type) {
|
|
123
|
-
case "Paragraph":
|
|
124
|
-
return serializeRichTextEditorParagraphNode(node);
|
|
125
|
-
|
|
126
|
-
case "List":
|
|
127
|
-
return serializeRichTextEditorListNode(node);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function serializeRichTextEditorParagraphNode(node: PageBlockItemRichTextEditorParagraphNode): ProsemirrorNode {
|
|
132
|
-
const content = serializeRichText(node.value);
|
|
133
|
-
return {
|
|
134
|
-
type: "paragraph",
|
|
135
|
-
...(content.length && { content }),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function serializeRichTextEditorListNode(node: PageBlockItemRichTextEditorListNode): ProsemirrorNode {
|
|
140
|
-
const type = node.listType === "OL" ? "orderedList" : "bulletList";
|
|
141
|
-
const attrs = node.listType === "OL" ? { start: 1 } : undefined;
|
|
142
|
-
const richTexts = node.value.length ? node.value : [{ spans: [] }];
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
type,
|
|
146
|
-
...(attrs && { attrs }),
|
|
147
|
-
content: richTexts.map(n => {
|
|
148
|
-
const content = serializeRichText(n);
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
type: "listItem",
|
|
152
|
-
content: [
|
|
153
|
-
{
|
|
154
|
-
type: "paragraph",
|
|
155
|
-
...(content.length && { content }),
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
};
|
|
159
|
-
}),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
// Sections
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
function internalSectionToProsemirrorNode(
|
|
168
|
-
section: PageSectionEditorModel,
|
|
169
|
-
definitionsMap: Map<string, PageBlockDefinition>
|
|
170
|
-
): ProsemirrorNode {
|
|
171
|
-
return {
|
|
172
|
-
type: "tabsSection",
|
|
173
|
-
attrs: {
|
|
174
|
-
id: section.id,
|
|
175
|
-
...(section.variantId && { variantId: section.variantId }),
|
|
176
|
-
},
|
|
177
|
-
content: section.items.map(item => sectionItemToProsemirrorNode(item, definitionsMap)),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function sectionItemToProsemirrorNode(
|
|
182
|
-
sectionItem: PageSectionItemV2,
|
|
183
|
-
definitionsMap: Map<string, PageBlockDefinition>
|
|
184
|
-
): ProsemirrorNode {
|
|
185
|
-
return {
|
|
186
|
-
type: "sectionItem",
|
|
187
|
-
attrs: {
|
|
188
|
-
id: sectionItem.id,
|
|
189
|
-
title: sectionItem.title,
|
|
190
|
-
},
|
|
191
|
-
content: sectionItem.columns.map(column => sectionColumnToProsemirrorNode(column, definitionsMap)),
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function sectionColumnToProsemirrorNode(
|
|
196
|
-
sectionColumn: PageSectionColumnV2,
|
|
197
|
-
definitionsMap: Map<string, PageBlockDefinition>
|
|
198
|
-
): ProsemirrorNode {
|
|
199
|
-
const blocks = internalBlocksToProsemirrorNodes(sectionColumn.blocks, definitionsMap);
|
|
200
|
-
|
|
201
|
-
if (!blocks.length) {
|
|
202
|
-
blocks.push({
|
|
203
|
-
type: "paragraph",
|
|
204
|
-
attrs: {
|
|
205
|
-
id: "id",
|
|
206
|
-
definitionId: "io.supernova.block.rich-text",
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
type: "sectionItemColumn",
|
|
213
|
-
attrs: {
|
|
214
|
-
id: sectionColumn.id,
|
|
215
|
-
},
|
|
216
|
-
content: blocks,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
// Blocks
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
function internalBlocksToProsemirrorNodes(
|
|
225
|
-
blocks: PageBlockEditorModel[],
|
|
226
|
-
definitionsMap: Map<string, PageBlockDefinition>
|
|
227
|
-
): ProsemirrorNode[] {
|
|
228
|
-
const result: ProsemirrorNode[] = [];
|
|
229
|
-
|
|
230
|
-
const listTreeBuilder = new ListTreeBuilder();
|
|
231
|
-
|
|
232
|
-
blocks.forEach(b => {
|
|
233
|
-
const definition = definitionsMap.get(b.data.packageId);
|
|
234
|
-
if (!definition) {
|
|
235
|
-
console.warn(`Could not find definition for ${b.id} (${b.data.packageId})`);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const multiRichTextProp = BlockDefinitionUtils.firstMultiRichTextProperty(definition);
|
|
240
|
-
|
|
241
|
-
if (multiRichTextProp) {
|
|
242
|
-
// This is list
|
|
243
|
-
const node = listTreeBuilder.addWithProperty(b, multiRichTextProp);
|
|
244
|
-
if (node) {
|
|
245
|
-
result.push(serializeAsMultiRichTextBlock(node));
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
// This is not a list
|
|
249
|
-
// Flush the tree builder to inject a non-tree block after it
|
|
250
|
-
const tree = listTreeBuilder.flush();
|
|
251
|
-
if (tree) {
|
|
252
|
-
result.push(serializeAsMultiRichTextBlock(tree));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const node = internalBlockToProsemirrorNode(b, definition);
|
|
256
|
-
node && result.push(node);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
const tree = listTreeBuilder.flush();
|
|
261
|
-
if (tree) {
|
|
262
|
-
result.push(serializeAsMultiRichTextBlock(tree));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return result;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function internalBlockToProsemirrorNode(
|
|
269
|
-
block: PageBlockEditorModel,
|
|
270
|
-
definition: PageBlockDefinition
|
|
271
|
-
): ProsemirrorNode | null {
|
|
272
|
-
// Single rich text
|
|
273
|
-
const richTextProperty = BlockDefinitionUtils.firstRichTextProperty(definition);
|
|
274
|
-
if (richTextProperty) {
|
|
275
|
-
return serializeAsRichTextBlock({
|
|
276
|
-
block: block,
|
|
277
|
-
definition: definition,
|
|
278
|
-
property: richTextProperty,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const tableProperty = BlockDefinitionUtils.firstTableProperty(definition);
|
|
283
|
-
if (tableProperty) {
|
|
284
|
-
return serializeAsTable({
|
|
285
|
-
block: block,
|
|
286
|
-
definition: definition,
|
|
287
|
-
property: tableProperty,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Divider
|
|
292
|
-
if (block.data.packageId === "io.supernova.block.divider") {
|
|
293
|
-
return serializeAsDivider({
|
|
294
|
-
block: block,
|
|
295
|
-
definition: definition,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return serializeAsCustomBlock(block, definition);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
//
|
|
303
|
-
// Single rich text blocks
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
function serializeAsRichTextBlock(input: InputWithProperty): ProsemirrorNode {
|
|
307
|
-
const { block, definition, property: richTextProperty } = input;
|
|
308
|
-
|
|
309
|
-
const blockItem = BlockParsingUtils.singleBlockItem(block);
|
|
310
|
-
const textPropertyValue = BlockParsingUtils.richTextPropertyValue(blockItem, richTextProperty.id);
|
|
311
|
-
|
|
312
|
-
const enrichedInput: RichTextInputWithValue = { ...input, richTextPropertyValue: textPropertyValue };
|
|
313
|
-
|
|
314
|
-
const parsedOptions = PageBlockDefinitionRichTextOptions.optional().parse(richTextProperty.options);
|
|
315
|
-
const style = parsedOptions?.richTextStyle ?? "Default";
|
|
316
|
-
|
|
317
|
-
switch (style) {
|
|
318
|
-
case "Callout":
|
|
319
|
-
return serializeAsCallout(enrichedInput);
|
|
320
|
-
case "Default":
|
|
321
|
-
return serializeAsParagraph(enrichedInput);
|
|
322
|
-
|
|
323
|
-
case "Quote":
|
|
324
|
-
return serializeAsBlockquote(enrichedInput);
|
|
325
|
-
|
|
326
|
-
case "Title1":
|
|
327
|
-
case "Title2":
|
|
328
|
-
case "Title3":
|
|
329
|
-
case "Title4":
|
|
330
|
-
case "Title5":
|
|
331
|
-
return serializeAsHeading(enrichedInput);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function serializeAsParagraph(input: RichTextInputWithValue): ProsemirrorNode {
|
|
336
|
-
return {
|
|
337
|
-
type: "paragraph",
|
|
338
|
-
attrs: serializeBlockNodeAttributes(input.block),
|
|
339
|
-
...serializeRichTextNodePart(input.richTextPropertyValue.value),
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function serializeAsHeading(input: RichTextInputWithValue): ProsemirrorNode {
|
|
344
|
-
return {
|
|
345
|
-
type: "heading",
|
|
346
|
-
attrs: {
|
|
347
|
-
...serializeBlockNodeAttributes(input.block),
|
|
348
|
-
level: richTextHeadingLevel(input.property),
|
|
349
|
-
},
|
|
350
|
-
...serializeRichTextNodePart(input.richTextPropertyValue.value),
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function serializeAsBlockquote(input: RichTextInputWithValue): ProsemirrorNode {
|
|
355
|
-
return {
|
|
356
|
-
type: "blockquote",
|
|
357
|
-
attrs: serializeBlockNodeAttributes(input.block),
|
|
358
|
-
...serializeRichTextNodePart(input.richTextPropertyValue.value),
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function serializeAsCallout(input: RichTextInputWithValue): ProsemirrorNode {
|
|
363
|
-
const calloutType = input.richTextPropertyValue.calloutType ?? "Info";
|
|
364
|
-
|
|
365
|
-
return {
|
|
366
|
-
type: "callout",
|
|
367
|
-
attrs: {
|
|
368
|
-
...serializeBlockNodeAttributes(input.block),
|
|
369
|
-
type: serializeCalloutType(calloutType),
|
|
370
|
-
},
|
|
371
|
-
...serializeRichTextNodePart(input.richTextPropertyValue.value),
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
//
|
|
376
|
-
// Multi rich text blocks
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
function serializeAsMultiRichTextBlock(node: ListNode): ProsemirrorNode {
|
|
380
|
-
switch (node.listType) {
|
|
381
|
-
case "Ordered":
|
|
382
|
-
return serializeAsOrderedList(node);
|
|
383
|
-
|
|
384
|
-
case "Unordered":
|
|
385
|
-
return serializeAsUnorderedList(node);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function serializeAsOrderedList(tree: ListNode): ProsemirrorNode {
|
|
390
|
-
return {
|
|
391
|
-
type: "orderedList",
|
|
392
|
-
attrs: {
|
|
393
|
-
...serializeBlockNodeAttributes(tree.block),
|
|
394
|
-
start: "1",
|
|
395
|
-
},
|
|
396
|
-
content: serializeListContent(tree),
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function serializeAsUnorderedList(tree: ListNode): ProsemirrorNode {
|
|
401
|
-
return {
|
|
402
|
-
type: "bulletList",
|
|
403
|
-
attrs: {
|
|
404
|
-
...serializeBlockNodeAttributes(tree.block),
|
|
405
|
-
},
|
|
406
|
-
content: serializeListContent(tree),
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
function serializeListContent(tree: ListNode): ProsemirrorNode[] {
|
|
411
|
-
const result: ProsemirrorNode[] = tree.leadingChildren.map(i => serializeAsTextListItem(i.text));
|
|
412
|
-
|
|
413
|
-
for (const child of tree.children) {
|
|
414
|
-
if (child.type === "ListItem") {
|
|
415
|
-
// Text list item
|
|
416
|
-
|
|
417
|
-
result.push(serializeAsTextListItem(child.text));
|
|
418
|
-
} else if (child.type === "List") {
|
|
419
|
-
// List list item
|
|
420
|
-
|
|
421
|
-
const previousNode = result[result.length - 1];
|
|
422
|
-
if (!previousNode) {
|
|
423
|
-
throw SupernovaException.shouldNotHappen("List node without previous node");
|
|
424
|
-
}
|
|
425
|
-
if (!previousNode.content) {
|
|
426
|
-
throw SupernovaException.shouldNotHappen("List item node has no content");
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const serializedList = serializeAsMultiRichTextBlock(child);
|
|
430
|
-
previousNode.content.push(serializedList);
|
|
431
|
-
} else {
|
|
432
|
-
// Should noit happen
|
|
433
|
-
|
|
434
|
-
throw SupernovaException.shouldNotHappen(`Unknown list node type: ${child}`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return result;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function serializeAsTextListItem(text: PageBlockText): ProsemirrorNode {
|
|
442
|
-
return {
|
|
443
|
-
type: "listItem",
|
|
444
|
-
content: [
|
|
445
|
-
{
|
|
446
|
-
type: "paragraph",
|
|
447
|
-
attrs: {
|
|
448
|
-
definitionId: "io.supernova.block.rich-text",
|
|
449
|
-
variantId: "default",
|
|
450
|
-
},
|
|
451
|
-
content: serializeRichText(text),
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
//
|
|
458
|
-
// Tables
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
function serializeAsTable(input: InputWithProperty): ProsemirrorNode {
|
|
462
|
-
const { block, definition, property: tableProperty } = input;
|
|
463
|
-
|
|
464
|
-
const blockItem = BlockParsingUtils.singleBlockItem(block);
|
|
465
|
-
const table = BlockParsingUtils.tablePropertyValue(blockItem, tableProperty.id);
|
|
466
|
-
|
|
467
|
-
return {
|
|
468
|
-
type: "tableContainer",
|
|
469
|
-
attrs: {
|
|
470
|
-
...serializeBlockNodeAttributes(input.block),
|
|
471
|
-
hasBorder: table.showBorder ?? true,
|
|
472
|
-
},
|
|
473
|
-
|
|
474
|
-
content: [
|
|
475
|
-
{
|
|
476
|
-
type: "table",
|
|
477
|
-
content: serializeTableRows(table),
|
|
478
|
-
},
|
|
479
|
-
],
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function serializeTableRows(table: PageBlockItemTableValue): ProsemirrorNode[] {
|
|
484
|
-
// If no rows are present, we have to generate a least one empty row
|
|
485
|
-
const rows: PageBlockItemTableRow[] = table.value.length ? table.value : [{ cells: [] }];
|
|
486
|
-
|
|
487
|
-
return rows.map<ProsemirrorNode>((row, rowIndex) => {
|
|
488
|
-
const isHeaderRow = rowIndex === 0 && table.highlightHeaderRow === true;
|
|
489
|
-
|
|
490
|
-
// If no cells are present, we have to generate at least one cell
|
|
491
|
-
const cells: PageBlockItemTableCell[] = row.cells.length ? row.cells : [{ id: "", alignment: "Left", nodes: [] }];
|
|
492
|
-
|
|
493
|
-
return {
|
|
494
|
-
type: "tableRow",
|
|
495
|
-
content: cells.map<ProsemirrorNode>((cell, cellIndex) => {
|
|
496
|
-
const isHeaderColumn = cellIndex === 0 && table.highlightHeaderColumn === true;
|
|
497
|
-
|
|
498
|
-
return {
|
|
499
|
-
type: isHeaderRow || isHeaderColumn ? "tableHeader" : "tableCell",
|
|
500
|
-
attrs: {
|
|
501
|
-
...(cell.id && { id: cell.id }),
|
|
502
|
-
textAlign: serializeTableCellAlignment(cell.alignment),
|
|
503
|
-
colspan: 1,
|
|
504
|
-
rowspan: 1,
|
|
505
|
-
...(cell.columnWidth && { colwidth: [cell.columnWidth] }),
|
|
506
|
-
},
|
|
507
|
-
content: serializeTableCellNodes(cell),
|
|
508
|
-
};
|
|
509
|
-
}),
|
|
510
|
-
};
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function serializeTableCellAlignment(alignment: PageBlockTableCellAlignment) {
|
|
515
|
-
switch (alignment) {
|
|
516
|
-
case "Left":
|
|
517
|
-
return "left";
|
|
518
|
-
case "Center":
|
|
519
|
-
return "center";
|
|
520
|
-
case "Right":
|
|
521
|
-
return "right";
|
|
522
|
-
|
|
523
|
-
default:
|
|
524
|
-
return "left";
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function serializeTableCellNodes(cell: PageBlockItemTableCell): ProsemirrorNode[] {
|
|
529
|
-
const result = cell.nodes.map(serializeTableNode);
|
|
530
|
-
|
|
531
|
-
if (result.length) {
|
|
532
|
-
return result;
|
|
533
|
-
} else {
|
|
534
|
-
return [{ type: "paragraph" }];
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
function serializeTableNode(node: PageBlockItemTableNode): ProsemirrorNode {
|
|
539
|
-
switch (node.type) {
|
|
540
|
-
case "RichText":
|
|
541
|
-
return {
|
|
542
|
-
type: "paragraph",
|
|
543
|
-
attrs: {
|
|
544
|
-
id: node.id,
|
|
545
|
-
definitionId: "io.supernova.block.rich-text",
|
|
546
|
-
},
|
|
547
|
-
...serializeRichTextNodePart(node.value),
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
case "Image":
|
|
551
|
-
return {
|
|
552
|
-
type: "image",
|
|
553
|
-
attrs: {
|
|
554
|
-
id: node.id,
|
|
555
|
-
definitionId: "io.supernova.block.image",
|
|
556
|
-
items: JSON.stringify([
|
|
557
|
-
{
|
|
558
|
-
id: node.id,
|
|
559
|
-
props: {
|
|
560
|
-
image: {
|
|
561
|
-
...(node.alt && { alt: node.alt }),
|
|
562
|
-
...(node.caption && { caption: node.caption }),
|
|
563
|
-
...(node.alignment && { alignment: node.alignment }),
|
|
564
|
-
value: node.value,
|
|
565
|
-
} satisfies PageBlockItemImageValue,
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
]),
|
|
569
|
-
},
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
//
|
|
575
|
-
// Divider
|
|
576
|
-
//
|
|
577
|
-
|
|
578
|
-
function serializeAsDivider(input: BaseInput): ProsemirrorNode {
|
|
579
|
-
return {
|
|
580
|
-
type: "horizontalRule",
|
|
581
|
-
attrs: serializeBlockNodeAttributes(input.block),
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
//
|
|
586
|
-
// Attributes
|
|
587
|
-
//
|
|
588
|
-
|
|
589
|
-
function serializeBlockNodeAttributes(block: PageBlockEditorModel) {
|
|
590
|
-
return {
|
|
591
|
-
id: block.id,
|
|
592
|
-
definitionId: block.data.packageId,
|
|
593
|
-
...(block.data.variantId && { variantId: block.data.variantId }),
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function richTextHeadingLevel(property: PageBlockDefinitionProperty): number | undefined {
|
|
598
|
-
const style = property.options?.richTextStyle;
|
|
599
|
-
if (!style) return undefined;
|
|
600
|
-
|
|
601
|
-
switch (style) {
|
|
602
|
-
case "Title1":
|
|
603
|
-
return 1;
|
|
604
|
-
case "Title2":
|
|
605
|
-
return 2;
|
|
606
|
-
case "Title3":
|
|
607
|
-
return 3;
|
|
608
|
-
case "Title4":
|
|
609
|
-
return 4;
|
|
610
|
-
case "Title5":
|
|
611
|
-
return 5;
|
|
612
|
-
case "Callout":
|
|
613
|
-
case "Default":
|
|
614
|
-
case "Quote":
|
|
615
|
-
return undefined;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
function serializeCalloutType(calloutType: PageBlockCalloutType) {
|
|
620
|
-
switch (calloutType) {
|
|
621
|
-
case "Error":
|
|
622
|
-
return "critical";
|
|
623
|
-
case "Info":
|
|
624
|
-
return "neutral";
|
|
625
|
-
case "Success":
|
|
626
|
-
return "positive";
|
|
627
|
-
case "Warning":
|
|
628
|
-
return "warning";
|
|
629
|
-
case "Primary":
|
|
630
|
-
return "primary";
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
//
|
|
635
|
-
// Rich text
|
|
636
|
-
//
|
|
637
|
-
|
|
638
|
-
function serializeRichTextNodePart(richText: PageBlockText): Pick<ProsemirrorNode, "content"> {
|
|
639
|
-
const spans = serializeRichText(richText);
|
|
640
|
-
if (spans.length) return { content: spans };
|
|
641
|
-
return {};
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
function serializeRichText(richText: PageBlockText) {
|
|
645
|
-
return richText.spans.map(serializeTextSpan).flat();
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
function serializeTextSpan(span: PageBlockTextSpan): ProsemirrorNode[] {
|
|
649
|
-
const hardBreakType = "hardBreak";
|
|
650
|
-
|
|
651
|
-
const marks = span.attributes.map(serializeTextSpanAttribute);
|
|
652
|
-
|
|
653
|
-
const textParts = span.text.split("\n");
|
|
654
|
-
const interspersed: ProsemirrorNode[] = [
|
|
655
|
-
{
|
|
656
|
-
type: "text",
|
|
657
|
-
text: textParts[0],
|
|
658
|
-
|
|
659
|
-
...(marks.length && { marks: marks }),
|
|
660
|
-
},
|
|
661
|
-
];
|
|
662
|
-
|
|
663
|
-
for (let i = 1; i < textParts.length; i++) {
|
|
664
|
-
interspersed.push(
|
|
665
|
-
{
|
|
666
|
-
type: hardBreakType,
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
type: "text",
|
|
670
|
-
text: textParts[i],
|
|
671
|
-
|
|
672
|
-
...(marks.length && { marks: marks }),
|
|
673
|
-
}
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return interspersed.filter(t => t.type === hardBreakType || !!t.text);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
function serializeTextSpanAttribute(spanAttribute: PageBlockTextSpanAttribute): ProsemirrorMark {
|
|
681
|
-
switch (spanAttribute.type) {
|
|
682
|
-
case "Bold":
|
|
683
|
-
return { type: "bold", attrs: {} };
|
|
684
|
-
case "Italic":
|
|
685
|
-
return { type: "italic", attrs: {} };
|
|
686
|
-
case "Strikethrough":
|
|
687
|
-
return { type: "strike", attrs: {} };
|
|
688
|
-
case "Code":
|
|
689
|
-
return { type: "code", attrs: {} };
|
|
690
|
-
case "Comment":
|
|
691
|
-
return {
|
|
692
|
-
type: "commentHighlight",
|
|
693
|
-
attrs: {
|
|
694
|
-
highlightId: spanAttribute.commentHighlightId,
|
|
695
|
-
resolved: spanAttribute.commentIsResolved,
|
|
696
|
-
},
|
|
697
|
-
};
|
|
698
|
-
case "Link":
|
|
699
|
-
if (spanAttribute.link) {
|
|
700
|
-
return serializeLinkMark(
|
|
701
|
-
spanAttribute.link,
|
|
702
|
-
spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
|
|
703
|
-
);
|
|
704
|
-
} else if (spanAttribute.documentationItemId) {
|
|
705
|
-
return serializeLinkMark(
|
|
706
|
-
`@page:${spanAttribute.documentationItemId}`,
|
|
707
|
-
spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false
|
|
708
|
-
);
|
|
709
|
-
} else {
|
|
710
|
-
return serializeLinkMark("about:blank", spanAttribute.openInNewTab ?? spanAttribute.openInNewWindow ?? false);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
function serializeLinkMark(href: string, openInNewTab: boolean): ProsemirrorMark {
|
|
716
|
-
return {
|
|
717
|
-
type: "link",
|
|
718
|
-
attrs: {
|
|
719
|
-
href: href,
|
|
720
|
-
target: openInNewTab ? "_blank" : "_self",
|
|
721
|
-
rel: "noopener noreferrer nofollow",
|
|
722
|
-
class: "tiptap-link",
|
|
723
|
-
},
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
export function serializeAsCustomBlock(block: PageBlockEditorModel, definition: PageBlockDefinition): ProsemirrorNode {
|
|
728
|
-
const items = block.data.items.map(i => {
|
|
729
|
-
return {
|
|
730
|
-
id: i.id,
|
|
731
|
-
props: i.props,
|
|
732
|
-
linksTo: i.linksTo,
|
|
733
|
-
};
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
const columns = block.data.appearance?.numberOfColumns;
|
|
737
|
-
|
|
738
|
-
return {
|
|
739
|
-
type: serializeCustomBlockNodeType(block, definition),
|
|
740
|
-
attrs: {
|
|
741
|
-
id: block.id,
|
|
742
|
-
definitionId: block.data.packageId,
|
|
743
|
-
...(block.data.variantId && { variantId: block.data.variantId }),
|
|
744
|
-
items: JSON.stringify(items),
|
|
745
|
-
|
|
746
|
-
...(block.data.appearance && { appearance: JSON.stringify(block.data.appearance) }),
|
|
747
|
-
...(columns && { columns: columns }),
|
|
748
|
-
},
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
function serializeCustomBlockNodeType(block: PageBlockEditorModel, definition: PageBlockDefinition): string {
|
|
753
|
-
switch (block.data.packageId) {
|
|
754
|
-
case "io.supernova.block.image":
|
|
755
|
-
return "image";
|
|
756
|
-
|
|
757
|
-
default:
|
|
758
|
-
return "blockNode";
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
function nonNullFilter<T>(item: T | null): item is T {
|
|
763
|
-
return !!item;
|
|
764
|
-
}
|