@supernova-studio/client 0.47.61 → 0.47.63
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/utils/hash.ts +13 -3
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +2 -2
- package/src/yjs/version-room/frontend.ts +1 -3
- package/src/yjs/version-room/utils.ts +2 -2
package/package.json
CHANGED
package/src/utils/hash.ts
CHANGED
|
@@ -38,13 +38,23 @@ function prepareObject(obj: any): any {
|
|
|
38
38
|
return sortedObj;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function generateHash(input: object | string): string {
|
|
41
|
+
export function generateHash(input: object | string, debug = false): string {
|
|
42
42
|
if (typeof input === "object") {
|
|
43
|
-
|
|
43
|
+
const sanitized = JSON.stringify(prepareObject(input));
|
|
44
|
+
if (debug) {
|
|
45
|
+
console.log("Hashing sanitized string:");
|
|
46
|
+
console.log(sanitized);
|
|
47
|
+
}
|
|
48
|
+
return hash(sanitized);
|
|
44
49
|
} else {
|
|
45
50
|
try {
|
|
46
51
|
const obj = JSON.parse(input);
|
|
47
|
-
|
|
52
|
+
const sanitized = JSON.stringify(prepareObject(obj));
|
|
53
|
+
if (debug) {
|
|
54
|
+
console.log("Hashing sanitized string:");
|
|
55
|
+
console.log(sanitized);
|
|
56
|
+
}
|
|
57
|
+
return hash(sanitized);
|
|
48
58
|
} catch {
|
|
49
59
|
return hash(input);
|
|
50
60
|
}
|
|
@@ -267,11 +267,10 @@ function parseAsRichText(
|
|
|
267
267
|
id: id,
|
|
268
268
|
type: "Block",
|
|
269
269
|
|
|
270
|
-
...(variantId && { variantId: variantId }),
|
|
271
|
-
|
|
272
270
|
data: {
|
|
273
271
|
packageId: definition.id,
|
|
274
272
|
indentLevel: 0,
|
|
273
|
+
...(variantId && { variantId: variantId }),
|
|
275
274
|
items: [
|
|
276
275
|
{
|
|
277
276
|
id: id,
|
|
@@ -528,6 +527,7 @@ function parseAsTableCell(prosemirrorNode: ProsemirrorNode): PageBlockItemTableC
|
|
|
528
527
|
const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth", z.array(z.number()).optional());
|
|
529
528
|
if (columnWidthArray) {
|
|
530
529
|
columnWidth = columnWidthArray[0];
|
|
530
|
+
columnWidth = Math.round(columnWidth * 100) / 100;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
533
|
const tableNodes = (prosemirrorNode.content ?? []).map(parseAsTableNode).filter(nonNullFilter);
|
|
@@ -249,10 +249,8 @@ export class FrontendVersionRoomYDoc {
|
|
|
249
249
|
//
|
|
250
250
|
|
|
251
251
|
notifyDocumentationPageContentUpdated(pageId: string, content: DocumentationPageEditorModel) {
|
|
252
|
-
const pageContentHash = generatePageContentHash(content);
|
|
252
|
+
const pageContentHash = generatePageContentHash(content, this.debug);
|
|
253
253
|
if (this.debug) {
|
|
254
|
-
console.log("Hashed:");
|
|
255
|
-
console.log(JSON.stringify(content));
|
|
256
254
|
console.log(`Will set page content hash: '${pageId}' : '${pageContentHash}'`);
|
|
257
255
|
}
|
|
258
256
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateHash } from "../../utils";
|
|
2
2
|
import { DocumentationPageEditorModel } from "../docs-editor";
|
|
3
3
|
|
|
4
|
-
export function generatePageContentHash(content: DocumentationPageEditorModel) {
|
|
5
|
-
return generateHash(content);
|
|
4
|
+
export function generatePageContentHash(content: DocumentationPageEditorModel, debug = false) {
|
|
5
|
+
return generateHash(content, debug);
|
|
6
6
|
}
|