@fileverse-dev/fortune-core 1.3.10 → 1.3.11-mixed
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 +74 -37
- package/es/events/mouse.js +1 -0
- package/es/events/paste.js +124 -56
- package/es/locale/en.d.ts +3 -0
- package/es/locale/en.js +3 -0
- package/es/locale/es.d.ts +3 -0
- package/es/locale/es.js +3 -0
- package/es/locale/hi.d.ts +3 -0
- package/es/locale/hi.js +3 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/zh.d.ts +3 -0
- package/es/locale/zh.js +3 -0
- package/es/locale/zh_tw.d.ts +3 -0
- package/es/locale/zh_tw.js +3 -0
- package/es/modules/ConditionFormat.js +26 -0
- 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/format.js +12 -7
- 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/modules/validation.js +6 -3
- package/es/settings.d.ts +5 -0
- package/es/types.d.ts +2 -0
- package/lib/api/range.js +20 -0
- package/lib/api/sheet.js +29 -1
- package/lib/events/keyboard.js +74 -37
- package/lib/events/mouse.js +1 -0
- package/lib/events/paste.js +122 -54
- package/lib/locale/en.d.ts +3 -0
- package/lib/locale/en.js +3 -0
- package/lib/locale/es.d.ts +3 -0
- package/lib/locale/es.js +3 -0
- package/lib/locale/hi.d.ts +3 -0
- package/lib/locale/hi.js +3 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/zh.d.ts +3 -0
- package/lib/locale/zh.js +3 -0
- package/lib/locale/zh_tw.d.ts +3 -0
- package/lib/locale/zh_tw.js +3 -0
- package/lib/modules/ConditionFormat.js +26 -0
- 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/format.js +12 -7
- 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/modules/validation.js +6 -3
- package/lib/settings.d.ts +5 -0
- package/lib/types.d.ts +2 -0
- package/package.json +1 -1
package/lib/modules/hyperlink.js
CHANGED
|
@@ -57,7 +57,7 @@ function getCellHyperlink(ctx, r, c) {
|
|
|
57
57
|
return undefined;
|
|
58
58
|
}
|
|
59
59
|
function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
60
|
-
var _a, _b, _c;
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
61
|
var applyToSelection = (options === null || options === void 0 ? void 0 : options.applyToSelection) && (options === null || options === void 0 ? void 0 : options.cellInput);
|
|
62
62
|
var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
63
63
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
@@ -77,8 +77,30 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
|
77
77
|
id: ctx.currentSheetId
|
|
78
78
|
};
|
|
79
79
|
flowdata[r][c] = cell;
|
|
80
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
81
|
+
ctx.hooks.updateCellYdoc([{
|
|
82
|
+
sheetId: ctx.currentSheetId,
|
|
83
|
+
path: ["hyperlink"],
|
|
84
|
+
key: "".concat(r, "_").concat(c),
|
|
85
|
+
value: {
|
|
86
|
+
linkType: linkType,
|
|
87
|
+
linkAddress: linkAddress
|
|
88
|
+
},
|
|
89
|
+
type: "update"
|
|
90
|
+
}, {
|
|
91
|
+
sheetId: ctx.currentSheetId,
|
|
92
|
+
path: ["celldata"],
|
|
93
|
+
value: {
|
|
94
|
+
r: r,
|
|
95
|
+
c: c,
|
|
96
|
+
v: cell
|
|
97
|
+
},
|
|
98
|
+
key: "".concat(r, "_").concat(c),
|
|
99
|
+
type: "update"
|
|
100
|
+
}]);
|
|
101
|
+
}
|
|
80
102
|
}
|
|
81
|
-
var offsets = (
|
|
103
|
+
var offsets = (_b = ctx.linkCard) === null || _b === void 0 ? void 0 : _b.selectionOffsets;
|
|
82
104
|
if (offsets) {
|
|
83
105
|
(0, _cursor.setSelectionByCharacterOffset)(options.cellInput, offsets.start, offsets.end);
|
|
84
106
|
}
|
|
@@ -107,8 +129,8 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
|
107
129
|
};
|
|
108
130
|
flowdata[r][c] = cell;
|
|
109
131
|
ctx.linkCard = undefined;
|
|
110
|
-
if ((
|
|
111
|
-
(
|
|
132
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
133
|
+
(_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc([{
|
|
112
134
|
sheetId: ctx.currentSheetId,
|
|
113
135
|
path: ["celldata"],
|
|
114
136
|
value: {
|
|
@@ -123,11 +145,12 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
|
123
145
|
}
|
|
124
146
|
}
|
|
125
147
|
function removeHyperlink(ctx, r, c) {
|
|
126
|
-
var _a, _b, _c;
|
|
148
|
+
var _a, _b, _c, _d;
|
|
127
149
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
128
150
|
if (!allowEdit) return;
|
|
129
151
|
var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
130
152
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
153
|
+
var updatedCell = null;
|
|
131
154
|
if (flowdata != null && sheetIndex != null) {
|
|
132
155
|
var hyperlink = _lodash.default.omit(ctx.luckysheetfile[sheetIndex].hyperlink, "".concat(r, "_").concat(c));
|
|
133
156
|
_lodash.default.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
|
|
@@ -136,9 +159,33 @@ function removeHyperlink(ctx, r, c) {
|
|
|
136
159
|
(_a = flowdata[r][c]) === null || _a === void 0 ? true : delete _a.hl;
|
|
137
160
|
(_b = flowdata[r][c]) === null || _b === void 0 ? true : delete _b.un;
|
|
138
161
|
(_c = flowdata[r][c]) === null || _c === void 0 ? true : delete _c.fc;
|
|
162
|
+
updatedCell = flowdata[r][c];
|
|
139
163
|
}
|
|
140
164
|
}
|
|
141
165
|
ctx.linkCard = undefined;
|
|
166
|
+
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc) {
|
|
167
|
+
var changes = [{
|
|
168
|
+
sheetId: ctx.currentSheetId,
|
|
169
|
+
path: ["hyperlink"],
|
|
170
|
+
key: "".concat(r, "_").concat(c),
|
|
171
|
+
value: null,
|
|
172
|
+
type: "delete"
|
|
173
|
+
}];
|
|
174
|
+
if (updatedCell != null) {
|
|
175
|
+
changes.push({
|
|
176
|
+
sheetId: ctx.currentSheetId,
|
|
177
|
+
path: ["celldata"],
|
|
178
|
+
value: {
|
|
179
|
+
r: r,
|
|
180
|
+
c: c,
|
|
181
|
+
v: updatedCell
|
|
182
|
+
},
|
|
183
|
+
key: "".concat(r, "_").concat(c),
|
|
184
|
+
type: "update"
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
188
|
+
}
|
|
142
189
|
}
|
|
143
190
|
function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
|
|
144
191
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
package/lib/modules/merge.js
CHANGED
|
@@ -9,7 +9,7 @@ var _utils = require("../utils");
|
|
|
9
9
|
var _inlineString = require("./inline-string");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
function mergeCells(ctx, sheetId, ranges, type) {
|
|
12
|
-
var _a, _b, _c;
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
13
|
var idx = (0, _utils.getSheetIndex)(ctx, sheetId);
|
|
14
14
|
if (idx == null) return;
|
|
15
15
|
var sheet = ctx.luckysheetfile[idx];
|
|
@@ -18,6 +18,7 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
18
18
|
cfg.merge = {};
|
|
19
19
|
}
|
|
20
20
|
var d = sheet.data;
|
|
21
|
+
var cellChanges = [];
|
|
21
22
|
if (type === "merge-cancel") {
|
|
22
23
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
23
24
|
var range = ranges[i];
|
|
@@ -47,6 +48,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
47
48
|
delete cell_clone.f;
|
|
48
49
|
delete cell_clone.spl;
|
|
49
50
|
d[r][c] = cell_clone;
|
|
51
|
+
cellChanges.push({
|
|
52
|
+
sheetId: sheetId,
|
|
53
|
+
path: ["celldata"],
|
|
54
|
+
value: {
|
|
55
|
+
r: r,
|
|
56
|
+
c: c,
|
|
57
|
+
v: d[r][c]
|
|
58
|
+
},
|
|
59
|
+
key: "".concat(r, "_").concat(c),
|
|
60
|
+
type: "update"
|
|
61
|
+
});
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
}
|
|
@@ -99,6 +111,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
99
111
|
delete cell_clone.f;
|
|
100
112
|
delete cell_clone.spl;
|
|
101
113
|
d[r][c] = cell_clone;
|
|
114
|
+
cellChanges.push({
|
|
115
|
+
sheetId: sheetId,
|
|
116
|
+
path: ["celldata"],
|
|
117
|
+
value: {
|
|
118
|
+
r: r,
|
|
119
|
+
c: c,
|
|
120
|
+
v: d[r][c]
|
|
121
|
+
},
|
|
122
|
+
key: "".concat(r, "_").concat(c),
|
|
123
|
+
type: "update"
|
|
124
|
+
});
|
|
102
125
|
}
|
|
103
126
|
}
|
|
104
127
|
}
|
|
@@ -130,6 +153,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
130
153
|
c: c1
|
|
131
154
|
}
|
|
132
155
|
};
|
|
156
|
+
cellChanges.push({
|
|
157
|
+
sheetId: sheetId,
|
|
158
|
+
path: ["celldata"],
|
|
159
|
+
value: {
|
|
160
|
+
r: r,
|
|
161
|
+
c: c,
|
|
162
|
+
v: d[r][c]
|
|
163
|
+
},
|
|
164
|
+
key: "".concat(r, "_").concat(c),
|
|
165
|
+
type: "update"
|
|
166
|
+
});
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
169
|
d[r1][c1] = fv;
|
|
@@ -141,6 +175,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
141
175
|
rs: r2 - r1 + 1,
|
|
142
176
|
cs: c2 - c1 + 1
|
|
143
177
|
};
|
|
178
|
+
cellChanges.push({
|
|
179
|
+
sheetId: sheetId,
|
|
180
|
+
path: ["celldata"],
|
|
181
|
+
value: {
|
|
182
|
+
r: r1,
|
|
183
|
+
c: c1,
|
|
184
|
+
v: d[r1][c1]
|
|
185
|
+
},
|
|
186
|
+
key: "".concat(r1, "_").concat(c1),
|
|
187
|
+
type: "update"
|
|
188
|
+
});
|
|
144
189
|
cfg.merge["".concat(r1, "_").concat(c1)] = {
|
|
145
190
|
r: r1,
|
|
146
191
|
c: c1,
|
|
@@ -163,6 +208,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
163
208
|
c: c
|
|
164
209
|
}
|
|
165
210
|
};
|
|
211
|
+
cellChanges.push({
|
|
212
|
+
sheetId: sheetId,
|
|
213
|
+
path: ["celldata"],
|
|
214
|
+
value: {
|
|
215
|
+
r: r,
|
|
216
|
+
c: c,
|
|
217
|
+
v: d[r][c]
|
|
218
|
+
},
|
|
219
|
+
key: "".concat(r, "_").concat(c),
|
|
220
|
+
type: "update"
|
|
221
|
+
});
|
|
166
222
|
}
|
|
167
223
|
d[r1][c] = fv;
|
|
168
224
|
var a = d[r1][c];
|
|
@@ -173,6 +229,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
173
229
|
rs: r2 - r1 + 1,
|
|
174
230
|
cs: 1
|
|
175
231
|
};
|
|
232
|
+
cellChanges.push({
|
|
233
|
+
sheetId: sheetId,
|
|
234
|
+
path: ["celldata"],
|
|
235
|
+
value: {
|
|
236
|
+
r: r1,
|
|
237
|
+
c: c,
|
|
238
|
+
v: d[r1][c]
|
|
239
|
+
},
|
|
240
|
+
key: "".concat(r1, "_").concat(c),
|
|
241
|
+
type: "update"
|
|
242
|
+
});
|
|
176
243
|
cfg.merge["".concat(r1, "_").concat(c)] = {
|
|
177
244
|
r: r1,
|
|
178
245
|
c: c,
|
|
@@ -196,6 +263,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
196
263
|
c: c1
|
|
197
264
|
}
|
|
198
265
|
};
|
|
266
|
+
cellChanges.push({
|
|
267
|
+
sheetId: sheetId,
|
|
268
|
+
path: ["celldata"],
|
|
269
|
+
value: {
|
|
270
|
+
r: r,
|
|
271
|
+
c: c,
|
|
272
|
+
v: d[r][c]
|
|
273
|
+
},
|
|
274
|
+
key: "".concat(r, "_").concat(c),
|
|
275
|
+
type: "update"
|
|
276
|
+
});
|
|
199
277
|
}
|
|
200
278
|
d[r][c1] = fv;
|
|
201
279
|
var a = d[r][c1];
|
|
@@ -206,6 +284,17 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
206
284
|
rs: 1,
|
|
207
285
|
cs: c2 - c1 + 1
|
|
208
286
|
};
|
|
287
|
+
cellChanges.push({
|
|
288
|
+
sheetId: sheetId,
|
|
289
|
+
path: ["celldata"],
|
|
290
|
+
value: {
|
|
291
|
+
r: r,
|
|
292
|
+
c: c1,
|
|
293
|
+
v: d[r][c1]
|
|
294
|
+
},
|
|
295
|
+
key: "".concat(r, "_").concat(c1),
|
|
296
|
+
type: "update"
|
|
297
|
+
});
|
|
209
298
|
cfg.merge["".concat(r, "_").concat(c1)] = {
|
|
210
299
|
r: r,
|
|
211
300
|
c: c1,
|
|
@@ -216,6 +305,9 @@ function mergeCells(ctx, sheetId, ranges, type) {
|
|
|
216
305
|
}
|
|
217
306
|
}
|
|
218
307
|
}
|
|
308
|
+
if (cellChanges.length > 0 && ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc)) {
|
|
309
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
310
|
+
}
|
|
219
311
|
sheet.config = cfg;
|
|
220
312
|
if (sheet.id === ctx.currentSheetId) {
|
|
221
313
|
ctx.config = cfg;
|
package/lib/modules/moveCells.js
CHANGED
|
@@ -131,7 +131,7 @@ function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
|
|
|
131
131
|
ele.style.display = "block";
|
|
132
132
|
}
|
|
133
133
|
function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
|
|
134
|
-
var _a, _b, _c, _d;
|
|
134
|
+
var _a, _b, _c, _d, _e;
|
|
135
135
|
if (!ctx.luckysheet_cell_selected_move) return;
|
|
136
136
|
ctx.luckysheet_cell_selected_move = false;
|
|
137
137
|
var ele = document.getElementById("fortune-cell-selected-move");
|
|
@@ -140,17 +140,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
|
|
|
140
140
|
globalCache.dragCellStartPos = undefined;
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
var
|
|
144
|
-
x =
|
|
145
|
-
y =
|
|
143
|
+
var _f = (0, _location.mousePosition)(e.pageX, e.pageY, ctx),
|
|
144
|
+
x = _f[0],
|
|
145
|
+
y = _f[1];
|
|
146
146
|
var rect = container.getBoundingClientRect();
|
|
147
147
|
var winH = rect.height - 20 * ctx.zoomRatio;
|
|
148
148
|
var winW = rect.width - 60 * ctx.zoomRatio;
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
row_index =
|
|
152
|
-
|
|
153
|
-
col_index =
|
|
149
|
+
var _g = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
|
|
150
|
+
_h = _g.row,
|
|
151
|
+
row_index = _h[2],
|
|
152
|
+
_j = _g.column,
|
|
153
|
+
col_index = _j[2];
|
|
154
154
|
var allowEdit = (0, _utils.isAllowEdit)(ctx, [{
|
|
155
155
|
row: [row_index, row_index],
|
|
156
156
|
column: [col_index, col_index]
|
|
@@ -200,6 +200,7 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
|
|
|
200
200
|
throw new Error(locale_drag.noMerge);
|
|
201
201
|
}
|
|
202
202
|
var borderInfoCompute = (0, _border.getBorderInfoCompute)(ctx, ctx.currentSheetId);
|
|
203
|
+
var cellChanges = [];
|
|
203
204
|
var hyperLinkList = {};
|
|
204
205
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
205
206
|
for (var r = last.row[0]; r <= last.row[1]; r += 1) {
|
|
@@ -212,6 +213,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
|
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
d[r][c] = null;
|
|
216
|
+
cellChanges.push({
|
|
217
|
+
sheetId: ctx.currentSheetId,
|
|
218
|
+
path: ["celldata"],
|
|
219
|
+
value: {
|
|
220
|
+
r: r,
|
|
221
|
+
c: c,
|
|
222
|
+
v: null
|
|
223
|
+
},
|
|
224
|
+
key: "".concat(r, "_").concat(c),
|
|
225
|
+
type: "update"
|
|
226
|
+
});
|
|
215
227
|
if ((_a = ctx.luckysheetfile[index].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) {
|
|
216
228
|
hyperLinkList["".concat(r, "_").concat(c)] = (_b = ctx.luckysheetfile[index].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(r, "_").concat(c)];
|
|
217
229
|
(_c = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].hyperlink) === null || _c === void 0 ? true : delete _c["".concat(r, "_").concat(c)];
|
|
@@ -300,6 +312,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
|
|
|
300
312
|
}
|
|
301
313
|
}
|
|
302
314
|
d[r + row_s][c + col_s] = value;
|
|
315
|
+
cellChanges.push({
|
|
316
|
+
sheetId: ctx.currentSheetId,
|
|
317
|
+
path: ["celldata"],
|
|
318
|
+
value: {
|
|
319
|
+
r: r + row_s,
|
|
320
|
+
c: c + col_s,
|
|
321
|
+
v: d[r + row_s][c + col_s]
|
|
322
|
+
},
|
|
323
|
+
key: "".concat(r + row_s, "_").concat(c + col_s),
|
|
324
|
+
type: "update"
|
|
325
|
+
});
|
|
303
326
|
if (hyperLinkList === null || hyperLinkList === void 0 ? void 0 : hyperLinkList["".concat(r + last.row[0], "_").concat(c + last.column[0])]) {
|
|
304
327
|
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])];
|
|
305
328
|
}
|
|
@@ -353,5 +376,8 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
|
|
|
353
376
|
if (sheetIndex != null) {
|
|
354
377
|
ctx.luckysheetfile[sheetIndex].config = _lodash.default.assign({}, cfg);
|
|
355
378
|
}
|
|
379
|
+
if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
380
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
381
|
+
}
|
|
356
382
|
(0, _refresh.jfrefreshgrid)(ctx, d, range);
|
|
357
383
|
}
|
package/lib/modules/rowcol.js
CHANGED
|
@@ -67,8 +67,63 @@ var refreshLocalMergeData = function refreshLocalMergeData(merge_new, file) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
|
+
var getMergeBounds = function getMergeBounds(mergeMap) {
|
|
71
|
+
if (!mergeMap) return null;
|
|
72
|
+
var minR = Infinity;
|
|
73
|
+
var minC = Infinity;
|
|
74
|
+
var maxR = -Infinity;
|
|
75
|
+
var maxC = -Infinity;
|
|
76
|
+
Object.values(mergeMap).forEach(function (mc) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
if (!mc) return;
|
|
79
|
+
var r = Number(mc.r);
|
|
80
|
+
var c = Number(mc.c);
|
|
81
|
+
var rs = Number((_a = mc.rs) !== null && _a !== void 0 ? _a : 1);
|
|
82
|
+
var cs = Number((_b = mc.cs) !== null && _b !== void 0 ? _b : 1);
|
|
83
|
+
if (!Number.isFinite(r) || !Number.isFinite(c)) return;
|
|
84
|
+
minR = Math.min(minR, r);
|
|
85
|
+
minC = Math.min(minC, c);
|
|
86
|
+
maxR = Math.max(maxR, r + Math.max(1, rs) - 1);
|
|
87
|
+
maxC = Math.max(maxC, c + Math.max(1, cs) - 1);
|
|
88
|
+
});
|
|
89
|
+
if (minR === Infinity) return null;
|
|
90
|
+
return {
|
|
91
|
+
minR: minR,
|
|
92
|
+
minC: minC,
|
|
93
|
+
maxR: maxR,
|
|
94
|
+
maxC: maxC
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2, c1, c2) {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) return;
|
|
100
|
+
if (!d || !Array.isArray(d) || d.length === 0) return;
|
|
101
|
+
var rowEnd = Math.min(r2, d.length - 1);
|
|
102
|
+
var colEnd = Math.min(c2, ((_c = (_b = d[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) - 1);
|
|
103
|
+
var rowStart = Math.max(0, r1);
|
|
104
|
+
var colStart = Math.max(0, c1);
|
|
105
|
+
if (rowStart > rowEnd || colStart > colEnd) return;
|
|
106
|
+
var changes = [];
|
|
107
|
+
for (var r = rowStart; r <= rowEnd; r += 1) {
|
|
108
|
+
var row = d[r] || [];
|
|
109
|
+
for (var c = colStart; c <= colEnd; c += 1) {
|
|
110
|
+
changes.push({
|
|
111
|
+
sheetId: sheetId,
|
|
112
|
+
path: ["celldata"],
|
|
113
|
+
value: {
|
|
114
|
+
r: r,
|
|
115
|
+
c: c,
|
|
116
|
+
v: (_d = row === null || row === void 0 ? void 0 : row[c]) !== null && _d !== void 0 ? _d : null
|
|
117
|
+
},
|
|
118
|
+
key: "".concat(r, "_").concat(c),
|
|
119
|
+
type: "update"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
124
|
+
};
|
|
70
125
|
function insertRowCol(ctx, op, changeSelection) {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
126
|
+
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;
|
|
72
127
|
if (changeSelection === void 0) {
|
|
73
128
|
changeSelection = true;
|
|
74
129
|
}
|
|
@@ -1033,9 +1088,19 @@ function insertRowCol(ctx, op, changeSelection) {
|
|
|
1033
1088
|
}
|
|
1034
1089
|
}
|
|
1035
1090
|
refreshLocalMergeData(merge_new, file);
|
|
1091
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1092
|
+
if (type === "row") {
|
|
1093
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1094
|
+
var startR = mergeBounds ? Math.min(baseStart, mergeBounds.minR) : baseStart;
|
|
1095
|
+
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);
|
|
1096
|
+
} else {
|
|
1097
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1098
|
+
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1099
|
+
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);
|
|
1100
|
+
}
|
|
1036
1101
|
}
|
|
1037
1102
|
function deleteRowCol(ctx, op) {
|
|
1038
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1103
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1039
1104
|
var type = op.type;
|
|
1040
1105
|
var start = op.start,
|
|
1041
1106
|
end = op.end,
|
|
@@ -1755,6 +1820,14 @@ function deleteRowCol(ctx, op) {
|
|
|
1755
1820
|
file.dataVerification = newDataVerification;
|
|
1756
1821
|
file.hyperlink = newHyperlink;
|
|
1757
1822
|
refreshLocalMergeData(merge_new, file);
|
|
1823
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1824
|
+
if (type === "row") {
|
|
1825
|
+
var startR = mergeBounds ? Math.min(start, mergeBounds.minR) : start;
|
|
1826
|
+
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);
|
|
1827
|
+
} else {
|
|
1828
|
+
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1829
|
+
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);
|
|
1830
|
+
}
|
|
1758
1831
|
if (file.id === ctx.currentSheetId) {
|
|
1759
1832
|
ctx.config = cfg;
|
|
1760
1833
|
} else {}
|
|
@@ -271,7 +271,7 @@ function onSearchDialogMoveEnd(globalCache) {
|
|
|
271
271
|
_lodash.default.set(globalCache, "searchDialog.moveProps", undefined);
|
|
272
272
|
}
|
|
273
273
|
function replace(ctx, searchText, replaceText, checkModes) {
|
|
274
|
-
var _a, _b;
|
|
274
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
275
275
|
var findAndReplace = (0, _locale.locale)(ctx).findAndReplace;
|
|
276
276
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
277
277
|
if (!allowEdit) {
|
|
@@ -318,6 +318,19 @@ function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
318
318
|
c = searchIndexArr[count].c;
|
|
319
319
|
var v = replaceText;
|
|
320
320
|
(0, _cell.setCellValue)(ctx, r, c, d, v);
|
|
321
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
322
|
+
ctx.hooks.updateCellYdoc([{
|
|
323
|
+
sheetId: ctx.currentSheetId,
|
|
324
|
+
path: ["celldata"],
|
|
325
|
+
value: {
|
|
326
|
+
r: r,
|
|
327
|
+
c: c,
|
|
328
|
+
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
|
|
329
|
+
},
|
|
330
|
+
key: "".concat(r, "_").concat(c),
|
|
331
|
+
type: "update"
|
|
332
|
+
}]);
|
|
333
|
+
}
|
|
321
334
|
} else {
|
|
322
335
|
var reg = void 0;
|
|
323
336
|
if (checkModes.caseCheck) {
|
|
@@ -329,6 +342,19 @@ function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
329
342
|
c = searchIndexArr[count].c;
|
|
330
343
|
var v = (0, _format.valueShowEs)(r, c, d).toString().replace(reg, replaceText);
|
|
331
344
|
(0, _cell.setCellValue)(ctx, r, c, d, v);
|
|
345
|
+
if ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc) {
|
|
346
|
+
ctx.hooks.updateCellYdoc([{
|
|
347
|
+
sheetId: ctx.currentSheetId,
|
|
348
|
+
path: ["celldata"],
|
|
349
|
+
value: {
|
|
350
|
+
r: r,
|
|
351
|
+
c: c,
|
|
352
|
+
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
|
|
353
|
+
},
|
|
354
|
+
key: "".concat(r, "_").concat(c),
|
|
355
|
+
type: "update"
|
|
356
|
+
}]);
|
|
357
|
+
}
|
|
332
358
|
}
|
|
333
359
|
ctx.luckysheet_select_save = (0, _selection.normalizeSelection)(ctx, [{
|
|
334
360
|
row: [r, r],
|
|
@@ -338,7 +364,7 @@ function replace(ctx, searchText, replaceText, checkModes) {
|
|
|
338
364
|
return null;
|
|
339
365
|
}
|
|
340
366
|
function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
341
|
-
var _a;
|
|
367
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
342
368
|
var findAndReplace = (0, _locale.locale)(ctx).findAndReplace;
|
|
343
369
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
344
370
|
if (!allowEdit) {
|
|
@@ -362,6 +388,7 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
362
388
|
return findAndReplace.noReplceTip;
|
|
363
389
|
}
|
|
364
390
|
var d = flowdata;
|
|
391
|
+
var cellChanges = [];
|
|
365
392
|
var replaceCount = 0;
|
|
366
393
|
if (checkModes.wordCheck) {
|
|
367
394
|
for (var i = 0; i < searchIndexArr.length; i += 1) {
|
|
@@ -369,6 +396,19 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
369
396
|
var c = searchIndexArr[i].c;
|
|
370
397
|
var v = replaceText;
|
|
371
398
|
(0, _cell.setCellValue)(ctx, r, c, d, v);
|
|
399
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
400
|
+
cellChanges.push({
|
|
401
|
+
sheetId: ctx.currentSheetId,
|
|
402
|
+
path: ["celldata"],
|
|
403
|
+
value: {
|
|
404
|
+
r: r,
|
|
405
|
+
c: c,
|
|
406
|
+
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
|
|
407
|
+
},
|
|
408
|
+
key: "".concat(r, "_").concat(c),
|
|
409
|
+
type: "update"
|
|
410
|
+
});
|
|
411
|
+
}
|
|
372
412
|
range.push({
|
|
373
413
|
row: [r, r],
|
|
374
414
|
column: [c, c]
|
|
@@ -387,6 +427,19 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
387
427
|
var c = searchIndexArr[i].c;
|
|
388
428
|
var v = (0, _format.valueShowEs)(r, c, d).toString().replace(reg, replaceText);
|
|
389
429
|
(0, _cell.setCellValue)(ctx, r, c, d, v);
|
|
430
|
+
if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
|
|
431
|
+
cellChanges.push({
|
|
432
|
+
sheetId: ctx.currentSheetId,
|
|
433
|
+
path: ["celldata"],
|
|
434
|
+
value: {
|
|
435
|
+
r: r,
|
|
436
|
+
c: c,
|
|
437
|
+
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
|
|
438
|
+
},
|
|
439
|
+
key: "".concat(r, "_").concat(c),
|
|
440
|
+
type: "update"
|
|
441
|
+
});
|
|
442
|
+
}
|
|
390
443
|
range.push({
|
|
391
444
|
row: [r, r],
|
|
392
445
|
column: [c, c]
|
|
@@ -394,6 +447,9 @@ function replaceAll(ctx, searchText, replaceText, checkModes) {
|
|
|
394
447
|
replaceCount += 1;
|
|
395
448
|
}
|
|
396
449
|
}
|
|
450
|
+
if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
|
|
451
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
452
|
+
}
|
|
397
453
|
ctx.luckysheet_select_save = (0, _selection.normalizeSelection)(ctx, range);
|
|
398
454
|
var succeedInfo = (0, _utils.replaceHtml)(findAndReplace.successTip, {
|
|
399
455
|
xlength: replaceCount
|