@fileverse-dev/fortune-core 1.2.90-ydoc-11 → 1.2.90-ydoc-12
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/events/paste.js +51 -6
- package/es/modules/selection.js +10 -0
- package/es/modules/toolbar.js +35 -12
- package/es/settings.d.ts +8 -0
- package/lib/events/paste.js +51 -6
- package/lib/modules/selection.js +10 -0
- package/lib/modules/toolbar.js +35 -12
- package/lib/settings.d.ts +8 -0
- package/package.json +1 -1
package/es/events/paste.js
CHANGED
|
@@ -189,28 +189,43 @@ function postPasteCut(ctx, source, target, RowlChange) {
|
|
|
189
189
|
storeSheetParamALL(ctx);
|
|
190
190
|
}
|
|
191
191
|
var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
192
|
-
var _a;
|
|
192
|
+
var _a, _b, _c;
|
|
193
|
+
var changes = [];
|
|
193
194
|
for (var r = 0; r < d.length; r += 1) {
|
|
194
195
|
var x = d[r];
|
|
195
196
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
196
197
|
var value = isObject(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
197
198
|
if (value && String(value).startsWith("=")) {
|
|
198
199
|
var cell = {};
|
|
199
|
-
var
|
|
200
|
-
v =
|
|
201
|
-
f =
|
|
200
|
+
var _d = execfunction(ctx, String(value), r, c, undefined, undefined, true),
|
|
201
|
+
v = _d[1],
|
|
202
|
+
f = _d[2];
|
|
202
203
|
cell.v = v;
|
|
203
204
|
cell.f = f;
|
|
204
205
|
cell.m = v.toString();
|
|
205
206
|
x[c] = cell;
|
|
206
207
|
}
|
|
207
208
|
d[r] = x;
|
|
209
|
+
changes.push({
|
|
210
|
+
sheetId: ctx.currentSheetId,
|
|
211
|
+
path: ['celldata'],
|
|
212
|
+
value: {
|
|
213
|
+
r: r,
|
|
214
|
+
c: c,
|
|
215
|
+
v: d[r][c]
|
|
216
|
+
},
|
|
217
|
+
key: r + '_' + c,
|
|
218
|
+
type: 'update'
|
|
219
|
+
});
|
|
208
220
|
}
|
|
209
221
|
}
|
|
222
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
223
|
+
(_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
|
|
224
|
+
}
|
|
210
225
|
};
|
|
211
226
|
function pasteHandler(ctx, data, borderInfo) {
|
|
212
227
|
var _a;
|
|
213
|
-
var _b, _c, _d, _e, _f, _g;
|
|
228
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
214
229
|
if (ctx.luckysheet_selection_range) {
|
|
215
230
|
ctx.luckysheet_selection_range = [];
|
|
216
231
|
}
|
|
@@ -258,6 +273,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
258
273
|
}
|
|
259
274
|
var RowlChange = false;
|
|
260
275
|
var offsetMC = {};
|
|
276
|
+
var changes = [];
|
|
261
277
|
for (var h = minh; h <= maxh; h += 1) {
|
|
262
278
|
var x = d[h];
|
|
263
279
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -305,12 +321,26 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
305
321
|
};
|
|
306
322
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
307
323
|
}
|
|
324
|
+
changes.push({
|
|
325
|
+
sheetId: ctx.currentSheetId,
|
|
326
|
+
path: ['celldata'],
|
|
327
|
+
value: {
|
|
328
|
+
r: h,
|
|
329
|
+
c: c,
|
|
330
|
+
v: d[h][c]
|
|
331
|
+
},
|
|
332
|
+
key: h + '_' + c,
|
|
333
|
+
type: 'update'
|
|
334
|
+
});
|
|
308
335
|
}
|
|
309
336
|
d[h] = x;
|
|
310
337
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
311
338
|
cfg.rowlen[h] = currentRowLen;
|
|
312
339
|
}
|
|
313
340
|
}
|
|
341
|
+
if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
|
|
342
|
+
(_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
|
|
343
|
+
}
|
|
314
344
|
ctx.luckysheet_select_save = [{
|
|
315
345
|
row: [minh, maxh],
|
|
316
346
|
column: [minc, maxc]
|
|
@@ -335,7 +365,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
335
365
|
}
|
|
336
366
|
var d = getFlowdata(ctx);
|
|
337
367
|
if (!d) return;
|
|
338
|
-
var last = (
|
|
368
|
+
var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
|
|
339
369
|
if (!last) return;
|
|
340
370
|
var curR = last.row == null ? 0 : last.row[0];
|
|
341
371
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -360,6 +390,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
360
390
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
361
391
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
362
392
|
};
|
|
393
|
+
var changes = [];
|
|
363
394
|
for (var r = 0; r < rlen; r += 1) {
|
|
364
395
|
var x = d[r + curR];
|
|
365
396
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -432,9 +463,23 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
432
463
|
}
|
|
433
464
|
x[c + curC] = cell;
|
|
434
465
|
}
|
|
466
|
+
changes.push(changes.push({
|
|
467
|
+
sheetId: ctx.currentSheetId,
|
|
468
|
+
path: ['celldata'],
|
|
469
|
+
value: {
|
|
470
|
+
r: r,
|
|
471
|
+
c: c,
|
|
472
|
+
v: d[r][c]
|
|
473
|
+
},
|
|
474
|
+
key: r + '_' + c,
|
|
475
|
+
type: 'update'
|
|
476
|
+
}));
|
|
435
477
|
}
|
|
436
478
|
d[r + curR] = x;
|
|
437
479
|
}
|
|
480
|
+
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
|
|
481
|
+
(_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
|
|
482
|
+
}
|
|
438
483
|
last.row = [curR, curR + rlen - 1];
|
|
439
484
|
last.column = [curC, curC + clen - 1];
|
|
440
485
|
jfrefreshgrid(ctx, null, undefined);
|
package/es/modules/selection.js
CHANGED
|
@@ -1525,6 +1525,7 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1525
1525
|
var r2 = selection[s].row[1];
|
|
1526
1526
|
var c1 = selection[s].column[0];
|
|
1527
1527
|
var c2 = selection[s].column[1];
|
|
1528
|
+
var changes = [];
|
|
1528
1529
|
for (var r = r1; r <= r2; r += 1) {
|
|
1529
1530
|
for (var c = c1; c <= c2; c += 1) {
|
|
1530
1531
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -1556,6 +1557,15 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1556
1557
|
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
|
|
1557
1558
|
ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
|
|
1558
1559
|
}
|
|
1560
|
+
changes.push({
|
|
1561
|
+
sheetId: ctx.currentSheetId,
|
|
1562
|
+
path: ['celldata'],
|
|
1563
|
+
value: {
|
|
1564
|
+
r: r,
|
|
1565
|
+
c: c,
|
|
1566
|
+
v: d[r][c]
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1559
1569
|
}
|
|
1560
1570
|
}
|
|
1561
1571
|
}
|
package/es/modules/toolbar.js
CHANGED
|
@@ -15,13 +15,14 @@ import { showLinkCard } from "./hyperlink";
|
|
|
15
15
|
import { cfSplitRange } from "./conditionalFormat";
|
|
16
16
|
import { clearMeasureTextCache, getCellTextInfo } from "./text";
|
|
17
17
|
export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
19
|
-
var
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
19
|
+
var _11;
|
|
20
20
|
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
21
21
|
if (_.isNil(d) || _.isNil(attr)) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (attr === "ct") {
|
|
25
|
+
var changes = [];
|
|
25
26
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
26
27
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
27
28
|
continue;
|
|
@@ -73,9 +74,18 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
73
74
|
m: mask
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
changes.push({
|
|
78
|
+
sheetId: ctx.currentSheetId,
|
|
79
|
+
path: ['celldata'],
|
|
80
|
+
value: {
|
|
81
|
+
r: r,
|
|
82
|
+
c: c,
|
|
83
|
+
v: d[r][c]
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
88
|
+
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
} else {
|
|
@@ -122,6 +132,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
122
132
|
if (sheetIndex == null) {
|
|
123
133
|
return;
|
|
124
134
|
}
|
|
135
|
+
var changes = [];
|
|
125
136
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
126
137
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
127
138
|
continue;
|
|
@@ -131,11 +142,11 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
131
142
|
if (value && _.isPlainObject(value)) {
|
|
132
143
|
updateInlineStringFormatOutside(value, attr, foucsStatus);
|
|
133
144
|
value[attr] = foucsStatus;
|
|
134
|
-
(
|
|
145
|
+
(_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
|
|
135
146
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
136
|
-
var cellWidth = ((
|
|
147
|
+
var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
137
148
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
138
|
-
var currentColWidth_1 = ((
|
|
149
|
+
var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
139
150
|
var lineCount_1 = 1;
|
|
140
151
|
var fontString_1 = "10px Arial";
|
|
141
152
|
if (value.fs) {
|
|
@@ -148,9 +159,9 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
148
159
|
lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
|
|
149
160
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
150
161
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
151
|
-
} else if ((
|
|
162
|
+
} else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
|
|
152
163
|
lineCount_1 -= 1;
|
|
153
|
-
var line = (
|
|
164
|
+
var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
|
|
154
165
|
line.forEach(function (item) {
|
|
155
166
|
var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
|
|
156
167
|
lineCount_1 += subLineCount;
|
|
@@ -170,7 +181,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
170
181
|
});
|
|
171
182
|
if (!textInfo) return "continue";
|
|
172
183
|
var rowHeight = _.round(textInfo.textHeightAll);
|
|
173
|
-
var currentRowHeight = ((
|
|
184
|
+
var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
174
185
|
if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
175
186
|
if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
176
187
|
_.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -185,7 +196,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
185
196
|
});
|
|
186
197
|
if (!textInfo) return "continue";
|
|
187
198
|
var newHeight = _.round(textInfo.textHeightAll);
|
|
188
|
-
var oldHeight = ((
|
|
199
|
+
var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
189
200
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
190
201
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
191
202
|
var padding = 12;
|
|
@@ -200,11 +211,23 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
200
211
|
};
|
|
201
212
|
d[r][c][attr] = foucsStatus;
|
|
202
213
|
}
|
|
214
|
+
changes.push({
|
|
215
|
+
sheetId: ctx.currentSheetId,
|
|
216
|
+
path: ['celldata'],
|
|
217
|
+
value: {
|
|
218
|
+
r: r,
|
|
219
|
+
c: c,
|
|
220
|
+
v: d[r][c]
|
|
221
|
+
}
|
|
222
|
+
});
|
|
203
223
|
};
|
|
204
224
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
205
225
|
_loop_1(c);
|
|
206
226
|
}
|
|
207
227
|
}
|
|
228
|
+
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
229
|
+
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
230
|
+
}
|
|
208
231
|
}
|
|
209
232
|
}
|
|
210
233
|
export function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/es/settings.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Sheet, Selection, CellMatrix, Cell } from "./types";
|
|
3
|
+
type SheetChangePath = {
|
|
4
|
+
sheetId: string;
|
|
5
|
+
path: string[];
|
|
6
|
+
key?: string;
|
|
7
|
+
value: any;
|
|
8
|
+
type?: 'update' | 'delete';
|
|
9
|
+
};
|
|
3
10
|
export type Hooks = {
|
|
4
11
|
calcChainChange?: () => void;
|
|
5
12
|
sheetLengthChange?: () => void;
|
|
@@ -11,6 +18,7 @@ export type Hooks = {
|
|
|
11
18
|
conditionFormatChange?: () => void;
|
|
12
19
|
cellDataChange?: () => void;
|
|
13
20
|
hyperlinkChange?: () => void;
|
|
21
|
+
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
14
22
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
15
23
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
16
24
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|
package/lib/events/paste.js
CHANGED
|
@@ -202,28 +202,43 @@ function postPasteCut(ctx, source, target, RowlChange) {
|
|
|
202
202
|
(0, _sheet.storeSheetParamALL)(ctx);
|
|
203
203
|
}
|
|
204
204
|
var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
205
|
-
var _a;
|
|
205
|
+
var _a, _b, _c;
|
|
206
|
+
var changes = [];
|
|
206
207
|
for (var r = 0; r < d.length; r += 1) {
|
|
207
208
|
var x = d[r];
|
|
208
209
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
209
210
|
var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
210
211
|
if (value && String(value).startsWith("=")) {
|
|
211
212
|
var cell = {};
|
|
212
|
-
var
|
|
213
|
-
v =
|
|
214
|
-
f =
|
|
213
|
+
var _d = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
|
|
214
|
+
v = _d[1],
|
|
215
|
+
f = _d[2];
|
|
215
216
|
cell.v = v;
|
|
216
217
|
cell.f = f;
|
|
217
218
|
cell.m = v.toString();
|
|
218
219
|
x[c] = cell;
|
|
219
220
|
}
|
|
220
221
|
d[r] = x;
|
|
222
|
+
changes.push({
|
|
223
|
+
sheetId: ctx.currentSheetId,
|
|
224
|
+
path: ['celldata'],
|
|
225
|
+
value: {
|
|
226
|
+
r: r,
|
|
227
|
+
c: c,
|
|
228
|
+
v: d[r][c]
|
|
229
|
+
},
|
|
230
|
+
key: r + '_' + c,
|
|
231
|
+
type: 'update'
|
|
232
|
+
});
|
|
221
233
|
}
|
|
222
234
|
}
|
|
235
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
236
|
+
(_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
|
|
237
|
+
}
|
|
223
238
|
};
|
|
224
239
|
function pasteHandler(ctx, data, borderInfo) {
|
|
225
240
|
var _a;
|
|
226
|
-
var _b, _c, _d, _e, _f, _g;
|
|
241
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
227
242
|
if (ctx.luckysheet_selection_range) {
|
|
228
243
|
ctx.luckysheet_selection_range = [];
|
|
229
244
|
}
|
|
@@ -271,6 +286,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
271
286
|
}
|
|
272
287
|
var RowlChange = false;
|
|
273
288
|
var offsetMC = {};
|
|
289
|
+
var changes = [];
|
|
274
290
|
for (var h = minh; h <= maxh; h += 1) {
|
|
275
291
|
var x = d[h];
|
|
276
292
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -318,12 +334,26 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
318
334
|
};
|
|
319
335
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
320
336
|
}
|
|
337
|
+
changes.push({
|
|
338
|
+
sheetId: ctx.currentSheetId,
|
|
339
|
+
path: ['celldata'],
|
|
340
|
+
value: {
|
|
341
|
+
r: h,
|
|
342
|
+
c: c,
|
|
343
|
+
v: d[h][c]
|
|
344
|
+
},
|
|
345
|
+
key: h + '_' + c,
|
|
346
|
+
type: 'update'
|
|
347
|
+
});
|
|
321
348
|
}
|
|
322
349
|
d[h] = x;
|
|
323
350
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
324
351
|
cfg.rowlen[h] = currentRowLen;
|
|
325
352
|
}
|
|
326
353
|
}
|
|
354
|
+
if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
|
|
355
|
+
(_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
|
|
356
|
+
}
|
|
327
357
|
ctx.luckysheet_select_save = [{
|
|
328
358
|
row: [minh, maxh],
|
|
329
359
|
column: [minc, maxc]
|
|
@@ -348,7 +378,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
348
378
|
}
|
|
349
379
|
var d = (0, _context.getFlowdata)(ctx);
|
|
350
380
|
if (!d) return;
|
|
351
|
-
var last = (
|
|
381
|
+
var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
|
|
352
382
|
if (!last) return;
|
|
353
383
|
var curR = last.row == null ? 0 : last.row[0];
|
|
354
384
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -373,6 +403,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
373
403
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
374
404
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
375
405
|
};
|
|
406
|
+
var changes = [];
|
|
376
407
|
for (var r = 0; r < rlen; r += 1) {
|
|
377
408
|
var x = d[r + curR];
|
|
378
409
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -445,9 +476,23 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
445
476
|
}
|
|
446
477
|
x[c + curC] = cell;
|
|
447
478
|
}
|
|
479
|
+
changes.push(changes.push({
|
|
480
|
+
sheetId: ctx.currentSheetId,
|
|
481
|
+
path: ['celldata'],
|
|
482
|
+
value: {
|
|
483
|
+
r: r,
|
|
484
|
+
c: c,
|
|
485
|
+
v: d[r][c]
|
|
486
|
+
},
|
|
487
|
+
key: r + '_' + c,
|
|
488
|
+
type: 'update'
|
|
489
|
+
}));
|
|
448
490
|
}
|
|
449
491
|
d[r + curR] = x;
|
|
450
492
|
}
|
|
493
|
+
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
|
|
494
|
+
(_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
|
|
495
|
+
}
|
|
451
496
|
last.row = [curR, curR + rlen - 1];
|
|
452
497
|
last.column = [curC, curC + clen - 1];
|
|
453
498
|
(0, _refresh.jfrefreshgrid)(ctx, null, undefined);
|
package/lib/modules/selection.js
CHANGED
|
@@ -1560,6 +1560,7 @@ function deleteSelectedCellText(ctx) {
|
|
|
1560
1560
|
var r2 = selection[s].row[1];
|
|
1561
1561
|
var c1 = selection[s].column[0];
|
|
1562
1562
|
var c2 = selection[s].column[1];
|
|
1563
|
+
var changes = [];
|
|
1563
1564
|
for (var r = r1; r <= r2; r += 1) {
|
|
1564
1565
|
for (var c = c1; c <= c2; c += 1) {
|
|
1565
1566
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
@@ -1591,6 +1592,15 @@ function deleteSelectedCellText(ctx) {
|
|
|
1591
1592
|
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
|
|
1592
1593
|
ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
|
|
1593
1594
|
}
|
|
1595
|
+
changes.push({
|
|
1596
|
+
sheetId: ctx.currentSheetId,
|
|
1597
|
+
path: ['celldata'],
|
|
1598
|
+
value: {
|
|
1599
|
+
r: r,
|
|
1600
|
+
c: c,
|
|
1601
|
+
v: d[r][c]
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1594
1604
|
}
|
|
1595
1605
|
}
|
|
1596
1606
|
}
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -48,13 +48,14 @@ var _conditionalFormat = require("./conditionalFormat");
|
|
|
48
48
|
var _text = require("./text");
|
|
49
49
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
50
50
|
function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
52
|
-
var
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
52
|
+
var _11;
|
|
53
53
|
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
54
54
|
if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
if (attr === "ct") {
|
|
58
|
+
var changes = [];
|
|
58
59
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
59
60
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
60
61
|
continue;
|
|
@@ -106,9 +107,18 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
106
107
|
m: mask
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
changes.push({
|
|
111
|
+
sheetId: ctx.currentSheetId,
|
|
112
|
+
path: ['celldata'],
|
|
113
|
+
value: {
|
|
114
|
+
r: r,
|
|
115
|
+
c: c,
|
|
116
|
+
v: d[r][c]
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
121
|
+
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
} else {
|
|
@@ -155,6 +165,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
155
165
|
if (sheetIndex == null) {
|
|
156
166
|
return;
|
|
157
167
|
}
|
|
168
|
+
var changes = [];
|
|
158
169
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
159
170
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
160
171
|
continue;
|
|
@@ -164,11 +175,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
164
175
|
if (value && _lodash.default.isPlainObject(value)) {
|
|
165
176
|
(0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
|
|
166
177
|
value[attr] = foucsStatus;
|
|
167
|
-
(
|
|
178
|
+
(_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
|
|
168
179
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
169
|
-
var cellWidth = ((
|
|
180
|
+
var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
170
181
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
171
|
-
var currentColWidth_1 = ((
|
|
182
|
+
var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
172
183
|
var lineCount_1 = 1;
|
|
173
184
|
var fontString_1 = "10px Arial";
|
|
174
185
|
if (value.fs) {
|
|
@@ -181,9 +192,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
181
192
|
lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
|
|
182
193
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
183
194
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
184
|
-
} else if ((
|
|
195
|
+
} else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
|
|
185
196
|
lineCount_1 -= 1;
|
|
186
|
-
var line = (
|
|
197
|
+
var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
|
|
187
198
|
line.forEach(function (item) {
|
|
188
199
|
var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
|
|
189
200
|
lineCount_1 += subLineCount;
|
|
@@ -203,7 +214,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
203
214
|
});
|
|
204
215
|
if (!textInfo) return "continue";
|
|
205
216
|
var rowHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
206
|
-
var currentRowHeight = ((
|
|
217
|
+
var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
207
218
|
if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
208
219
|
if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
209
220
|
_lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -218,7 +229,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
218
229
|
});
|
|
219
230
|
if (!textInfo) return "continue";
|
|
220
231
|
var newHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
221
|
-
var oldHeight = ((
|
|
232
|
+
var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
222
233
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
223
234
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
224
235
|
var padding = 12;
|
|
@@ -233,11 +244,23 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
233
244
|
};
|
|
234
245
|
d[r][c][attr] = foucsStatus;
|
|
235
246
|
}
|
|
247
|
+
changes.push({
|
|
248
|
+
sheetId: ctx.currentSheetId,
|
|
249
|
+
path: ['celldata'],
|
|
250
|
+
value: {
|
|
251
|
+
r: r,
|
|
252
|
+
c: c,
|
|
253
|
+
v: d[r][c]
|
|
254
|
+
}
|
|
255
|
+
});
|
|
236
256
|
};
|
|
237
257
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
238
258
|
_loop_1(c);
|
|
239
259
|
}
|
|
240
260
|
}
|
|
261
|
+
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
262
|
+
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
263
|
+
}
|
|
241
264
|
}
|
|
242
265
|
}
|
|
243
266
|
function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/lib/settings.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Sheet, Selection, CellMatrix, Cell } from "./types";
|
|
3
|
+
type SheetChangePath = {
|
|
4
|
+
sheetId: string;
|
|
5
|
+
path: string[];
|
|
6
|
+
key?: string;
|
|
7
|
+
value: any;
|
|
8
|
+
type?: 'update' | 'delete';
|
|
9
|
+
};
|
|
3
10
|
export type Hooks = {
|
|
4
11
|
calcChainChange?: () => void;
|
|
5
12
|
sheetLengthChange?: () => void;
|
|
@@ -11,6 +18,7 @@ export type Hooks = {
|
|
|
11
18
|
conditionFormatChange?: () => void;
|
|
12
19
|
cellDataChange?: () => void;
|
|
13
20
|
hyperlinkChange?: () => void;
|
|
21
|
+
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
14
22
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
15
23
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
16
24
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|