@fileverse-dev/fortune-core 1.3.11-input-ref-2 → 1.3.11-input-ref-3

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.
@@ -1,6 +1,6 @@
1
1
  import { Context } from "../context";
2
2
  import { GlobalCache } from "../types";
3
3
  export declare function handleGlobalEnter(ctx: Context, cellInput: HTMLDivElement, e: KeyboardEvent, cache: GlobalCache, canvas?: CanvasRenderingContext2D): void;
4
- export declare function handleWithCtrlOrMetaKey(ctx: Context, cache: GlobalCache, e: KeyboardEvent, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, handleUndo: () => void, handleRedo: () => void): void;
4
+ export declare function handleWithCtrlOrMetaKey(ctx: Context, cache: GlobalCache, e: KeyboardEvent, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, handleUndo: () => void, handleRedo: () => void, canvas?: CanvasRenderingContext2D): void;
5
5
  export declare function handleArrowKey(ctx: Context, e: KeyboardEvent): void;
6
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>;
@@ -233,6 +233,17 @@ function isPlainTextCellOrFxEdit(ctx, cellInput, fxInput) {
233
233
  if (cellT.startsWith("=") || fxT.startsWith("=")) return false;
234
234
  return true;
235
235
  }
236
+ function isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput) {
237
+ return (cache === null || cache === void 0 ? void 0 : cache.enteredEditByTyping) === true && ctx.luckysheetCellUpdate.length > 0 && isPlainTextCellOrFxEdit(ctx, cellInput, fxInput);
238
+ }
239
+ function commitDirectPlainCellEdit(ctx, cache, cellInput, canvas) {
240
+ if (ctx.luckysheetCellUpdate.length === 0) return;
241
+ updateCell(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
242
+ if (cache) {
243
+ cache.enteredEditByTyping = false;
244
+ clearTypeOverPending(cache);
245
+ }
246
+ }
236
247
  function handleControlPlusArrowKey(ctx, e, shiftPressed) {
237
248
  var isFormulaRefMode = isLegacyFormulaRangeMode(ctx);
238
249
  if (isFormulaRefMode) {
@@ -303,12 +314,16 @@ function handleControlPlusArrowKey(ctx, e, shiftPressed) {
303
314
  break;
304
315
  }
305
316
  }
306
- export function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo) {
317
+ export function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas) {
307
318
  var _a, _b, _c, _d;
308
319
  var flowdata = getFlowdata(ctx);
309
320
  if (!flowdata) return;
310
321
  if ((e.ctrlKey || e.metaKey) && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key) && isPlainTextCellOrFxEdit(ctx, cellInput, fxInput)) {
311
- return;
322
+ if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
323
+ commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
324
+ } else {
325
+ return;
326
+ }
312
327
  }
313
328
  if (e.shiftKey) {
314
329
  ctx.luckysheet_shiftpositon = _.cloneDeep((_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1]);
@@ -567,10 +582,13 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
567
582
  e.preventDefault();
568
583
  } else {
569
584
  if (e.ctrlKey || e.metaKey) {
570
- handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo);
585
+ handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas);
571
586
  return [2];
572
587
  }
573
588
  if (e.shiftKey && (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight")) {
589
+ if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
590
+ commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
591
+ }
574
592
  handleShiftWithArrowKey(ctx, e);
575
593
  } else if (kstr === "Escape") {
576
594
  ctx.contextMenu = {};
@@ -1,6 +1,6 @@
1
1
  import { Context } from "../context";
2
2
  import { GlobalCache } from "../types";
3
3
  export declare function handleGlobalEnter(ctx: Context, cellInput: HTMLDivElement, e: KeyboardEvent, cache: GlobalCache, canvas?: CanvasRenderingContext2D): void;
4
- export declare function handleWithCtrlOrMetaKey(ctx: Context, cache: GlobalCache, e: KeyboardEvent, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, handleUndo: () => void, handleRedo: () => void): void;
4
+ export declare function handleWithCtrlOrMetaKey(ctx: Context, cache: GlobalCache, e: KeyboardEvent, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null | undefined, handleUndo: () => void, handleRedo: () => void, canvas?: CanvasRenderingContext2D): void;
5
5
  export declare function handleArrowKey(ctx: Context, e: KeyboardEvent): void;
6
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>;
@@ -243,6 +243,17 @@ function isPlainTextCellOrFxEdit(ctx, cellInput, fxInput) {
243
243
  if (cellT.startsWith("=") || fxT.startsWith("=")) return false;
244
244
  return true;
245
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
+ }
246
257
  function handleControlPlusArrowKey(ctx, e, shiftPressed) {
247
258
  var isFormulaRefMode = isLegacyFormulaRangeMode(ctx);
248
259
  if (isFormulaRefMode) {
@@ -313,12 +324,16 @@ function handleControlPlusArrowKey(ctx, e, shiftPressed) {
313
324
  break;
314
325
  }
315
326
  }
316
- function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo) {
327
+ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas) {
317
328
  var _a, _b, _c, _d;
318
329
  var flowdata = (0, _context.getFlowdata)(ctx);
319
330
  if (!flowdata) return;
320
331
  if ((e.ctrlKey || e.metaKey) && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key) && isPlainTextCellOrFxEdit(ctx, cellInput, fxInput)) {
321
- return;
332
+ if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
333
+ commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
334
+ } else {
335
+ return;
336
+ }
322
337
  }
323
338
  if (e.shiftKey) {
324
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]);
@@ -577,10 +592,13 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
577
592
  e.preventDefault();
578
593
  } else {
579
594
  if (e.ctrlKey || e.metaKey) {
580
- handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo);
595
+ handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo, canvas);
581
596
  return [2];
582
597
  }
583
598
  if (e.shiftKey && (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight")) {
599
+ if (isDirectPlainTextCellEdit(ctx, cache, cellInput, fxInput)) {
600
+ commitDirectPlainCellEdit(ctx, cache, cellInput, canvas);
601
+ }
584
602
  handleShiftWithArrowKey(ctx, e);
585
603
  } else if (kstr === "Escape") {
586
604
  ctx.contextMenu = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.11-input-ref-2",
3
+ "version": "1.3.11-input-ref-3",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",