@supernova-studio/client 0.38.0 → 0.40.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 +1 -29
- package/dist/index.d.ts +1 -29
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +20 -18
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +8 -2
package/package.json
CHANGED
|
@@ -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
|
//
|
|
@@ -73,8 +73,14 @@ export function prosemirrorDocToPage(
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function shallowProsemirrorNodeToBlock(
|
|
77
|
-
|
|
76
|
+
export function shallowProsemirrorNodeToBlock(
|
|
77
|
+
prosemirrorNode: ProsemirrorNode,
|
|
78
|
+
definition: PageBlockDefinition
|
|
79
|
+
): PageBlockEditorModel | null {
|
|
80
|
+
return (
|
|
81
|
+
prosemirrorNodeAndDefinitionToBlock(prosemirrorNode, definition, new Map([[definition.id, definition]]), 0)[0] ??
|
|
82
|
+
null
|
|
83
|
+
);
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
//
|