@fileverse-dev/fortune-core 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/events/keyboard.d.ts +1 -1
- package/es/events/keyboard.js +226 -99
- package/es/locale/en.d.ts +6 -0
- package/es/locale/en.js +11 -0
- package/es/modules/ConditionFormat.js +107 -16
- package/es/modules/selection.d.ts +2 -0
- package/es/modules/selection.js +86 -0
- package/lib/events/keyboard.d.ts +1 -1
- package/lib/events/keyboard.js +225 -98
- package/lib/locale/en.d.ts +6 -0
- package/lib/locale/en.js +11 -0
- package/lib/modules/ConditionFormat.js +107 -16
- package/lib/modules/selection.d.ts +2 -0
- package/lib/modules/selection.js +88 -0
- package/package.json +1 -1
package/es/events/keyboard.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { GlobalCache } from "../types";
|
|
|
3
3
|
export declare function handleGlobalEnter(ctx: Context, cellInput: HTMLDivElement, e: KeyboardEvent, canvas?: CanvasRenderingContext2D): void;
|
|
4
4
|
export declare function handleWithCtrlOrMetaKey(ctx: Context, cache: GlobalCache, e: KeyboardEvent, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, handleUndo: () => void, handleRedo: () => void): void;
|
|
5
5
|
export declare function handleArrowKey(ctx: Context, e: KeyboardEvent): void;
|
|
6
|
-
export declare function handleGlobalKeyDown(ctx: Context, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, e: KeyboardEvent, cache: GlobalCache, handleUndo: () => void, handleRedo: () => void, canvas?: CanvasRenderingContext2D): void
|
|
6
|
+
export declare function handleGlobalKeyDown(ctx: Context, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, e: KeyboardEvent, cache: GlobalCache, handleUndo: () => void, handleRedo: () => void, canvas?: CanvasRenderingContext2D): Promise<void>;
|
package/es/events/keyboard.js
CHANGED
|
@@ -1,9 +1,124 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) {
|
|
3
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
+
resolve(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) {
|
|
9
|
+
try {
|
|
10
|
+
step(generator.next(value));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
reject(e);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function rejected(value) {
|
|
16
|
+
try {
|
|
17
|
+
step(generator["throw"](value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function step(result) {
|
|
23
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
24
|
+
}
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
29
|
+
var _ = {
|
|
30
|
+
label: 0,
|
|
31
|
+
sent: function sent() {
|
|
32
|
+
if (t[0] & 1) throw t[1];
|
|
33
|
+
return t[1];
|
|
34
|
+
},
|
|
35
|
+
trys: [],
|
|
36
|
+
ops: []
|
|
37
|
+
},
|
|
38
|
+
f,
|
|
39
|
+
y,
|
|
40
|
+
t,
|
|
41
|
+
g;
|
|
42
|
+
return g = {
|
|
43
|
+
next: verb(0),
|
|
44
|
+
"throw": verb(1),
|
|
45
|
+
"return": verb(2)
|
|
46
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
47
|
+
return this;
|
|
48
|
+
}), g;
|
|
49
|
+
function verb(n) {
|
|
50
|
+
return function (v) {
|
|
51
|
+
return step([n, v]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function step(op) {
|
|
55
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
|
+
switch (op[0]) {
|
|
60
|
+
case 0:
|
|
61
|
+
case 1:
|
|
62
|
+
t = op;
|
|
63
|
+
break;
|
|
64
|
+
case 4:
|
|
65
|
+
_.label++;
|
|
66
|
+
return {
|
|
67
|
+
value: op[1],
|
|
68
|
+
done: false
|
|
69
|
+
};
|
|
70
|
+
case 5:
|
|
71
|
+
_.label++;
|
|
72
|
+
y = op[1];
|
|
73
|
+
op = [0];
|
|
74
|
+
continue;
|
|
75
|
+
case 7:
|
|
76
|
+
op = _.ops.pop();
|
|
77
|
+
_.trys.pop();
|
|
78
|
+
continue;
|
|
79
|
+
default:
|
|
80
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
81
|
+
_ = 0;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
85
|
+
_.label = op[1];
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
89
|
+
_.label = t[1];
|
|
90
|
+
t = op;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (t && _.label < t[2]) {
|
|
94
|
+
_.label = t[2];
|
|
95
|
+
_.ops.push(op);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (t[2]) _.ops.pop();
|
|
99
|
+
_.trys.pop();
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
op = body.call(thisArg, _);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
op = [6, e];
|
|
105
|
+
y = 0;
|
|
106
|
+
} finally {
|
|
107
|
+
f = t = 0;
|
|
108
|
+
}
|
|
109
|
+
if (op[0] & 5) throw op[1];
|
|
110
|
+
return {
|
|
111
|
+
value: op[0] ? op[1] : void 0,
|
|
112
|
+
done: true
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
1
116
|
import _ from "lodash";
|
|
2
117
|
import { hideCRCount, removeActiveImage } from "..";
|
|
3
118
|
import { getFlowdata } from "../context";
|
|
4
119
|
import { updateCell, cancelNormalSelected } from "../modules/cell";
|
|
5
120
|
import { handleFormulaInput } from "../modules/formula";
|
|
6
|
-
import { copy, deleteSelectedCellText, deleteSelectedCellFormat, textFormat, fillDate, fillTime, moveHighlightCell, moveHighlightRange, selectAll, selectionCache } from "../modules/selection";
|
|
121
|
+
import { copy, deleteSelectedCellText, deleteSelectedCellFormat, textFormat, fillDate, fillTime, fillRightData, fillDownData, moveHighlightCell, moveHighlightRange, selectAll, selectionCache } from "../modules/selection";
|
|
7
122
|
import { cancelPaintModel, handleBold, handleItalic, handleUnderline, handleLink } from "../modules/toolbar";
|
|
8
123
|
import { hasPartMC } from "../modules/validation";
|
|
9
124
|
import { getNowDateTime, getSheetIndex, isAllowEdit } from "../utils";
|
|
@@ -256,105 +371,117 @@ export function handleArrowKey(ctx, e) {
|
|
|
256
371
|
}
|
|
257
372
|
export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
|
|
258
373
|
var _a;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
|
|
268
|
-
textFormat(ctx, "left");
|
|
269
|
-
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
|
|
270
|
-
textFormat(ctx, "right");
|
|
271
|
-
}
|
|
272
|
-
if ((e.metaKey || e.ctrlKey) && e.code === "KeyK") {
|
|
273
|
-
handleLink(ctx);
|
|
274
|
-
}
|
|
275
|
-
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "Semicolon") {
|
|
276
|
-
fillDate(ctx);
|
|
277
|
-
}
|
|
278
|
-
if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "Semicolon") {
|
|
279
|
-
fillTime(ctx);
|
|
280
|
-
}
|
|
281
|
-
ctx.luckysheet_select_status = false;
|
|
282
|
-
var kcode = e.keyCode;
|
|
283
|
-
var kstr = e.key;
|
|
284
|
-
if (!_.isEmpty(ctx.contextMenu) || ctx.filterContextMenu) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
if (kstr === "Escape" && !!ctx.luckysheet_selection_range) {
|
|
288
|
-
ctx.luckysheet_selection_range = [];
|
|
289
|
-
}
|
|
290
|
-
var allowEdit = isAllowEdit(ctx);
|
|
291
|
-
if (ctx.luckysheetCellUpdate.length > 0 && kstr !== "Enter" && kstr !== "Tab" && kstr !== "ArrowUp" && kstr !== "ArrowDown" && kstr !== "ArrowLeft" && kstr !== "ArrowRight") {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (kstr === "Enter") {
|
|
295
|
-
if (!allowEdit) return;
|
|
296
|
-
handleGlobalEnter(ctx, cellInput, e, canvas);
|
|
297
|
-
} else if (kstr === "Tab") {
|
|
298
|
-
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
if (e.shiftKey) {
|
|
302
|
-
moveHighlightCell(ctx, "right", -1, "rangeOfSelect");
|
|
303
|
-
} else {
|
|
304
|
-
moveHighlightCell(ctx, "right", 1, "rangeOfSelect");
|
|
305
|
-
}
|
|
306
|
-
e.preventDefault();
|
|
307
|
-
} else if (kstr === "F2") {
|
|
308
|
-
if (!allowEdit) return;
|
|
309
|
-
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
|
|
313
|
-
if (!last) return;
|
|
314
|
-
var row_index = last.row_focus;
|
|
315
|
-
var col_index = last.column_focus;
|
|
316
|
-
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
317
|
-
e.preventDefault();
|
|
318
|
-
} else if (kstr === "F4" && ctx.luckysheetCellUpdate.length > 0) {
|
|
319
|
-
e.preventDefault();
|
|
320
|
-
} else if (kstr === "Escape" && ctx.luckysheetCellUpdate.length > 0) {
|
|
321
|
-
cancelNormalSelected(ctx);
|
|
322
|
-
moveHighlightCell(ctx, "down", 0, "rangeOfSelect");
|
|
323
|
-
e.preventDefault();
|
|
324
|
-
} else {
|
|
325
|
-
if (e.ctrlKey || e.metaKey) {
|
|
326
|
-
handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo);
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
if (e.shiftKey && (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight")) {
|
|
330
|
-
handleShiftWithArrowKey(ctx, e);
|
|
331
|
-
} else if (kstr === "Escape") {
|
|
332
|
-
ctx.contextMenu = {};
|
|
333
|
-
} else if (kstr === "Delete" || kstr === "Backspace") {
|
|
334
|
-
if (!allowEdit) return;
|
|
335
|
-
if (ctx.activeImg != null) {
|
|
336
|
-
removeActiveImage(ctx);
|
|
337
|
-
} else {
|
|
338
|
-
deleteSelectedCellText(ctx);
|
|
374
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
375
|
+
var kcode, kstr, allowEdit, last, row_index, col_index, last, row_index, col_index;
|
|
376
|
+
return __generator(this, function (_b) {
|
|
377
|
+
if (e.shiftKey && e.code === "Space") {
|
|
378
|
+
e.stopImmediatePropagation();
|
|
379
|
+
e.stopPropagation();
|
|
380
|
+
e.preventDefault();
|
|
381
|
+
return [2];
|
|
339
382
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
383
|
+
if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
|
|
384
|
+
textFormat(ctx, "center");
|
|
385
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
|
|
386
|
+
textFormat(ctx, "left");
|
|
387
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
|
|
388
|
+
textFormat(ctx, "right");
|
|
389
|
+
}
|
|
390
|
+
if ((e.metaKey || e.ctrlKey) && e.code === "KeyK") {
|
|
391
|
+
handleLink(ctx);
|
|
392
|
+
}
|
|
393
|
+
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.code === "Semicolon") {
|
|
394
|
+
fillDate(ctx);
|
|
395
|
+
}
|
|
396
|
+
if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "Semicolon") {
|
|
397
|
+
fillTime(ctx);
|
|
398
|
+
}
|
|
399
|
+
if ((e.metaKey || e.ctrlKey) && e.code === "KeyR") {
|
|
400
|
+
fillRightData(ctx);
|
|
401
|
+
}
|
|
402
|
+
if ((e.metaKey || e.ctrlKey) && e.code === "KeyD") {
|
|
403
|
+
fillDownData(ctx);
|
|
404
|
+
}
|
|
405
|
+
ctx.luckysheet_select_status = false;
|
|
406
|
+
kcode = e.keyCode;
|
|
407
|
+
kstr = e.key;
|
|
408
|
+
if (!_.isEmpty(ctx.contextMenu) || ctx.filterContextMenu) {
|
|
409
|
+
return [2];
|
|
410
|
+
}
|
|
411
|
+
if (kstr === "Escape" && !!ctx.luckysheet_selection_range) {
|
|
412
|
+
ctx.luckysheet_selection_range = [];
|
|
413
|
+
}
|
|
414
|
+
allowEdit = isAllowEdit(ctx);
|
|
415
|
+
if (ctx.luckysheetCellUpdate.length > 0 && kstr !== "Enter" && kstr !== "Tab" && kstr !== "ArrowUp" && kstr !== "ArrowDown" && kstr !== "ArrowLeft" && kstr !== "ArrowRight") {
|
|
416
|
+
return [2];
|
|
417
|
+
}
|
|
418
|
+
if (kstr === "Enter") {
|
|
419
|
+
if (!allowEdit) return [2];
|
|
420
|
+
handleGlobalEnter(ctx, cellInput, e, canvas);
|
|
421
|
+
} else if (kstr === "Tab") {
|
|
422
|
+
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
423
|
+
return [2];
|
|
424
|
+
}
|
|
425
|
+
if (e.shiftKey) {
|
|
426
|
+
moveHighlightCell(ctx, "right", -1, "rangeOfSelect");
|
|
427
|
+
} else {
|
|
428
|
+
moveHighlightCell(ctx, "right", 1, "rangeOfSelect");
|
|
429
|
+
}
|
|
430
|
+
e.preventDefault();
|
|
431
|
+
} else if (kstr === "F2") {
|
|
432
|
+
if (!allowEdit) return [2];
|
|
433
|
+
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
434
|
+
return [2];
|
|
435
|
+
}
|
|
436
|
+
last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
|
|
437
|
+
if (!last) return [2];
|
|
438
|
+
row_index = last.row_focus;
|
|
439
|
+
col_index = last.column_focus;
|
|
350
440
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
351
|
-
|
|
352
|
-
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
} else if (kstr === "F4" && ctx.luckysheetCellUpdate.length > 0) {
|
|
443
|
+
e.preventDefault();
|
|
444
|
+
} else if (kstr === "Escape" && ctx.luckysheetCellUpdate.length > 0) {
|
|
445
|
+
cancelNormalSelected(ctx);
|
|
446
|
+
moveHighlightCell(ctx, "down", 0, "rangeOfSelect");
|
|
447
|
+
e.preventDefault();
|
|
448
|
+
} else {
|
|
449
|
+
if (e.ctrlKey || e.metaKey) {
|
|
450
|
+
handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo);
|
|
451
|
+
return [2];
|
|
452
|
+
}
|
|
453
|
+
if (e.shiftKey && (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight")) {
|
|
454
|
+
handleShiftWithArrowKey(ctx, e);
|
|
455
|
+
} else if (kstr === "Escape") {
|
|
456
|
+
ctx.contextMenu = {};
|
|
457
|
+
} else if (kstr === "Delete" || kstr === "Backspace") {
|
|
458
|
+
if (!allowEdit) return [2];
|
|
459
|
+
if (ctx.activeImg != null) {
|
|
460
|
+
removeActiveImage(ctx);
|
|
461
|
+
} else {
|
|
462
|
+
deleteSelectedCellText(ctx);
|
|
463
|
+
}
|
|
464
|
+
jfrefreshgrid(ctx, null, undefined);
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
} else if (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight") {
|
|
467
|
+
handleArrowKey(ctx, e);
|
|
468
|
+
} else if (!(kcode >= 112 && kcode <= 123 || kcode <= 46 || kcode === 144 || kcode === 108 || e.ctrlKey || e.altKey || e.shiftKey && (kcode === 37 || kcode === 38 || kcode === 39 || kcode === 40)) || kcode === 8 || kcode === 32 || kcode === 46 || kcode === 0 || e.ctrlKey && kcode === 86) {
|
|
469
|
+
if (!allowEdit) return [2];
|
|
470
|
+
if (String.fromCharCode(kcode) != null && !_.isEmpty(ctx.luckysheet_select_save) && kstr !== "CapsLock" && kstr !== "Win" && kcode !== 18) {
|
|
471
|
+
last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
|
|
472
|
+
row_index = last.row_focus;
|
|
473
|
+
col_index = last.column_focus;
|
|
474
|
+
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
475
|
+
cache.overwriteCell = true;
|
|
476
|
+
handleFormulaInput(ctx, fxInput, cellInput, kcode);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
353
479
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
480
|
+
if (cellInput !== document.activeElement) {
|
|
481
|
+
cellInput === null || cellInput === void 0 ? void 0 : cellInput.focus();
|
|
482
|
+
}
|
|
483
|
+
e.stopPropagation();
|
|
484
|
+
return [2];
|
|
485
|
+
});
|
|
486
|
+
});
|
|
360
487
|
}
|
package/es/locale/en.d.ts
CHANGED
|
@@ -517,8 +517,12 @@ declare const _default: {
|
|
|
517
517
|
conditionformat: {
|
|
518
518
|
conditionformat_greaterThan: string;
|
|
519
519
|
conditionformat_greaterThan_title: string;
|
|
520
|
+
conditionformat_greaterThanOrEqual: string;
|
|
521
|
+
conditionformat_greaterThanOrEqual_title: string;
|
|
520
522
|
conditionformat_lessThan: string;
|
|
521
523
|
conditionformat_lessThan_title: string;
|
|
524
|
+
conditionformat_lessThanOrEqual: string;
|
|
525
|
+
conditionformat_lessThanOrEqual_title: string;
|
|
522
526
|
conditionformat_between: string;
|
|
523
527
|
conditionformat_between_title: string;
|
|
524
528
|
conditionformat_equal: string;
|
|
@@ -619,7 +623,9 @@ declare const _default: {
|
|
|
619
623
|
specificText: string;
|
|
620
624
|
occurrenceDate: string;
|
|
621
625
|
greaterThan: string;
|
|
626
|
+
greaterThanOrEqual: string;
|
|
622
627
|
lessThan: string;
|
|
628
|
+
lessThanOrEqual: string;
|
|
623
629
|
between: string;
|
|
624
630
|
equal: string;
|
|
625
631
|
in: string;
|
package/es/locale/en.js
CHANGED
|
@@ -9075,6 +9075,11 @@ export default {
|
|
|
9075
9075
|
pos: "before",
|
|
9076
9076
|
value: "CLP$",
|
|
9077
9077
|
geckoId: "clp"
|
|
9078
|
+
}, {
|
|
9079
|
+
name: "Czech Koruna",
|
|
9080
|
+
pos: "after",
|
|
9081
|
+
value: "CZK",
|
|
9082
|
+
geckoId: "czk"
|
|
9078
9083
|
}, {
|
|
9079
9084
|
name: "Danish Krone",
|
|
9080
9085
|
pos: "after",
|
|
@@ -9659,8 +9664,12 @@ export default {
|
|
|
9659
9664
|
conditionformat: {
|
|
9660
9665
|
conditionformat_greaterThan: "Conditional format - Greater than",
|
|
9661
9666
|
conditionformat_greaterThan_title: "Format cells greater than",
|
|
9667
|
+
conditionformat_greaterThanOrEqual: "Conditional format - Greater than or equal",
|
|
9668
|
+
conditionformat_greaterThanOrEqual_title: "Format cells greater than or equal",
|
|
9662
9669
|
conditionformat_lessThan: "Conditional format - Less than",
|
|
9663
9670
|
conditionformat_lessThan_title: "Format cells smaller than",
|
|
9671
|
+
conditionformat_lessThanOrEqual: "Conditional format - Less than or equal",
|
|
9672
|
+
conditionformat_lessThanOrEqual_title: "Format cells less than or equal",
|
|
9664
9673
|
conditionformat_between: "Conditional format - Betweenness",
|
|
9665
9674
|
conditionformat_between_title: "Format cells with values between",
|
|
9666
9675
|
conditionformat_equal: "Conditional format - Equal",
|
|
@@ -9761,7 +9770,9 @@ export default {
|
|
|
9761
9770
|
specificText: "Specific text",
|
|
9762
9771
|
occurrenceDate: "Date",
|
|
9763
9772
|
greaterThan: "Greater than",
|
|
9773
|
+
greaterThanOrEqual: "Greater than or equal",
|
|
9764
9774
|
lessThan: "Less than",
|
|
9775
|
+
lessThanOrEqual: "Less than or equal",
|
|
9765
9776
|
between: "Between",
|
|
9766
9777
|
equal: "Equal",
|
|
9767
9778
|
in: "In",
|
|
@@ -16,6 +16,86 @@ import { genarate } from "./format";
|
|
|
16
16
|
import { execfunction, functionCopy } from "./formula";
|
|
17
17
|
import { checkProtectionFormatCells } from "./protection";
|
|
18
18
|
import { isRealNull } from "./validation";
|
|
19
|
+
function hasAlphabeticChars(value) {
|
|
20
|
+
return /[a-zA-Z]/.test(String(value));
|
|
21
|
+
}
|
|
22
|
+
function compareGreaterThan(cellValue, conditionValue, symbol) {
|
|
23
|
+
var cellStr = String(cellValue);
|
|
24
|
+
var conditionStr = String(conditionValue);
|
|
25
|
+
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
26
|
+
if (symbol === '>=') {
|
|
27
|
+
return cellStr.localeCompare(conditionStr) >= 0;
|
|
28
|
+
}
|
|
29
|
+
return cellStr.localeCompare(conditionStr) > 0;
|
|
30
|
+
}
|
|
31
|
+
var cellNum = Number(cellValue);
|
|
32
|
+
var conditionNum = Number(conditionValue);
|
|
33
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '>=') {
|
|
34
|
+
return cellNum >= conditionNum;
|
|
35
|
+
}
|
|
36
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '>') {
|
|
37
|
+
return cellNum > conditionNum;
|
|
38
|
+
}
|
|
39
|
+
if (symbol === '>=') {
|
|
40
|
+
return cellStr.localeCompare(conditionStr) >= 0;
|
|
41
|
+
}
|
|
42
|
+
return cellStr.localeCompare(conditionStr) > 0;
|
|
43
|
+
}
|
|
44
|
+
function compareLessThan(cellValue, conditionValue, symbol) {
|
|
45
|
+
var cellStr = String(cellValue);
|
|
46
|
+
var conditionStr = String(conditionValue);
|
|
47
|
+
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
48
|
+
if (symbol === '<=') {
|
|
49
|
+
return cellStr.localeCompare(conditionStr) <= 0;
|
|
50
|
+
}
|
|
51
|
+
return cellStr.localeCompare(conditionStr) < 0;
|
|
52
|
+
}
|
|
53
|
+
var cellNum = Number(cellValue);
|
|
54
|
+
var conditionNum = Number(conditionValue);
|
|
55
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '<=') {
|
|
56
|
+
return cellNum <= conditionNum;
|
|
57
|
+
}
|
|
58
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum)) {
|
|
59
|
+
return cellNum < conditionNum;
|
|
60
|
+
}
|
|
61
|
+
if (symbol === '<=') {
|
|
62
|
+
return cellStr.localeCompare(conditionStr) <= 0;
|
|
63
|
+
}
|
|
64
|
+
return cellStr.localeCompare(conditionStr) < 0;
|
|
65
|
+
}
|
|
66
|
+
function compareBetween(cellValue, value1, value2) {
|
|
67
|
+
var cellStr = String(cellValue);
|
|
68
|
+
var val1Str = String(value1);
|
|
69
|
+
var val2Str = String(value2);
|
|
70
|
+
var smallerValue, biggerValue;
|
|
71
|
+
if (hasAlphabeticChars(value1) || hasAlphabeticChars(value2) || hasAlphabeticChars(cellValue)) {
|
|
72
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
73
|
+
biggerValue = val1Str;
|
|
74
|
+
smallerValue = val2Str;
|
|
75
|
+
} else {
|
|
76
|
+
biggerValue = val2Str;
|
|
77
|
+
smallerValue = val1Str;
|
|
78
|
+
}
|
|
79
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
80
|
+
} else {
|
|
81
|
+
var cellNum = Number(cellValue);
|
|
82
|
+
var val1Num = Number(value1);
|
|
83
|
+
var val2Num = Number(value2);
|
|
84
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
85
|
+
var smallerNum = Math.min(val1Num, val2Num);
|
|
86
|
+
var biggerNum = Math.max(val1Num, val2Num);
|
|
87
|
+
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
88
|
+
}
|
|
89
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
90
|
+
biggerValue = val1Str;
|
|
91
|
+
smallerValue = val2Str;
|
|
92
|
+
} else {
|
|
93
|
+
biggerValue = val2Str;
|
|
94
|
+
smallerValue = val1Str;
|
|
95
|
+
}
|
|
96
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
19
99
|
export function getHistoryRules(fileH) {
|
|
20
100
|
var historyRules = [];
|
|
21
101
|
for (var h = 0; h < fileH.length; h += 1) {
|
|
@@ -44,7 +124,7 @@ export function setConditionRules(ctx, protection, generalDialog, conditionforma
|
|
|
44
124
|
var conditionName = rules.rulesType;
|
|
45
125
|
var conditionRange = [];
|
|
46
126
|
var conditionValue = [];
|
|
47
|
-
if (conditionName === "greaterThan" || conditionName === "lessThan" || conditionName === "equal" || conditionName === "textContains") {
|
|
127
|
+
if (conditionName === "greaterThan" || conditionName === "greaterThanOrEqual" || conditionName === "lessThan" || conditionName === "lessThanOrEqual" || conditionName === "equal" || conditionName === "textContains") {
|
|
48
128
|
var v = rules.rulesValue;
|
|
49
129
|
var rangeArr = getRangeByTxt(ctx, v);
|
|
50
130
|
if (rangeArr.length > 1) {
|
|
@@ -468,7 +548,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
468
548
|
var textColor_1 = format.textColor,
|
|
469
549
|
cellColor_1 = format.cellColor;
|
|
470
550
|
for (var s = 0; s < cellrange.length; s += 1) {
|
|
471
|
-
if (conditionName === "greaterThan" || conditionName === "lessThan" || conditionName === "equal" || conditionName === "textContains") {
|
|
551
|
+
if (conditionName === "greaterThan" || conditionName === "greaterThanOrEqual" || conditionName === "lessThan" || conditionName === "lessThanOrEqual" || conditionName === "equal" || conditionName === "textContains") {
|
|
472
552
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
473
553
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
474
554
|
if (_.isNil(d[r]) || _.isNil(d[r][c])) {
|
|
@@ -478,7 +558,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
478
558
|
if (_.isNil(cell) || _.isNil(cell.v) || isRealNull(cell.v)) {
|
|
479
559
|
continue;
|
|
480
560
|
}
|
|
481
|
-
if (conditionName === "greaterThan" &&
|
|
561
|
+
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0, '>')) {
|
|
482
562
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
483
563
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
484
564
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -488,7 +568,27 @@ export function compute(ctx, ruleArr, d) {
|
|
|
488
568
|
cellColor: cellColor_1
|
|
489
569
|
};
|
|
490
570
|
}
|
|
491
|
-
} else if (conditionName === "
|
|
571
|
+
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0, '>=')) {
|
|
572
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
573
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
574
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
575
|
+
} else {
|
|
576
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
577
|
+
textColor: textColor_1,
|
|
578
|
+
cellColor: cellColor_1
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
} else if (conditionName === "lessThan" && compareLessThan(cell.v, conditionValue0, "<")) {
|
|
582
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
583
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
584
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
585
|
+
} else {
|
|
586
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
587
|
+
textColor: textColor_1,
|
|
588
|
+
cellColor: cellColor_1
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0, '<=')) {
|
|
492
592
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
493
593
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
494
594
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -522,15 +622,6 @@ export function compute(ctx, ruleArr, d) {
|
|
|
522
622
|
}
|
|
523
623
|
}
|
|
524
624
|
} else if (conditionName === "between") {
|
|
525
|
-
var vBig = 0;
|
|
526
|
-
var vSmall = 0;
|
|
527
|
-
if (conditionValue0 > conditionValue1) {
|
|
528
|
-
vBig = conditionValue0;
|
|
529
|
-
vSmall = conditionValue1;
|
|
530
|
-
} else {
|
|
531
|
-
vBig = conditionValue1;
|
|
532
|
-
vSmall = conditionValue0;
|
|
533
|
-
}
|
|
534
625
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
535
626
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
536
627
|
if (_.isNil(d[r]) || _.isNil(d[r][c])) {
|
|
@@ -540,7 +631,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
540
631
|
if (_.isNil(cell) || _.isNil(cell.v) || isRealNull(cell.v)) {
|
|
541
632
|
continue;
|
|
542
633
|
}
|
|
543
|
-
if (
|
|
634
|
+
if (compareBetween(cell.v, conditionValue0, conditionValue1)) {
|
|
544
635
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
545
636
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
546
637
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -1004,7 +1095,7 @@ export function CFSplitRange(range1, range2, range3, type) {
|
|
|
1004
1095
|
row: [range2.row[1] + 1, r2],
|
|
1005
1096
|
column: [c1, c2]
|
|
1006
1097
|
}, {
|
|
1007
|
-
row: [
|
|
1098
|
+
row: [range2.row[0] + offset_r, r2 + offset_r],
|
|
1008
1099
|
column: [range2.column[0] + offset_c, c2 + offset_c]
|
|
1009
1100
|
}];
|
|
1010
1101
|
} else if (type === "restPart") {
|
|
@@ -1017,7 +1108,7 @@ export function CFSplitRange(range1, range2, range3, type) {
|
|
|
1017
1108
|
}];
|
|
1018
1109
|
} else if (type === "operatePart") {
|
|
1019
1110
|
range = [{
|
|
1020
|
-
row: [
|
|
1111
|
+
row: [range2.row[0] + offset_r, r2 + offset_r],
|
|
1021
1112
|
column: [range2.column[0] + offset_c, c2 + offset_c]
|
|
1022
1113
|
}];
|
|
1023
1114
|
}
|
|
@@ -25,6 +25,8 @@ export declare function rangeValueToHtml(ctx: Context, sheetId: string, ranges?:
|
|
|
25
25
|
export declare function copy(ctx: Context): void;
|
|
26
26
|
export declare function deleteSelectedCellText(ctx: Context): string;
|
|
27
27
|
export declare function deleteSelectedCellFormat(ctx: Context): string;
|
|
28
|
+
export declare function fillRightData(ctx: Context): string;
|
|
29
|
+
export declare function fillDownData(ctx: Context): string;
|
|
28
30
|
export declare function textFormat(ctx: Context, type: "left" | "center" | "right"): string;
|
|
29
31
|
export declare function fillDate(ctx: Context): string;
|
|
30
32
|
export declare function fillTime(ctx: Context): string;
|