@fileverse-dev/dsheet 3.0.2-patch.7 → 3.0.2-patch.9
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/{constants-Q8nzbvQO.js → constants-Cdz6oSCq.js} +3 -5
- package/dist/constants.js +1 -1
- package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
- package/dist/editor/constants/shared-constants.d.ts +0 -2
- package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
- package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
- package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
- package/dist/editor/utils/apply-comment-markers.d.ts +22 -0
- package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
- package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
- package/dist/editor/utils/update-ydoc.d.ts +13 -3
- package/dist/executeStringFunction-DVN2p-9G.js +32625 -0
- package/dist/formula.js +1 -1
- package/dist/{index-BqJw4oqU.js → index-T7U1EYEU.js} +21436 -24333
- package/dist/index.es.js +39 -39
- package/dist/sheet-engine/core/api/cell.d.ts +0 -20
- package/dist/sheet-engine/core/api/common.d.ts +2 -1
- package/dist/sheet-engine/core/api/index.d.ts +1 -0
- package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
- package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
- package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
- package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
- package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
- package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
- package/dist/sheet-engine/core/settings.d.ts +1 -1
- package/dist/sheet-engine/core/types.d.ts +3 -0
- package/dist/sheet-engine/core/utils/active-draft-context.d.ts +4 -0
- package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
- package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
- package/dist/sheet-engine/core/utils/merge-hydrate.d.ts +15 -0
- package/dist/sheet-engine/core/utils/mirror-cell-format-ranges.d.ts +17 -0
- package/dist/sheet-engine/core/utils/range-format.d.ts +76 -0
- package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +46 -0
- package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
- package/dist/use-xlsx-import-impl-B9Uq_cFK.js +1572 -0
- package/dist/{xlsx-export-impl-BVnggmUo.js → xlsx-export-impl-0bnKq9JC.js} +1210 -1198
- package/package.json +1 -1
- package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
- package/dist/use-xlsx-import-impl-OjMoKLbj.js +0 -1537
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as s, a as t, b as o, S as r, d as l, i as
|
|
2
|
-
import {
|
|
1
|
+
import { C as s, a as t, b as o, S as r, d as l, i as d, e as n, T as i, f as c, g as S, h, j as m, k as p, l as C, n as u, o as E, p as F, q as g, s as x, t as R, u as f, v as A, w as L, x as w, z as I, A as T, B as v, D, E as M } from "./index-T7U1EYEU.js";
|
|
2
|
+
import { cm as k, cn as V, co as X, ct as z, bj as P, e as U, f as _, l as j, a as y, d2 as B, d3 as O, b2 as G, d4 as H, d5 as q, d9 as J, da as K, dc as N, D as Y, dr as Z, dR as Q, aX as W } from "./executeStringFunction-DVN2p-9G.js";
|
|
3
3
|
import { FLVURL as ee } from "@fileverse-dev/formulajs";
|
|
4
|
-
import { E as se, S as te } from "./constants-
|
|
4
|
+
import { E as se, S as te } from "./constants-Cdz6oSCq.js";
|
|
5
5
|
export {
|
|
6
6
|
s as CommentAction,
|
|
7
7
|
t as CommentCellUI,
|
|
@@ -10,50 +10,50 @@ export {
|
|
|
10
10
|
l as DSheetSkeleton,
|
|
11
11
|
se as ERROR_MESSAGES_FLAG,
|
|
12
12
|
ee as FLVURL,
|
|
13
|
-
|
|
13
|
+
d as FortuneCore,
|
|
14
14
|
te as SERVICES_API_KEY,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
n as SupportedChain,
|
|
16
|
+
i as TEMPLATES,
|
|
17
|
+
c as api,
|
|
18
|
+
k as clearColumnsCellsFormat,
|
|
19
|
+
S as clearFilter,
|
|
20
|
+
V as clearRowsCellsFormat,
|
|
21
|
+
X as clearSelectedCellFormat,
|
|
22
22
|
h as createFilter,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
z as deleteRowCol,
|
|
24
|
+
P as deleteSelectedCellText,
|
|
25
25
|
m as describeMatchedShortcut,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
U as executeStringFunction,
|
|
27
|
+
_ as formulaResponseUiSync,
|
|
28
|
+
j as getFlowdata,
|
|
29
29
|
p as getRemoveDuplicatesErrorMessage,
|
|
30
30
|
C as getRemoveDuplicatesPreview,
|
|
31
|
-
|
|
31
|
+
y as getSheetIndex,
|
|
32
32
|
u as handleCSVUpload,
|
|
33
33
|
E as handleCopy,
|
|
34
34
|
F as handleExportToCSV,
|
|
35
35
|
g as handleExportToJSON,
|
|
36
36
|
x as handleExportToXLSX,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
B as handleFreeze,
|
|
38
|
+
O as handleHorizontalAlign,
|
|
39
|
+
G as handleLink,
|
|
40
|
+
H as handleMerge,
|
|
41
|
+
R as handlePasteByClick,
|
|
42
|
+
q as handleSort,
|
|
43
|
+
J as handleTextSize,
|
|
44
|
+
K as handleVerticalAlign,
|
|
45
|
+
f as importSpreadsheetFile,
|
|
46
|
+
N as insertRowCol,
|
|
47
|
+
A as isBrowserZoomShortcut,
|
|
48
|
+
L as isFormulaListShortcut,
|
|
49
|
+
w as isOpenShortcutsModalShortcut,
|
|
50
|
+
Y as jfrefreshgrid,
|
|
51
|
+
Z as loadLocale,
|
|
52
|
+
I as removeActiveImage,
|
|
53
|
+
T as removeDuplicates,
|
|
54
|
+
v as showImgChooser,
|
|
55
|
+
Q as toolbarItemClickHandler,
|
|
56
|
+
W as updateFormat,
|
|
57
|
+
D as useEnsStatus,
|
|
58
|
+
M as useXLSXImport
|
|
59
59
|
};
|
|
@@ -6,26 +6,6 @@ export declare function getCellValue(ctx: Context, row: number, column: number,
|
|
|
6
6
|
type?: keyof Cell;
|
|
7
7
|
}): any;
|
|
8
8
|
export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
|
|
9
|
-
/**
|
|
10
|
-
* Apply a cell value coming from a remote RTC peer, verbatim.
|
|
11
|
-
*
|
|
12
|
-
* This differs from `setCellValue` in two important ways and must be used for
|
|
13
|
-
* every Yjs-driven remote apply:
|
|
14
|
-
*
|
|
15
|
-
* 1. It NEVER runs the formula engine and NEVER fires the local-edit hooks
|
|
16
|
-
* (`onLocalCellEdit` / `afterUpdateCell`). The peer already computed the
|
|
17
|
-
* value, so we use the synced `v`/`m`/`f` as-is. This avoids both
|
|
18
|
-
* recomputation divergence and an update loop back into Yjs.
|
|
19
|
-
*
|
|
20
|
-
* 2. It PRESERVES the formula calc list. The regular `setCellValue` object
|
|
21
|
-
* branch calls `delFunctionGroup`, which removes the cell from `calcChain`
|
|
22
|
-
* and strips its dependency edges. Because `execFunctionGroup` walks
|
|
23
|
-
* `calcChain` to decide what to recompute, dropping a formula cell there
|
|
24
|
-
* permanently breaks its reactivity on that client (even after RTC stops).
|
|
25
|
-
* Here we instead keep formula cells registered via
|
|
26
|
-
* `insertUpdateFunctionGroup`, so they stay reactive to future local edits
|
|
27
|
-
* on both owner and peer.
|
|
28
|
-
*/
|
|
29
9
|
export declare function applyRemoteCellValue(ctx: Context, row: number, column: number, value: any, options?: CommonOptions): void;
|
|
30
10
|
export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
|
|
31
11
|
export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Context } from '../context';
|
|
2
2
|
import { CellMatrix, CellWithRowAndCol, Sheet } from '../types';
|
|
3
|
+
import { CellFormatRange } from '../utils/range-format';
|
|
3
4
|
|
|
4
5
|
export type CommonOptions = {
|
|
5
6
|
index?: number;
|
|
6
7
|
id?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare const dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
9
|
-
export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
10
|
+
export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[], merge?: Record<string, any> | null) => CellMatrix | null;
|
|
10
11
|
export declare function getSheet(ctx: Context, options?: CommonOptions): Sheet;
|
|
11
12
|
export declare function getSheetWithLatestCelldata(ctx: Context, options?: CommonOptions): {
|
|
12
13
|
celldata: CellWithRowAndCol[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from '../context';
|
|
2
|
+
|
|
3
|
+
/** Drop cached dense-sheet set (e.g. after structural workbook changes). */
|
|
4
|
+
export declare function invalidateSheetsRequiredDenseCache(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Sheets that must keep dense `data` while `activeSheetId` is active:
|
|
7
|
+
* the active tab, tabs its formulas read, and tabs with formulas that read it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSheetsRequiredDense(ctx: Context, activeSheetId: string): Set<string>;
|
|
10
|
+
/** Sheets the formula worker needs dense — active refs plus any tab with formulas. */
|
|
11
|
+
export declare function getSheetsNeededForWorkerSnapshot(ctx: Context): Set<string>;
|
|
12
|
+
export declare function demoteSheetToCelldata(ctx: Context, sheetId: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* On tab switch: persist outgoing config, demote tabs not needed dense,
|
|
15
|
+
* hydrate active tab + cross-sheet references.
|
|
16
|
+
*/
|
|
17
|
+
export declare function syncAndDemoteInactiveFlowdata(ctx: Context, activeSheetId: string, previousSheetId: string | null): Set<string>;
|
|
@@ -5,6 +5,11 @@ import { CellMatrix, Sheet } from '../types';
|
|
|
5
5
|
export declare function getAllSheets(ctx: Context): Sheet[];
|
|
6
6
|
export { getSheet };
|
|
7
7
|
export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
|
|
8
|
+
/** Build dense `data` from sparse `celldata` when a sheet is activated or referenced. */
|
|
9
|
+
export declare function ensureSheetFlowdata(ctx: Context, options?: {
|
|
10
|
+
index?: number;
|
|
11
|
+
id?: string;
|
|
12
|
+
}): CellMatrix | null;
|
|
8
13
|
export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
9
14
|
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
10
15
|
export declare function copySheet(ctx: Context, sheetId: string): void;
|
|
@@ -2,6 +2,7 @@ import { Context } from '../context';
|
|
|
2
2
|
import { SnapshotEvalInput, SnapshotEvalOutput, SnapshotFormulaCell, evalFormulasInSnapshot } from './formula-snapshot-eval';
|
|
3
3
|
import { FORMULA_WORKER_CHUNK_SIZE } from './formula-async-eval';
|
|
4
4
|
|
|
5
|
+
export declare function invalidateFormulaWorkerSnapshot(): void;
|
|
5
6
|
export declare function buildSnapshotEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): SnapshotEvalInput;
|
|
6
7
|
export declare function buildWorkerEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): Omit<SnapshotEvalInput, 'sheets'>;
|
|
7
8
|
export declare function initFormulaWorkerSnapshot(ctx: Context, snapshotKey: string): boolean;
|
|
@@ -3,5 +3,9 @@ import { Context } from '../context';
|
|
|
3
3
|
/**
|
|
4
4
|
* Defer sheet-level metadata hooks until after React applies Immer updates, so
|
|
5
5
|
* getSheet() / Yjs diff see dataVerification, CF rules, and hyperlinks from paste/cut.
|
|
6
|
+
*
|
|
7
|
+
* Capture the hook fns themselves (not `ctx.hooks`): paste runs inside produce,
|
|
8
|
+
* and reading a draft `hooks` proxy after it is revoked throws
|
|
9
|
+
* "Cannot perform 'get' on a proxy that has been revoked".
|
|
6
10
|
*/
|
|
7
11
|
export declare function scheduleSheetMetadataSyncHooks(ctx: Context): void;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { Context } from '../context';
|
|
2
2
|
import { Settings } from '../settings';
|
|
3
|
-
import { CellMatrix, Sheet } from '../types';
|
|
3
|
+
import { CellMatrix, Sheet, SheetConfig } from '../types';
|
|
4
|
+
import { CellFormatRange } from '../utils/range-format';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Persist active ctx.config onto ONE sheet file only.
|
|
8
|
+
* If Immer wrote keys (e.g. cellFormatRanges) on file.config but not ctx.config,
|
|
9
|
+
* keep those instead of wiping them with a blind replace.
|
|
10
|
+
* Never touches other sheets.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assignActiveConfigToSheetFile(file: Sheet, activeConfig: SheetConfig | undefined): void;
|
|
13
|
+
/**
|
|
14
|
+
* Promote format-only cells in a rectangle into cellFormatRanges.
|
|
15
|
+
* Scans only [r1..r2]×[c1..c2]. Returns new ranges if anything changed.
|
|
16
|
+
*
|
|
17
|
+
* Writes through luckysheetfile[i].config (same as toolbar) so Immer undo
|
|
18
|
+
* history tracks the change and peers get the reverse via afterConfigChanges.
|
|
19
|
+
*/
|
|
20
|
+
export declare function syncFormatOnlyRectIntoRanges(ctx: Context, cfg: SheetConfig | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): CellFormatRange[] | null;
|
|
5
21
|
export declare function storeSheetParamALL(ctx: Context): void;
|
|
6
22
|
export declare function changeSheet(ctx: Context, id: string, isPivotInitial?: boolean, isNewSheet?: boolean, isCopySheet?: boolean): void;
|
|
7
23
|
export declare function addSheet(ctx: Context, settings?: Required<Settings>, newSheetID?: string | undefined, // if action is from websocket, there will be a new sheetID
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function isTransparentBorderColor(color: string): boolean;
|
|
2
|
+
export declare function isMeaningfulBorderSide(side: {
|
|
3
|
+
style?: number;
|
|
4
|
+
color?: string;
|
|
5
|
+
} | undefined): boolean;
|
|
6
|
+
export declare function filterMeaningfulBorderSides(sides: {
|
|
7
|
+
l?: {
|
|
8
|
+
style?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
};
|
|
11
|
+
r?: {
|
|
12
|
+
style?: number;
|
|
13
|
+
color?: string;
|
|
14
|
+
};
|
|
15
|
+
t?: {
|
|
16
|
+
style?: number;
|
|
17
|
+
color?: string;
|
|
18
|
+
};
|
|
19
|
+
b?: {
|
|
20
|
+
style?: number;
|
|
21
|
+
color?: string;
|
|
22
|
+
};
|
|
23
|
+
}): typeof sides;
|
|
@@ -23,7 +23,7 @@ export type Hooks = {
|
|
|
23
23
|
cellDataChange?: () => void;
|
|
24
24
|
hyperlinkChange?: () => void;
|
|
25
25
|
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
26
|
-
updateAllCell?: (sheetId: string) => void;
|
|
26
|
+
updateAllCell?: (sheetId: string, caller?: string) => void;
|
|
27
27
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
28
28
|
/** Clears RTC remote-apply lock so local edits can run data-block formulas. */
|
|
29
29
|
onLocalCellEdit?: () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Patch as ImmerPatch } from 'immer';
|
|
2
2
|
import { PatchOptions } from './utils';
|
|
3
|
+
import { CellFormatRange } from './utils/range-format';
|
|
3
4
|
|
|
4
5
|
export type Op = {
|
|
5
6
|
op: 'replace' | 'remove' | 'add' | 'insertRowCol' | 'deleteRowCol' | 'addSheet' | 'deleteSheet';
|
|
@@ -140,6 +141,8 @@ export type SheetConfig = {
|
|
|
140
141
|
customHeight?: Record<string, number>;
|
|
141
142
|
customWidth?: Record<string, number>;
|
|
142
143
|
borderInfo?: any[];
|
|
144
|
+
/** Range-level cell formatting for empty cells (toolbar bulk format). */
|
|
145
|
+
cellFormatRanges?: CellFormatRange[];
|
|
143
146
|
authority?: any;
|
|
144
147
|
rowReadOnly?: Record<number, number>;
|
|
145
148
|
colReadOnly?: Record<number, number>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from '../context';
|
|
2
|
+
|
|
3
|
+
export type BorderSelection = {
|
|
4
|
+
row: [number, number];
|
|
5
|
+
column: [number, number];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Remap borderInfo after a row/column reorder (header drag).
|
|
9
|
+
* Uses the same old→new index map as remapCellFormatRanges.
|
|
10
|
+
* O(border entries × span) — only runs on drag drop, not per-frame.
|
|
11
|
+
*/
|
|
12
|
+
export declare function remapBorderInfo(borderInfo: any[] | undefined, axis: 'row' | 'column', indexMap: Record<number, number>): any[];
|
|
13
|
+
/** Remove border entries overlapping a single selection (cell + range types). */
|
|
14
|
+
export declare function removeBorderInfoForSelection(borderInfo: any[], rowSt: number, rowEd: number, colSt: number, colEd: number): any[];
|
|
15
|
+
export declare function removeBorderInfoInSelections(borderInfo: any[] | undefined, selections: BorderSelection[]): any[];
|
|
16
|
+
export declare function syncBorderInfoToYdoc(ctx: Context, borderInfo: any[]): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Cell } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare const CELL_FORMAT_ATTRS: readonly ["tb", "ht", "vt", "tr", "fs", "ff", "fc", "bl", "it", "un", "cl", "bg", "ct"];
|
|
4
|
+
export type CellFormatAttr = (typeof CELL_FORMAT_ATTRS)[number];
|
|
5
|
+
export declare function hasCellMeaningfulContent(cell: Cell | string | number | boolean | null | undefined): boolean;
|
|
6
|
+
export declare function isFormatOnlyEmptyCell(cell: Cell | string | number | boolean | null | undefined): boolean;
|
|
7
|
+
/** Pull only present format attrs from a format-only empty cell (cheap, no clone). */
|
|
8
|
+
export declare function extractCellFormatAttrs(cell: Cell | string | number | boolean | null | undefined): Partial<Record<CellFormatAttr, unknown>> | null;
|
|
9
|
+
export declare function shouldPersistCelldataCell(cell: Cell | string | number | boolean | null | undefined): boolean;
|
|
10
|
+
export declare function celldataEntryEqual(existing: unknown, next: unknown): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CellMatrix } from '../types';
|
|
2
|
+
|
|
3
|
+
type MergeEntry = {
|
|
4
|
+
r?: number;
|
|
5
|
+
c?: number;
|
|
6
|
+
rs?: number;
|
|
7
|
+
cs?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Rebuild merge anchor + shadow `mc` refs on dense data from config.merge.
|
|
11
|
+
* Cheap: O(merge area), not O(grid). Safe to call on every hydrate — idempotent.
|
|
12
|
+
* Covers docs whose shadow cells were dropped by earlier compaction.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyMergeConfigToData(data: CellMatrix | null | undefined, merge: Record<string, MergeEntry> | null | undefined): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from '../context';
|
|
2
|
+
import { CellFormatRange } from './range-format';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keep workbook config.cellFormatRanges aligned with a ydoc commit.
|
|
6
|
+
* Cheap no-op when already equal. Mutates ctx in place (immer draft or produce).
|
|
7
|
+
*/
|
|
8
|
+
export declare function mirrorCellFormatRangesIntoContext(ctx: Context, sheetId: string, ranges: CellFormatRange[]): boolean;
|
|
9
|
+
export type CellFormatRangesCommit = {
|
|
10
|
+
sheetId: string;
|
|
11
|
+
ranges: CellFormatRange[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Apply ydoc-committed ranges into the live workbook.
|
|
15
|
+
* Prefers the in-flight immer draft (same edit); falls back to a produce() update.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyCellFormatRangesCommits(commits: CellFormatRangesCommit[], setContext?: ((updater: (prev: Context) => Context) => void) | null): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Cell, CellMatrix, CellWithRowAndCol, Sheet } from '../types';
|
|
2
|
+
|
|
3
|
+
export type CellFormatRange = {
|
|
4
|
+
row: [number, number];
|
|
5
|
+
column: [number, number];
|
|
6
|
+
tb?: string;
|
|
7
|
+
ht?: number | string;
|
|
8
|
+
vt?: number | string;
|
|
9
|
+
tr?: string;
|
|
10
|
+
fs?: number;
|
|
11
|
+
ff?: number | string;
|
|
12
|
+
fc?: string;
|
|
13
|
+
bl?: number;
|
|
14
|
+
it?: number;
|
|
15
|
+
un?: number;
|
|
16
|
+
cl?: number;
|
|
17
|
+
bg?: string;
|
|
18
|
+
ct?: Cell["ct"];
|
|
19
|
+
};
|
|
20
|
+
declare function rangesEqual(a: CellFormatRange[] | undefined, b: CellFormatRange[] | undefined): boolean;
|
|
21
|
+
/** Merge overlapping/adjacent ranges that carry identical format attrs. */
|
|
22
|
+
export declare function normalizeCellFormatRanges(ranges: CellFormatRange[] | undefined): CellFormatRange[];
|
|
23
|
+
/**
|
|
24
|
+
* Remap format ranges after a row or column permutation, such as header
|
|
25
|
+
* drag-and-drop. A contiguous source range can become multiple rectangles
|
|
26
|
+
* when the moved indices are no longer contiguous.
|
|
27
|
+
*/
|
|
28
|
+
export declare function remapCellFormatRanges(ranges: CellFormatRange[] | undefined, axis: "row" | "column", indexMap: Record<number, number>): CellFormatRange[];
|
|
29
|
+
/**
|
|
30
|
+
* Move format ranges with a cut-and-paste cell block move. Formatting in both
|
|
31
|
+
* the old source and the overwritten destination is cleared; only the source
|
|
32
|
+
* intersection is translated to the target rectangle.
|
|
33
|
+
*/
|
|
34
|
+
export declare function moveCellFormatRanges(ranges: CellFormatRange[] | undefined, source: Pick<CellFormatRange, "row" | "column">, target: Pick<CellFormatRange, "row" | "column">): CellFormatRange[];
|
|
35
|
+
export declare function getCellFormatRangeGridBounds(ranges: CellFormatRange[] | undefined): {
|
|
36
|
+
maxRow: number;
|
|
37
|
+
maxCol: number;
|
|
38
|
+
} | null;
|
|
39
|
+
export declare function upsertCellFormatRange(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number, attrs: Partial<CellFormatRange>): {
|
|
40
|
+
ranges: CellFormatRange[];
|
|
41
|
+
changed: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* When a cell loses meaningful content but keeps style, put that style back
|
|
45
|
+
* into cellFormatRanges as a 1x1 (normalize merges with neighbours).
|
|
46
|
+
*/
|
|
47
|
+
export declare function migrateFormatOnlyCellIntoRanges(ranges: CellFormatRange[] | undefined, r: number, c: number, cell: Cell | string | number | boolean | null | undefined): {
|
|
48
|
+
ranges: CellFormatRange[];
|
|
49
|
+
changed: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Scan a dense-data rectangle and move any format-only cells into
|
|
53
|
+
* cellFormatRanges. Adjacent identical styles merge via normalize.
|
|
54
|
+
*/
|
|
55
|
+
export declare function migrateFormatOnlyCellsFromData(ranges: CellFormatRange[] | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): {
|
|
56
|
+
ranges: CellFormatRange[];
|
|
57
|
+
changed: boolean;
|
|
58
|
+
};
|
|
59
|
+
export declare function punchHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, r: number, c: number): CellFormatRange[];
|
|
60
|
+
/**
|
|
61
|
+
* Remove format coverage for a whole rectangle in O(ranges), not O(area × ranges).
|
|
62
|
+
* Prefer this over punching cell-by-cell (select-all clear must stay cheap).
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeCellFormatRangesInRect(ranges: CellFormatRange[] | undefined, row: [number, number], column: [number, number]): CellFormatRange[];
|
|
65
|
+
export declare function punchRectHoleInCellFormatRanges(ranges: CellFormatRange[] | undefined, rowSt: number, rowEd: number, colSt: number, colEd: number): CellFormatRange[];
|
|
66
|
+
export declare function shiftCellFormatRangesOnInsert(ranges: CellFormatRange[] | undefined, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom"): CellFormatRange[];
|
|
67
|
+
export declare function shiftCellFormatRangesOnDelete(ranges: CellFormatRange[] | undefined, type: "row" | "column", start: number, end: number): CellFormatRange[];
|
|
68
|
+
export declare function applyCellFormatRangesToData(data: CellMatrix | null | undefined, ranges: CellFormatRange[] | undefined): void;
|
|
69
|
+
export declare function buildSheetDataMatrixForExport(sheet: {
|
|
70
|
+
data?: CellMatrix | null;
|
|
71
|
+
celldata?: CellWithRowAndCol[];
|
|
72
|
+
row?: number;
|
|
73
|
+
column?: number;
|
|
74
|
+
config?: Sheet["config"];
|
|
75
|
+
}): CellMatrix;
|
|
76
|
+
export { rangesEqual };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Context } from '../context';
|
|
2
|
+
import { Cell, CellWithRowAndCol } from '../types';
|
|
3
|
+
|
|
4
|
+
export type CelldataYdocChange = {
|
|
5
|
+
sheetId: string;
|
|
6
|
+
path: string[];
|
|
7
|
+
key?: string;
|
|
8
|
+
value: any;
|
|
9
|
+
type?: 'update' | 'delete';
|
|
10
|
+
};
|
|
11
|
+
/** Cheap equality before deep compare — hot path for structural diffs. */
|
|
12
|
+
export declare function cellsEqualForYdocPersist(before: unknown, after: unknown): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Snapshot persisted cells in a range.
|
|
15
|
+
* Prefer sparse `celldata` when provided — O(populated cells), not O(range area).
|
|
16
|
+
*/
|
|
17
|
+
export declare function snapshotPersistedCelldataInRange(data: unknown[][] | null | undefined, r1: number, r2: number, c1: number, c2: number, celldata?: CellWithRowAndCol[] | null): Map<string, Cell | string | number | boolean>;
|
|
18
|
+
export declare function appendCelldataDiffChange(changes: CelldataYdocChange[], sheetId: string, r: number, c: number, cell: unknown, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
|
|
19
|
+
export declare function buildCelldataChangesForRange(sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): CelldataYdocChange[];
|
|
20
|
+
export declare function emitCelldataRangeDiffToYdoc(ctx: Context, sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
|
|
21
|
+
/**
|
|
22
|
+
* After delete row/col, emit deletes for persisted keys that now sit past the
|
|
23
|
+
* shrunken grid. Range diffs only visit coordinates still inside `data`, so
|
|
24
|
+
* tail keys would otherwise resurrect on peers/reload.
|
|
25
|
+
*/
|
|
26
|
+
export declare function emitCelldataDeletesBeyondGrid(ctx: Context, sheetId: string, beforePersisted: Map<string, Cell | string | number | boolean> | undefined, rowCount: number, colCount: number): void;
|
|
27
|
+
export type MergeBounds = {
|
|
28
|
+
minR: number;
|
|
29
|
+
minC: number;
|
|
30
|
+
maxR: number;
|
|
31
|
+
maxC: number;
|
|
32
|
+
};
|
|
33
|
+
/** Disturbed range for insert row/col — snapshot only rows/cols that may shift. */
|
|
34
|
+
export declare function getInsertRowColSnapshotBounds(type: 'row' | 'column', index: number, direction: 'lefttop' | 'rightbottom', rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
|
|
35
|
+
r1: number;
|
|
36
|
+
r2: number;
|
|
37
|
+
c1: number;
|
|
38
|
+
c2: number;
|
|
39
|
+
};
|
|
40
|
+
/** Disturbed range for delete row/col — from deletion point to sheet edge. */
|
|
41
|
+
export declare function getDeleteRowColSnapshotBounds(type: 'row' | 'column', start: number, rowCount: number, colCount: number, mergeBounds: MergeBounds | null): {
|
|
42
|
+
r1: number;
|
|
43
|
+
r2: number;
|
|
44
|
+
c1: number;
|
|
45
|
+
c2: number;
|
|
46
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CellFormatRange } from '../../../core/utils/range-format';
|
|
1
2
|
import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from '../../../core';
|
|
2
3
|
import { getCryptoPrice } from '../../utils/cryptoApi';
|
|
3
4
|
import { SetContextOptions } from '../../context';
|
|
@@ -148,6 +149,12 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
148
149
|
} | null;
|
|
149
150
|
}, options?: api.CommonOptions) => void;
|
|
150
151
|
setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
|
|
152
|
+
/** Merge keys into a map-backed sheet field without replacing the whole map. */
|
|
153
|
+
patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
|
|
154
|
+
/** Merge sub-keys into sheet.config without replacing the whole config object. */
|
|
155
|
+
setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
|
|
156
|
+
deleteKeys?: string[];
|
|
157
|
+
}) => void;
|
|
151
158
|
setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
|
|
152
159
|
scroll: (options: {
|
|
153
160
|
scrollLeft?: number;
|
|
@@ -166,7 +173,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
166
173
|
calculateSubSheetFormula: (id: string) => void;
|
|
167
174
|
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
|
|
168
175
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
169
|
-
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
176
|
+
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[], merge?: Record<string, any> | null) => CellMatrix | null;
|
|
170
177
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
171
178
|
getLocaleContext: () => any;
|
|
172
179
|
getWorkbookContext: () => Context;
|
|
@@ -150,6 +150,10 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
150
150
|
} | null;
|
|
151
151
|
}, options?: api.CommonOptions) => void;
|
|
152
152
|
setSheetMapField: (field: string, value: Record<string, any> | null | undefined, options?: api.CommonOptions) => void;
|
|
153
|
+
patchSheetMapField: (field: string, updates: Record<string, any>, deleteKeys?: string[], options?: api.CommonOptions) => void;
|
|
154
|
+
setSheetConfigFields: (partial: Record<string, any>, options?: api.CommonOptions & {
|
|
155
|
+
deleteKeys?: string[];
|
|
156
|
+
}) => void;
|
|
153
157
|
setSheetConditionFormatRules: (rules: any[], options?: api.CommonOptions) => void;
|
|
154
158
|
scroll: (options: {
|
|
155
159
|
scrollLeft?: number;
|
|
@@ -168,7 +172,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
168
172
|
calculateSubSheetFormula: (id: string) => void;
|
|
169
173
|
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
|
|
170
174
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
171
|
-
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
175
|
+
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: import('../../../core/utils/range-format').CellFormatRange[], merge?: Record<string, any> | null) => CellMatrix | null;
|
|
172
176
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
173
177
|
getLocaleContext: () => any;
|
|
174
178
|
getWorkbookContext: () => Context;
|