@fileverse-dev/fortune-core 1.3.0-paint → 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/modules/selection.js +27 -33
- package/es/modules/toolbar.js +0 -1
- 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/modules/selection.js +27 -33
- package/lib/modules/toolbar.js +0 -1
- 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);
|
package/es/modules/selection.js
CHANGED
|
@@ -180,8 +180,6 @@ export function selectTitlesRange(map) {
|
|
|
180
180
|
return rangeArr;
|
|
181
181
|
}
|
|
182
182
|
export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
183
|
-
var _a;
|
|
184
|
-
console.log("pasteHandlerOfPaintModel", ctx, copyRange);
|
|
185
183
|
var cfg = ctx.config;
|
|
186
184
|
if (cfg.merge == null) {
|
|
187
185
|
cfg.merge = {};
|
|
@@ -371,40 +369,36 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
371
369
|
}
|
|
372
370
|
var currFile = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
|
|
373
371
|
currFile.config = cfg;
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
372
|
+
currFile.dataVerification = dataVerification;
|
|
373
|
+
var cdformat = null;
|
|
377
374
|
var copyIndex = getSheetIndex(ctx, copySheetIndex);
|
|
378
|
-
if (copyIndex
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
emptyRange = emptyRange.concat(range);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (emptyRange.length > 0) {
|
|
400
|
-
ruleArr[i].cellrange = [{
|
|
401
|
-
row: [minh, maxh],
|
|
402
|
-
column: [minc, maxc]
|
|
403
|
-
}];
|
|
404
|
-
cdformat.push(ruleArr[i]);
|
|
375
|
+
if (!copyIndex) return;
|
|
376
|
+
var ruleArr = _.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
|
|
377
|
+
if (!_.isNil(ruleArr) && ruleArr.length > 0) {
|
|
378
|
+
var currentIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
379
|
+
cdformat = _.cloneDeep(ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save);
|
|
380
|
+
for (var i = 0; i < ruleArr.length; i += 1) {
|
|
381
|
+
var cdformat_cellrange = ruleArr[i].cellrange;
|
|
382
|
+
var emptyRange = [];
|
|
383
|
+
for (var j = 0; j < cdformat_cellrange.length; j += 1) {
|
|
384
|
+
var range = CFSplitRange(cdformat_cellrange[j], {
|
|
385
|
+
row: [c_r1, c_r2],
|
|
386
|
+
column: [c_c1, c_c2]
|
|
387
|
+
}, {
|
|
388
|
+
row: [minh, maxh],
|
|
389
|
+
column: [minc, maxc]
|
|
390
|
+
}, "operatePart");
|
|
391
|
+
if (range.length > 0) {
|
|
392
|
+
emptyRange = emptyRange.concat(range);
|
|
405
393
|
}
|
|
406
394
|
}
|
|
407
|
-
|
|
395
|
+
if (emptyRange.length > 0) {
|
|
396
|
+
ruleArr[i].cellrange = [{
|
|
397
|
+
row: [minh, maxh],
|
|
398
|
+
column: [minc, maxc]
|
|
399
|
+
}];
|
|
400
|
+
cdformat.push(ruleArr[i]);
|
|
401
|
+
}
|
|
408
402
|
}
|
|
409
403
|
}
|
|
410
404
|
}
|
package/es/modules/toolbar.js
CHANGED
|
@@ -727,7 +727,6 @@ export function handleVerticalAlign(ctx, cellInput, value) {
|
|
|
727
727
|
setAttr(ctx, cellInput, "vt", value);
|
|
728
728
|
}
|
|
729
729
|
export function handleFormatPainter(ctx) {
|
|
730
|
-
console.log("handleFormatPainter", ctx);
|
|
731
730
|
var allowEdit = isAllowEdit(ctx);
|
|
732
731
|
if (!allowEdit) return;
|
|
733
732
|
if (ctx.luckysheet_select_save == null || ctx.luckysheet_select_save.length === 0) {
|
|
@@ -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);
|
package/lib/modules/selection.js
CHANGED
|
@@ -215,8 +215,6 @@ function selectTitlesRange(map) {
|
|
|
215
215
|
return rangeArr;
|
|
216
216
|
}
|
|
217
217
|
function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
218
|
-
var _a;
|
|
219
|
-
console.log("pasteHandlerOfPaintModel", ctx, copyRange);
|
|
220
218
|
var cfg = ctx.config;
|
|
221
219
|
if (cfg.merge == null) {
|
|
222
220
|
cfg.merge = {};
|
|
@@ -406,40 +404,36 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
406
404
|
}
|
|
407
405
|
var currFile = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
|
|
408
406
|
currFile.config = cfg;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
407
|
+
currFile.dataVerification = dataVerification;
|
|
408
|
+
var cdformat = null;
|
|
412
409
|
var copyIndex = (0, _utils.getSheetIndex)(ctx, copySheetIndex);
|
|
413
|
-
if (copyIndex
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
emptyRange = emptyRange.concat(range);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
if (emptyRange.length > 0) {
|
|
435
|
-
ruleArr[i].cellrange = [{
|
|
436
|
-
row: [minh, maxh],
|
|
437
|
-
column: [minc, maxc]
|
|
438
|
-
}];
|
|
439
|
-
cdformat.push(ruleArr[i]);
|
|
410
|
+
if (!copyIndex) return;
|
|
411
|
+
var ruleArr = _lodash.default.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
|
|
412
|
+
if (!_lodash.default.isNil(ruleArr) && ruleArr.length > 0) {
|
|
413
|
+
var currentIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
414
|
+
cdformat = _lodash.default.cloneDeep(ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save);
|
|
415
|
+
for (var i = 0; i < ruleArr.length; i += 1) {
|
|
416
|
+
var cdformat_cellrange = ruleArr[i].cellrange;
|
|
417
|
+
var emptyRange = [];
|
|
418
|
+
for (var j = 0; j < cdformat_cellrange.length; j += 1) {
|
|
419
|
+
var range = (0, _ConditionFormat.CFSplitRange)(cdformat_cellrange[j], {
|
|
420
|
+
row: [c_r1, c_r2],
|
|
421
|
+
column: [c_c1, c_c2]
|
|
422
|
+
}, {
|
|
423
|
+
row: [minh, maxh],
|
|
424
|
+
column: [minc, maxc]
|
|
425
|
+
}, "operatePart");
|
|
426
|
+
if (range.length > 0) {
|
|
427
|
+
emptyRange = emptyRange.concat(range);
|
|
440
428
|
}
|
|
441
429
|
}
|
|
442
|
-
|
|
430
|
+
if (emptyRange.length > 0) {
|
|
431
|
+
ruleArr[i].cellrange = [{
|
|
432
|
+
row: [minh, maxh],
|
|
433
|
+
column: [minc, maxc]
|
|
434
|
+
}];
|
|
435
|
+
cdformat.push(ruleArr[i]);
|
|
436
|
+
}
|
|
443
437
|
}
|
|
444
438
|
}
|
|
445
439
|
}
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -760,7 +760,6 @@ function handleVerticalAlign(ctx, cellInput, value) {
|
|
|
760
760
|
setAttr(ctx, cellInput, "vt", value);
|
|
761
761
|
}
|
|
762
762
|
function handleFormatPainter(ctx) {
|
|
763
|
-
console.log("handleFormatPainter", ctx);
|
|
764
763
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
765
764
|
if (!allowEdit) return;
|
|
766
765
|
if (ctx.luckysheet_select_save == null || ctx.luckysheet_select_save.length === 0) {
|
|
@@ -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) {
|