@visactor/vtable-plugins 1.23.3-alpha.0 → 1.24.0
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/cjs/auto-fill/index.d.ts +3 -2
- package/cjs/auto-fill/index.js.map +1 -1
- package/cjs/auto-fill/series-converters.d.ts +3 -3
- package/cjs/auto-fill/series-converters.js.map +1 -1
- package/cjs/contextmenu/handle-menu-helper.js +1 -2
- package/cjs/contextmenu/index.js +2 -1
- package/cjs/excel-edit-cell-keyboard.d.ts +4 -2
- package/cjs/excel-edit-cell-keyboard.js.map +1 -1
- package/cjs/filter/filter-engine.js +5 -1
- package/cjs/filter/filter-engine.js.map +1 -1
- package/cjs/filter/filter-state-manager.d.ts +6 -1
- package/cjs/filter/filter-state-manager.js +81 -0
- package/cjs/filter/filter-state-manager.js.map +1 -1
- package/cjs/filter/filter-toolbar.d.ts +2 -0
- package/cjs/filter/filter-toolbar.js +23 -3
- package/cjs/filter/filter-toolbar.js.map +1 -1
- package/cjs/filter/filter.d.ts +4 -2
- package/cjs/filter/filter.js +32 -10
- package/cjs/filter/filter.js.map +1 -1
- package/cjs/filter/index.js +2 -1
- package/cjs/filter/types.d.ts +3 -0
- package/cjs/filter/types.js.map +1 -1
- package/cjs/filter/value-filter.js +11 -41
- package/cjs/filter/value-filter.js.map +1 -1
- package/cjs/filter/value-filter.syncSingleStateFromTableData.backup.d.ts +46 -0
- package/cjs/filter/value-filter.syncSingleStateFromTableData.backup.js +247 -0
- package/cjs/filter/value-filter.syncSingleStateFromTableData.backup.js.map +1 -0
- package/cjs/history/formula.d.ts +40 -0
- package/cjs/history/formula.js +112 -0
- package/cjs/history/formula.js.map +1 -0
- package/cjs/history/history-plugin.d.ts +88 -0
- package/cjs/history/history-plugin.js +699 -0
- package/cjs/history/history-plugin.js.map +1 -0
- package/cjs/history/index.d.ts +3 -0
- package/cjs/history/index.js +24 -0
- package/cjs/history/index.js.map +1 -0
- package/cjs/history/replay.d.ts +9 -0
- package/cjs/history/replay.js +268 -0
- package/cjs/history/replay.js.map +1 -0
- package/cjs/history/sheet-key.d.ts +9 -0
- package/cjs/history/sheet-key.js +44 -0
- package/cjs/history/sheet-key.js.map +1 -0
- package/cjs/history/snapshot.d.ts +15 -0
- package/cjs/history/snapshot.js +78 -0
- package/cjs/history/snapshot.js.map +1 -0
- package/cjs/history/types.d.ts +105 -0
- package/cjs/history/types.js +6 -0
- package/cjs/history/types.js.map +1 -0
- package/cjs/history-plugin.d.ts +1 -0
- package/cjs/history-plugin.js +21 -0
- package/cjs/history-plugin.js.map +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/master-detail-plugin/checkbox.js +1 -1
- package/cjs/master-detail-plugin/config.js +1 -1
- package/cjs/master-detail-plugin/core.js +1 -1
- package/cjs/master-detail-plugin/events.js +1 -1
- package/cjs/master-detail-plugin/types.d.ts +1 -1
- package/cjs/master-detail-plugin/types.js.map +1 -1
- package/cjs/rotate-table.d.ts +7 -6
- package/cjs/rotate-table.js +12 -13
- package/cjs/rotate-table.js.map +1 -1
- package/cjs/row-series.js +2 -1
- package/cjs/table-export/util/pagination.js.map +1 -1
- package/cjs/wps-fill-handle.d.ts +4 -2
- package/cjs/wps-fill-handle.js.map +1 -1
- package/dist/vtable-plugins.js +1903 -81
- package/dist/vtable-plugins.min.js +3 -3
- package/es/auto-fill/index.d.ts +3 -2
- package/es/auto-fill/index.js.map +1 -1
- package/es/auto-fill/series-converters.d.ts +3 -3
- package/es/auto-fill/series-converters.js.map +1 -1
- package/es/contextmenu/handle-menu-helper.js +1 -2
- package/es/contextmenu/index.js +2 -1
- package/es/excel-edit-cell-keyboard.d.ts +4 -2
- package/es/excel-edit-cell-keyboard.js.map +1 -1
- package/es/filter/filter-engine.js +5 -1
- package/es/filter/filter-engine.js.map +1 -1
- package/es/filter/filter-state-manager.d.ts +6 -1
- package/es/filter/filter-state-manager.js +81 -0
- package/es/filter/filter-state-manager.js.map +1 -1
- package/es/filter/filter-toolbar.d.ts +2 -0
- package/es/filter/filter-toolbar.js +23 -3
- package/es/filter/filter-toolbar.js.map +1 -1
- package/es/filter/filter.d.ts +4 -2
- package/es/filter/filter.js +32 -10
- package/es/filter/filter.js.map +1 -1
- package/es/filter/index.js +2 -1
- package/es/filter/types.d.ts +3 -0
- package/es/filter/types.js.map +1 -1
- package/es/filter/value-filter.js +12 -41
- package/es/filter/value-filter.js.map +1 -1
- package/es/filter/value-filter.syncSingleStateFromTableData.backup.d.ts +46 -0
- package/es/filter/value-filter.syncSingleStateFromTableData.backup.js +242 -0
- package/es/filter/value-filter.syncSingleStateFromTableData.backup.js.map +1 -0
- package/es/history/formula.d.ts +40 -0
- package/es/history/formula.js +103 -0
- package/es/history/formula.js.map +1 -0
- package/es/history/history-plugin.d.ts +88 -0
- package/es/history/history-plugin.js +698 -0
- package/es/history/history-plugin.js.map +1 -0
- package/es/history/index.d.ts +3 -0
- package/es/history/index.js +4 -0
- package/es/history/index.js.map +1 -0
- package/es/history/replay.d.ts +9 -0
- package/es/history/replay.js +260 -0
- package/es/history/replay.js.map +1 -0
- package/es/history/sheet-key.d.ts +9 -0
- package/es/history/sheet-key.js +38 -0
- package/es/history/sheet-key.js.map +1 -0
- package/es/history/snapshot.d.ts +15 -0
- package/es/history/snapshot.js +71 -0
- package/es/history/snapshot.js.map +1 -0
- package/es/history/types.d.ts +105 -0
- package/es/history/types.js +2 -0
- package/es/history/types.js.map +1 -0
- package/es/history-plugin.d.ts +1 -0
- package/es/history-plugin.js +2 -0
- package/es/history-plugin.js.map +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/master-detail-plugin/checkbox.js +1 -1
- package/es/master-detail-plugin/config.js +1 -1
- package/es/master-detail-plugin/core.js +1 -1
- package/es/master-detail-plugin/events.js +1 -1
- package/es/master-detail-plugin/types.d.ts +1 -1
- package/es/master-detail-plugin/types.js.map +1 -1
- package/es/rotate-table.d.ts +7 -6
- package/es/rotate-table.js +2 -3
- package/es/rotate-table.js.map +1 -1
- package/es/row-series.js +2 -1
- package/es/table-export/util/pagination.js.map +1 -1
- package/es/wps-fill-handle.d.ts +4 -2
- package/es/wps-fill-handle.js.map +1 -1
- package/package.json +10 -8
- package/cjs/auto-fill/__tests__/formula-integration.test.d.ts +0 -23
- package/cjs/auto-fill/__tests__/formula-integration.test.js +0 -61
- package/cjs/auto-fill/__tests__/formula-integration.test.js.map +0 -1
- package/es/auto-fill/__tests__/formula-integration.test.d.ts +0 -23
- package/es/auto-fill/__tests__/formula-integration.test.js +0 -54
- package/es/auto-fill/__tests__/formula-integration.test.js.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export function makeCellKey(sheetKey, row, col) {
|
|
2
|
+
return `${sheetKey}:${row}:${col}`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function parseA1Notation(a1) {
|
|
6
|
+
const match = a1.match(/^([A-Z]+)([0-9]+)$/i);
|
|
7
|
+
if (!match) return null;
|
|
8
|
+
const letters = match[1].toUpperCase(), rowNumber = parseInt(match[2], 10);
|
|
9
|
+
if (!rowNumber || rowNumber < 1) return null;
|
|
10
|
+
let col = 0;
|
|
11
|
+
for (let i = 0; i < letters.length; i++) col = 26 * col + (letters.charCodeAt(i) - 64);
|
|
12
|
+
return {
|
|
13
|
+
row: rowNumber - 1,
|
|
14
|
+
col: col - 1
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function captureCellPreChangeContent(args) {
|
|
19
|
+
const {sheetKey: sheetKey, row: row, col: col, currentValue: currentValue, formulaManager: formulaManager, store: store} = args;
|
|
20
|
+
if (!sheetKey) return;
|
|
21
|
+
const cellKey = makeCellKey(sheetKey, row, col);
|
|
22
|
+
if (null == formulaManager ? void 0 : formulaManager.getCellFormula) try {
|
|
23
|
+
const oldFormula = formulaManager.getCellFormula({
|
|
24
|
+
sheet: sheetKey,
|
|
25
|
+
row: row,
|
|
26
|
+
col: col
|
|
27
|
+
});
|
|
28
|
+
if (oldFormula) {
|
|
29
|
+
const normalized = "string" != typeof oldFormula || oldFormula.startsWith("=") ? oldFormula : `=${oldFormula}`;
|
|
30
|
+
return void store.set(cellKey, normalized);
|
|
31
|
+
}
|
|
32
|
+
} catch (_a) {}
|
|
33
|
+
store.set(cellKey, null == currentValue ? "" : currentValue);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function popCellPreChangeContent(args) {
|
|
37
|
+
const {sheetKey: sheetKey, row: row, col: col, fallbackOldContent: fallbackOldContent, store: store} = args;
|
|
38
|
+
if (!sheetKey) return fallbackOldContent;
|
|
39
|
+
const cellKey = makeCellKey(sheetKey, row, col), oldContent = store.get(cellKey);
|
|
40
|
+
return store.delete(cellKey), void 0 !== oldContent ? oldContent : fallbackOldContent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function applyCellContent(args) {
|
|
44
|
+
const {table: table, sheetKey: sheetKey, row: row, col: col, content: content, formulaManager: formulaManager} = args;
|
|
45
|
+
if (sheetKey && (null == formulaManager ? void 0 : formulaManager.setCellContent) && (null == formulaManager ? void 0 : formulaManager.getCellValue)) {
|
|
46
|
+
try {
|
|
47
|
+
formulaManager.setCellContent({
|
|
48
|
+
sheet: sheetKey,
|
|
49
|
+
row: row,
|
|
50
|
+
col: col
|
|
51
|
+
}, content);
|
|
52
|
+
} catch (_a) {
|
|
53
|
+
return void table.changeCellValue(col, row, content, !1, !1, !0);
|
|
54
|
+
}
|
|
55
|
+
if ("string" == typeof content && content.startsWith("=")) {
|
|
56
|
+
const result = formulaManager.getCellValue({
|
|
57
|
+
sheet: sheetKey,
|
|
58
|
+
row: row,
|
|
59
|
+
col: col
|
|
60
|
+
}), display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
61
|
+
return table.changeCellValue(col, row, display, !1, !1, !0), void refreshDependentDisplays({
|
|
62
|
+
table: table,
|
|
63
|
+
sheetKey: sheetKey,
|
|
64
|
+
startCell: {
|
|
65
|
+
sheet: sheetKey,
|
|
66
|
+
row: row,
|
|
67
|
+
col: col
|
|
68
|
+
},
|
|
69
|
+
formulaManager: formulaManager
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return table.changeCellValue(col, row, content, !1, !1, !0), void refreshDependentDisplays({
|
|
73
|
+
table: table,
|
|
74
|
+
sheetKey: sheetKey,
|
|
75
|
+
startCell: {
|
|
76
|
+
sheet: sheetKey,
|
|
77
|
+
row: row,
|
|
78
|
+
col: col
|
|
79
|
+
},
|
|
80
|
+
formulaManager: formulaManager
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
table.changeCellValue(col, row, content, !1, !1, !0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function refreshDependentDisplays(args) {
|
|
87
|
+
var _a;
|
|
88
|
+
const {table: table, sheetKey: sheetKey, startCell: startCell, formulaManager: formulaManager} = args, maxCells = null !== (_a = args.maxCells) && void 0 !== _a ? _a : 5e3;
|
|
89
|
+
if (!(null == formulaManager ? void 0 : formulaManager.getCellDependents) || !(null == formulaManager ? void 0 : formulaManager.getCellValue)) return;
|
|
90
|
+
const visited = new Set, queue = [ ...formulaManager.getCellDependents(startCell) || [] ];
|
|
91
|
+
let processed = 0;
|
|
92
|
+
for (;queue.length; ) {
|
|
93
|
+
const cell = queue.shift();
|
|
94
|
+
if (!cell || cell.sheet !== sheetKey) continue;
|
|
95
|
+
const key = makeCellKey(cell.sheet, cell.row, cell.col);
|
|
96
|
+
if (visited.has(key)) continue;
|
|
97
|
+
if (visited.add(key), processed++, processed > maxCells) break;
|
|
98
|
+
const result = formulaManager.getCellValue(cell), display = (null == result ? void 0 : result.error) ? "#ERROR!" : null == result ? void 0 : result.value;
|
|
99
|
+
table.changeCellValue(cell.col, cell.row, display, !1, !1, !0);
|
|
100
|
+
(formulaManager.getCellDependents(cell) || []).forEach((d => queue.push(d)));
|
|
101
|
+
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;YACpB,SAAS;SACV;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,SAAS,EAAE,CAAC;QACZ,IAAI,SAAS,GAAG,QAAQ,EAAE;YACxB,MAAM;SACP;QAED,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC;QAC1D,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAEvE,MAAM,IAAI,GAAG,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;AACH,CAAC","file":"formula.js","sourcesContent":["import type { ListTable } from '@visactor/vtable';\n\nexport function makeCellKey(sheetKey: string, row: number, col: number): string {\n return `${sheetKey}:${row}:${col}`;\n}\n\n// 将 A1 单元格引用(如 \"B5\")解析成 0-based 行列索引。\nexport function parseA1Notation(a1: string): { row: number; col: number } | null {\n const match = a1.match(/^([A-Z]+)([0-9]+)$/i);\n if (!match) {\n return null;\n }\n const letters = match[1].toUpperCase();\n const rowNumber = parseInt(match[2], 10);\n if (!rowNumber || rowNumber < 1) {\n return null;\n }\n let col = 0;\n for (let i = 0; i < letters.length; i++) {\n col = col * 26 + (letters.charCodeAt(i) - 64);\n }\n return { row: rowNumber - 1, col: col - 1 };\n}\n\nexport function captureCellPreChangeContent(args: {\n sheetKey: string | undefined;\n row: number;\n col: number;\n currentValue: any;\n formulaManager: any;\n store: Map<string, any>;\n}): void {\n const { sheetKey, row, col, currentValue, formulaManager, store } = args;\n if (!sheetKey) {\n return;\n }\n const cellKey = makeCellKey(sheetKey, row, col);\n\n // 对公式单元格优先记录公式字符串(而不是显示值),确保撤销能恢复“公式关系”。\n if (formulaManager?.getCellFormula) {\n try {\n const oldFormula = formulaManager.getCellFormula({ sheet: sheetKey, row, col });\n if (oldFormula) {\n const normalized =\n typeof oldFormula === 'string' && !oldFormula.startsWith('=') ? `=${oldFormula}` : oldFormula;\n store.set(cellKey, normalized);\n return;\n }\n } catch {\n // ignore\n }\n }\n\n store.set(cellKey, currentValue == null ? '' : currentValue);\n}\n\nexport function popCellPreChangeContent(args: {\n sheetKey: string | undefined;\n row: number;\n col: number;\n fallbackOldContent: any;\n store: Map<string, any>;\n}): any {\n const { sheetKey, row, col, fallbackOldContent, store } = args;\n if (!sheetKey) {\n return fallbackOldContent;\n }\n const cellKey = makeCellKey(sheetKey, row, col);\n const oldContent = store.get(cellKey);\n store.delete(cellKey);\n return typeof oldContent !== 'undefined' ? oldContent : fallbackOldContent;\n}\n\nexport function applyCellContent(args: {\n table: ListTable;\n sheetKey: string | undefined;\n row: number;\n col: number;\n content: any;\n formulaManager: any;\n}): void {\n const { table, sheetKey, row, col, content, formulaManager } = args;\n\n if (sheetKey && formulaManager?.setCellContent && formulaManager?.getCellValue) {\n // 优先写入 formula engine:写入公式后再把显示值同步回 table。\n try {\n formulaManager.setCellContent({ sheet: sheetKey, row, col }, content);\n } catch {\n table.changeCellValue(col, row, content, false, false, true);\n return;\n }\n\n const isFormula = typeof content === 'string' && content.startsWith('=');\n if (isFormula) {\n const result = formulaManager.getCellValue({ sheet: sheetKey, row, col });\n const display = result?.error ? '#ERROR!' : result?.value;\n table.changeCellValue(col, row, display, false, false, true);\n refreshDependentDisplays({ table, sheetKey, startCell: { sheet: sheetKey, row, col }, formulaManager });\n return;\n }\n\n table.changeCellValue(col, row, content, false, false, true);\n refreshDependentDisplays({ table, sheetKey, startCell: { sheet: sheetKey, row, col }, formulaManager });\n return;\n }\n\n table.changeCellValue(col, row, content, false, false, true);\n}\n\nexport function refreshDependentDisplays(args: {\n table: ListTable;\n sheetKey: string;\n startCell: { sheet: string; row: number; col: number };\n formulaManager: any;\n maxCells?: number;\n}): void {\n const { table, sheetKey, startCell, formulaManager } = args;\n const maxCells = args.maxCells ?? 5000;\n\n if (!formulaManager?.getCellDependents || !formulaManager?.getCellValue) {\n return;\n }\n\n const visited = new Set<string>();\n const queue = [...(formulaManager.getCellDependents(startCell) || [])];\n let processed = 0;\n\n while (queue.length) {\n const cell = queue.shift();\n if (!cell || cell.sheet !== sheetKey) {\n continue;\n }\n const key = makeCellKey(cell.sheet, cell.row, cell.col);\n if (visited.has(key)) {\n continue;\n }\n visited.add(key);\n processed++;\n if (processed > maxCells) {\n break;\n }\n\n const result = formulaManager.getCellValue(cell);\n const display = result?.error ? '#ERROR!' : result?.value;\n table.changeCellValue(cell.col, cell.row, display, false, false, true);\n\n const deps = formulaManager.getCellDependents(cell) || [];\n deps.forEach((d: any) => queue.push(d));\n }\n}\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { BaseTableAPI, pluginsDefinition } from '@visactor/vtable';
|
|
2
|
+
import type { TableEventHandlersEventArgumentMap } from '@visactor/vtable/es/ts-types/events';
|
|
3
|
+
import type { HistoryCommand, HistoryPluginOptions } from './types';
|
|
4
|
+
export declare class HistoryPlugin implements pluginsDefinition.IVTablePlugin {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
runTime: any[];
|
|
8
|
+
private table;
|
|
9
|
+
private vtableSheet;
|
|
10
|
+
private resolvedSheetKey;
|
|
11
|
+
private undoStack;
|
|
12
|
+
private redoStack;
|
|
13
|
+
private currentTransaction;
|
|
14
|
+
private isReplaying;
|
|
15
|
+
private maxHistory;
|
|
16
|
+
private enableCompression;
|
|
17
|
+
private onTransactionPushed?;
|
|
18
|
+
private prevColumnsSnapshot;
|
|
19
|
+
private prevMergeSnapshot;
|
|
20
|
+
private prevRecordsSnapshot;
|
|
21
|
+
private prevFormulasSnapshot;
|
|
22
|
+
private prevResizedRowHeightsSnapshot;
|
|
23
|
+
private prevResizedColWidthsSnapshot;
|
|
24
|
+
private lastKnownSortState;
|
|
25
|
+
private sortStartSnapshot;
|
|
26
|
+
private sortPending;
|
|
27
|
+
private sortEventBound;
|
|
28
|
+
private sortChangeOrderListenerId;
|
|
29
|
+
private cellPreChangeContent;
|
|
30
|
+
private formulaCache;
|
|
31
|
+
private formulaEventBound;
|
|
32
|
+
private formulaEventManager;
|
|
33
|
+
private onFormulaAddedHandler;
|
|
34
|
+
private resizeRowStartHeight;
|
|
35
|
+
private resizeColStartWidth;
|
|
36
|
+
private filterEventBound;
|
|
37
|
+
private filterUnsubscribe;
|
|
38
|
+
private filterSnapshotCache;
|
|
39
|
+
private filterPluginId;
|
|
40
|
+
private filterPluginRef;
|
|
41
|
+
private filterApplySnapshotOriginal;
|
|
42
|
+
private filterApplyingSnapshot;
|
|
43
|
+
constructor(options?: HistoryPluginOptions);
|
|
44
|
+
run(...args: [TableEventHandlersEventArgumentMap[keyof TableEventHandlersEventArgumentMap], any, BaseTableAPI]): void;
|
|
45
|
+
startTransaction(): void;
|
|
46
|
+
endTransaction(): void;
|
|
47
|
+
undo(): void;
|
|
48
|
+
redo(): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
updateOptions(options: Partial<HistoryPluginOptions>): void;
|
|
51
|
+
release(): void;
|
|
52
|
+
private ensureFilterEventBindings;
|
|
53
|
+
private unbindFilterEvents;
|
|
54
|
+
private getSheetKey;
|
|
55
|
+
private getSnapshotState;
|
|
56
|
+
private setSnapshotState;
|
|
57
|
+
private pushTransaction;
|
|
58
|
+
private trimHistory;
|
|
59
|
+
private pushCommand;
|
|
60
|
+
recordExternalCommand(cmd: HistoryCommand): void;
|
|
61
|
+
private tryCompressCellChange;
|
|
62
|
+
private handleBeforeKeydown;
|
|
63
|
+
private handleChangeCellValue;
|
|
64
|
+
private handleChangeCellValues;
|
|
65
|
+
private ensureFormulaEventBindings;
|
|
66
|
+
private ensureSortEventBindings;
|
|
67
|
+
private unbindSortEvents;
|
|
68
|
+
private unbindFormulaEvents;
|
|
69
|
+
private cloneMergeConfig;
|
|
70
|
+
private isSameMergeConfig;
|
|
71
|
+
private handleMergeCells;
|
|
72
|
+
private handleUnmergeCells;
|
|
73
|
+
private handleMergeConfigChanged;
|
|
74
|
+
private handleAddRecord;
|
|
75
|
+
private handleDeleteRecord;
|
|
76
|
+
private handleUpdateRecord;
|
|
77
|
+
private handleAddColumn;
|
|
78
|
+
private handleDeleteColumn;
|
|
79
|
+
private handleChangeHeaderPosition;
|
|
80
|
+
private normalizeSortState;
|
|
81
|
+
private handleSortClick;
|
|
82
|
+
private handleResizeRow;
|
|
83
|
+
private handleResizeRowEnd;
|
|
84
|
+
private handleResizeColumn;
|
|
85
|
+
private handleResizeColumnEnd;
|
|
86
|
+
private applyCommand;
|
|
87
|
+
private deleteRecordsByReference;
|
|
88
|
+
}
|