@fileverse-dev/fortune-core 1.3.12 → 1.3.13-create-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/events/keyboard.d.ts +2 -2
- package/es/events/keyboard.js +204 -30
- package/es/events/mouse.js +79 -44
- package/es/events/paste.js +240 -56
- package/es/locale/en.d.ts +3 -0
- package/es/locale/en.js +3 -0
- package/es/locale/es.d.ts +3 -0
- package/es/locale/es.js +3 -0
- package/es/locale/hi.d.ts +3 -0
- package/es/locale/hi.js +3 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/zh.d.ts +3 -0
- package/es/locale/zh.js +3 -0
- package/es/locale/zh_tw.d.ts +3 -0
- package/es/locale/zh_tw.js +3 -0
- package/es/modules/ConditionFormat.js +26 -0
- package/es/modules/cell.d.ts +5 -1
- package/es/modules/cell.js +182 -38
- package/es/modules/clipboard.js +111 -2
- package/es/modules/format.js +12 -7
- package/es/modules/formula.d.ts +23 -0
- package/es/modules/formula.js +610 -51
- package/es/modules/hyperlink.js +18 -6
- package/es/modules/inline-string.js +61 -8
- package/es/modules/moveCells.js +52 -9
- package/es/modules/selection.d.ts +1 -0
- package/es/modules/selection.js +102 -16
- package/es/modules/validation.js +6 -3
- package/es/paste-helpers/calculate-range-cell-size.js +5 -4
- package/es/paste-table-helpers.d.ts +1 -1
- package/es/paste-table-helpers.js +170 -21
- package/es/types.d.ts +3 -0
- package/lib/events/keyboard.d.ts +2 -2
- package/lib/events/keyboard.js +203 -29
- package/lib/events/mouse.js +78 -43
- package/lib/events/paste.js +238 -54
- package/lib/locale/en.d.ts +3 -0
- package/lib/locale/en.js +3 -0
- package/lib/locale/es.d.ts +3 -0
- package/lib/locale/es.js +3 -0
- package/lib/locale/hi.d.ts +3 -0
- package/lib/locale/hi.js +3 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/zh.d.ts +3 -0
- package/lib/locale/zh.js +3 -0
- package/lib/locale/zh_tw.d.ts +3 -0
- package/lib/locale/zh_tw.js +3 -0
- package/lib/modules/ConditionFormat.js +26 -0
- package/lib/modules/cell.d.ts +5 -1
- package/lib/modules/cell.js +180 -36
- package/lib/modules/clipboard.js +111 -2
- package/lib/modules/format.js +12 -7
- package/lib/modules/formula.d.ts +23 -0
- package/lib/modules/formula.js +623 -51
- package/lib/modules/hyperlink.js +18 -6
- package/lib/modules/inline-string.js +61 -8
- package/lib/modules/moveCells.js +52 -9
- package/lib/modules/selection.d.ts +1 -0
- package/lib/modules/selection.js +101 -15
- package/lib/modules/validation.js +6 -3
- package/lib/paste-helpers/calculate-range-cell-size.js +5 -4
- package/lib/paste-table-helpers.d.ts +1 -1
- package/lib/paste-table-helpers.js +170 -21
- package/lib/types.d.ts +3 -0
- package/package.json +1 -1
package/lib/events/keyboard.js
CHANGED
|
@@ -12,12 +12,14 @@ var _2 = require("..");
|
|
|
12
12
|
var _context = require("../context");
|
|
13
13
|
var _cell = require("../modules/cell");
|
|
14
14
|
var _formula = require("../modules/formula");
|
|
15
|
+
var _inlineString = require("../modules/inline-string");
|
|
15
16
|
var _selection = require("../modules/selection");
|
|
16
17
|
var _toolbar = require("../modules/toolbar");
|
|
17
18
|
var _validation = require("../modules/validation");
|
|
18
19
|
var _utils = require("../utils");
|
|
19
20
|
var _copy = require("./copy");
|
|
20
21
|
var _refresh = require("../modules/refresh");
|
|
22
|
+
var _cursor = require("../modules/cursor");
|
|
21
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
24
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
23
25
|
function adopt(value) {
|
|
@@ -134,8 +136,21 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
134
136
|
};
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
+
function clearTypeOverPending(cache) {
|
|
140
|
+
delete cache.pendingTypeOverCell;
|
|
141
|
+
}
|
|
142
|
+
function getTypeOverInitialContent(e) {
|
|
143
|
+
if (e.keyCode === 229) return undefined;
|
|
144
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return undefined;
|
|
145
|
+
if (e.key === "Backspace" || e.key === "Delete") return "";
|
|
146
|
+
if (e.key.length === 1) return e.key;
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
function isLegacyFormulaRangeMode(ctx) {
|
|
150
|
+
return !!ctx.formulaCache.rangestart || !!ctx.formulaCache.rangedrag_column_start || !!ctx.formulaCache.rangedrag_row_start || ctx.formulaCache.rangeSelectionActive === true || (0, _formula.israngeseleciton)(ctx);
|
|
151
|
+
}
|
|
152
|
+
function handleGlobalEnter(ctx, cellInput, e, cache, canvas) {
|
|
153
|
+
var _a, _b, _c, _d;
|
|
139
154
|
if ((e.altKey || e.metaKey) && ctx.luckysheetCellUpdate.length > 0) {
|
|
140
155
|
var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
|
|
141
156
|
if (last && !_lodash.default.isNil(last.row_focus) && !_lodash.default.isNil(last.column_focus)) {}
|
|
@@ -143,33 +158,61 @@ function handleGlobalEnter(ctx, cellInput, e, canvas) {
|
|
|
143
158
|
} else if (ctx.luckysheetCellUpdate.length > 0) {
|
|
144
159
|
var lastCellUpdate = _lodash.default.clone(ctx.luckysheetCellUpdate);
|
|
145
160
|
(0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
161
|
+
cache.enteredEditByTyping = false;
|
|
162
|
+
clearTypeOverPending(cache);
|
|
146
163
|
ctx.luckysheet_select_save = [{
|
|
147
164
|
row: [lastCellUpdate[0], lastCellUpdate[0]],
|
|
148
165
|
column: [lastCellUpdate[1], lastCellUpdate[1]],
|
|
149
166
|
row_focus: lastCellUpdate[0],
|
|
150
167
|
column_focus: lastCellUpdate[1]
|
|
151
168
|
}];
|
|
152
|
-
(0,
|
|
169
|
+
var rowStep = e.shiftKey ? -(0, _2.hideCRCount)(ctx, "ArrowUp") : (0, _2.hideCRCount)(ctx, "ArrowDown");
|
|
170
|
+
(0, _selection.moveHighlightCell)(ctx, "down", rowStep, "rangeOfSelect");
|
|
153
171
|
e.preventDefault();
|
|
154
172
|
} else {
|
|
155
173
|
if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0) {
|
|
156
174
|
var last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
|
|
157
175
|
var row_index = last.row_focus;
|
|
158
176
|
var col_index = last.column_focus;
|
|
177
|
+
if (!_lodash.default.isNil(row_index) && !_lodash.default.isNil(col_index)) {
|
|
178
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
179
|
+
var cellAt = (_d = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _d === void 0 ? void 0 : _d[col_index];
|
|
180
|
+
if ((cellAt === null || cellAt === void 0 ? void 0 : cellAt.f) != null && String(cellAt.f).trim() !== "") {
|
|
181
|
+
(0, _formula.suppressFormulaRangeSelectionForInitialEdit)(ctx);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
159
184
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
185
|
+
cache.enteredEditByTyping = false;
|
|
186
|
+
clearTypeOverPending(cache);
|
|
160
187
|
e.preventDefault();
|
|
161
188
|
}
|
|
162
189
|
}
|
|
163
190
|
}
|
|
191
|
+
function cellCountsForDataEdge(cell) {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
if (cell == null) return false;
|
|
194
|
+
if (!_lodash.default.isPlainObject(cell)) return !_lodash.default.isNil(cell);
|
|
195
|
+
if (cell.f != null && String(cell.f) !== "") return true;
|
|
196
|
+
if (!_lodash.default.isNil(cell.v)) return true;
|
|
197
|
+
if ((0, _inlineString.isInlineStringCell)(cell)) {
|
|
198
|
+
return ((_b = (_a = cell.ct) === null || _a === void 0 ? void 0 : _a.s) !== null && _b !== void 0 ? _b : []).some(function (seg) {
|
|
199
|
+
return (seg === null || seg === void 0 ? void 0 : seg.v) != null && String(seg.v).length > 0;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
164
204
|
function moveToEdge(sheetData, key, curr, rowDelta, colDelta, startR, endR, startC, endC, maxRow, maxCol) {
|
|
165
|
-
var _a, _b, _c
|
|
205
|
+
var _a, _b, _c;
|
|
166
206
|
var selectedLimit = -1;
|
|
167
207
|
if (key === "ArrowUp") selectedLimit = startR - 1;else if (key === "ArrowDown") selectedLimit = endR + 1;else if (key === "ArrowLeft") selectedLimit = startC - 1;else if (key === "ArrowRight") selectedLimit = endC + 1;
|
|
168
208
|
var maxRowCol = colDelta === 0 ? maxRow : maxCol;
|
|
169
209
|
var r = colDelta === 0 ? selectedLimit : curr;
|
|
170
210
|
var c = colDelta === 0 ? curr : selectedLimit;
|
|
171
211
|
while (r >= 0 && c >= 0 && (colDelta === 0 ? r : c) < maxRowCol - 1) {
|
|
172
|
-
|
|
212
|
+
var here = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[r]) === null || _a === void 0 ? void 0 : _a[c];
|
|
213
|
+
var behind = (_b = sheetData === null || sheetData === void 0 ? void 0 : sheetData[r - rowDelta]) === null || _b === void 0 ? void 0 : _b[c - colDelta];
|
|
214
|
+
var ahead = (_c = sheetData === null || sheetData === void 0 ? void 0 : sheetData[r + rowDelta]) === null || _c === void 0 ? void 0 : _c[c + colDelta];
|
|
215
|
+
if (cellCountsForDataEdge(here) && (!cellCountsForDataEdge(behind) || !cellCountsForDataEdge(ahead))) {
|
|
173
216
|
break;
|
|
174
217
|
} else {
|
|
175
218
|
r += 1 * rowDelta;
|
|
@@ -178,12 +221,51 @@ function moveToEdge(sheetData, key, curr, rowDelta, colDelta, startR, endR, star
|
|
|
178
221
|
}
|
|
179
222
|
return colDelta === 0 ? r : c;
|
|
180
223
|
}
|
|
224
|
+
function isPlainTextCellOrFxEdit(ctx, cellInput, fxInput) {
|
|
225
|
+
var _a, _b, _c;
|
|
226
|
+
if (ctx.luckysheetCellUpdate.length === 0) return false;
|
|
227
|
+
var cellT = ((_a = cellInput === null || cellInput === void 0 ? void 0 : cellInput.innerText) !== null && _a !== void 0 ? _a : "").trim();
|
|
228
|
+
var fxT = ((_b = fxInput === null || fxInput === void 0 ? void 0 : fxInput.innerText) !== null && _b !== void 0 ? _b : "").trim();
|
|
229
|
+
var owner = (0, _formula.getFormulaEditorOwner)(ctx);
|
|
230
|
+
if (owner === "fx" && fxInput) {
|
|
231
|
+
return !fxT.startsWith("=");
|
|
232
|
+
}
|
|
233
|
+
if (owner === "cell") {
|
|
234
|
+
return !cellT.startsWith("=");
|
|
235
|
+
}
|
|
236
|
+
var aid = (_c = document.activeElement) === null || _c === void 0 ? void 0 : _c.id;
|
|
237
|
+
if (aid === "luckysheet-functionbox-cell" && fxInput) {
|
|
238
|
+
return !fxT.startsWith("=");
|
|
239
|
+
}
|
|
240
|
+
if (aid === "luckysheet-rich-text-editor") {
|
|
241
|
+
return !cellT.startsWith("=");
|
|
242
|
+
}
|
|
243
|
+
if (cellT.startsWith("=") || fxT.startsWith("=")) return false;
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
function isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput) {
|
|
247
|
+
return (cache === null || cache === void 0 ? void 0 : cache.enteredEditByTyping) === true && ctx.luckysheetCellUpdate.length > 0 && isPlainTextCellOrFxEdit(ctx, cellInput, fxInput);
|
|
248
|
+
}
|
|
249
|
+
function commitDirectPlainCellEdit(ctx, cache, cellInput, canvas) {
|
|
250
|
+
if (ctx.luckysheetCellUpdate.length === 0) return;
|
|
251
|
+
(0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
252
|
+
if (cache) {
|
|
253
|
+
cache.enteredEditByTyping = false;
|
|
254
|
+
clearTypeOverPending(cache);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
181
257
|
function handleControlPlusArrowKey(ctx, e, shiftPressed) {
|
|
182
|
-
|
|
258
|
+
var isFormulaRefMode = isLegacyFormulaRangeMode(ctx);
|
|
259
|
+
if (isFormulaRefMode) {
|
|
260
|
+
ctx.formulaCache.rangeSelectionActive = true;
|
|
261
|
+
}
|
|
262
|
+
if (ctx.luckysheetCellUpdate.length > 0 && !isFormulaRefMode) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
183
265
|
var idx = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
184
266
|
if (_lodash.default.isNil(idx)) return;
|
|
185
267
|
var file = ctx.luckysheetfile[idx];
|
|
186
|
-
if (!file ||
|
|
268
|
+
if (!file || _lodash.default.isNil(file.row) || _lodash.default.isNil(file.column)) return;
|
|
187
269
|
var maxRow = file.row;
|
|
188
270
|
var maxCol = file.column;
|
|
189
271
|
var last;
|
|
@@ -242,10 +324,17 @@ function handleControlPlusArrowKey(ctx, e, shiftPressed) {
|
|
|
242
324
|
break;
|
|
243
325
|
}
|
|
244
326
|
}
|
|
245
|
-
function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo) {
|
|
246
|
-
var _a, _b, _c, _d;
|
|
327
|
+
function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas) {
|
|
328
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
247
329
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
248
330
|
if (!flowdata) return;
|
|
331
|
+
if ((e.ctrlKey || e.metaKey) && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key) && isPlainTextCellOrFxEdit(ctx, cellInput, fxInput)) {
|
|
332
|
+
if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
|
|
333
|
+
commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
|
|
334
|
+
} else {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
249
338
|
if (e.shiftKey) {
|
|
250
339
|
ctx.luckysheet_shiftpositon = _lodash.default.cloneDeep((_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1]);
|
|
251
340
|
ctx.luckysheet_shiftkeydown = true;
|
|
@@ -258,6 +347,8 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
258
347
|
var col_index = last.column_focus;
|
|
259
348
|
(0, _cell.updateCell)(ctx, row_index, col_index, cellInput);
|
|
260
349
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
350
|
+
cache.enteredEditByTyping = false;
|
|
351
|
+
clearTypeOverPending(cache);
|
|
261
352
|
cache.ignoreWriteCell = true;
|
|
262
353
|
var value = (0, _utils.getNowDateTime)(2);
|
|
263
354
|
cellInput.innerText = value;
|
|
@@ -266,6 +357,14 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
266
357
|
handleRedo();
|
|
267
358
|
e.stopPropagation();
|
|
268
359
|
return;
|
|
360
|
+
} else if (e.code === "KeyV") {
|
|
361
|
+
if (((_d = (_c = ctx.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 1) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
_selection.selectionCache.isPasteAction = true;
|
|
365
|
+
_selection.selectionCache.isPasteValuesOnly = true;
|
|
366
|
+
e.stopPropagation();
|
|
367
|
+
return;
|
|
269
368
|
}
|
|
270
369
|
} else if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
271
370
|
handleControlPlusArrowKey(ctx, e, false);
|
|
@@ -278,7 +377,14 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
278
377
|
} else if (e.code === "Backslash") {
|
|
279
378
|
(0, _selection.deleteSelectedCellFormat)(ctx);
|
|
280
379
|
} else if (e.code === "KeyC") {
|
|
281
|
-
|
|
380
|
+
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
var sel = window.getSelection();
|
|
383
|
+
var text = sel && !sel.isCollapsed ? sel.toString() : cellInput.innerText;
|
|
384
|
+
(_e = navigator.clipboard) === null || _e === void 0 ? void 0 : _e.writeText(text).catch(function () {});
|
|
385
|
+
} else {
|
|
386
|
+
(0, _copy.handleCopy)(ctx);
|
|
387
|
+
}
|
|
282
388
|
e.stopPropagation();
|
|
283
389
|
return;
|
|
284
390
|
} else if (e.code === "KeyF") {
|
|
@@ -286,7 +392,7 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
286
392
|
} else if (e.code === "KeyH") {
|
|
287
393
|
ctx.showReplace = true;
|
|
288
394
|
} else if (e.code === "KeyV") {
|
|
289
|
-
if (((
|
|
395
|
+
if (((_g = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0) > 1) {
|
|
290
396
|
return;
|
|
291
397
|
}
|
|
292
398
|
_selection.selectionCache.isPasteAction = true;
|
|
@@ -334,7 +440,17 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
334
440
|
}
|
|
335
441
|
function handleShiftWithArrowKey(ctx, e) {
|
|
336
442
|
var _a;
|
|
337
|
-
if (ctx.
|
|
443
|
+
if (ctx.formulaCache.keyboardRangeSelectionLock === true) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (ctx.formulaCache.rangeSelectionActive === false && !(0, _formula.maybeRecoverDirtyRangeSelection)(ctx)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
var isFormulaMode = isLegacyFormulaRangeMode(ctx);
|
|
450
|
+
if (isFormulaMode) {
|
|
451
|
+
ctx.formulaCache.rangeSelectionActive = true;
|
|
452
|
+
}
|
|
453
|
+
if (ctx.luckysheetCellUpdate.length > 0 && !isFormulaMode) {
|
|
338
454
|
return;
|
|
339
455
|
}
|
|
340
456
|
ctx.luckysheet_shiftpositon = _lodash.default.cloneDeep((_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1]);
|
|
@@ -358,17 +474,18 @@ function handleShiftWithArrowKey(ctx, e) {
|
|
|
358
474
|
e.preventDefault();
|
|
359
475
|
}
|
|
360
476
|
function handleArrowKey(ctx, e) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
477
|
+
if (ctx.formulaCache.keyboardRangeSelectionLock === true) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (ctx.formulaCache.rangeSelectionActive === false && !(0, _formula.maybeRecoverDirtyRangeSelection)(ctx)) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
var isFormulaRefMode = isLegacyFormulaRangeMode(ctx);
|
|
484
|
+
if (isFormulaRefMode) ctx.formulaCache.rangeSelectionActive = true;
|
|
485
|
+
if (ctx.luckysheetCellUpdate.length > 0 && !isFormulaRefMode) {
|
|
486
|
+
return;
|
|
371
487
|
}
|
|
488
|
+
if (ctx.luckysheetCellUpdate.length > 0 || ctx.luckysheet_cell_selected_move || ctx.luckysheet_cell_selected_extend) {}
|
|
372
489
|
var moveCount = (0, _2.hideCRCount)(ctx, e.key);
|
|
373
490
|
switch (e.key) {
|
|
374
491
|
case "ArrowUp":
|
|
@@ -386,12 +503,13 @@ function handleArrowKey(ctx, e) {
|
|
|
386
503
|
default:
|
|
387
504
|
break;
|
|
388
505
|
}
|
|
506
|
+
e.preventDefault();
|
|
389
507
|
}
|
|
390
508
|
function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
|
|
391
|
-
var _a, _b, _c;
|
|
509
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
392
510
|
return __awaiter(this, void 0, void 0, function () {
|
|
393
|
-
var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
|
|
394
|
-
return __generator(this, function (
|
|
511
|
+
var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, flowdataF2, cellF2, isEditing, inlineText, fxText, isFormulaEdit, enteredByTyping, last, row_index, col_index, flowdata, cellAt, existingFormula, initial;
|
|
512
|
+
return __generator(this, function (_h) {
|
|
395
513
|
if (e.shiftKey && e.code === "Space") {
|
|
396
514
|
e.stopImmediatePropagation();
|
|
397
515
|
e.stopPropagation();
|
|
@@ -452,10 +570,12 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
452
570
|
}
|
|
453
571
|
if (kstr === "Enter") {
|
|
454
572
|
if (!allowEdit) return [2];
|
|
455
|
-
handleGlobalEnter(ctx, cellInput, e, canvas);
|
|
573
|
+
handleGlobalEnter(ctx, cellInput, e, cache, canvas);
|
|
456
574
|
} else if (kstr === "Tab") {
|
|
457
575
|
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
458
576
|
(0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
577
|
+
cache.enteredEditByTyping = false;
|
|
578
|
+
clearTypeOverPending(cache);
|
|
459
579
|
}
|
|
460
580
|
if (e.shiftKey) {
|
|
461
581
|
(0, _selection.moveHighlightCell)(ctx, "right", -(0, _2.hideCRCount)(ctx, "ArrowLeft"), "rangeOfSelect");
|
|
@@ -472,20 +592,34 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
472
592
|
if (!last) return [2];
|
|
473
593
|
row_index = last.row_focus;
|
|
474
594
|
col_index = last.column_focus;
|
|
595
|
+
if (!_lodash.default.isNil(row_index) && !_lodash.default.isNil(col_index)) {
|
|
596
|
+
flowdataF2 = (0, _context.getFlowdata)(ctx);
|
|
597
|
+
cellF2 = (_d = flowdataF2 === null || flowdataF2 === void 0 ? void 0 : flowdataF2[row_index]) === null || _d === void 0 ? void 0 : _d[col_index];
|
|
598
|
+
if ((cellF2 === null || cellF2 === void 0 ? void 0 : cellF2.f) != null && String(cellF2.f).trim() !== "") {
|
|
599
|
+
(0, _formula.suppressFormulaRangeSelectionForInitialEdit)(ctx);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
cache.enteredEditByTyping = false;
|
|
603
|
+
clearTypeOverPending(cache);
|
|
475
604
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
476
605
|
e.preventDefault();
|
|
477
606
|
} else if (kstr === "F4" && ctx.luckysheetCellUpdate.length > 0) {
|
|
478
607
|
e.preventDefault();
|
|
479
608
|
} else if (kstr === "Escape" && ctx.luckysheetCellUpdate.length > 0) {
|
|
609
|
+
cache.enteredEditByTyping = false;
|
|
610
|
+
clearTypeOverPending(cache);
|
|
480
611
|
(0, _cell.cancelNormalSelected)(ctx);
|
|
481
612
|
(0, _selection.moveHighlightCell)(ctx, "down", 0, "rangeOfSelect");
|
|
482
613
|
e.preventDefault();
|
|
483
614
|
} else {
|
|
484
615
|
if (e.ctrlKey || e.metaKey) {
|
|
485
|
-
handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo);
|
|
616
|
+
handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas);
|
|
486
617
|
return [2];
|
|
487
618
|
}
|
|
488
619
|
if (e.shiftKey && (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight")) {
|
|
620
|
+
if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
|
|
621
|
+
commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
|
|
622
|
+
}
|
|
489
623
|
handleShiftWithArrowKey(ctx, e);
|
|
490
624
|
} else if (kstr === "Escape") {
|
|
491
625
|
ctx.contextMenu = {};
|
|
@@ -494,21 +628,61 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
494
628
|
if (ctx.activeImg != null) {
|
|
495
629
|
(0, _2.removeActiveImage)(ctx);
|
|
496
630
|
} else {
|
|
631
|
+
if (ctx.formulaCache.rangeSelectionActive === true) {
|
|
632
|
+
(0, _formula.markRangeSelectionDirty)(ctx);
|
|
633
|
+
}
|
|
497
634
|
(0, _selection.deleteSelectedCellText)(ctx);
|
|
498
635
|
}
|
|
499
636
|
(0, _refresh.jfrefreshgrid)(ctx, null, undefined);
|
|
500
637
|
e.preventDefault();
|
|
501
638
|
} else if (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight") {
|
|
502
|
-
|
|
639
|
+
isEditing = ctx.luckysheetCellUpdate.length > 0;
|
|
640
|
+
inlineText = (_e = cellInput === null || cellInput === void 0 ? void 0 : cellInput.innerText) !== null && _e !== void 0 ? _e : "";
|
|
641
|
+
fxText = (_f = fxInput === null || fxInput === void 0 ? void 0 : fxInput.innerText) !== null && _f !== void 0 ? _f : "";
|
|
642
|
+
isFormulaEdit = isEditing && (inlineText.trim().startsWith("=") || fxText.trim().startsWith("="));
|
|
643
|
+
enteredByTyping = cache.enteredEditByTyping === true;
|
|
644
|
+
if (isEditing && !isFormulaEdit && enteredByTyping && !e.shiftKey) {
|
|
645
|
+
(0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
646
|
+
cache.enteredEditByTyping = false;
|
|
647
|
+
clearTypeOverPending(cache);
|
|
648
|
+
handleArrowKey(ctx, e);
|
|
649
|
+
e.preventDefault();
|
|
650
|
+
} else {
|
|
651
|
+
handleArrowKey(ctx, e);
|
|
652
|
+
}
|
|
503
653
|
} 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) {
|
|
504
654
|
if (!allowEdit) return [2];
|
|
505
655
|
if (String.fromCharCode(kcode) != null && !_lodash.default.isEmpty(ctx.luckysheet_select_save) && kstr !== "CapsLock" && kstr !== "Win" && kcode !== 18) {
|
|
506
656
|
last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
|
|
507
657
|
row_index = last.row_focus;
|
|
508
658
|
col_index = last.column_focus;
|
|
659
|
+
if (_lodash.default.isNil(row_index) || _lodash.default.isNil(col_index)) return [2];
|
|
660
|
+
flowdata = (0, _context.getFlowdata)(ctx);
|
|
661
|
+
cellAt = (_g = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _g === void 0 ? void 0 : _g[col_index];
|
|
662
|
+
existingFormula = (cellAt === null || cellAt === void 0 ? void 0 : cellAt.f) != null && String(cellAt.f).trim() !== "" ? String(cellAt.f).replace(/[\r\n]/g, "") : null;
|
|
663
|
+
if (existingFormula != null) {
|
|
664
|
+
(0, _formula.suppressFormulaRangeSelectionForInitialEdit)(ctx);
|
|
665
|
+
}
|
|
509
666
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
510
667
|
cache.overwriteCell = true;
|
|
511
|
-
|
|
668
|
+
cache.pendingTypeOverCell = [row_index, col_index];
|
|
669
|
+
(0, _formula.setFormulaEditorOwner)(ctx, "cell");
|
|
670
|
+
cache.enteredEditByTyping = true;
|
|
671
|
+
cellInput.focus();
|
|
672
|
+
initial = getTypeOverInitialContent(e);
|
|
673
|
+
if (initial !== undefined) {
|
|
674
|
+
cellInput.textContent = initial;
|
|
675
|
+
if (fxInput) fxInput.textContent = initial;
|
|
676
|
+
(0, _formula.handleFormulaInput)(ctx, fxInput, cellInput, kcode);
|
|
677
|
+
e.preventDefault();
|
|
678
|
+
} else {
|
|
679
|
+
cellInput.textContent = "";
|
|
680
|
+
if (fxInput) fxInput.textContent = "";
|
|
681
|
+
(0, _formula.handleFormulaInput)(ctx, fxInput, cellInput, kcode);
|
|
682
|
+
}
|
|
683
|
+
queueMicrotask(function () {
|
|
684
|
+
(0, _cursor.moveToEnd)(cellInput);
|
|
685
|
+
});
|
|
512
686
|
}
|
|
513
687
|
}
|
|
514
688
|
}
|