@fileverse-dev/fortune-core 1.1.67 → 1.1.68
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/api/index.d.ts +1 -0
- package/es/api/index.js +2 -1
- package/es/canvas.js +25 -0
- package/es/context.d.ts +3 -1
- package/es/events/mouse.js +2 -1
- package/es/modules/cell.d.ts +3 -0
- package/es/modules/cell.js +85 -1
- package/es/modules/error-state-helpers.d.ts +5 -0
- package/es/modules/error-state-helpers.js +82 -0
- package/es/modules/formula.js +15 -4
- package/es/modules/hyperlink.js +4 -4
- package/es/modules/index.d.ts +1 -0
- package/es/modules/index.js +2 -1
- package/es/modules/validation.d.ts +3 -0
- package/es/modules/validation.js +12 -0
- package/es/settings.js +2 -2
- package/es/types.d.ts +8 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +12 -0
- package/lib/canvas.js +25 -0
- package/lib/context.d.ts +3 -1
- package/lib/events/mouse.js +1 -0
- package/lib/modules/cell.d.ts +3 -0
- package/lib/modules/cell.js +87 -0
- package/lib/modules/error-state-helpers.d.ts +5 -0
- package/lib/modules/error-state-helpers.js +91 -0
- package/lib/modules/formula.js +13 -2
- package/lib/modules/hyperlink.js +4 -4
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/modules/validation.d.ts +3 -0
- package/lib/modules/validation.js +15 -1
- package/lib/settings.js +2 -2
- package/lib/types.d.ts +8 -0
- package/package.json +1 -1
package/es/api/index.d.ts
CHANGED
package/es/api/index.js
CHANGED
package/es/canvas.js
CHANGED
|
@@ -1121,6 +1121,31 @@ var Canvas = function () {
|
|
|
1121
1121
|
endX: cellsize[2] + cellsize[0],
|
|
1122
1122
|
endY: cellsize[3] + cellsize[1]
|
|
1123
1123
|
}, renderCtx);
|
|
1124
|
+
if (cell === null || cell === void 0 ? void 0 : cell.error) {
|
|
1125
|
+
var errorBorderColor = "#FB3449";
|
|
1126
|
+
var borderThicknessInPixels = 1;
|
|
1127
|
+
var leftCellBoundary = Math.round(startX + offsetLeft - 3 + bodrder05);
|
|
1128
|
+
var topCellBoundary = Math.round(startY + offsetTop - 3 + bodrder05);
|
|
1129
|
+
var rightCellBoundary = Math.round(endX + offsetLeft - 3 + bodrder05);
|
|
1130
|
+
var bottomCellBoundary = Math.round(endY + offsetTop - 3 + bodrder05);
|
|
1131
|
+
var innerCellWidth = rightCellBoundary - leftCellBoundary;
|
|
1132
|
+
var innerCellHeight = bottomCellBoundary - topCellBoundary;
|
|
1133
|
+
var renderingContext = renderCtx;
|
|
1134
|
+
renderingContext.save();
|
|
1135
|
+
renderingContext.fillStyle = errorBorderColor;
|
|
1136
|
+
renderingContext.fillRect(leftCellBoundary, topCellBoundary, innerCellWidth, borderThicknessInPixels);
|
|
1137
|
+
renderingContext.fillRect(leftCellBoundary, bottomCellBoundary - borderThicknessInPixels, innerCellWidth, borderThicknessInPixels);
|
|
1138
|
+
renderingContext.fillRect(leftCellBoundary, topCellBoundary, borderThicknessInPixels, innerCellHeight);
|
|
1139
|
+
renderingContext.fillRect(rightCellBoundary - borderThicknessInPixels, topCellBoundary, borderThicknessInPixels, innerCellHeight);
|
|
1140
|
+
var errorRibbonSize = 8 * this.sheetCtx.zoomRatio;
|
|
1141
|
+
renderingContext.beginPath();
|
|
1142
|
+
renderingContext.moveTo(leftCellBoundary + borderThicknessInPixels, topCellBoundary + borderThicknessInPixels);
|
|
1143
|
+
renderingContext.lineTo(leftCellBoundary + borderThicknessInPixels + errorRibbonSize, topCellBoundary + borderThicknessInPixels);
|
|
1144
|
+
renderingContext.lineTo(leftCellBoundary + borderThicknessInPixels, topCellBoundary + borderThicknessInPixels + errorRibbonSize);
|
|
1145
|
+
renderingContext.closePath();
|
|
1146
|
+
renderingContext.fill();
|
|
1147
|
+
renderingContext.restore();
|
|
1148
|
+
}
|
|
1124
1149
|
};
|
|
1125
1150
|
Canvas.prototype.cellOverflowRender = function (r, c, stc, edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute) {
|
|
1126
1151
|
var startY;
|
package/es/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SheetConfig } from ".";
|
|
2
2
|
import { FormulaCache } from "./modules";
|
|
3
3
|
import { Hooks } from "./settings";
|
|
4
|
-
import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache } from "./types";
|
|
4
|
+
import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from "./types";
|
|
5
5
|
interface MutableRefObject<T> {
|
|
6
6
|
current: T;
|
|
7
7
|
}
|
|
@@ -21,8 +21,10 @@ export type Context = {
|
|
|
21
21
|
fullscreenmode: boolean;
|
|
22
22
|
devicePixelRatio: number;
|
|
23
23
|
commentBoxes?: CommentBox[];
|
|
24
|
+
errorBoxes?: CellError[];
|
|
24
25
|
editingCommentBox?: CommentBox;
|
|
25
26
|
hoveredCommentBox?: CommentBox;
|
|
27
|
+
hoverErrorBox?: CellError;
|
|
26
28
|
insertedImgs?: Image[];
|
|
27
29
|
editingInsertedImgs?: Image;
|
|
28
30
|
activeImg?: string;
|
package/es/events/mouse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import { getFlowdata } from "../context";
|
|
3
|
-
import { cancelActiveImgItem, cancelPaintModel, functionHTMLGenerate, israngeseleciton, rangeHightlightselected, rangeSetValue, onCommentBoxMove, onCommentBoxMoveEnd, onCommentBoxResize, onCommentBoxResizeEnd, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, removeEditingComment, overShowComment, removeOverShowComment, rangeDrag, onFormulaRangeDragEnd, createFormulaRangeSelect, createRangeHightlight, onCellsMoveEnd, onCellsMove, cellFocus, editComment, onIframeMoveEnd, onIframeResizeEnd } from "../modules";
|
|
3
|
+
import { cancelActiveImgItem, cancelPaintModel, functionHTMLGenerate, israngeseleciton, rangeHightlightselected, rangeSetValue, onCommentBoxMove, onCommentBoxMoveEnd, onCommentBoxResize, onCommentBoxResizeEnd, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, removeEditingComment, overShowComment, removeOverShowComment, rangeDrag, onFormulaRangeDragEnd, createFormulaRangeSelect, createRangeHightlight, onCellsMoveEnd, onCellsMove, cellFocus, editComment, onIframeMoveEnd, onIframeResizeEnd, overShowError } from "../modules";
|
|
4
4
|
import { getFrozenHandleLeft, getFrozenHandleTop, scrollToFrozenRowCol } from "../modules/freeze";
|
|
5
5
|
import { cancelFunctionrangeSelected, mergeBorder, mergeMoveMain, updateCell, luckysheetUpdateCell } from "../modules/cell";
|
|
6
6
|
import { colLocation, colLocationByIndex, rowLocation, rowLocationByIndex } from "../modules/location";
|
|
@@ -899,6 +899,7 @@ export function handleOverlayMouseMove(ctx, globalCache, e, cellInput, scrollX,
|
|
|
899
899
|
if (onImageResize(ctx, globalCache, e)) return;
|
|
900
900
|
onCellsMove(ctx, globalCache, e, scrollX, scrollY, container);
|
|
901
901
|
overShowComment(ctx, e, scrollX, scrollY, container);
|
|
902
|
+
overShowError(ctx, e, scrollX, scrollY, container);
|
|
902
903
|
onSearchDialogMove(globalCache, e);
|
|
903
904
|
onRangeSelectionModalMove(globalCache, e);
|
|
904
905
|
if (!!ctx.luckysheet_scroll_status || !!ctx.luckysheet_select_status || !!ctx.luckysheet_rows_selected_status || !!ctx.luckysheet_cols_selected_status || !!ctx.luckysheet_cell_selected_move || !!ctx.luckysheet_cell_selected_extend || !!ctx.luckysheet_cols_change_size || !!ctx.luckysheet_rows_change_size) {
|
package/es/modules/cell.d.ts
CHANGED
|
@@ -30,3 +30,6 @@ export declare function getQKBorder(width: string, type: string, color: string):
|
|
|
30
30
|
export declare function getdatabyselection(ctx: Context, range: Selection | undefined, sheetId: string): (Cell | null)[][];
|
|
31
31
|
export declare function luckysheetUpdateCell(ctx: Context, row_index: number, col_index: number): void;
|
|
32
32
|
export declare function getDataBySelectionNoCopy(ctx: Context, range: Selection): (Cell | null)[][];
|
|
33
|
+
export declare function clearSelectedCellFormat(ctx: Context): void;
|
|
34
|
+
export declare function clearRowsCellsFormat(ctx: Context): void;
|
|
35
|
+
export declare function clearColumnsCellsFormat(ctx: Context): void;
|
package/es/modules/cell.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getSheetIndex, indexToColumnChar, rgbToHex, processArray, getContentInP
|
|
|
5
5
|
import { checkCF, getComputeMap } from "./ConditionFormat";
|
|
6
6
|
import { getFailureText, validateCellData } from "./dataVerification";
|
|
7
7
|
import { genarate, update } from "./format";
|
|
8
|
-
import { getRowHeight } from "../api";
|
|
8
|
+
import { clearCellError, getRowHeight } from "../api";
|
|
9
9
|
import { delFunctionGroup, execfunction, execFunctionGroup, functionHTMLGenerate, getcellrange, iscelldata } from "./formula";
|
|
10
10
|
import { attrToCssName, convertSpanToShareString, isInlineStringCell, isInlineStringCT } from "./inline-string";
|
|
11
11
|
import { isRealNull, isRealNum, valueIsError } from "./validation";
|
|
@@ -633,8 +633,10 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
633
633
|
Object.keys(value).forEach(function (attr) {
|
|
634
634
|
curv[attr] = value[attr];
|
|
635
635
|
});
|
|
636
|
+
clearCellError(ctx, r, c);
|
|
636
637
|
}
|
|
637
638
|
} else {
|
|
639
|
+
clearCellError(ctx, r, c);
|
|
638
640
|
delFunctionGroup(ctx, r, c);
|
|
639
641
|
curv = _.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
|
|
640
642
|
curv.v = value;
|
|
@@ -708,12 +710,14 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
708
710
|
dynamicArrayItem = v[3].data;
|
|
709
711
|
}
|
|
710
712
|
} else {
|
|
713
|
+
clearCellError(ctx, r, c);
|
|
711
714
|
var v = curv;
|
|
712
715
|
if (_.isNil(value.v)) {
|
|
713
716
|
value.v = v;
|
|
714
717
|
}
|
|
715
718
|
}
|
|
716
719
|
} else {
|
|
720
|
+
clearCellError(ctx, r, c);
|
|
717
721
|
delFunctionGroup(ctx, r, c);
|
|
718
722
|
execFunctionGroup(ctx, r, c, value);
|
|
719
723
|
isRunExecFunction = false;
|
|
@@ -1146,4 +1150,84 @@ export function getDataBySelectionNoCopy(ctx, range) {
|
|
|
1146
1150
|
data.push(row);
|
|
1147
1151
|
}
|
|
1148
1152
|
return data;
|
|
1153
|
+
}
|
|
1154
|
+
function keepOnlyValueParts(cell) {
|
|
1155
|
+
if (!cell) return cell !== null && cell !== void 0 ? cell : null;
|
|
1156
|
+
var rawValue = cell.v,
|
|
1157
|
+
displayText = cell.m,
|
|
1158
|
+
formula = cell.f;
|
|
1159
|
+
return rawValue !== undefined || displayText !== undefined || formula !== undefined ? {
|
|
1160
|
+
v: rawValue,
|
|
1161
|
+
m: displayText,
|
|
1162
|
+
f: formula
|
|
1163
|
+
} : null;
|
|
1164
|
+
}
|
|
1165
|
+
export function clearSelectedCellFormat(ctx) {
|
|
1166
|
+
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1167
|
+
if (activeSheetIndex == null) return;
|
|
1168
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1169
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1170
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1171
|
+
var sheetData = activeSheetFile.data;
|
|
1172
|
+
selectedRanges.forEach(function (_a) {
|
|
1173
|
+
var rowRange = _a.row,
|
|
1174
|
+
columnRange = _a.column;
|
|
1175
|
+
var startRow = rowRange[0],
|
|
1176
|
+
endRow = rowRange[1];
|
|
1177
|
+
var startColumn = columnRange[0],
|
|
1178
|
+
endColumn = columnRange[1];
|
|
1179
|
+
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1180
|
+
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1181
|
+
if (!rowCells) continue;
|
|
1182
|
+
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1183
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1184
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
export function clearRowsCellsFormat(ctx) {
|
|
1190
|
+
var _a, _b;
|
|
1191
|
+
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1192
|
+
if (activeSheetIndex == null) return;
|
|
1193
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1194
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1195
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1196
|
+
var sheetData = activeSheetFile.data;
|
|
1197
|
+
var columnCount = (_b = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1198
|
+
selectedRanges.forEach(function (_a) {
|
|
1199
|
+
var rowRange = _a.row;
|
|
1200
|
+
var startRow = rowRange[0],
|
|
1201
|
+
endRow = rowRange[1];
|
|
1202
|
+
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1203
|
+
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1204
|
+
if (!rowCells) continue;
|
|
1205
|
+
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
1206
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1207
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
export function clearColumnsCellsFormat(ctx) {
|
|
1213
|
+
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1214
|
+
if (activeSheetIndex == null) return;
|
|
1215
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1216
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1217
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1218
|
+
var sheetData = activeSheetFile.data;
|
|
1219
|
+
var rowCount = sheetData.length;
|
|
1220
|
+
selectedRanges.forEach(function (_a) {
|
|
1221
|
+
var columnRange = _a.column;
|
|
1222
|
+
var startColumn = columnRange[0],
|
|
1223
|
+
endColumn = columnRange[1];
|
|
1224
|
+
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1225
|
+
var rowCells = sheetData[rowIndex];
|
|
1226
|
+
if (!rowCells) continue;
|
|
1227
|
+
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1228
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1229
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1149
1233
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
2
|
+
import { CellError } from "../types";
|
|
3
|
+
export declare function overShowError(ctx: Context, e: MouseEvent, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement): void;
|
|
4
|
+
export declare function setCellError(ctx: Context, r: number, c: number, err: CellError): void;
|
|
5
|
+
export declare function clearCellError(ctx: Context, r: number, c: number): void;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
return __assign.apply(this, arguments);
|
|
10
|
+
};
|
|
11
|
+
import _ from "lodash";
|
|
12
|
+
import { getFlowdata } from "../context";
|
|
13
|
+
import { colLocation, rowLocation } from "./location";
|
|
14
|
+
import { mergeBorder } from "./cell";
|
|
15
|
+
export function overShowError(ctx, e, scrollX, scrollY, container) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
var _d, _e, _f, _g, _h;
|
|
18
|
+
var flowdata = getFlowdata(ctx);
|
|
19
|
+
if (!flowdata) return;
|
|
20
|
+
var scrollLeft = scrollX.scrollLeft;
|
|
21
|
+
var scrollTop = scrollY.scrollTop;
|
|
22
|
+
var rect = container.getBoundingClientRect();
|
|
23
|
+
var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
|
|
24
|
+
var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
|
|
25
|
+
var r = rowLocation(y, ctx.visibledatarow)[2];
|
|
26
|
+
var c = colLocation(x, ctx.visibledatacolumn)[2];
|
|
27
|
+
var merge = mergeBorder(ctx, flowdata, r, c);
|
|
28
|
+
if (merge) {
|
|
29
|
+
_a = merge.row, r = _a[2];
|
|
30
|
+
_b = merge.column, c = _b[2];
|
|
31
|
+
}
|
|
32
|
+
var firstSelection = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[0];
|
|
33
|
+
var row_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
34
|
+
var col_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
35
|
+
if (r === row_focus && c === col_focus) {
|
|
36
|
+
ctx.hoverErrorBox = undefined;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var row_column = "".concat(r, "_").concat(c);
|
|
40
|
+
var cell = (_e = flowdata[r]) === null || _e === void 0 ? void 0 : _e[c];
|
|
41
|
+
var err = cell === null || cell === void 0 ? void 0 : cell.error;
|
|
42
|
+
var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _.findIndex(ctx.errorBoxes, function (v) {
|
|
43
|
+
return v.row_column === row_column;
|
|
44
|
+
}) !== -1 : false;
|
|
45
|
+
if (!err || errorAlreadyListed) {
|
|
46
|
+
ctx.hoverErrorBox = undefined;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (((_f = ctx.hoverErrorBox) === null || _f === void 0 ? void 0 : _f.row_column) === row_column) return;
|
|
50
|
+
var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
|
|
51
|
+
var colLeft = ctx.visibledatacolumn[c];
|
|
52
|
+
if (merge) {
|
|
53
|
+
rowTop = merge.row[0];
|
|
54
|
+
_c = merge.column, colLeft = _c[1];
|
|
55
|
+
}
|
|
56
|
+
var toX = colLeft;
|
|
57
|
+
var toY = rowTop;
|
|
58
|
+
var zoom = ctx.zoomRatio;
|
|
59
|
+
var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
|
|
60
|
+
var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
|
|
61
|
+
if (top < 0) top = 2;
|
|
62
|
+
ctx.hoverErrorBox = {
|
|
63
|
+
row_column: row_column,
|
|
64
|
+
left: left,
|
|
65
|
+
top: top,
|
|
66
|
+
title: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.title) || "Error",
|
|
67
|
+
message: ((_h = cell.error) === null || _h === void 0 ? void 0 : _h.message) || "Default error message"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function setCellError(ctx, r, c, err) {
|
|
71
|
+
var flow = getFlowdata(ctx);
|
|
72
|
+
if (!flow) return;
|
|
73
|
+
if (!flow[r]) flow[r] = [];
|
|
74
|
+
if (!flow[r][c]) flow[r][c] = {};
|
|
75
|
+
flow[r][c].error = __assign({}, err);
|
|
76
|
+
}
|
|
77
|
+
export function clearCellError(ctx, r, c) {
|
|
78
|
+
var _a;
|
|
79
|
+
var flow = getFlowdata(ctx);
|
|
80
|
+
if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
|
|
81
|
+
delete flow[r][c].error;
|
|
82
|
+
}
|
package/es/modules/formula.js
CHANGED
|
@@ -18,16 +18,16 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
import _ from "lodash";
|
|
22
21
|
import { Parser, ERROR_REF } from "@fileverse-dev/formula-parser";
|
|
22
|
+
import _ from "lodash";
|
|
23
23
|
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
|
-
import { error } from "./validation";
|
|
26
|
+
import { customErrorMessage, error, detectErrorFromValue } from "./validation";
|
|
27
27
|
import { locale } from "../locale";
|
|
28
28
|
import { colors } from "./color";
|
|
29
29
|
import { colLocation, mousePosition, rowLocation } from "./location";
|
|
30
|
-
import { cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult } from ".";
|
|
30
|
+
import { cancelFunctionrangeSelected, clearCellError, seletedHighlistByindex, setCellError, spillSortResult } from ".";
|
|
31
31
|
import { isLetterNumberPattern, removeLastSpan } from "../utils/index";
|
|
32
32
|
var functionHTMLIndex = 0;
|
|
33
33
|
var rangeIndexes = [];
|
|
@@ -729,7 +729,18 @@ export function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notIns
|
|
|
729
729
|
var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
|
|
730
730
|
finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
|
|
731
731
|
}
|
|
732
|
-
|
|
732
|
+
var isError = !_.isNil(formulaError);
|
|
733
|
+
var detectedErrorFromValue = detectErrorFromValue(finalResult === null || finalResult === void 0 ? void 0 : finalResult.toString());
|
|
734
|
+
if (isError || detectedErrorFromValue) {
|
|
735
|
+
setCellError(ctx, r, c, {
|
|
736
|
+
row_column: "".concat(r, "_").concat(c),
|
|
737
|
+
title: "Error",
|
|
738
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || detectedErrorFromValue || "Unknown Error"
|
|
739
|
+
});
|
|
740
|
+
} else {
|
|
741
|
+
clearCellError(ctx, r, c);
|
|
742
|
+
}
|
|
743
|
+
return [true, !isError ? finalResult : customErrorMessage(formulaError), txt];
|
|
733
744
|
}
|
|
734
745
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
735
746
|
var r = dynamicArrayItem.r,
|
package/es/modules/hyperlink.js
CHANGED
|
@@ -62,6 +62,7 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export function removeHyperlink(ctx, r, c) {
|
|
65
|
+
var _a, _b, _c;
|
|
65
66
|
var allowEdit = isAllowEdit(ctx);
|
|
66
67
|
if (!allowEdit) return;
|
|
67
68
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -71,10 +72,9 @@ export function removeHyperlink(ctx, r, c) {
|
|
|
71
72
|
_.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
|
|
72
73
|
var cell = flowdata[r][c];
|
|
73
74
|
if (cell != null) {
|
|
74
|
-
flowdata[r][c]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
75
|
+
(_a = flowdata[r][c]) === null || _a === void 0 ? true : delete _a.hl;
|
|
76
|
+
(_b = flowdata[r][c]) === null || _b === void 0 ? true : delete _b.un;
|
|
77
|
+
(_c = flowdata[r][c]) === null || _c === void 0 ? true : delete _c.fc;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
ctx.linkCard = undefined;
|
package/es/modules/index.d.ts
CHANGED
package/es/modules/index.js
CHANGED
|
@@ -9,6 +9,9 @@ export declare const error: {
|
|
|
9
9
|
nl: string;
|
|
10
10
|
sp: string;
|
|
11
11
|
};
|
|
12
|
+
export declare const errorMessagesFromValue: Record<string, string>;
|
|
13
|
+
export declare function detectErrorFromValue(input: string): string;
|
|
14
|
+
export declare function customErrorMessage(errorMessage: string): string;
|
|
12
15
|
export declare function valueIsError(value: string): boolean;
|
|
13
16
|
export declare function isRealNull(val: any): boolean;
|
|
14
17
|
export declare function isHexValue(str: string): boolean;
|
package/es/modules/validation.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import dayjs from "dayjs";
|
|
2
3
|
import _ from "lodash";
|
|
4
|
+
import { error as cellErrorMessages, ERROR_NAME, ERROR_DIV_ZERO, ERROR_NULL, ERROR_NUM, ERROR_REF, ERROR_VALUE, ERROR } from "@fileverse-dev/formula-parser";
|
|
3
5
|
import { hasChinaword } from "./text";
|
|
4
6
|
export var error = {
|
|
5
7
|
v: "#VALUE!",
|
|
@@ -11,6 +13,16 @@ export var error = {
|
|
|
11
13
|
nl: "#NULL!",
|
|
12
14
|
sp: "#SPILL!"
|
|
13
15
|
};
|
|
16
|
+
export var errorMessagesFromValue = (_a = {}, _a[ERROR_DIV_ZERO] = "Invalid calculation: the divisor (second value) cannot be zero", _a[ERROR_NAME] = "Wrong function name or parameter", _a[ERROR_NULL] = "Formula returned null", _a[ERROR_NUM] = "Invalid number", _a[ERROR_REF] = "Invalid reference", _a[ERROR_VALUE] = "Invalid value", _a[ERROR] = "Unknown error", _a);
|
|
17
|
+
export function detectErrorFromValue(input) {
|
|
18
|
+
return errorMessagesFromValue[input];
|
|
19
|
+
}
|
|
20
|
+
export function customErrorMessage(errorMessage) {
|
|
21
|
+
if (errorMessage === cellErrorMessages(ERROR_NAME)) {
|
|
22
|
+
return "#ERROR";
|
|
23
|
+
}
|
|
24
|
+
return errorMessage;
|
|
25
|
+
}
|
|
14
26
|
var errorValues = Object.values(error);
|
|
15
27
|
export function valueIsError(value) {
|
|
16
28
|
return errorValues.includes(value);
|
package/es/settings.js
CHANGED
|
@@ -18,8 +18,8 @@ export var defaultSettings = {
|
|
|
18
18
|
defaultRowHeight: 19,
|
|
19
19
|
defaultFontSize: 10,
|
|
20
20
|
toolbarItems: ["undo", "redo", "format-painter", "clear-format", "|", "currency", "percentage-format", "number-decrease", "number-increase", "format", "|", "font", "|", "font-size", "|", "bold", "italic", "strike-through", "underline", "|", "font-color", "background", "border", "merge-cell", "|", "horizontal-align", "vertical-align", "text-wrap", "text-rotation", "|", "freeze", "conditionFormat", "filter", "link", "image", "comment", "quick-formula", "dataVerification", "splitColumn", "locationCondition", "screenshot", "search"],
|
|
21
|
-
cellContextMenu: ["split-text", "cut", "copy", "paste", "clear", "|", "insert-row", "insert-column", "cell-delete-row", "cell-delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "conditionFormat", "sort", "ascSort", "desSort", "orderAZ", "orderZA", "filter", "searchReplace", "dataVerification", "|", "chart", "link", "data", "cell-format", "comment"],
|
|
22
|
-
headerContextMenu: ["copy", "paste", "|", "insert-row", "insert-column", "delete-row", "delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "split-text", "clear", "sort", "orderAZ", "orderZA"],
|
|
21
|
+
cellContextMenu: ["split-text", "cut", "copy", "paste", "clear", "|", "insert-row", "insert-column", "cell-delete-row", "cell-delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "conditionFormat", "sort", "ascSort", "desSort", "orderAZ", "orderZA", "filter", "searchReplace", "dataVerification", "|", "chart", "link", "data", "cell-format", "comment", "|", "clear-format"],
|
|
22
|
+
headerContextMenu: ["copy", "paste", "|", "insert-row", "insert-column", "delete-row", "delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "split-text", "clear", "sort", "orderAZ", "orderZA", "|", "clear-format"],
|
|
23
23
|
sheetTabContextMenu: ["delete", "copy", "rename", "color", "hide", "|", "move"],
|
|
24
24
|
filterContextMenu: ["sort-by-asc", "sort-by-desc", "filter-by-value"],
|
|
25
25
|
generateSheetId: function generateSheetId() {
|
package/es/types.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export type CellStyle = {
|
|
|
25
25
|
un?: number;
|
|
26
26
|
tr?: string;
|
|
27
27
|
};
|
|
28
|
+
export type CellError = {
|
|
29
|
+
title: string;
|
|
30
|
+
message: string;
|
|
31
|
+
left?: number;
|
|
32
|
+
top?: number;
|
|
33
|
+
row_column?: string;
|
|
34
|
+
};
|
|
28
35
|
export type Cell = {
|
|
29
36
|
v?: string | number | boolean;
|
|
30
37
|
m?: string | number;
|
|
@@ -62,6 +69,7 @@ export type Cell = {
|
|
|
62
69
|
c: number;
|
|
63
70
|
id: string;
|
|
64
71
|
};
|
|
72
|
+
error?: CellError;
|
|
65
73
|
} & CellStyle;
|
|
66
74
|
export type CellWithRowAndCol = {
|
|
67
75
|
r: number;
|
package/lib/api/index.d.ts
CHANGED
package/lib/api/index.js
CHANGED
|
@@ -98,4 +98,16 @@ Object.keys(_workbook).forEach(function (key) {
|
|
|
98
98
|
return _workbook[key];
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
+
});
|
|
102
|
+
var _errorStateHelpers = require("../modules/error-state-helpers");
|
|
103
|
+
Object.keys(_errorStateHelpers).forEach(function (key) {
|
|
104
|
+
if (key === "default" || key === "__esModule") return;
|
|
105
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
106
|
+
if (key in exports && exports[key] === _errorStateHelpers[key]) return;
|
|
107
|
+
Object.defineProperty(exports, key, {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function get() {
|
|
110
|
+
return _errorStateHelpers[key];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
101
113
|
});
|
package/lib/canvas.js
CHANGED
|
@@ -1128,6 +1128,31 @@ var Canvas = exports.Canvas = function () {
|
|
|
1128
1128
|
endX: cellsize[2] + cellsize[0],
|
|
1129
1129
|
endY: cellsize[3] + cellsize[1]
|
|
1130
1130
|
}, renderCtx);
|
|
1131
|
+
if (cell === null || cell === void 0 ? void 0 : cell.error) {
|
|
1132
|
+
var errorBorderColor = "#FB3449";
|
|
1133
|
+
var borderThicknessInPixels = 1;
|
|
1134
|
+
var leftCellBoundary = Math.round(startX + offsetLeft - 3 + bodrder05);
|
|
1135
|
+
var topCellBoundary = Math.round(startY + offsetTop - 3 + bodrder05);
|
|
1136
|
+
var rightCellBoundary = Math.round(endX + offsetLeft - 3 + bodrder05);
|
|
1137
|
+
var bottomCellBoundary = Math.round(endY + offsetTop - 3 + bodrder05);
|
|
1138
|
+
var innerCellWidth = rightCellBoundary - leftCellBoundary;
|
|
1139
|
+
var innerCellHeight = bottomCellBoundary - topCellBoundary;
|
|
1140
|
+
var renderingContext = renderCtx;
|
|
1141
|
+
renderingContext.save();
|
|
1142
|
+
renderingContext.fillStyle = errorBorderColor;
|
|
1143
|
+
renderingContext.fillRect(leftCellBoundary, topCellBoundary, innerCellWidth, borderThicknessInPixels);
|
|
1144
|
+
renderingContext.fillRect(leftCellBoundary, bottomCellBoundary - borderThicknessInPixels, innerCellWidth, borderThicknessInPixels);
|
|
1145
|
+
renderingContext.fillRect(leftCellBoundary, topCellBoundary, borderThicknessInPixels, innerCellHeight);
|
|
1146
|
+
renderingContext.fillRect(rightCellBoundary - borderThicknessInPixels, topCellBoundary, borderThicknessInPixels, innerCellHeight);
|
|
1147
|
+
var errorRibbonSize = 8 * this.sheetCtx.zoomRatio;
|
|
1148
|
+
renderingContext.beginPath();
|
|
1149
|
+
renderingContext.moveTo(leftCellBoundary + borderThicknessInPixels, topCellBoundary + borderThicknessInPixels);
|
|
1150
|
+
renderingContext.lineTo(leftCellBoundary + borderThicknessInPixels + errorRibbonSize, topCellBoundary + borderThicknessInPixels);
|
|
1151
|
+
renderingContext.lineTo(leftCellBoundary + borderThicknessInPixels, topCellBoundary + borderThicknessInPixels + errorRibbonSize);
|
|
1152
|
+
renderingContext.closePath();
|
|
1153
|
+
renderingContext.fill();
|
|
1154
|
+
renderingContext.restore();
|
|
1155
|
+
}
|
|
1131
1156
|
};
|
|
1132
1157
|
Canvas.prototype.cellOverflowRender = function (r, c, stc, edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute) {
|
|
1133
1158
|
var startY;
|
package/lib/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SheetConfig } from ".";
|
|
2
2
|
import { FormulaCache } from "./modules";
|
|
3
3
|
import { Hooks } from "./settings";
|
|
4
|
-
import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache } from "./types";
|
|
4
|
+
import { Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from "./types";
|
|
5
5
|
interface MutableRefObject<T> {
|
|
6
6
|
current: T;
|
|
7
7
|
}
|
|
@@ -21,8 +21,10 @@ export type Context = {
|
|
|
21
21
|
fullscreenmode: boolean;
|
|
22
22
|
devicePixelRatio: number;
|
|
23
23
|
commentBoxes?: CommentBox[];
|
|
24
|
+
errorBoxes?: CellError[];
|
|
24
25
|
editingCommentBox?: CommentBox;
|
|
25
26
|
hoveredCommentBox?: CommentBox;
|
|
27
|
+
hoverErrorBox?: CellError;
|
|
26
28
|
insertedImgs?: Image[];
|
|
27
29
|
editingInsertedImgs?: Image;
|
|
28
30
|
activeImg?: string;
|
package/lib/events/mouse.js
CHANGED
|
@@ -918,6 +918,7 @@ function handleOverlayMouseMove(ctx, globalCache, e, cellInput, scrollX, scrollY
|
|
|
918
918
|
if ((0, _modules.onImageResize)(ctx, globalCache, e)) return;
|
|
919
919
|
(0, _modules.onCellsMove)(ctx, globalCache, e, scrollX, scrollY, container);
|
|
920
920
|
(0, _modules.overShowComment)(ctx, e, scrollX, scrollY, container);
|
|
921
|
+
(0, _modules.overShowError)(ctx, e, scrollX, scrollY, container);
|
|
921
922
|
(0, _searchReplace.onSearchDialogMove)(globalCache, e);
|
|
922
923
|
(0, _hyperlink.onRangeSelectionModalMove)(globalCache, e);
|
|
923
924
|
if (!!ctx.luckysheet_scroll_status || !!ctx.luckysheet_select_status || !!ctx.luckysheet_rows_selected_status || !!ctx.luckysheet_cols_selected_status || !!ctx.luckysheet_cell_selected_move || !!ctx.luckysheet_cell_selected_extend || !!ctx.luckysheet_cols_change_size || !!ctx.luckysheet_rows_change_size) {
|
package/lib/modules/cell.d.ts
CHANGED
|
@@ -30,3 +30,6 @@ export declare function getQKBorder(width: string, type: string, color: string):
|
|
|
30
30
|
export declare function getdatabyselection(ctx: Context, range: Selection | undefined, sheetId: string): (Cell | null)[][];
|
|
31
31
|
export declare function luckysheetUpdateCell(ctx: Context, row_index: number, col_index: number): void;
|
|
32
32
|
export declare function getDataBySelectionNoCopy(ctx: Context, range: Selection): (Cell | null)[][];
|
|
33
|
+
export declare function clearSelectedCellFormat(ctx: Context): void;
|
|
34
|
+
export declare function clearRowsCellsFormat(ctx: Context): void;
|
|
35
|
+
export declare function clearColumnsCellsFormat(ctx: Context): void;
|
package/lib/modules/cell.js
CHANGED
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.cancelFunctionrangeSelected = cancelFunctionrangeSelected;
|
|
7
7
|
exports.cancelNormalSelected = cancelNormalSelected;
|
|
8
|
+
exports.clearColumnsCellsFormat = clearColumnsCellsFormat;
|
|
9
|
+
exports.clearRowsCellsFormat = clearRowsCellsFormat;
|
|
10
|
+
exports.clearSelectedCellFormat = clearSelectedCellFormat;
|
|
8
11
|
exports.getCellValue = getCellValue;
|
|
9
12
|
exports.getDataBySelectionNoCopy = getDataBySelectionNoCopy;
|
|
10
13
|
exports.getFlattenedRange = getFlattenedRange;
|
|
@@ -663,8 +666,10 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
663
666
|
Object.keys(value).forEach(function (attr) {
|
|
664
667
|
curv[attr] = value[attr];
|
|
665
668
|
});
|
|
669
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
666
670
|
}
|
|
667
671
|
} else {
|
|
672
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
668
673
|
(0, _formula.delFunctionGroup)(ctx, r, c);
|
|
669
674
|
curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
|
|
670
675
|
curv.v = value;
|
|
@@ -738,12 +743,14 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
738
743
|
dynamicArrayItem = v[3].data;
|
|
739
744
|
}
|
|
740
745
|
} else {
|
|
746
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
741
747
|
var v = curv;
|
|
742
748
|
if (_lodash.default.isNil(value.v)) {
|
|
743
749
|
value.v = v;
|
|
744
750
|
}
|
|
745
751
|
}
|
|
746
752
|
} else {
|
|
753
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
747
754
|
(0, _formula.delFunctionGroup)(ctx, r, c);
|
|
748
755
|
(0, _formula.execFunctionGroup)(ctx, r, c, value);
|
|
749
756
|
isRunExecFunction = false;
|
|
@@ -1176,4 +1183,84 @@ function getDataBySelectionNoCopy(ctx, range) {
|
|
|
1176
1183
|
data.push(row);
|
|
1177
1184
|
}
|
|
1178
1185
|
return data;
|
|
1186
|
+
}
|
|
1187
|
+
function keepOnlyValueParts(cell) {
|
|
1188
|
+
if (!cell) return cell !== null && cell !== void 0 ? cell : null;
|
|
1189
|
+
var rawValue = cell.v,
|
|
1190
|
+
displayText = cell.m,
|
|
1191
|
+
formula = cell.f;
|
|
1192
|
+
return rawValue !== undefined || displayText !== undefined || formula !== undefined ? {
|
|
1193
|
+
v: rawValue,
|
|
1194
|
+
m: displayText,
|
|
1195
|
+
f: formula
|
|
1196
|
+
} : null;
|
|
1197
|
+
}
|
|
1198
|
+
function clearSelectedCellFormat(ctx) {
|
|
1199
|
+
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1200
|
+
if (activeSheetIndex == null) return;
|
|
1201
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1202
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1203
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1204
|
+
var sheetData = activeSheetFile.data;
|
|
1205
|
+
selectedRanges.forEach(function (_a) {
|
|
1206
|
+
var rowRange = _a.row,
|
|
1207
|
+
columnRange = _a.column;
|
|
1208
|
+
var startRow = rowRange[0],
|
|
1209
|
+
endRow = rowRange[1];
|
|
1210
|
+
var startColumn = columnRange[0],
|
|
1211
|
+
endColumn = columnRange[1];
|
|
1212
|
+
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1213
|
+
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1214
|
+
if (!rowCells) continue;
|
|
1215
|
+
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1216
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1217
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
function clearRowsCellsFormat(ctx) {
|
|
1223
|
+
var _a, _b;
|
|
1224
|
+
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1225
|
+
if (activeSheetIndex == null) return;
|
|
1226
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1227
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1228
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1229
|
+
var sheetData = activeSheetFile.data;
|
|
1230
|
+
var columnCount = (_b = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1231
|
+
selectedRanges.forEach(function (_a) {
|
|
1232
|
+
var rowRange = _a.row;
|
|
1233
|
+
var startRow = rowRange[0],
|
|
1234
|
+
endRow = rowRange[1];
|
|
1235
|
+
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1236
|
+
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1237
|
+
if (!rowCells) continue;
|
|
1238
|
+
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
1239
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1240
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
function clearColumnsCellsFormat(ctx) {
|
|
1246
|
+
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1247
|
+
if (activeSheetIndex == null) return;
|
|
1248
|
+
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1249
|
+
var selectedRanges = ctx.luckysheet_select_save;
|
|
1250
|
+
if (!activeSheetFile || !selectedRanges) return;
|
|
1251
|
+
var sheetData = activeSheetFile.data;
|
|
1252
|
+
var rowCount = sheetData.length;
|
|
1253
|
+
selectedRanges.forEach(function (_a) {
|
|
1254
|
+
var columnRange = _a.column;
|
|
1255
|
+
var startColumn = columnRange[0],
|
|
1256
|
+
endColumn = columnRange[1];
|
|
1257
|
+
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1258
|
+
var rowCells = sheetData[rowIndex];
|
|
1259
|
+
if (!rowCells) continue;
|
|
1260
|
+
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1261
|
+
if (rowCells[columnIndex] === undefined) continue;
|
|
1262
|
+
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1179
1266
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
2
|
+
import { CellError } from "../types";
|
|
3
|
+
export declare function overShowError(ctx: Context, e: MouseEvent, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement): void;
|
|
4
|
+
export declare function setCellError(ctx: Context, r: number, c: number, err: CellError): void;
|
|
5
|
+
export declare function clearCellError(ctx: Context, r: number, c: number): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clearCellError = clearCellError;
|
|
7
|
+
exports.overShowError = overShowError;
|
|
8
|
+
exports.setCellError = setCellError;
|
|
9
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _context = require("../context");
|
|
11
|
+
var _location = require("./location");
|
|
12
|
+
var _cell = require("./cell");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
15
|
+
__assign = Object.assign || function (t) {
|
|
16
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
+
s = arguments[i];
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
return __assign.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
function overShowError(ctx, e, scrollX, scrollY, container) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
var _d, _e, _f, _g, _h;
|
|
27
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
28
|
+
if (!flowdata) return;
|
|
29
|
+
var scrollLeft = scrollX.scrollLeft;
|
|
30
|
+
var scrollTop = scrollY.scrollTop;
|
|
31
|
+
var rect = container.getBoundingClientRect();
|
|
32
|
+
var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
|
|
33
|
+
var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
|
|
34
|
+
var r = (0, _location.rowLocation)(y, ctx.visibledatarow)[2];
|
|
35
|
+
var c = (0, _location.colLocation)(x, ctx.visibledatacolumn)[2];
|
|
36
|
+
var merge = (0, _cell.mergeBorder)(ctx, flowdata, r, c);
|
|
37
|
+
if (merge) {
|
|
38
|
+
_a = merge.row, r = _a[2];
|
|
39
|
+
_b = merge.column, c = _b[2];
|
|
40
|
+
}
|
|
41
|
+
var firstSelection = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[0];
|
|
42
|
+
var row_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
43
|
+
var col_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
44
|
+
if (r === row_focus && c === col_focus) {
|
|
45
|
+
ctx.hoverErrorBox = undefined;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var row_column = "".concat(r, "_").concat(c);
|
|
49
|
+
var cell = (_e = flowdata[r]) === null || _e === void 0 ? void 0 : _e[c];
|
|
50
|
+
var err = cell === null || cell === void 0 ? void 0 : cell.error;
|
|
51
|
+
var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _lodash.default.findIndex(ctx.errorBoxes, function (v) {
|
|
52
|
+
return v.row_column === row_column;
|
|
53
|
+
}) !== -1 : false;
|
|
54
|
+
if (!err || errorAlreadyListed) {
|
|
55
|
+
ctx.hoverErrorBox = undefined;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (((_f = ctx.hoverErrorBox) === null || _f === void 0 ? void 0 : _f.row_column) === row_column) return;
|
|
59
|
+
var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
|
|
60
|
+
var colLeft = ctx.visibledatacolumn[c];
|
|
61
|
+
if (merge) {
|
|
62
|
+
rowTop = merge.row[0];
|
|
63
|
+
_c = merge.column, colLeft = _c[1];
|
|
64
|
+
}
|
|
65
|
+
var toX = colLeft;
|
|
66
|
+
var toY = rowTop;
|
|
67
|
+
var zoom = ctx.zoomRatio;
|
|
68
|
+
var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
|
|
69
|
+
var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
|
|
70
|
+
if (top < 0) top = 2;
|
|
71
|
+
ctx.hoverErrorBox = {
|
|
72
|
+
row_column: row_column,
|
|
73
|
+
left: left,
|
|
74
|
+
top: top,
|
|
75
|
+
title: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.title) || "Error",
|
|
76
|
+
message: ((_h = cell.error) === null || _h === void 0 ? void 0 : _h.message) || "Default error message"
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function setCellError(ctx, r, c, err) {
|
|
80
|
+
var flow = (0, _context.getFlowdata)(ctx);
|
|
81
|
+
if (!flow) return;
|
|
82
|
+
if (!flow[r]) flow[r] = [];
|
|
83
|
+
if (!flow[r][c]) flow[r][c] = {};
|
|
84
|
+
flow[r][c].error = __assign({}, err);
|
|
85
|
+
}
|
|
86
|
+
function clearCellError(ctx, r, c) {
|
|
87
|
+
var _a;
|
|
88
|
+
var flow = (0, _context.getFlowdata)(ctx);
|
|
89
|
+
if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
|
|
90
|
+
delete flow[r][c].error;
|
|
91
|
+
}
|
package/lib/modules/formula.js
CHANGED
|
@@ -28,8 +28,8 @@ exports.rangeDragRow = rangeDragRow;
|
|
|
28
28
|
exports.rangeHightlightselected = rangeHightlightselected;
|
|
29
29
|
exports.rangeSetValue = rangeSetValue;
|
|
30
30
|
exports.setCaretPosition = setCaretPosition;
|
|
31
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
32
31
|
var _formulaParser = require("@fileverse-dev/formula-parser");
|
|
32
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
33
33
|
var _context = require("../context");
|
|
34
34
|
var _utils = require("../utils");
|
|
35
35
|
var _cell = require("./cell");
|
|
@@ -759,7 +759,18 @@ function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc
|
|
|
759
759
|
var resultStr = Number(result).toFixed(ctx.formulaCache.parser.cryptoDecimals).toLowerCase();
|
|
760
760
|
finalResult = "".concat(resultStr, " ").concat(ctx.formulaCache.parser.cryptoDenomination);
|
|
761
761
|
}
|
|
762
|
-
|
|
762
|
+
var isError = !_lodash.default.isNil(formulaError);
|
|
763
|
+
var detectedErrorFromValue = (0, _validation.detectErrorFromValue)(finalResult === null || finalResult === void 0 ? void 0 : finalResult.toString());
|
|
764
|
+
if (isError || detectedErrorFromValue) {
|
|
765
|
+
(0, _2.setCellError)(ctx, r, c, {
|
|
766
|
+
row_column: "".concat(r, "_").concat(c),
|
|
767
|
+
title: "Error",
|
|
768
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || detectedErrorFromValue || "Unknown Error"
|
|
769
|
+
});
|
|
770
|
+
} else {
|
|
771
|
+
(0, _2.clearCellError)(ctx, r, c);
|
|
772
|
+
}
|
|
773
|
+
return [true, !isError ? finalResult : (0, _validation.customErrorMessage)(formulaError), txt];
|
|
763
774
|
}
|
|
764
775
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
765
776
|
var r = dynamicArrayItem.r,
|
package/lib/modules/hyperlink.js
CHANGED
|
@@ -78,6 +78,7 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
function removeHyperlink(ctx, r, c) {
|
|
81
|
+
var _a, _b, _c;
|
|
81
82
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
82
83
|
if (!allowEdit) return;
|
|
83
84
|
var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
@@ -87,10 +88,9 @@ function removeHyperlink(ctx, r, c) {
|
|
|
87
88
|
_lodash.default.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
|
|
88
89
|
var cell = flowdata[r][c];
|
|
89
90
|
if (cell != null) {
|
|
90
|
-
flowdata[r][c]
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
91
|
+
(_a = flowdata[r][c]) === null || _a === void 0 ? true : delete _a.hl;
|
|
92
|
+
(_b = flowdata[r][c]) === null || _b === void 0 ? true : delete _b.un;
|
|
93
|
+
(_c = flowdata[r][c]) === null || _c === void 0 ? true : delete _c.fc;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
ctx.linkCard = undefined;
|
package/lib/modules/index.d.ts
CHANGED
package/lib/modules/index.js
CHANGED
|
@@ -398,4 +398,15 @@ Object.keys(_iframe).forEach(function (key) {
|
|
|
398
398
|
return _iframe[key];
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
|
+
});
|
|
402
|
+
var _errorStateHelpers = require("./error-state-helpers");
|
|
403
|
+
Object.keys(_errorStateHelpers).forEach(function (key) {
|
|
404
|
+
if (key === "default" || key === "__esModule") return;
|
|
405
|
+
if (key in exports && exports[key] === _errorStateHelpers[key]) return;
|
|
406
|
+
Object.defineProperty(exports, key, {
|
|
407
|
+
enumerable: true,
|
|
408
|
+
get: function get() {
|
|
409
|
+
return _errorStateHelpers[key];
|
|
410
|
+
}
|
|
411
|
+
});
|
|
401
412
|
});
|
|
@@ -9,6 +9,9 @@ export declare const error: {
|
|
|
9
9
|
nl: string;
|
|
10
10
|
sp: string;
|
|
11
11
|
};
|
|
12
|
+
export declare const errorMessagesFromValue: Record<string, string>;
|
|
13
|
+
export declare function detectErrorFromValue(input: string): string;
|
|
14
|
+
export declare function customErrorMessage(errorMessage: string): string;
|
|
12
15
|
export declare function valueIsError(value: string): boolean;
|
|
13
16
|
export declare function isRealNull(val: any): boolean;
|
|
14
17
|
export declare function isHexValue(str: string): boolean;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.customErrorMessage = customErrorMessage;
|
|
7
|
+
exports.detectErrorFromValue = detectErrorFromValue;
|
|
6
8
|
exports.diff = diff;
|
|
7
|
-
exports.error = void 0;
|
|
9
|
+
exports.errorMessagesFromValue = exports.error = void 0;
|
|
8
10
|
exports.hasPartMC = hasPartMC;
|
|
9
11
|
exports.isHexValue = isHexValue;
|
|
10
12
|
exports.isRealNull = isRealNull;
|
|
@@ -15,8 +17,10 @@ exports.isdatetime = isdatetime;
|
|
|
15
17
|
exports.valueIsError = valueIsError;
|
|
16
18
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
17
19
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
20
|
+
var _formulaParser = require("@fileverse-dev/formula-parser");
|
|
18
21
|
var _text = require("./text");
|
|
19
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
var _a;
|
|
20
24
|
var error = exports.error = {
|
|
21
25
|
v: "#VALUE!",
|
|
22
26
|
n: "#NAME?",
|
|
@@ -27,6 +31,16 @@ var error = exports.error = {
|
|
|
27
31
|
nl: "#NULL!",
|
|
28
32
|
sp: "#SPILL!"
|
|
29
33
|
};
|
|
34
|
+
var errorMessagesFromValue = exports.errorMessagesFromValue = (_a = {}, _a[_formulaParser.ERROR_DIV_ZERO] = "Invalid calculation: the divisor (second value) cannot be zero", _a[_formulaParser.ERROR_NAME] = "Wrong function name or parameter", _a[_formulaParser.ERROR_NULL] = "Formula returned null", _a[_formulaParser.ERROR_NUM] = "Invalid number", _a[_formulaParser.ERROR_REF] = "Invalid reference", _a[_formulaParser.ERROR_VALUE] = "Invalid value", _a[_formulaParser.ERROR] = "Unknown error", _a);
|
|
35
|
+
function detectErrorFromValue(input) {
|
|
36
|
+
return errorMessagesFromValue[input];
|
|
37
|
+
}
|
|
38
|
+
function customErrorMessage(errorMessage) {
|
|
39
|
+
if (errorMessage === (0, _formulaParser.error)(_formulaParser.ERROR_NAME)) {
|
|
40
|
+
return "#ERROR";
|
|
41
|
+
}
|
|
42
|
+
return errorMessage;
|
|
43
|
+
}
|
|
30
44
|
var errorValues = Object.values(error);
|
|
31
45
|
function valueIsError(value) {
|
|
32
46
|
return errorValues.includes(value);
|
package/lib/settings.js
CHANGED
|
@@ -24,8 +24,8 @@ var defaultSettings = exports.defaultSettings = {
|
|
|
24
24
|
defaultRowHeight: 19,
|
|
25
25
|
defaultFontSize: 10,
|
|
26
26
|
toolbarItems: ["undo", "redo", "format-painter", "clear-format", "|", "currency", "percentage-format", "number-decrease", "number-increase", "format", "|", "font", "|", "font-size", "|", "bold", "italic", "strike-through", "underline", "|", "font-color", "background", "border", "merge-cell", "|", "horizontal-align", "vertical-align", "text-wrap", "text-rotation", "|", "freeze", "conditionFormat", "filter", "link", "image", "comment", "quick-formula", "dataVerification", "splitColumn", "locationCondition", "screenshot", "search"],
|
|
27
|
-
cellContextMenu: ["split-text", "cut", "copy", "paste", "clear", "|", "insert-row", "insert-column", "cell-delete-row", "cell-delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "conditionFormat", "sort", "ascSort", "desSort", "orderAZ", "orderZA", "filter", "searchReplace", "dataVerification", "|", "chart", "link", "data", "cell-format", "comment"],
|
|
28
|
-
headerContextMenu: ["copy", "paste", "|", "insert-row", "insert-column", "delete-row", "delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "split-text", "clear", "sort", "orderAZ", "orderZA"],
|
|
27
|
+
cellContextMenu: ["split-text", "cut", "copy", "paste", "clear", "|", "insert-row", "insert-column", "cell-delete-row", "cell-delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "conditionFormat", "sort", "ascSort", "desSort", "orderAZ", "orderZA", "filter", "searchReplace", "dataVerification", "|", "chart", "link", "data", "cell-format", "comment", "|", "clear-format"],
|
|
28
|
+
headerContextMenu: ["copy", "paste", "|", "insert-row", "insert-column", "delete-row", "delete-column", "delete-cell", "hide-row", "hide-column", "set-row-height", "set-column-width", "|", "split-text", "clear", "sort", "orderAZ", "orderZA", "|", "clear-format"],
|
|
29
29
|
sheetTabContextMenu: ["delete", "copy", "rename", "color", "hide", "|", "move"],
|
|
30
30
|
filterContextMenu: ["sort-by-asc", "sort-by-desc", "filter-by-value"],
|
|
31
31
|
generateSheetId: function generateSheetId() {
|
package/lib/types.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export type CellStyle = {
|
|
|
25
25
|
un?: number;
|
|
26
26
|
tr?: string;
|
|
27
27
|
};
|
|
28
|
+
export type CellError = {
|
|
29
|
+
title: string;
|
|
30
|
+
message: string;
|
|
31
|
+
left?: number;
|
|
32
|
+
top?: number;
|
|
33
|
+
row_column?: string;
|
|
34
|
+
};
|
|
28
35
|
export type Cell = {
|
|
29
36
|
v?: string | number | boolean;
|
|
30
37
|
m?: string | number;
|
|
@@ -62,6 +69,7 @@ export type Cell = {
|
|
|
62
69
|
c: number;
|
|
63
70
|
id: string;
|
|
64
71
|
};
|
|
72
|
+
error?: CellError;
|
|
65
73
|
} & CellStyle;
|
|
66
74
|
export type CellWithRowAndCol = {
|
|
67
75
|
r: number;
|