@supernova-studio/client 0.51.2 → 0.52.1
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 +159 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/yjs/version-room/utils.ts +18 -5
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
PageBlockItemMultiRichTextValue,
|
|
5
5
|
PageBlockItemRichTextValue,
|
|
6
6
|
PageBlockItemTableValue,
|
|
7
|
+
PageBlockText,
|
|
7
8
|
mapPageBlockItemValuesV2,
|
|
8
9
|
removeCommentSpans,
|
|
9
10
|
} from "@supernova-studio/model";
|
|
@@ -18,7 +19,7 @@ export function generatePageContentHash(
|
|
|
18
19
|
let sanitizedContent = structuredClone(content);
|
|
19
20
|
|
|
20
21
|
// Remove comment spans
|
|
21
|
-
sanitizedContent =
|
|
22
|
+
sanitizedContent = sanitizePageContents(sanitizedContent, definitions);
|
|
22
23
|
|
|
23
24
|
// Make sure hashes of empty pages always match
|
|
24
25
|
if (isPageContentEmpty(sanitizedContent)) {
|
|
@@ -51,7 +52,7 @@ function isPageContentEmpty(content: DocumentationPageEditorModel): boolean {
|
|
|
51
52
|
return !textValue.value.spans.length;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
function
|
|
55
|
+
function sanitizePageContents(
|
|
55
56
|
content: DocumentationPageEditorModel,
|
|
56
57
|
definitions: PageBlockDefinition[]
|
|
57
58
|
): DocumentationPageEditorModel {
|
|
@@ -62,7 +63,7 @@ function removeCommentSpansFromPage(
|
|
|
62
63
|
const richTextValue = value as PageBlockItemRichTextValue;
|
|
63
64
|
return {
|
|
64
65
|
...richTextValue,
|
|
65
|
-
value:
|
|
66
|
+
value: sanitizeRichText(richTextValue.value),
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -70,7 +71,7 @@ function removeCommentSpansFromPage(
|
|
|
70
71
|
const multiRichTextValue = value as PageBlockItemMultiRichTextValue;
|
|
71
72
|
return {
|
|
72
73
|
...multiRichTextValue,
|
|
73
|
-
value: multiRichTextValue.value.map(
|
|
74
|
+
value: multiRichTextValue.value.map(sanitizeRichText),
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -80,7 +81,7 @@ function removeCommentSpansFromPage(
|
|
|
80
81
|
r.cells.forEach(c => {
|
|
81
82
|
c.nodes.forEach(n => {
|
|
82
83
|
if (n.type === "RichText") {
|
|
83
|
-
n.value =
|
|
84
|
+
n.value = sanitizeRichText(n.value);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
});
|
|
@@ -94,3 +95,15 @@ function removeCommentSpansFromPage(
|
|
|
94
95
|
|
|
95
96
|
return content;
|
|
96
97
|
}
|
|
98
|
+
|
|
99
|
+
function sanitizeRichText(richText: PageBlockText): PageBlockText {
|
|
100
|
+
return sortSpanAttributes(removeCommentSpans(richText));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function sortSpanAttributes(richText: PageBlockText) {
|
|
104
|
+
richText.spans.forEach(s => {
|
|
105
|
+
s.attributes.sort((lhs, rhs) => lhs.type.localeCompare(rhs.type));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return richText;
|
|
109
|
+
}
|