@leankylin-sheet/core 5.2.21 → 5.2.23

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/index.esm.js CHANGED
@@ -31637,7 +31637,7 @@ function locale(ctx) {
31637
31637
  }
31638
31638
 
31639
31639
  function moveToEnd(obj) {
31640
- if (document.createRange) {
31640
+ if (document.createRange && obj) {
31641
31641
  if (obj.innerHTML !== obj.innerText || obj.innerHTML === "") {
31642
31642
  obj.focus();
31643
31643
  var range = window.getSelection();
@@ -36595,8 +36595,9 @@ function setCaretPosition(ctx, textDom, children, pos) {
36595
36595
  sel === null || sel === void 0 ? void 0 : sel.addRange(range);
36596
36596
  el.focus();
36597
36597
  } catch (err) {
36598
+ var _ctx$formulaCache, _ctx$formulaCache$ran;
36598
36599
  console.error(err);
36599
- moveToEnd(ctx.formulaCache.rangeResizeTo[0]);
36600
+ moveToEnd((_ctx$formulaCache = ctx.formulaCache) === null || _ctx$formulaCache === void 0 ? void 0 : (_ctx$formulaCache$ran = _ctx$formulaCache.rangeResizeTo) === null || _ctx$formulaCache$ran === void 0 ? void 0 : _ctx$formulaCache$ran[0]);
36600
36601
  }
36601
36602
  }
36602
36603
  function functionRange(ctx, obj, v, vp) {
@@ -37310,6 +37311,10 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37310
37311
  $editor = fxInput;
37311
37312
  $copyTo = cellInput;
37312
37313
  }
37314
+ if (ctx.active_f) {
37315
+ $editor = fxInput;
37316
+ $copyTo = cellInput;
37317
+ }
37313
37318
  var range = "";
37314
37319
  var rf = selected.row[0];
37315
37320
  var cf = selected.column[0];
@@ -37326,6 +37331,7 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37326
37331
  var span = $editor.querySelector("span[rangeindex='".concat(ctx.formulaCache.rangechangeindex, "']"));
37327
37332
  if (span) {
37328
37333
  span.innerHTML = range;
37334
+ console.log(333312);
37329
37335
  setCaretPosition(ctx, span, 0, range.length);
37330
37336
  }
37331
37337
  } else if (ctx.active_f) {
@@ -37339,7 +37345,7 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37339
37345
  }
37340
37346
  ctx.formulaCache.rangechangeindex = functionHTMLIndex;
37341
37347
  var _span = $editor.querySelector("span[rangeindex='".concat(ctx.formulaCache.rangechangeindex, "']"));
37342
- setCaretPosition(ctx, _span, 0, range.length);
37348
+ setCaretPosition(ctx, _span || $editor, 0, range.length);
37343
37349
  functionHTMLIndex += 1;
37344
37350
  } else {
37345
37351
  var _function_str = "<span class=\"leankylin-formula-functionrange-cell\" rangeindex=\"".concat(functionHTMLIndex, "\" dir=\"auto\" style=\"color:").concat(getHLColor(functionHTMLIndex), ";\">").concat(range, "</span>");
@@ -46583,19 +46589,39 @@ function calculateSheetFromula(ctx, id, isrefresh) {
46583
46589
  console.time("calcTime:".concat(id));
46584
46590
  var index$1 = getSheetIndex(ctx, id);
46585
46591
  var luckysheetfile = ctx.luckysheetfile;
46586
- if (!ctx.luckysheetfile[index$1].data) return;
46587
- for (var r = 0; r < ctx.luckysheetfile[index$1].data.length; r += 1) {
46588
- for (var c = 0; c < ctx.luckysheetfile[index$1].data[r].length; c += 1) {
46589
- var cell = ctx.luckysheetfile[index$1].data[r][c];
46592
+ var sheetData = luckysheetfile[index$1].data;
46593
+ if (!sheetData) return;
46594
+ var calcChain = luckysheetfile[index$1].calcChain || [];
46595
+ if (isrefresh && calcChain.length > 0) {
46596
+ execFunctionGroup(ctx, null, null, null, id, sheetData, true);
46597
+ groupValuesRefresh(ctx);
46598
+ } else {
46599
+ var cellsToUpdate = [];
46600
+ for (var i = 0; i < calcChain.length; i += 1) {
46601
+ var _calcChain$i = calcChain[i],
46602
+ r = _calcChain$i.r,
46603
+ c = _calcChain$i.c;
46604
+ var cell = sheetData[r][c];
46590
46605
  if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46591
46606
  continue;
46592
46607
  }
46593
- var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, isrefresh, true);
46608
+ var result = execfunction(ctx, cell.f, r, c, id, false, true);
46594
46609
  var newV = result[1];
46595
46610
  if (newV === cell.v) {
46596
46611
  continue;
46597
46612
  }
46598
- setCellValue$1(ctx, r, c, result[1], null, {
46613
+ cellsToUpdate.push({
46614
+ r: r,
46615
+ c: c,
46616
+ v: newV
46617
+ });
46618
+ }
46619
+ for (var _i = 0; _i < cellsToUpdate.length; _i += 1) {
46620
+ var _cellsToUpdate$_i = cellsToUpdate[_i],
46621
+ _r = _cellsToUpdate$_i.r,
46622
+ _c = _cellsToUpdate$_i.c,
46623
+ v = _cellsToUpdate$_i.v;
46624
+ setCellValue$1(ctx, _r, _c, v, null, {
46599
46625
  id: id
46600
46626
  });
46601
46627
  }
@@ -46665,9 +46691,9 @@ function calculateSheetByCells(ctx, cells) {
46665
46691
  for (var _index = 0; _index < calcChain.length; _index++) {
46666
46692
  var _parseCellReferences;
46667
46693
  var _calcChain$_index = calcChain[_index],
46668
- _r2 = _calcChain$_index.r,
46669
- _c2 = _calcChain$_index.c;
46670
- var cell = file.data[_r2][_c2];
46694
+ _r3 = _calcChain$_index.r,
46695
+ _c3 = _calcChain$_index.c;
46696
+ var cell = file.data[_r3][_c3];
46671
46697
  if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46672
46698
  continue;
46673
46699
  }
@@ -46679,8 +46705,8 @@ function calculateSheetByCells(ctx, cells) {
46679
46705
  });
46680
46706
  if (n) {
46681
46707
  needUpdateCell.push({
46682
- r: _r2,
46683
- c: _c2,
46708
+ r: _r3,
46709
+ c: _c3,
46684
46710
  id: sheetId,
46685
46711
  f: cell.f,
46686
46712
  v: cell.v
@@ -46696,17 +46722,17 @@ function calculateSheetByCells(ctx, cells) {
46696
46722
  });
46697
46723
  for (var nIndex = 0; nIndex < needUpdateCell.length; nIndex++) {
46698
46724
  var _needUpdateCell$nInde = needUpdateCell[nIndex],
46699
- _r = _needUpdateCell$nInde.r,
46700
- _c = _needUpdateCell$nInde.c,
46725
+ _r2 = _needUpdateCell$nInde.r,
46726
+ _c2 = _needUpdateCell$nInde.c,
46701
46727
  _id = _needUpdateCell$nInde.id,
46702
46728
  _f = _needUpdateCell$nInde.f,
46703
46729
  v = _needUpdateCell$nInde.v;
46704
- var result = execfunction(ctx, _f, _r, _c, _id, undefined, true);
46730
+ var result = execfunction(ctx, _f, _r2, _c2, _id, undefined, true);
46705
46731
  var newV = result[1];
46706
46732
  if (newV === v) {
46707
46733
  continue;
46708
46734
  }
46709
- setCellValue$1(ctx, _r, _c, result[1], null, {
46735
+ setCellValue$1(ctx, _r2, _c2, result[1], null, {
46710
46736
  id: _id
46711
46737
  });
46712
46738
  }
package/dist/index.js CHANGED
@@ -31647,7 +31647,7 @@ function locale(ctx) {
31647
31647
  }
31648
31648
 
31649
31649
  function moveToEnd(obj) {
31650
- if (document.createRange) {
31650
+ if (document.createRange && obj) {
31651
31651
  if (obj.innerHTML !== obj.innerText || obj.innerHTML === "") {
31652
31652
  obj.focus();
31653
31653
  var range = window.getSelection();
@@ -36605,8 +36605,9 @@ function setCaretPosition(ctx, textDom, children, pos) {
36605
36605
  sel === null || sel === void 0 ? void 0 : sel.addRange(range);
36606
36606
  el.focus();
36607
36607
  } catch (err) {
36608
+ var _ctx$formulaCache, _ctx$formulaCache$ran;
36608
36609
  console.error(err);
36609
- moveToEnd(ctx.formulaCache.rangeResizeTo[0]);
36610
+ moveToEnd((_ctx$formulaCache = ctx.formulaCache) === null || _ctx$formulaCache === void 0 ? void 0 : (_ctx$formulaCache$ran = _ctx$formulaCache.rangeResizeTo) === null || _ctx$formulaCache$ran === void 0 ? void 0 : _ctx$formulaCache$ran[0]);
36610
36611
  }
36611
36612
  }
36612
36613
  function functionRange(ctx, obj, v, vp) {
@@ -37320,6 +37321,10 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37320
37321
  $editor = fxInput;
37321
37322
  $copyTo = cellInput;
37322
37323
  }
37324
+ if (ctx.active_f) {
37325
+ $editor = fxInput;
37326
+ $copyTo = cellInput;
37327
+ }
37323
37328
  var range = "";
37324
37329
  var rf = selected.row[0];
37325
37330
  var cf = selected.column[0];
@@ -37336,6 +37341,7 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37336
37341
  var span = $editor.querySelector("span[rangeindex='".concat(ctx.formulaCache.rangechangeindex, "']"));
37337
37342
  if (span) {
37338
37343
  span.innerHTML = range;
37344
+ console.log(333312);
37339
37345
  setCaretPosition(ctx, span, 0, range.length);
37340
37346
  }
37341
37347
  } else if (ctx.active_f) {
@@ -37349,7 +37355,7 @@ function rangeSetValue(ctx, cellInput, selected, fxInput) {
37349
37355
  }
37350
37356
  ctx.formulaCache.rangechangeindex = functionHTMLIndex;
37351
37357
  var _span = $editor.querySelector("span[rangeindex='".concat(ctx.formulaCache.rangechangeindex, "']"));
37352
- setCaretPosition(ctx, _span, 0, range.length);
37358
+ setCaretPosition(ctx, _span || $editor, 0, range.length);
37353
37359
  functionHTMLIndex += 1;
37354
37360
  } else {
37355
37361
  var _function_str = "<span class=\"leankylin-formula-functionrange-cell\" rangeindex=\"".concat(functionHTMLIndex, "\" dir=\"auto\" style=\"color:").concat(getHLColor(functionHTMLIndex), ";\">").concat(range, "</span>");
@@ -46593,19 +46599,39 @@ function calculateSheetFromula(ctx, id, isrefresh) {
46593
46599
  console.time("calcTime:".concat(id));
46594
46600
  var index$1 = getSheetIndex(ctx, id);
46595
46601
  var luckysheetfile = ctx.luckysheetfile;
46596
- if (!ctx.luckysheetfile[index$1].data) return;
46597
- for (var r = 0; r < ctx.luckysheetfile[index$1].data.length; r += 1) {
46598
- for (var c = 0; c < ctx.luckysheetfile[index$1].data[r].length; c += 1) {
46599
- var cell = ctx.luckysheetfile[index$1].data[r][c];
46602
+ var sheetData = luckysheetfile[index$1].data;
46603
+ if (!sheetData) return;
46604
+ var calcChain = luckysheetfile[index$1].calcChain || [];
46605
+ if (isrefresh && calcChain.length > 0) {
46606
+ execFunctionGroup(ctx, null, null, null, id, sheetData, true);
46607
+ groupValuesRefresh(ctx);
46608
+ } else {
46609
+ var cellsToUpdate = [];
46610
+ for (var i = 0; i < calcChain.length; i += 1) {
46611
+ var _calcChain$i = calcChain[i],
46612
+ r = _calcChain$i.r,
46613
+ c = _calcChain$i.c;
46614
+ var cell = sheetData[r][c];
46600
46615
  if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46601
46616
  continue;
46602
46617
  }
46603
- var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, isrefresh, true);
46618
+ var result = execfunction(ctx, cell.f, r, c, id, false, true);
46604
46619
  var newV = result[1];
46605
46620
  if (newV === cell.v) {
46606
46621
  continue;
46607
46622
  }
46608
- setCellValue$1(ctx, r, c, result[1], null, {
46623
+ cellsToUpdate.push({
46624
+ r: r,
46625
+ c: c,
46626
+ v: newV
46627
+ });
46628
+ }
46629
+ for (var _i = 0; _i < cellsToUpdate.length; _i += 1) {
46630
+ var _cellsToUpdate$_i = cellsToUpdate[_i],
46631
+ _r = _cellsToUpdate$_i.r,
46632
+ _c = _cellsToUpdate$_i.c,
46633
+ v = _cellsToUpdate$_i.v;
46634
+ setCellValue$1(ctx, _r, _c, v, null, {
46609
46635
  id: id
46610
46636
  });
46611
46637
  }
@@ -46675,9 +46701,9 @@ function calculateSheetByCells(ctx, cells) {
46675
46701
  for (var _index = 0; _index < calcChain.length; _index++) {
46676
46702
  var _parseCellReferences;
46677
46703
  var _calcChain$_index = calcChain[_index],
46678
- _r2 = _calcChain$_index.r,
46679
- _c2 = _calcChain$_index.c;
46680
- var cell = file.data[_r2][_c2];
46704
+ _r3 = _calcChain$_index.r,
46705
+ _c3 = _calcChain$_index.c;
46706
+ var cell = file.data[_r3][_c3];
46681
46707
  if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46682
46708
  continue;
46683
46709
  }
@@ -46689,8 +46715,8 @@ function calculateSheetByCells(ctx, cells) {
46689
46715
  });
46690
46716
  if (n) {
46691
46717
  needUpdateCell.push({
46692
- r: _r2,
46693
- c: _c2,
46718
+ r: _r3,
46719
+ c: _c3,
46694
46720
  id: sheetId,
46695
46721
  f: cell.f,
46696
46722
  v: cell.v
@@ -46706,17 +46732,17 @@ function calculateSheetByCells(ctx, cells) {
46706
46732
  });
46707
46733
  for (var nIndex = 0; nIndex < needUpdateCell.length; nIndex++) {
46708
46734
  var _needUpdateCell$nInde = needUpdateCell[nIndex],
46709
- _r = _needUpdateCell$nInde.r,
46710
- _c = _needUpdateCell$nInde.c,
46735
+ _r2 = _needUpdateCell$nInde.r,
46736
+ _c2 = _needUpdateCell$nInde.c,
46711
46737
  _id = _needUpdateCell$nInde.id,
46712
46738
  _f = _needUpdateCell$nInde.f,
46713
46739
  v = _needUpdateCell$nInde.v;
46714
- var result = execfunction(ctx, _f, _r, _c, _id, undefined, true);
46740
+ var result = execfunction(ctx, _f, _r2, _c2, _id, undefined, true);
46715
46741
  var newV = result[1];
46716
46742
  if (newV === v) {
46717
46743
  continue;
46718
46744
  }
46719
- setCellValue$1(ctx, _r, _c, result[1], null, {
46745
+ setCellValue$1(ctx, _r2, _c2, result[1], null, {
46720
46746
  id: _id
46721
46747
  });
46722
46748
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "5.2.21",
3
+ "version": "5.2.23",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build": "father-build"
14
14
  },
15
15
  "dependencies": {
16
- "@leankylin-sheet/formula-parser": "5.2.21",
16
+ "@leankylin-sheet/formula-parser": "5.2.23",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",