Skip to content

Commit 769d3da

Browse files
authored
Mixed feed - TEC-2394, TEC-2395, TEC-2375 (#391)
* change width of inputbox if column length changes * remove auto sceintifix conversoin for decimal response * change height of inputbox if row height changes * overflow ignore formate of next cell * minor changes
1 parent d8cb1af commit 769d3da

8 files changed

Lines changed: 223 additions & 32 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@fileverse-dev/dsheet",
33
"private": false,
44
"description": "DSheet",
5-
"version": "2.0.32",
5+
"version": "2.0.33",
66
"main": "dist/index.es.js",
77
"module": "dist/index.es.js",
88
"exports": {
@@ -105,4 +105,4 @@
105105
"typescript": "^5.2.2",
106106
"vite": "^5.0.0"
107107
}
108-
}
108+
}

src/editor/hooks/use-editor-data.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ export const useEditorData = (
148148
if (cell) {
149149
const comment =
150150
(commentData as any)?.[
151-
`${sheetKey}_${rowIndex}_${colIndex}`
151+
`${sheetKey}_${rowIndex}_${colIndex}`
152152
] ??
153153
(commentData as any)?.[
154-
`${fileIndex}_${rowIndex}_${colIndex}`
154+
`${fileIndex}_${rowIndex}_${colIndex}`
155155
];
156156
if (comment) {
157157
cell.ps = allowComments

src/sheet-engine/core/canvas.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ function getBorderFix() {
4343
}
4444

4545
function hasCellDisplayContent(cell: any) {
46-
return !_.isEmpty(cell?.v) || _.isEmpty(cell?.m) || isInlineStringCell(cell);
46+
return (
47+
cell?.v != null ||
48+
(typeof cell?.m === 'string' && cell.m.length > 0) ||
49+
isInlineStringCell(cell)
50+
);
4751
}
4852

4953
function setLineDash(

src/sheet-engine/core/events/mouse.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import _ from 'lodash';
22
import { Freezen } from '..';
3-
import { Context, getFlowdata } from '../context';
3+
import {
4+
Context,
5+
getFlowdata,
6+
updateContextWithSheetData,
7+
} from '../context';
48
import {
59
cancelActiveImgItem,
610
cancelPaintModel,
@@ -2500,6 +2504,8 @@ export function mouseRender(
25002504
scrollX.scrollLeft -
25012505
window.scrollX;
25022506
if (x < rect.width + ctx.scrollLeft - 100) {
2507+
// Match mouseup commit (`x + 3`); stored on globalCache to avoid Immer churn.
2508+
globalCache.colResizeLiveRightPx = x + 3;
25032509
const changeSizeLine = container.querySelector(
25042510
'.fortune-change-size-line',
25052511
);
@@ -2522,6 +2528,8 @@ export function mouseRender(
25222528
scrollY.scrollTop -
25232529
window.scrollY;
25242530
if (y < rect.height + ctx.scrollTop - 20) {
2531+
// Match mouseup commit (`y + 3`); stored on globalCache to avoid Immer churn.
2532+
globalCache.rowResizeLiveBottomPx = y + 3;
25252533
const changeSizeLine = container.querySelector(
25262534
'.fortune-change-size-line',
25272535
);
@@ -4200,6 +4208,7 @@ export function handleOverlayMouseUp(
42004208

42014209
// 改变行高
42024210
if (ctx.luckysheet_rows_change_size) {
4211+
delete globalCache.rowResizeLiveBottomPx;
42034212
ctx.luckysheet_rows_change_size = false;
42044213

42054214
// $("#fortune-change-size-line").hide();
@@ -4286,6 +4295,11 @@ export function handleOverlayMouseUp(
42864295
if (idx == null) return;
42874296
ctx.luckysheetfile[idx].config = ctx.config;
42884297

4298+
const flowdataAfterRowResize = getFlowdata(ctx);
4299+
if (flowdataAfterRowResize) {
4300+
updateContextWithSheetData(ctx, flowdataAfterRowResize);
4301+
}
4302+
42894303
// server.saveParam("cg", ctx.currentSheetId, cfg.rowlen, {
42904304
// k: "rowlen",
42914305
// });
@@ -4301,6 +4315,7 @@ export function handleOverlayMouseUp(
43014315

43024316
// 改变列宽
43034317
if (ctx.luckysheet_cols_change_size) {
4318+
delete globalCache.colResizeLiveRightPx;
43044319
ctx.luckysheet_cols_change_size = false;
43054320

43064321
const { scrollLeft } = ctx;
@@ -4390,6 +4405,11 @@ export function handleOverlayMouseUp(
43904405
if (idx == null) return;
43914406
ctx.luckysheetfile[idx].config = ctx.config;
43924407

4408+
const flowdataAfterColResize = getFlowdata(ctx);
4409+
if (flowdataAfterColResize) {
4410+
updateContextWithSheetData(ctx, flowdataAfterColResize);
4411+
}
4412+
43934413
// server.saveParam("cg", ctx.currentSheetId, cfg.columnlen, {
43944414
// k: "columnlen",
43954415
// });
@@ -5423,7 +5443,7 @@ export function handleColSizeHandleMouseDown(
54235443
cancelActiveImgItem(ctx, globalCache);
54245444
// }
54255445

5426-
ctx.luckysheetCellUpdate = [];
5446+
// Keep in-cell edit open while resizing (do not clear luckysheetCellUpdate).
54275447

54285448
// let mouse = mouseposition(event.pageX, event.pageY);
54295449
const { scrollLeft } = ctx;
@@ -5439,8 +5459,10 @@ export function handleColSizeHandleMouseDown(
54395459
const col = col_location[1];
54405460
const col_index = col_location[2];
54415461

5462+
delete globalCache.colResizeLiveRightPx;
54425463
ctx.luckysheet_cols_change_size = true;
54435464
ctx.luckysheet_scroll_status = true;
5465+
globalCache.colResizeLiveRightPx = col;
54445466
const changeSizeLine = workbookContainer.querySelector(
54455467
'.fortune-change-size-line',
54465468
);
@@ -5556,7 +5578,7 @@ export function handleRowSizeHandleMouseDown(
55565578
israngeseleciton(ctx)
55575579
)
55585580
return;
5559-
ctx.luckysheetCellUpdate = [];
5581+
// Keep in-cell edit open while resizing (do not clear luckysheetCellUpdate).
55605582

55615583
// let mouse = mouseposition(event.pageX, event.pageY);
55625584
const { scrollLeft } = ctx;
@@ -5572,8 +5594,10 @@ export function handleRowSizeHandleMouseDown(
55725594
const row = row_location[1];
55735595
const row_index = row_location[2];
55745596

5597+
delete globalCache.rowResizeLiveBottomPx;
55755598
ctx.luckysheet_rows_change_size = true;
55765599
ctx.luckysheet_scroll_status = true;
5600+
globalCache.rowResizeLiveBottomPx = row;
55775601
const changeSizeLine = workbookContainer.querySelector(
55785602
'.fortune-change-size-line',
55795603
);

src/sheet-engine/core/modules/cell.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,12 @@ export function setCellValue(
616616
if (cell.v === Infinity || cell.v === -Infinity) {
617617
cell.m = cell.v.toString();
618618
} else {
619-
if (shouldUseScientificForComputedNumber(cell.v as number)) {
620-
cell.m = formatScientificForComputedNumber(cell.v as number);
621-
} else if (cell.v.toString().toLowerCase().indexOf('e') > -1) {
619+
const v_p = Math.round((cell.v as number) * 1000000000) / 1000000000;
620+
if (shouldUseScientificForComputedNumber(v_p)) {
621+
cell.m = formatScientificForComputedNumber(v_p);
622+
} else if ((cell.v as number).toString().toLowerCase().indexOf('e') > -1) {
622623
cell.m = formatMForNumericCellAvoidingGsRules(cell.v as number);
623624
} else {
624-
const v_p = Math.round(cell.v * 1000000000) / 1000000000;
625625
if (_.isNil(cell.ct)) {
626626
const mask = genarate(v_p);
627627
if (mask != null) {
@@ -631,8 +631,6 @@ export function setCellValue(
631631
const mask = update(cell.ct.fa!, v_p);
632632
cell.m = mask.toString();
633633
}
634-
635-
// cell.m = mask[0].toString();
636634
}
637635
}
638636

src/sheet-engine/core/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ export type GlobalCache = {
411411
scrollTop?: number;
412412
scrollLeft?: number;
413413
};
414+
/** Live column right edge (px) while dragging column resize; not in Immer context. */
415+
colResizeLiveRightPx?: number;
416+
/** Live row bottom edge (px) while dragging row resize; not in Immer context. */
417+
rowResizeLiveBottomPx?: number;
414418
};
415419

416420
export type SingleRange = { row: number[]; column: number[] };

0 commit comments

Comments
 (0)