@fileverse-dev/fortune-core 1.3.10 → 1.3.11
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/range.js +20 -0
- package/es/api/sheet.js +30 -2
- package/es/events/keyboard.js +15 -1
- package/es/events/paste.js +77 -28
- package/es/modules/cell.js +58 -2
- package/es/modules/comment.js +129 -24
- package/es/modules/dataVerification.js +34 -1
- package/es/modules/dropCell.js +65 -1
- package/es/modules/formula.js +14 -0
- package/es/modules/hyperlink.js +52 -5
- package/es/modules/merge.js +93 -1
- package/es/modules/moveCells.js +35 -9
- package/es/modules/rowcol.js +75 -2
- package/es/modules/searchReplace.js +58 -2
- package/es/modules/selection.js +152 -42
- package/es/modules/sort.js +74 -9
- package/es/modules/splitColumn.js +21 -0
- package/es/modules/toolbar.js +46 -3
- package/es/settings.d.ts +5 -0
- package/lib/api/range.js +20 -0
- package/lib/api/sheet.js +29 -1
- package/lib/events/keyboard.js +15 -1
- package/lib/events/paste.js +77 -28
- package/lib/modules/cell.js +58 -2
- package/lib/modules/comment.js +129 -24
- package/lib/modules/dataVerification.js +34 -1
- package/lib/modules/dropCell.js +65 -1
- package/lib/modules/formula.js +14 -0
- package/lib/modules/hyperlink.js +52 -5
- package/lib/modules/merge.js +93 -1
- package/lib/modules/moveCells.js +35 -9
- package/lib/modules/rowcol.js +75 -2
- package/lib/modules/searchReplace.js +58 -2
- package/lib/modules/selection.js +152 -42
- package/lib/modules/sort.js +74 -9
- package/lib/modules/splitColumn.js +21 -0
- package/lib/modules/toolbar.js +46 -3
- package/lib/settings.d.ts +5 -0
- package/package.json +1 -1
package/es/modules/merge.js
CHANGED
|
@@ -2,7 +2,7 @@ import _ from "lodash";
|
|
|
2
2
|
import { getSheetIndex } from "../utils";
|
|
3
3
|
import { isInlineStringCT } from "./inline-string";
|
|
4
4
|
export function mergeCells(ctx, sheetId, ranges, type) {
|
|
5
|
-
var _a, _b, _c;
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
6
|
var idx = getSheetIndex(ctx, sheetId);
|
|
7
7
|
if (idx == null) return;
|
|
8
8
|
var sheet = ctx.luckysheetfile[idx];
|
|
@@ -11,6 +11,7 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
11
11
|
cfg.merge = {};
|
|
12
12
|
}
|
|
13
13
|
var d = sheet.data;
|
|
14
|
+
var cellChanges = [];
|
|
14
15
|
if (type === "merge-cancel") {
|
|
15
16
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
16
17
|
var range = ranges[i];
|
|
@@ -40,6 +41,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
40
41
|
delete cell_clone.f;
|
|
41
42
|
delete cell_clone.spl;
|
|
42
43
|
d[r][c] = cell_clone;
|
|
44
|
+
cellChanges.push({
|
|
45
|
+
sheetId: sheetId,
|
|
46
|
+
path: ["celldata"],
|
|
47
|
+
value: {
|
|
48
|
+
r: r,
|
|
49
|
+
c: c,
|
|
50
|
+
v: d[r][c]
|
|
51
|
+
},
|
|
52
|
+
key: "".concat(r, "_").concat(c),
|
|
53
|
+
type: "update"
|
|
54
|
+
});
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
}
|
|
@@ -92,6 +104,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
92
104
|
delete cell_clone.f;
|
|
93
105
|
delete cell_clone.spl;
|
|
94
106
|
d[r][c] = cell_clone;
|
|
107
|
+
cellChanges.push({
|
|
108
|
+
sheetId: sheetId,
|
|
109
|
+
path: ["celldata"],
|
|
110
|
+
value: {
|
|
111
|
+
r: r,
|
|
112
|
+
c: c,
|
|
113
|
+
v: d[r][c]
|
|
114
|
+
},
|
|
115
|
+
key: "".concat(r, "_").concat(c),
|
|
116
|
+
type: "update"
|
|
117
|
+
});
|
|
95
118
|
}
|
|
96
119
|
}
|
|
97
120
|
}
|
|
@@ -123,6 +146,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
123
146
|
c: c1
|
|
124
147
|
}
|
|
125
148
|
};
|
|
149
|
+
cellChanges.push({
|
|
150
|
+
sheetId: sheetId,
|
|
151
|
+
path: ["celldata"],
|
|
152
|
+
value: {
|
|
153
|
+
r: r,
|
|
154
|
+
c: c,
|
|
155
|
+
v: d[r][c]
|
|
156
|
+
},
|
|
157
|
+
key: "".concat(r, "_").concat(c),
|
|
158
|
+
type: "update"
|
|
159
|
+
});
|
|
126
160
|
}
|
|
127
161
|
}
|
|
128
162
|
d[r1][c1] = fv;
|
|
@@ -134,6 +168,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
134
168
|
rs: r2 - r1 + 1,
|
|
135
169
|
cs: c2 - c1 + 1
|
|
136
170
|
};
|
|
171
|
+
cellChanges.push({
|
|
172
|
+
sheetId: sheetId,
|
|
173
|
+
path: ["celldata"],
|
|
174
|
+
value: {
|
|
175
|
+
r: r1,
|
|
176
|
+
c: c1,
|
|
177
|
+
v: d[r1][c1]
|
|
178
|
+
},
|
|
179
|
+
key: "".concat(r1, "_").concat(c1),
|
|
180
|
+
type: "update"
|
|
181
|
+
});
|
|
137
182
|
cfg.merge["".concat(r1, "_").concat(c1)] = {
|
|
138
183
|
r: r1,
|
|
139
184
|
c: c1,
|
|
@@ -156,6 +201,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
156
201
|
c: c
|
|
157
202
|
}
|
|
158
203
|
};
|
|
204
|
+
cellChanges.push({
|
|
205
|
+
sheetId: sheetId,
|
|
206
|
+
path: ["celldata"],
|
|
207
|
+
value: {
|
|
208
|
+
r: r,
|
|
209
|
+
c: c,
|
|
210
|
+
v: d[r][c]
|
|
211
|
+
},
|
|
212
|
+
key: "".concat(r, "_").concat(c),
|
|
213
|
+
type: "update"
|
|
214
|
+
});
|
|
159
215
|
}
|
|
160
216
|
d[r1][c] = fv;
|
|
161
217
|
var a = d[r1][c];
|
|
@@ -166,6 +222,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
166
222
|
rs: r2 - r1 + 1,
|
|
167
223
|
cs: 1
|
|
168
224
|
};
|
|
225
|
+
cellChanges.push({
|
|
226
|
+
sheetId: sheetId,
|
|
227
|
+
path: ["celldata"],
|
|
228
|
+
value: {
|
|
229
|
+
r: r1,
|
|
230
|
+
c: c,
|
|
231
|
+
v: d[r1][c]
|
|
232
|
+
},
|
|
233
|
+
key: "".concat(r1, "_").concat(c),
|
|
234
|
+
type: "update"
|
|
235
|
+
});
|
|
169
236
|
cfg.merge["".concat(r1, "_").concat(c)] = {
|
|
170
237
|
r: r1,
|
|
171
238
|
c: c,
|
|
@@ -189,6 +256,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
189
256
|
c: c1
|
|
190
257
|
}
|
|
191
258
|
};
|
|
259
|
+
cellChanges.push({
|
|
260
|
+
sheetId: sheetId,
|
|
261
|
+
path: ["celldata"],
|
|
262
|
+
value: {
|
|
263
|
+
r: r,
|
|
264
|
+
c: c,
|
|
265
|
+
v: d[r][c]
|
|
266
|
+
},
|
|
267
|
+
key: "".concat(r, "_").concat(c),
|
|
268
|
+
type: "update"
|
|
269
|
+
});
|
|
192
270
|
}
|
|
193
271
|
d[r][c1] = fv;
|
|
194
272
|
var a = d[r][c1];
|
|
@@ -199,6 +277,17 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
199
277
|
rs: 1,
|
|
200
278
|
cs: c2 - c1 + 1
|
|
201
279
|
};
|
|
280
|
+
cellChanges.push({
|
|
281
|
+
sheetId: sheetId,
|
|
282
|
+
path: ["celldata"],
|
|
283
|
+
value: {
|
|
284
|
+
r: r,
|
|
285
|
+
c: c1,
|
|
286
|
+
v: d[r][c1]
|
|
287
|
+
},
|
|
288
|
+
key: "".concat(r, "_").concat(c1),
|
|
289
|
+
type: "update"
|
|
290
|
+
});
|
|
202
291
|
cfg.merge["".concat(r, "_").concat(c1)] = {
|
|
203
292
|
r: r,
|
|
204
293
|
c: c1,
|
|
@@ -209,6 +298,9 @@ export function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
209
298
|
}
|
|
210
299
|
}
|
|
211
300
|
}
|
|
301
|
+
if (cellChanges.length > 0 && ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc)) {
|
|
302
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
303
|
+
}
|
|
212
304
|
sheet.config = cfg;
|
|
213
305
|
if (sheet.id === ctx.currentSheetId) {
|
|
214
306
|
ctx.config = cfg;
|
package/es/modules/moveCells.js
CHANGED
|
@@ -122,7 +122,7 @@ export function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, contain
|
|
|
122
122
|
ele.style.display = "block";
|
|
123
123
|
}
|
|
124
124
|
export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
|
|
125
|
-
var _a, _b, _c, _d;
|
|
125
|
+
var _a, _b, _c, _d, _e;
|
|
126
126
|
if (!ctx.luckysheet_cell_selected_move) return;
|
|
127
127
|
ctx.luckysheet_cell_selected_move = false;
|
|
128
128
|
var ele = document.getElementById("fortune-cell-selected-move");
|
|
@@ -131,17 +131,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
131
131
|
globalCache.dragCellStartPos = undefined;
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
var
|
|
135
|
-
x =
|
|
136
|
-
y =
|
|
134
|
+
var _f = mousePosition(e.pageX, e.pageY, ctx),
|
|
135
|
+
x = _f[0],
|
|
136
|
+
y = _f[1];
|
|
137
137
|
var rect = container.getBoundingClientRect();
|
|
138
138
|
var winH = rect.height - 20 * ctx.zoomRatio;
|
|
139
139
|
var winW = rect.width - 60 * ctx.zoomRatio;
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
row_index =
|
|
143
|
-
|
|
144
|
-
col_index =
|
|
140
|
+
var _g = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
|
|
141
|
+
_h = _g.row,
|
|
142
|
+
row_index = _h[2],
|
|
143
|
+
_j = _g.column,
|
|
144
|
+
col_index = _j[2];
|
|
145
145
|
var allowEdit = isAllowEdit(ctx, [{
|
|
146
146
|
row: [row_index, row_index],
|
|
147
147
|
column: [col_index, col_index]
|
|
@@ -191,6 +191,7 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
191
191
|
throw new Error(locale_drag.noMerge);
|
|
192
192
|
}
|
|
193
193
|
var borderInfoCompute = getBorderInfoCompute(ctx, ctx.currentSheetId);
|
|
194
|
+
var cellChanges = [];
|
|
194
195
|
var hyperLinkList = {};
|
|
195
196
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
196
197
|
for (var r = last.row[0]; r <= last.row[1]; r += 1) {
|
|
@@ -203,6 +204,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
d[r][c] = null;
|
|
207
|
+
cellChanges.push({
|
|
208
|
+
sheetId: ctx.currentSheetId,
|
|
209
|
+
path: ["celldata"],
|
|
210
|
+
value: {
|
|
211
|
+
r: r,
|
|
212
|
+
c: c,
|
|
213
|
+
v: null
|
|
214
|
+
},
|
|
215
|
+
key: "".concat(r, "_").concat(c),
|
|
216
|
+
type: "update"
|
|
217
|
+
});
|
|
206
218
|
if ((_a = ctx.luckysheetfile[index].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) {
|
|
207
219
|
hyperLinkList["".concat(r, "_").concat(c)] = (_b = ctx.luckysheetfile[index].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(r, "_").concat(c)];
|
|
208
220
|
(_c = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink) === null || _c === void 0 ? true : delete _c["".concat(r, "_").concat(c)];
|
|
@@ -291,6 +303,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
291
303
|
}
|
|
292
304
|
}
|
|
293
305
|
d[r + row_s][c + col_s] = value;
|
|
306
|
+
cellChanges.push({
|
|
307
|
+
sheetId: ctx.currentSheetId,
|
|
308
|
+
path: ["celldata"],
|
|
309
|
+
value: {
|
|
310
|
+
r: r + row_s,
|
|
311
|
+
c: c + col_s,
|
|
312
|
+
v: d[r + row_s][c + col_s]
|
|
313
|
+
},
|
|
314
|
+
key: "".concat(r + row_s, "_").concat(c + col_s),
|
|
315
|
+
type: "update"
|
|
316
|
+
});
|
|
294
317
|
if (hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])]) {
|
|
295
318
|
ctx.luckysheetfile[index].hyperlink["".concat(r + row_s, "_").concat(c + col_s)] = hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])];
|
|
296
319
|
}
|
|
@@ -344,5 +367,8 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
344
367
|
if (sheetIndex != null) {
|
|
345
368
|
ctx.luckysheetfile[sheetIndex].config = _.assign({}, cfg);
|
|
346
369
|
}
|
|
370
|
+
if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
371
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
372
|
+
}
|
|
347
373
|
jfrefreshgrid(ctx, d, range);
|
|
348
374
|
}
|
package/es/modules/rowcol.js
CHANGED
|
@@ -54,8 +54,63 @@ var refreshLocalMergeData = function refreshLocalMergeData(merge_new, file) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
+
var getMergeBounds = function getMergeBounds(mergeMap) {
|
|
58
|
+
if (!mergeMap) return null;
|
|
59
|
+
var minR = Infinity;
|
|
60
|
+
var minC = Infinity;
|
|
61
|
+
var maxR = -Infinity;
|
|
62
|
+
var maxC = -Infinity;
|
|
63
|
+
Object.values(mergeMap).forEach(function (mc) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (!mc) return;
|
|
66
|
+
var r = Number(mc.r);
|
|
67
|
+
var c = Number(mc.c);
|
|
68
|
+
var rs = Number((_a = mc.rs) !== null && _a !== void 0 ? _a : 1);
|
|
69
|
+
var cs = Number((_b = mc.cs) !== null && _b !== void 0 ? _b : 1);
|
|
70
|
+
if (!Number.isFinite(r) || !Number.isFinite(c)) return;
|
|
71
|
+
minR = Math.min(minR, r);
|
|
72
|
+
minC = Math.min(minC, c);
|
|
73
|
+
maxR = Math.max(maxR, r + Math.max(1, rs) - 1);
|
|
74
|
+
maxC = Math.max(maxC, c + Math.max(1, cs) - 1);
|
|
75
|
+
});
|
|
76
|
+
if (minR === Infinity) return null;
|
|
77
|
+
return {
|
|
78
|
+
minR: minR,
|
|
79
|
+
minC: minC,
|
|
80
|
+
maxR: maxR,
|
|
81
|
+
maxC: maxC
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2, c1, c2) {
|
|
85
|
+
var _a, _b, _c, _d;
|
|
86
|
+
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) return;
|
|
87
|
+
if (!d || !Array.isArray(d) || d.length === 0) return;
|
|
88
|
+
var rowEnd = Math.min(r2, d.length - 1);
|
|
89
|
+
var colEnd = Math.min(c2, ((_c = (_b = d[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) - 1);
|
|
90
|
+
var rowStart = Math.max(0, r1);
|
|
91
|
+
var colStart = Math.max(0, c1);
|
|
92
|
+
if (rowStart > rowEnd || colStart > colEnd) return;
|
|
93
|
+
var changes = [];
|
|
94
|
+
for (var r = rowStart; r <= rowEnd; r += 1) {
|
|
95
|
+
var row = d[r] || [];
|
|
96
|
+
for (var c = colStart; c <= colEnd; c += 1) {
|
|
97
|
+
changes.push({
|
|
98
|
+
sheetId: sheetId,
|
|
99
|
+
path: ["celldata"],
|
|
100
|
+
value: {
|
|
101
|
+
r: r,
|
|
102
|
+
c: c,
|
|
103
|
+
v: (_d = row === null || row === void 0 ? void 0 : row[c]) !== null && _d !== void 0 ? _d : null
|
|
104
|
+
},
|
|
105
|
+
key: "".concat(r, "_").concat(c),
|
|
106
|
+
type: "update"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
111
|
+
};
|
|
57
112
|
export function insertRowCol(ctx, op, changeSelection) {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
113
|
+
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;
|
|
59
114
|
if (changeSelection === void 0) {
|
|
60
115
|
changeSelection = true;
|
|
61
116
|
}
|
|
@@ -1020,9 +1075,19 @@ export function insertRowCol(ctx, op, changeSelection) {
|
|
|
1020
1075
|
}
|
|
1021
1076
|
}
|
|
1022
1077
|
refreshLocalMergeData(merge_new, file);
|
|
1078
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1079
|
+
if (type === "row") {
|
|
1080
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1081
|
+
var startR = mergeBounds ? Math.min(baseStart, mergeBounds.minR) : baseStart;
|
|
1082
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_y = (_x = d[0]) === null || _x === void 0 ? void 0 : _x.length) !== null && _y !== void 0 ? _y : 1) - 1);
|
|
1083
|
+
} else {
|
|
1084
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1085
|
+
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1086
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_0 = (_z = d[0]) === null || _z === void 0 ? void 0 : _z.length) !== null && _0 !== void 0 ? _0 : 1) - 1);
|
|
1087
|
+
}
|
|
1023
1088
|
}
|
|
1024
1089
|
export function deleteRowCol(ctx, op) {
|
|
1025
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1090
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1026
1091
|
var type = op.type;
|
|
1027
1092
|
var start = op.start,
|
|
1028
1093
|
end = op.end,
|
|
@@ -1742,6 +1807,14 @@ export function deleteRowCol(ctx, op) {
|
|
|
1742
1807
|
file.dataVerification = newDataVerification;
|
|
1743
1808
|
file.hyperlink = newHyperlink;
|
|
1744
1809
|
refreshLocalMergeData(merge_new, file);
|
|
1810
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1811
|
+
if (type === "row") {
|
|
1812
|
+
var startR = mergeBounds ? Math.min(start, mergeBounds.minR) : start;
|
|
1813
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_s = (_r = d[0]) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 1) - 1);
|
|
1814
|
+
} else {
|
|
1815
|
+
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1816
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_u = (_t = d[0]) === null || _t === void 0 ? void 0 : _t.length) !== null && _u !== void 0 ? _u : 1) - 1);
|
|
1817
|
+
}
|
|
1745
1818
|
if (file.id === ctx.currentSheetId) {
|
|
1746
1819
|
ctx.config = cfg;
|
|
1747
1820
|
} else {}
|
|
@@ -257,7 +257,7 @@ export function onSearchDialogMoveEnd(globalCache) {
|
|
|
257
257
|
_.set(globalCache, "searchDialog.moveProps", undefined);
|
|
258
258
|
}
|
|
259
259
|
export function replace(ctx, searchText, replaceText, checkModes) {
|
|
260
|
-
var _a, _b;
|
|
260
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
261
261
|
var findAndReplace = locale(ctx).findAndReplace;
|
|
262
262
|
var allowEdit = isAllowEdit(ctx);
|
|
263
263
|
if (!allowEdit) {
|
|
@@ -304,6 +304,19 @@ export function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
304
304
|
c = searchIndexArr[count].c;
|
|
305
305
|
var v = replaceText;
|
|
306
306
|
setCellValue(ctx, r, c, d, v);
|
|
307
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
308
|
+
ctx.hooks.updateCellYdoc([{
|
|
309
|
+
sheetId: ctx.currentSheetId,
|
|
310
|
+
path: ["celldata"],
|
|
311
|
+
value: {
|
|
312
|
+
r: r,
|
|
313
|
+
c: c,
|
|
314
|
+
v: (_e = (_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) !== null && _e !== void 0 ? _e : null
|
|
315
|
+
},
|
|
316
|
+
key: "".concat(r, "_").concat(c),
|
|
317
|
+
type: "update"
|
|
318
|
+
}]);
|
|
319
|
+
}
|
|
307
320
|
} else {
|
|
308
321
|
var reg = void 0;
|
|
309
322
|
if (checkModes.caseCheck) {
|
|
@@ -315,6 +328,19 @@ export function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
315
328
|
c = searchIndexArr[count].c;
|
|
316
329
|
var v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
|
|
317
330
|
setCellValue(ctx, r, c, d, v);
|
|
331
|
+
if ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc) {
|
|
332
|
+
ctx.hooks.updateCellYdoc([{
|
|
333
|
+
sheetId: ctx.currentSheetId,
|
|
334
|
+
path: ["celldata"],
|
|
335
|
+
value: {
|
|
336
|
+
r: r,
|
|
337
|
+
c: c,
|
|
338
|
+
v: (_h = (_g = d === null || d === void 0 ? void 0 : d[r]) === null || _g === void 0 ? void 0 : _g[c]) !== null && _h !== void 0 ? _h : null
|
|
339
|
+
},
|
|
340
|
+
key: "".concat(r, "_").concat(c),
|
|
341
|
+
type: "update"
|
|
342
|
+
}]);
|
|
343
|
+
}
|
|
318
344
|
}
|
|
319
345
|
ctx.luckysheet_select_save = normalizeSelection(ctx, [{
|
|
320
346
|
row: [r, r],
|
|
@@ -324,7 +350,7 @@ export function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
324
350
|
return null;
|
|
325
351
|
}
|
|
326
352
|
export function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
327
|
-
var _a;
|
|
353
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
328
354
|
var findAndReplace = locale(ctx).findAndReplace;
|
|
329
355
|
var allowEdit = isAllowEdit(ctx);
|
|
330
356
|
if (!allowEdit) {
|
|
@@ -348,6 +374,7 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
348
374
|
return findAndReplace.noReplceTip;
|
|
349
375
|
}
|
|
350
376
|
var d = flowdata;
|
|
377
|
+
var cellChanges = [];
|
|
351
378
|
var replaceCount = 0;
|
|
352
379
|
if (checkModes.wordCheck) {
|
|
353
380
|
for (var i = 0; i < searchIndexArr.length; i += 1) {
|
|
@@ -355,6 +382,19 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
355
382
|
var c = searchIndexArr[i].c;
|
|
356
383
|
var v = replaceText;
|
|
357
384
|
setCellValue(ctx, r, c, d, v);
|
|
385
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
386
|
+
cellChanges.push({
|
|
387
|
+
sheetId: ctx.currentSheetId,
|
|
388
|
+
path: ["celldata"],
|
|
389
|
+
value: {
|
|
390
|
+
r: r,
|
|
391
|
+
c: c,
|
|
392
|
+
v: (_d = (_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) !== null && _d !== void 0 ? _d : null
|
|
393
|
+
},
|
|
394
|
+
key: "".concat(r, "_").concat(c),
|
|
395
|
+
type: "update"
|
|
396
|
+
});
|
|
397
|
+
}
|
|
358
398
|
range.push({
|
|
359
399
|
row: [r, r],
|
|
360
400
|
column: [c, c]
|
|
@@ -373,6 +413,19 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
373
413
|
var c = searchIndexArr[i].c;
|
|
374
414
|
var v = valueShowEs(r, c, d).toString().replace(reg, replaceText);
|
|
375
415
|
setCellValue(ctx, r, c, d, v);
|
|
416
|
+
if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
|
|
417
|
+
cellChanges.push({
|
|
418
|
+
sheetId: ctx.currentSheetId,
|
|
419
|
+
path: ["celldata"],
|
|
420
|
+
value: {
|
|
421
|
+
r: r,
|
|
422
|
+
c: c,
|
|
423
|
+
v: (_g = (_f = d === null || d === void 0 ? void 0 : d[r]) === null || _f === void 0 ? void 0 : _f[c]) !== null && _g !== void 0 ? _g : null
|
|
424
|
+
},
|
|
425
|
+
key: "".concat(r, "_").concat(c),
|
|
426
|
+
type: "update"
|
|
427
|
+
});
|
|
428
|
+
}
|
|
376
429
|
range.push({
|
|
377
430
|
row: [r, r],
|
|
378
431
|
column: [c, c]
|
|
@@ -380,6 +433,9 @@ export function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
380
433
|
replaceCount += 1;
|
|
381
434
|
}
|
|
382
435
|
}
|
|
436
|
+
if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
437
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
438
|
+
}
|
|
383
439
|
ctx.luckysheet_select_save = normalizeSelection(ctx, range);
|
|
384
440
|
var succeedInfo = replaceHtml(findAndReplace.successTip, {
|
|
385
441
|
xlength: replaceCount
|