@fileverse-dev/dsheet 1.2.93-ydoc-8 → 1.2.93-ydoc-10

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.
@@ -0,0 +1,20 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+
3
+ import * as Y from 'yjs';
4
+ type SyncContext = {
5
+ sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
6
+ ydocRef: React.MutableRefObject<Y.Doc | null>;
7
+ dsheetId: string;
8
+ handleOnChangePortalUpdate: () => void;
9
+ };
10
+ export declare const syncCurrentSheetField: (context: SyncContext, field: "images" | "iframes" | "frozen" | "name" | "config" | "showGridLines") => void;
11
+ export declare const createSheetLengthChangeHandler: ({ sheetEditorRef, ydocRef, dsheetId, currentDataRef, handleOnChangePortalUpdate, }: {
12
+ sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
13
+ ydocRef: React.MutableRefObject<Y.Doc | null>;
14
+ dsheetId: string;
15
+ currentDataRef: React.MutableRefObject<any>;
16
+ handleOnChangePortalUpdate: () => void;
17
+ }) => () => void;
18
+ export declare const createAfterOrderChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
19
+ export declare const createAfterColRowChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
20
+ export {};
@@ -5,7 +5,7 @@ import { DataBlockApiKeyHandlerType, SheetUpdateData } from '../types';
5
5
 
6
6
  import * as Y from 'yjs';
7
7
  export interface EditorContextType {
8
- handleOnChangePortalUpdate: (data: any[]) => void;
8
+ handleOnChangePortalUpdate: () => void;
9
9
  setSelectedTemplate?: React.Dispatch<React.SetStateAction<string>>;
10
10
  setShowSmartContractModal?: React.Dispatch<React.SetStateAction<boolean>>;
11
11
  getDocumentTitle?: () => string;
@@ -20,7 +20,7 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
20
20
  currentDataRef: import('react').MutableRefObject<Sheet[]>;
21
21
  remoteUpdateRef: import('react').MutableRefObject<boolean>;
22
22
  isDataLoaded: boolean;
23
- handleChange: (data: Sheet[]) => void;
23
+ handleChange: (_data: Sheet[]) => void;
24
24
  handleLiveQuery: (subsheetIndex: number, queryData: import('@fileverse-dev/fortune-core').LiveQueryData) => void;
25
25
  initialiseLiveQueryData: (sheets: Sheet[]) => void;
26
26
  };
@@ -2,12 +2,8 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync calcChain array for active sheet.
6
+ * calcChain is keyed by `r_c` while stored in Yjs.
11
7
  */
12
8
  export declare const calcChainYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
13
9
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -2,12 +2,8 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync condition format rules for active sheet.
6
+ * This field is stored as one array payload in Yjs.
11
7
  */
12
8
  export declare const conditionFormatYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
13
9
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -2,12 +2,7 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync dataBlockCalcFunction map for the active sheet to Yjs.
11
6
  */
12
7
  export declare const dataBlockListYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, dataBlockCalcFunction }: {
13
8
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -2,12 +2,7 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync current sheet dataVerification object to Yjs.
11
6
  */
12
7
  export declare const dataVerificationYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
13
8
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -2,12 +2,7 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync hyperlink map for the active sheet to Yjs.
11
6
  */
12
7
  export declare const hyperlinkYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
13
8
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -1,4 +1,4 @@
1
1
  import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
- export declare const handleExportToJSON: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, dsheetId: string) => void;
4
+ export declare const handleExportToJSON: (sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, ydocRef: React.RefObject<Y.Doc | null>, _dsheetId: string) => void;
@@ -2,12 +2,7 @@ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
2
 
3
3
  import * as Y from 'yjs';
4
4
  /**
5
- * Verifies the integrity of sheet data in a YDoc against a given sheet editor instance.
6
- * This function is used to verify that the sheet data in a YDoc matches the data in a sheet editor instance.
7
- * @param {Object} options
8
- * @param {React.RefObject<WorkbookInstance | null>} options.sheetEditorRef - Reference to the sheet editor instance
9
- * @param {React.RefObject<Y.Doc | null>} options.ydocRef - Reference to the YDoc instance
10
- * @returns {void}
5
+ * Sync liveQueryList map for the active sheet to Yjs.
11
6
  */
12
7
  export declare const liveQueryListYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal }: {
13
8
  sheetEditorRef: React.RefObject<WorkbookInstance | null>;
@@ -0,0 +1,31 @@
1
+ import { WorkbookInstance } from '@fileverse-dev/fortune-react';
2
+ import { SheetChangePath } from './update-ydoc';
3
+
4
+ import * as Y from 'yjs';
5
+ type SyncContext = {
6
+ currentSheetId: string;
7
+ oldSheet: Record<string, any>;
8
+ ydoc: Y.Doc;
9
+ };
10
+ /**
11
+ * Build a stable sync context from current editor sheet and Yjs snapshot.
12
+ * This keeps all field-level sync handlers aligned on the same baseline.
13
+ */
14
+ export declare const getSheetYdocSyncContext: ({ sheetEditorRef, ydocRef, dsheetId, }: {
15
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
16
+ ydocRef: React.RefObject<Y.Doc | null>;
17
+ dsheetId: string;
18
+ }) => SyncContext | null;
19
+ export declare const buildMapFieldChanges: ({ sheetId, fieldPath, oldData, newData, }: {
20
+ sheetId: string;
21
+ fieldPath: string;
22
+ oldData: Record<string, any>;
23
+ newData: Record<string, any>;
24
+ }) => SheetChangePath[];
25
+ export declare const applyYdocSheetChanges: ({ ydoc, dsheetId, changes, handleContentPortal, }: {
26
+ ydoc: Y.Doc;
27
+ dsheetId: string;
28
+ changes: SheetChangePath[];
29
+ handleContentPortal?: any;
30
+ }) => void;
31
+ export {};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/dsheet",
3
3
  "private": false,
4
4
  "description": "DSheet",
5
- "version": "1.2.93-ydoc-8",
5
+ "version": "1.2.93-ydoc-10",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {
@@ -41,6 +41,7 @@
41
41
  "exceljs": "^4.4.0",
42
42
  "js-base64": "^3.7.7",
43
43
  "katex": "^0.16.11",
44
+ "lodash": "^4.17.23",
44
45
  "luckyexcel": "^1.0.1",
45
46
  "papaparse": "^5.5.2",
46
47
  "react": "^18.2.0",
@@ -56,6 +57,7 @@
56
57
  "yjs": "^13.6.15"
57
58
  },
58
59
  "devDependencies": {
60
+ "@types/lodash": "^4.17.23",
59
61
  "@types/node": "^20.10.0",
60
62
  "@types/papaparse": "^5.3.15",
61
63
  "@types/react": "^18.2.37",