@fileverse-dev/fortune-react 1.2.43 → 1.2.45
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/components/SheetOverlay/drag_and_drop/column-helpers.js +86 -51
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +87 -49
- package/es/components/Workbook/api.d.ts +4 -1
- package/es/components/Workbook/api.js +13 -1
- package/es/components/Workbook/index.d.ts +3 -0
- package/es/components/Workbook/index.js +1 -1
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +86 -51
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +87 -49
- package/lib/components/Workbook/api.d.ts +4 -1
- package/lib/components/Workbook/api.js +13 -1
- package/lib/components/Workbook/index.d.ts +3 -0
- package/lib/components/Workbook/index.js +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,9 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
30
30
|
context = _a.context,
|
|
31
31
|
setContext = _a.setContext,
|
|
32
32
|
refs = _a.refs;
|
|
33
|
+
var selectedColWidth = useRef(0);
|
|
34
|
+
var selectedSourceColRef = useRef([]);
|
|
35
|
+
var selectedTargetColRef = useRef([]);
|
|
33
36
|
var dragRef = useRef({
|
|
34
37
|
mouseDown: false,
|
|
35
38
|
startX: 0,
|
|
@@ -142,6 +145,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
142
145
|
});
|
|
143
146
|
if (selectedBlock) {
|
|
144
147
|
ghostWidthPx = Math.max(60, selectedBlock.col - selectedBlock.col_pre - 1);
|
|
148
|
+
selectedColWidth.current = ghostWidthPx;
|
|
145
149
|
var count = selectedBlock.c2 - selectedBlock.c1 + 1;
|
|
146
150
|
ghostLabel = count > 1 ? "".concat(count, " cols") : "Col ".concat(String.fromCharCode(65 + selectedBlock.c1));
|
|
147
151
|
} else {
|
|
@@ -150,6 +154,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
150
154
|
end = _a[1];
|
|
151
155
|
var sourceColWidth = end - pre - 1;
|
|
152
156
|
ghostWidthPx = Math.max(60, sourceColWidth);
|
|
157
|
+
selectedColWidth.current = ghostWidthPx;
|
|
153
158
|
}
|
|
154
159
|
el.style.width = "".concat(ghostWidthPx, "px");
|
|
155
160
|
el.textContent = ghostLabel;
|
|
@@ -183,28 +188,30 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
183
188
|
var dragOffset = Math.abs(ev.pageX - dragRef.current.startX);
|
|
184
189
|
if (!isDragActivated(host, dragOffset)) return;
|
|
185
190
|
var lineLeftPx = computeInsertionFromPageX(ev.pageX).lineLeftPx;
|
|
186
|
-
var ghostPosOffset =
|
|
191
|
+
var ghostPosOffset = 60;
|
|
192
|
+
var ghostFinalPos = dragRef.current.startX > ev.pageX ? lineLeftPx + ghostPosOffset : lineLeftPx - (selectedColWidth.current - ghostPosOffset);
|
|
187
193
|
if (dragRef.current.lineEl) {
|
|
188
194
|
dragRef.current.lineEl.style.left = "".concat(lineLeftPx, "px");
|
|
189
195
|
}
|
|
190
196
|
if (dragRef.current.ghostEl) {
|
|
191
|
-
dragRef.current.ghostEl.style.left = "".concat(
|
|
197
|
+
dragRef.current.ghostEl.style.left = "".concat(ghostFinalPos, "px");
|
|
192
198
|
}
|
|
193
199
|
};
|
|
194
200
|
var handleColumnDragEnd = function handleColumnDragEnd(ev) {
|
|
201
|
+
var _a, _b, _c;
|
|
195
202
|
if (!dragRef.current.mouseDown) return;
|
|
196
203
|
dragRef.current.mouseDown = false;
|
|
197
204
|
try {
|
|
198
205
|
document.body.style.userSelect = dragRef.current.prevUserSelect || "";
|
|
199
206
|
document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
|
|
200
|
-
} catch (
|
|
207
|
+
} catch (_d) {}
|
|
201
208
|
if (dragRef.current.active) {
|
|
202
209
|
var finalInsertionIndex_1 = computeInsertionFromPageX(ev.pageX).insertionIndex;
|
|
203
|
-
var sourceIndex_1 =
|
|
210
|
+
var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.column) === null || _c === void 0 ? void 0 : _c[0]) || 0;
|
|
204
211
|
var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
|
|
205
212
|
if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
|
|
206
213
|
setContext(function (draft) {
|
|
207
|
-
var _a, _b, _c, _d;
|
|
214
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
208
215
|
var _sheet = draft.luckysheetfile[sheetIdx_1];
|
|
209
216
|
if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
|
|
210
217
|
var rows = _sheet.data;
|
|
@@ -213,50 +220,81 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
213
220
|
if (sourceIndex_1 < 0 || sourceIndex_1 >= numCols) return;
|
|
214
221
|
var targetIndex = finalInsertionIndex_1;
|
|
215
222
|
if (targetIndex > sourceIndex_1) targetIndex -= 1;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (targetIndex < 0) targetIndex = 0;
|
|
221
|
-
if (targetIndex > row.length) targetIndex = row.length;
|
|
222
|
-
row.splice(targetIndex, 0, cellData);
|
|
223
|
+
var selectedColRange = ((_d = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.column) || [];
|
|
224
|
+
var selectedSourceCol = [];
|
|
225
|
+
for (var i = selectedColRange === null || selectedColRange === void 0 ? void 0 : selectedColRange[0]; i <= (selectedColRange === null || selectedColRange === void 0 ? void 0 : selectedColRange[1]); i += 1) {
|
|
226
|
+
selectedSourceCol.push(i);
|
|
223
227
|
}
|
|
228
|
+
var tempSelectedTargetCol = [];
|
|
229
|
+
selectedSourceCol.forEach(function (_, index) {
|
|
230
|
+
if (sourceIndex_1 < targetIndex) {
|
|
231
|
+
tempSelectedTargetCol.push(targetIndex - index);
|
|
232
|
+
} else {
|
|
233
|
+
tempSelectedTargetCol.push(targetIndex + index);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
var selectedTargetCol = (_e = __spreadArray([], tempSelectedTargetCol, true)) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) {
|
|
237
|
+
return a - b;
|
|
238
|
+
});
|
|
239
|
+
selectedSourceColRef.current = selectedSourceCol;
|
|
240
|
+
selectedTargetColRef.current = selectedTargetCol;
|
|
241
|
+
console.log("selectedSourceCol", selectedTargetCol);
|
|
242
|
+
selectedSourceCol.forEach(function () {
|
|
243
|
+
var adjustedSourceIndex = sourceIndex_1;
|
|
244
|
+
if (targetIndex < sourceIndex_1) {
|
|
245
|
+
adjustedSourceIndex = sourceIndex_1 + (selectedSourceCol.length - 1);
|
|
246
|
+
}
|
|
247
|
+
for (var j = 0; j < rows.length; j += 1) {
|
|
248
|
+
var row = rows[j];
|
|
249
|
+
if (!row || adjustedSourceIndex >= row.length) continue;
|
|
250
|
+
var cellData = row.splice(adjustedSourceIndex, 1)[0];
|
|
251
|
+
if (targetIndex < 0) targetIndex = 0;
|
|
252
|
+
if (targetIndex > row.length) targetIndex = row.length;
|
|
253
|
+
row.splice(targetIndex, 0, cellData);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
224
256
|
_sheet.data = rows;
|
|
225
257
|
updateContextWithSheetData(draft, _sheet.data);
|
|
226
258
|
var d = getFlowdata(draft);
|
|
227
259
|
d === null || d === void 0 ? void 0 : d.forEach(function (row) {
|
|
228
260
|
row.forEach(function (cell) {
|
|
229
261
|
if (cell) {
|
|
230
|
-
var
|
|
231
|
-
var targetColName_1 = numberToColumnName(targetIndex);
|
|
232
|
-
if (cell.f) {
|
|
233
|
-
cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
|
|
234
|
-
if (/^\d+$/.test(p1)) {
|
|
235
|
-
return "".concat(targetColName_1).concat(p1);
|
|
236
|
-
}
|
|
237
|
-
return match;
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
var otherAffectedCols = [];
|
|
262
|
+
var otherAffectedCols_1 = [];
|
|
241
263
|
if (sourceIndex_1 < targetIndex) {
|
|
242
|
-
|
|
243
|
-
|
|
264
|
+
var start = selectedSourceCol === null || selectedSourceCol === void 0 ? void 0 : selectedSourceCol[selectedSourceCol.length - 1];
|
|
265
|
+
var last = selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1];
|
|
266
|
+
for (var c = start + 1; c <= last; c += 1) {
|
|
267
|
+
otherAffectedCols_1.push({
|
|
244
268
|
source: numberToColumnName(c),
|
|
245
|
-
target: numberToColumnName(c -
|
|
269
|
+
target: numberToColumnName(c - selectedSourceCol.length)
|
|
246
270
|
});
|
|
247
271
|
}
|
|
272
|
+
selectedSourceCol.forEach(function (c, index) {
|
|
273
|
+
otherAffectedCols_1.push({
|
|
274
|
+
source: numberToColumnName(c),
|
|
275
|
+
target: numberToColumnName(selectedTargetCol[index])
|
|
276
|
+
});
|
|
277
|
+
});
|
|
248
278
|
} else if (sourceIndex_1 > targetIndex) {
|
|
249
|
-
|
|
250
|
-
|
|
279
|
+
var start = selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0];
|
|
280
|
+
var last = selectedSourceCol === null || selectedSourceCol === void 0 ? void 0 : selectedSourceCol[0];
|
|
281
|
+
for (var c = start; c < last; c += 1) {
|
|
282
|
+
otherAffectedCols_1.push({
|
|
251
283
|
source: numberToColumnName(c),
|
|
252
|
-
target: numberToColumnName(c +
|
|
284
|
+
target: numberToColumnName(c + selectedSourceCol.length)
|
|
253
285
|
});
|
|
254
286
|
}
|
|
287
|
+
selectedSourceCol.forEach(function (c, index) {
|
|
288
|
+
otherAffectedCols_1.push({
|
|
289
|
+
source: numberToColumnName(c),
|
|
290
|
+
target: numberToColumnName(selectedTargetCol[index])
|
|
291
|
+
});
|
|
292
|
+
});
|
|
255
293
|
}
|
|
256
294
|
if (cell.f) {
|
|
257
295
|
var formula_1 = cell.f;
|
|
258
296
|
var replacements_1 = [];
|
|
259
|
-
|
|
297
|
+
otherAffectedCols_1.forEach(function (col) {
|
|
260
298
|
var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
|
|
261
299
|
var match;
|
|
262
300
|
while ((match = regex.exec(formula_1)) !== null) {
|
|
@@ -290,38 +328,35 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
290
328
|
if (colRow.length !== 2) return;
|
|
291
329
|
var presentcol = parseInt(colRow[1], 10);
|
|
292
330
|
var updatedCol = presentcol;
|
|
293
|
-
if (presentcol
|
|
294
|
-
|
|
331
|
+
if (selectedSourceCol.includes(presentcol)) {
|
|
332
|
+
var index = selectedSourceCol.indexOf(presentcol);
|
|
333
|
+
var target = selectedTargetCol[index];
|
|
334
|
+
updatedCol = target;
|
|
295
335
|
} else if (presentcol > sourceIndex_1 && presentcol < targetIndex) {
|
|
296
|
-
updatedCol -=
|
|
336
|
+
updatedCol -= selectedSourceCol.length;
|
|
297
337
|
} else if (presentcol < sourceIndex_1 && presentcol >= targetIndex) {
|
|
298
|
-
updatedCol +=
|
|
338
|
+
updatedCol += selectedSourceCol.length;
|
|
299
339
|
}
|
|
300
340
|
newDataVerification_1["".concat(colRow[0], "_").concat(updatedCol)] = itemData;
|
|
301
341
|
});
|
|
302
342
|
_sheet.dataVerification = newDataVerification_1;
|
|
303
343
|
}
|
|
304
|
-
(
|
|
305
|
-
if (item.c
|
|
306
|
-
item.c
|
|
344
|
+
(_f = _sheet.calcChain) === null || _f === void 0 ? void 0 : _f.forEach(function (item) {
|
|
345
|
+
if (selectedSourceCol.includes(item.c)) {
|
|
346
|
+
var index = selectedSourceCol.indexOf(item.c);
|
|
347
|
+
item.c = selectedTargetCol[index];
|
|
307
348
|
} else if (item.c > sourceIndex_1 && item.c < targetIndex) {
|
|
308
|
-
item.c -=
|
|
349
|
+
item.c -= selectedSourceCol.length;
|
|
309
350
|
} else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
|
|
310
|
-
item.c +=
|
|
351
|
+
item.c += selectedSourceCol.length;
|
|
311
352
|
}
|
|
312
353
|
});
|
|
313
|
-
(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (sel_1 && sel_1[0]) {
|
|
320
|
-
sel_1[0].column = [targetIndex, targetIndex];
|
|
321
|
-
}
|
|
322
|
-
setContext(function (draftCtx) {
|
|
323
|
-
console.log("after update", sel_1);
|
|
324
|
-
api.setSelection(draftCtx, sel_1, {
|
|
354
|
+
(_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
|
|
355
|
+
var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
|
|
356
|
+
api.setSelection(draft, [{
|
|
357
|
+
row: [0, rowLen],
|
|
358
|
+
column: [selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0], selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1]]
|
|
359
|
+
}], {
|
|
325
360
|
id: context.currentSheetId
|
|
326
361
|
});
|
|
327
362
|
});
|
|
@@ -21,6 +21,9 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
21
21
|
context = _a.context,
|
|
22
22
|
setContext = _a.setContext,
|
|
23
23
|
refs = _a.refs;
|
|
24
|
+
var selectedRowHeight = useRef(0);
|
|
25
|
+
var selectedSourceRowRef = useRef([]);
|
|
26
|
+
var selectedTargetRowRef = useRef([]);
|
|
24
27
|
var dragRef = useRef({
|
|
25
28
|
mouseDown: false,
|
|
26
29
|
startY: 0,
|
|
@@ -132,6 +135,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
132
135
|
});
|
|
133
136
|
if (selectedBlock) {
|
|
134
137
|
ghostHeightPx = Math.max(24, selectedBlock.row - selectedBlock.row_pre - 1);
|
|
138
|
+
selectedRowHeight.current = ghostHeightPx;
|
|
135
139
|
var count = selectedBlock.r2 - selectedBlock.r1 + 1;
|
|
136
140
|
ghostLabel = count > 1 ? "".concat(count, " rows") : "".concat(selectedBlock.r1 + 1, " row");
|
|
137
141
|
} else {
|
|
@@ -140,6 +144,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
140
144
|
end = _a[1];
|
|
141
145
|
var sourceRowHeight = end - pre - 1;
|
|
142
146
|
ghostHeightPx = Math.max(24, sourceRowHeight);
|
|
147
|
+
selectedRowHeight.current = ghostHeightPx;
|
|
143
148
|
}
|
|
144
149
|
el.style.height = "".concat(ghostHeightPx, "px");
|
|
145
150
|
el.textContent = ghostLabel;
|
|
@@ -166,6 +171,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
166
171
|
return true;
|
|
167
172
|
};
|
|
168
173
|
var handleRowDrag = function handleRowDrag(ev) {
|
|
174
|
+
var _a, _b;
|
|
169
175
|
if (!dragRef.current.mouseDown) return;
|
|
170
176
|
dragRef.current.lastNativeEvent = ev;
|
|
171
177
|
var host = containerRef.current;
|
|
@@ -173,72 +179,111 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
173
179
|
var dragOffset = Math.abs(ev.pageY - dragRef.current.startY);
|
|
174
180
|
if (!isDragActivated(host, dragOffset)) return;
|
|
175
181
|
var lineTopPx = computeInsertionFromPageY(ev.pageY).lineTopPx;
|
|
176
|
-
var
|
|
182
|
+
var rows = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row;
|
|
183
|
+
var selectedRowLength = rows && rows[1] != null && rows[0] != null ? rows[1] - rows[0] + 1 : 0;
|
|
184
|
+
var off = 3 - selectedRowLength;
|
|
185
|
+
var bottomOff = (off + 1) * 25;
|
|
186
|
+
var topRowOff = selectedRowLength - 4;
|
|
187
|
+
var topOff = topRowOff * 25;
|
|
188
|
+
var ghostFinalPos = dragRef.current.startY > ev.pageY ? lineTopPx - topOff : lineTopPx + bottomOff;
|
|
177
189
|
if (dragRef.current.lineEl) {
|
|
178
190
|
dragRef.current.lineEl.style.top = "".concat(lineTopPx, "px");
|
|
179
191
|
}
|
|
180
192
|
if (dragRef.current.ghostEl) {
|
|
181
|
-
dragRef.current.ghostEl.style.top = "".concat(
|
|
193
|
+
dragRef.current.ghostEl.style.top = "".concat(ghostFinalPos, "px");
|
|
182
194
|
}
|
|
183
195
|
};
|
|
184
196
|
var handleRowDragEnd = function handleRowDragEnd(ev) {
|
|
185
|
-
var _a;
|
|
197
|
+
var _a, _b, _c;
|
|
186
198
|
if (!dragRef.current.mouseDown) return;
|
|
187
199
|
dragRef.current.mouseDown = false;
|
|
188
200
|
try {
|
|
189
201
|
document.body.style.userSelect = dragRef.current.prevUserSelect || "";
|
|
190
202
|
document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
|
|
191
|
-
} catch (
|
|
203
|
+
} catch (_d) {}
|
|
192
204
|
if (dragRef.current.active) {
|
|
193
205
|
var finalInsertionIndex_1 = computeInsertionFromPageY(ev.pageY).insertionIndex;
|
|
194
|
-
var sourceIndex_1 =
|
|
206
|
+
var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) === null || _c === void 0 ? void 0 : _c[0]) || 0;
|
|
195
207
|
var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
|
|
196
208
|
if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
|
|
197
209
|
setContext(function (draft) {
|
|
198
|
-
var _a, _b;
|
|
210
|
+
var _a, _b, _c, _d, _e, _f;
|
|
199
211
|
var _sheet = draft.luckysheetfile[sheetIdx_1];
|
|
200
212
|
if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
|
|
201
213
|
var rows = _sheet.data;
|
|
202
214
|
if (sourceIndex_1 < 0 || sourceIndex_1 >= rows.length) return;
|
|
203
215
|
var targetIndex = finalInsertionIndex_1;
|
|
204
216
|
if (targetIndex > sourceIndex_1) targetIndex -= 1;
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
217
|
+
var selectedRowRange = ((_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) || [];
|
|
218
|
+
var selectedSourceRow = [];
|
|
219
|
+
for (var i = selectedRowRange === null || selectedRowRange === void 0 ? void 0 : selectedRowRange[0]; i <= (selectedRowRange === null || selectedRowRange === void 0 ? void 0 : selectedRowRange[1]); i += 1) {
|
|
220
|
+
selectedSourceRow.push(i);
|
|
221
|
+
}
|
|
222
|
+
var tempSelectedTargetRow = [];
|
|
223
|
+
selectedSourceRow.forEach(function (_, index) {
|
|
224
|
+
if (sourceIndex_1 < targetIndex) {
|
|
225
|
+
tempSelectedTargetRow.push(targetIndex - index);
|
|
226
|
+
} else {
|
|
227
|
+
tempSelectedTargetRow.push(targetIndex + index);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
var selectedTargetRow = (_c = __spreadArray([], tempSelectedTargetRow, true)) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) {
|
|
231
|
+
return a - b;
|
|
232
|
+
});
|
|
233
|
+
selectedSourceRowRef.current = selectedSourceRow;
|
|
234
|
+
selectedTargetRowRef.current = selectedTargetRow;
|
|
235
|
+
selectedSourceRow.forEach(function () {
|
|
236
|
+
var adjustedSourceIndex = sourceIndex_1;
|
|
237
|
+
if (targetIndex < sourceIndex_1) {
|
|
238
|
+
adjustedSourceIndex = sourceIndex_1 + (selectedSourceRow.length - 1);
|
|
239
|
+
}
|
|
240
|
+
var rowData = rows.splice(adjustedSourceIndex, 1)[0];
|
|
241
|
+
if (targetIndex < 0) targetIndex = 0;
|
|
242
|
+
if (targetIndex > rows.length) targetIndex = rows.length;
|
|
243
|
+
rows.splice(targetIndex, 0, rowData);
|
|
244
|
+
});
|
|
209
245
|
_sheet.data = rows;
|
|
210
246
|
updateContextWithSheetData(draft, _sheet.data);
|
|
211
247
|
var d = getFlowdata(draft);
|
|
212
248
|
d === null || d === void 0 ? void 0 : d.forEach(function (row) {
|
|
213
249
|
row.forEach(function (cell) {
|
|
214
250
|
if (cell) {
|
|
215
|
-
var
|
|
216
|
-
var targetingIndex_1 = targetIndex + 1;
|
|
217
|
-
if (cell.f) {
|
|
218
|
-
cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
|
|
219
|
-
return "".concat(p1).concat(targetingIndex_1);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
var otherAffectedRows = [];
|
|
251
|
+
var otherAffectedRows_1 = [];
|
|
223
252
|
if (sourceIndex_1 < targetIndex) {
|
|
224
|
-
|
|
225
|
-
|
|
253
|
+
var start = selectedSourceRow === null || selectedSourceRow === void 0 ? void 0 : selectedSourceRow[selectedSourceRow.length - 1];
|
|
254
|
+
var last = selectedTargetRow === null || selectedTargetRow === void 0 ? void 0 : selectedTargetRow[selectedTargetRow.length - 1];
|
|
255
|
+
for (var c = start + 1; c < last; c += 1) {
|
|
256
|
+
otherAffectedRows_1.push({
|
|
226
257
|
source: c,
|
|
227
|
-
target: c -
|
|
258
|
+
target: c - selectedSourceRow.length
|
|
228
259
|
});
|
|
229
260
|
}
|
|
261
|
+
selectedSourceRow.forEach(function (c, index) {
|
|
262
|
+
otherAffectedRows_1.push({
|
|
263
|
+
source: c,
|
|
264
|
+
target: selectedTargetRow[index]
|
|
265
|
+
});
|
|
266
|
+
});
|
|
230
267
|
} else {
|
|
231
|
-
|
|
232
|
-
|
|
268
|
+
var start = selectedTargetRow === null || selectedTargetRow === void 0 ? void 0 : selectedTargetRow[0];
|
|
269
|
+
var last = selectedSourceRow === null || selectedSourceRow === void 0 ? void 0 : selectedSourceRow[0];
|
|
270
|
+
for (var c = start; c < last; c += 1) {
|
|
271
|
+
otherAffectedRows_1.push({
|
|
233
272
|
source: c,
|
|
234
|
-
target: c +
|
|
273
|
+
target: c + +selectedSourceRow.length
|
|
235
274
|
});
|
|
236
275
|
}
|
|
276
|
+
selectedSourceRow.forEach(function (c, index) {
|
|
277
|
+
otherAffectedRows_1.push({
|
|
278
|
+
source: c,
|
|
279
|
+
target: selectedTargetRow[index]
|
|
280
|
+
});
|
|
281
|
+
});
|
|
237
282
|
}
|
|
238
283
|
if (cell.f) {
|
|
239
284
|
var formula_1 = cell.f;
|
|
240
285
|
var replacements_1 = [];
|
|
241
|
-
|
|
286
|
+
otherAffectedRows_1.forEach(function (_a) {
|
|
242
287
|
var source = _a.source,
|
|
243
288
|
target = _a.target;
|
|
244
289
|
var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
|
|
@@ -272,41 +317,34 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
272
317
|
if (colRow.length !== 2) return;
|
|
273
318
|
var presentRow = parseInt(colRow[0], 10);
|
|
274
319
|
var updatedRow = presentRow;
|
|
275
|
-
if (presentRow
|
|
276
|
-
|
|
320
|
+
if (selectedSourceRow.includes(presentRow)) {
|
|
321
|
+
var index = selectedSourceRow.indexOf(presentRow);
|
|
322
|
+
var target = selectedTargetRow[index];
|
|
323
|
+
updatedRow = target;
|
|
277
324
|
} else if (presentRow > sourceIndex_1 && presentRow < targetIndex) {
|
|
278
|
-
updatedRow -=
|
|
325
|
+
updatedRow -= selectedSourceRow.length;
|
|
279
326
|
} else if (presentRow < sourceIndex_1 && presentRow >= targetIndex) {
|
|
280
|
-
updatedRow +=
|
|
327
|
+
updatedRow += selectedSourceRow.length;
|
|
281
328
|
}
|
|
282
329
|
newDataVerification_1["".concat(updatedRow, "_").concat(colRow[1])] = itemData;
|
|
283
330
|
});
|
|
284
331
|
_sheet.dataVerification = newDataVerification_1;
|
|
285
332
|
}
|
|
286
|
-
(
|
|
287
|
-
if (item.r
|
|
288
|
-
|
|
333
|
+
(_d = _sheet.calcChain) === null || _d === void 0 ? void 0 : _d.forEach(function (item) {
|
|
334
|
+
if (selectedSourceRow.includes(item.r)) {
|
|
335
|
+
var index = selectedSourceRow.indexOf(item.c);
|
|
336
|
+
item.r = selectedTargetRow[index];
|
|
289
337
|
} else if (item.r > sourceIndex_1 && item.r < targetIndex) {
|
|
290
|
-
item.r -=
|
|
338
|
+
item.r -= selectedSourceRow.length;
|
|
291
339
|
} else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
|
|
292
|
-
item.r +=
|
|
340
|
+
item.r += selectedSourceRow.length;
|
|
293
341
|
}
|
|
294
342
|
});
|
|
295
|
-
(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (targetIndex_1 > sourceIndex_1) targetIndex_1 -= 1;
|
|
301
|
-
var selData = api.getSelection(context) || [];
|
|
302
|
-
var sel = __spreadArray([], selData, true);
|
|
303
|
-
if (sel && sel[0]) {
|
|
304
|
-
sel[0].column = [targetIndex_1, targetIndex_1];
|
|
305
|
-
}
|
|
306
|
-
setContext(function (draftCtx) {
|
|
307
|
-
api.setSelection(draftCtx, [{
|
|
308
|
-
row: [targetIndex_1, targetIndex_1],
|
|
309
|
-
column: [0, colLen_1]
|
|
343
|
+
(_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
|
|
344
|
+
var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
|
|
345
|
+
api.setSelection(draft, [{
|
|
346
|
+
row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
|
|
347
|
+
column: [0, colLen]
|
|
310
348
|
}], {
|
|
311
349
|
id: context.currentSheetId
|
|
312
350
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
|
|
2
2
|
import { getCryptoPrice } from "../../utils/cryptoApi";
|
|
3
3
|
import { SetContextOptions } from "../../context";
|
|
4
|
-
export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
|
|
4
|
+
export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null, refs: any): {
|
|
5
5
|
applyOp: (ops: Op[]) => void;
|
|
6
6
|
getCryptoPrice: typeof getCryptoPrice;
|
|
7
7
|
getCellValue: (row: number, column: number, options?: api.CommonOptions & {
|
|
@@ -1191,4 +1191,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
1191
1191
|
getWorkbookContext: () => Context;
|
|
1192
1192
|
getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
|
|
1193
1193
|
getSettings: () => Required<Settings>;
|
|
1194
|
+
getRefs: () => any;
|
|
1195
|
+
getShowDialog: () => (content: import("react").ReactNode, type?: "ok" | "yesno" | undefined, title?: import("react").ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
|
|
1196
|
+
getSplitColComponent: () => import("react").FC<{}>;
|
|
1194
1197
|
};
|
|
@@ -12,7 +12,9 @@ import { addSheet, api, deleteRowCol, deleteSheet, insertRowCol, opToPatch, crea
|
|
|
12
12
|
import { applyPatches } from "immer";
|
|
13
13
|
import _ from "lodash";
|
|
14
14
|
import { getCryptoPrice } from "../../utils/cryptoApi";
|
|
15
|
-
|
|
15
|
+
import { useDialog } from "../../hooks/useDialog";
|
|
16
|
+
import { SplitColumn } from "../../components/SplitColumn";
|
|
17
|
+
export function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache, refs) {
|
|
16
18
|
return {
|
|
17
19
|
applyOp: function applyOp(ops) {
|
|
18
20
|
setContext(function (ctx_) {
|
|
@@ -436,6 +438,16 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
|
|
|
436
438
|
},
|
|
437
439
|
getSettings: function getSettings() {
|
|
438
440
|
return settings;
|
|
441
|
+
},
|
|
442
|
+
getRefs: function getRefs() {
|
|
443
|
+
return refs;
|
|
444
|
+
},
|
|
445
|
+
getShowDialog: function getShowDialog() {
|
|
446
|
+
var showDialog = useDialog().showDialog;
|
|
447
|
+
return showDialog;
|
|
448
|
+
},
|
|
449
|
+
getSplitColComponent: function getSplitColComponent() {
|
|
450
|
+
return SplitColumn;
|
|
439
451
|
}
|
|
440
452
|
};
|
|
441
453
|
}
|
|
@@ -1199,5 +1199,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
1199
1199
|
getWorkbookContext: () => Context;
|
|
1200
1200
|
getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions | undefined) => void;
|
|
1201
1201
|
getSettings: () => Required<Settings>;
|
|
1202
|
+
getRefs: () => any;
|
|
1203
|
+
getShowDialog: () => (content: React.ReactNode, type?: "ok" | "yesno" | undefined, title?: React.ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
|
|
1204
|
+
getSplitColComponent: () => React.FC<{}>;
|
|
1202
1205
|
}>>;
|
|
1203
1206
|
export default Workbook;
|
|
@@ -663,7 +663,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
663
663
|
};
|
|
664
664
|
}, [onPaste]);
|
|
665
665
|
useImperativeHandle(ref, function () {
|
|
666
|
-
return generateAPIs(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current);
|
|
666
|
+
return generateAPIs(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current, refs);
|
|
667
667
|
}, [context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, globalCache]);
|
|
668
668
|
var i = getSheetIndex(context, context.currentSheetId);
|
|
669
669
|
if (i == null) {
|
|
@@ -38,6 +38,9 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
38
38
|
context = _a.context,
|
|
39
39
|
setContext = _a.setContext,
|
|
40
40
|
refs = _a.refs;
|
|
41
|
+
var selectedColWidth = (0, _react.useRef)(0);
|
|
42
|
+
var selectedSourceColRef = (0, _react.useRef)([]);
|
|
43
|
+
var selectedTargetColRef = (0, _react.useRef)([]);
|
|
41
44
|
var dragRef = (0, _react.useRef)({
|
|
42
45
|
mouseDown: false,
|
|
43
46
|
startX: 0,
|
|
@@ -150,6 +153,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
150
153
|
});
|
|
151
154
|
if (selectedBlock) {
|
|
152
155
|
ghostWidthPx = Math.max(60, selectedBlock.col - selectedBlock.col_pre - 1);
|
|
156
|
+
selectedColWidth.current = ghostWidthPx;
|
|
153
157
|
var count = selectedBlock.c2 - selectedBlock.c1 + 1;
|
|
154
158
|
ghostLabel = count > 1 ? "".concat(count, " cols") : "Col ".concat(String.fromCharCode(65 + selectedBlock.c1));
|
|
155
159
|
} else {
|
|
@@ -158,6 +162,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
158
162
|
end = _a[1];
|
|
159
163
|
var sourceColWidth = end - pre - 1;
|
|
160
164
|
ghostWidthPx = Math.max(60, sourceColWidth);
|
|
165
|
+
selectedColWidth.current = ghostWidthPx;
|
|
161
166
|
}
|
|
162
167
|
el.style.width = "".concat(ghostWidthPx, "px");
|
|
163
168
|
el.textContent = ghostLabel;
|
|
@@ -191,28 +196,30 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
191
196
|
var dragOffset = Math.abs(ev.pageX - dragRef.current.startX);
|
|
192
197
|
if (!isDragActivated(host, dragOffset)) return;
|
|
193
198
|
var lineLeftPx = computeInsertionFromPageX(ev.pageX).lineLeftPx;
|
|
194
|
-
var ghostPosOffset =
|
|
199
|
+
var ghostPosOffset = 60;
|
|
200
|
+
var ghostFinalPos = dragRef.current.startX > ev.pageX ? lineLeftPx + ghostPosOffset : lineLeftPx - (selectedColWidth.current - ghostPosOffset);
|
|
195
201
|
if (dragRef.current.lineEl) {
|
|
196
202
|
dragRef.current.lineEl.style.left = "".concat(lineLeftPx, "px");
|
|
197
203
|
}
|
|
198
204
|
if (dragRef.current.ghostEl) {
|
|
199
|
-
dragRef.current.ghostEl.style.left = "".concat(
|
|
205
|
+
dragRef.current.ghostEl.style.left = "".concat(ghostFinalPos, "px");
|
|
200
206
|
}
|
|
201
207
|
};
|
|
202
208
|
var handleColumnDragEnd = function handleColumnDragEnd(ev) {
|
|
209
|
+
var _a, _b, _c;
|
|
203
210
|
if (!dragRef.current.mouseDown) return;
|
|
204
211
|
dragRef.current.mouseDown = false;
|
|
205
212
|
try {
|
|
206
213
|
document.body.style.userSelect = dragRef.current.prevUserSelect || "";
|
|
207
214
|
document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
|
|
208
|
-
} catch (
|
|
215
|
+
} catch (_d) {}
|
|
209
216
|
if (dragRef.current.active) {
|
|
210
217
|
var finalInsertionIndex_1 = computeInsertionFromPageX(ev.pageX).insertionIndex;
|
|
211
|
-
var sourceIndex_1 =
|
|
218
|
+
var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.column) === null || _c === void 0 ? void 0 : _c[0]) || 0;
|
|
212
219
|
var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
|
|
213
220
|
if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
|
|
214
221
|
setContext(function (draft) {
|
|
215
|
-
var _a, _b, _c, _d;
|
|
222
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
216
223
|
var _sheet = draft.luckysheetfile[sheetIdx_1];
|
|
217
224
|
if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
|
|
218
225
|
var rows = _sheet.data;
|
|
@@ -221,50 +228,81 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
221
228
|
if (sourceIndex_1 < 0 || sourceIndex_1 >= numCols) return;
|
|
222
229
|
var targetIndex = finalInsertionIndex_1;
|
|
223
230
|
if (targetIndex > sourceIndex_1) targetIndex -= 1;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (targetIndex < 0) targetIndex = 0;
|
|
229
|
-
if (targetIndex > row.length) targetIndex = row.length;
|
|
230
|
-
row.splice(targetIndex, 0, cellData);
|
|
231
|
+
var selectedColRange = ((_d = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.column) || [];
|
|
232
|
+
var selectedSourceCol = [];
|
|
233
|
+
for (var i = selectedColRange === null || selectedColRange === void 0 ? void 0 : selectedColRange[0]; i <= (selectedColRange === null || selectedColRange === void 0 ? void 0 : selectedColRange[1]); i += 1) {
|
|
234
|
+
selectedSourceCol.push(i);
|
|
231
235
|
}
|
|
236
|
+
var tempSelectedTargetCol = [];
|
|
237
|
+
selectedSourceCol.forEach(function (_, index) {
|
|
238
|
+
if (sourceIndex_1 < targetIndex) {
|
|
239
|
+
tempSelectedTargetCol.push(targetIndex - index);
|
|
240
|
+
} else {
|
|
241
|
+
tempSelectedTargetCol.push(targetIndex + index);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
var selectedTargetCol = (_e = __spreadArray([], tempSelectedTargetCol, true)) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) {
|
|
245
|
+
return a - b;
|
|
246
|
+
});
|
|
247
|
+
selectedSourceColRef.current = selectedSourceCol;
|
|
248
|
+
selectedTargetColRef.current = selectedTargetCol;
|
|
249
|
+
console.log("selectedSourceCol", selectedTargetCol);
|
|
250
|
+
selectedSourceCol.forEach(function () {
|
|
251
|
+
var adjustedSourceIndex = sourceIndex_1;
|
|
252
|
+
if (targetIndex < sourceIndex_1) {
|
|
253
|
+
adjustedSourceIndex = sourceIndex_1 + (selectedSourceCol.length - 1);
|
|
254
|
+
}
|
|
255
|
+
for (var j = 0; j < rows.length; j += 1) {
|
|
256
|
+
var row = rows[j];
|
|
257
|
+
if (!row || adjustedSourceIndex >= row.length) continue;
|
|
258
|
+
var cellData = row.splice(adjustedSourceIndex, 1)[0];
|
|
259
|
+
if (targetIndex < 0) targetIndex = 0;
|
|
260
|
+
if (targetIndex > row.length) targetIndex = row.length;
|
|
261
|
+
row.splice(targetIndex, 0, cellData);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
232
264
|
_sheet.data = rows;
|
|
233
265
|
(0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
|
|
234
266
|
var d = (0, _fortuneCore.getFlowdata)(draft);
|
|
235
267
|
d === null || d === void 0 ? void 0 : d.forEach(function (row) {
|
|
236
268
|
row.forEach(function (cell) {
|
|
237
269
|
if (cell) {
|
|
238
|
-
var
|
|
239
|
-
var targetColName_1 = numberToColumnName(targetIndex);
|
|
240
|
-
if (cell.f) {
|
|
241
|
-
cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
|
|
242
|
-
if (/^\d+$/.test(p1)) {
|
|
243
|
-
return "".concat(targetColName_1).concat(p1);
|
|
244
|
-
}
|
|
245
|
-
return match;
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
var otherAffectedCols = [];
|
|
270
|
+
var otherAffectedCols_1 = [];
|
|
249
271
|
if (sourceIndex_1 < targetIndex) {
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
var start = selectedSourceCol === null || selectedSourceCol === void 0 ? void 0 : selectedSourceCol[selectedSourceCol.length - 1];
|
|
273
|
+
var last = selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1];
|
|
274
|
+
for (var c = start + 1; c <= last; c += 1) {
|
|
275
|
+
otherAffectedCols_1.push({
|
|
252
276
|
source: numberToColumnName(c),
|
|
253
|
-
target: numberToColumnName(c -
|
|
277
|
+
target: numberToColumnName(c - selectedSourceCol.length)
|
|
254
278
|
});
|
|
255
279
|
}
|
|
280
|
+
selectedSourceCol.forEach(function (c, index) {
|
|
281
|
+
otherAffectedCols_1.push({
|
|
282
|
+
source: numberToColumnName(c),
|
|
283
|
+
target: numberToColumnName(selectedTargetCol[index])
|
|
284
|
+
});
|
|
285
|
+
});
|
|
256
286
|
} else if (sourceIndex_1 > targetIndex) {
|
|
257
|
-
|
|
258
|
-
|
|
287
|
+
var start = selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0];
|
|
288
|
+
var last = selectedSourceCol === null || selectedSourceCol === void 0 ? void 0 : selectedSourceCol[0];
|
|
289
|
+
for (var c = start; c < last; c += 1) {
|
|
290
|
+
otherAffectedCols_1.push({
|
|
259
291
|
source: numberToColumnName(c),
|
|
260
|
-
target: numberToColumnName(c +
|
|
292
|
+
target: numberToColumnName(c + selectedSourceCol.length)
|
|
261
293
|
});
|
|
262
294
|
}
|
|
295
|
+
selectedSourceCol.forEach(function (c, index) {
|
|
296
|
+
otherAffectedCols_1.push({
|
|
297
|
+
source: numberToColumnName(c),
|
|
298
|
+
target: numberToColumnName(selectedTargetCol[index])
|
|
299
|
+
});
|
|
300
|
+
});
|
|
263
301
|
}
|
|
264
302
|
if (cell.f) {
|
|
265
303
|
var formula_1 = cell.f;
|
|
266
304
|
var replacements_1 = [];
|
|
267
|
-
|
|
305
|
+
otherAffectedCols_1.forEach(function (col) {
|
|
268
306
|
var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
|
|
269
307
|
var match;
|
|
270
308
|
while ((match = regex.exec(formula_1)) !== null) {
|
|
@@ -298,38 +336,35 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
298
336
|
if (colRow.length !== 2) return;
|
|
299
337
|
var presentcol = parseInt(colRow[1], 10);
|
|
300
338
|
var updatedCol = presentcol;
|
|
301
|
-
if (presentcol
|
|
302
|
-
|
|
339
|
+
if (selectedSourceCol.includes(presentcol)) {
|
|
340
|
+
var index = selectedSourceCol.indexOf(presentcol);
|
|
341
|
+
var target = selectedTargetCol[index];
|
|
342
|
+
updatedCol = target;
|
|
303
343
|
} else if (presentcol > sourceIndex_1 && presentcol < targetIndex) {
|
|
304
|
-
updatedCol -=
|
|
344
|
+
updatedCol -= selectedSourceCol.length;
|
|
305
345
|
} else if (presentcol < sourceIndex_1 && presentcol >= targetIndex) {
|
|
306
|
-
updatedCol +=
|
|
346
|
+
updatedCol += selectedSourceCol.length;
|
|
307
347
|
}
|
|
308
348
|
newDataVerification_1["".concat(colRow[0], "_").concat(updatedCol)] = itemData;
|
|
309
349
|
});
|
|
310
350
|
_sheet.dataVerification = newDataVerification_1;
|
|
311
351
|
}
|
|
312
|
-
(
|
|
313
|
-
if (item.c
|
|
314
|
-
item.c
|
|
352
|
+
(_f = _sheet.calcChain) === null || _f === void 0 ? void 0 : _f.forEach(function (item) {
|
|
353
|
+
if (selectedSourceCol.includes(item.c)) {
|
|
354
|
+
var index = selectedSourceCol.indexOf(item.c);
|
|
355
|
+
item.c = selectedTargetCol[index];
|
|
315
356
|
} else if (item.c > sourceIndex_1 && item.c < targetIndex) {
|
|
316
|
-
item.c -=
|
|
357
|
+
item.c -= selectedSourceCol.length;
|
|
317
358
|
} else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
|
|
318
|
-
item.c +=
|
|
359
|
+
item.c += selectedSourceCol.length;
|
|
319
360
|
}
|
|
320
361
|
});
|
|
321
|
-
(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (sel_1 && sel_1[0]) {
|
|
328
|
-
sel_1[0].column = [targetIndex, targetIndex];
|
|
329
|
-
}
|
|
330
|
-
setContext(function (draftCtx) {
|
|
331
|
-
console.log("after update", sel_1);
|
|
332
|
-
_fortuneCore.api.setSelection(draftCtx, sel_1, {
|
|
362
|
+
(_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
|
|
363
|
+
var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
|
|
364
|
+
_fortuneCore.api.setSelection(draft, [{
|
|
365
|
+
row: [0, rowLen],
|
|
366
|
+
column: [selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0], selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1]]
|
|
367
|
+
}], {
|
|
333
368
|
id: context.currentSheetId
|
|
334
369
|
});
|
|
335
370
|
});
|
|
@@ -28,6 +28,9 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
28
28
|
context = _a.context,
|
|
29
29
|
setContext = _a.setContext,
|
|
30
30
|
refs = _a.refs;
|
|
31
|
+
var selectedRowHeight = (0, _react.useRef)(0);
|
|
32
|
+
var selectedSourceRowRef = (0, _react.useRef)([]);
|
|
33
|
+
var selectedTargetRowRef = (0, _react.useRef)([]);
|
|
31
34
|
var dragRef = (0, _react.useRef)({
|
|
32
35
|
mouseDown: false,
|
|
33
36
|
startY: 0,
|
|
@@ -139,6 +142,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
139
142
|
});
|
|
140
143
|
if (selectedBlock) {
|
|
141
144
|
ghostHeightPx = Math.max(24, selectedBlock.row - selectedBlock.row_pre - 1);
|
|
145
|
+
selectedRowHeight.current = ghostHeightPx;
|
|
142
146
|
var count = selectedBlock.r2 - selectedBlock.r1 + 1;
|
|
143
147
|
ghostLabel = count > 1 ? "".concat(count, " rows") : "".concat(selectedBlock.r1 + 1, " row");
|
|
144
148
|
} else {
|
|
@@ -147,6 +151,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
147
151
|
end = _a[1];
|
|
148
152
|
var sourceRowHeight = end - pre - 1;
|
|
149
153
|
ghostHeightPx = Math.max(24, sourceRowHeight);
|
|
154
|
+
selectedRowHeight.current = ghostHeightPx;
|
|
150
155
|
}
|
|
151
156
|
el.style.height = "".concat(ghostHeightPx, "px");
|
|
152
157
|
el.textContent = ghostLabel;
|
|
@@ -173,6 +178,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
173
178
|
return true;
|
|
174
179
|
};
|
|
175
180
|
var handleRowDrag = function handleRowDrag(ev) {
|
|
181
|
+
var _a, _b;
|
|
176
182
|
if (!dragRef.current.mouseDown) return;
|
|
177
183
|
dragRef.current.lastNativeEvent = ev;
|
|
178
184
|
var host = containerRef.current;
|
|
@@ -180,72 +186,111 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
180
186
|
var dragOffset = Math.abs(ev.pageY - dragRef.current.startY);
|
|
181
187
|
if (!isDragActivated(host, dragOffset)) return;
|
|
182
188
|
var lineTopPx = computeInsertionFromPageY(ev.pageY).lineTopPx;
|
|
183
|
-
var
|
|
189
|
+
var rows = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row;
|
|
190
|
+
var selectedRowLength = rows && rows[1] != null && rows[0] != null ? rows[1] - rows[0] + 1 : 0;
|
|
191
|
+
var off = 3 - selectedRowLength;
|
|
192
|
+
var bottomOff = (off + 1) * 25;
|
|
193
|
+
var topRowOff = selectedRowLength - 4;
|
|
194
|
+
var topOff = topRowOff * 25;
|
|
195
|
+
var ghostFinalPos = dragRef.current.startY > ev.pageY ? lineTopPx - topOff : lineTopPx + bottomOff;
|
|
184
196
|
if (dragRef.current.lineEl) {
|
|
185
197
|
dragRef.current.lineEl.style.top = "".concat(lineTopPx, "px");
|
|
186
198
|
}
|
|
187
199
|
if (dragRef.current.ghostEl) {
|
|
188
|
-
dragRef.current.ghostEl.style.top = "".concat(
|
|
200
|
+
dragRef.current.ghostEl.style.top = "".concat(ghostFinalPos, "px");
|
|
189
201
|
}
|
|
190
202
|
};
|
|
191
203
|
var handleRowDragEnd = function handleRowDragEnd(ev) {
|
|
192
|
-
var _a;
|
|
204
|
+
var _a, _b, _c;
|
|
193
205
|
if (!dragRef.current.mouseDown) return;
|
|
194
206
|
dragRef.current.mouseDown = false;
|
|
195
207
|
try {
|
|
196
208
|
document.body.style.userSelect = dragRef.current.prevUserSelect || "";
|
|
197
209
|
document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
|
|
198
|
-
} catch (
|
|
210
|
+
} catch (_d) {}
|
|
199
211
|
if (dragRef.current.active) {
|
|
200
212
|
var finalInsertionIndex_1 = computeInsertionFromPageY(ev.pageY).insertionIndex;
|
|
201
|
-
var sourceIndex_1 =
|
|
213
|
+
var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) === null || _c === void 0 ? void 0 : _c[0]) || 0;
|
|
202
214
|
var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
|
|
203
215
|
if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
|
|
204
216
|
setContext(function (draft) {
|
|
205
|
-
var _a, _b;
|
|
217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
206
218
|
var _sheet = draft.luckysheetfile[sheetIdx_1];
|
|
207
219
|
if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
|
|
208
220
|
var rows = _sheet.data;
|
|
209
221
|
if (sourceIndex_1 < 0 || sourceIndex_1 >= rows.length) return;
|
|
210
222
|
var targetIndex = finalInsertionIndex_1;
|
|
211
223
|
if (targetIndex > sourceIndex_1) targetIndex -= 1;
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
224
|
+
var selectedRowRange = ((_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) || [];
|
|
225
|
+
var selectedSourceRow = [];
|
|
226
|
+
for (var i = selectedRowRange === null || selectedRowRange === void 0 ? void 0 : selectedRowRange[0]; i <= (selectedRowRange === null || selectedRowRange === void 0 ? void 0 : selectedRowRange[1]); i += 1) {
|
|
227
|
+
selectedSourceRow.push(i);
|
|
228
|
+
}
|
|
229
|
+
var tempSelectedTargetRow = [];
|
|
230
|
+
selectedSourceRow.forEach(function (_, index) {
|
|
231
|
+
if (sourceIndex_1 < targetIndex) {
|
|
232
|
+
tempSelectedTargetRow.push(targetIndex - index);
|
|
233
|
+
} else {
|
|
234
|
+
tempSelectedTargetRow.push(targetIndex + index);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
var selectedTargetRow = (_c = __spreadArray([], tempSelectedTargetRow, true)) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) {
|
|
238
|
+
return a - b;
|
|
239
|
+
});
|
|
240
|
+
selectedSourceRowRef.current = selectedSourceRow;
|
|
241
|
+
selectedTargetRowRef.current = selectedTargetRow;
|
|
242
|
+
selectedSourceRow.forEach(function () {
|
|
243
|
+
var adjustedSourceIndex = sourceIndex_1;
|
|
244
|
+
if (targetIndex < sourceIndex_1) {
|
|
245
|
+
adjustedSourceIndex = sourceIndex_1 + (selectedSourceRow.length - 1);
|
|
246
|
+
}
|
|
247
|
+
var rowData = rows.splice(adjustedSourceIndex, 1)[0];
|
|
248
|
+
if (targetIndex < 0) targetIndex = 0;
|
|
249
|
+
if (targetIndex > rows.length) targetIndex = rows.length;
|
|
250
|
+
rows.splice(targetIndex, 0, rowData);
|
|
251
|
+
});
|
|
216
252
|
_sheet.data = rows;
|
|
217
253
|
(0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
|
|
218
254
|
var d = (0, _fortuneCore.getFlowdata)(draft);
|
|
219
255
|
d === null || d === void 0 ? void 0 : d.forEach(function (row) {
|
|
220
256
|
row.forEach(function (cell) {
|
|
221
257
|
if (cell) {
|
|
222
|
-
var
|
|
223
|
-
var targetingIndex_1 = targetIndex + 1;
|
|
224
|
-
if (cell.f) {
|
|
225
|
-
cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
|
|
226
|
-
return "".concat(p1).concat(targetingIndex_1);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
var otherAffectedRows = [];
|
|
258
|
+
var otherAffectedRows_1 = [];
|
|
230
259
|
if (sourceIndex_1 < targetIndex) {
|
|
231
|
-
|
|
232
|
-
|
|
260
|
+
var start = selectedSourceRow === null || selectedSourceRow === void 0 ? void 0 : selectedSourceRow[selectedSourceRow.length - 1];
|
|
261
|
+
var last = selectedTargetRow === null || selectedTargetRow === void 0 ? void 0 : selectedTargetRow[selectedTargetRow.length - 1];
|
|
262
|
+
for (var c = start + 1; c < last; c += 1) {
|
|
263
|
+
otherAffectedRows_1.push({
|
|
233
264
|
source: c,
|
|
234
|
-
target: c -
|
|
265
|
+
target: c - selectedSourceRow.length
|
|
235
266
|
});
|
|
236
267
|
}
|
|
268
|
+
selectedSourceRow.forEach(function (c, index) {
|
|
269
|
+
otherAffectedRows_1.push({
|
|
270
|
+
source: c,
|
|
271
|
+
target: selectedTargetRow[index]
|
|
272
|
+
});
|
|
273
|
+
});
|
|
237
274
|
} else {
|
|
238
|
-
|
|
239
|
-
|
|
275
|
+
var start = selectedTargetRow === null || selectedTargetRow === void 0 ? void 0 : selectedTargetRow[0];
|
|
276
|
+
var last = selectedSourceRow === null || selectedSourceRow === void 0 ? void 0 : selectedSourceRow[0];
|
|
277
|
+
for (var c = start; c < last; c += 1) {
|
|
278
|
+
otherAffectedRows_1.push({
|
|
240
279
|
source: c,
|
|
241
|
-
target: c +
|
|
280
|
+
target: c + +selectedSourceRow.length
|
|
242
281
|
});
|
|
243
282
|
}
|
|
283
|
+
selectedSourceRow.forEach(function (c, index) {
|
|
284
|
+
otherAffectedRows_1.push({
|
|
285
|
+
source: c,
|
|
286
|
+
target: selectedTargetRow[index]
|
|
287
|
+
});
|
|
288
|
+
});
|
|
244
289
|
}
|
|
245
290
|
if (cell.f) {
|
|
246
291
|
var formula_1 = cell.f;
|
|
247
292
|
var replacements_1 = [];
|
|
248
|
-
|
|
293
|
+
otherAffectedRows_1.forEach(function (_a) {
|
|
249
294
|
var source = _a.source,
|
|
250
295
|
target = _a.target;
|
|
251
296
|
var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
|
|
@@ -279,41 +324,34 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
279
324
|
if (colRow.length !== 2) return;
|
|
280
325
|
var presentRow = parseInt(colRow[0], 10);
|
|
281
326
|
var updatedRow = presentRow;
|
|
282
|
-
if (presentRow
|
|
283
|
-
|
|
327
|
+
if (selectedSourceRow.includes(presentRow)) {
|
|
328
|
+
var index = selectedSourceRow.indexOf(presentRow);
|
|
329
|
+
var target = selectedTargetRow[index];
|
|
330
|
+
updatedRow = target;
|
|
284
331
|
} else if (presentRow > sourceIndex_1 && presentRow < targetIndex) {
|
|
285
|
-
updatedRow -=
|
|
332
|
+
updatedRow -= selectedSourceRow.length;
|
|
286
333
|
} else if (presentRow < sourceIndex_1 && presentRow >= targetIndex) {
|
|
287
|
-
updatedRow +=
|
|
334
|
+
updatedRow += selectedSourceRow.length;
|
|
288
335
|
}
|
|
289
336
|
newDataVerification_1["".concat(updatedRow, "_").concat(colRow[1])] = itemData;
|
|
290
337
|
});
|
|
291
338
|
_sheet.dataVerification = newDataVerification_1;
|
|
292
339
|
}
|
|
293
|
-
(
|
|
294
|
-
if (item.r
|
|
295
|
-
|
|
340
|
+
(_d = _sheet.calcChain) === null || _d === void 0 ? void 0 : _d.forEach(function (item) {
|
|
341
|
+
if (selectedSourceRow.includes(item.r)) {
|
|
342
|
+
var index = selectedSourceRow.indexOf(item.c);
|
|
343
|
+
item.r = selectedTargetRow[index];
|
|
296
344
|
} else if (item.r > sourceIndex_1 && item.r < targetIndex) {
|
|
297
|
-
item.r -=
|
|
345
|
+
item.r -= selectedSourceRow.length;
|
|
298
346
|
} else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
|
|
299
|
-
item.r +=
|
|
347
|
+
item.r += selectedSourceRow.length;
|
|
300
348
|
}
|
|
301
349
|
});
|
|
302
|
-
(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (targetIndex_1 > sourceIndex_1) targetIndex_1 -= 1;
|
|
308
|
-
var selData = _fortuneCore.api.getSelection(context) || [];
|
|
309
|
-
var sel = __spreadArray([], selData, true);
|
|
310
|
-
if (sel && sel[0]) {
|
|
311
|
-
sel[0].column = [targetIndex_1, targetIndex_1];
|
|
312
|
-
}
|
|
313
|
-
setContext(function (draftCtx) {
|
|
314
|
-
_fortuneCore.api.setSelection(draftCtx, [{
|
|
315
|
-
row: [targetIndex_1, targetIndex_1],
|
|
316
|
-
column: [0, colLen_1]
|
|
350
|
+
(_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
|
|
351
|
+
var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
|
|
352
|
+
_fortuneCore.api.setSelection(draft, [{
|
|
353
|
+
row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
|
|
354
|
+
column: [0, colLen]
|
|
317
355
|
}], {
|
|
318
356
|
id: context.currentSheetId
|
|
319
357
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
|
|
2
2
|
import { getCryptoPrice } from "../../utils/cryptoApi";
|
|
3
3
|
import { SetContextOptions } from "../../context";
|
|
4
|
-
export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
|
|
4
|
+
export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null, refs: any): {
|
|
5
5
|
applyOp: (ops: Op[]) => void;
|
|
6
6
|
getCryptoPrice: typeof getCryptoPrice;
|
|
7
7
|
getCellValue: (row: number, column: number, options?: api.CommonOptions & {
|
|
@@ -1191,4 +1191,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
1191
1191
|
getWorkbookContext: () => Context;
|
|
1192
1192
|
getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
|
|
1193
1193
|
getSettings: () => Required<Settings>;
|
|
1194
|
+
getRefs: () => any;
|
|
1195
|
+
getShowDialog: () => (content: import("react").ReactNode, type?: "ok" | "yesno" | undefined, title?: import("react").ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
|
|
1196
|
+
getSplitColComponent: () => import("react").FC<{}>;
|
|
1194
1197
|
};
|
|
@@ -8,6 +8,8 @@ var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
|
8
8
|
var _immer = require("immer");
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
10
|
var _cryptoApi = require("../../utils/cryptoApi");
|
|
11
|
+
var _useDialog = require("../../hooks/useDialog");
|
|
12
|
+
var _SplitColumn = require("../../components/SplitColumn");
|
|
11
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
14
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
13
15
|
__assign = Object.assign || function (t) {
|
|
@@ -19,7 +21,7 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
19
21
|
};
|
|
20
22
|
return __assign.apply(this, arguments);
|
|
21
23
|
};
|
|
22
|
-
function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
|
|
24
|
+
function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache, refs) {
|
|
23
25
|
return {
|
|
24
26
|
applyOp: function applyOp(ops) {
|
|
25
27
|
setContext(function (ctx_) {
|
|
@@ -443,6 +445,16 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
|
|
|
443
445
|
},
|
|
444
446
|
getSettings: function getSettings() {
|
|
445
447
|
return settings;
|
|
448
|
+
},
|
|
449
|
+
getRefs: function getRefs() {
|
|
450
|
+
return refs;
|
|
451
|
+
},
|
|
452
|
+
getShowDialog: function getShowDialog() {
|
|
453
|
+
var showDialog = (0, _useDialog.useDialog)().showDialog;
|
|
454
|
+
return showDialog;
|
|
455
|
+
},
|
|
456
|
+
getSplitColComponent: function getSplitColComponent() {
|
|
457
|
+
return _SplitColumn.SplitColumn;
|
|
446
458
|
}
|
|
447
459
|
};
|
|
448
460
|
}
|
|
@@ -1199,5 +1199,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
1199
1199
|
getWorkbookContext: () => Context;
|
|
1200
1200
|
getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions | undefined) => void;
|
|
1201
1201
|
getSettings: () => Required<Settings>;
|
|
1202
|
+
getRefs: () => any;
|
|
1203
|
+
getShowDialog: () => (content: React.ReactNode, type?: "ok" | "yesno" | undefined, title?: React.ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
|
|
1204
|
+
getSplitColComponent: () => React.FC<{}>;
|
|
1202
1205
|
}>>;
|
|
1203
1206
|
export default Workbook;
|
|
@@ -672,7 +672,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
672
672
|
};
|
|
673
673
|
}, [onPaste]);
|
|
674
674
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
675
|
-
return (0, _api.generateAPIs)(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current);
|
|
675
|
+
return (0, _api.generateAPIs)(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current, refs);
|
|
676
676
|
}, [context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, globalCache]);
|
|
677
677
|
var i = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
|
|
678
678
|
if (i == null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.45",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"tsc": "tsc"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@fileverse-dev/fortune-core": "1.2.
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.2.44",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-40",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|