@fileverse-dev/fortune-core 1.3.0 → 1.3.1-column-1
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/context.d.ts +5 -0
- package/es/events/mouse.d.ts +1 -0
- package/es/events/mouse.js +50 -0
- package/es/paste-helpers/calculate-range-cell-size.d.ts +1 -0
- package/es/paste-helpers/calculate-range-cell-size.js +39 -0
- package/lib/context.d.ts +5 -0
- package/lib/events/mouse.d.ts +1 -0
- package/lib/events/mouse.js +51 -0
- package/lib/paste-helpers/calculate-range-cell-size.d.ts +1 -0
- package/lib/paste-helpers/calculate-range-cell-size.js +40 -0
- package/package.json +1 -1
package/es/context.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export type Context = {
|
|
|
53
53
|
optionLabel_es: any;
|
|
54
54
|
optionLabel_hi: any;
|
|
55
55
|
dataRegulation?: DataRegulationProps;
|
|
56
|
+
updateScope?: "current" | "all";
|
|
57
|
+
sourceCell?: {
|
|
58
|
+
row: number;
|
|
59
|
+
col: number;
|
|
60
|
+
};
|
|
56
61
|
};
|
|
57
62
|
dataVerificationDropDownList?: boolean;
|
|
58
63
|
conditionRules: ConditionRulesProps;
|
package/es/events/mouse.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare function handleOverlayMouseUp(ctx: Context, globalCache: GlobalCa
|
|
|
17
17
|
export declare function handleRowHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
|
|
18
18
|
export declare function handleColumnHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
|
|
19
19
|
export declare function handleColSizeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
20
|
+
export declare function handleColSizeHandleDoubleClick(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement): void;
|
|
20
21
|
export declare function handleRowSizeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
21
22
|
export declare function handleColFreezeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
22
23
|
export declare function handleRowFreezeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
package/es/events/mouse.js
CHANGED
|
@@ -11,6 +11,7 @@ import { onDropCellSelectEnd, onDropCellSelect } from "../modules/dropCell";
|
|
|
11
11
|
import { handleFormulaInput, rangeDragColumn, rangeDragRow } from "../modules/formula";
|
|
12
12
|
import { showLinkCard, onRangeSelectionModalMove, onRangeSelectionModalMoveEnd } from "../modules/hyperlink";
|
|
13
13
|
import { onSearchDialogMove, onSearchDialogMoveEnd } from "../modules/searchReplace";
|
|
14
|
+
import { getColumnAutoFitWidth } from "../paste-helpers/calculate-range-cell-size";
|
|
14
15
|
var mouseWheelUniqueTimeout;
|
|
15
16
|
var scrollLockTimeout;
|
|
16
17
|
export function handleGlobalWheel(ctx, e, cache, scrollbarX, scrollbarY) {
|
|
@@ -1668,6 +1669,55 @@ export function handleColSizeHandleMouseDown(ctx, globalCache, e, headerContaine
|
|
|
1668
1669
|
ctx.luckysheet_cols_change_size_start = [_x, col_index];
|
|
1669
1670
|
e.stopPropagation();
|
|
1670
1671
|
}
|
|
1672
|
+
export function handleColSizeHandleDoubleClick(ctx, globalCache, e, headerContainer) {
|
|
1673
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1674
|
+
var scrollLeft = ctx.scrollLeft;
|
|
1675
|
+
var mouseX = e.pageX - headerContainer.getBoundingClientRect().left - window.scrollX;
|
|
1676
|
+
var _x = mouseX + scrollLeft;
|
|
1677
|
+
var freeze = (_a = globalCache.freezen) === null || _a === void 0 ? void 0 : _a[ctx.currentSheetId];
|
|
1678
|
+
var x = fixPositionOnFrozenCells(freeze, _x, 0, mouseX, 0).x;
|
|
1679
|
+
var col_location = colLocation(x, ctx.visibledatacolumn);
|
|
1680
|
+
var col_index = col_location[2];
|
|
1681
|
+
var cfg = ctx.config;
|
|
1682
|
+
if (cfg.columnlen == null) {
|
|
1683
|
+
cfg.columnlen = {};
|
|
1684
|
+
}
|
|
1685
|
+
if (cfg.customWidth == null) {
|
|
1686
|
+
cfg.customWidth = {};
|
|
1687
|
+
}
|
|
1688
|
+
var applyAutoFit = function applyAutoFit(colIdx) {
|
|
1689
|
+
var autoWidth = getColumnAutoFitWidth(ctx, colIdx);
|
|
1690
|
+
cfg.columnlen[colIdx] = autoWidth;
|
|
1691
|
+
cfg.customWidth[colIdx] = 1;
|
|
1692
|
+
};
|
|
1693
|
+
var changeColumnSelected = false;
|
|
1694
|
+
if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0) {
|
|
1695
|
+
(_e = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d.filter(function (select) {
|
|
1696
|
+
return select.column_select;
|
|
1697
|
+
})) === null || _e === void 0 ? void 0 : _e.some(function (select) {
|
|
1698
|
+
if (col_index >= select.column[0] && col_index <= select.column[1]) {
|
|
1699
|
+
changeColumnSelected = true;
|
|
1700
|
+
}
|
|
1701
|
+
return changeColumnSelected;
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
if (changeColumnSelected) {
|
|
1705
|
+
(_g = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f.filter(function (select) {
|
|
1706
|
+
return select.column_select;
|
|
1707
|
+
})) === null || _g === void 0 ? void 0 : _g.forEach(function (select) {
|
|
1708
|
+
for (var c = select.column[0]; c <= select.column[1]; c += 1) {
|
|
1709
|
+
applyAutoFit(c);
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
} else {
|
|
1713
|
+
applyAutoFit(col_index);
|
|
1714
|
+
}
|
|
1715
|
+
ctx.config = cfg;
|
|
1716
|
+
var idx = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1717
|
+
if (idx == null) return;
|
|
1718
|
+
ctx.luckysheetfile[idx].config = ctx.config;
|
|
1719
|
+
e.stopPropagation();
|
|
1720
|
+
}
|
|
1671
1721
|
export function handleRowSizeHandleMouseDown(ctx, globalCache, e, headerContainer, workbookContainer, cellArea) {
|
|
1672
1722
|
var _a;
|
|
1673
1723
|
removeEditingComment(ctx, globalCache);
|
|
@@ -3,6 +3,7 @@ export declare function calculateRangeCellSize(ctx: Context, sheetId: string, st
|
|
|
3
3
|
rowMax: Record<number, number>;
|
|
4
4
|
colMax: Record<number, number>;
|
|
5
5
|
};
|
|
6
|
+
export declare function getColumnAutoFitWidth(ctx: Context, colIndex: number): number;
|
|
6
7
|
export declare const updateSheetCellSizes: (ctx: Context, sheetIndex: number, measurements: {
|
|
7
8
|
rowMax: Record<number, number>;
|
|
8
9
|
colMax: Record<number, number>;
|
|
@@ -101,6 +101,45 @@ export function calculateRangeCellSize(ctx, sheetId, startRow, endRow, startCol,
|
|
|
101
101
|
colMax: maxColumnWidths
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
export function getColumnAutoFitWidth(ctx, colIndex) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
var flowdata = getFlowdata(ctx);
|
|
107
|
+
if (!flowdata) return ctx.defaultcollen;
|
|
108
|
+
var rowCount = flowdata.length;
|
|
109
|
+
var cellSizeMeasurer = document.getElementById("fs-cell-measurer");
|
|
110
|
+
if (!cellSizeMeasurer) {
|
|
111
|
+
cellSizeMeasurer = document.createElement("div");
|
|
112
|
+
cellSizeMeasurer.id = "fs-cell-measurer";
|
|
113
|
+
Object.assign(cellSizeMeasurer.style, {
|
|
114
|
+
position: "fixed",
|
|
115
|
+
left: "-99999px",
|
|
116
|
+
top: "-99999px",
|
|
117
|
+
visibility: "hidden",
|
|
118
|
+
lineHeight: "1.3",
|
|
119
|
+
whiteSpace: "pre",
|
|
120
|
+
wordBreak: "normal",
|
|
121
|
+
overflowWrap: "break-word"
|
|
122
|
+
});
|
|
123
|
+
document.body.appendChild(cellSizeMeasurer);
|
|
124
|
+
}
|
|
125
|
+
var maxWidth = ctx.defaultcollen;
|
|
126
|
+
for (var row = 0; row < rowCount; row++) {
|
|
127
|
+
var cell = (_a = flowdata[row]) === null || _a === void 0 ? void 0 : _a[colIndex];
|
|
128
|
+
if (!cell) continue;
|
|
129
|
+
if (cell.mc && cell.mc.rs == null) continue;
|
|
130
|
+
var text = getCellDisplayText(cell);
|
|
131
|
+
if (!text) continue;
|
|
132
|
+
applyFontOnMeasurer(cell, cellSizeMeasurer);
|
|
133
|
+
var fontSizePt = (_b = cell.fs) !== null && _b !== void 0 ? _b : ctx.defaultFontSize;
|
|
134
|
+
cellSizeMeasurer.style.fontSize = "".concat(fontSizePt, "pt");
|
|
135
|
+
cellSizeMeasurer.style.whiteSpace = "pre";
|
|
136
|
+
cellSizeMeasurer.style.width = "auto";
|
|
137
|
+
cellSizeMeasurer.textContent = text;
|
|
138
|
+
var intrinsicWidth = Math.ceil(cellSizeMeasurer.scrollWidth + 12);
|
|
139
|
+
if (intrinsicWidth > maxWidth) maxWidth = intrinsicWidth;
|
|
140
|
+
}
|
|
141
|
+
return maxWidth;
|
|
142
|
+
}
|
|
104
143
|
export var updateSheetCellSizes = function updateSheetCellSizes(ctx, sheetIndex, measurements, maxColumnWidth) {
|
|
105
144
|
var _a;
|
|
106
145
|
if (maxColumnWidth === void 0) {
|
package/lib/context.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export type Context = {
|
|
|
53
53
|
optionLabel_es: any;
|
|
54
54
|
optionLabel_hi: any;
|
|
55
55
|
dataRegulation?: DataRegulationProps;
|
|
56
|
+
updateScope?: "current" | "all";
|
|
57
|
+
sourceCell?: {
|
|
58
|
+
row: number;
|
|
59
|
+
col: number;
|
|
60
|
+
};
|
|
56
61
|
};
|
|
57
62
|
dataVerificationDropDownList?: boolean;
|
|
58
63
|
conditionRules: ConditionRulesProps;
|
package/lib/events/mouse.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare function handleOverlayMouseUp(ctx: Context, globalCache: GlobalCa
|
|
|
17
17
|
export declare function handleRowHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
|
|
18
18
|
export declare function handleColumnHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
|
|
19
19
|
export declare function handleColSizeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
20
|
+
export declare function handleColSizeHandleDoubleClick(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement): void;
|
|
20
21
|
export declare function handleRowSizeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
21
22
|
export declare function handleColFreezeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
|
22
23
|
export declare function handleRowFreezeHandleMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, headerContainer: HTMLDivElement, workbookContainer: HTMLDivElement, cellArea: HTMLDivElement): void;
|
package/lib/events/mouse.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.fixPositionOnFrozenCells = fixPositionOnFrozenCells;
|
|
|
7
7
|
exports.handleCellAreaDoubleClick = handleCellAreaDoubleClick;
|
|
8
8
|
exports.handleCellAreaMouseDown = handleCellAreaMouseDown;
|
|
9
9
|
exports.handleColFreezeHandleMouseDown = handleColFreezeHandleMouseDown;
|
|
10
|
+
exports.handleColSizeHandleDoubleClick = handleColSizeHandleDoubleClick;
|
|
10
11
|
exports.handleColSizeHandleMouseDown = handleColSizeHandleMouseDown;
|
|
11
12
|
exports.handleColumnHeaderMouseDown = handleColumnHeaderMouseDown;
|
|
12
13
|
exports.handleContextMenu = handleContextMenu;
|
|
@@ -29,6 +30,7 @@ var _dropCell = require("../modules/dropCell");
|
|
|
29
30
|
var _formula = require("../modules/formula");
|
|
30
31
|
var _hyperlink = require("../modules/hyperlink");
|
|
31
32
|
var _searchReplace = require("../modules/searchReplace");
|
|
33
|
+
var _calculateRangeCellSize = require("../paste-helpers/calculate-range-cell-size");
|
|
32
34
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
35
|
var mouseWheelUniqueTimeout;
|
|
34
36
|
var scrollLockTimeout;
|
|
@@ -1687,6 +1689,55 @@ function handleColSizeHandleMouseDown(ctx, globalCache, e, headerContainer, work
|
|
|
1687
1689
|
ctx.luckysheet_cols_change_size_start = [_x, col_index];
|
|
1688
1690
|
e.stopPropagation();
|
|
1689
1691
|
}
|
|
1692
|
+
function handleColSizeHandleDoubleClick(ctx, globalCache, e, headerContainer) {
|
|
1693
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1694
|
+
var scrollLeft = ctx.scrollLeft;
|
|
1695
|
+
var mouseX = e.pageX - headerContainer.getBoundingClientRect().left - window.scrollX;
|
|
1696
|
+
var _x = mouseX + scrollLeft;
|
|
1697
|
+
var freeze = (_a = globalCache.freezen) === null || _a === void 0 ? void 0 : _a[ctx.currentSheetId];
|
|
1698
|
+
var x = fixPositionOnFrozenCells(freeze, _x, 0, mouseX, 0).x;
|
|
1699
|
+
var col_location = (0, _location.colLocation)(x, ctx.visibledatacolumn);
|
|
1700
|
+
var col_index = col_location[2];
|
|
1701
|
+
var cfg = ctx.config;
|
|
1702
|
+
if (cfg.columnlen == null) {
|
|
1703
|
+
cfg.columnlen = {};
|
|
1704
|
+
}
|
|
1705
|
+
if (cfg.customWidth == null) {
|
|
1706
|
+
cfg.customWidth = {};
|
|
1707
|
+
}
|
|
1708
|
+
var applyAutoFit = function applyAutoFit(colIdx) {
|
|
1709
|
+
var autoWidth = (0, _calculateRangeCellSize.getColumnAutoFitWidth)(ctx, colIdx);
|
|
1710
|
+
cfg.columnlen[colIdx] = autoWidth;
|
|
1711
|
+
cfg.customWidth[colIdx] = 1;
|
|
1712
|
+
};
|
|
1713
|
+
var changeColumnSelected = false;
|
|
1714
|
+
if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0) {
|
|
1715
|
+
(_e = (_d = ctx.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d.filter(function (select) {
|
|
1716
|
+
return select.column_select;
|
|
1717
|
+
})) === null || _e === void 0 ? void 0 : _e.some(function (select) {
|
|
1718
|
+
if (col_index >= select.column[0] && col_index <= select.column[1]) {
|
|
1719
|
+
changeColumnSelected = true;
|
|
1720
|
+
}
|
|
1721
|
+
return changeColumnSelected;
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
if (changeColumnSelected) {
|
|
1725
|
+
(_g = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f.filter(function (select) {
|
|
1726
|
+
return select.column_select;
|
|
1727
|
+
})) === null || _g === void 0 ? void 0 : _g.forEach(function (select) {
|
|
1728
|
+
for (var c = select.column[0]; c <= select.column[1]; c += 1) {
|
|
1729
|
+
applyAutoFit(c);
|
|
1730
|
+
}
|
|
1731
|
+
});
|
|
1732
|
+
} else {
|
|
1733
|
+
applyAutoFit(col_index);
|
|
1734
|
+
}
|
|
1735
|
+
ctx.config = cfg;
|
|
1736
|
+
var idx = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1737
|
+
if (idx == null) return;
|
|
1738
|
+
ctx.luckysheetfile[idx].config = ctx.config;
|
|
1739
|
+
e.stopPropagation();
|
|
1740
|
+
}
|
|
1690
1741
|
function handleRowSizeHandleMouseDown(ctx, globalCache, e, headerContainer, workbookContainer, cellArea) {
|
|
1691
1742
|
var _a;
|
|
1692
1743
|
(0, _modules.removeEditingComment)(ctx, globalCache);
|
|
@@ -3,6 +3,7 @@ export declare function calculateRangeCellSize(ctx: Context, sheetId: string, st
|
|
|
3
3
|
rowMax: Record<number, number>;
|
|
4
4
|
colMax: Record<number, number>;
|
|
5
5
|
};
|
|
6
|
+
export declare function getColumnAutoFitWidth(ctx: Context, colIndex: number): number;
|
|
6
7
|
export declare const updateSheetCellSizes: (ctx: Context, sheetIndex: number, measurements: {
|
|
7
8
|
rowMax: Record<number, number>;
|
|
8
9
|
colMax: Record<number, number>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calculateRangeCellSize = calculateRangeCellSize;
|
|
7
|
+
exports.getColumnAutoFitWidth = getColumnAutoFitWidth;
|
|
7
8
|
exports.updateSheetCellSizes = void 0;
|
|
8
9
|
var _pasteTableHelpers = require("../paste-table-helpers");
|
|
9
10
|
var _utils = require("../utils");
|
|
@@ -108,6 +109,45 @@ function calculateRangeCellSize(ctx, sheetId, startRow, endRow, startCol, endCol
|
|
|
108
109
|
colMax: maxColumnWidths
|
|
109
110
|
};
|
|
110
111
|
}
|
|
112
|
+
function getColumnAutoFitWidth(ctx, colIndex) {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
115
|
+
if (!flowdata) return ctx.defaultcollen;
|
|
116
|
+
var rowCount = flowdata.length;
|
|
117
|
+
var cellSizeMeasurer = document.getElementById("fs-cell-measurer");
|
|
118
|
+
if (!cellSizeMeasurer) {
|
|
119
|
+
cellSizeMeasurer = document.createElement("div");
|
|
120
|
+
cellSizeMeasurer.id = "fs-cell-measurer";
|
|
121
|
+
Object.assign(cellSizeMeasurer.style, {
|
|
122
|
+
position: "fixed",
|
|
123
|
+
left: "-99999px",
|
|
124
|
+
top: "-99999px",
|
|
125
|
+
visibility: "hidden",
|
|
126
|
+
lineHeight: "1.3",
|
|
127
|
+
whiteSpace: "pre",
|
|
128
|
+
wordBreak: "normal",
|
|
129
|
+
overflowWrap: "break-word"
|
|
130
|
+
});
|
|
131
|
+
document.body.appendChild(cellSizeMeasurer);
|
|
132
|
+
}
|
|
133
|
+
var maxWidth = ctx.defaultcollen;
|
|
134
|
+
for (var row = 0; row < rowCount; row++) {
|
|
135
|
+
var cell = (_a = flowdata[row]) === null || _a === void 0 ? void 0 : _a[colIndex];
|
|
136
|
+
if (!cell) continue;
|
|
137
|
+
if (cell.mc && cell.mc.rs == null) continue;
|
|
138
|
+
var text = getCellDisplayText(cell);
|
|
139
|
+
if (!text) continue;
|
|
140
|
+
applyFontOnMeasurer(cell, cellSizeMeasurer);
|
|
141
|
+
var fontSizePt = (_b = cell.fs) !== null && _b !== void 0 ? _b : ctx.defaultFontSize;
|
|
142
|
+
cellSizeMeasurer.style.fontSize = "".concat(fontSizePt, "pt");
|
|
143
|
+
cellSizeMeasurer.style.whiteSpace = "pre";
|
|
144
|
+
cellSizeMeasurer.style.width = "auto";
|
|
145
|
+
cellSizeMeasurer.textContent = text;
|
|
146
|
+
var intrinsicWidth = Math.ceil(cellSizeMeasurer.scrollWidth + 12);
|
|
147
|
+
if (intrinsicWidth > maxWidth) maxWidth = intrinsicWidth;
|
|
148
|
+
}
|
|
149
|
+
return maxWidth;
|
|
150
|
+
}
|
|
111
151
|
var updateSheetCellSizes = exports.updateSheetCellSizes = function updateSheetCellSizes(ctx, sheetIndex, measurements, maxColumnWidth) {
|
|
112
152
|
var _a;
|
|
113
153
|
if (maxColumnWidth === void 0) {
|