@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.52.0",
3
+ "version": "0.52.1",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -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 = removeCommentSpansFromPage(sanitizedContent, definitions);
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 removeCommentSpansFromPage(
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: removeCommentSpans(richTextValue.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(removeCommentSpans),
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 = removeCommentSpans(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
+ }