@fileverse-dev/fortune-core 1.1.46 → 1.1.48
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/es/events/mouse.js +1 -1
- package/es/modules/cell.js +20 -19
- package/es/modules/formula.d.ts +1 -0
- package/es/modules/formula.js +12 -2
- package/es/utils/index.js +30 -23
- package/lib/events/mouse.js +1 -1
- package/lib/modules/cell.js +20 -19
- package/lib/modules/formula.d.ts +1 -0
- package/lib/modules/formula.js +13 -2
- package/lib/utils/index.js +30 -23
- package/package.json +1 -1
package/es/events/mouse.js
CHANGED
|
@@ -178,7 +178,7 @@ export function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, containe
|
|
|
178
178
|
var spans = doc.querySelectorAll("span");
|
|
179
179
|
var firstSpan = spans[0];
|
|
180
180
|
var lastSpan = spans[spans.length - 1];
|
|
181
|
-
if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx)
|
|
181
|
+
if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx)) {
|
|
182
182
|
var rowseleted = [row_index, row_index_ed];
|
|
183
183
|
var columnseleted = [col_index, col_index_ed];
|
|
184
184
|
var left = col_pre;
|
package/es/modules/cell.js
CHANGED
|
@@ -93,7 +93,8 @@ export function getCellValue(r, c, data, attr) {
|
|
|
93
93
|
return retv;
|
|
94
94
|
}
|
|
95
95
|
export function setCellValue(ctx, r, c, d, v) {
|
|
96
|
-
var _a, _b, _c, _d, _e, _f;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
97
|
+
console.log("setCellValue", r, c, v);
|
|
97
98
|
if (_.isNil(d)) {
|
|
98
99
|
d = getFlowdata(ctx);
|
|
99
100
|
}
|
|
@@ -127,12 +128,10 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
127
128
|
vupdate = v;
|
|
128
129
|
}
|
|
129
130
|
var commaPresent = false;
|
|
130
|
-
var decimalPresent = false;
|
|
131
131
|
if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
|
|
132
132
|
commaPresent = vupdate.includes(",");
|
|
133
|
-
decimalPresent = vupdate.includes(".");
|
|
134
133
|
var removeCommasValidated = function removeCommasValidated(str) {
|
|
135
|
-
return /^[\d
|
|
134
|
+
return /^[\d,.]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
|
|
136
135
|
};
|
|
137
136
|
vupdate = removeCommasValidated(vupdate);
|
|
138
137
|
}
|
|
@@ -273,13 +272,15 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
273
272
|
}
|
|
274
273
|
}
|
|
275
274
|
cell.v = vupdate;
|
|
275
|
+
var strValue = String(vupdate);
|
|
276
276
|
var format = void 0;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
277
|
+
var hasDecimal = strValue.includes(".");
|
|
278
|
+
var hasComma = commaPresent;
|
|
279
|
+
if (hasDecimal) {
|
|
280
|
+
var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
|
|
281
|
+
format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
|
|
282
|
+
} else if (hasComma) {
|
|
283
|
+
format = "#,##0";
|
|
283
284
|
} else {
|
|
284
285
|
format = "0";
|
|
285
286
|
}
|
|
@@ -500,7 +501,7 @@ export function cancelNormalSelected(ctx) {
|
|
|
500
501
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
501
502
|
}
|
|
502
503
|
export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
503
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
504
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
504
505
|
console.log("updateCell", r, c, $input, value);
|
|
505
506
|
var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
|
|
506
507
|
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
@@ -670,8 +671,8 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
670
671
|
f: v[2]
|
|
671
672
|
};
|
|
672
673
|
if (/^[\d.,]+$/.test(value.v)) {
|
|
673
|
-
var args = getContentInParentheses(value === null || value === void 0 ? void 0 : value.f).split(
|
|
674
|
-
var cellRefs = args.map(function (arg) {
|
|
674
|
+
var args = (_k = getContentInParentheses(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
|
|
675
|
+
var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
675
676
|
return arg.trim().toUpperCase();
|
|
676
677
|
});
|
|
677
678
|
var formatted = processArray(cellRefs, d, flowdata);
|
|
@@ -722,8 +723,8 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
722
723
|
isRunExecFunction = false;
|
|
723
724
|
}
|
|
724
725
|
}
|
|
725
|
-
var decemialCount = ((
|
|
726
|
-
var coin = (
|
|
726
|
+
var decemialCount = ((_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().includes(".")) ? (_o = (_m = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _m === void 0 ? void 0 : _m.toString().split(" ")[0].split(".")[1]) === null || _o === void 0 ? void 0 : _o.length : 0;
|
|
727
|
+
var coin = (_p = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _p === void 0 ? void 0 : _p.toString().split(" ")[1];
|
|
727
728
|
if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
|
|
728
729
|
value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount || 2), " ").concat(coin);
|
|
729
730
|
}
|
|
@@ -739,7 +740,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
739
740
|
} else if (_typeof(value) === "object" && !value.tb) {
|
|
740
741
|
value.tb = "1";
|
|
741
742
|
}
|
|
742
|
-
var isValueArray = Array.isArray((
|
|
743
|
+
var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
|
|
743
744
|
try {
|
|
744
745
|
if (isValueArray) {
|
|
745
746
|
if (spillSortResult(ctx, r, c, value, d)) {
|
|
@@ -763,8 +764,8 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
763
764
|
if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
|
|
764
765
|
var defaultrowlen = ctx.defaultrowlen;
|
|
765
766
|
var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
|
|
766
|
-
if (!(((
|
|
767
|
-
var cellWidth = ((
|
|
767
|
+
if (!(((_r = cfg.columnlen) === null || _r === void 0 ? void 0 : _r[c]) && ((_s = cfg.rowlen) === null || _s === void 0 ? void 0 : _s[r]))) {
|
|
768
|
+
var cellWidth = ((_t = cfg.columnlen) === null || _t === void 0 ? void 0 : _t[c]) || ctx.defaultcollen;
|
|
768
769
|
var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
|
|
769
770
|
r: r,
|
|
770
771
|
c: c,
|
|
@@ -775,7 +776,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
775
776
|
currentRowLen = textInfo.textHeightAll + 2;
|
|
776
777
|
}
|
|
777
778
|
var previousRowHeight = getRowHeight(ctx, [r])[r];
|
|
778
|
-
if (currentRowLen > defaultrowlen && !((
|
|
779
|
+
if (currentRowLen > defaultrowlen && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
|
|
779
780
|
if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
780
781
|
cfg.rowlen[r] = currentRowLen;
|
|
781
782
|
}
|
package/es/modules/formula.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare function createFormulaRangeSelect(ctx: Context, select: {
|
|
|
40
40
|
} & Rect): void;
|
|
41
41
|
export declare function createRangeHightlight(ctx: Context, inputInnerHtmlStr: string, ignoreRangeIndex?: number): void;
|
|
42
42
|
export declare function setCaretPosition(ctx: Context, textDom: HTMLElement, children: number, pos: number): void;
|
|
43
|
+
export declare function moveCursorToEnd(editableDiv: HTMLDivElement): void;
|
|
43
44
|
export declare function getrangeseleciton(): ParentNode | ChildNode | null | undefined;
|
|
44
45
|
export declare function rangeHightlightselected(ctx: Context, $editor: HTMLDivElement): void;
|
|
45
46
|
export declare function functionHTMLGenerate(txt: string): string;
|
package/es/modules/formula.js
CHANGED
|
@@ -24,7 +24,6 @@ import { getFlowdata } from "../context";
|
|
|
24
24
|
import { columnCharToIndex, escapeScriptTag, getSheetIndex, indexToColumnChar, getSheetIdByName, escapeHTMLTag } from "../utils";
|
|
25
25
|
import { getcellFormula, getRangetxt, mergeMoveMain, setCellValue } from "./cell";
|
|
26
26
|
import { error } from "./validation";
|
|
27
|
-
import { moveToEnd } from "./cursor";
|
|
28
27
|
import { locale } from "../locale";
|
|
29
28
|
import { colors } from "./color";
|
|
30
29
|
import { colLocation, mousePosition, rowLocation } from "./location";
|
|
@@ -1237,7 +1236,18 @@ export function setCaretPosition(ctx, textDom, children, pos) {
|
|
|
1237
1236
|
el.focus();
|
|
1238
1237
|
} catch (err) {
|
|
1239
1238
|
console.error(err);
|
|
1240
|
-
|
|
1239
|
+
moveCursorToEnd(textDom);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
export function moveCursorToEnd(editableDiv) {
|
|
1243
|
+
editableDiv.focus();
|
|
1244
|
+
var range = document.createRange();
|
|
1245
|
+
var selection = window.getSelection();
|
|
1246
|
+
range.selectNodeContents(editableDiv);
|
|
1247
|
+
range.collapse(false);
|
|
1248
|
+
if (selection) {
|
|
1249
|
+
selection.removeAllRanges();
|
|
1250
|
+
selection.addRange(range);
|
|
1241
1251
|
}
|
|
1242
1252
|
}
|
|
1243
1253
|
function functionRange(ctx, obj, v, vp) {
|
package/es/utils/index.js
CHANGED
|
@@ -212,8 +212,16 @@ export function removeLastSpan(htmlString) {
|
|
|
212
212
|
}
|
|
213
213
|
export function getContentInParentheses(str) {
|
|
214
214
|
if (!str) return null;
|
|
215
|
-
var
|
|
216
|
-
|
|
215
|
+
var parenMatch = str.match(/\(([^)]+)\)/);
|
|
216
|
+
if (parenMatch) return parenMatch[1];
|
|
217
|
+
var formulaMatch = str.match(/^=([\w\d:+\-*/]+)$/);
|
|
218
|
+
if (formulaMatch) {
|
|
219
|
+
var refs = formulaMatch[1].split(/[\+\-\*\/]/).map(function (part) {
|
|
220
|
+
return part.trim();
|
|
221
|
+
}).filter(Boolean);
|
|
222
|
+
return refs.join(",");
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
217
225
|
}
|
|
218
226
|
export function processArray(cellReferences, d, flowData) {
|
|
219
227
|
function isValidCellReference(cell) {
|
|
@@ -224,10 +232,10 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
224
232
|
var match = cell.match(/^([A-Za-z]+)(\d+)$/);
|
|
225
233
|
if (!match) return null;
|
|
226
234
|
var letters = match[1].toLowerCase();
|
|
227
|
-
var number = parseInt(match[2]);
|
|
235
|
+
var number = parseInt(match[2], 10);
|
|
228
236
|
var col = 0;
|
|
229
|
-
for (var i = 0; i < letters.length; i
|
|
230
|
-
col = col * 26 + (letters.charCodeAt(i) -
|
|
237
|
+
for (var i = 0; i < letters.length; i += 1) {
|
|
238
|
+
col = col * 26 + (letters.charCodeAt(i) - "a".charCodeAt(0) + 1);
|
|
231
239
|
}
|
|
232
240
|
col -= 1;
|
|
233
241
|
var row = number - 1;
|
|
@@ -238,32 +246,31 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
238
246
|
row: row
|
|
239
247
|
};
|
|
240
248
|
}
|
|
241
|
-
var validCellReferences = cellReferences.filter(function (cellRef) {
|
|
242
|
-
if (cellRef.includes(
|
|
243
|
-
var _a = cellRef.split(
|
|
249
|
+
var validCellReferences = cellReferences === null || cellReferences === void 0 ? void 0 : cellReferences.filter(function (cellRef) {
|
|
250
|
+
if (cellRef.includes(":")) {
|
|
251
|
+
var _a = cellRef.split(":"),
|
|
244
252
|
startCell = _a[0],
|
|
245
253
|
endCell = _a[1];
|
|
246
254
|
return isValidCellReference(startCell.trim()) && isValidCellReference(endCell.trim());
|
|
247
|
-
} else {
|
|
248
|
-
return isValidCellReference(cellRef.trim());
|
|
249
255
|
}
|
|
256
|
+
return isValidCellReference(cellRef.trim());
|
|
250
257
|
});
|
|
251
258
|
var expandedCellReferences = [];
|
|
252
|
-
validCellReferences.forEach(function (cellRef) {
|
|
253
|
-
if (cellRef.includes(
|
|
254
|
-
var _a = cellRef.split(
|
|
259
|
+
validCellReferences === null || validCellReferences === void 0 ? void 0 : validCellReferences.forEach(function (cellRef) {
|
|
260
|
+
if (cellRef.includes(":")) {
|
|
261
|
+
var _a = cellRef.split(":"),
|
|
255
262
|
startCell = _a[0],
|
|
256
263
|
endCell = _a[1];
|
|
257
264
|
var startParsed = parseCellReference(startCell.trim());
|
|
258
265
|
var endParsed = parseCellReference(endCell.trim());
|
|
259
266
|
if (!startParsed || !endParsed) return;
|
|
260
|
-
for (var row = startParsed.number; row <= endParsed.number; row
|
|
261
|
-
for (var col = startParsed.col; col <= endParsed.col; col
|
|
262
|
-
var letters =
|
|
267
|
+
for (var row = startParsed.number; row <= endParsed.number; row += 1) {
|
|
268
|
+
for (var col = startParsed.col; col <= endParsed.col; col += 1) {
|
|
269
|
+
var letters = "";
|
|
263
270
|
var tempCol = col + 1;
|
|
264
271
|
while (tempCol > 0) {
|
|
265
|
-
tempCol
|
|
266
|
-
letters = String.fromCharCode(
|
|
272
|
+
tempCol -= 1;
|
|
273
|
+
letters = String.fromCharCode("A".charCodeAt(0) + tempCol % 26) + letters;
|
|
267
274
|
tempCol = Math.floor(tempCol / 26);
|
|
268
275
|
}
|
|
269
276
|
var cellName = letters + row;
|
|
@@ -283,15 +290,15 @@ export function processArray(cellReferences, d, flowData) {
|
|
|
283
290
|
}
|
|
284
291
|
});
|
|
285
292
|
var formated;
|
|
286
|
-
coordinates.forEach(function (coord
|
|
293
|
+
coordinates.forEach(function (coord) {
|
|
287
294
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
288
295
|
var row = coord[0],
|
|
289
296
|
col = coord[1];
|
|
290
297
|
if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
|
|
291
|
-
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes(
|
|
292
|
-
formated =
|
|
293
|
-
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes(
|
|
294
|
-
formated =
|
|
298
|
+
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
|
|
299
|
+
formated = "#,##0";
|
|
300
|
+
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
|
|
301
|
+
formated = "#,##0.00";
|
|
295
302
|
}
|
|
296
303
|
}
|
|
297
304
|
});
|
package/lib/events/mouse.js
CHANGED
|
@@ -197,7 +197,7 @@ function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, container, fxIn
|
|
|
197
197
|
var spans = doc.querySelectorAll("span");
|
|
198
198
|
var firstSpan = spans[0];
|
|
199
199
|
var lastSpan = spans[spans.length - 1];
|
|
200
|
-
if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx)
|
|
200
|
+
if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx)) {
|
|
201
201
|
var rowseleted = [row_index, row_index_ed];
|
|
202
202
|
var columnseleted = [col_index, col_index_ed];
|
|
203
203
|
var left = col_pre;
|
package/lib/modules/cell.js
CHANGED
|
@@ -123,7 +123,8 @@ function getCellValue(r, c, data, attr) {
|
|
|
123
123
|
return retv;
|
|
124
124
|
}
|
|
125
125
|
function setCellValue(ctx, r, c, d, v) {
|
|
126
|
-
var _a, _b, _c, _d, _e, _f;
|
|
126
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
127
|
+
console.log("setCellValue", r, c, v);
|
|
127
128
|
if (_lodash.default.isNil(d)) {
|
|
128
129
|
d = (0, _context.getFlowdata)(ctx);
|
|
129
130
|
}
|
|
@@ -157,12 +158,10 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
157
158
|
vupdate = v;
|
|
158
159
|
}
|
|
159
160
|
var commaPresent = false;
|
|
160
|
-
var decimalPresent = false;
|
|
161
161
|
if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
|
|
162
162
|
commaPresent = vupdate.includes(",");
|
|
163
|
-
decimalPresent = vupdate.includes(".");
|
|
164
163
|
var removeCommasValidated = function removeCommasValidated(str) {
|
|
165
|
-
return /^[\d
|
|
164
|
+
return /^[\d,.]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
|
|
166
165
|
};
|
|
167
166
|
vupdate = removeCommasValidated(vupdate);
|
|
168
167
|
}
|
|
@@ -303,13 +302,15 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
303
302
|
}
|
|
304
303
|
}
|
|
305
304
|
cell.v = vupdate;
|
|
305
|
+
var strValue = String(vupdate);
|
|
306
306
|
var format = void 0;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
var hasDecimal = strValue.includes(".");
|
|
308
|
+
var hasComma = commaPresent;
|
|
309
|
+
if (hasDecimal) {
|
|
310
|
+
var decimalCount = ((_g = strValue.split(".")[1]) === null || _g === void 0 ? void 0 : _g.length) || 0;
|
|
311
|
+
format = hasComma ? "#,##0.".concat("0".repeat(decimalCount)) : "0.".concat("0".repeat(decimalCount));
|
|
312
|
+
} else if (hasComma) {
|
|
313
|
+
format = "#,##0";
|
|
313
314
|
} else {
|
|
314
315
|
format = "0";
|
|
315
316
|
}
|
|
@@ -530,7 +531,7 @@ function cancelNormalSelected(ctx) {
|
|
|
530
531
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
531
532
|
}
|
|
532
533
|
function updateCell(ctx, r, c, $input, value, canvas) {
|
|
533
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
534
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
534
535
|
console.log("updateCell", r, c, $input, value);
|
|
535
536
|
var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
|
|
536
537
|
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
@@ -700,8 +701,8 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
700
701
|
f: v[2]
|
|
701
702
|
};
|
|
702
703
|
if (/^[\d.,]+$/.test(value.v)) {
|
|
703
|
-
var args = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f).split(
|
|
704
|
-
var cellRefs = args.map(function (arg) {
|
|
704
|
+
var args = (_k = (0, _utils.getContentInParentheses)(value === null || value === void 0 ? void 0 : value.f)) === null || _k === void 0 ? void 0 : _k.split(",");
|
|
705
|
+
var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
705
706
|
return arg.trim().toUpperCase();
|
|
706
707
|
});
|
|
707
708
|
var formatted = (0, _utils.processArray)(cellRefs, d, flowdata);
|
|
@@ -752,8 +753,8 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
752
753
|
isRunExecFunction = false;
|
|
753
754
|
}
|
|
754
755
|
}
|
|
755
|
-
var decemialCount = ((
|
|
756
|
-
var coin = (
|
|
756
|
+
var decemialCount = ((_l = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _l === void 0 ? void 0 : _l.toString().includes(".")) ? (_o = (_m = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _m === void 0 ? void 0 : _m.toString().split(" ")[0].split(".")[1]) === null || _o === void 0 ? void 0 : _o.length : 0;
|
|
757
|
+
var coin = (_p = oldValue === null || oldValue === void 0 ? void 0 : oldValue.m) === null || _p === void 0 ? void 0 : _p.toString().split(" ")[1];
|
|
757
758
|
if (_typeof(value) === "object" && value.baseValue && !(value === null || value === void 0 ? void 0 : value.m)) {
|
|
758
759
|
value.m = "".concat((parseFloat(value === null || value === void 0 ? void 0 : value.v) / (oldValue === null || oldValue === void 0 ? void 0 : oldValue.baseCurrencyPrice)).toFixed(decemialCount || 2), " ").concat(coin);
|
|
759
760
|
}
|
|
@@ -769,7 +770,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
769
770
|
} else if (_typeof(value) === "object" && !value.tb) {
|
|
770
771
|
value.tb = "1";
|
|
771
772
|
}
|
|
772
|
-
var isValueArray = Array.isArray((
|
|
773
|
+
var isValueArray = Array.isArray((_q = value === null || value === void 0 ? void 0 : value.v) === null || _q === void 0 ? void 0 : _q[0]);
|
|
773
774
|
try {
|
|
774
775
|
if (isValueArray) {
|
|
775
776
|
if ((0, _sort.spillSortResult)(ctx, r, c, value, d)) {
|
|
@@ -793,8 +794,8 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
793
794
|
if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
|
|
794
795
|
var defaultrowlen = ctx.defaultrowlen;
|
|
795
796
|
var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
|
|
796
|
-
if (!(((
|
|
797
|
-
var cellWidth = ((
|
|
797
|
+
if (!(((_r = cfg.columnlen) === null || _r === void 0 ? void 0 : _r[c]) && ((_s = cfg.rowlen) === null || _s === void 0 ? void 0 : _s[r]))) {
|
|
798
|
+
var cellWidth = ((_t = cfg.columnlen) === null || _t === void 0 ? void 0 : _t[c]) || ctx.defaultcollen;
|
|
798
799
|
var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
|
|
799
800
|
r: r,
|
|
800
801
|
c: c,
|
|
@@ -805,7 +806,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
805
806
|
currentRowLen = textInfo.textHeightAll + 2;
|
|
806
807
|
}
|
|
807
808
|
var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
|
|
808
|
-
if (currentRowLen > defaultrowlen && !((
|
|
809
|
+
if (currentRowLen > defaultrowlen && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
|
|
809
810
|
if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
810
811
|
cfg.rowlen[r] = currentRowLen;
|
|
811
812
|
}
|
package/lib/modules/formula.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare function createFormulaRangeSelect(ctx: Context, select: {
|
|
|
40
40
|
} & Rect): void;
|
|
41
41
|
export declare function createRangeHightlight(ctx: Context, inputInnerHtmlStr: string, ignoreRangeIndex?: number): void;
|
|
42
42
|
export declare function setCaretPosition(ctx: Context, textDom: HTMLElement, children: number, pos: number): void;
|
|
43
|
+
export declare function moveCursorToEnd(editableDiv: HTMLDivElement): void;
|
|
43
44
|
export declare function getrangeseleciton(): ParentNode | ChildNode | null | undefined;
|
|
44
45
|
export declare function rangeHightlightselected(ctx: Context, $editor: HTMLDivElement): void;
|
|
45
46
|
export declare function functionHTMLGenerate(txt: string): string;
|
package/lib/modules/formula.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.handleFormulaInput = handleFormulaInput;
|
|
|
20
20
|
exports.insertUpdateFunctionGroup = insertUpdateFunctionGroup;
|
|
21
21
|
exports.iscelldata = iscelldata;
|
|
22
22
|
exports.israngeseleciton = israngeseleciton;
|
|
23
|
+
exports.moveCursorToEnd = moveCursorToEnd;
|
|
23
24
|
exports.onFormulaRangeDragEnd = onFormulaRangeDragEnd;
|
|
24
25
|
exports.rangeDrag = rangeDrag;
|
|
25
26
|
exports.rangeDragColumn = rangeDragColumn;
|
|
@@ -33,7 +34,6 @@ var _context = require("../context");
|
|
|
33
34
|
var _utils = require("../utils");
|
|
34
35
|
var _cell = require("./cell");
|
|
35
36
|
var _validation = require("./validation");
|
|
36
|
-
var _cursor = require("./cursor");
|
|
37
37
|
var _locale = require("../locale");
|
|
38
38
|
var _color = require("./color");
|
|
39
39
|
var _location = require("./location");
|
|
@@ -1266,7 +1266,18 @@ function setCaretPosition(ctx, textDom, children, pos) {
|
|
|
1266
1266
|
el.focus();
|
|
1267
1267
|
} catch (err) {
|
|
1268
1268
|
console.error(err);
|
|
1269
|
-
(
|
|
1269
|
+
moveCursorToEnd(textDom);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function moveCursorToEnd(editableDiv) {
|
|
1273
|
+
editableDiv.focus();
|
|
1274
|
+
var range = document.createRange();
|
|
1275
|
+
var selection = window.getSelection();
|
|
1276
|
+
range.selectNodeContents(editableDiv);
|
|
1277
|
+
range.collapse(false);
|
|
1278
|
+
if (selection) {
|
|
1279
|
+
selection.removeAllRanges();
|
|
1280
|
+
selection.addRange(range);
|
|
1270
1281
|
}
|
|
1271
1282
|
}
|
|
1272
1283
|
function functionRange(ctx, obj, v, vp) {
|
package/lib/utils/index.js
CHANGED
|
@@ -280,8 +280,16 @@ function removeLastSpan(htmlString) {
|
|
|
280
280
|
}
|
|
281
281
|
function getContentInParentheses(str) {
|
|
282
282
|
if (!str) return null;
|
|
283
|
-
var
|
|
284
|
-
|
|
283
|
+
var parenMatch = str.match(/\(([^)]+)\)/);
|
|
284
|
+
if (parenMatch) return parenMatch[1];
|
|
285
|
+
var formulaMatch = str.match(/^=([\w\d:+\-*/]+)$/);
|
|
286
|
+
if (formulaMatch) {
|
|
287
|
+
var refs = formulaMatch[1].split(/[\+\-\*\/]/).map(function (part) {
|
|
288
|
+
return part.trim();
|
|
289
|
+
}).filter(Boolean);
|
|
290
|
+
return refs.join(",");
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
285
293
|
}
|
|
286
294
|
function processArray(cellReferences, d, flowData) {
|
|
287
295
|
function isValidCellReference(cell) {
|
|
@@ -292,10 +300,10 @@ function processArray(cellReferences, d, flowData) {
|
|
|
292
300
|
var match = cell.match(/^([A-Za-z]+)(\d+)$/);
|
|
293
301
|
if (!match) return null;
|
|
294
302
|
var letters = match[1].toLowerCase();
|
|
295
|
-
var number = parseInt(match[2]);
|
|
303
|
+
var number = parseInt(match[2], 10);
|
|
296
304
|
var col = 0;
|
|
297
|
-
for (var i = 0; i < letters.length; i
|
|
298
|
-
col = col * 26 + (letters.charCodeAt(i) -
|
|
305
|
+
for (var i = 0; i < letters.length; i += 1) {
|
|
306
|
+
col = col * 26 + (letters.charCodeAt(i) - "a".charCodeAt(0) + 1);
|
|
299
307
|
}
|
|
300
308
|
col -= 1;
|
|
301
309
|
var row = number - 1;
|
|
@@ -306,32 +314,31 @@ function processArray(cellReferences, d, flowData) {
|
|
|
306
314
|
row: row
|
|
307
315
|
};
|
|
308
316
|
}
|
|
309
|
-
var validCellReferences = cellReferences.filter(function (cellRef) {
|
|
310
|
-
if (cellRef.includes(
|
|
311
|
-
var _a = cellRef.split(
|
|
317
|
+
var validCellReferences = cellReferences === null || cellReferences === void 0 ? void 0 : cellReferences.filter(function (cellRef) {
|
|
318
|
+
if (cellRef.includes(":")) {
|
|
319
|
+
var _a = cellRef.split(":"),
|
|
312
320
|
startCell = _a[0],
|
|
313
321
|
endCell = _a[1];
|
|
314
322
|
return isValidCellReference(startCell.trim()) && isValidCellReference(endCell.trim());
|
|
315
|
-
} else {
|
|
316
|
-
return isValidCellReference(cellRef.trim());
|
|
317
323
|
}
|
|
324
|
+
return isValidCellReference(cellRef.trim());
|
|
318
325
|
});
|
|
319
326
|
var expandedCellReferences = [];
|
|
320
|
-
validCellReferences.forEach(function (cellRef) {
|
|
321
|
-
if (cellRef.includes(
|
|
322
|
-
var _a = cellRef.split(
|
|
327
|
+
validCellReferences === null || validCellReferences === void 0 ? void 0 : validCellReferences.forEach(function (cellRef) {
|
|
328
|
+
if (cellRef.includes(":")) {
|
|
329
|
+
var _a = cellRef.split(":"),
|
|
323
330
|
startCell = _a[0],
|
|
324
331
|
endCell = _a[1];
|
|
325
332
|
var startParsed = parseCellReference(startCell.trim());
|
|
326
333
|
var endParsed = parseCellReference(endCell.trim());
|
|
327
334
|
if (!startParsed || !endParsed) return;
|
|
328
|
-
for (var row = startParsed.number; row <= endParsed.number; row
|
|
329
|
-
for (var col = startParsed.col; col <= endParsed.col; col
|
|
330
|
-
var letters =
|
|
335
|
+
for (var row = startParsed.number; row <= endParsed.number; row += 1) {
|
|
336
|
+
for (var col = startParsed.col; col <= endParsed.col; col += 1) {
|
|
337
|
+
var letters = "";
|
|
331
338
|
var tempCol = col + 1;
|
|
332
339
|
while (tempCol > 0) {
|
|
333
|
-
tempCol
|
|
334
|
-
letters = String.fromCharCode(
|
|
340
|
+
tempCol -= 1;
|
|
341
|
+
letters = String.fromCharCode("A".charCodeAt(0) + tempCol % 26) + letters;
|
|
335
342
|
tempCol = Math.floor(tempCol / 26);
|
|
336
343
|
}
|
|
337
344
|
var cellName = letters + row;
|
|
@@ -351,15 +358,15 @@ function processArray(cellReferences, d, flowData) {
|
|
|
351
358
|
}
|
|
352
359
|
});
|
|
353
360
|
var formated;
|
|
354
|
-
coordinates.forEach(function (coord
|
|
361
|
+
coordinates.forEach(function (coord) {
|
|
355
362
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
356
363
|
var row = coord[0],
|
|
357
364
|
col = coord[1];
|
|
358
365
|
if (row >= 0 && row < d.length && col >= 0 && col < d[row].length) {
|
|
359
|
-
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes(
|
|
360
|
-
formated =
|
|
361
|
-
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes(
|
|
362
|
-
formated =
|
|
366
|
+
if (((_b = (_a = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.fa) && ((_e = (_d = (_c = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _c === void 0 ? void 0 : _c.ct) === null || _d === void 0 ? void 0 : _d.fa) === null || _e === void 0 ? void 0 : _e.includes("#,##0"))) {
|
|
367
|
+
formated = "#,##0";
|
|
368
|
+
} else if (((_g = (_f = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _f === void 0 ? void 0 : _f.ct) === null || _g === void 0 ? void 0 : _g.fa) && ((_k = (_j = (_h = flowData === null || flowData === void 0 ? void 0 : flowData[row][col]) === null || _h === void 0 ? void 0 : _h.ct) === null || _j === void 0 ? void 0 : _j.fa) === null || _k === void 0 ? void 0 : _k.includes("#,##0.00"))) {
|
|
369
|
+
formated = "#,##0.00";
|
|
363
370
|
}
|
|
364
371
|
}
|
|
365
372
|
});
|