@supernova-studio/client 0.0.7 → 0.0.9
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/package.json
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
ProsemirrorNode,
|
|
16
16
|
ProsemirrorMark,
|
|
17
17
|
} from "./prosemirror/types";
|
|
18
|
-
import { BlockDefinitionUtils,
|
|
18
|
+
import { BlockDefinitionUtils, BlockParsingUtils } from "./utils";
|
|
19
19
|
import { DocumentationPageEditorModel } from "./model";
|
|
20
20
|
import { prosemirrorJSONToYXmlFragment } from "y-prosemirror";
|
|
21
21
|
import { pmSchema } from "./prosemirror";
|
|
@@ -81,8 +81,8 @@ export function blockToProsemirrorNode(
|
|
|
81
81
|
export function serializeAsRichTextBlock(input: Input): ProsemirrorNode {
|
|
82
82
|
const { block, definition, richTextProperty } = input;
|
|
83
83
|
|
|
84
|
-
const blockItem =
|
|
85
|
-
const textPropertyValue =
|
|
84
|
+
const blockItem = BlockParsingUtils.singleBlockItem(block);
|
|
85
|
+
const textPropertyValue = BlockParsingUtils.richTextPropertyValue(blockItem, richTextProperty.id);
|
|
86
86
|
|
|
87
87
|
const enrichedInput: InputWithValue = { ...input, richTextPropertyValue: textPropertyValue };
|
|
88
88
|
|
package/src/docs-editor/utils.ts
CHANGED
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
PageBlockText,
|
|
7
7
|
} from "@supernova-studio/model";
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const BlockParsingUtils = {
|
|
10
10
|
singleBlockItem(block: PageBlockEditorModel) {
|
|
11
11
|
if (!block.data.items.length) throw new Error(`Block ${block.id} has no items`);
|
|
12
12
|
if (block.data.items.length > 1) throw new Error(`Block ${block.id} has more than 1 item`);
|
|
13
13
|
|
|
14
|
-
return block.data.items[0]
|
|
14
|
+
return block.data.items[0]!;
|
|
15
15
|
},
|
|
16
16
|
|
|
17
17
|
richTextPropertyValue(item: PageBlockItemV2, propertyKey: string) {
|