@fileverse-dev/fortune-core 1.3.10-yjs-2 → 1.3.10-yjs-4
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/modules/cell.js +12 -12
- package/es/modules/hyperlink.js +52 -5
- package/es/modules/rowcol.js +2 -8
- package/es/modules/selection.js +0 -1
- package/es/modules/sort.js +21 -0
- package/lib/modules/cell.js +12 -12
- package/lib/modules/hyperlink.js +52 -5
- package/lib/modules/rowcol.js +2 -8
- package/lib/modules/selection.js +0 -1
- package/lib/modules/sort.js +21 -0
- package/package.json +1 -1
package/es/modules/cell.js
CHANGED
|
@@ -110,13 +110,12 @@ export function getCellValue(r, c, data, attr) {
|
|
|
110
110
|
return retv;
|
|
111
111
|
}
|
|
112
112
|
export function setCellValue(ctx, r, c, d, v) {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
113
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
114
114
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
115
115
|
if (_.isNil(d)) {
|
|
116
116
|
d = getFlowdata(ctx);
|
|
117
117
|
}
|
|
118
118
|
if (!d) return;
|
|
119
|
-
var oldValue = _.cloneDeep(d[r][c]);
|
|
120
119
|
var cell = d[r][c];
|
|
121
120
|
var vupdate;
|
|
122
121
|
if (_.isPlainObject(v)) {
|
|
@@ -164,9 +163,6 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
164
163
|
cell = null;
|
|
165
164
|
}
|
|
166
165
|
d[r][c] = cell;
|
|
167
|
-
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.afterUpdateCell) {
|
|
168
|
-
ctx.hooks.afterUpdateCell(r, c, oldValue, (_b = d[r][c]) !== null && _b !== void 0 ? _b : null);
|
|
169
|
-
}
|
|
170
166
|
return;
|
|
171
167
|
}
|
|
172
168
|
if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
|
|
@@ -189,21 +185,21 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
189
185
|
t: "s"
|
|
190
186
|
};
|
|
191
187
|
cell.v = vupdateStr;
|
|
192
|
-
} else if (vupdateStr.toUpperCase() === "TRUE" && (_.isNil((
|
|
188
|
+
} else if (vupdateStr.toUpperCase() === "TRUE" && (_.isNil((_a = cell.ct) === null || _a === void 0 ? void 0 : _a.fa) || ((_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) !== "@")) {
|
|
193
189
|
cell.m = "TRUE";
|
|
194
190
|
cell.ct = {
|
|
195
191
|
fa: "General",
|
|
196
192
|
t: "b"
|
|
197
193
|
};
|
|
198
194
|
cell.v = true;
|
|
199
|
-
} else if (vupdateStr.toUpperCase() === "FALSE" && (_.isNil((
|
|
195
|
+
} else if (vupdateStr.toUpperCase() === "FALSE" && (_.isNil((_c = cell.ct) === null || _c === void 0 ? void 0 : _c.fa) || ((_d = cell.ct) === null || _d === void 0 ? void 0 : _d.fa) !== "@")) {
|
|
200
196
|
cell.m = "FALSE";
|
|
201
197
|
cell.ct = {
|
|
202
198
|
fa: "General",
|
|
203
199
|
t: "b"
|
|
204
200
|
};
|
|
205
201
|
cell.v = false;
|
|
206
|
-
} else if (vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length - 1)) && (_.isNil((
|
|
202
|
+
} else if (vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length - 1)) && (_.isNil((_e = cell.ct) === null || _e === void 0 ? void 0 : _e.fa) || ((_f = cell.ct) === null || _f === void 0 ? void 0 : _f.fa) !== "@")) {
|
|
207
203
|
cell.ct = {
|
|
208
204
|
fa: "0%",
|
|
209
205
|
t: "n"
|
|
@@ -233,7 +229,7 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
233
229
|
var isDigit = /^\d+$/.test(vupdate);
|
|
234
230
|
if (isDigit) {
|
|
235
231
|
var flowdata = getFlowdata(ctx);
|
|
236
|
-
var args = (
|
|
232
|
+
var args = (_g = getContentInParentheses(cell === null || cell === void 0 ? void 0 : cell.f)) === null || _g === void 0 ? void 0 : _g.split(",");
|
|
237
233
|
var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
238
234
|
return arg.trim().toUpperCase();
|
|
239
235
|
});
|
|
@@ -356,9 +352,6 @@ export function setCellValue(ctx, r, c, d, v) {
|
|
|
356
352
|
}
|
|
357
353
|
}
|
|
358
354
|
d[r][c] = cell;
|
|
359
|
-
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.afterUpdateCell) {
|
|
360
|
-
ctx.hooks.afterUpdateCell(r, c, oldValue, (_l = d[r][c]) !== null && _l !== void 0 ? _l : null);
|
|
361
|
-
}
|
|
362
355
|
if (ctx.luckysheet_selection_range) {
|
|
363
356
|
ctx.luckysheet_selection_range = [];
|
|
364
357
|
}
|
|
@@ -866,6 +859,13 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
866
859
|
}
|
|
867
860
|
}
|
|
868
861
|
}
|
|
862
|
+
if (ctx.hooks.afterUpdateCell) {
|
|
863
|
+
var newValue_2 = _.cloneDeep(flowdata[r][c]);
|
|
864
|
+
var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
|
|
865
|
+
setTimeout(function () {
|
|
866
|
+
afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue_1, newValue_2);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
869
|
ctx.formulaCache.execFunctionGlobalData = null;
|
|
870
870
|
} catch (e) {
|
|
871
871
|
console.error(e);
|
package/es/modules/hyperlink.js
CHANGED
|
@@ -41,7 +41,7 @@ export function getCellHyperlink(ctx, r, c) {
|
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
|
|
44
|
-
var _a, _b, _c;
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
45
|
var applyToSelection = (options === null || options === void 0 ? void 0 : options.applyToSelection) && (options === null || options === void 0 ? void 0 : options.cellInput);
|
|
46
46
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
47
47
|
var flowdata = getFlowdata(ctx);
|
|
@@ -61,8 +61,30 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
61
61
|
id: ctx.currentSheetId
|
|
62
62
|
};
|
|
63
63
|
flowdata[r][c] = cell;
|
|
64
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
65
|
+
ctx.hooks.updateCellYdoc([{
|
|
66
|
+
sheetId: ctx.currentSheetId,
|
|
67
|
+
path: ["hyperlink"],
|
|
68
|
+
key: "".concat(r, "_").concat(c),
|
|
69
|
+
value: {
|
|
70
|
+
linkType: linkType,
|
|
71
|
+
linkAddress: linkAddress
|
|
72
|
+
},
|
|
73
|
+
type: "update"
|
|
74
|
+
}, {
|
|
75
|
+
sheetId: ctx.currentSheetId,
|
|
76
|
+
path: ["celldata"],
|
|
77
|
+
value: {
|
|
78
|
+
r: r,
|
|
79
|
+
c: c,
|
|
80
|
+
v: cell
|
|
81
|
+
},
|
|
82
|
+
key: "".concat(r, "_").concat(c),
|
|
83
|
+
type: "update"
|
|
84
|
+
}]);
|
|
85
|
+
}
|
|
64
86
|
}
|
|
65
|
-
var offsets = (
|
|
87
|
+
var offsets = (_b = ctx.linkCard) === null || _b === void 0 ? void 0 : _b.selectionOffsets;
|
|
66
88
|
if (offsets) {
|
|
67
89
|
setSelectionByCharacterOffset(options.cellInput, offsets.start, offsets.end);
|
|
68
90
|
}
|
|
@@ -91,8 +113,8 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
91
113
|
};
|
|
92
114
|
flowdata[r][c] = cell;
|
|
93
115
|
ctx.linkCard = undefined;
|
|
94
|
-
if ((
|
|
95
|
-
(
|
|
116
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
117
|
+
(_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc([{
|
|
96
118
|
sheetId: ctx.currentSheetId,
|
|
97
119
|
path: ["celldata"],
|
|
98
120
|
value: {
|
|
@@ -107,11 +129,12 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, option
|
|
|
107
129
|
}
|
|
108
130
|
}
|
|
109
131
|
export function removeHyperlink(ctx, r, c) {
|
|
110
|
-
var _a, _b, _c;
|
|
132
|
+
var _a, _b, _c, _d;
|
|
111
133
|
var allowEdit = isAllowEdit(ctx);
|
|
112
134
|
if (!allowEdit) return;
|
|
113
135
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
114
136
|
var flowdata = getFlowdata(ctx);
|
|
137
|
+
var updatedCell = null;
|
|
115
138
|
if (flowdata != null && sheetIndex != null) {
|
|
116
139
|
var hyperlink = _.omit(ctx.luckysheetfile[sheetIndex].hyperlink, "".concat(r, "_").concat(c));
|
|
117
140
|
_.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
|
|
@@ -120,9 +143,33 @@ export function removeHyperlink(ctx, r, c) {
|
|
|
120
143
|
(_a = flowdata[r][c]) === null || _a === void 0 ? true : delete _a.hl;
|
|
121
144
|
(_b = flowdata[r][c]) === null || _b === void 0 ? true : delete _b.un;
|
|
122
145
|
(_c = flowdata[r][c]) === null || _c === void 0 ? true : delete _c.fc;
|
|
146
|
+
updatedCell = flowdata[r][c];
|
|
123
147
|
}
|
|
124
148
|
}
|
|
125
149
|
ctx.linkCard = undefined;
|
|
150
|
+
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateCellYdoc) {
|
|
151
|
+
var changes = [{
|
|
152
|
+
sheetId: ctx.currentSheetId,
|
|
153
|
+
path: ["hyperlink"],
|
|
154
|
+
key: "".concat(r, "_").concat(c),
|
|
155
|
+
value: null,
|
|
156
|
+
type: "delete"
|
|
157
|
+
}];
|
|
158
|
+
if (updatedCell != null) {
|
|
159
|
+
changes.push({
|
|
160
|
+
sheetId: ctx.currentSheetId,
|
|
161
|
+
path: ["celldata"],
|
|
162
|
+
value: {
|
|
163
|
+
r: r,
|
|
164
|
+
c: c,
|
|
165
|
+
v: updatedCell
|
|
166
|
+
},
|
|
167
|
+
key: "".concat(r, "_").concat(c),
|
|
168
|
+
type: "update"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
172
|
+
}
|
|
126
173
|
}
|
|
127
174
|
export function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
|
|
128
175
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
package/es/modules/rowcol.js
CHANGED
|
@@ -110,7 +110,7 @@ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2,
|
|
|
110
110
|
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
111
111
|
};
|
|
112
112
|
export function insertRowCol(ctx, op, changeSelection) {
|
|
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
|
|
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;
|
|
114
114
|
if (changeSelection === void 0) {
|
|
115
115
|
changeSelection = true;
|
|
116
116
|
}
|
|
@@ -1085,12 +1085,9 @@ export function insertRowCol(ctx, op, changeSelection) {
|
|
|
1085
1085
|
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1086
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
1087
|
}
|
|
1088
|
-
if ((_1 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _1 === void 0 ? void 0 : _1.updateAllCell) {
|
|
1089
|
-
ctx.hooks.updateAllCell(id);
|
|
1090
|
-
}
|
|
1091
1088
|
}
|
|
1092
1089
|
export function deleteRowCol(ctx, op) {
|
|
1093
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u
|
|
1090
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1094
1091
|
var type = op.type;
|
|
1095
1092
|
var start = op.start,
|
|
1096
1093
|
end = op.end,
|
|
@@ -1818,9 +1815,6 @@ export function deleteRowCol(ctx, op) {
|
|
|
1818
1815
|
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1819
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);
|
|
1820
1817
|
}
|
|
1821
|
-
if ((_v = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _v === void 0 ? void 0 : _v.updateAllCell) {
|
|
1822
|
-
ctx.hooks.updateAllCell(id);
|
|
1823
|
-
}
|
|
1824
1818
|
if (file.id === ctx.currentSheetId) {
|
|
1825
1819
|
ctx.config = cfg;
|
|
1826
1820
|
} else {}
|
package/es/modules/selection.js
CHANGED
|
@@ -1526,7 +1526,6 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1526
1526
|
var d = getFlowdata(ctx);
|
|
1527
1527
|
if (!d) return "dataNullError";
|
|
1528
1528
|
var has_PartMC = false;
|
|
1529
|
-
var cellChanges = [];
|
|
1530
1529
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1531
1530
|
var r1 = selection[s].row[0];
|
|
1532
1531
|
var r2 = selection[s].row[1];
|
package/es/modules/sort.js
CHANGED
|
@@ -68,6 +68,7 @@ export function orderbydata(isAsc, index, data) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
export function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr, stc, edc) {
|
|
71
|
+
var _a, _b;
|
|
71
72
|
var sortedData = orderbydata(isAsc, index, dataRange).sortedData;
|
|
72
73
|
for (var r = str; r <= edr; r += 1) {
|
|
73
74
|
for (var c = stc; c <= edc; c += 1) {
|
|
@@ -79,6 +80,26 @@ export function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr,
|
|
|
79
80
|
row: [str, edr],
|
|
80
81
|
column: [stc, edc]
|
|
81
82
|
}]);
|
|
83
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
84
|
+
var changes = [];
|
|
85
|
+
for (var r = str; r <= edr; r += 1) {
|
|
86
|
+
var row = sheetData[r] || [];
|
|
87
|
+
for (var c = stc; c <= edc; c += 1) {
|
|
88
|
+
changes.push({
|
|
89
|
+
sheetId: ctx.currentSheetId,
|
|
90
|
+
path: ["celldata"],
|
|
91
|
+
value: {
|
|
92
|
+
r: r,
|
|
93
|
+
c: c,
|
|
94
|
+
v: (_b = row === null || row === void 0 ? void 0 : row[c]) !== null && _b !== void 0 ? _b : null
|
|
95
|
+
},
|
|
96
|
+
key: "".concat(r, "_").concat(c),
|
|
97
|
+
type: "update"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
102
|
+
}
|
|
82
103
|
}
|
|
83
104
|
export function sortSelection(ctx, isAsc, colIndex) {
|
|
84
105
|
var _a;
|
package/lib/modules/cell.js
CHANGED
|
@@ -143,13 +143,12 @@ function getCellValue(r, c, data, attr) {
|
|
|
143
143
|
return retv;
|
|
144
144
|
}
|
|
145
145
|
function setCellValue(ctx, r, c, d, v) {
|
|
146
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
146
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
147
147
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
148
148
|
if (_lodash.default.isNil(d)) {
|
|
149
149
|
d = (0, _context.getFlowdata)(ctx);
|
|
150
150
|
}
|
|
151
151
|
if (!d) return;
|
|
152
|
-
var oldValue = _lodash.default.cloneDeep(d[r][c]);
|
|
153
152
|
var cell = d[r][c];
|
|
154
153
|
var vupdate;
|
|
155
154
|
if (_lodash.default.isPlainObject(v)) {
|
|
@@ -197,9 +196,6 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
197
196
|
cell = null;
|
|
198
197
|
}
|
|
199
198
|
d[r][c] = cell;
|
|
200
|
-
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.afterUpdateCell) {
|
|
201
|
-
ctx.hooks.afterUpdateCell(r, c, oldValue, (_b = d[r][c]) !== null && _b !== void 0 ? _b : null);
|
|
202
|
-
}
|
|
203
199
|
return;
|
|
204
200
|
}
|
|
205
201
|
if ((0, _validation.isRealNull)(cell) || (_lodash.default.isString(cell) || _lodash.default.isNumber(cell)) && cell === v) {
|
|
@@ -222,21 +218,21 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
222
218
|
t: "s"
|
|
223
219
|
};
|
|
224
220
|
cell.v = vupdateStr;
|
|
225
|
-
} else if (vupdateStr.toUpperCase() === "TRUE" && (_lodash.default.isNil((
|
|
221
|
+
} else if (vupdateStr.toUpperCase() === "TRUE" && (_lodash.default.isNil((_a = cell.ct) === null || _a === void 0 ? void 0 : _a.fa) || ((_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) !== "@")) {
|
|
226
222
|
cell.m = "TRUE";
|
|
227
223
|
cell.ct = {
|
|
228
224
|
fa: "General",
|
|
229
225
|
t: "b"
|
|
230
226
|
};
|
|
231
227
|
cell.v = true;
|
|
232
|
-
} else if (vupdateStr.toUpperCase() === "FALSE" && (_lodash.default.isNil((
|
|
228
|
+
} else if (vupdateStr.toUpperCase() === "FALSE" && (_lodash.default.isNil((_c = cell.ct) === null || _c === void 0 ? void 0 : _c.fa) || ((_d = cell.ct) === null || _d === void 0 ? void 0 : _d.fa) !== "@")) {
|
|
233
229
|
cell.m = "FALSE";
|
|
234
230
|
cell.ct = {
|
|
235
231
|
fa: "General",
|
|
236
232
|
t: "b"
|
|
237
233
|
};
|
|
238
234
|
cell.v = false;
|
|
239
|
-
} else if (vupdateStr.substr(-1) === "%" && (0, _validation.isRealNum)(vupdateStr.substring(0, vupdateStr.length - 1)) && (_lodash.default.isNil((
|
|
235
|
+
} else if (vupdateStr.substr(-1) === "%" && (0, _validation.isRealNum)(vupdateStr.substring(0, vupdateStr.length - 1)) && (_lodash.default.isNil((_e = cell.ct) === null || _e === void 0 ? void 0 : _e.fa) || ((_f = cell.ct) === null || _f === void 0 ? void 0 : _f.fa) !== "@")) {
|
|
240
236
|
cell.ct = {
|
|
241
237
|
fa: "0%",
|
|
242
238
|
t: "n"
|
|
@@ -266,7 +262,7 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
266
262
|
var isDigit = /^\d+$/.test(vupdate);
|
|
267
263
|
if (isDigit) {
|
|
268
264
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
269
|
-
var args = (
|
|
265
|
+
var args = (_g = (0, _utils.getContentInParentheses)(cell === null || cell === void 0 ? void 0 : cell.f)) === null || _g === void 0 ? void 0 : _g.split(",");
|
|
270
266
|
var cellRefs = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
271
267
|
return arg.trim().toUpperCase();
|
|
272
268
|
});
|
|
@@ -389,9 +385,6 @@ function setCellValue(ctx, r, c, d, v) {
|
|
|
389
385
|
}
|
|
390
386
|
}
|
|
391
387
|
d[r][c] = cell;
|
|
392
|
-
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.afterUpdateCell) {
|
|
393
|
-
ctx.hooks.afterUpdateCell(r, c, oldValue, (_l = d[r][c]) !== null && _l !== void 0 ? _l : null);
|
|
394
|
-
}
|
|
395
388
|
if (ctx.luckysheet_selection_range) {
|
|
396
389
|
ctx.luckysheet_selection_range = [];
|
|
397
390
|
}
|
|
@@ -899,6 +892,13 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
899
892
|
}
|
|
900
893
|
}
|
|
901
894
|
}
|
|
895
|
+
if (ctx.hooks.afterUpdateCell) {
|
|
896
|
+
var newValue_2 = _lodash.default.cloneDeep(flowdata[r][c]);
|
|
897
|
+
var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
|
|
898
|
+
setTimeout(function () {
|
|
899
|
+
afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue_1, newValue_2);
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
902
|
ctx.formulaCache.execFunctionGlobalData = null;
|
|
903
903
|
} catch (e) {
|
|
904
904
|
console.error(e);
|
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/rowcol.js
CHANGED
|
@@ -123,7 +123,7 @@ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2,
|
|
|
123
123
|
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
124
124
|
};
|
|
125
125
|
function insertRowCol(ctx, op, changeSelection) {
|
|
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
|
|
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;
|
|
127
127
|
if (changeSelection === void 0) {
|
|
128
128
|
changeSelection = true;
|
|
129
129
|
}
|
|
@@ -1098,12 +1098,9 @@ function insertRowCol(ctx, op, changeSelection) {
|
|
|
1098
1098
|
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1099
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
1100
|
}
|
|
1101
|
-
if ((_1 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _1 === void 0 ? void 0 : _1.updateAllCell) {
|
|
1102
|
-
ctx.hooks.updateAllCell(id);
|
|
1103
|
-
}
|
|
1104
1101
|
}
|
|
1105
1102
|
function deleteRowCol(ctx, op) {
|
|
1106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u
|
|
1103
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1107
1104
|
var type = op.type;
|
|
1108
1105
|
var start = op.start,
|
|
1109
1106
|
end = op.end,
|
|
@@ -1831,9 +1828,6 @@ function deleteRowCol(ctx, op) {
|
|
|
1831
1828
|
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1832
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);
|
|
1833
1830
|
}
|
|
1834
|
-
if ((_v = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _v === void 0 ? void 0 : _v.updateAllCell) {
|
|
1835
|
-
ctx.hooks.updateAllCell(id);
|
|
1836
|
-
}
|
|
1837
1831
|
if (file.id === ctx.currentSheetId) {
|
|
1838
1832
|
ctx.config = cfg;
|
|
1839
1833
|
} else {}
|
package/lib/modules/selection.js
CHANGED
|
@@ -1561,7 +1561,6 @@ function deleteSelectedCellText(ctx) {
|
|
|
1561
1561
|
var d = (0, _context.getFlowdata)(ctx);
|
|
1562
1562
|
if (!d) return "dataNullError";
|
|
1563
1563
|
var has_PartMC = false;
|
|
1564
|
-
var cellChanges = [];
|
|
1565
1564
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1566
1565
|
var r1 = selection[s].row[0];
|
|
1567
1566
|
var r2 = selection[s].row[1];
|
package/lib/modules/sort.js
CHANGED
|
@@ -78,6 +78,7 @@ function orderbydata(isAsc, index, data) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr, stc, edc) {
|
|
81
|
+
var _a, _b;
|
|
81
82
|
var sortedData = orderbydata(isAsc, index, dataRange).sortedData;
|
|
82
83
|
for (var r = str; r <= edr; r += 1) {
|
|
83
84
|
for (var c = stc; c <= edc; c += 1) {
|
|
@@ -89,6 +90,26 @@ function sortDataRange(ctx, sheetData, dataRange, index, isAsc, str, edr, stc, e
|
|
|
89
90
|
row: [str, edr],
|
|
90
91
|
column: [stc, edc]
|
|
91
92
|
}]);
|
|
93
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
94
|
+
var changes = [];
|
|
95
|
+
for (var r = str; r <= edr; r += 1) {
|
|
96
|
+
var row = sheetData[r] || [];
|
|
97
|
+
for (var c = stc; c <= edc; c += 1) {
|
|
98
|
+
changes.push({
|
|
99
|
+
sheetId: ctx.currentSheetId,
|
|
100
|
+
path: ["celldata"],
|
|
101
|
+
value: {
|
|
102
|
+
r: r,
|
|
103
|
+
c: c,
|
|
104
|
+
v: (_b = row === null || row === void 0 ? void 0 : row[c]) !== null && _b !== void 0 ? _b : null
|
|
105
|
+
},
|
|
106
|
+
key: "".concat(r, "_").concat(c),
|
|
107
|
+
type: "update"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
function sortSelection(ctx, isAsc, colIndex) {
|
|
94
115
|
var _a;
|