@fileverse-dev/fortune-core 1.3.5 → 1.3.6-right-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/api/sheet.js +41 -6
- package/es/canvas.js +7 -7
- package/es/events/keyboard.js +3 -3
- package/es/events/mouse.js +1 -1
- package/es/events/paste.js +34 -18
- package/es/modules/cell.js +10 -6
- package/es/modules/cursor.d.ts +1 -0
- package/es/modules/cursor.js +35 -0
- package/es/modules/format.js +29 -38
- package/es/modules/hyperlink.d.ts +2 -2
- package/es/modules/hyperlink.js +6 -2
- package/es/modules/selection.js +215 -7
- package/es/modules/ssf.js +1 -1
- package/es/modules/toolbar.js +34 -13
- package/es/modules/validation.d.ts +10 -0
- package/es/modules/validation.js +283 -20
- package/es/paste-table-helpers.js +11 -11
- package/lib/api/sheet.js +41 -6
- package/lib/canvas.js +7 -7
- package/lib/events/keyboard.js +3 -3
- package/lib/events/mouse.js +1 -1
- package/lib/events/paste.js +32 -16
- package/lib/modules/cell.js +10 -6
- package/lib/modules/cursor.d.ts +1 -0
- package/lib/modules/cursor.js +36 -0
- package/lib/modules/format.js +28 -37
- package/lib/modules/hyperlink.d.ts +2 -2
- package/lib/modules/hyperlink.js +6 -2
- package/lib/modules/selection.js +215 -7
- package/lib/modules/ssf.js +1 -1
- package/lib/modules/toolbar.js +33 -12
- package/lib/modules/validation.d.ts +10 -0
- package/lib/modules/validation.js +284 -20
- package/lib/paste-table-helpers.js +11 -11
- package/package.json +1 -1
package/es/modules/validation.js
CHANGED
|
@@ -39,33 +39,296 @@ export function isRealNum(val) {
|
|
|
39
39
|
}
|
|
40
40
|
return !Number.isNaN(Number(val));
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
var MONTH_NAME_MAP = {
|
|
43
|
+
january: 1,
|
|
44
|
+
february: 2,
|
|
45
|
+
march: 3,
|
|
46
|
+
april: 4,
|
|
47
|
+
may: 5,
|
|
48
|
+
june: 6,
|
|
49
|
+
july: 7,
|
|
50
|
+
august: 8,
|
|
51
|
+
september: 9,
|
|
52
|
+
october: 10,
|
|
53
|
+
november: 11,
|
|
54
|
+
december: 12,
|
|
55
|
+
jan: 1,
|
|
56
|
+
feb: 2,
|
|
57
|
+
mar: 3,
|
|
58
|
+
apr: 4,
|
|
59
|
+
jun: 6,
|
|
60
|
+
jul: 7,
|
|
61
|
+
aug: 8,
|
|
62
|
+
sep: 9,
|
|
63
|
+
oct: 10,
|
|
64
|
+
nov: 11,
|
|
65
|
+
dec: 12
|
|
66
|
+
};
|
|
67
|
+
var MONTH_NAMES_RE = "january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec";
|
|
68
|
+
var MONTH_ABBR_RE = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec";
|
|
69
|
+
function isValidDateParts(year, month, day) {
|
|
70
|
+
if (year < 1900) return false;
|
|
71
|
+
if (month < 1 || month > 12) return false;
|
|
72
|
+
if (day < 1 || day > 31) return false;
|
|
73
|
+
if (month === 2) {
|
|
74
|
+
var isLeap = new Date(year, 1, 29).getDate() === 29;
|
|
75
|
+
if (isLeap && day > 29) return false;
|
|
76
|
+
if (!isLeap && day > 28) return false;
|
|
47
77
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
78
|
+
if ([4, 6, 9, 11].includes(month) && day > 30) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
export function detectDateFormat(str) {
|
|
82
|
+
if (!str || str.toString().length < 5) return null;
|
|
83
|
+
var s = str.toString().trim();
|
|
84
|
+
var m;
|
|
85
|
+
m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(s);
|
|
86
|
+
if (m) {
|
|
87
|
+
var y = +m[1];
|
|
88
|
+
var mo = +m[2];
|
|
89
|
+
var d = +m[3];
|
|
90
|
+
var h = +m[4];
|
|
91
|
+
var mi = +m[5];
|
|
92
|
+
var sec = m[6] != null ? +m[6] : 0;
|
|
93
|
+
if (isValidDateParts(y, mo, d)) {
|
|
94
|
+
return {
|
|
95
|
+
year: y,
|
|
96
|
+
month: mo,
|
|
97
|
+
day: d,
|
|
98
|
+
hours: h,
|
|
99
|
+
minutes: mi,
|
|
100
|
+
seconds: sec,
|
|
101
|
+
formatType: "yyyy-MM-ddTHH:mm"
|
|
102
|
+
};
|
|
103
|
+
}
|
|
53
104
|
}
|
|
54
|
-
|
|
55
|
-
|
|
105
|
+
m = /^(\d{4})-(\d{1,2})-(\d{1,2})(?:\s(\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(s);
|
|
106
|
+
if (m) {
|
|
107
|
+
var y = +m[1];
|
|
108
|
+
var mo = +m[2];
|
|
109
|
+
var d = +m[3];
|
|
110
|
+
if (isValidDateParts(y, mo, d)) {
|
|
111
|
+
var h = m[4] != null ? +m[4] : 0;
|
|
112
|
+
var mi = m[5] != null ? +m[5] : 0;
|
|
113
|
+
var sec = m[6] != null ? +m[6] : 0;
|
|
114
|
+
return {
|
|
115
|
+
year: y,
|
|
116
|
+
month: mo,
|
|
117
|
+
day: d,
|
|
118
|
+
hours: h,
|
|
119
|
+
minutes: mi,
|
|
120
|
+
seconds: sec,
|
|
121
|
+
formatType: m[4] != null ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
56
124
|
}
|
|
57
|
-
|
|
58
|
-
|
|
125
|
+
m = /^(\d{4})\/(\d{1,2})\/(\d{1,2})(?:\s(\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(s);
|
|
126
|
+
if (m) {
|
|
127
|
+
var y = +m[1];
|
|
128
|
+
var mo = +m[2];
|
|
129
|
+
var d = +m[3];
|
|
130
|
+
if (isValidDateParts(y, mo, d)) {
|
|
131
|
+
var h = m[4] != null ? +m[4] : 0;
|
|
132
|
+
var mi = m[5] != null ? +m[5] : 0;
|
|
133
|
+
var sec = m[6] != null ? +m[6] : 0;
|
|
134
|
+
return {
|
|
135
|
+
year: y,
|
|
136
|
+
month: mo,
|
|
137
|
+
day: d,
|
|
138
|
+
hours: h,
|
|
139
|
+
minutes: mi,
|
|
140
|
+
seconds: sec,
|
|
141
|
+
formatType: m[4] != null ? "yyyy/MM/dd HH:mm" : "yyyy/MM/dd"
|
|
142
|
+
};
|
|
143
|
+
}
|
|
59
144
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
145
|
+
m = /^(\d{4})\.(\d{1,2})\.(\d{1,2})$/.exec(s);
|
|
146
|
+
if (m) {
|
|
147
|
+
var y = +m[1];
|
|
148
|
+
var mo = +m[2];
|
|
149
|
+
var d = +m[3];
|
|
150
|
+
if (isValidDateParts(y, mo, d)) {
|
|
151
|
+
return {
|
|
152
|
+
year: y,
|
|
153
|
+
month: mo,
|
|
154
|
+
day: d,
|
|
155
|
+
hours: 0,
|
|
156
|
+
minutes: 0,
|
|
157
|
+
seconds: 0,
|
|
158
|
+
formatType: "yyyy.MM.dd"
|
|
159
|
+
};
|
|
63
160
|
}
|
|
64
|
-
|
|
65
|
-
|
|
161
|
+
}
|
|
162
|
+
m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})\s(\d{1,2}):(\d{2})\s?(AM|PM)$/i.exec(s);
|
|
163
|
+
if (m) {
|
|
164
|
+
var p1 = +m[1];
|
|
165
|
+
var p2 = +m[2];
|
|
166
|
+
var y = +m[3];
|
|
167
|
+
var h = +m[4];
|
|
168
|
+
var mi = +m[5];
|
|
169
|
+
var ampm = m[6].toUpperCase();
|
|
170
|
+
if (p1 <= 12 && isValidDateParts(y, p1, p2)) {
|
|
171
|
+
var actualH = h;
|
|
172
|
+
if (ampm === "PM" && h !== 12) actualH = h + 12;
|
|
173
|
+
if (ampm === "AM" && h === 12) actualH = 0;
|
|
174
|
+
return {
|
|
175
|
+
year: y,
|
|
176
|
+
month: p1,
|
|
177
|
+
day: p2,
|
|
178
|
+
hours: actualH,
|
|
179
|
+
minutes: mi,
|
|
180
|
+
seconds: 0,
|
|
181
|
+
formatType: "MM/dd/yyyy h:mm AM/PM"
|
|
182
|
+
};
|
|
66
183
|
}
|
|
67
184
|
}
|
|
68
|
-
|
|
185
|
+
m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(s);
|
|
186
|
+
if (m) {
|
|
187
|
+
var p1 = +m[1];
|
|
188
|
+
var p2 = +m[2];
|
|
189
|
+
var y = +m[3];
|
|
190
|
+
if (p1 > 12 && isValidDateParts(y, p2, p1)) {
|
|
191
|
+
return {
|
|
192
|
+
year: y,
|
|
193
|
+
month: p2,
|
|
194
|
+
day: p1,
|
|
195
|
+
hours: 0,
|
|
196
|
+
minutes: 0,
|
|
197
|
+
seconds: 0,
|
|
198
|
+
formatType: "dd/MM/yyyy"
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (p2 > 12 && p1 <= 12 && isValidDateParts(y, p1, p2)) {
|
|
202
|
+
var formatType = m[1].length === 1 ? "M/d/yyyy" : "MM/dd/yyyy";
|
|
203
|
+
return {
|
|
204
|
+
year: y,
|
|
205
|
+
month: p1,
|
|
206
|
+
day: p2,
|
|
207
|
+
hours: 0,
|
|
208
|
+
minutes: 0,
|
|
209
|
+
seconds: 0,
|
|
210
|
+
formatType: formatType
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (p1 <= 12 && p2 <= 31 && isValidDateParts(y, p1, p2)) {
|
|
214
|
+
var formatType = m[1].length === 1 ? "M/d/yyyy" : "MM/dd/yyyy";
|
|
215
|
+
return {
|
|
216
|
+
year: y,
|
|
217
|
+
month: p1,
|
|
218
|
+
day: p2,
|
|
219
|
+
hours: 0,
|
|
220
|
+
minutes: 0,
|
|
221
|
+
seconds: 0,
|
|
222
|
+
formatType: formatType
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
m = /^(\d{2})\/(\d{2})\/(\d{2})$/.exec(s);
|
|
227
|
+
if (m) {
|
|
228
|
+
var p1 = +m[1];
|
|
229
|
+
var p2 = +m[2];
|
|
230
|
+
var y = 2000 + +m[3];
|
|
231
|
+
if (p1 <= 12 && p2 <= 31 && isValidDateParts(y, p1, p2)) {
|
|
232
|
+
return {
|
|
233
|
+
year: y,
|
|
234
|
+
month: p1,
|
|
235
|
+
day: p2,
|
|
236
|
+
hours: 0,
|
|
237
|
+
minutes: 0,
|
|
238
|
+
seconds: 0,
|
|
239
|
+
formatType: "MM/dd/yy"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
m = /^(\d{1,2})-(\d{1,2})-(\d{4})$/.exec(s);
|
|
244
|
+
if (m) {
|
|
245
|
+
var p1 = +m[1];
|
|
246
|
+
var p2 = +m[2];
|
|
247
|
+
var y = +m[3];
|
|
248
|
+
if (p1 > 12 && isValidDateParts(y, p2, p1)) {
|
|
249
|
+
return {
|
|
250
|
+
year: y,
|
|
251
|
+
month: p2,
|
|
252
|
+
day: p1,
|
|
253
|
+
hours: 0,
|
|
254
|
+
minutes: 0,
|
|
255
|
+
seconds: 0,
|
|
256
|
+
formatType: "dd-MM-yyyy"
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
m = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/.exec(s);
|
|
261
|
+
if (m) {
|
|
262
|
+
var p1 = +m[1];
|
|
263
|
+
var p2 = +m[2];
|
|
264
|
+
var y = +m[3];
|
|
265
|
+
if (p1 > 12 && isValidDateParts(y, p2, p1)) {
|
|
266
|
+
return {
|
|
267
|
+
year: y,
|
|
268
|
+
month: p2,
|
|
269
|
+
day: p1,
|
|
270
|
+
hours: 0,
|
|
271
|
+
minutes: 0,
|
|
272
|
+
seconds: 0,
|
|
273
|
+
formatType: "dd.MM.yyyy"
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
m = new RegExp("^(".concat(MONTH_NAMES_RE, ")\\s+(\\d{1,2}),?\\s+(\\d{4})$"), "i").exec(s);
|
|
278
|
+
if (m) {
|
|
279
|
+
var mo = MONTH_NAME_MAP[m[1].toLowerCase()];
|
|
280
|
+
var d = +m[2];
|
|
281
|
+
var y = +m[3];
|
|
282
|
+
if (mo && isValidDateParts(y, mo, d)) {
|
|
283
|
+
return {
|
|
284
|
+
year: y,
|
|
285
|
+
month: mo,
|
|
286
|
+
day: d,
|
|
287
|
+
hours: 0,
|
|
288
|
+
minutes: 0,
|
|
289
|
+
seconds: 0,
|
|
290
|
+
formatType: "named"
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
m = new RegExp("^(\\d{1,2})\\s+(".concat(MONTH_NAMES_RE, ")\\s+(\\d{4})$"), "i").exec(s);
|
|
295
|
+
if (m) {
|
|
296
|
+
var d = +m[1];
|
|
297
|
+
var mo = MONTH_NAME_MAP[m[2].toLowerCase()];
|
|
298
|
+
var y = +m[3];
|
|
299
|
+
if (mo && isValidDateParts(y, mo, d)) {
|
|
300
|
+
return {
|
|
301
|
+
year: y,
|
|
302
|
+
month: mo,
|
|
303
|
+
day: d,
|
|
304
|
+
hours: 0,
|
|
305
|
+
minutes: 0,
|
|
306
|
+
seconds: 0,
|
|
307
|
+
formatType: "named"
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
m = new RegExp("^(".concat(MONTH_ABBR_RE, ")-(\\d{1,2})-(\\d{4})$"), "i").exec(s);
|
|
312
|
+
if (m) {
|
|
313
|
+
var mo = MONTH_NAME_MAP[m[1].toLowerCase()];
|
|
314
|
+
var d = +m[2];
|
|
315
|
+
var y = +m[3];
|
|
316
|
+
if (mo && isValidDateParts(y, mo, d)) {
|
|
317
|
+
return {
|
|
318
|
+
year: y,
|
|
319
|
+
month: mo,
|
|
320
|
+
day: d,
|
|
321
|
+
hours: 0,
|
|
322
|
+
minutes: 0,
|
|
323
|
+
seconds: 0,
|
|
324
|
+
formatType: "named"
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
function checkDateTime(str) {
|
|
331
|
+
return detectDateFormat(str) !== null;
|
|
69
332
|
}
|
|
70
333
|
export function isdatetime(s) {
|
|
71
334
|
if (s === null || s.toString().length < 5) {
|
|
@@ -12,7 +12,6 @@ var __assign = this && this.__assign || function () {
|
|
|
12
12
|
import _ from "lodash";
|
|
13
13
|
import { locale } from "./locale";
|
|
14
14
|
import { getQKBorder, saveHyperlink } from "./modules";
|
|
15
|
-
import { genarate } from "./modules/format";
|
|
16
15
|
import { getSheetIndex } from "./utils";
|
|
17
16
|
import { setRowHeight, setColumnWidth } from "./api";
|
|
18
17
|
export var DEFAULT_FONT_SIZE = 12;
|
|
@@ -127,8 +126,7 @@ function brToNewline(str) {
|
|
|
127
126
|
return str.replace(/<br\s*\/?>/gi, "\n");
|
|
128
127
|
}
|
|
129
128
|
var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
130
|
-
var _a;
|
|
131
|
-
var _b, _c, _d, _e;
|
|
129
|
+
var _a, _b, _c, _d;
|
|
132
130
|
var cell = {};
|
|
133
131
|
var rawText = (td.innerText || td.innerHTML || "").trim();
|
|
134
132
|
var isLineBreak = rawText.includes("<br />");
|
|
@@ -146,22 +144,24 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
146
144
|
})
|
|
147
145
|
});
|
|
148
146
|
} else {
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
cell.v = rawText;
|
|
148
|
+
cell.m = rawText;
|
|
149
|
+
cell.ct = {
|
|
150
|
+
fa: "General",
|
|
151
|
+
t: "g"
|
|
152
|
+
};
|
|
151
153
|
if (HEX_REGEX.test(rawText)) {
|
|
152
154
|
cell.ct = {
|
|
153
155
|
fa: "@",
|
|
154
156
|
t: "s"
|
|
155
157
|
};
|
|
156
|
-
cell.m = rawText;
|
|
157
|
-
cell.v = rawText;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
if (((
|
|
160
|
+
if (((_a = td.style) === null || _a === void 0 ? void 0 : _a.alignItems) === "center") {
|
|
161
161
|
cell.vt = 0;
|
|
162
|
-
} else if (((
|
|
162
|
+
} else if (((_b = td.style) === null || _b === void 0 ? void 0 : _b.alignItems) === "flex-end") {
|
|
163
163
|
cell.vt = 2;
|
|
164
|
-
} else if (((
|
|
164
|
+
} else if (((_c = td.style) === null || _c === void 0 ? void 0 : _c.alignItems) === "flex-start") {
|
|
165
165
|
cell.vt = 1;
|
|
166
166
|
}
|
|
167
167
|
var styleBlock = typeof classStyles[".".concat(td.className)] === "string" ? classStyles[".".concat(td.className)] : "";
|
|
@@ -188,7 +188,7 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
188
188
|
} else {
|
|
189
189
|
cell.ht = 1;
|
|
190
190
|
}
|
|
191
|
-
if (((
|
|
191
|
+
if (((_d = td === null || td === void 0 ? void 0 : td.style) === null || _d === void 0 ? void 0 : _d["overflow-wrap"]) === "anywhere") {
|
|
192
192
|
cell.tb = "2";
|
|
193
193
|
} else {
|
|
194
194
|
cell.tb = "2";
|
package/lib/api/sheet.js
CHANGED
|
@@ -22,6 +22,17 @@ var _common = require("./common");
|
|
|
22
22
|
var _utils = require("../utils");
|
|
23
23
|
var _2 = require("..");
|
|
24
24
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
26
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
27
|
+
__assign = Object.assign || function (t) {
|
|
28
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29
|
+
s = arguments[i];
|
|
30
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
34
|
+
return __assign.apply(this, arguments);
|
|
35
|
+
};
|
|
25
36
|
function isCellReferenced(formulaString, cell) {
|
|
26
37
|
function colToNumber(col) {
|
|
27
38
|
var num = 0;
|
|
@@ -153,6 +164,7 @@ function generateCopySheetName(ctx, sheetId) {
|
|
|
153
164
|
return sheetCopyName;
|
|
154
165
|
}
|
|
155
166
|
function copySheet(ctx, sheetId) {
|
|
167
|
+
var _a, _b, _c;
|
|
156
168
|
var index = (0, _utils.getSheetIndex)(ctx, sheetId);
|
|
157
169
|
var order = ctx.luckysheetfile[index].order + 1;
|
|
158
170
|
var sheetName = generateCopySheetName(ctx, sheetId);
|
|
@@ -162,8 +174,32 @@ function copySheet(ctx, sheetId) {
|
|
|
162
174
|
sheetData.celldata = (0, _common.dataToCelldata)(sheetData.data);
|
|
163
175
|
delete sheetData.data;
|
|
164
176
|
_2.api.addSheet(ctx, undefined, (0, _uuid.v4)(), ctx.luckysheetfile[index].isPivotTable, sheetName, sheetData);
|
|
177
|
+
var newSheetIndex = ctx.luckysheetfile.length - 1;
|
|
178
|
+
var newSheet = ctx.luckysheetfile[newSheetIndex];
|
|
179
|
+
var newSheetId = newSheet.id;
|
|
180
|
+
if ((_a = newSheet.calcChain) === null || _a === void 0 ? void 0 : _a.length) {
|
|
181
|
+
newSheet.calcChain = newSheet.calcChain.map(function (entry) {
|
|
182
|
+
return __assign(__assign({}, entry), {
|
|
183
|
+
id: newSheetId
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if ((_b = newSheet.dynamicArray) === null || _b === void 0 ? void 0 : _b.length) {
|
|
188
|
+
newSheet.dynamicArray = newSheet.dynamicArray.map(function (entry) {
|
|
189
|
+
return entry && _typeof(entry) === "object" && "id" in entry ? __assign(__assign({}, entry), {
|
|
190
|
+
id: newSheetId
|
|
191
|
+
}) : entry;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if ((_c = newSheet.dynamicArray_compute) === null || _c === void 0 ? void 0 : _c.length) {
|
|
195
|
+
newSheet.dynamicArray_compute = newSheet.dynamicArray_compute.map(function (entry) {
|
|
196
|
+
return entry && _typeof(entry) === "object" && "id" in entry ? __assign(__assign({}, entry), {
|
|
197
|
+
id: newSheetId
|
|
198
|
+
}) : entry;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
165
201
|
var sheetOrderList = {};
|
|
166
|
-
sheetOrderList[
|
|
202
|
+
sheetOrderList[newSheetId] = order;
|
|
167
203
|
_2.api.setSheetOrder(ctx, sheetOrderList);
|
|
168
204
|
}
|
|
169
205
|
function calculateSheetFromula(ctx, id) {
|
|
@@ -191,23 +227,22 @@ function calculateSheetFromula(ctx, id) {
|
|
|
191
227
|
}
|
|
192
228
|
}
|
|
193
229
|
function calculateReferencedCellSheetFromula(ctx, id, refCell) {
|
|
194
|
-
var _a, _b, _c, _d, _e
|
|
230
|
+
var _a, _b, _c, _d, _e;
|
|
195
231
|
var index = (0, _utils.getSheetIndex)(ctx, id);
|
|
196
232
|
if (!ctx.luckysheetfile[index].data) return;
|
|
197
233
|
var _loop_1 = function _loop_1(r) {
|
|
198
234
|
var _loop_2 = function _loop_2(c) {
|
|
199
|
-
console.log(refCell, (_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f);
|
|
200
235
|
var isRef = false;
|
|
201
|
-
if (refCell && ((
|
|
236
|
+
if (refCell && ((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) && !((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
|
|
202
237
|
isRef = refCell.some(function (cell) {
|
|
203
238
|
var _a;
|
|
204
239
|
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
205
240
|
});
|
|
206
241
|
}
|
|
207
|
-
if (!isRef || !((
|
|
242
|
+
if (!isRef || !((_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f) || ((_d = ctx.luckysheetfile[index].data[r][c]) === null || _d === void 0 ? void 0 : _d.isDataBlockFormula)) {
|
|
208
243
|
return "continue";
|
|
209
244
|
}
|
|
210
|
-
var result = (0, _2.execfunction)(ctx, (
|
|
245
|
+
var result = (0, _2.execfunction)(ctx, (_e = ctx.luckysheetfile[index].data[r][c]) === null || _e === void 0 ? void 0 : _e.f, r, c, id);
|
|
211
246
|
var isValueArray = Array.isArray(result[1]);
|
|
212
247
|
if (isValueArray) {
|
|
213
248
|
var value = {
|
package/lib/canvas.js
CHANGED
|
@@ -862,7 +862,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
862
862
|
}, renderCtx);
|
|
863
863
|
};
|
|
864
864
|
Canvas.prototype.cellRender = function (r, c, startY, startX, endY, endX, value, renderCtx, afCompute, cfCompute, offsetLeft, offsetTop, dynamicArrayCompute, cellOverflowMap, colStart, colEnd, scrollHeight, scrollWidth, bodrder05, isMerge) {
|
|
865
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
865
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
866
866
|
if (isMerge === void 0) {
|
|
867
867
|
isMerge = false;
|
|
868
868
|
}
|
|
@@ -952,7 +952,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
952
952
|
renderCtx.fill();
|
|
953
953
|
}
|
|
954
954
|
var text = optionValue_1[i];
|
|
955
|
-
var fontSize = (cell === null || cell === void 0 ? void 0 : cell.fs) * this_1.sheetCtx.zoomRatio;
|
|
955
|
+
var fontSize = ((_f = cell === null || cell === void 0 ? void 0 : cell.fs) !== null && _f !== void 0 ? _f : 13) * this_1.sheetCtx.zoomRatio;
|
|
956
956
|
renderCtx.font = "".concat(fontSize, "px sans-serif");
|
|
957
957
|
renderCtx.fillStyle = "rgba(0, 0, 0, 0.8)";
|
|
958
958
|
renderCtx.textBaseline = "middle";
|
|
@@ -1010,7 +1010,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1010
1010
|
} else {
|
|
1011
1011
|
cellOverflow_bd_r_render = false;
|
|
1012
1012
|
}
|
|
1013
|
-
} else if (((
|
|
1013
|
+
} else if (((_g = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _g === void 0 ? void 0 : _g.type) === "checkbox") {
|
|
1014
1014
|
var pos_x = startX + offsetLeft;
|
|
1015
1015
|
var pos_y = startY + offsetTop + 1;
|
|
1016
1016
|
renderCtx.save();
|
|
@@ -1019,7 +1019,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1019
1019
|
renderCtx.clip();
|
|
1020
1020
|
renderCtx.scale(this.sheetCtx.zoomRatio, this.sheetCtx.zoomRatio);
|
|
1021
1021
|
var measureText = (0, _text.getMeasureText)(value, renderCtx, this.sheetCtx);
|
|
1022
|
-
var textMetrics = measureText.width +
|
|
1022
|
+
var textMetrics = measureText.width + 18;
|
|
1023
1023
|
var oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
|
|
1024
1024
|
var horizonAlignPos = pos_x + space_width;
|
|
1025
1025
|
if (horizonAlign === 0) {
|
|
@@ -1071,7 +1071,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1071
1071
|
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos + 18, verticalAlignPos_text);
|
|
1072
1072
|
renderCtx.restore();
|
|
1073
1073
|
} else {
|
|
1074
|
-
if (((
|
|
1074
|
+
if (((_h = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _h === void 0 ? void 0 : _h.valueLen) && ((_k = (_j = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _j === void 0 ? void 0 : _j.valueLen) === null || _k === void 0 ? void 0 : _k.toString()) !== "NaN") {
|
|
1075
1075
|
var x = startX + offsetLeft + space_width;
|
|
1076
1076
|
var y = startY + offsetTop + space_height;
|
|
1077
1077
|
var w = cellWidth - space_width * 2;
|
|
@@ -1203,7 +1203,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1203
1203
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
|
|
1204
1204
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1205
1205
|
}
|
|
1206
|
-
if (((
|
|
1206
|
+
if (((_o = (_m = (_l = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _l === void 0 ? void 0 : _l.fa) === null || _m === void 0 ? void 0 : _m.indexOf("[Red]")) !== null && _o !== void 0 ? _o : -1) > -1 && ((_p = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _p === void 0 ? void 0 : _p.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
|
|
1207
1207
|
renderCtx.fillStyle = "#ff0000";
|
|
1208
1208
|
}
|
|
1209
1209
|
var sheetId = this.sheetCtx.currentSheetId;
|
|
@@ -1246,7 +1246,7 @@ var Canvas = exports.Canvas = function () {
|
|
|
1246
1246
|
renderCtx.stroke();
|
|
1247
1247
|
renderCtx.closePath();
|
|
1248
1248
|
}
|
|
1249
|
-
(
|
|
1249
|
+
(_r = (_q = this.sheetCtx.hooks).afterRenderCell) === null || _r === void 0 ? void 0 : _r.call(_q, (_s = flowdata[r]) === null || _s === void 0 ? void 0 : _s[c], {
|
|
1250
1250
|
row: r,
|
|
1251
1251
|
column: c,
|
|
1252
1252
|
startX: cellsize[0],
|
package/lib/events/keyboard.js
CHANGED
|
@@ -149,7 +149,7 @@ function handleGlobalEnter(ctx, cellInput, e, canvas) {
|
|
|
149
149
|
row_focus: lastCellUpdate[0],
|
|
150
150
|
column_focus: lastCellUpdate[1]
|
|
151
151
|
}];
|
|
152
|
-
(0, _selection.moveHighlightCell)(ctx, "down",
|
|
152
|
+
(0, _selection.moveHighlightCell)(ctx, "down", (0, _2.hideCRCount)(ctx, "ArrowDown"), "rangeOfSelect");
|
|
153
153
|
e.preventDefault();
|
|
154
154
|
} else {
|
|
155
155
|
if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0) {
|
|
@@ -444,9 +444,9 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
444
444
|
(0, _cell.updateCell)(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
445
445
|
}
|
|
446
446
|
if (e.shiftKey) {
|
|
447
|
-
(0, _selection.moveHighlightCell)(ctx, "right", -
|
|
447
|
+
(0, _selection.moveHighlightCell)(ctx, "right", -(0, _2.hideCRCount)(ctx, "ArrowLeft"), "rangeOfSelect");
|
|
448
448
|
} else {
|
|
449
|
-
(0, _selection.moveHighlightCell)(ctx, "right",
|
|
449
|
+
(0, _selection.moveHighlightCell)(ctx, "right", (0, _2.hideCRCount)(ctx, "ArrowRight"), "rangeOfSelect");
|
|
450
450
|
}
|
|
451
451
|
e.preventDefault();
|
|
452
452
|
} else if (kstr === "F2") {
|
package/lib/events/mouse.js
CHANGED
|
@@ -166,7 +166,7 @@ function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, container, fxIn
|
|
|
166
166
|
_a = margeset.row, row_pre = _a[0], row = _a[1], row_index = _a[2], row_index_ed = _a[3];
|
|
167
167
|
_b = margeset.column, col_pre = _b[0], col = _b[1], col_index = _b[2], col_index_ed = _b[3];
|
|
168
168
|
}
|
|
169
|
-
(0, _hyperlink.showLinkCard)(ctx, row_index, col_index, false, true);
|
|
169
|
+
(0, _hyperlink.showLinkCard)(ctx, row_index, col_index, undefined, false, true);
|
|
170
170
|
if (((_e = (_d = ctx.hooks).beforeCellMouseDown) === null || _e === void 0 ? void 0 : _e.call(_d, (_f = flowdata[row_index]) === null || _f === void 0 ? void 0 : _f[col_index], {
|
|
171
171
|
row: row_index,
|
|
172
172
|
column: col_index,
|
package/lib/events/paste.js
CHANGED
|
@@ -91,11 +91,9 @@ function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
|
91
91
|
var rowOffset = destRow - srcRow;
|
|
92
92
|
var hadInvalid = false;
|
|
93
93
|
var cellRefRegex = /\b(\$?)([A-Z]+)(\$?)(\d+)\b/g;
|
|
94
|
-
var stringOrCellRef = /"(?:\\.|[^"])*"|(
|
|
94
|
+
var stringOrCellRef = /"(?:\\.|[^"])*"|(\$?[A-Z]+\$?\d+)(?!\s*!)\b/g;
|
|
95
95
|
var result = formula.replace(stringOrCellRef, function (m, cellRef) {
|
|
96
96
|
if (!cellRef) return m;
|
|
97
|
-
if (cellRef.startsWith("$")) return m;
|
|
98
|
-
console.log(m, "cellRef", cellRef);
|
|
99
97
|
return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
|
|
100
98
|
var colIndex = columnLabelIndex(colLetters);
|
|
101
99
|
var rowIndex = parseInt(rowNum, 10);
|
|
@@ -222,14 +220,13 @@ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
|
222
220
|
}
|
|
223
221
|
};
|
|
224
222
|
function pasteHandler(ctx, data, borderInfo) {
|
|
225
|
-
var _a;
|
|
226
|
-
var _b, _c, _d, _e, _f, _g;
|
|
223
|
+
var _a, _b, _c, _d, _e, _f;
|
|
227
224
|
if (ctx.luckysheet_selection_range) {
|
|
228
225
|
ctx.luckysheet_selection_range = [];
|
|
229
226
|
}
|
|
230
227
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
231
228
|
if (!allowEdit || ctx.isFlvReadOnly) return;
|
|
232
|
-
if (((
|
|
229
|
+
if (((_b = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) !== 1) {
|
|
233
230
|
return;
|
|
234
231
|
}
|
|
235
232
|
if (_typeof(data) === "object") {
|
|
@@ -278,7 +275,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
278
275
|
currentRowLen = cfg.rowlen[h];
|
|
279
276
|
}
|
|
280
277
|
for (var c = minc; c <= maxc; c += 1) {
|
|
281
|
-
if ((
|
|
278
|
+
if ((_c = x === null || x === void 0 ? void 0 : x[c]) === null || _c === void 0 ? void 0 : _c.mc) {
|
|
282
279
|
if ("rs" in x[c].mc) {
|
|
283
280
|
delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
|
|
284
281
|
}
|
|
@@ -289,7 +286,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
289
286
|
value = data[h - minh][c - minc];
|
|
290
287
|
}
|
|
291
288
|
x[c] = value;
|
|
292
|
-
if (value != null && ((
|
|
289
|
+
if (value != null && ((_d = x === null || x === void 0 ? void 0 : x[c]) === null || _d === void 0 ? void 0 : _d.mc)) {
|
|
293
290
|
if (x[c].mc.rs != null) {
|
|
294
291
|
x[c].mc.r = h;
|
|
295
292
|
x[c].mc.c = c;
|
|
@@ -316,7 +313,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
316
313
|
b: borderInfo["".concat(h - minh, "_").concat(c - minc)].b
|
|
317
314
|
}
|
|
318
315
|
};
|
|
319
|
-
(
|
|
316
|
+
(_e = cfg.borderInfo) === null || _e === void 0 ? void 0 : _e.push(bd_obj);
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
319
|
d[h] = x;
|
|
@@ -348,7 +345,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
348
345
|
}
|
|
349
346
|
var d = (0, _context.getFlowdata)(ctx);
|
|
350
347
|
if (!d) return;
|
|
351
|
-
var last = (
|
|
348
|
+
var last = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f[ctx.luckysheet_select_save.length - 1];
|
|
352
349
|
if (!last) return;
|
|
353
350
|
var curR = last.row == null ? 0 : last.row[0];
|
|
354
351
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -389,9 +386,23 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
389
386
|
}
|
|
390
387
|
}
|
|
391
388
|
if (originCell) {
|
|
392
|
-
originCell.
|
|
389
|
+
if (originCell.ct && originCell.ct.t === "d" && !isUrl) {
|
|
390
|
+
var df = (0, _validation.detectDateFormat)(originalValueStr);
|
|
391
|
+
if (df) {
|
|
392
|
+
var dateObj = new Date(df.year, df.month - 1, df.day, df.hours, df.minutes, df.seconds);
|
|
393
|
+
originCell.v = (0, _format.datenum_local)(dateObj);
|
|
394
|
+
} else {
|
|
395
|
+
originCell.v = originalValueStr;
|
|
396
|
+
}
|
|
397
|
+
} else {
|
|
398
|
+
originCell.v = isUrl ? originalValueStr : value;
|
|
399
|
+
}
|
|
393
400
|
if (originCell.ct != null && originCell.ct.fa != null) {
|
|
394
|
-
|
|
401
|
+
if (originCell.ct.t === "d" && typeof originCell.v !== "number") {
|
|
402
|
+
originCell.m = String(originCell.v);
|
|
403
|
+
} else {
|
|
404
|
+
originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
|
|
405
|
+
}
|
|
395
406
|
} else {
|
|
396
407
|
originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
|
|
397
408
|
}
|
|
@@ -420,8 +431,12 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
420
431
|
t: "s"
|
|
421
432
|
};
|
|
422
433
|
} else {
|
|
423
|
-
|
|
424
|
-
|
|
434
|
+
cell.v = originalValueStr;
|
|
435
|
+
cell.m = originalValueStr;
|
|
436
|
+
cell.ct = {
|
|
437
|
+
fa: "General",
|
|
438
|
+
t: "g"
|
|
439
|
+
};
|
|
425
440
|
if (/^0x?[a-fA-F0-9]+$/.test(value)) {
|
|
426
441
|
cell.m = value;
|
|
427
442
|
cell.ct = {
|
|
@@ -1024,9 +1039,10 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1024
1039
|
if (!_lodash.default.isNil(value) && !_lodash.default.isNil(value.f)) {
|
|
1025
1040
|
var adjustedFormula = value.f;
|
|
1026
1041
|
var isError = false;
|
|
1042
|
+
var srcRow = c_r1 + (h - mth);
|
|
1043
|
+
var srcCol = c_c1 + (c - mtc);
|
|
1027
1044
|
try {
|
|
1028
|
-
adjustedFormula = adjustFormulaForPaste(value.f,
|
|
1029
|
-
console.log("adjustedFormula", adjustedFormula);
|
|
1045
|
+
adjustedFormula = adjustFormulaForPaste(value.f, srcCol, srcRow, c, h);
|
|
1030
1046
|
} catch (error) {
|
|
1031
1047
|
isError = true;
|
|
1032
1048
|
value.error = {
|