@fileverse-dev/fortune-core 1.3.10 → 1.3.11-input-ref-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.
Files changed (43) hide show
  1. package/es/api/range.js +20 -0
  2. package/es/api/sheet.js +30 -2
  3. package/es/events/keyboard.js +50 -15
  4. package/es/events/mouse.js +62 -40
  5. package/es/events/paste.js +77 -28
  6. package/es/modules/cell.js +60 -2
  7. package/es/modules/comment.js +129 -24
  8. package/es/modules/dataVerification.js +34 -1
  9. package/es/modules/dropCell.js +65 -1
  10. package/es/modules/formula.d.ts +11 -0
  11. package/es/modules/formula.js +390 -47
  12. package/es/modules/hyperlink.js +52 -5
  13. package/es/modules/merge.js +93 -1
  14. package/es/modules/moveCells.js +35 -9
  15. package/es/modules/rowcol.js +75 -2
  16. package/es/modules/searchReplace.js +58 -2
  17. package/es/modules/selection.js +152 -42
  18. package/es/modules/sort.js +74 -9
  19. package/es/modules/splitColumn.js +21 -0
  20. package/es/modules/toolbar.js +46 -3
  21. package/es/settings.d.ts +5 -0
  22. package/lib/api/range.js +20 -0
  23. package/lib/api/sheet.js +29 -1
  24. package/lib/events/keyboard.js +49 -14
  25. package/lib/events/mouse.js +61 -39
  26. package/lib/events/paste.js +77 -28
  27. package/lib/modules/cell.js +60 -2
  28. package/lib/modules/comment.js +129 -24
  29. package/lib/modules/dataVerification.js +34 -1
  30. package/lib/modules/dropCell.js +65 -1
  31. package/lib/modules/formula.d.ts +11 -0
  32. package/lib/modules/formula.js +399 -47
  33. package/lib/modules/hyperlink.js +52 -5
  34. package/lib/modules/merge.js +93 -1
  35. package/lib/modules/moveCells.js +35 -9
  36. package/lib/modules/rowcol.js +75 -2
  37. package/lib/modules/searchReplace.js +58 -2
  38. package/lib/modules/selection.js +152 -42
  39. package/lib/modules/sort.js +74 -9
  40. package/lib/modules/splitColumn.js +21 -0
  41. package/lib/modules/toolbar.js +46 -3
  42. package/lib/settings.d.ts +5 -0
  43. package/package.json +1 -1
@@ -229,7 +229,7 @@ export function validateCellData(ctx, item, cellValue) {
229
229
  return true;
230
230
  }
231
231
  export function checkboxChange(ctx, r, c) {
232
- var _a;
232
+ var _a, _b, _c, _d;
233
233
  var index = getSheetIndex(ctx, ctx.currentSheetId);
234
234
  var currentDataVerification = (_a = ctx.luckysheetfile[index].dataVerification) !== null && _a !== void 0 ? _a : {};
235
235
  var item = currentDataVerification["".concat(r, "_").concat(c)];
@@ -240,6 +240,25 @@ export function checkboxChange(ctx, r, c) {
240
240
  }
241
241
  var d = getFlowdata(ctx);
242
242
  setCellValue(ctx, r, c, d, value);
243
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
244
+ ctx.hooks.updateCellYdoc([{
245
+ sheetId: ctx.currentSheetId,
246
+ path: ["celldata"],
247
+ value: {
248
+ r: r,
249
+ c: c,
250
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) !== null && _d !== void 0 ? _d : null
251
+ },
252
+ key: "".concat(r, "_").concat(c),
253
+ type: "update"
254
+ }, {
255
+ sheetId: ctx.currentSheetId,
256
+ path: ["dataVerification"],
257
+ key: "".concat(r, "_").concat(c),
258
+ value: JSON.parse(JSON.stringify(item)),
259
+ type: "update"
260
+ }]);
261
+ }
243
262
  }
244
263
  export function getFailureText(ctx, item) {
245
264
  var _a, _b, _c, _d, _e;
@@ -587,6 +606,7 @@ export function cellFocus(ctx, r, c, clickMode) {
587
606
  }
588
607
  export function setDropdownValue(ctx, value, arr) {
589
608
  var _a;
609
+ var _b, _c, _d;
590
610
  if (!ctx.luckysheet_select_save) return;
591
611
  var d = getFlowdata(ctx);
592
612
  if (!d) return;
@@ -632,6 +652,19 @@ export function setDropdownValue(ctx, value, arr) {
632
652
  v: value,
633
653
  pillColor: selectedColor
634
654
  });
655
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
656
+ ctx.hooks.updateCellYdoc([{
657
+ sheetId: ctx.currentSheetId,
658
+ path: ["celldata"],
659
+ value: {
660
+ r: rowIndex,
661
+ c: colIndex,
662
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[rowIndex]) === null || _c === void 0 ? void 0 : _c[colIndex]) !== null && _d !== void 0 ? _d : null
663
+ },
664
+ key: "".concat(rowIndex, "_").concat(colIndex),
665
+ type: "update"
666
+ }]);
667
+ }
635
668
  var currentRowHeight = getRowHeight(ctx, [rowIndex])[rowIndex];
636
669
  var newHeight = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22;
637
670
  if (currentRowHeight < newHeight) {
@@ -1779,7 +1779,7 @@ function getApplyData(copyD, csLen, asLen) {
1779
1779
  }
1780
1780
  export function updateDropCell(ctx) {
1781
1781
  var _a, _b, _c, _d;
1782
- var _e, _f, _g;
1782
+ var _e, _f, _g, _h;
1783
1783
  var d = getFlowdata(ctx);
1784
1784
  var allowEdit = isAllowEdit(ctx);
1785
1785
  var isReadOnly = isAllowEditReadOnly(ctx);
@@ -1815,6 +1815,7 @@ export function updateDropCell(ctx) {
1815
1815
  var apply_end_r = applyRange.row[1];
1816
1816
  var apply_str_c = applyRange.column[0];
1817
1817
  var apply_end_c = applyRange.column[1];
1818
+ var cellChanges = [];
1818
1819
  if (direction === "down" || direction === "up") {
1819
1820
  var asLen = apply_end_r - apply_str_r + 1;
1820
1821
  for (var i = apply_str_c; i <= apply_end_c; i += 1) {
@@ -1825,6 +1826,7 @@ export function updateDropCell(ctx) {
1825
1826
  for (var j = apply_str_r; j <= apply_end_r; j += 1) {
1826
1827
  if (hiddenRows.has("".concat(j))) continue;
1827
1828
  var cell = applyData[j - apply_str_r];
1829
+ var afterHookCalled = false;
1828
1830
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1829
1831
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "down", j - apply_str_r + 1));
1830
1832
  var v = formula.execfunction(ctx, f, j, i);
@@ -1836,6 +1838,7 @@ export function updateDropCell(ctx) {
1836
1838
  v: v[1] instanceof Promise ? v[1] : cell.v,
1837
1839
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1838
1840
  }));
1841
+ afterHookCalled = true;
1839
1842
  }
1840
1843
  if (cell.spl != null) {
1841
1844
  cell.spl = v[3].data;
@@ -1873,6 +1876,19 @@ export function updateDropCell(ctx) {
1873
1876
  }
1874
1877
  }
1875
1878
  d[j][i] = cell || null;
1879
+ if (!afterHookCalled) {
1880
+ cellChanges.push({
1881
+ sheetId: ctx.currentSheetId,
1882
+ path: ["celldata"],
1883
+ value: {
1884
+ r: j,
1885
+ c: i,
1886
+ v: d[j][i]
1887
+ },
1888
+ key: "".concat(j, "_").concat(i),
1889
+ type: "update"
1890
+ });
1891
+ }
1876
1892
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1877
1893
  var bd_c = i;
1878
1894
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1911,6 +1927,7 @@ export function updateDropCell(ctx) {
1911
1927
  for (var j = apply_end_r; j >= apply_str_r; j -= 1) {
1912
1928
  if (hiddenRows.has("".concat(j))) continue;
1913
1929
  var cell = applyData[apply_end_r - j];
1930
+ var afterHookCalled = false;
1914
1931
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1915
1932
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "up", apply_end_r - j + 1));
1916
1933
  var v = formula.execfunction(ctx, f, j, i);
@@ -1922,6 +1939,7 @@ export function updateDropCell(ctx) {
1922
1939
  v: v[1] instanceof Promise ? v[1] : cell.v,
1923
1940
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1924
1941
  }));
1942
+ afterHookCalled = true;
1925
1943
  }
1926
1944
  if (cell.spl != null) {
1927
1945
  cell.spl = v[3].data;
@@ -1953,6 +1971,19 @@ export function updateDropCell(ctx) {
1953
1971
  }
1954
1972
  }
1955
1973
  d[j][i] = cell || null;
1974
+ if (!afterHookCalled) {
1975
+ cellChanges.push({
1976
+ sheetId: ctx.currentSheetId,
1977
+ path: ["celldata"],
1978
+ value: {
1979
+ r: j,
1980
+ c: i,
1981
+ v: d[j][i]
1982
+ },
1983
+ key: "".concat(j, "_").concat(i),
1984
+ type: "update"
1985
+ });
1986
+ }
1956
1987
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1957
1988
  var bd_c = i;
1958
1989
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1998,6 +2029,7 @@ export function updateDropCell(ctx) {
1998
2029
  for (var j = apply_str_c; j <= apply_end_c; j += 1) {
1999
2030
  if (hiddenCols.has("".concat(j))) continue;
2000
2031
  var cell = applyData[j - apply_str_c];
2032
+ var afterHookCalled = false;
2001
2033
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2002
2034
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "right", j - apply_str_c + 1));
2003
2035
  var v = formula.execfunction(ctx, f, i, j);
@@ -2009,6 +2041,7 @@ export function updateDropCell(ctx) {
2009
2041
  v: v[1] instanceof Promise ? v[1] : cell.v,
2010
2042
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2011
2043
  }));
2044
+ afterHookCalled = true;
2012
2045
  }
2013
2046
  if (cell.spl != null) {
2014
2047
  cell.spl = v[3].data;
@@ -2040,6 +2073,19 @@ export function updateDropCell(ctx) {
2040
2073
  }
2041
2074
  }
2042
2075
  d[i][j] = cell || null;
2076
+ if (!afterHookCalled) {
2077
+ cellChanges.push({
2078
+ sheetId: ctx.currentSheetId,
2079
+ path: ["celldata"],
2080
+ value: {
2081
+ r: i,
2082
+ c: j,
2083
+ v: d[i][j]
2084
+ },
2085
+ key: "".concat(i, "_").concat(j),
2086
+ type: "update"
2087
+ });
2088
+ }
2043
2089
  var bd_r = i;
2044
2090
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2045
2091
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2078,6 +2124,7 @@ export function updateDropCell(ctx) {
2078
2124
  for (var j = apply_end_c; j >= apply_str_c; j -= 1) {
2079
2125
  if (hiddenCols.has("".concat(j))) continue;
2080
2126
  var cell = applyData[apply_end_c - j];
2127
+ var afterHookCalled = false;
2081
2128
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2082
2129
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "left", apply_end_c - j + 1));
2083
2130
  var v = formula.execfunction(ctx, f, i, j);
@@ -2089,6 +2136,7 @@ export function updateDropCell(ctx) {
2089
2136
  v: v[1] instanceof Promise ? v[1] : cell.v,
2090
2137
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2091
2138
  }));
2139
+ afterHookCalled = true;
2092
2140
  }
2093
2141
  if (cell.spl != null) {
2094
2142
  cell.spl = v[3].data;
@@ -2120,6 +2168,19 @@ export function updateDropCell(ctx) {
2120
2168
  }
2121
2169
  }
2122
2170
  d[i][j] = cell || null;
2171
+ if (!afterHookCalled) {
2172
+ cellChanges.push({
2173
+ sheetId: ctx.currentSheetId,
2174
+ path: ["celldata"],
2175
+ value: {
2176
+ r: i,
2177
+ c: j,
2178
+ v: d[i][j]
2179
+ },
2180
+ key: "".concat(i, "_").concat(j),
2181
+ type: "update"
2182
+ });
2183
+ }
2123
2184
  var bd_r = i;
2124
2185
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2125
2186
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2156,6 +2217,9 @@ export function updateDropCell(ctx) {
2156
2217
  }
2157
2218
  }
2158
2219
  }
2220
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
2221
+ ctx.hooks.updateCellYdoc(cellChanges);
2222
+ }
2159
2223
  var cdformat = file.luckysheet_conditionformat_save;
2160
2224
  if (cdformat != null && cdformat.length > 0) {
2161
2225
  for (var i = 0; i < cdformat.length; i += 1) {
@@ -20,6 +20,8 @@ export declare class FormulaCache {
20
20
  rangetosheet?: string;
21
21
  rangedrag_column_start?: boolean;
22
22
  rangedrag_row_start?: boolean;
23
+ rangeSelectionActive?: boolean | null;
24
+ formulaEditorOwner?: "cell" | "fx" | null;
23
25
  functionRangeIndex?: number[];
24
26
  functionlistMap: any;
25
27
  execFunctionExist?: any[];
@@ -44,8 +46,17 @@ export declare function setCaretPosition(ctx: Context, textDom: HTMLElement, chi
44
46
  export declare function getrangeseleciton(): ParentNode | ChildNode | null | undefined;
45
47
  export declare function rangeHightlightselected(ctx: Context, $editor: HTMLDivElement): void;
46
48
  export declare function functionHTMLGenerate(txt: string): string;
49
+ export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): number | null;
50
+ export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
51
+ export declare function setFormulaEditorOwner(ctx: Context, owner: "cell" | "fx" | null): void;
52
+ export declare function getFormulaEditorOwner(ctx: Context): "cell" | "fx" | null;
53
+ export declare function isCaretAtValidFormulaRangeInsertionPoint(editor: HTMLElement | null): boolean;
54
+ export declare function markRangeSelectionDirty(ctx: Context): void;
55
+ export declare function getFormulaRangeIndexForKeyboardSync($editor: HTMLDivElement): number | null;
47
56
  export declare function handleFormulaInput(ctx: Context, $copyTo: HTMLDivElement | null | undefined, $editor: HTMLDivElement, kcode: number, preText?: string, refreshRangeSelect?: boolean): void;
48
57
  export declare function israngeseleciton(ctx: Context, istooltip?: boolean): boolean;
58
+ export declare function isFormulaReferenceInputMode(ctx: Context): boolean;
59
+ export declare function maybeRecoverDirtyRangeSelection(ctx: Context): boolean;
49
60
  export declare function functionStrChange(txt: string, type: string, rc: "row" | "col", orient: string | null, stindex: number, step: number): string;
50
61
  export declare function rangeSetValue(ctx: Context, cellInput: HTMLDivElement, selected: any, fxInput?: HTMLDivElement | null): void;
51
62
  export declare function onFormulaRangeDragEnd(ctx: Context): void;