@fileverse-dev/fortune-core 1.1.66-clear-formatting-1 → 1.1.66-error-2
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 +0 -3
- package/es/modules/cell.js +5 -81
- package/es/modules/error-state-helpers.d.ts +9 -0
- package/es/modules/error-state-helpers.js +93 -0
- package/es/modules/formula.js +12 -2
- package/es/modules/index.d.ts +1 -0
- package/es/modules/index.js +2 -1
- package/es/settings.js +1 -1
- 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 +0 -3
- package/lib/modules/cell.js +4 -83
- package/lib/modules/error-state-helpers.d.ts +9 -0
- package/lib/modules/error-state-helpers.js +103 -0
- package/lib/modules/formula.js +11 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/settings.js +1 -1
- 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 errorColor = "#FB3449";
|
|
1126
|
+
var bw = 1;
|
|
1127
|
+
var L = Math.round(startX + offsetLeft - 1 + bodrder05);
|
|
1128
|
+
var T = Math.round(startY + offsetTop - 1 + bodrder05);
|
|
1129
|
+
var R = Math.round(endX + offsetLeft - 2 + bodrder05);
|
|
1130
|
+
var B = Math.round(endY + offsetTop - 2 + bodrder05);
|
|
1131
|
+
var wInside = R - L;
|
|
1132
|
+
var hInside = B - T;
|
|
1133
|
+
var ctx2 = renderCtx;
|
|
1134
|
+
ctx2.save();
|
|
1135
|
+
ctx2.fillStyle = errorColor;
|
|
1136
|
+
ctx2.fillRect(L, T, wInside, bw);
|
|
1137
|
+
ctx2.fillRect(L, B - bw, wInside, bw);
|
|
1138
|
+
ctx2.fillRect(L, T, bw, hInside);
|
|
1139
|
+
ctx2.fillRect(R - bw, T, bw, hInside);
|
|
1140
|
+
var ribbon = 8 * this.sheetCtx.zoomRatio;
|
|
1141
|
+
ctx2.beginPath();
|
|
1142
|
+
ctx2.moveTo(L + bw, T + bw);
|
|
1143
|
+
ctx2.lineTo(L + bw + ribbon, T + bw);
|
|
1144
|
+
ctx2.lineTo(L + bw, T + bw + ribbon);
|
|
1145
|
+
ctx2.closePath();
|
|
1146
|
+
ctx2.fill();
|
|
1147
|
+
ctx2.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,6 +30,3 @@ 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,84 +1150,4 @@ export function getDataBySelectionNoCopy(ctx, range) {
|
|
|
1146
1150
|
data.push(row);
|
|
1147
1151
|
}
|
|
1148
1152
|
return data;
|
|
1149
|
-
}
|
|
1150
|
-
function keepOnlyValueParts(cell) {
|
|
1151
|
-
if (!cell) return cell !== null && cell !== void 0 ? cell : null;
|
|
1152
|
-
var rawValue = cell.v,
|
|
1153
|
-
displayText = cell.m,
|
|
1154
|
-
formula = cell.f;
|
|
1155
|
-
return rawValue !== undefined || displayText !== undefined || formula !== undefined ? {
|
|
1156
|
-
v: rawValue,
|
|
1157
|
-
m: displayText,
|
|
1158
|
-
f: formula
|
|
1159
|
-
} : null;
|
|
1160
|
-
}
|
|
1161
|
-
export function clearSelectedCellFormat(ctx) {
|
|
1162
|
-
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1163
|
-
if (activeSheetIndex == null) return;
|
|
1164
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1165
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1166
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1167
|
-
var sheetData = activeSheetFile.data;
|
|
1168
|
-
selectedRanges.forEach(function (_a) {
|
|
1169
|
-
var rowRange = _a.row,
|
|
1170
|
-
columnRange = _a.column;
|
|
1171
|
-
var startRow = rowRange[0],
|
|
1172
|
-
endRow = rowRange[1];
|
|
1173
|
-
var startColumn = columnRange[0],
|
|
1174
|
-
endColumn = columnRange[1];
|
|
1175
|
-
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1176
|
-
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1177
|
-
if (!rowCells) continue;
|
|
1178
|
-
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1179
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1180
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
export function clearRowsCellsFormat(ctx) {
|
|
1186
|
-
var _a, _b;
|
|
1187
|
-
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1188
|
-
if (activeSheetIndex == null) return;
|
|
1189
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1190
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1191
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1192
|
-
var sheetData = activeSheetFile.data;
|
|
1193
|
-
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;
|
|
1194
|
-
selectedRanges.forEach(function (_a) {
|
|
1195
|
-
var rowRange = _a.row;
|
|
1196
|
-
var startRow = rowRange[0],
|
|
1197
|
-
endRow = rowRange[1];
|
|
1198
|
-
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1199
|
-
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1200
|
-
if (!rowCells) continue;
|
|
1201
|
-
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
1202
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1203
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
export function clearColumnsCellsFormat(ctx) {
|
|
1209
|
-
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1210
|
-
if (activeSheetIndex == null) return;
|
|
1211
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1212
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1213
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1214
|
-
var sheetData = activeSheetFile.data;
|
|
1215
|
-
var rowCount = sheetData.length;
|
|
1216
|
-
selectedRanges.forEach(function (_a) {
|
|
1217
|
-
var columnRange = _a.column;
|
|
1218
|
-
var startColumn = columnRange[0],
|
|
1219
|
-
endColumn = columnRange[1];
|
|
1220
|
-
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1221
|
-
var rowCells = sheetData[rowIndex];
|
|
1222
|
-
if (!rowCells) continue;
|
|
1223
|
-
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1224
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1225
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
1153
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
6
|
+
export declare function showErrors(ctx: Context, errorShowCells: {
|
|
7
|
+
r: number;
|
|
8
|
+
c: number;
|
|
9
|
+
}[]): void;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { getCommentBoxByRC } from "./comment";
|
|
14
|
+
import { colLocation, rowLocation } from "./location";
|
|
15
|
+
import { mergeBorder } from "./cell";
|
|
16
|
+
export function overShowError(ctx, e, scrollX, scrollY, container) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
var _d, _e, _f, _g, _h;
|
|
19
|
+
var flowdata = getFlowdata(ctx);
|
|
20
|
+
if (!flowdata) return;
|
|
21
|
+
var scrollLeft = scrollX.scrollLeft;
|
|
22
|
+
var scrollTop = scrollY.scrollTop;
|
|
23
|
+
var rect = container.getBoundingClientRect();
|
|
24
|
+
var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
|
|
25
|
+
var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
|
|
26
|
+
var r = rowLocation(y, ctx.visibledatarow)[2];
|
|
27
|
+
var c = colLocation(x, ctx.visibledatacolumn)[2];
|
|
28
|
+
var merge = mergeBorder(ctx, flowdata, r, c);
|
|
29
|
+
if (merge) {
|
|
30
|
+
_a = merge.row, r = _a[2];
|
|
31
|
+
_b = merge.column, c = _b[2];
|
|
32
|
+
}
|
|
33
|
+
var firstSelection = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[0];
|
|
34
|
+
var row_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
35
|
+
var col_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
36
|
+
if (r === row_focus && c === col_focus) {
|
|
37
|
+
ctx.hoverErrorBox = undefined;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var row_column = "".concat(r, "_").concat(c);
|
|
41
|
+
var cell = (_e = flowdata[r]) === null || _e === void 0 ? void 0 : _e[c];
|
|
42
|
+
var err = cell === null || cell === void 0 ? void 0 : cell.error;
|
|
43
|
+
var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _.findIndex(ctx.errorBoxes, function (v) {
|
|
44
|
+
return v.row_column === row_column;
|
|
45
|
+
}) !== -1 : false;
|
|
46
|
+
if (!err || errorAlreadyListed) {
|
|
47
|
+
ctx.hoverErrorBox = undefined;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (((_f = ctx.hoverErrorBox) === null || _f === void 0 ? void 0 : _f.row_column) === row_column) return;
|
|
51
|
+
var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
|
|
52
|
+
var colLeft = ctx.visibledatacolumn[c];
|
|
53
|
+
if (merge) {
|
|
54
|
+
rowTop = merge.row[0];
|
|
55
|
+
_c = merge.column, colLeft = _c[1];
|
|
56
|
+
}
|
|
57
|
+
var toX = colLeft;
|
|
58
|
+
var toY = rowTop;
|
|
59
|
+
var zoom = ctx.zoomRatio;
|
|
60
|
+
var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
|
|
61
|
+
var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
|
|
62
|
+
if (top < 0) top = 2;
|
|
63
|
+
ctx.hoverErrorBox = {
|
|
64
|
+
row_column: row_column,
|
|
65
|
+
left: left,
|
|
66
|
+
top: top,
|
|
67
|
+
title: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.title) || "Error",
|
|
68
|
+
message: ((_h = cell.error) === null || _h === void 0 ? void 0 : _h.message) || "Default error message"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function setCellError(ctx, r, c, err) {
|
|
72
|
+
var flow = getFlowdata(ctx);
|
|
73
|
+
if (!flow) return;
|
|
74
|
+
if (!flow[r]) flow[r] = [];
|
|
75
|
+
if (!flow[r][c]) flow[r][c] = {};
|
|
76
|
+
flow[r][c].error = __assign({}, err);
|
|
77
|
+
}
|
|
78
|
+
export function clearCellError(ctx, r, c) {
|
|
79
|
+
var _a;
|
|
80
|
+
var flow = getFlowdata(ctx);
|
|
81
|
+
if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
|
|
82
|
+
delete flow[r][c].error;
|
|
83
|
+
}
|
|
84
|
+
export function showErrors(ctx, errorShowCells) {
|
|
85
|
+
var flowdata = getFlowdata(ctx);
|
|
86
|
+
if (!flowdata) return;
|
|
87
|
+
var errorBoxes = errorShowCells.map(function (_a) {
|
|
88
|
+
var r = _a.r,
|
|
89
|
+
c = _a.c;
|
|
90
|
+
return getCommentBoxByRC(ctx, flowdata, r, c);
|
|
91
|
+
});
|
|
92
|
+
ctx.errorBoxes = errorBoxes;
|
|
93
|
+
}
|
package/es/modules/formula.js
CHANGED
|
@@ -27,7 +27,7 @@ import { error } 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,17 @@ 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
|
+
if (isError) {
|
|
734
|
+
setCellError(ctx, r, c, {
|
|
735
|
+
row_column: "".concat(r, "_").concat(c),
|
|
736
|
+
title: "Error",
|
|
737
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || "Unknown Error"
|
|
738
|
+
});
|
|
739
|
+
} else {
|
|
740
|
+
clearCellError(ctx, r, c);
|
|
741
|
+
}
|
|
742
|
+
return [true, !isError ? finalResult : formulaError, txt];
|
|
733
743
|
}
|
|
734
744
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
735
745
|
var r = dynamicArrayItem.r,
|
package/es/modules/index.d.ts
CHANGED
package/es/modules/index.js
CHANGED
package/es/settings.js
CHANGED
|
@@ -18,7 +18,7 @@ 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"
|
|
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
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"],
|
|
23
23
|
sheetTabContextMenu: ["delete", "copy", "rename", "color", "hide", "|", "move"],
|
|
24
24
|
filterContextMenu: ["sort-by-asc", "sort-by-desc", "filter-by-value"],
|
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 errorColor = "#FB3449";
|
|
1133
|
+
var bw = 1;
|
|
1134
|
+
var L = Math.round(startX + offsetLeft - 1 + bodrder05);
|
|
1135
|
+
var T = Math.round(startY + offsetTop - 1 + bodrder05);
|
|
1136
|
+
var R = Math.round(endX + offsetLeft - 2 + bodrder05);
|
|
1137
|
+
var B = Math.round(endY + offsetTop - 2 + bodrder05);
|
|
1138
|
+
var wInside = R - L;
|
|
1139
|
+
var hInside = B - T;
|
|
1140
|
+
var ctx2 = renderCtx;
|
|
1141
|
+
ctx2.save();
|
|
1142
|
+
ctx2.fillStyle = errorColor;
|
|
1143
|
+
ctx2.fillRect(L, T, wInside, bw);
|
|
1144
|
+
ctx2.fillRect(L, B - bw, wInside, bw);
|
|
1145
|
+
ctx2.fillRect(L, T, bw, hInside);
|
|
1146
|
+
ctx2.fillRect(R - bw, T, bw, hInside);
|
|
1147
|
+
var ribbon = 8 * this.sheetCtx.zoomRatio;
|
|
1148
|
+
ctx2.beginPath();
|
|
1149
|
+
ctx2.moveTo(L + bw, T + bw);
|
|
1150
|
+
ctx2.lineTo(L + bw + ribbon, T + bw);
|
|
1151
|
+
ctx2.lineTo(L + bw, T + bw + ribbon);
|
|
1152
|
+
ctx2.closePath();
|
|
1153
|
+
ctx2.fill();
|
|
1154
|
+
ctx2.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,6 +30,3 @@ 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,9 +5,6 @@ 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;
|
|
11
8
|
exports.getCellValue = getCellValue;
|
|
12
9
|
exports.getDataBySelectionNoCopy = getDataBySelectionNoCopy;
|
|
13
10
|
exports.getFlattenedRange = getFlattenedRange;
|
|
@@ -666,8 +663,10 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
666
663
|
Object.keys(value).forEach(function (attr) {
|
|
667
664
|
curv[attr] = value[attr];
|
|
668
665
|
});
|
|
666
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
669
667
|
}
|
|
670
668
|
} else {
|
|
669
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
671
670
|
(0, _formula.delFunctionGroup)(ctx, r, c);
|
|
672
671
|
curv = _lodash.default.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
|
|
673
672
|
curv.v = value;
|
|
@@ -741,12 +740,14 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
741
740
|
dynamicArrayItem = v[3].data;
|
|
742
741
|
}
|
|
743
742
|
} else {
|
|
743
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
744
744
|
var v = curv;
|
|
745
745
|
if (_lodash.default.isNil(value.v)) {
|
|
746
746
|
value.v = v;
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
} else {
|
|
750
|
+
(0, _api.clearCellError)(ctx, r, c);
|
|
750
751
|
(0, _formula.delFunctionGroup)(ctx, r, c);
|
|
751
752
|
(0, _formula.execFunctionGroup)(ctx, r, c, value);
|
|
752
753
|
isRunExecFunction = false;
|
|
@@ -1179,84 +1180,4 @@ function getDataBySelectionNoCopy(ctx, range) {
|
|
|
1179
1180
|
data.push(row);
|
|
1180
1181
|
}
|
|
1181
1182
|
return data;
|
|
1182
|
-
}
|
|
1183
|
-
function keepOnlyValueParts(cell) {
|
|
1184
|
-
if (!cell) return cell !== null && cell !== void 0 ? cell : null;
|
|
1185
|
-
var rawValue = cell.v,
|
|
1186
|
-
displayText = cell.m,
|
|
1187
|
-
formula = cell.f;
|
|
1188
|
-
return rawValue !== undefined || displayText !== undefined || formula !== undefined ? {
|
|
1189
|
-
v: rawValue,
|
|
1190
|
-
m: displayText,
|
|
1191
|
-
f: formula
|
|
1192
|
-
} : null;
|
|
1193
|
-
}
|
|
1194
|
-
function clearSelectedCellFormat(ctx) {
|
|
1195
|
-
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1196
|
-
if (activeSheetIndex == null) return;
|
|
1197
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1198
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1199
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1200
|
-
var sheetData = activeSheetFile.data;
|
|
1201
|
-
selectedRanges.forEach(function (_a) {
|
|
1202
|
-
var rowRange = _a.row,
|
|
1203
|
-
columnRange = _a.column;
|
|
1204
|
-
var startRow = rowRange[0],
|
|
1205
|
-
endRow = rowRange[1];
|
|
1206
|
-
var startColumn = columnRange[0],
|
|
1207
|
-
endColumn = columnRange[1];
|
|
1208
|
-
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1209
|
-
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1210
|
-
if (!rowCells) continue;
|
|
1211
|
-
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1212
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1213
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
function clearRowsCellsFormat(ctx) {
|
|
1219
|
-
var _a, _b;
|
|
1220
|
-
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1221
|
-
if (activeSheetIndex == null) return;
|
|
1222
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1223
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1224
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1225
|
-
var sheetData = activeSheetFile.data;
|
|
1226
|
-
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;
|
|
1227
|
-
selectedRanges.forEach(function (_a) {
|
|
1228
|
-
var rowRange = _a.row;
|
|
1229
|
-
var startRow = rowRange[0],
|
|
1230
|
-
endRow = rowRange[1];
|
|
1231
|
-
for (var rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
1232
|
-
var rowCells = sheetData === null || sheetData === void 0 ? void 0 : sheetData[rowIndex];
|
|
1233
|
-
if (!rowCells) continue;
|
|
1234
|
-
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
1235
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1236
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
function clearColumnsCellsFormat(ctx) {
|
|
1242
|
-
var activeSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1243
|
-
if (activeSheetIndex == null) return;
|
|
1244
|
-
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1245
|
-
var selectedRanges = ctx.luckysheet_select_save;
|
|
1246
|
-
if (!activeSheetFile || !selectedRanges) return;
|
|
1247
|
-
var sheetData = activeSheetFile.data;
|
|
1248
|
-
var rowCount = sheetData.length;
|
|
1249
|
-
selectedRanges.forEach(function (_a) {
|
|
1250
|
-
var columnRange = _a.column;
|
|
1251
|
-
var startColumn = columnRange[0],
|
|
1252
|
-
endColumn = columnRange[1];
|
|
1253
|
-
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
1254
|
-
var rowCells = sheetData[rowIndex];
|
|
1255
|
-
if (!rowCells) continue;
|
|
1256
|
-
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1257
|
-
if (rowCells[columnIndex] === undefined) continue;
|
|
1258
|
-
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
});
|
|
1262
1183
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
6
|
+
export declare function showErrors(ctx: Context, errorShowCells: {
|
|
7
|
+
r: number;
|
|
8
|
+
c: number;
|
|
9
|
+
}[]): void;
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
exports.showErrors = showErrors;
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
var _context = require("../context");
|
|
12
|
+
var _comment = require("./comment");
|
|
13
|
+
var _location = require("./location");
|
|
14
|
+
var _cell = require("./cell");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
17
|
+
__assign = Object.assign || function (t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
function overShowError(ctx, e, scrollX, scrollY, container) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
var _d, _e, _f, _g, _h;
|
|
29
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
30
|
+
if (!flowdata) return;
|
|
31
|
+
var scrollLeft = scrollX.scrollLeft;
|
|
32
|
+
var scrollTop = scrollY.scrollTop;
|
|
33
|
+
var rect = container.getBoundingClientRect();
|
|
34
|
+
var x = e.pageX - rect.left - ctx.rowHeaderWidth + scrollLeft;
|
|
35
|
+
var y = e.pageY - rect.top - ctx.columnHeaderHeight + scrollTop;
|
|
36
|
+
var r = (0, _location.rowLocation)(y, ctx.visibledatarow)[2];
|
|
37
|
+
var c = (0, _location.colLocation)(x, ctx.visibledatacolumn)[2];
|
|
38
|
+
var merge = (0, _cell.mergeBorder)(ctx, flowdata, r, c);
|
|
39
|
+
if (merge) {
|
|
40
|
+
_a = merge.row, r = _a[2];
|
|
41
|
+
_b = merge.column, c = _b[2];
|
|
42
|
+
}
|
|
43
|
+
var firstSelection = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[0];
|
|
44
|
+
var row_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
45
|
+
var col_focus = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
46
|
+
if (r === row_focus && c === col_focus) {
|
|
47
|
+
ctx.hoverErrorBox = undefined;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var row_column = "".concat(r, "_").concat(c);
|
|
51
|
+
var cell = (_e = flowdata[r]) === null || _e === void 0 ? void 0 : _e[c];
|
|
52
|
+
var err = cell === null || cell === void 0 ? void 0 : cell.error;
|
|
53
|
+
var errorAlreadyListed = Array.isArray(ctx.errorBoxes) ? _lodash.default.findIndex(ctx.errorBoxes, function (v) {
|
|
54
|
+
return v.row_column === row_column;
|
|
55
|
+
}) !== -1 : false;
|
|
56
|
+
if (!err || errorAlreadyListed) {
|
|
57
|
+
ctx.hoverErrorBox = undefined;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (((_f = ctx.hoverErrorBox) === null || _f === void 0 ? void 0 : _f.row_column) === row_column) return;
|
|
61
|
+
var rowTop = r - 1 === -1 ? 0 : ctx.visibledatarow[r - 1];
|
|
62
|
+
var colLeft = ctx.visibledatacolumn[c];
|
|
63
|
+
if (merge) {
|
|
64
|
+
rowTop = merge.row[0];
|
|
65
|
+
_c = merge.column, colLeft = _c[1];
|
|
66
|
+
}
|
|
67
|
+
var toX = colLeft;
|
|
68
|
+
var toY = rowTop;
|
|
69
|
+
var zoom = ctx.zoomRatio;
|
|
70
|
+
var left = err.left == null ? toX + 8 * zoom : err.left * zoom;
|
|
71
|
+
var top = err.top == null ? toY - 2 * zoom : err.top * zoom;
|
|
72
|
+
if (top < 0) top = 2;
|
|
73
|
+
ctx.hoverErrorBox = {
|
|
74
|
+
row_column: row_column,
|
|
75
|
+
left: left,
|
|
76
|
+
top: top,
|
|
77
|
+
title: ((_g = cell.error) === null || _g === void 0 ? void 0 : _g.title) || "Error",
|
|
78
|
+
message: ((_h = cell.error) === null || _h === void 0 ? void 0 : _h.message) || "Default error message"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function setCellError(ctx, r, c, err) {
|
|
82
|
+
var flow = (0, _context.getFlowdata)(ctx);
|
|
83
|
+
if (!flow) return;
|
|
84
|
+
if (!flow[r]) flow[r] = [];
|
|
85
|
+
if (!flow[r][c]) flow[r][c] = {};
|
|
86
|
+
flow[r][c].error = __assign({}, err);
|
|
87
|
+
}
|
|
88
|
+
function clearCellError(ctx, r, c) {
|
|
89
|
+
var _a;
|
|
90
|
+
var flow = (0, _context.getFlowdata)(ctx);
|
|
91
|
+
if (!((_a = flow === null || flow === void 0 ? void 0 : flow[r]) === null || _a === void 0 ? void 0 : _a[c])) return;
|
|
92
|
+
delete flow[r][c].error;
|
|
93
|
+
}
|
|
94
|
+
function showErrors(ctx, errorShowCells) {
|
|
95
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
96
|
+
if (!flowdata) return;
|
|
97
|
+
var errorBoxes = errorShowCells.map(function (_a) {
|
|
98
|
+
var r = _a.r,
|
|
99
|
+
c = _a.c;
|
|
100
|
+
return (0, _comment.getCommentBoxByRC)(ctx, flowdata, r, c);
|
|
101
|
+
});
|
|
102
|
+
ctx.errorBoxes = errorBoxes;
|
|
103
|
+
}
|
package/lib/modules/formula.js
CHANGED
|
@@ -759,7 +759,17 @@ 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
|
+
if (isError) {
|
|
764
|
+
(0, _2.setCellError)(ctx, r, c, {
|
|
765
|
+
row_column: "".concat(r, "_").concat(c),
|
|
766
|
+
title: "Error",
|
|
767
|
+
message: (formulaError === null || formulaError === void 0 ? void 0 : formulaError.toString()) || "Unknown Error"
|
|
768
|
+
});
|
|
769
|
+
} else {
|
|
770
|
+
(0, _2.clearCellError)(ctx, r, c);
|
|
771
|
+
}
|
|
772
|
+
return [true, !isError ? finalResult : formulaError, txt];
|
|
763
773
|
}
|
|
764
774
|
function insertUpdateDynamicArray(ctx, dynamicArrayItem) {
|
|
765
775
|
var r = dynamicArrayItem.r,
|
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
|
});
|
package/lib/settings.js
CHANGED
|
@@ -24,7 +24,7 @@ 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"
|
|
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
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"],
|
|
29
29
|
sheetTabContextMenu: ["delete", "copy", "rename", "color", "hide", "|", "move"],
|
|
30
30
|
filterContextMenu: ["sort-by-asc", "sort-by-desc", "filter-by-value"],
|
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;
|