@fileverse-dev/fortune-core 1.3.11-mixed → 1.3.12

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.
@@ -291,6 +291,9 @@ function extendCssText(origin, cover, isLimit) {
291
291
  }
292
292
  return newCss;
293
293
  }
294
+ function escapeHtmlAttr(s) {
295
+ return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
296
+ }
294
297
  export function updateInlineStringFormat(ctx, attr, value, cellInput) {
295
298
  var _a, _b, _c;
296
299
  var w = window.getSelection();
@@ -298,6 +301,34 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
298
301
  if (w.rangeCount === 0) return;
299
302
  var range = w.getRangeAt(0);
300
303
  var $textEditor = cellInput;
304
+ if (range.startContainer === $textEditor && range.endContainer === $textEditor && range.collapsed === false) {
305
+ var start = range.startOffset;
306
+ var end = range.endOffset;
307
+ var children = Array.from($textEditor.childNodes).slice(start, end);
308
+ children.forEach(function (node) {
309
+ var _a, _b;
310
+ if (node.nodeType === Node.ELEMENT_NODE) {
311
+ var el = node;
312
+ if (el.tagName === "SPAN") {
313
+ var cssText = getCssText(el.style.cssText, attr, value);
314
+ el.setAttribute("style", cssText);
315
+ }
316
+ } else if (node.nodeType === Node.TEXT_NODE) {
317
+ var text = (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
318
+ if (text.length === 0) return;
319
+ var wrapper = document.createElement("span");
320
+ var cssText = getCssText("", attr, value);
321
+ wrapper.setAttribute("style", cssText);
322
+ wrapper.textContent = text;
323
+ (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(wrapper, node);
324
+ }
325
+ });
326
+ var newRange = document.createRange();
327
+ newRange.selectNodeContents($textEditor);
328
+ w.removeAllRanges();
329
+ w.addRange(newRange);
330
+ return;
331
+ }
301
332
  if (range.collapsed === true) {
302
333
  return;
303
334
  }
@@ -335,7 +366,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
335
366
  cssText = extendCssText(box.style.cssText, cssText);
336
367
  }
337
368
  }
338
- cont += "<span style='".concat(cssText, "'>").concat(left, "</span>");
369
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(left, "</span>");
339
370
  }
340
371
  if (mid !== "") {
341
372
  var cssText = getCssText(span.style.cssText, attr, value);
@@ -345,7 +376,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
345
376
  cssText = extendCssText(box.style.cssText, cssText);
346
377
  }
347
378
  }
348
- cont += "<span style='".concat(cssText, "'>").concat(mid, "</span>");
379
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(mid, "</span>");
349
380
  }
350
381
  if (right !== "") {
351
382
  var cssText = span.style.cssText;
@@ -355,7 +386,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
355
386
  cssText = extendCssText(box.style.cssText, cssText);
356
387
  }
357
388
  }
358
- cont += "<span style='".concat(cssText, "'>").concat(right, "</span>");
389
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(right, "</span>");
359
390
  }
360
391
  if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
361
392
  spanIndex = _.indexOf($textEditor.querySelectorAll("span"), span);
@@ -398,33 +429,33 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
398
429
  for (var i = 0; i < startSpanIndex; i += 1) {
399
430
  var span = spans[i];
400
431
  var content = span.innerHTML;
401
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
432
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
402
433
  }
403
434
  if (sleft !== "") {
404
- cont += "<span style='".concat(startSpan.style.cssText, "'>").concat(sleft, "</span>");
435
+ cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\">").concat(sleft, "</span>");
405
436
  }
406
437
  if (sright !== "") {
407
438
  var cssText = getCssText(startSpan.style.cssText, attr, value);
408
- cont += "<span style='".concat(cssText, "'>").concat(sright, "</span>");
439
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(sright, "</span>");
409
440
  }
410
441
  if (startSpanIndex < endSpanIndex) {
411
442
  for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
412
443
  var span = spans[i];
413
444
  var content = span.innerHTML;
414
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
445
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
415
446
  }
416
447
  }
417
448
  if (eleft !== "") {
418
449
  var cssText = getCssText(endSpan.style.cssText, attr, value);
419
- cont += "<span style='".concat(cssText, "'>").concat(eleft, "</span>");
450
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(eleft, "</span>");
420
451
  }
421
452
  if (eright !== "") {
422
- cont += "<span style='".concat(endSpan.style.cssText, "'>").concat(eright, "</span>");
453
+ cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\">").concat(eright, "</span>");
423
454
  }
424
455
  for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
425
456
  var span = spans[i];
426
457
  var content = span.innerHTML;
427
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
458
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
428
459
  }
429
460
  $textEditor.innerHTML = cont;
430
461
  var startSeletedNodeIndex = void 0;
@@ -442,13 +473,10 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
442
473
  }
443
474
  }
444
475
  }
445
- function escapeHtmlAttr(s) {
446
- return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
447
- }
448
476
  function getLinkDataAttrs(span) {
449
477
  var _a, _b;
450
478
  if (((_a = span.dataset) === null || _a === void 0 ? void 0 : _a.linkType) && ((_b = span.dataset) === null || _b === void 0 ? void 0 : _b.linkAddress)) {
451
- return " data-link-type='".concat(escapeHtmlAttr(span.dataset.linkType), "' data-link-address='").concat(escapeHtmlAttr(span.dataset.linkAddress), "'");
479
+ return " data-link-type=\"".concat(escapeHtmlAttr(span.dataset.linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(span.dataset.linkAddress), "\"");
452
480
  }
453
481
  return "";
454
482
  }
@@ -486,7 +514,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
486
514
  var box = span.closest("#luckysheet-input-box");
487
515
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
488
516
  }
489
- cont += "<span style='".concat(cssText, "'").concat(dataAttrs, ">").concat(left, "</span>");
517
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(left, "</span>");
490
518
  }
491
519
  if (mid !== "") {
492
520
  var cssText = getLinkStyleCssText(span.style.cssText);
@@ -494,7 +522,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
494
522
  var box = span.closest("#luckysheet-input-box");
495
523
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
496
524
  }
497
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(mid, "</span>");
525
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(mid, "</span>");
498
526
  }
499
527
  if (right !== "") {
500
528
  var cssText = span.style.cssText;
@@ -502,7 +530,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
502
530
  var box = span.closest("#luckysheet-input-box");
503
531
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
504
532
  }
505
- cont += "<span style='".concat(cssText, "'").concat(dataAttrs, ">").concat(right, "</span>");
533
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(right, "</span>");
506
534
  }
507
535
  if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
508
536
  span.outerHTML = cont;
@@ -532,32 +560,32 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
532
560
  var cont = "";
533
561
  for (var i = 0; i < startSpanIndex; i += 1) {
534
562
  var sp = spans[i];
535
- cont += "<span style='".concat(sp.style.cssText, "'").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
563
+ cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
536
564
  }
537
565
  if (sleft !== "") {
538
- cont += "<span style='".concat(startSpan.style.cssText, "'").concat(getLinkDataAttrs(startSpan), ">").concat(sleft, "</span>");
566
+ cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\"").concat(getLinkDataAttrs(startSpan), ">").concat(sleft, "</span>");
539
567
  }
540
568
  if (sright !== "") {
541
569
  var cssText = getLinkStyleCssText(startSpan.style.cssText);
542
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(sright, "</span>");
570
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sright, "</span>");
543
571
  }
544
572
  if (startSpanIndex < endSpanIndex) {
545
573
  for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
546
574
  var sp = spans[i];
547
575
  var cssText = getLinkStyleCssText(sp.style.cssText);
548
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(sp.innerHTML, "</span>");
576
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sp.innerHTML, "</span>");
549
577
  }
550
578
  }
551
579
  if (eleft !== "") {
552
580
  var cssText = getLinkStyleCssText(endSpan.style.cssText);
553
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(eleft, "</span>");
581
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(eleft, "</span>");
554
582
  }
555
583
  if (eright !== "") {
556
- cont += "<span style='".concat(endSpan.style.cssText, "'").concat(getLinkDataAttrs(endSpan), ">").concat(eright, "</span>");
584
+ cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\"").concat(getLinkDataAttrs(endSpan), ">").concat(eright, "</span>");
557
585
  }
558
586
  for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
559
587
  var sp = spans[i];
560
- cont += "<span style='".concat(sp.style.cssText, "'").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
588
+ cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
561
589
  }
562
590
  $textEditor.innerHTML = cont;
563
591
  spans = $textEditor.querySelectorAll("span");
@@ -66,7 +66,6 @@ var MONTH_NAME_MAP = {
66
66
  };
67
67
  var MONTH_NAMES_RE = "january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec";
68
68
  var MONTH_ABBR_RE = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec";
69
- var MONTH_ABBR_SET = new Set(MONTH_ABBR_RE.split("|"));
70
69
  function isValidDateParts(year, month, day) {
71
70
  if (year < 1900) return false;
72
71
  if (month < 1 || month > 12) return false;
@@ -281,7 +280,6 @@ export function detectDateFormat(str) {
281
280
  var d = +m[2];
282
281
  var y = +m[3];
283
282
  if (mo && isValidDateParts(y, mo, d)) {
284
- var isAbbr = MONTH_ABBR_SET.has(m[1].toLowerCase());
285
283
  return {
286
284
  year: y,
287
285
  month: mo,
@@ -289,7 +287,7 @@ export function detectDateFormat(str) {
289
287
  hours: 0,
290
288
  minutes: 0,
291
289
  seconds: 0,
292
- formatType: isAbbr ? "named-mdy-abbr" : "named-mdy-full"
290
+ formatType: "named"
293
291
  };
294
292
  }
295
293
  }
@@ -299,7 +297,6 @@ export function detectDateFormat(str) {
299
297
  var mo = MONTH_NAME_MAP[m[2].toLowerCase()];
300
298
  var y = +m[3];
301
299
  if (mo && isValidDateParts(y, mo, d)) {
302
- var isAbbr = MONTH_ABBR_SET.has(m[2].toLowerCase());
303
300
  return {
304
301
  year: y,
305
302
  month: mo,
@@ -307,7 +304,7 @@ export function detectDateFormat(str) {
307
304
  hours: 0,
308
305
  minutes: 0,
309
306
  seconds: 0,
310
- formatType: isAbbr ? "named-dmy-abbr" : "named-dmy-full"
307
+ formatType: "named"
311
308
  };
312
309
  }
313
310
  }
@@ -324,7 +321,7 @@ export function detectDateFormat(str) {
324
321
  hours: 0,
325
322
  minutes: 0,
326
323
  seconds: 0,
327
- formatType: "named-abbr-dashes"
324
+ formatType: "named"
328
325
  };
329
326
  }
330
327
  }
package/es/types.d.ts CHANGED
@@ -328,8 +328,6 @@ export type GlobalCache = {
328
328
  verticalScrollLock?: boolean;
329
329
  horizontalScrollLock?: boolean;
330
330
  overwriteCell?: boolean;
331
- overwriteCellFirstChar?: string;
332
- enteredEditByTyping?: boolean;
333
331
  ignoreWriteCell?: boolean;
334
332
  doNotFocus?: boolean;
335
333
  doNotUpdateCell?: boolean;
@@ -179,72 +179,63 @@ function moveToEdge(sheetData, key, curr, rowDelta, colDelta, startR, endR, star
179
179
  return colDelta === 0 ? r : c;
180
180
  }
181
181
  function handleControlPlusArrowKey(ctx, e, shiftPressed) {
182
- var _a, _b, _c, _d;
182
+ if (ctx.luckysheetCellUpdate.length > 0) return;
183
183
  var idx = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
184
184
  if (_lodash.default.isNil(idx)) return;
185
185
  var file = ctx.luckysheetfile[idx];
186
+ if (!file || !file.row || !file.column) return;
186
187
  var maxRow = file.row;
187
188
  var maxCol = file.column;
188
- if (_lodash.default.isNil(maxRow) || _lodash.default.isNil(maxCol)) return;
189
- var last = ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0 ? ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1] : undefined;
189
+ var last;
190
+ if (ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0) last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
190
191
  if (!last) return;
191
192
  var currR = last.row_focus;
192
193
  var currC = last.column_focus;
193
194
  if (_lodash.default.isNil(currR) || _lodash.default.isNil(currC)) return;
194
- var startR = (_a = last.row) === null || _a === void 0 ? void 0 : _a[0];
195
- var endR = (_b = last.row) === null || _b === void 0 ? void 0 : _b[1];
196
- var startC = (_c = last.column) === null || _c === void 0 ? void 0 : _c[0];
197
- var endC = (_d = last.column) === null || _d === void 0 ? void 0 : _d[1];
198
- if (_lodash.default.isNil(startR) || _lodash.default.isNil(endR) || _lodash.default.isNil(startC) || _lodash.default.isNil(endC)) {
199
- return;
200
- }
195
+ var startR = last.row[0];
196
+ var endR = last.row[1];
197
+ var startC = last.column[0];
198
+ var endC = last.column[1];
201
199
  var horizontalOffset = currC - endC !== 0 ? currC - endC : currC - startC;
202
200
  var verticalOffset = currR - endR !== 0 ? currR - endR : currR - startR;
203
201
  var sheetData = file.data;
204
202
  if (!sheetData) return;
203
+ var selectedLimit;
205
204
  switch (e.key) {
206
205
  case "ArrowUp":
207
- {
208
- var selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
209
- if (shiftPressed) {
210
- (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
211
- (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
212
- } else {
213
- (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
214
- }
206
+ selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
207
+ if (shiftPressed) {
208
+ (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
209
+ (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
210
+ } else {
211
+ (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
215
212
  }
216
213
  break;
217
214
  case "ArrowDown":
218
- {
219
- var selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
220
- if (shiftPressed) {
221
- (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
222
- (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
223
- } else {
224
- (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
225
- }
215
+ selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
216
+ if (shiftPressed) {
217
+ (0, _selection.moveHighlightRange)(ctx, "down", verticalOffset, "rangeOfSelect");
218
+ (0, _selection.moveHighlightRange)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
219
+ } else {
220
+ (0, _selection.moveHighlightCell)(ctx, "down", selectedLimit - currR, "rangeOfSelect");
226
221
  }
227
222
  break;
228
223
  case "ArrowLeft":
229
- {
230
- var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
231
- if (shiftPressed) {
232
- (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
233
- (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
234
- } else {
235
- (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
236
- }
224
+ selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
225
+ if (shiftPressed) {
226
+ (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
227
+ (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
228
+ } else {
229
+ (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
237
230
  }
238
231
  break;
239
232
  case "ArrowRight":
240
- {
241
- var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
242
- if (shiftPressed) {
243
- (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
244
- (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
245
- } else {
246
- (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
247
- }
233
+ selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
234
+ if (shiftPressed) {
235
+ (0, _selection.moveHighlightRange)(ctx, "right", horizontalOffset, "rangeOfSelect");
236
+ (0, _selection.moveHighlightRange)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
237
+ } else {
238
+ (0, _selection.moveHighlightCell)(ctx, "right", selectedLimit - currC, "rangeOfSelect");
248
239
  }
249
240
  break;
250
241
  default:
@@ -397,10 +388,10 @@ function handleArrowKey(ctx, e) {
397
388
  }
398
389
  }
399
390
  function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
400
- var _a, _b, _c, _d;
391
+ var _a, _b, _c;
401
392
  return __awaiter(this, void 0, void 0, function () {
402
- var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, isEditing, inputText, isFormulaEdit, enteredByTyping, last, row_index, col_index;
403
- return __generator(this, function (_e) {
393
+ var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
394
+ return __generator(this, function (_d) {
404
395
  if (e.shiftKey && e.code === "Space") {
405
396
  e.stopImmediatePropagation();
406
397
  e.stopPropagation();
@@ -508,18 +499,7 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
508
499
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
509
500
  e.preventDefault();
510
501
  } else if (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight") {
511
- isEditing = ctx.luckysheetCellUpdate.length > 0;
512
- inputText = (_d = cellInput === null || cellInput === void 0 ? void 0 : cellInput.innerText) !== null && _d !== void 0 ? _d : "";
513
- isFormulaEdit = isEditing && inputText.trim().startsWith("=");
514
- enteredByTyping = cache.enteredEditByTyping === true;
515
- if (isEditing && !isFormulaEdit && enteredByTyping) {
516
- (0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
517
- cache.enteredEditByTyping = false;
518
- handleArrowKey(ctx, e);
519
- e.preventDefault();
520
- } else {
521
- handleArrowKey(ctx, e);
522
- }
502
+ handleArrowKey(ctx, e);
523
503
  } 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) {
524
504
  if (!allowEdit) return [2];
525
505
  if (String.fromCharCode(kcode) != null && !_lodash.default.isEmpty(ctx.luckysheet_select_save) && kstr !== "CapsLock" && kstr !== "Win" && kcode !== 18) {
@@ -528,10 +508,7 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
528
508
  col_index = last.column_focus;
529
509
  ctx.luckysheetCellUpdate = [row_index, col_index];
530
510
  cache.overwriteCell = true;
531
- cache.overwriteCellFirstChar = e.key;
532
- cache.enteredEditByTyping = true;
533
511
  (0, _formula.handleFormulaInput)(ctx, fxInput, cellInput, kcode);
534
- e.preventDefault();
535
512
  }
536
513
  }
537
514
  }
@@ -508,7 +508,6 @@ function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
508
508
  row_index = row_focus;
509
509
  col_index = column_focus;
510
510
  }
511
- globalCache.enteredEditByTyping = false;
512
511
  (0, _cell.luckysheetUpdateCell)(ctx, row_index, col_index);
513
512
  }
514
513
  function handleContextMenu(ctx, settings, e, workbookContainer, container, area) {
@@ -236,7 +236,7 @@ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
236
236
  }
237
237
  };
238
238
  function pasteHandler(ctx, data, borderInfo) {
239
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
239
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
240
240
  if (ctx.luckysheet_selection_range) {
241
241
  ctx.luckysheet_selection_range = [];
242
242
  }
@@ -420,39 +420,25 @@ function pasteHandler(ctx, data, borderInfo) {
420
420
  }
421
421
  }
422
422
  if (originCell) {
423
- if (!isUrl) {
424
- var generated = (0, _format.genarate)(originalValueStr);
425
- if (generated) {
426
- var genM = generated[0],
427
- genCt = generated[1],
428
- genV = generated[2];
429
- if ((genCt === null || genCt === void 0 ? void 0 : genCt.t) === "d") {
430
- originCell.v = genV;
431
- originCell.m = genM !== null && genM !== void 0 ? genM : originalValueStr;
432
- originCell.ct = genCt;
433
- } else {
434
- originCell.v = value;
435
- if (originCell.ct != null && originCell.ct.fa != null) {
436
- if (originCell.ct.t === "d" && typeof originCell.v !== "number") {
437
- originCell.m = String(originCell.v);
438
- } else {
439
- originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
440
- }
441
- } else {
442
- originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
443
- }
444
- }
423
+ if (originCell.ct && originCell.ct.t === "d" && !isUrl) {
424
+ var df = (0, _validation.detectDateFormat)(originalValueStr);
425
+ if (df) {
426
+ var dateObj = new Date(df.year, df.month - 1, df.day, df.hours, df.minutes, df.seconds);
427
+ originCell.v = (0, _format.datenum_local)(dateObj);
445
428
  } else {
446
- originCell.v = value;
447
- if (originCell.ct != null && originCell.ct.fa != null) {
448
- originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
449
- } else {
450
- originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
451
- }
429
+ originCell.v = originalValueStr;
430
+ }
431
+ } else {
432
+ originCell.v = isUrl ? originalValueStr : value;
433
+ }
434
+ if (originCell.ct != null && originCell.ct.fa != null) {
435
+ if (originCell.ct.t === "d" && typeof originCell.v !== "number") {
436
+ originCell.m = String(originCell.v);
437
+ } else {
438
+ originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
452
439
  }
453
440
  } else {
454
- originCell.v = originalValueStr;
455
- originCell.m = originalValueStr;
441
+ originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
456
442
  }
457
443
  if (originCell.f != null && originCell.f.length > 0) {
458
444
  originCell.f = "";
@@ -479,24 +465,19 @@ function pasteHandler(ctx, data, borderInfo) {
479
465
  t: "s"
480
466
  };
481
467
  } else {
468
+ cell.v = originalValueStr;
469
+ cell.m = originalValueStr;
470
+ cell.ct = {
471
+ fa: "General",
472
+ t: "g"
473
+ };
482
474
  if (/^0x?[a-fA-F0-9]+$/.test(value)) {
483
- cell.v = value;
484
475
  cell.m = value;
485
476
  cell.ct = {
486
477
  fa: "@",
487
478
  t: "s"
488
479
  };
489
- } else {
490
- var _m = (_j = (0, _format.genarate)(originalValueStr)) !== null && _j !== void 0 ? _j : [],
491
- m = _m[0],
492
- ct = _m[1],
493
- v = _m[2];
494
- cell.v = v !== null && v !== void 0 ? v : originalValueStr;
495
- cell.m = m != null ? String(m) : originalValueStr;
496
- cell.ct = ct !== null && ct !== void 0 ? ct : {
497
- fa: "General",
498
- t: "g"
499
- };
480
+ cell.v = value;
500
481
  }
501
482
  }
502
483
  if (isUrl && url) {
@@ -527,8 +508,8 @@ function pasteHandler(ctx, data, borderInfo) {
527
508
  }
528
509
  d[r + curR] = x;
529
510
  }
530
- if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
531
- (_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
511
+ if ((_j = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _j === void 0 ? void 0 : _j.updateCellYdoc) {
512
+ (_k = ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc(changes);
532
513
  }
533
514
  last.row = [curR, curR + rlen - 1];
534
515
  last.column = [curC, curC + clen - 1];
@@ -530,8 +530,6 @@ declare const _default: {
530
530
  conditionformat_equal_title: string;
531
531
  conditionformat_textContains: string;
532
532
  conditionformat_textContains_title: string;
533
- conditionformat_empty: string;
534
- conditionformat_empty_title: string;
535
533
  conditionformat_occurrenceDate: string;
536
534
  conditionformat_occurrenceDate_title: string;
537
535
  conditionformat_duplicateValue: string;
@@ -635,7 +633,6 @@ declare const _default: {
635
633
  between2: string;
636
634
  contain: string;
637
635
  textContains: string;
638
- empty: string;
639
636
  duplicateValue: string;
640
637
  uniqueValue: string;
641
638
  top: string;
package/lib/locale/en.js CHANGED
@@ -9634,8 +9634,6 @@ var _default = exports.default = {
9634
9634
  conditionformat_equal_title: "Format cells equal to",
9635
9635
  conditionformat_textContains: "Conditional format - Text Contains",
9636
9636
  conditionformat_textContains_title: "Format cells containing the following text",
9637
- conditionformat_empty: "Conditional format - Empty",
9638
- conditionformat_empty_title: "Format cells that are empty",
9639
9637
  conditionformat_occurrenceDate: "Conditional format - Occurrence Date",
9640
9638
  conditionformat_occurrenceDate_title: "Format cells containing the following dates",
9641
9639
  conditionformat_duplicateValue: "Conditional format - Duplicate Value",
@@ -9739,7 +9737,6 @@ var _default = exports.default = {
9739
9737
  between2: "",
9740
9738
  contain: "Contain",
9741
9739
  textContains: "Text contains",
9742
- empty: "Empty",
9743
9740
  duplicateValue: "Duplicate value",
9744
9741
  uniqueValue: "Unique value",
9745
9742
  top: "Top",
@@ -688,8 +688,6 @@ declare const _default: {
688
688
  conditionformat_equal_title: string;
689
689
  conditionformat_textContains: string;
690
690
  conditionformat_textContains_title: string;
691
- conditionformat_empty: string;
692
- conditionformat_empty_title: string;
693
691
  conditionformat_occurrenceDate: string;
694
692
  conditionformat_occurrenceDate_title: string;
695
693
  conditionformat_duplicateValue: string;
@@ -791,7 +789,6 @@ declare const _default: {
791
789
  between2: string;
792
790
  contain: string;
793
791
  textContains: string;
794
- empty: string;
795
792
  duplicateValue: string;
796
793
  uniqueValue: string;
797
794
  top: string;
package/lib/locale/es.js CHANGED
@@ -9571,8 +9571,6 @@ var _default = exports.default = {
9571
9571
  conditionformat_equal_title: "Dar formato a celdas iguales a",
9572
9572
  conditionformat_textContains: "Conditionformat-TextContains",
9573
9573
  conditionformat_textContains_title: "Dar formato a las celdas que contienen el siguiente texto",
9574
- conditionformat_empty: "Conditional format - Empty",
9575
- conditionformat_empty_title: "Dar formato a las celdas vacías",
9576
9574
  conditionformat_occurrenceDate: "Conditionformat-OccurrenceDate",
9577
9575
  conditionformat_occurrenceDate_title: "Dar formato a celdas que contienen las siguientes fechas",
9578
9576
  conditionformat_duplicateValue: "Conditionformat-DuplicateValue",
@@ -9674,7 +9672,6 @@ var _default = exports.default = {
9674
9672
  between2: "",
9675
9673
  contain: "Contiene",
9676
9674
  textContains: "Texto contiene",
9677
- empty: "Vacío",
9678
9675
  duplicateValue: "Valor duplicado",
9679
9676
  uniqueValue: "Valor Unico",
9680
9677
  top: "Mejor",
@@ -563,8 +563,6 @@ declare const _default: {
563
563
  conditionformat_equal_title: string;
564
564
  conditionformat_textContains: string;
565
565
  conditionformat_textContains_title: string;
566
- conditionformat_empty: string;
567
- conditionformat_empty_title: string;
568
566
  conditionformat_occurrenceDate: string;
569
567
  conditionformat_occurrenceDate_title: string;
570
568
  conditionformat_duplicateValue: string;
@@ -666,7 +664,6 @@ declare const _default: {
666
664
  between2: string;
667
665
  contain: string;
668
666
  textContains: string;
669
- empty: string;
670
667
  duplicateValue: string;
671
668
  uniqueValue: string;
672
669
  top: string;
package/lib/locale/hi.js CHANGED
@@ -10084,8 +10084,6 @@ var _default = exports.default = {
10084
10084
  conditionformat_equal_title: "के बराबर कोशिकाओं को प्रारूपित करें",
10085
10085
  conditionformat_textContains: "Conditionformat-TextContains",
10086
10086
  conditionformat_textContains_title: "निम्नलिखित पाठ वाली कोशिकाओं को प्रारूपित करें",
10087
- conditionformat_empty: "Conditional format - Empty",
10088
- conditionformat_empty_title: "खाली कोशिकाओं को प्रारूपित करें",
10089
10087
  conditionformat_occurrenceDate: "Conditionformat-OccurrenceDate",
10090
10088
  conditionformat_occurrenceDate_title: "निम्नलिखित तिथियों वाली कोशिकाओं को प्रारूपित करें",
10091
10089
  conditionformat_duplicateValue: "Conditionformat-DuplicateValue",
@@ -10187,7 +10185,6 @@ var _default = exports.default = {
10187
10185
  between2: "",
10188
10186
  contain: "शामिल",
10189
10187
  textContains: "पाठ शामिल है",
10190
- empty: "खाली",
10191
10188
  duplicateValue: "डुप्लिकेट मान",
10192
10189
  uniqueValue: "अद्वितीय मान",
10193
10190
  top: "शीर्ष",