@fileverse-dev/fortune-core 1.3.10-yjs-3 → 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/hyperlink.js +52 -5
- package/es/modules/rowcol.js +0 -3
- package/es/modules/selection.js +0 -1
- package/es/modules/sort.js +21 -0
- package/lib/modules/hyperlink.js +52 -5
- package/lib/modules/rowcol.js +0 -3
- package/lib/modules/selection.js +0 -1
- package/lib/modules/sort.js +21 -0
- package/package.json +1 -1
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
|
@@ -107,9 +107,6 @@ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2,
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
changes.forEach(function (change) {
|
|
111
|
-
console.log("emitCellRangeToYdoc", change, __assign({}, change.value.v));
|
|
112
|
-
});
|
|
113
110
|
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
114
111
|
};
|
|
115
112
|
export function insertRowCol(ctx, op, changeSelection) {
|
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/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
|
@@ -120,9 +120,6 @@ var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2,
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
changes.forEach(function (change) {
|
|
124
|
-
console.log("emitCellRangeToYdoc", change, __assign({}, change.value.v));
|
|
125
|
-
});
|
|
126
123
|
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
127
124
|
};
|
|
128
125
|
function insertRowCol(ctx, op, changeSelection) {
|
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;
|