@fileverse-dev/dsheet 4.1.1-edit-mode-16 → 4.1.2-overhaul-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/README.md +7 -9
- package/dist/{constants-B3rfAvvz.js → constants-5ZxHFftQ.js} +22 -79
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +3 -3
- package/dist/crypto-constants-CY-Whjwy.js +333 -0
- package/dist/editor/components/editor-workbook.d.ts +1 -5
- package/dist/editor/components/permission-chip.d.ts +1 -5
- package/dist/editor/contexts/editor-context.d.ts +2 -11
- package/dist/editor/dsheet-editor.d.ts +2 -3
- package/dist/editor/hooks/use-collab-awareness.d.ts +6 -3
- package/dist/editor/hooks/use-editor-data.d.ts +2 -2
- package/dist/editor/hooks/use-editor-sync.d.ts +2 -6
- package/dist/editor/types/comments.d.ts +11 -0
- package/dist/editor/types.d.ts +4 -30
- package/dist/editor/utils/apply-comment-markers.d.ts +3 -11
- package/dist/editor/utils/comment-anchors-ydoc.d.ts +32 -0
- package/dist/editor/utils/remap-comment-anchors.d.ts +26 -0
- package/dist/{executeStringFunction-CxsiamWG.js → executeStringFunction-adhsb5GH.js} +1152 -1107
- package/dist/formula.js +1 -1
- package/dist/{index-DQvYqAJz.js → index-DC_Tcoo4.js} +27654 -28038
- package/dist/index.d.ts +3 -4
- package/dist/index.es.js +52 -55
- package/dist/persistence-utils-DsM_MOB1.js +89 -0
- package/dist/persistence-utils.d.ts +0 -6
- package/dist/persistence.js +1 -1
- package/dist/sheet-engine/core/index.d.ts +1 -1
- package/dist/sheet-engine/core/settings.d.ts +40 -0
- package/dist/sheet-engine/core/utils/comment-anchor-move.d.ts +17 -0
- package/dist/sheet-engine/react/components/Toolbar/index.d.ts +0 -1
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +0 -1
- package/dist/style.css +1 -1
- package/dist/sync-local/SyncManager.d.ts +9 -54
- package/dist/sync-local/index.d.ts +1 -1
- package/dist/sync-local/socketClient.d.ts +8 -75
- package/dist/sync-local/types/index.d.ts +15 -111
- package/dist/sync-local/useSyncManager.d.ts +0 -4
- package/dist/sync-local/utils/objectToFile.d.ts +1 -0
- package/dist/{use-xlsx-import-impl-DjiPGIoS.js → use-xlsx-import-impl-CcET8OCA.js} +148 -148
- package/dist/{xlsx-defined-names-Dr4_psg0.js → xlsx-defined-names-u1Jyf-M6.js} +2 -2
- package/dist/{xlsx-export-impl-D2YNoxJm.js → xlsx-export-impl-BjQj4U0N.js} +192 -188
- package/dist/{xlsx-hyperlink-inline-BkLFFNwP.js → xlsx-hyperlink-inline-D2-WOlOD.js} +2 -2
- package/package.json +2 -2
- package/dist/crypto-constants-ZTlAYRUf.js +0 -1165
- package/dist/editor/components/editor-workbook-controls.d.ts +0 -11
- package/dist/editor/components/permission-chip-model.d.ts +0 -34
- package/dist/editor/components/permission-chip.test.d.ts +0 -1
- package/dist/editor/hooks/collaboration-lifecycle.d.ts +0 -35
- package/dist/editor/hooks/collaboration-lifecycle.test.d.ts +0 -1
- package/dist/editor/utils/detach-workbook-data.d.ts +0 -8
- package/dist/editor/utils/detach-workbook-data.test.d.ts +0 -1
- package/dist/editor/utils/editor-handle.d.ts +0 -11
- package/dist/editor/utils/editor-handle.test.d.ts +0 -1
- package/dist/persistence-utils-BXFajzvq.js +0 -98
- package/dist/persistence-utils.test.d.ts +0 -1
- package/dist/sync-local/crypto/room-key.d.ts +0 -2
- package/dist/sync-local/crypto/room-key.test.d.ts +0 -1
- package/dist/sync-local/floor.d.ts +0 -8
- package/dist/sync-local/floor.test.d.ts +0 -1
- package/dist/sync-local/presence.d.ts +0 -13
- package/dist/sync-local/presence.test.d.ts +0 -1
- package/dist/sync-local/session-tools.d.ts +0 -31
- package/dist/sync-local/session-tools.test.d.ts +0 -1
- /package/dist/editor/{components/editor-workbook-controls.test.d.ts → utils/remap-comment-anchors.test.d.ts} +0 -0
|
@@ -8,7 +8,7 @@ import * as Y from 'yjs';
|
|
|
8
8
|
* Hook for managing sheet data
|
|
9
9
|
* Handles initialization, updates, and persistence of sheet data
|
|
10
10
|
*/
|
|
11
|
-
export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | null>, dsheetId: string, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>, isReadOnly?: boolean, onChange?: (data: Sheet[]) => void, syncStatus?: "initializing" | "syncing" | "synced" | "error",
|
|
11
|
+
export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | null>, dsheetId: string, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>, portalContent?: string, isReadOnly?: boolean, onChange?: (data: Sheet[]) => void, syncStatus?: "initializing" | "syncing" | "synced" | "error", commentData?: object, dataBlockCalcFunction?: {
|
|
12
12
|
[key: string]: {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
|
|
|
16
16
|
[key: string]: {
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
|
-
}>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, allowComments?: boolean, collabEnabled?: boolean) => {
|
|
19
|
+
}>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, allowComments?: boolean, hasCollabContentInitialised?: boolean, collabEnabled?: boolean) => {
|
|
20
20
|
sheetData: Sheet[];
|
|
21
21
|
setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[]>>;
|
|
22
22
|
currentDataRef: import('react').MutableRefObject<Sheet[]>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
2
|
import { CollaborationProps } from '../../sync-local/types';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
|
-
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean,
|
|
4
|
+
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean, collaboration?: CollaborationProps, onCollabUpdate?: (fullState: string, updateChunk: string) => void) => {
|
|
5
5
|
ydocRef: import('react').MutableRefObject<Y.Doc | null>;
|
|
6
6
|
persistenceRef: import('react').MutableRefObject<IndexeddbPersistence | null>;
|
|
7
7
|
syncStatus: "error" | "syncing" | "initializing" | "synced";
|
|
8
|
-
|
|
8
|
+
isSyncedRef: import('react').MutableRefObject<boolean>;
|
|
9
9
|
refreshIndexedDB: () => Promise<void>;
|
|
10
10
|
getContentSnapshot: () => import('../../persistence-utils').DSheetContentSnapshot;
|
|
11
11
|
mergeContent: (encodedState: string) => import('../../persistence-utils').DSheetContentSnapshot;
|
|
@@ -13,10 +13,6 @@ export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boo
|
|
|
13
13
|
isCollabReady: boolean;
|
|
14
14
|
isCollabSyncing: boolean;
|
|
15
15
|
terminateSession: () => void;
|
|
16
|
-
updateTitle: (args: {
|
|
17
|
-
encryptedTitle: string;
|
|
18
|
-
documentTitle: string;
|
|
19
|
-
}) => void;
|
|
20
16
|
awareness: import('y-protocols/awareness.js').Awareness | null;
|
|
21
17
|
hasCollabContentInitialised: boolean;
|
|
22
18
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { CommentAnchorMove } from '../../sheet-engine/core/settings';
|
|
2
3
|
|
|
4
|
+
export type { CommentAnchorMove };
|
|
3
5
|
export interface CommentThread {
|
|
4
6
|
id: string;
|
|
5
7
|
key: string;
|
|
@@ -12,6 +14,8 @@ export interface CommentThread {
|
|
|
12
14
|
replies: CommentReply[];
|
|
13
15
|
isResolved?: boolean;
|
|
14
16
|
isDeleted?: boolean;
|
|
17
|
+
/** IPFS/indexer hash — stable across local `comment-*` ids and on-chain uuids. */
|
|
18
|
+
contentHash?: string;
|
|
15
19
|
}
|
|
16
20
|
export interface CommentReply {
|
|
17
21
|
id: string;
|
|
@@ -41,6 +45,11 @@ export interface CommentsConfig {
|
|
|
41
45
|
commentsData: Record<string, CommentThread>;
|
|
42
46
|
onSendComment: (key: string, textareaId: string) => void;
|
|
43
47
|
onCommentAction: (action: CommentActionParams) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Called after row/column drag-drop or a cell-range move so the host can
|
|
50
|
+
* remap comment keys. Use `remapCommentAnchors` from the package.
|
|
51
|
+
*/
|
|
52
|
+
onCellPositionsChanged?: (move: CommentAnchorMove) => void;
|
|
44
53
|
userName?: string;
|
|
45
54
|
ownerAddress?: string;
|
|
46
55
|
currentUserAddress?: string;
|
|
@@ -118,6 +127,8 @@ export interface CommentCellUIProps {
|
|
|
118
127
|
dragHandler: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
119
128
|
isHover?: boolean;
|
|
120
129
|
disabled?: boolean;
|
|
130
|
+
isAuthenticated?: boolean;
|
|
131
|
+
unauthenticatedFallback?: React.ReactNode;
|
|
121
132
|
}
|
|
122
133
|
export interface CommentsContentProps {
|
|
123
134
|
sheetEditorRef: React.RefObject<SheetEditorRef>;
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -10,8 +10,7 @@ import { DSheetContentSnapshot } from '../persistence';
|
|
|
10
10
|
|
|
11
11
|
import * as Y from 'yjs';
|
|
12
12
|
export type { ThemeKey } from '../sheet-engine/core/theme';
|
|
13
|
-
export type
|
|
14
|
-
export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, } from './types/comments';
|
|
13
|
+
export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, CommentAnchorMove, } from './types/comments';
|
|
15
14
|
export { CommentAction } from './types/comments';
|
|
16
15
|
export interface SheetUpdateData {
|
|
17
16
|
data: Sheet[];
|
|
@@ -23,15 +22,6 @@ export interface EditorValues {
|
|
|
23
22
|
openPanel: (panelId: string) => void;
|
|
24
23
|
closePanel: () => void;
|
|
25
24
|
}
|
|
26
|
-
export type DSheetEditorHandle = WorkbookInstance & {
|
|
27
|
-
refreshIndexedDB: () => Promise<void>;
|
|
28
|
-
terminateSession: () => void;
|
|
29
|
-
updateCollaboratorName: (name: string) => void;
|
|
30
|
-
updateSessionTitle: (args: {
|
|
31
|
-
encryptedTitle: string;
|
|
32
|
-
documentTitle: string;
|
|
33
|
-
}) => void;
|
|
34
|
-
};
|
|
35
25
|
export interface PanelConfig {
|
|
36
26
|
id: string;
|
|
37
27
|
header: {
|
|
@@ -77,23 +67,9 @@ export interface DsheetProps {
|
|
|
77
67
|
onContentUpdate?: () => void;
|
|
78
68
|
onChange?: (updateData: SheetUpdateData, encodedUpdate?: string) => void;
|
|
79
69
|
collaboration?: CollaborationProps;
|
|
80
|
-
/** Called when local IndexedDB persistence fails. The editor and durable
|
|
81
|
-
* collaboration continue using the in-memory Y.Doc, matching dDoc. */
|
|
82
|
-
onIndexedDbError?: (error: Error) => void;
|
|
83
70
|
username?: string;
|
|
84
71
|
portalContent?: string;
|
|
85
72
|
isReadOnly?: boolean;
|
|
86
|
-
/** Permission status displayed above the toolbar. When omitted, read-only
|
|
87
|
-
* sheets retain the existing View/View-and-comment behavior. */
|
|
88
|
-
permissionMode?: DSheetPermissionMode;
|
|
89
|
-
/** Called when a read-only consumer asks to elevate to edit mode. The host
|
|
90
|
-
* owns access proof, loading, errors, and the resulting mode transition. */
|
|
91
|
-
onEnterEdit?: () => void;
|
|
92
|
-
/** Called when an invited commenter needs to authenticate before the host can
|
|
93
|
-
* recover comment capability. */
|
|
94
|
-
onSignInToComment?: () => void;
|
|
95
|
-
/** Lets the host toggle a recovered commenter between comment and view mode. */
|
|
96
|
-
onViewerModeChange?: (mode: 'comment' | 'view') => void;
|
|
97
73
|
allowSheetDownload?: boolean;
|
|
98
74
|
isTemplateOpen?: boolean;
|
|
99
75
|
selectedTemplate?: string;
|
|
@@ -104,8 +80,9 @@ export interface DsheetProps {
|
|
|
104
80
|
setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>;
|
|
105
81
|
commentsConfig?: CommentsConfig;
|
|
106
82
|
toggleTemplateSidebar?: () => void;
|
|
107
|
-
|
|
108
|
-
|
|
83
|
+
sheetEditorRef?: RefObject<WorkbookInstance & {
|
|
84
|
+
refreshIndexedDB: () => Promise<void>;
|
|
85
|
+
}>;
|
|
109
86
|
/** Override where datablock API keys are stored (default: localStorage). */
|
|
110
87
|
apiKeyStorage?: ApiKeyStorage;
|
|
111
88
|
/** Optional lifecycle events for analytics / side-effects. */
|
|
@@ -116,9 +93,6 @@ export interface DsheetProps {
|
|
|
116
93
|
* collab start/resume on 'synced' — starting before local content is fully
|
|
117
94
|
* synced is what let the RTC layer bind to a stale doc in the past. */
|
|
118
95
|
onContentSyncStatusChange?: (status: 'initializing' | 'syncing' | 'synced' | 'error') => void;
|
|
119
|
-
/** Fires once the first collaboration sync has been reconciled with the
|
|
120
|
-
* workbook, or when that reconciliation fails. */
|
|
121
|
-
onCollaborationInitializationComplete?: (result: 'ready' | 'error') => void;
|
|
122
96
|
editorStateRef?: React.MutableRefObject<{
|
|
123
97
|
refreshIndexedDB: () => Promise<void>;
|
|
124
98
|
getContentSnapshot: () => DSheetContentSnapshot;
|
|
@@ -4,17 +4,9 @@ type CommentData = object | null | undefined;
|
|
|
4
4
|
* the consumer-provided `commentData`.
|
|
5
5
|
*
|
|
6
6
|
* `ps` is a per-client, permission-gated *view overlay* — it is NOT persisted in
|
|
7
|
-
* ydoc
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* gated on the local `allowComments` permission, it must never be written back
|
|
11
|
-
* to shared ydoc state — doing so would let one viewer wipe markers for all.
|
|
12
|
-
*
|
|
13
|
-
* Handles both shapes:
|
|
14
|
-
* - Dense `sheet.data` (the live active sheet in `luckysheetfile`).
|
|
15
|
-
* - Sparse `sheet.celldata` (plain snapshots from `ySheetArrayToPlain`, and
|
|
16
|
-
* inactive sheets). `initSheetData()` converts celldata → data on activation,
|
|
17
|
-
* so `ps` set on celldata carries through.
|
|
7
|
+
* ydoc (`shouldPersistCelldataCell` ignores marker-only cells). Empty cells are
|
|
8
|
+
* `null`, so a tiny `{ ps }` object is created in the live view only so the
|
|
9
|
+
* triangle can render. Row/column drag still owns real cell data.
|
|
18
10
|
*
|
|
19
11
|
* Mutates in place and returns the same array.
|
|
20
12
|
*/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
/** Sibling share key on the same Y.Doc as the sheet array. */
|
|
3
|
+
export declare function getCommentAnchorsMapKey(dsheetId: string): string;
|
|
4
|
+
export declare function getCommentAnchorsYMap(ydoc: Y.Doc, dsheetId: string): Y.Map<string>;
|
|
5
|
+
export declare function readCommentAnchorsFromYdoc(ydoc: Y.Doc | null | undefined, dsheetId: string): Record<string, string>;
|
|
6
|
+
type CommentAnchorRecord = {
|
|
7
|
+
id?: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
contentHash?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Re-key comments by identity first (id, then contentHash), then the comment's
|
|
13
|
+
* own current cell-key. Stale cell-key aliases that now belong to another
|
|
14
|
+
* thread must not steal or duplicate it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyCommentAnchorMap<T extends CommentAnchorRecord>(commentsData: Record<string, T> | null | undefined, anchors: Record<string, string>): Record<string, T>;
|
|
17
|
+
export declare function applyYdocCommentAnchors<T extends CommentAnchorRecord>(commentsData: Record<string, T> | object | null | undefined, ydoc: Y.Doc | null | undefined, dsheetId: string): Record<string, T>;
|
|
18
|
+
/**
|
|
19
|
+
* Persist current commentId/contentHash → cell-key into ydoc so viewers/publish
|
|
20
|
+
* see the remapped positions. No-ops when the map already matches.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeCommentAnchorsToYdoc({ ydoc, dsheetId, commentsData, handleContentPortal, skipUnmapped, keyMoves, }: {
|
|
23
|
+
ydoc: Y.Doc | null | undefined;
|
|
24
|
+
dsheetId: string;
|
|
25
|
+
commentsData: Record<string, CommentAnchorRecord> | null | undefined;
|
|
26
|
+
handleContentPortal?: () => void;
|
|
27
|
+
/** When the map already has entries, skip comments that are not in it yet. */
|
|
28
|
+
skipUnmapped?: boolean;
|
|
29
|
+
/** old cell-key → new cell-key so indexer keys still resolve after remap. */
|
|
30
|
+
keyMoves?: Record<string, string>;
|
|
31
|
+
}): void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CommentAnchorMove } from '../../sheet-engine/core/settings';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* old cell-key → new cell-key, matched by comment id. Used when writing
|
|
5
|
+
* ydoc aliases so indexer keys still resolve after a remap.
|
|
6
|
+
*/
|
|
7
|
+
export declare function commentKeyMovesById<T extends {
|
|
8
|
+
id?: string;
|
|
9
|
+
key?: string;
|
|
10
|
+
}>(before: Record<string, T>, after: Record<string, T>): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Remap in-memory comment keys after a row/column drag, cell-range move,
|
|
13
|
+
* or insert/delete of rows/columns.
|
|
14
|
+
*
|
|
15
|
+
* - Row/column drag: apply the full permutation `indexMap` (no collisions).
|
|
16
|
+
* - Cells: comments in the source rectangle follow the offset; comments that
|
|
17
|
+
* only lived in the destination are detached to `WITHOUT_CELL_<id>` so they
|
|
18
|
+
* remain in the sidebar instead of colliding with the incoming thread.
|
|
19
|
+
* - Insert: comments at/after the insertion point shift by `count`.
|
|
20
|
+
* - Delete: comments on removed rows/cols are detached; later ones shift up/left.
|
|
21
|
+
*/
|
|
22
|
+
export declare function remapCommentAnchors<T extends {
|
|
23
|
+
key?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
}>(commentsData: Record<string, T>, move: CommentAnchorMove): Record<string, T>;
|
|
26
|
+
export type { CommentAnchorMove };
|