@supernova-studio/client 0.52.0 → 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.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/yjs/version-room/utils.ts +18 -5
package/dist/index.mjs
CHANGED
|
@@ -6427,7 +6427,7 @@ var VersionRoomBaseYDoc = class {
|
|
|
6427
6427
|
// src/yjs/version-room/utils.ts
|
|
6428
6428
|
function generatePageContentHash(content, definitions, debug = false) {
|
|
6429
6429
|
let sanitizedContent = structuredClone(content);
|
|
6430
|
-
sanitizedContent =
|
|
6430
|
+
sanitizedContent = sanitizePageContents(sanitizedContent, definitions);
|
|
6431
6431
|
if (isPageContentEmpty(sanitizedContent)) {
|
|
6432
6432
|
sanitizedContent = { blocks: [] };
|
|
6433
6433
|
}
|
|
@@ -6448,21 +6448,21 @@ function isPageContentEmpty(content) {
|
|
|
6448
6448
|
const textValue = singleItem.props["text"];
|
|
6449
6449
|
return !textValue.value.spans.length;
|
|
6450
6450
|
}
|
|
6451
|
-
function
|
|
6451
|
+
function sanitizePageContents(content, definitions) {
|
|
6452
6452
|
const defMap = new PageBlockDefinitionsMap(definitions);
|
|
6453
6453
|
mapPageBlockItemValuesV2(content.blocks, defMap, (block, item, prop, value) => {
|
|
6454
6454
|
if (prop.type === "RichText") {
|
|
6455
6455
|
const richTextValue = value;
|
|
6456
6456
|
return {
|
|
6457
6457
|
...richTextValue,
|
|
6458
|
-
value:
|
|
6458
|
+
value: sanitizeRichText(richTextValue.value)
|
|
6459
6459
|
};
|
|
6460
6460
|
}
|
|
6461
6461
|
if (prop.type === "MultiRichText") {
|
|
6462
6462
|
const multiRichTextValue = value;
|
|
6463
6463
|
return {
|
|
6464
6464
|
...multiRichTextValue,
|
|
6465
|
-
value: multiRichTextValue.value.map(
|
|
6465
|
+
value: multiRichTextValue.value.map(sanitizeRichText)
|
|
6466
6466
|
};
|
|
6467
6467
|
}
|
|
6468
6468
|
if (prop.type === "Table") {
|
|
@@ -6471,7 +6471,7 @@ function removeCommentSpansFromPage(content, definitions) {
|
|
|
6471
6471
|
r.cells.forEach((c) => {
|
|
6472
6472
|
c.nodes.forEach((n) => {
|
|
6473
6473
|
if (n.type === "RichText") {
|
|
6474
|
-
n.value =
|
|
6474
|
+
n.value = sanitizeRichText(n.value);
|
|
6475
6475
|
}
|
|
6476
6476
|
});
|
|
6477
6477
|
});
|
|
@@ -6482,6 +6482,15 @@ function removeCommentSpansFromPage(content, definitions) {
|
|
|
6482
6482
|
});
|
|
6483
6483
|
return content;
|
|
6484
6484
|
}
|
|
6485
|
+
function sanitizeRichText(richText) {
|
|
6486
|
+
return sortSpanAttributes(removeCommentSpans(richText));
|
|
6487
|
+
}
|
|
6488
|
+
function sortSpanAttributes(richText) {
|
|
6489
|
+
richText.spans.forEach((s) => {
|
|
6490
|
+
s.attributes.sort((lhs, rhs) => lhs.type.localeCompare(rhs.type));
|
|
6491
|
+
});
|
|
6492
|
+
return richText;
|
|
6493
|
+
}
|
|
6485
6494
|
|
|
6486
6495
|
// src/yjs/version-room/frontend.ts
|
|
6487
6496
|
var FrontendVersionRoomYDoc = class {
|