Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions packages/core/src/events/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@
e: KeyboardEvent,
shiftPressed: boolean
) {
if (ctx.luckysheetCellUpdate.length > 0) return;
// if (ctx.luckysheetCellUpdate.length > 0) return;

const idx = getSheetIndex(ctx, ctx.currentSheetId);
if (_.isNil(idx)) return;
// if (_.isNil(idx)) return;

const file = ctx.luckysheetfile[idx];

Check failure on line 163 in packages/core/src/events/keyboard.ts

View workflow job for this annotation

GitHub Actions / test

Type 'null' cannot be used as an index type.

Check failure on line 163 in packages/core/src/events/keyboard.ts

View workflow job for this annotation

GitHub Actions / test

Type 'null' cannot be used as an index type.
if (!file || !file.row || !file.column) return;
// if (!file || !file.row || !file.column) return;
const maxRow = file.row;
const maxCol = file.column;
let last;
Expand Down Expand Up @@ -603,12 +603,10 @@

// handling for inputbox active arrow navigation for cell reference input for functions like SUM(A1:A10)
if (
lastSpan?.innerText.includes(")") ||
lastSpan?.innerText.includes('"') ||
(notFunctionInit &&
/^[a-zA-Z]+$/.test(lastSpan?.innerText) &&
!_.includes(["="], lastSpan?.innerText)) ||
/^[a-zA-Z]+$/.test(lastSpan?.innerText)
true
// lastSpan?.innerText.includes(")") ||
// lastSpan?.innerText.includes('"') ||
// notFunctionInit
) {
return;
}
Expand Down
12 changes: 4 additions & 8 deletions packages/core/src/events/mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,10 @@ export function handleCellAreaMouseDown(
const lastSpan = spans[spans.length - 1];

if (
(ctx.formulaCache.rangestart ||
ctx.formulaCache.rangedrag_column_start ||
ctx.formulaCache.rangedrag_row_start ||
israngeseleciton(ctx) ||
(firstSpan?.innerText.includes("=") &&
!lastSpan?.innerText.includes(")"))) &&
lastSpan &&
ctx.luckysheetCellUpdate.length === 2
ctx.formulaCache.rangestart ||
ctx.formulaCache.rangedrag_column_start ||
ctx.formulaCache.rangedrag_row_start ||
israngeseleciton(ctx)
) {
// 公式选区
let rowseleted = [row_index, row_index_ed];
Expand Down
38 changes: 29 additions & 9 deletions packages/react/src/components/SheetOverlay/InputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
handleUnderline,
handleStrikeThrough,
getRangeRectsByCharacterOffset,
rangeSetValue,
} from "@fileverse-dev/fortune-core";
import React, {
useContext,
Expand All @@ -32,7 +33,7 @@ import React, {
useLayoutEffect,
useState,
} from "react";
import _ from "lodash";
import _, { set } from "lodash";
import { Tooltip } from "@fileverse/ui";
import WorkbookContext from "../../context";
import ContentEditable from "./ContentEditable";
Expand Down Expand Up @@ -377,6 +378,26 @@ const InputBox: React.FC = () => {
event.preventDefault();
};

useEffect(() => {
if (!context.luckysheet_select_save?.[0]?.row) return;
console.log("InputBox useEffect triggered", rangeSetValue);
setContext((ctx) => {
rangeSetValue?.(
ctx,
refs.cellInput.current!,
{
row: ctx.luckysheet_select_save?.[0]?.row,
column: ctx.luckysheet_select_save?.[0]?.column,
},
refs.fxInput.current!
);
});
}, [
context.luckysheet_select_save,
context.rangeDialog?.show,
isInputBoxActive,
]);

const onKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLDivElement>) => {
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
Expand Down Expand Up @@ -477,14 +498,13 @@ const InputBox: React.FC = () => {
!arrowRefNotAllowed &&
!/^[a-zA-Z]+$/.test(lastSpan?.innerText)
) {
allowListNavigation = false;
inputRef.current!.innerHTML = `${
inputRef.current!.innerHTML
}<span class="fortune-formula-functionrange-cell" rangeindex="0" dir="auto" style="color:#c1232b;">${refCell}</span>`;

setTimeout(() => {
moveCursorToEnd(inputRef.current!);
}, 1);
// allowListNavigation = false;
// inputRef.current!.innerHTML = `${
// inputRef.current!.innerHTML
// }<span class="fortune-formula-functionrange-cell" rangeindex="0" dir="auto" style="color:#c1232b;">${refCell}</span>`;
// setTimeout(() => {
// moveCursorToEnd(inputRef.current!);
// }, 1);
}

if (isLetterNumberPattern(lastSpan?.innerText)) {
Expand Down
Loading