@rowsncolumns/spreadsheet-state 28.0.67 → 28.0.69
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/dist/cjs/helpers/sheet-title.d.ts +3 -0
- package/dist/cjs/helpers/sheet-title.d.ts.map +1 -1
- package/dist/cjs/helpers/sheet-title.js +10 -1
- package/dist/cjs/hooks/use-on-copy.d.ts +8 -1
- package/dist/cjs/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-copy.js +248 -153
- package/dist/cjs/hooks/use-on-rename-sheet.js +2 -2
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +1 -1
- package/dist/cjs/interface/delete-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-column.js +62 -60
- package/dist/cjs/interface/delete-table-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-table-column.js +4 -3
- package/dist/cjs/interface/delete-table-row.d.ts.map +1 -1
- package/dist/cjs/interface/delete-table-row.js +19 -8
- package/dist/cjs/interface/insert-column.d.ts.map +1 -1
- package/dist/cjs/interface/insert-column.js +5 -4
- package/dist/cjs/interface/insert-table-row.d.ts.map +1 -1
- package/dist/cjs/interface/insert-table-row.js +19 -9
- package/dist/cjs/interface/update-sheet.d.ts.map +1 -1
- package/dist/cjs/interface/update-sheet.js +4 -1
- package/dist/esm/helpers/sheet-title.d.ts +3 -0
- package/dist/esm/helpers/sheet-title.d.ts.map +1 -1
- package/dist/esm/helpers/sheet-title.js +9 -0
- package/dist/esm/hooks/use-on-copy.d.ts +8 -1
- package/dist/esm/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-copy.js +196 -145
- package/dist/esm/hooks/use-on-rename-sheet.js +2 -2
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +1 -1
- package/dist/esm/interface/delete-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-column.js +30 -18
- package/dist/esm/interface/delete-table-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-table-column.js +4 -2
- package/dist/esm/interface/delete-table-row.d.ts.map +1 -1
- package/dist/esm/interface/delete-table-row.js +17 -8
- package/dist/esm/interface/insert-column.d.ts.map +1 -1
- package/dist/esm/interface/insert-column.js +5 -3
- package/dist/esm/interface/insert-table-row.d.ts.map +1 -1
- package/dist/esm/interface/insert-table-row.js +17 -9
- package/dist/esm/interface/update-sheet.d.ts.map +1 -1
- package/dist/esm/interface/update-sheet.js +4 -1
- package/package.json +24 -24
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Sheet } from "@rowsncolumns/spreadsheet";
|
|
2
2
|
export declare const MAX_SHEET_TITLE_LENGTH = 32;
|
|
3
3
|
export declare const truncateSheetTitle: (title: string) => string;
|
|
4
|
+
/** Worksheet names cannot be empty or whitespace-only. */
|
|
5
|
+
export declare const isValidSheetTitle: (title: string) => boolean;
|
|
6
|
+
/** Truncates a valid title; drops an invalid (blank) one so the rest of the spec still applies. */
|
|
4
7
|
export declare const sanitizeSheetSpecTitle: <S extends Sheet>(sheetSpec: Partial<S>) => Partial<S>;
|
|
5
8
|
//# sourceMappingURL=sheet-title.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-title.d.ts","sourceRoot":"","sources":["../../../helpers/sheet-title.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,MAElD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,KAAK,EACpD,WAAW,OAAO,CAAC,CAAC,CAAC,KACpB,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"sheet-title.d.ts","sourceRoot":"","sources":["../../../helpers/sheet-title.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,MAElD,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,OAEjD,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,KAAK,EACpD,WAAW,OAAO,CAAC,CAAC,CAAC,KACpB,OAAO,CAAC,CAAC,CAcX,CAAC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
2
|
export var MAX_SHEET_TITLE_LENGTH = 32;
|
|
3
3
|
export var truncateSheetTitle = function (title) {
|
|
4
4
|
return title.slice(0, MAX_SHEET_TITLE_LENGTH);
|
|
5
5
|
};
|
|
6
|
+
/** Worksheet names cannot be empty or whitespace-only. */
|
|
7
|
+
export var isValidSheetTitle = function (title) {
|
|
8
|
+
return title.trim().length > 0;
|
|
9
|
+
};
|
|
10
|
+
/** Truncates a valid title; drops an invalid (blank) one so the rest of the spec still applies. */
|
|
6
11
|
export var sanitizeSheetSpecTitle = function (sheetSpec) {
|
|
7
12
|
if (typeof sheetSpec.title !== "string") {
|
|
8
13
|
return sheetSpec;
|
|
9
14
|
}
|
|
15
|
+
if (!isValidSheetTitle(sheetSpec.title)) {
|
|
16
|
+
var _title = sheetSpec.title, rest = __rest(sheetSpec, ["title"]);
|
|
17
|
+
return rest;
|
|
18
|
+
}
|
|
10
19
|
return __assign(__assign({}, sheetSpec), { title: truncateSheetTitle(sheetSpec.title) });
|
|
11
20
|
};
|
|
@@ -5,6 +5,13 @@ import type { BandedRange, TableView } from "@rowsncolumns/spreadsheet";
|
|
|
5
5
|
import { type CellData, type CellFormat, type SelectionAttributes } from "@rowsncolumns/spreadsheet";
|
|
6
6
|
import type { CellXfs, SharedStringValue, SharedStrings } from "../types";
|
|
7
7
|
import type { useSheetProperties } from "./use-sheet-properties";
|
|
8
|
+
/**
|
|
9
|
+
* Excel/Sheets copy a multi-area selection only when every area spans the same
|
|
10
|
+
* rows (areas sit side by side, left to right) or the same columns (areas stack,
|
|
11
|
+
* top to bottom). Returns the row and column indexes of the merged rectangle, or
|
|
12
|
+
* undefined for any other shape.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getCopiedRowsAndColumns: (copiedSelections: SelectionArea<SelectionAttributes>[]) => [rows: number[], columns: number[]] | undefined;
|
|
8
15
|
type UseOnCopyProps<T extends CellData> = {
|
|
9
16
|
theme?: SpreadsheetTheme;
|
|
10
17
|
merges?: GridRange[] | null;
|
|
@@ -43,7 +50,7 @@ export type CopySchema<T extends CellData> = {
|
|
|
43
50
|
* @param param0
|
|
44
51
|
* @returns
|
|
45
52
|
*/
|
|
46
|
-
export declare const useOnCopy: <T extends CellData>({ theme, merges, tables: sheetTables, bandedRanges, getFormattedValue, getCellData, getColumnWidth, getRowHeight, cellXfs, sharedStrings, getEffectiveFormat, isHiddenRow, isColumnHidden, }: UseOnCopyProps<T>) => (e: ClipboardEvent | undefined, sheetId: number, copiedSelections: SelectionArea<SelectionAttributes>[]) =>
|
|
53
|
+
export declare const useOnCopy: <T extends CellData>({ theme, merges, tables: sheetTables, bandedRanges, getFormattedValue, getCellData, getColumnWidth, getRowHeight, cellXfs, sharedStrings, getEffectiveFormat, isHiddenRow, isColumnHidden, }: UseOnCopyProps<T>) => (e: ClipboardEvent | undefined, sheetId: number, copiedSelections: SelectionArea<SelectionAttributes>[], isCutOperation?: boolean) => boolean;
|
|
47
54
|
export declare const useMergedCellMap: (merges?: GridRange[] | null) => Map<string, [isMasterCell: boolean, readonly [rowspan: number, colspan: number]]>;
|
|
48
55
|
export {};
|
|
49
56
|
//# sourceMappingURL=use-on-copy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-copy.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-on-copy.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AAanC,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAajE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,kBAAkB,aAAa,CAAC,mBAAmB,CAAC,EAAE,KACrD,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,SA0CxC,CAAC;AAEF,KAAK,cAAc,CAAC,CAAC,SAAS,QAAQ,IAAI;IACxC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IACpC,iBAAiB,EAAE,CACjB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,KAChB,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/B,WAAW,CACT,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IACxB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7D,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACxD,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,kBAAkB,CAAC,EAAE,UAAU,CAC7B,OAAO,kBAAkB,CAC1B,CAAC,oBAAoB,CAAC,CAAC;IACxB,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACzD,cAAc,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,IAAI;IAC3C,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC9B,SAAS,EAAE,gBAAgB,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAClD,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;CACnE,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,QAAQ,EAAE,8LAc3C,cAAc,CAAC,CAAC,CAAC,SAOX,cAAc,GAAG,SAAS,WACpB,MAAM,oBACG,aAAa,CAAC,mBAAmB,CAAC,EAAE,mBACrC,OAAO,YAqX7B,CAAC;AAGF,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,EAAE,GAAG,IAAI,sFA4B3D,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { __assign, __read, __values } from "tslib";
|
|
1
|
+
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
2
2
|
import { areaInsideArea, cellIdentifier, } from "@rowsncolumns/grid";
|
|
3
3
|
import { getBandedCells, getStringifiedColor, } from "@rowsncolumns/spreadsheet";
|
|
4
4
|
import { cellToAddress, getStyleId, getCellUserEnteredValue, getExtendedValueFormula, isNil, iterateCellsInRange, } from "@rowsncolumns/utils";
|
|
5
5
|
import { useCallback, useMemo } from "react";
|
|
6
|
+
import { useShowError } from "../atoms/error-state.atom";
|
|
6
7
|
import { isStyleReference } from "../sheet-cell";
|
|
7
8
|
var escapeHtmlAttribute = function (value) {
|
|
8
9
|
return value
|
|
@@ -12,6 +13,74 @@ var escapeHtmlAttribute = function (value) {
|
|
|
12
13
|
.replace(/</g, "<")
|
|
13
14
|
.replace(/>/g, ">");
|
|
14
15
|
};
|
|
16
|
+
var MULTIPLE_SELECTIONS_ERROR = "This action won't work on multiple selections.";
|
|
17
|
+
/**
|
|
18
|
+
* Excel/Sheets copy a multi-area selection only when every area spans the same
|
|
19
|
+
* rows (areas sit side by side, left to right) or the same columns (areas stack,
|
|
20
|
+
* top to bottom). Returns the row and column indexes of the merged rectangle, or
|
|
21
|
+
* undefined for any other shape.
|
|
22
|
+
*/
|
|
23
|
+
export var getCopiedRowsAndColumns = function (copiedSelections) {
|
|
24
|
+
var e_1, _a, e_2, _b;
|
|
25
|
+
var ranges = copiedSelections.map(function (_a) {
|
|
26
|
+
var range = _a.range;
|
|
27
|
+
return range;
|
|
28
|
+
});
|
|
29
|
+
var _c = __read(ranges, 1), first = _c[0];
|
|
30
|
+
if (!first) {
|
|
31
|
+
return [[], []];
|
|
32
|
+
}
|
|
33
|
+
var sameRows = ranges.every(function (range) {
|
|
34
|
+
return range.startRowIndex === first.startRowIndex &&
|
|
35
|
+
range.endRowIndex === first.endRowIndex;
|
|
36
|
+
});
|
|
37
|
+
var sameColumns = ranges.every(function (range) {
|
|
38
|
+
return range.startColumnIndex === first.startColumnIndex &&
|
|
39
|
+
range.endColumnIndex === first.endColumnIndex;
|
|
40
|
+
});
|
|
41
|
+
if (!sameRows && !sameColumns) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
var rowRanges = sameRows
|
|
45
|
+
? [first]
|
|
46
|
+
: __spreadArray([], __read(ranges), false).sort(function (a, b) { return a.startRowIndex - b.startRowIndex; });
|
|
47
|
+
var columnRanges = sameColumns
|
|
48
|
+
? [first]
|
|
49
|
+
: __spreadArray([], __read(ranges), false).sort(function (a, b) { return a.startColumnIndex - b.startColumnIndex; });
|
|
50
|
+
var rows = [];
|
|
51
|
+
try {
|
|
52
|
+
for (var rowRanges_1 = __values(rowRanges), rowRanges_1_1 = rowRanges_1.next(); !rowRanges_1_1.done; rowRanges_1_1 = rowRanges_1.next()) {
|
|
53
|
+
var _d = rowRanges_1_1.value, startRowIndex = _d.startRowIndex, endRowIndex = _d.endRowIndex;
|
|
54
|
+
for (var rowIndex = startRowIndex; rowIndex <= endRowIndex; rowIndex++) {
|
|
55
|
+
rows.push(rowIndex);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
if (rowRanges_1_1 && !rowRanges_1_1.done && (_a = rowRanges_1.return)) _a.call(rowRanges_1);
|
|
63
|
+
}
|
|
64
|
+
finally { if (e_1) throw e_1.error; }
|
|
65
|
+
}
|
|
66
|
+
var columns = [];
|
|
67
|
+
try {
|
|
68
|
+
for (var columnRanges_1 = __values(columnRanges), columnRanges_1_1 = columnRanges_1.next(); !columnRanges_1_1.done; columnRanges_1_1 = columnRanges_1.next()) {
|
|
69
|
+
var _e = columnRanges_1_1.value, startColumnIndex = _e.startColumnIndex, endColumnIndex = _e.endColumnIndex;
|
|
70
|
+
for (var columnIndex = startColumnIndex; columnIndex <= endColumnIndex; columnIndex++) {
|
|
71
|
+
columns.push(columnIndex);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
76
|
+
finally {
|
|
77
|
+
try {
|
|
78
|
+
if (columnRanges_1_1 && !columnRanges_1_1.done && (_b = columnRanges_1.return)) _b.call(columnRanges_1);
|
|
79
|
+
}
|
|
80
|
+
finally { if (e_2) throw e_2.error; }
|
|
81
|
+
}
|
|
82
|
+
return [rows, columns];
|
|
83
|
+
};
|
|
15
84
|
/**
|
|
16
85
|
* Called when user copies a selection from sheet
|
|
17
86
|
* 1. User can copy from any cell
|
|
@@ -23,9 +92,20 @@ export var useOnCopy = function (_a) {
|
|
|
23
92
|
var theme = _a.theme, merges = _a.merges, sheetTables = _a.tables, bandedRanges = _a.bandedRanges, getFormattedValue = _a.getFormattedValue, getCellData = _a.getCellData, getColumnWidth = _a.getColumnWidth, getRowHeight = _a.getRowHeight, cellXfs = _a.cellXfs, sharedStrings = _a.sharedStrings, getEffectiveFormat = _a.getEffectiveFormat, isHiddenRow = _a.isHiddenRow, isColumnHidden = _a.isColumnHidden;
|
|
24
93
|
// Merge cell map
|
|
25
94
|
var mergedCellMap = useMergedCellMap(merges);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
95
|
+
var showError = useShowError();
|
|
96
|
+
return useCallback(function (e, sheetId, copiedSelections, isCutOperation) {
|
|
97
|
+
var e_3, _a, e_4, _b, e_5, _c;
|
|
98
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
99
|
+
// Excel refuses to cut a multi-area selection, and only copies one whose
|
|
100
|
+
// areas share the same rows or the same columns.
|
|
101
|
+
var rowsAndColumns = isCutOperation && copiedSelections.length > 1
|
|
102
|
+
? undefined
|
|
103
|
+
: getCopiedRowsAndColumns(copiedSelections);
|
|
104
|
+
if (!rowsAndColumns) {
|
|
105
|
+
showError({ message: MULTIPLE_SELECTIONS_ERROR });
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
var _0 = __read(rowsAndColumns, 2), rows = _0[0], columns = _0[1];
|
|
29
109
|
var isRowHidden = isHiddenRow !== null && isHiddenRow !== void 0 ? isHiddenRow : (function () { return false; });
|
|
30
110
|
var isColHidden = isColumnHidden !== null && isColumnHidden !== void 0 ? isColumnHidden : (function () { return false; });
|
|
31
111
|
// Table styling (header fill, banded row/column fills, table borders)
|
|
@@ -76,33 +156,42 @@ export var useOnCopy = function (_a) {
|
|
|
76
156
|
}
|
|
77
157
|
};
|
|
78
158
|
var colGroups = "<colgroup>";
|
|
79
|
-
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
for (var columnIndex = startColumnIndex; columnIndex <= endColumnIndex; columnIndex++) {
|
|
159
|
+
try {
|
|
160
|
+
for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
|
|
161
|
+
var columnIndex = columns_1_1.value;
|
|
83
162
|
if (isColHidden(sheetId, columnIndex))
|
|
84
163
|
continue;
|
|
85
164
|
var cellWidth = getColumnWidth(sheetId, columnIndex);
|
|
86
165
|
colGroups += "<col width=\"".concat(cellWidth, "\" />");
|
|
87
166
|
}
|
|
88
|
-
}
|
|
167
|
+
}
|
|
168
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
169
|
+
finally {
|
|
170
|
+
try {
|
|
171
|
+
if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
|
|
172
|
+
}
|
|
173
|
+
finally { if (e_3) throw e_3.error; }
|
|
174
|
+
}
|
|
89
175
|
colGroups += "</colgroup>";
|
|
90
176
|
var htmlString = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\"\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n xmlns=\"http://www.w3.org/TR/REC-html40\">\n <meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">\n <style>\n <!--table{mso-displayed-decimal-separator:\".\"; mso-displayed-thousand-separator:\",\";}tr{mso-height-source:auto;}col{mso-width-source:auto;}-->\n </style>\n <style type=\"text/css\"><!--td {border: 1px solid #cccccc;}br {mso-data-placement:same-cell;}--></style><body>\n <table xmlns=\"http://www.w3.org/1999/xhtml\" cellspacing=\"0\" cellpadding=\"0\" dir=\"ltr\" border=\"1\" style=\"table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none\">".concat(colGroups, "<tbody>");
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
177
|
+
/* Check if user is copying a table */
|
|
178
|
+
if (copiedSelections.length === 1) {
|
|
179
|
+
var range_1 = copiedSelections[0].range;
|
|
94
180
|
var table = sheetTables === null || sheetTables === void 0 ? void 0 : sheetTables.find(function (table) {
|
|
95
|
-
return areaInsideArea(table.range,
|
|
181
|
+
return areaInsideArea(table.range, range_1) && table.sheetId === sheetId;
|
|
96
182
|
});
|
|
97
183
|
if (table) {
|
|
98
184
|
// We need to set a rowDelta and colDelta
|
|
99
|
-
var rowDelta = table.range.startRowIndex -
|
|
100
|
-
var colDelta = table.range.startColumnIndex -
|
|
185
|
+
var rowDelta = table.range.startRowIndex - range_1.startRowIndex;
|
|
186
|
+
var colDelta = table.range.startColumnIndex - range_1.startColumnIndex;
|
|
101
187
|
// Add table
|
|
102
188
|
tables.push(__assign(__assign({}, table), { rowDelta: rowDelta, colDelta: colDelta }));
|
|
103
189
|
}
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
104
192
|
/* Iterate over all cells */
|
|
105
|
-
for (var
|
|
193
|
+
for (var rows_1 = __values(rows), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
|
|
194
|
+
var rowIndex = rows_1_1.value;
|
|
106
195
|
if (isRowHidden(sheetId, rowIndex)) {
|
|
107
196
|
continue;
|
|
108
197
|
}
|
|
@@ -110,129 +199,139 @@ export var useOnCopy = function (_a) {
|
|
|
110
199
|
htmlString += "<tr style=\"height:".concat(rowHeight, "px\">");
|
|
111
200
|
var csvRow = [];
|
|
112
201
|
var jsonRow = [];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
202
|
+
try {
|
|
203
|
+
for (var columns_2 = (e_5 = void 0, __values(columns)), columns_2_1 = columns_2.next(); !columns_2_1.done; columns_2_1 = columns_2.next()) {
|
|
204
|
+
var columnIndex = columns_2_1.value;
|
|
205
|
+
if (isColHidden(sheetId, columnIndex)) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
var mergedCellInfo = mergedCellMap.get(cellIdentifier(rowIndex, columnIndex));
|
|
209
|
+
var isMasterCell = mergedCellInfo ? mergedCellInfo[0] : true;
|
|
210
|
+
if (!isMasterCell) {
|
|
211
|
+
jsonRow.push({
|
|
212
|
+
data: undefined,
|
|
213
|
+
});
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
var _1 = __read(mergedCellInfo
|
|
217
|
+
? mergedCellInfo[1]
|
|
218
|
+
: [1, 1], 2), rowspan = _1[0], colspan = _1[1];
|
|
219
|
+
var formattedValue = (_d = getFormattedValue(sheetId, rowIndex, columnIndex)) !== null && _d !== void 0 ? _d : "";
|
|
220
|
+
var cellData = getCellData(sheetId, rowIndex, columnIndex);
|
|
221
|
+
var normalizedCellData = cellData;
|
|
222
|
+
if (cellData && typeof cellData === "object") {
|
|
223
|
+
normalizedCellData = __assign({}, cellData);
|
|
224
|
+
if (!isNil(normalizedCellData.ss)) {
|
|
225
|
+
normalizedCellData.ss = collectSharedString(String(normalizedCellData.ss));
|
|
226
|
+
}
|
|
227
|
+
collectCellXfs(normalizedCellData.uf);
|
|
228
|
+
collectCellXfs(normalizedCellData.ef);
|
|
229
|
+
}
|
|
230
|
+
var formula = getExtendedValueFormula(getCellUserEnteredValue(cellData));
|
|
231
|
+
var origin_1 = (_e = cellToAddress({ rowIndex: rowIndex, columnIndex: columnIndex })) !== null && _e !== void 0 ? _e : "".concat(rowIndex, ":").concat(columnIndex);
|
|
232
|
+
var formulaAttr = formula
|
|
233
|
+
? " data-sheets-formula=\"".concat(escapeHtmlAttribute(formula), "\" data-formula=\"").concat(escapeHtmlAttribute(formula), "\" data-sheets-formula-origin=\"").concat(escapeHtmlAttribute(origin_1), "\" data-formula-origin=\"").concat(escapeHtmlAttribute(origin_1), "\"")
|
|
234
|
+
: "";
|
|
235
|
+
var effectiveFormat = getEffectiveFormat === null || getEffectiveFormat === void 0 ? void 0 : getEffectiveFormat(sheetId, rowIndex, columnIndex);
|
|
236
|
+
var bandedFormat = bandedCells === null || bandedCells === void 0 ? void 0 : bandedCells.get(cellIdentifier(rowIndex, columnIndex));
|
|
237
|
+
var numberFormatType = (_f = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.numberFormat) === null || _f === void 0 ? void 0 : _f.type;
|
|
238
|
+
var numberFormatPattern = (_g = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.numberFormat) === null || _g === void 0 ? void 0 : _g.pattern;
|
|
239
|
+
var numberFormatAttr = numberFormatType
|
|
240
|
+
? " data-sheets-numberformat-type=\"".concat(escapeHtmlAttribute(numberFormatType), "\"").concat(numberFormatPattern
|
|
241
|
+
? " data-sheets-numberformat-pattern=\"".concat(escapeHtmlAttribute(numberFormatPattern), "\"")
|
|
242
|
+
: "")
|
|
243
|
+
: "";
|
|
244
|
+
// Alignment is encoded as data attributes so paste doesn't have
|
|
245
|
+
// to trust `getComputedStyle().textAlign`, which fabricates a
|
|
246
|
+
// CSS-spec default of `"start"` even when the value was never set.
|
|
247
|
+
var horizontalAlignment = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.horizontalAlignment;
|
|
248
|
+
var verticalAlignment = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.verticalAlignment;
|
|
249
|
+
var alignmentAttr = "".concat(horizontalAlignment
|
|
250
|
+
? " data-sheets-horizontal-alignment=\"".concat(escapeHtmlAttribute(horizontalAlignment), "\"")
|
|
251
|
+
: "").concat(verticalAlignment
|
|
252
|
+
? " data-sheets-vertical-alignment=\"".concat(escapeHtmlAttribute(verticalAlignment), "\"")
|
|
253
|
+
: "");
|
|
254
|
+
// Csv
|
|
255
|
+
csvRow.push(formattedValue);
|
|
256
|
+
// Style
|
|
257
|
+
var isItalic = (_h = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _h === void 0 ? void 0 : _h.italic;
|
|
258
|
+
var isBold = (_j = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _j === void 0 ? void 0 : _j.bold;
|
|
259
|
+
var isUnderline = (_k = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _k === void 0 ? void 0 : _k.underline;
|
|
260
|
+
var isStrikeThrough = (_l = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _l === void 0 ? void 0 : _l.strikethrough;
|
|
261
|
+
var baselineOffset = (_m = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _m === void 0 ? void 0 : _m.baselineOffset;
|
|
262
|
+
// Cell-level formatting wins over the banded (table style) layer,
|
|
263
|
+
// matching the canvas grid's merge order.
|
|
264
|
+
var cellBorders = (_o = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.borders) !== null && _o !== void 0 ? _o : bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.borders;
|
|
265
|
+
var borderTop = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.top;
|
|
266
|
+
var borderBottom = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.bottom;
|
|
267
|
+
var borderLeft = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.left;
|
|
268
|
+
var borderRight = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.right;
|
|
269
|
+
var textDecoration = "".concat(isUnderline ? "underline" : "", " ").concat(isStrikeThrough ? "line-through" : "").trim();
|
|
270
|
+
var wordWrap = (effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.wrapStrategy) === "wrap";
|
|
271
|
+
var style = theme
|
|
272
|
+
? {
|
|
273
|
+
"background-color": getStringifiedColor((_p = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.backgroundColor) !== null && _p !== void 0 ? _p : bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.backgroundColor, theme),
|
|
274
|
+
color: getStringifiedColor((_r = (_q = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _q === void 0 ? void 0 : _q.color) !== null && _r !== void 0 ? _r : (_s = bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.textFormat) === null || _s === void 0 ? void 0 : _s.color, theme),
|
|
275
|
+
padding: "2px 3px 2px 3px",
|
|
276
|
+
overflow: "hidden",
|
|
277
|
+
"font-weight": isBold ? "700" : "normal",
|
|
278
|
+
"font-family": (_t = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _t === void 0 ? void 0 : _t.fontFamily,
|
|
279
|
+
"font-style": isItalic ? "italic" : "normal",
|
|
280
|
+
"text-decoration": textDecoration
|
|
281
|
+
? textDecoration
|
|
282
|
+
: undefined,
|
|
283
|
+
"font-size": "".concat((_v = (_u = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _u === void 0 ? void 0 : _u.fontSize) !== null && _v !== void 0 ? _v : 10, "pt"),
|
|
284
|
+
"text-align": effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.horizontalAlignment,
|
|
285
|
+
"vertical-align": effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.verticalAlignment,
|
|
286
|
+
"border-top": borderTop
|
|
287
|
+
? "".concat(borderTop.width, "px solid ").concat(getStringifiedColor(borderTop.color, theme))
|
|
288
|
+
: undefined,
|
|
289
|
+
"border-left": borderLeft
|
|
290
|
+
? "".concat(borderLeft.width, "px solid ").concat(getStringifiedColor(borderLeft.color, theme))
|
|
291
|
+
: undefined,
|
|
292
|
+
"border-right": borderRight
|
|
293
|
+
? "".concat(borderRight.width, "px solid ").concat(getStringifiedColor(borderRight.color, theme))
|
|
294
|
+
: undefined,
|
|
295
|
+
"border-bottom": borderBottom
|
|
296
|
+
? "".concat(borderBottom.width, "px solid ").concat(getStringifiedColor(borderBottom.color, theme))
|
|
297
|
+
: undefined,
|
|
298
|
+
"text-wrap": wordWrap ? "wrap" : undefined,
|
|
299
|
+
}
|
|
300
|
+
: {};
|
|
301
|
+
// html
|
|
302
|
+
var innerHtml = baselineOffset === "superscript"
|
|
303
|
+
? "<sup>".concat(formattedValue, "</sup>")
|
|
304
|
+
: baselineOffset === "subscript"
|
|
305
|
+
? "<sub>".concat(formattedValue, "</sub>")
|
|
306
|
+
: formattedValue;
|
|
307
|
+
htmlString +=
|
|
308
|
+
"<td".concat(formulaAttr).concat(numberFormatAttr).concat(alignmentAttr, " ").concat(rowspan > 1 ? "rowspan=\"".concat(rowspan, "\"") : "", " ").concat(colspan > 1 ? "colspan=\"".concat(colspan, "\"") : "", " style='").concat(Object.entries(style)
|
|
309
|
+
.filter(function (_a) {
|
|
310
|
+
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
|
|
311
|
+
return !isNil(v);
|
|
312
|
+
})
|
|
313
|
+
.map(function (_a) {
|
|
314
|
+
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
|
315
|
+
return "".concat(k, ":").concat(v);
|
|
316
|
+
})
|
|
317
|
+
.join(";"), "'>") +
|
|
318
|
+
innerHtml +
|
|
319
|
+
"</td>";
|
|
320
|
+
// json
|
|
120
321
|
jsonRow.push({
|
|
121
|
-
data:
|
|
322
|
+
data: normalizedCellData,
|
|
323
|
+
sourceCell: { rowIndex: rowIndex, columnIndex: columnIndex },
|
|
324
|
+
rowspan: rowspan,
|
|
325
|
+
colspan: colspan,
|
|
122
326
|
});
|
|
123
|
-
continue;
|
|
124
327
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var normalizedCellData = cellData;
|
|
131
|
-
if (cellData && typeof cellData === "object") {
|
|
132
|
-
normalizedCellData = __assign({}, cellData);
|
|
133
|
-
if (!isNil(normalizedCellData.ss)) {
|
|
134
|
-
normalizedCellData.ss = collectSharedString(String(normalizedCellData.ss));
|
|
135
|
-
}
|
|
136
|
-
collectCellXfs(normalizedCellData.uf);
|
|
137
|
-
collectCellXfs(normalizedCellData.ef);
|
|
328
|
+
}
|
|
329
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
330
|
+
finally {
|
|
331
|
+
try {
|
|
332
|
+
if (columns_2_1 && !columns_2_1.done && (_c = columns_2.return)) _c.call(columns_2);
|
|
138
333
|
}
|
|
139
|
-
|
|
140
|
-
var origin_1 = (_c = cellToAddress({ rowIndex: rowIndex, columnIndex: columnIndex })) !== null && _c !== void 0 ? _c : "".concat(rowIndex, ":").concat(columnIndex);
|
|
141
|
-
var formulaAttr = formula
|
|
142
|
-
? " data-sheets-formula=\"".concat(escapeHtmlAttribute(formula), "\" data-formula=\"").concat(escapeHtmlAttribute(formula), "\" data-sheets-formula-origin=\"").concat(escapeHtmlAttribute(origin_1), "\" data-formula-origin=\"").concat(escapeHtmlAttribute(origin_1), "\"")
|
|
143
|
-
: "";
|
|
144
|
-
var effectiveFormat = getEffectiveFormat === null || getEffectiveFormat === void 0 ? void 0 : getEffectiveFormat(sheetId, rowIndex, columnIndex);
|
|
145
|
-
var bandedFormat = bandedCells === null || bandedCells === void 0 ? void 0 : bandedCells.get(cellIdentifier(rowIndex, columnIndex));
|
|
146
|
-
var numberFormatType = (_d = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.numberFormat) === null || _d === void 0 ? void 0 : _d.type;
|
|
147
|
-
var numberFormatPattern = (_e = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.numberFormat) === null || _e === void 0 ? void 0 : _e.pattern;
|
|
148
|
-
var numberFormatAttr = numberFormatType
|
|
149
|
-
? " data-sheets-numberformat-type=\"".concat(escapeHtmlAttribute(numberFormatType), "\"").concat(numberFormatPattern
|
|
150
|
-
? " data-sheets-numberformat-pattern=\"".concat(escapeHtmlAttribute(numberFormatPattern), "\"")
|
|
151
|
-
: "")
|
|
152
|
-
: "";
|
|
153
|
-
// Alignment is encoded as data attributes so paste doesn't have
|
|
154
|
-
// to trust `getComputedStyle().textAlign`, which fabricates a
|
|
155
|
-
// CSS-spec default of `"start"` even when the value was never set.
|
|
156
|
-
var horizontalAlignment = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.horizontalAlignment;
|
|
157
|
-
var verticalAlignment = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.verticalAlignment;
|
|
158
|
-
var alignmentAttr = "".concat(horizontalAlignment
|
|
159
|
-
? " data-sheets-horizontal-alignment=\"".concat(escapeHtmlAttribute(horizontalAlignment), "\"")
|
|
160
|
-
: "").concat(verticalAlignment
|
|
161
|
-
? " data-sheets-vertical-alignment=\"".concat(escapeHtmlAttribute(verticalAlignment), "\"")
|
|
162
|
-
: "");
|
|
163
|
-
// Csv
|
|
164
|
-
csvRow.push(formattedValue);
|
|
165
|
-
// Style
|
|
166
|
-
var isItalic = (_f = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _f === void 0 ? void 0 : _f.italic;
|
|
167
|
-
var isBold = (_g = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _g === void 0 ? void 0 : _g.bold;
|
|
168
|
-
var isUnderline = (_h = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _h === void 0 ? void 0 : _h.underline;
|
|
169
|
-
var isStrikeThrough = (_j = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _j === void 0 ? void 0 : _j.strikethrough;
|
|
170
|
-
var baselineOffset = (_k = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _k === void 0 ? void 0 : _k.baselineOffset;
|
|
171
|
-
// Cell-level formatting wins over the banded (table style) layer,
|
|
172
|
-
// matching the canvas grid's merge order.
|
|
173
|
-
var cellBorders = (_l = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.borders) !== null && _l !== void 0 ? _l : bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.borders;
|
|
174
|
-
var borderTop = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.top;
|
|
175
|
-
var borderBottom = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.bottom;
|
|
176
|
-
var borderLeft = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.left;
|
|
177
|
-
var borderRight = cellBorders === null || cellBorders === void 0 ? void 0 : cellBorders.right;
|
|
178
|
-
var textDecoration = "".concat(isUnderline ? "underline" : "", " ").concat(isStrikeThrough ? "line-through" : "").trim();
|
|
179
|
-
var wordWrap = (effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.wrapStrategy) === "wrap";
|
|
180
|
-
var style = theme
|
|
181
|
-
? {
|
|
182
|
-
"background-color": getStringifiedColor((_m = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.backgroundColor) !== null && _m !== void 0 ? _m : bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.backgroundColor, theme),
|
|
183
|
-
color: getStringifiedColor((_p = (_o = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _o === void 0 ? void 0 : _o.color) !== null && _p !== void 0 ? _p : (_q = bandedFormat === null || bandedFormat === void 0 ? void 0 : bandedFormat.textFormat) === null || _q === void 0 ? void 0 : _q.color, theme),
|
|
184
|
-
padding: "2px 3px 2px 3px",
|
|
185
|
-
overflow: "hidden",
|
|
186
|
-
"font-weight": isBold ? "700" : "normal",
|
|
187
|
-
"font-family": (_r = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _r === void 0 ? void 0 : _r.fontFamily,
|
|
188
|
-
"font-style": isItalic ? "italic" : "normal",
|
|
189
|
-
"text-decoration": textDecoration
|
|
190
|
-
? textDecoration
|
|
191
|
-
: undefined,
|
|
192
|
-
"font-size": "".concat((_t = (_s = effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.textFormat) === null || _s === void 0 ? void 0 : _s.fontSize) !== null && _t !== void 0 ? _t : 10, "pt"),
|
|
193
|
-
"text-align": effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.horizontalAlignment,
|
|
194
|
-
"vertical-align": effectiveFormat === null || effectiveFormat === void 0 ? void 0 : effectiveFormat.verticalAlignment,
|
|
195
|
-
"border-top": borderTop
|
|
196
|
-
? "".concat(borderTop.width, "px solid ").concat(getStringifiedColor(borderTop.color, theme))
|
|
197
|
-
: undefined,
|
|
198
|
-
"border-left": borderLeft
|
|
199
|
-
? "".concat(borderLeft.width, "px solid ").concat(getStringifiedColor(borderLeft.color, theme))
|
|
200
|
-
: undefined,
|
|
201
|
-
"border-right": borderRight
|
|
202
|
-
? "".concat(borderRight.width, "px solid ").concat(getStringifiedColor(borderRight.color, theme))
|
|
203
|
-
: undefined,
|
|
204
|
-
"border-bottom": borderBottom
|
|
205
|
-
? "".concat(borderBottom.width, "px solid ").concat(getStringifiedColor(borderBottom.color, theme))
|
|
206
|
-
: undefined,
|
|
207
|
-
"text-wrap": wordWrap ? "wrap" : undefined,
|
|
208
|
-
}
|
|
209
|
-
: {};
|
|
210
|
-
// html
|
|
211
|
-
var innerHtml = baselineOffset === "superscript"
|
|
212
|
-
? "<sup>".concat(formattedValue, "</sup>")
|
|
213
|
-
: baselineOffset === "subscript"
|
|
214
|
-
? "<sub>".concat(formattedValue, "</sub>")
|
|
215
|
-
: formattedValue;
|
|
216
|
-
htmlString +=
|
|
217
|
-
"<td".concat(formulaAttr).concat(numberFormatAttr).concat(alignmentAttr, " ").concat(rowspan > 1 ? "rowspan=\"".concat(rowspan, "\"") : "", " ").concat(colspan > 1 ? "colspan=\"".concat(colspan, "\"") : "", " style='").concat(Object.entries(style)
|
|
218
|
-
.filter(function (_a) {
|
|
219
|
-
var _b = __read(_a, 2), _ = _b[0], v = _b[1];
|
|
220
|
-
return !isNil(v);
|
|
221
|
-
})
|
|
222
|
-
.map(function (_a) {
|
|
223
|
-
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
|
224
|
-
return "".concat(k, ":").concat(v);
|
|
225
|
-
})
|
|
226
|
-
.join(";"), "'>") +
|
|
227
|
-
innerHtml +
|
|
228
|
-
"</td>";
|
|
229
|
-
// json
|
|
230
|
-
jsonRow.push({
|
|
231
|
-
data: normalizedCellData,
|
|
232
|
-
sourceCell: { rowIndex: rowIndex, columnIndex: columnIndex },
|
|
233
|
-
rowspan: rowspan,
|
|
234
|
-
colspan: colspan,
|
|
235
|
-
});
|
|
334
|
+
finally { if (e_5) throw e_5.error; }
|
|
236
335
|
}
|
|
237
336
|
/* Join with ',' for csv */
|
|
238
337
|
csv.push(csvRow.join(","));
|
|
@@ -243,21 +342,15 @@ export var useOnCopy = function (_a) {
|
|
|
243
342
|
// json
|
|
244
343
|
json.push(jsonRow);
|
|
245
344
|
}
|
|
246
|
-
htmlString += "<tbody></table></body></html>";
|
|
247
|
-
};
|
|
248
|
-
try {
|
|
249
|
-
for (var copiedSelections_1 = __values(copiedSelections), copiedSelections_1_1 = copiedSelections_1.next(); !copiedSelections_1_1.done; copiedSelections_1_1 = copiedSelections_1.next()) {
|
|
250
|
-
var range = copiedSelections_1_1.value.range;
|
|
251
|
-
_loop_1(range);
|
|
252
|
-
}
|
|
253
345
|
}
|
|
254
|
-
catch (
|
|
346
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
255
347
|
finally {
|
|
256
348
|
try {
|
|
257
|
-
if (
|
|
349
|
+
if (rows_1_1 && !rows_1_1.done && (_b = rows_1.return)) _b.call(rows_1);
|
|
258
350
|
}
|
|
259
|
-
finally { if (
|
|
351
|
+
finally { if (e_4) throw e_4.error; }
|
|
260
352
|
}
|
|
353
|
+
htmlString += "<tbody></table></body></html>";
|
|
261
354
|
var csvStr = csv.join("\n");
|
|
262
355
|
var plainTextStr = plainText.join("\n");
|
|
263
356
|
if (copiedSharedStrings.size) {
|
|
@@ -267,11 +360,13 @@ export var useOnCopy = function (_a) {
|
|
|
267
360
|
if (copiedCellXfs.size) {
|
|
268
361
|
copiedSchema.cellXfs = Array.from(copiedCellXfs.entries());
|
|
269
362
|
}
|
|
270
|
-
(
|
|
271
|
-
(
|
|
272
|
-
(
|
|
273
|
-
(
|
|
363
|
+
(_w = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _w === void 0 ? void 0 : _w.setData("text/html", htmlString);
|
|
364
|
+
(_x = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _x === void 0 ? void 0 : _x.setData("text/plain", plainTextStr);
|
|
365
|
+
(_y = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _y === void 0 ? void 0 : _y.setData("text/csv", csvStr);
|
|
366
|
+
(_z = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _z === void 0 ? void 0 : _z.setData("application/json", JSON.stringify(copiedSchema));
|
|
367
|
+
return true;
|
|
274
368
|
}, [
|
|
369
|
+
showError,
|
|
275
370
|
theme,
|
|
276
371
|
sheetTables,
|
|
277
372
|
bandedRanges,
|
|
@@ -290,14 +385,14 @@ export var useOnCopy = function (_a) {
|
|
|
290
385
|
// Merge cell map
|
|
291
386
|
export var useMergedCellMap = function (merges) {
|
|
292
387
|
return useMemo(function () {
|
|
293
|
-
var
|
|
388
|
+
var e_6, _a;
|
|
294
389
|
var mergedCellMap = new Map();
|
|
295
390
|
var finalMerges = merges !== null && merges !== void 0 ? merges : [];
|
|
296
391
|
for (var i = 0; i < finalMerges.length; i++) {
|
|
297
392
|
var range = finalMerges[i];
|
|
298
393
|
var startRowIndex = range.startRowIndex, startColumnIndex = range.startColumnIndex, endColumnIndex = range.endColumnIndex, endRowIndex = range.endRowIndex;
|
|
299
394
|
try {
|
|
300
|
-
for (var _b = (
|
|
395
|
+
for (var _b = (e_6 = void 0, __values(iterateCellsInRange(range))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
301
396
|
var _d = __read(_c.value, 2), rowIndex = _d[0], columnIndex = _d[1];
|
|
302
397
|
var isMasterCell = rowIndex === startRowIndex && columnIndex === startColumnIndex;
|
|
303
398
|
var spans = isMasterCell
|
|
@@ -312,12 +407,12 @@ export var useMergedCellMap = function (merges) {
|
|
|
312
407
|
]);
|
|
313
408
|
}
|
|
314
409
|
}
|
|
315
|
-
catch (
|
|
410
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
316
411
|
finally {
|
|
317
412
|
try {
|
|
318
413
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
319
414
|
}
|
|
320
|
-
finally { if (
|
|
415
|
+
finally { if (e_6) throw e_6.error; }
|
|
321
416
|
}
|
|
322
417
|
}
|
|
323
418
|
return mergedCellMap;
|
|
@@ -2,7 +2,7 @@ import { __assign, __read } from "tslib";
|
|
|
2
2
|
import { produceWithPatches } from "immer";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
import { updateFormulaSheetReferences } from "../api/rename-sheet";
|
|
5
|
-
import { truncateSheetTitle } from "../helpers/sheet-title";
|
|
5
|
+
import { isValidSheetTitle, truncateSheetTitle } from "../helpers/sheet-title";
|
|
6
6
|
import { useCanEditSheet, useCanEditWorkbook } from "./use-can-edit-cellrange";
|
|
7
7
|
export var useOnRenameSheet = function (_a) {
|
|
8
8
|
var locale = _a.locale, onChangeSheetData = _a.onChangeSheetData, onChangeSheets = _a.onChangeSheets, onChangeActiveCell = _a.onChangeActiveCell, getActiveCell = _a.getActiveCell, getGraphNodes = _a.getGraphNodes, getPrecedents = _a.getPrecedents, createHistory = _a.createHistory, onCommand = _a.onCommand;
|
|
@@ -10,7 +10,7 @@ export var useOnRenameSheet = function (_a) {
|
|
|
10
10
|
var canEditWorkbook = useCanEditWorkbook();
|
|
11
11
|
return useCallback(function (sheetId, name, oldName) {
|
|
12
12
|
// Worksheet names cannot be empty or whitespace-only
|
|
13
|
-
if (name
|
|
13
|
+
if (!isValidSheetTitle(name)) {
|
|
14
14
|
console.debug("Sheet name cannot be empty.");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -525,7 +525,7 @@ export declare const useSpreadsheetState: <T extends CellData = CellData, S exte
|
|
|
525
525
|
onInsertTableRow: (tableView: TableView, relativeRowIndex?: number, rowData?: Record<string, string | undefined | null>[]) => void;
|
|
526
526
|
onDeleteTableColumn: (tableView: TableView, dimensionIndex: number) => void;
|
|
527
527
|
onDeleteTableRow: (tableView: TableView, rowIndexes: number[]) => void;
|
|
528
|
-
onCopy: (e: ClipboardEvent | undefined, sheetId: number, copiedSelections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[]) =>
|
|
528
|
+
onCopy: (e: ClipboardEvent | undefined, sheetId: number, copiedSelections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[], isCutOperation?: boolean) => boolean;
|
|
529
529
|
onPaste: (e: ClipboardEvent | undefined, sourceSheetId: number | undefined, destinationSheetId: number, copiedSelections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[] | undefined, activeCell: import("@rowsncolumns/grid").CellInterface, selections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[] | undefined, finalSelections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[] | undefined, isCutOperation: boolean) => Promise<void>;
|
|
530
530
|
onCreateBasicFilter: (sheetId: number, activeCell: import("@rowsncolumns/grid").CellInterface, selections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[], basicFilterSpec?: Partial<import("@rowsncolumns/spreadsheet").FilterView>) => void;
|
|
531
531
|
onCreateTable: (sheetId: number, activeCell: import("@rowsncolumns/grid").CellInterface, selections: import("@rowsncolumns/grid").SelectionArea<SelectionAttributes>[], tableSpec?: Partial<TableView>, theme?: import("@rowsncolumns/spreadsheet").TableTheme, bandedRange?: BandedDefinition) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-column.d.ts","sourceRoot":"","sources":["../../../interface/delete-column.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AASjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,qbAyB/D,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,MACrB,SAAS,MAAM,EAAE,eAAe,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"delete-column.d.ts","sourceRoot":"","sources":["../../../interface/delete-column.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AASjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,qbAyB/D,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,MACrB,SAAS,MAAM,EAAE,eAAe,MAAM,EAAE,SAuUjD,CAAC"}
|