@fileverse-dev/fortune-core 1.3.5-hyper-1 → 1.3.5-hyper-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/sheet.js +4 -5
- package/es/modules/cursor.d.ts +1 -0
- package/es/modules/cursor.js +35 -0
- package/lib/api/sheet.js +4 -5
- package/lib/modules/cursor.d.ts +1 -0
- package/lib/modules/cursor.js +36 -0
- package/package.json +1 -1
package/es/api/sheet.js
CHANGED
|
@@ -209,23 +209,22 @@ export function calculateSheetFromula(ctx, id) {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
export function calculateReferencedCellSheetFromula(ctx, id, refCell) {
|
|
212
|
-
var _a, _b, _c, _d, _e
|
|
212
|
+
var _a, _b, _c, _d, _e;
|
|
213
213
|
var index = getSheetIndex(ctx, id);
|
|
214
214
|
if (!ctx.luckysheetfile[index].data) return;
|
|
215
215
|
var _loop_1 = function _loop_1(r) {
|
|
216
216
|
var _loop_2 = function _loop_2(c) {
|
|
217
|
-
console.log(refCell, (_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f);
|
|
218
217
|
var isRef = false;
|
|
219
|
-
if (refCell && ((
|
|
218
|
+
if (refCell && ((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) && !((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
|
|
220
219
|
isRef = refCell.some(function (cell) {
|
|
221
220
|
var _a;
|
|
222
221
|
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
223
222
|
});
|
|
224
223
|
}
|
|
225
|
-
if (!isRef || !((
|
|
224
|
+
if (!isRef || !((_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f) || ((_d = ctx.luckysheetfile[index].data[r][c]) === null || _d === void 0 ? void 0 : _d.isDataBlockFormula)) {
|
|
226
225
|
return "continue";
|
|
227
226
|
}
|
|
228
|
-
var result = execfunction(ctx, (
|
|
227
|
+
var result = execfunction(ctx, (_e = ctx.luckysheetfile[index].data[r][c]) === null || _e === void 0 ? void 0 : _e.f, r, c, id);
|
|
229
228
|
var isValueArray = Array.isArray(result[1]);
|
|
230
229
|
if (isValueArray) {
|
|
231
230
|
var value = {
|
package/es/modules/cursor.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare function getSelectionCharacterOffsets(element: Node): {
|
|
|
6
6
|
end: number;
|
|
7
7
|
} | null;
|
|
8
8
|
export declare function setSelectionByCharacterOffset(element: HTMLDivElement, start: number, end: number): void;
|
|
9
|
+
export declare function getRangeRectsByCharacterOffset(element: HTMLDivElement, start: number, end: number): DOMRect[];
|
package/es/modules/cursor.js
CHANGED
|
@@ -114,4 +114,39 @@ export function setSelectionByCharacterOffset(element, start, end) {
|
|
|
114
114
|
sel.removeAllRanges();
|
|
115
115
|
sel.addRange(range);
|
|
116
116
|
}
|
|
117
|
+
}
|
|
118
|
+
export function getRangeRectsByCharacterOffset(element, start, end) {
|
|
119
|
+
if (start >= end) return [];
|
|
120
|
+
var charIndex = 0;
|
|
121
|
+
var startNode = null;
|
|
122
|
+
var startOffset = 0;
|
|
123
|
+
var endNode = null;
|
|
124
|
+
var endOffset = 0;
|
|
125
|
+
function walk(node) {
|
|
126
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
127
|
+
var len = (node.textContent || "").length;
|
|
128
|
+
if (startNode == null && charIndex + len > start) {
|
|
129
|
+
startNode = node;
|
|
130
|
+
startOffset = start - charIndex;
|
|
131
|
+
}
|
|
132
|
+
if (endNode == null && charIndex + len >= end) {
|
|
133
|
+
endNode = node;
|
|
134
|
+
endOffset = end - charIndex;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
charIndex += len;
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
for (var i = 0; i < node.childNodes.length; i += 1) {
|
|
141
|
+
if (walk(node.childNodes[i])) return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
walk(element);
|
|
146
|
+
if (!startNode || !endNode) return [];
|
|
147
|
+
var range = document.createRange();
|
|
148
|
+
range.setStart(startNode, startOffset);
|
|
149
|
+
range.setEnd(endNode, endOffset);
|
|
150
|
+
var rects = range.getClientRects();
|
|
151
|
+
return Array.from(rects);
|
|
117
152
|
}
|
package/lib/api/sheet.js
CHANGED
|
@@ -227,23 +227,22 @@ function calculateSheetFromula(ctx, id) {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
function calculateReferencedCellSheetFromula(ctx, id, refCell) {
|
|
230
|
-
var _a, _b, _c, _d, _e
|
|
230
|
+
var _a, _b, _c, _d, _e;
|
|
231
231
|
var index = (0, _utils.getSheetIndex)(ctx, id);
|
|
232
232
|
if (!ctx.luckysheetfile[index].data) return;
|
|
233
233
|
var _loop_1 = function _loop_1(r) {
|
|
234
234
|
var _loop_2 = function _loop_2(c) {
|
|
235
|
-
console.log(refCell, (_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f);
|
|
236
235
|
var isRef = false;
|
|
237
|
-
if (refCell && ((
|
|
236
|
+
if (refCell && ((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) && !((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
|
|
238
237
|
isRef = refCell.some(function (cell) {
|
|
239
238
|
var _a;
|
|
240
239
|
return isCellReferenced((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f, cell);
|
|
241
240
|
});
|
|
242
241
|
}
|
|
243
|
-
if (!isRef || !((
|
|
242
|
+
if (!isRef || !((_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f) || ((_d = ctx.luckysheetfile[index].data[r][c]) === null || _d === void 0 ? void 0 : _d.isDataBlockFormula)) {
|
|
244
243
|
return "continue";
|
|
245
244
|
}
|
|
246
|
-
var result = (0, _2.execfunction)(ctx, (
|
|
245
|
+
var result = (0, _2.execfunction)(ctx, (_e = ctx.luckysheetfile[index].data[r][c]) === null || _e === void 0 ? void 0 : _e.f, r, c, id);
|
|
247
246
|
var isValueArray = Array.isArray(result[1]);
|
|
248
247
|
if (isValueArray) {
|
|
249
248
|
var value = {
|
package/lib/modules/cursor.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare function getSelectionCharacterOffsets(element: Node): {
|
|
|
6
6
|
end: number;
|
|
7
7
|
} | null;
|
|
8
8
|
export declare function setSelectionByCharacterOffset(element: HTMLDivElement, start: number, end: number): void;
|
|
9
|
+
export declare function getRangeRectsByCharacterOffset(element: HTMLDivElement, start: number, end: number): DOMRect[];
|
package/lib/modules/cursor.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getRangeRectsByCharacterOffset = getRangeRectsByCharacterOffset;
|
|
6
7
|
exports.getSelectionCharacterOffsets = getSelectionCharacterOffsets;
|
|
7
8
|
exports.moveToEnd = moveToEnd;
|
|
8
9
|
exports.selectTextContent = selectTextContent;
|
|
@@ -124,4 +125,39 @@ function setSelectionByCharacterOffset(element, start, end) {
|
|
|
124
125
|
sel.removeAllRanges();
|
|
125
126
|
sel.addRange(range);
|
|
126
127
|
}
|
|
128
|
+
}
|
|
129
|
+
function getRangeRectsByCharacterOffset(element, start, end) {
|
|
130
|
+
if (start >= end) return [];
|
|
131
|
+
var charIndex = 0;
|
|
132
|
+
var startNode = null;
|
|
133
|
+
var startOffset = 0;
|
|
134
|
+
var endNode = null;
|
|
135
|
+
var endOffset = 0;
|
|
136
|
+
function walk(node) {
|
|
137
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
138
|
+
var len = (node.textContent || "").length;
|
|
139
|
+
if (startNode == null && charIndex + len > start) {
|
|
140
|
+
startNode = node;
|
|
141
|
+
startOffset = start - charIndex;
|
|
142
|
+
}
|
|
143
|
+
if (endNode == null && charIndex + len >= end) {
|
|
144
|
+
endNode = node;
|
|
145
|
+
endOffset = end - charIndex;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
charIndex += len;
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
for (var i = 0; i < node.childNodes.length; i += 1) {
|
|
152
|
+
if (walk(node.childNodes[i])) return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
walk(element);
|
|
157
|
+
if (!startNode || !endNode) return [];
|
|
158
|
+
var range = document.createRange();
|
|
159
|
+
range.setStart(startNode, startOffset);
|
|
160
|
+
range.setEnd(endNode, endOffset);
|
|
161
|
+
var rects = range.getClientRects();
|
|
162
|
+
return Array.from(rects);
|
|
127
163
|
}
|