@fileverse-dev/fortune-core 1.3.12 → 1.3.13-create-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/events/keyboard.d.ts +2 -2
- package/es/events/keyboard.js +204 -30
- package/es/events/mouse.js +79 -44
- package/es/events/paste.js +240 -56
- package/es/locale/en.d.ts +3 -0
- package/es/locale/en.js +3 -0
- package/es/locale/es.d.ts +3 -0
- package/es/locale/es.js +3 -0
- package/es/locale/hi.d.ts +3 -0
- package/es/locale/hi.js +3 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/zh.d.ts +3 -0
- package/es/locale/zh.js +3 -0
- package/es/locale/zh_tw.d.ts +3 -0
- package/es/locale/zh_tw.js +3 -0
- package/es/modules/ConditionFormat.js +26 -0
- package/es/modules/cell.d.ts +5 -1
- package/es/modules/cell.js +182 -38
- package/es/modules/clipboard.js +111 -2
- package/es/modules/format.js +12 -7
- package/es/modules/formula.d.ts +23 -0
- package/es/modules/formula.js +610 -51
- package/es/modules/hyperlink.js +18 -6
- package/es/modules/inline-string.js +61 -8
- package/es/modules/moveCells.js +52 -9
- package/es/modules/selection.d.ts +1 -0
- package/es/modules/selection.js +102 -16
- package/es/modules/validation.js +6 -3
- package/es/paste-helpers/calculate-range-cell-size.js +5 -4
- package/es/paste-table-helpers.d.ts +1 -1
- package/es/paste-table-helpers.js +170 -21
- package/es/types.d.ts +3 -0
- package/lib/events/keyboard.d.ts +2 -2
- package/lib/events/keyboard.js +203 -29
- package/lib/events/mouse.js +78 -43
- package/lib/events/paste.js +238 -54
- package/lib/locale/en.d.ts +3 -0
- package/lib/locale/en.js +3 -0
- package/lib/locale/es.d.ts +3 -0
- package/lib/locale/es.js +3 -0
- package/lib/locale/hi.d.ts +3 -0
- package/lib/locale/hi.js +3 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/zh.d.ts +3 -0
- package/lib/locale/zh.js +3 -0
- package/lib/locale/zh_tw.d.ts +3 -0
- package/lib/locale/zh_tw.js +3 -0
- package/lib/modules/ConditionFormat.js +26 -0
- package/lib/modules/cell.d.ts +5 -1
- package/lib/modules/cell.js +180 -36
- package/lib/modules/clipboard.js +111 -2
- package/lib/modules/format.js +12 -7
- package/lib/modules/formula.d.ts +23 -0
- package/lib/modules/formula.js +623 -51
- package/lib/modules/hyperlink.js +18 -6
- package/lib/modules/inline-string.js +61 -8
- package/lib/modules/moveCells.js +52 -9
- package/lib/modules/selection.d.ts +1 -0
- package/lib/modules/selection.js +101 -15
- package/lib/modules/validation.js +6 -3
- package/lib/paste-helpers/calculate-range-cell-size.js +5 -4
- package/lib/paste-table-helpers.d.ts +1 -1
- package/lib/paste-table-helpers.js +170 -21
- package/lib/types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -691,6 +691,32 @@ export function compute(ctx, ruleArr, d) {
|
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
+
} else if (conditionName === "empty") {
|
|
695
|
+
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
696
|
+
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
697
|
+
var cell = _.isNil(d[r]) || _.isNil(d[r][c]) ? null : d[r][c];
|
|
698
|
+
var isEmpty = _.isNil(cell) || _.isNil(cell.v) || isRealNull(cell.v);
|
|
699
|
+
if (isEmpty) {
|
|
700
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
701
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
702
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
703
|
+
computeMap["".concat(r, "_").concat(c)].bold = bold_1;
|
|
704
|
+
computeMap["".concat(r, "_").concat(c)].italic = italic_1;
|
|
705
|
+
computeMap["".concat(r, "_").concat(c)].underline = underline_1;
|
|
706
|
+
computeMap["".concat(r, "_").concat(c)].strikethrough = strikethrough_1;
|
|
707
|
+
} else {
|
|
708
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
709
|
+
textColor: textColor_1,
|
|
710
|
+
cellColor: cellColor_1,
|
|
711
|
+
bold: bold_1,
|
|
712
|
+
italic: italic_1,
|
|
713
|
+
underline: underline_1,
|
|
714
|
+
strikethrough: strikethrough_1
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
694
720
|
} else if (conditionName === "between") {
|
|
695
721
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
696
722
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
package/es/modules/cell.d.ts
CHANGED
|
@@ -25,7 +25,11 @@ export declare function getRangeByTxt(ctx: Context, txt: string): any[];
|
|
|
25
25
|
export declare function isAllSelectedCellsInStatus(ctx: Context, attr: keyof Cell, status: any): boolean;
|
|
26
26
|
export declare function getFontStyleByCell(cell: Cell | null | undefined, checksAF?: any[], checksCF?: any, isCheck?: boolean): any;
|
|
27
27
|
export declare function getStyleByCell(ctx: Context, d: CellMatrix, r: number, c: number): any;
|
|
28
|
-
export declare function getInlineStringHTML(r: number, c: number, data: CellMatrix
|
|
28
|
+
export declare function getInlineStringHTML(r: number, c: number, data: CellMatrix, options?: {
|
|
29
|
+
useSemanticMarkup?: boolean;
|
|
30
|
+
isRangeCopy?: boolean;
|
|
31
|
+
inheritedStyle?: Record<string, string>;
|
|
32
|
+
}): string;
|
|
29
33
|
export declare function getQKBorder(width: string, type: string, color: string): (string | number)[];
|
|
30
34
|
export declare function getdatabyselection(ctx: Context, range: Selection | undefined, sheetId: string): (Cell | null)[][];
|
|
31
35
|
export declare function luckysheetUpdateCell(ctx: Context, row_index: number, col_index: number): void;
|
package/es/modules/cell.js
CHANGED
|
@@ -16,10 +16,11 @@ import { checkCF, getComputeMap } from "./ConditionFormat";
|
|
|
16
16
|
import { getFailureText, validateCellData } from "./dataVerification";
|
|
17
17
|
import { genarate, update } from "./format";
|
|
18
18
|
import { clearCellError, getRowHeight } from "../api";
|
|
19
|
-
import { delFunctionGroup, execfunction, execFunctionGroup, functionHTMLGenerate, getcellrange, iscelldata } from "./formula";
|
|
20
|
-
import {
|
|
19
|
+
import { delFunctionGroup, execfunction, execFunctionGroup, functionHTMLGenerate, getcellrange, iscelldata, suppressFormulaRangeSelectionForInitialEdit } from "./formula";
|
|
20
|
+
import { convertSpanToShareString, isInlineStringCell, isInlineStringCT } from "./inline-string";
|
|
21
21
|
import { isRealNull, isRealNum, valueIsError } from "./validation";
|
|
22
22
|
import { getCellTextInfo } from "./text";
|
|
23
|
+
import { locale } from "../locale";
|
|
23
24
|
import { spillSortResult } from "./sort";
|
|
24
25
|
export function normalizedCellAttr(cell, attr, defaultFontSize) {
|
|
25
26
|
if (defaultFontSize === void 0) {
|
|
@@ -69,6 +70,32 @@ function newlinesToBr(text) {
|
|
|
69
70
|
if (!text) return "";
|
|
70
71
|
return text.replace(/\r\n|\r|\n/g, "<br />");
|
|
71
72
|
}
|
|
73
|
+
function closeUnclosedParenthesesInFormula(formula) {
|
|
74
|
+
if (!formula.startsWith("=") || formula.length <= 1) return formula;
|
|
75
|
+
var body = formula.slice(1);
|
|
76
|
+
var depth = 0;
|
|
77
|
+
var inString = false;
|
|
78
|
+
for (var i = 0; i < body.length; i += 1) {
|
|
79
|
+
var ch = body[i];
|
|
80
|
+
if (inString) {
|
|
81
|
+
if (ch === '"') {
|
|
82
|
+
if (body[i + 1] === '"') {
|
|
83
|
+
i += 1;
|
|
84
|
+
} else {
|
|
85
|
+
inString = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (ch === '"') {
|
|
91
|
+
inString = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (ch === "(") depth += 1;else if (ch === ")") depth = Math.max(0, depth - 1);
|
|
95
|
+
}
|
|
96
|
+
if (depth <= 0) return formula;
|
|
97
|
+
return "".concat(formula).concat(")".repeat(depth));
|
|
98
|
+
}
|
|
72
99
|
export function getCellValue(r, c, data, attr) {
|
|
73
100
|
var _a;
|
|
74
101
|
if (!attr) {
|
|
@@ -541,6 +568,8 @@ export function cancelNormalSelected(ctx) {
|
|
|
541
568
|
ctx.formulaCache.rangestart = false;
|
|
542
569
|
ctx.formulaCache.rangedrag_column_start = false;
|
|
543
570
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
571
|
+
ctx.formulaCache.rangeSelectionActive = null;
|
|
572
|
+
ctx.formulaCache.formulaEditorOwner = null;
|
|
544
573
|
}
|
|
545
574
|
export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
546
575
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
@@ -616,6 +645,11 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
616
645
|
}
|
|
617
646
|
}
|
|
618
647
|
value = value || inputText;
|
|
648
|
+
if (_.isString(value) && value.startsWith("=") && value.length > 1) {
|
|
649
|
+
value = closeUnclosedParenthesesInFormula(value);
|
|
650
|
+
} else if (_.isPlainObject(value) && _.isString(value.f) && value.f.startsWith("=") && value.f.length > 1) {
|
|
651
|
+
value.f = closeUnclosedParenthesesInFormula(value.f);
|
|
652
|
+
}
|
|
619
653
|
var shouldClearError = (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.f) ? oldValue_1.f !== value : (oldValue_1 === null || oldValue_1 === void 0 ? void 0 : oldValue_1.v) !== value;
|
|
620
654
|
if (shouldClearError) {
|
|
621
655
|
clearCellError(ctx, r, c);
|
|
@@ -975,37 +1009,68 @@ export function getRangeByTxt(ctx, txt) {
|
|
|
975
1009
|
return range;
|
|
976
1010
|
}
|
|
977
1011
|
export function isAllSelectedCellsInStatus(ctx, attr, status) {
|
|
978
|
-
var _a, _b
|
|
1012
|
+
var _a, _b;
|
|
979
1013
|
if (!_.isEmpty(ctx.luckysheetCellUpdate)) {
|
|
980
1014
|
var w = window.getSelection();
|
|
981
1015
|
if (!w) return false;
|
|
982
1016
|
if (w.rangeCount === 0) return false;
|
|
983
|
-
var
|
|
984
|
-
if (
|
|
1017
|
+
var range_1 = w.getRangeAt(0);
|
|
1018
|
+
if (range_1.collapsed === true) {
|
|
985
1019
|
return false;
|
|
986
1020
|
}
|
|
987
|
-
var endContainer =
|
|
988
|
-
var startContainer =
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1021
|
+
var endContainer = range_1.endContainer;
|
|
1022
|
+
var startContainer = range_1.startContainer;
|
|
1023
|
+
var toElement = function toElement(n) {
|
|
1024
|
+
if (!n) return null;
|
|
1025
|
+
if (n.nodeType === Node.ELEMENT_NODE) return n;
|
|
1026
|
+
return n.parentElement;
|
|
1027
|
+
};
|
|
1028
|
+
var startEl = toElement(startContainer);
|
|
1029
|
+
var endEl = toElement(endContainer);
|
|
1030
|
+
var editorRoot = (_b = (_a = startEl === null || startEl === void 0 ? void 0 : startEl.closest("#luckysheet-rich-text-editor")) !== null && _a !== void 0 ? _a : endEl === null || endEl === void 0 ? void 0 : endEl.closest("#luckysheet-rich-text-editor")) !== null && _b !== void 0 ? _b : toElement(range_1.commonAncestorContainer);
|
|
1031
|
+
var isStyleActive_1 = function isStyleActive_1(element) {
|
|
1032
|
+
var computed = window.getComputedStyle(element);
|
|
1033
|
+
var fontWeight = (computed.fontWeight || "").toLowerCase();
|
|
1034
|
+
var fontStyle = (computed.fontStyle || "").toLowerCase();
|
|
1035
|
+
var textDecorationLine = (computed.textDecorationLine || computed.textDecoration || "").toLowerCase();
|
|
1036
|
+
var borderBottomWidth = (computed.borderBottomWidth || "").toLowerCase();
|
|
1037
|
+
if (status === 1) {
|
|
1038
|
+
if (attr === "bl") {
|
|
1039
|
+
if (fontWeight === "bold") return true;
|
|
1040
|
+
var n = Number(fontWeight);
|
|
1041
|
+
return !Number.isNaN(n) && n >= 600;
|
|
1042
|
+
}
|
|
1043
|
+
if (attr === "it") {
|
|
1044
|
+
return fontStyle === "italic" || fontStyle === "oblique";
|
|
1045
|
+
}
|
|
1046
|
+
if (attr === "cl") {
|
|
1047
|
+
return textDecorationLine.includes("line-through");
|
|
1048
|
+
}
|
|
1049
|
+
if (attr === "un") {
|
|
1050
|
+
return textDecorationLine.includes("underline") || borderBottomWidth !== "" && borderBottomWidth !== "0px" && borderBottomWidth !== "0";
|
|
1003
1051
|
}
|
|
1004
|
-
return _.every(rangeSpans, function (s) {
|
|
1005
|
-
return !_.isEmpty(s.style[cssField_1]);
|
|
1006
|
-
});
|
|
1007
1052
|
}
|
|
1053
|
+
return false;
|
|
1054
|
+
};
|
|
1055
|
+
var selectedElements_1 = [];
|
|
1056
|
+
if (editorRoot) {
|
|
1057
|
+
var spans = editorRoot.querySelectorAll("span");
|
|
1058
|
+
spans.forEach(function (span) {
|
|
1059
|
+
if (span.textContent && span.textContent.length > 0 && range_1.intersectsNode(span)) {
|
|
1060
|
+
selectedElements_1.push(span);
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
if (selectedElements_1.length === 0) {
|
|
1065
|
+
if (startEl) selectedElements_1.push(startEl);
|
|
1066
|
+
if (endEl && endEl !== startEl) selectedElements_1.push(endEl);
|
|
1067
|
+
}
|
|
1068
|
+
if (selectedElements_1.length === 0) {
|
|
1069
|
+
return false;
|
|
1008
1070
|
}
|
|
1071
|
+
return _.every(selectedElements_1, function (el) {
|
|
1072
|
+
return isStyleActive_1(el);
|
|
1073
|
+
});
|
|
1009
1074
|
}
|
|
1010
1075
|
var cells = getFlattenedRange(ctx);
|
|
1011
1076
|
var flowdata = getFlowdata(ctx);
|
|
@@ -1041,7 +1106,7 @@ export function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
|
|
|
1041
1106
|
if (key === "it" && valueNum !== 0) {
|
|
1042
1107
|
style.fontStyle = "italic";
|
|
1043
1108
|
}
|
|
1044
|
-
if (key === "fs" &&
|
|
1109
|
+
if (key === "fs" && !_.isNil(value)) {
|
|
1045
1110
|
style.fontSize = "".concat(valueNum, "pt");
|
|
1046
1111
|
}
|
|
1047
1112
|
if (key === "fc" && value !== "#000000" || ((_a = checksAF === null || checksAF === void 0 ? void 0 : checksAF.length) !== null && _a !== void 0 ? _a : 0) > 0 || (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor)) {
|
|
@@ -1065,14 +1130,13 @@ export function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
|
|
|
1065
1130
|
return style;
|
|
1066
1131
|
}
|
|
1067
1132
|
export function getStyleByCell(ctx, d, r, c) {
|
|
1068
|
-
var _a;
|
|
1133
|
+
var _a, _b;
|
|
1069
1134
|
var style = {};
|
|
1070
1135
|
var checksAF = [];
|
|
1071
1136
|
var cf_compute = getComputeMap(ctx);
|
|
1072
1137
|
var checksCF = checkCF(r, c, cf_compute);
|
|
1073
1138
|
var cell = (_a = d === null || d === void 0 ? void 0 : d[r]) === null || _a === void 0 ? void 0 : _a[c];
|
|
1074
1139
|
if (!cell) return {};
|
|
1075
|
-
var isInline = isInlineStringCell(cell);
|
|
1076
1140
|
if ("bg" in cell) {
|
|
1077
1141
|
var value = normalizedCellAttr(cell, "bg");
|
|
1078
1142
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.cellColor) {
|
|
@@ -1103,7 +1167,9 @@ export function getStyleByCell(ctx, d, r, c) {
|
|
|
1103
1167
|
}
|
|
1104
1168
|
if ("ff" in cell) {
|
|
1105
1169
|
var value = normalizedCellAttr(cell, "ff");
|
|
1106
|
-
|
|
1170
|
+
var fontarray = locale(ctx).fontarray;
|
|
1171
|
+
var ffIndex = parseInt(value, 10);
|
|
1172
|
+
style.fontFamily = Number.isNaN(ffIndex) ? value : (_b = fontarray[ffIndex]) !== null && _b !== void 0 ? _b : value;
|
|
1107
1173
|
}
|
|
1108
1174
|
if ("vt" in cell) {
|
|
1109
1175
|
var value = normalizedCellAttr(cell, "vt");
|
|
@@ -1113,12 +1179,52 @@ export function getStyleByCell(ctx, d, r, c) {
|
|
|
1113
1179
|
style.alignItems = "flex-end";
|
|
1114
1180
|
}
|
|
1115
1181
|
}
|
|
1116
|
-
|
|
1117
|
-
style = _.assign(style, getFontStyleByCell(cell, checksAF, checksCF));
|
|
1118
|
-
}
|
|
1182
|
+
style = _.assign(style, getFontStyleByCell(cell, checksAF, checksCF));
|
|
1119
1183
|
return style;
|
|
1120
1184
|
}
|
|
1121
|
-
|
|
1185
|
+
function normalizeInlineStringClipboardStyle(style) {
|
|
1186
|
+
var decorations = new Set();
|
|
1187
|
+
var normalizedStyle = {
|
|
1188
|
+
color: style.color || "#000000",
|
|
1189
|
+
fontFamily: style.fontFamily || "Arial",
|
|
1190
|
+
fontSize: style.fontSize || "11pt",
|
|
1191
|
+
fontStyle: style.fontStyle || "normal",
|
|
1192
|
+
fontWeight: style.fontWeight || "400"
|
|
1193
|
+
};
|
|
1194
|
+
var backgroundColor = style.backgroundColor || style.background;
|
|
1195
|
+
if (backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
1196
|
+
normalizedStyle.backgroundColor = backgroundColor;
|
|
1197
|
+
}
|
|
1198
|
+
if (typeof style.textDecoration === "string") {
|
|
1199
|
+
style.textDecoration.split(/\s+/).filter(Boolean).forEach(function (decoration) {
|
|
1200
|
+
return decorations.add(decoration);
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
if (style.borderBottom) {
|
|
1204
|
+
decorations.add("underline");
|
|
1205
|
+
normalizedStyle.textDecorationSkipInk = "none";
|
|
1206
|
+
}
|
|
1207
|
+
if (decorations.size > 0) {
|
|
1208
|
+
normalizedStyle.textDecoration = Array.from(decorations).join(" ");
|
|
1209
|
+
}
|
|
1210
|
+
return normalizedStyle;
|
|
1211
|
+
}
|
|
1212
|
+
function buildClipboardCompatibleInlineRuns(text, styleAttr) {
|
|
1213
|
+
var normalizedText = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
1214
|
+
var segments = normalizedText.split("\n");
|
|
1215
|
+
return segments.map(function (segment, index) {
|
|
1216
|
+
var html = "";
|
|
1217
|
+
if (segment.length > 0) {
|
|
1218
|
+
html += "<span style='".concat(styleAttr, "'>").concat(segment, "</span>");
|
|
1219
|
+
}
|
|
1220
|
+
if (index < segments.length - 1) {
|
|
1221
|
+
html += "<span style='".concat(styleAttr, "'><br></span>");
|
|
1222
|
+
}
|
|
1223
|
+
return html;
|
|
1224
|
+
}).join("");
|
|
1225
|
+
}
|
|
1226
|
+
export function getInlineStringHTML(r, c, data, options) {
|
|
1227
|
+
var _a;
|
|
1122
1228
|
var ct = getCellValue(r, c, data, "ct");
|
|
1123
1229
|
if (isInlineStringCT(ct)) {
|
|
1124
1230
|
var strings = ct.s;
|
|
@@ -1126,17 +1232,49 @@ export function getInlineStringHTML(r, c, data) {
|
|
|
1126
1232
|
for (var i = 0; i < strings.length; i += 1) {
|
|
1127
1233
|
var strObj = strings[i];
|
|
1128
1234
|
if (strObj.v) {
|
|
1129
|
-
var
|
|
1235
|
+
var baseStyle = __assign(__assign({}, (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) ? (_a = options.inheritedStyle) !== null && _a !== void 0 ? _a : {} : {}), getFontStyleByCell(strObj));
|
|
1236
|
+
var style = (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) ? normalizeInlineStringClipboardStyle(baseStyle) : baseStyle;
|
|
1237
|
+
if (!style.fontWeight) {
|
|
1238
|
+
style.fontWeight = "400";
|
|
1239
|
+
}
|
|
1240
|
+
if (!style.fontStyle) {
|
|
1241
|
+
style.fontStyle = "normal";
|
|
1242
|
+
}
|
|
1243
|
+
if (!style.fontSize) {
|
|
1244
|
+
style.fontSize = "11pt";
|
|
1245
|
+
}
|
|
1246
|
+
if (!style.fontFamily) {
|
|
1247
|
+
style.fontFamily = "Arial";
|
|
1248
|
+
}
|
|
1130
1249
|
var link = strObj.link;
|
|
1131
1250
|
if ((link === null || link === void 0 ? void 0 : link.linkType) && (link === null || link === void 0 ? void 0 : link.linkAddress)) {
|
|
1132
1251
|
style.color = style.color || "rgb(0, 0, 255)";
|
|
1133
|
-
|
|
1252
|
+
if (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) {
|
|
1253
|
+
style.textDecoration = style.textDecoration ? "".concat(style.textDecoration, " underline") : "underline";
|
|
1254
|
+
style.textDecorationSkipInk = "none";
|
|
1255
|
+
} else {
|
|
1256
|
+
style.borderBottom = style.borderBottom || "1px solid rgb(0, 0, 255)";
|
|
1257
|
+
}
|
|
1134
1258
|
}
|
|
1135
|
-
var styleStr = _.
|
|
1259
|
+
var styleStr = _.toPairs(style).filter(function (_a) {
|
|
1260
|
+
var v = _a[1];
|
|
1261
|
+
return !_.isNil(v) && v !== "" && v !== "undefined";
|
|
1262
|
+
}).map(function (_a) {
|
|
1263
|
+
var key = _a[0],
|
|
1264
|
+
v = _a[1];
|
|
1136
1265
|
return "".concat(_.kebabCase(key), ":").concat(_.isNumber(v) ? "".concat(v, "px") : v, ";");
|
|
1137
|
-
}).join("");
|
|
1138
|
-
var dataAttrs = (link === null || link === void 0 ? void 0 : link.linkType) && (link === null || link === void 0 ? void 0 : link.linkAddress) ? " data-link-type='".concat(String(link.linkType).replace(/'/g, "'"), "' data-link-address='").concat(String(link.linkAddress).replace(/'/g, "'"), "'") : "";
|
|
1139
|
-
|
|
1266
|
+
}).join(" ");
|
|
1267
|
+
var dataAttrs = !(options === null || options === void 0 ? void 0 : options.useSemanticMarkup) && (link === null || link === void 0 ? void 0 : link.linkType) && (link === null || link === void 0 ? void 0 : link.linkAddress) ? " data-link-type='".concat(String(link.linkType).replace(/'/g, "'"), "' data-link-address='").concat(String(link.linkAddress).replace(/'/g, "'"), "'") : "";
|
|
1268
|
+
if (options === null || options === void 0 ? void 0 : options.isRangeCopy) {
|
|
1269
|
+
if (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) {
|
|
1270
|
+
value += buildClipboardCompatibleInlineRuns(strObj.v, styleStr);
|
|
1271
|
+
} else {
|
|
1272
|
+
var segmentText = strObj.v.replace(/\r\n/g, "<br>").replace(/\n/g, "<br>");
|
|
1273
|
+
value += "<span class=\"luckysheet-input-span\" index='".concat(i, "' style='").concat(styleStr, "'").concat(dataAttrs, ">").concat(segmentText, "</span>");
|
|
1274
|
+
}
|
|
1275
|
+
} else {
|
|
1276
|
+
value += "<span class=\"luckysheet-input-span\" index='".concat(i, "' style='").concat(styleStr, "'").concat(dataAttrs, ">").concat(strObj.v, "</span>");
|
|
1277
|
+
}
|
|
1140
1278
|
}
|
|
1141
1279
|
}
|
|
1142
1280
|
return value;
|
|
@@ -1224,6 +1362,12 @@ export function getdatabyselection(ctx, range, sheetId) {
|
|
|
1224
1362
|
return data;
|
|
1225
1363
|
}
|
|
1226
1364
|
export function luckysheetUpdateCell(ctx, row_index, col_index) {
|
|
1365
|
+
var _a;
|
|
1366
|
+
var flowdata = getFlowdata(ctx);
|
|
1367
|
+
var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
|
|
1368
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null && String(cell.f).trim() !== "") {
|
|
1369
|
+
suppressFormulaRangeSelectionForInitialEdit(ctx);
|
|
1370
|
+
}
|
|
1227
1371
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
1228
1372
|
}
|
|
1229
1373
|
export function getDataBySelectionNoCopy(ctx, range) {
|
package/es/modules/clipboard.js
CHANGED
|
@@ -1,7 +1,116 @@
|
|
|
1
|
+
function getNodePlainText(node) {
|
|
2
|
+
var _a;
|
|
3
|
+
if (node.nodeType === 3) {
|
|
4
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
|
|
5
|
+
}
|
|
6
|
+
if (node.nodeType !== 1) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
var element = node;
|
|
10
|
+
if (element.tagName === "BR") {
|
|
11
|
+
return "\n";
|
|
12
|
+
}
|
|
13
|
+
return Array.from(element.childNodes).map(function (child) {
|
|
14
|
+
return getNodePlainText(child);
|
|
15
|
+
}).join("");
|
|
16
|
+
}
|
|
17
|
+
function normalizeClipboardCellText(value) {
|
|
18
|
+
return value.replace(/\r\n/g, "\n").replace(/<br\s*\/?>/gi, "\n");
|
|
19
|
+
}
|
|
20
|
+
function formatTableCellForPlainText(value) {
|
|
21
|
+
var normalizedValue = normalizeClipboardCellText(value);
|
|
22
|
+
if (/["\n\t]/.test(normalizedValue)) {
|
|
23
|
+
return "\"".concat(normalizedValue.replace(/"/g, '""'), "\"");
|
|
24
|
+
}
|
|
25
|
+
return normalizedValue;
|
|
26
|
+
}
|
|
27
|
+
function tableToPlainText(table) {
|
|
28
|
+
var grid = [];
|
|
29
|
+
Array.from(table.rows).forEach(function (row, rowIndex) {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = grid[rowIndex]) !== null && _a !== void 0 ? _a : grid[rowIndex] = [];
|
|
32
|
+
var colIndex = 0;
|
|
33
|
+
Array.from(row.cells).forEach(function (cell) {
|
|
34
|
+
var _a;
|
|
35
|
+
while (grid[rowIndex][colIndex] !== undefined) {
|
|
36
|
+
colIndex += 1;
|
|
37
|
+
}
|
|
38
|
+
var cellText = Array.from(cell.childNodes).map(function (child) {
|
|
39
|
+
return getNodePlainText(child);
|
|
40
|
+
}).join("");
|
|
41
|
+
var rowSpan = Math.max(Number(cell.getAttribute("rowspan")) || 1, 1);
|
|
42
|
+
var colSpan = Math.max(Number(cell.getAttribute("colspan")) || 1, 1);
|
|
43
|
+
for (var r = 0; r < rowSpan; r += 1) {
|
|
44
|
+
var targetRow = rowIndex + r;
|
|
45
|
+
(_a = grid[targetRow]) !== null && _a !== void 0 ? _a : grid[targetRow] = [];
|
|
46
|
+
for (var c = 0; c < colSpan; c += 1) {
|
|
47
|
+
grid[targetRow][colIndex + c] = r === 0 && c === 0 ? cellText : "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
colIndex += colSpan;
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
var columnCount = grid.reduce(function (max, row) {
|
|
54
|
+
return Math.max(max, row.length);
|
|
55
|
+
}, 0);
|
|
56
|
+
return grid.map(function (row) {
|
|
57
|
+
return Array.from({
|
|
58
|
+
length: columnCount
|
|
59
|
+
}, function (_, index) {
|
|
60
|
+
var _a;
|
|
61
|
+
return (_a = row[index]) !== null && _a !== void 0 ? _a : "";
|
|
62
|
+
}).map(function (cell) {
|
|
63
|
+
return formatTableCellForPlainText(cell);
|
|
64
|
+
}).join("\t");
|
|
65
|
+
}).join("\n");
|
|
66
|
+
}
|
|
67
|
+
function legacyHtmlToPlainText(html) {
|
|
68
|
+
return html.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "");
|
|
69
|
+
}
|
|
70
|
+
function htmlToPlainText(html) {
|
|
71
|
+
var legacyPlainText = legacyHtmlToPlainText(html);
|
|
72
|
+
if (typeof document === "undefined" || !/<table[\s>]/i.test(html)) {
|
|
73
|
+
return legacyPlainText;
|
|
74
|
+
}
|
|
75
|
+
var container = document.createElement("div");
|
|
76
|
+
container.innerHTML = html;
|
|
77
|
+
var table = container.querySelector("table");
|
|
78
|
+
if (!table || table.rows.length === 0) {
|
|
79
|
+
return legacyPlainText;
|
|
80
|
+
}
|
|
81
|
+
return tableToPlainText(table);
|
|
82
|
+
}
|
|
83
|
+
function formatPlainTextForClipboard(plainText, isTableContent) {
|
|
84
|
+
if (isTableContent === void 0) {
|
|
85
|
+
isTableContent = false;
|
|
86
|
+
}
|
|
87
|
+
if (!isTableContent && plainText.includes("\n") && !plainText.includes("\t")) {
|
|
88
|
+
return "\"".concat(plainText.replace(/"/g, '""'), "\"");
|
|
89
|
+
}
|
|
90
|
+
return plainText;
|
|
91
|
+
}
|
|
1
92
|
var clipboard = function () {
|
|
2
93
|
function clipboard() {}
|
|
3
94
|
clipboard.writeHtml = function (str) {
|
|
4
|
-
var _a;
|
|
95
|
+
var _a, _b;
|
|
96
|
+
if (typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) === null || _a === void 0 ? void 0 : _a.write) === "function") {
|
|
97
|
+
var htmlStr = str;
|
|
98
|
+
var htmlBlob = new Blob([htmlStr], {
|
|
99
|
+
type: "text/html"
|
|
100
|
+
});
|
|
101
|
+
var isTableContent = /<table[\s>]/i.test(str);
|
|
102
|
+
var plainText = formatPlainTextForClipboard(htmlToPlainText(str), isTableContent);
|
|
103
|
+
var textBlob = new Blob([plainText], {
|
|
104
|
+
type: "text/plain"
|
|
105
|
+
});
|
|
106
|
+
navigator.clipboard.write([new ClipboardItem({
|
|
107
|
+
"text/html": htmlBlob,
|
|
108
|
+
"text/plain": textBlob
|
|
109
|
+
})]).catch(function (e) {
|
|
110
|
+
return console.error(e);
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
5
114
|
try {
|
|
6
115
|
var ele_1 = document.getElementById("fortune-copy-content");
|
|
7
116
|
if (!ele_1) {
|
|
@@ -12,7 +121,7 @@ var clipboard = function () {
|
|
|
12
121
|
ele_1.style.height = "0";
|
|
13
122
|
ele_1.style.width = "0";
|
|
14
123
|
ele_1.style.left = "-10000px";
|
|
15
|
-
(
|
|
124
|
+
(_b = document.querySelector(".fortune-container")) === null || _b === void 0 ? void 0 : _b.append(ele_1);
|
|
16
125
|
}
|
|
17
126
|
var previouslyFocusedElement_1 = document.activeElement;
|
|
18
127
|
ele_1.style.display = "block";
|
package/es/modules/format.js
CHANGED
|
@@ -240,20 +240,24 @@ export function genarate(value) {
|
|
|
240
240
|
v = datenum_local(dateObj);
|
|
241
241
|
ct.t = "d";
|
|
242
242
|
var map = {
|
|
243
|
-
"yyyy-MM-dd": "dd
|
|
244
|
-
"yyyy-MM-dd HH:mm": "dd
|
|
245
|
-
"yyyy-MM-ddTHH:mm": "dd
|
|
246
|
-
"yyyy/MM/dd": "
|
|
247
|
-
"yyyy/MM/dd HH:mm": "
|
|
243
|
+
"yyyy-MM-dd": "yyyy-MM-dd",
|
|
244
|
+
"yyyy-MM-dd HH:mm": "yyyy-MM-dd HH:mm",
|
|
245
|
+
"yyyy-MM-ddTHH:mm": "yyyy-MM-dd HH:mm",
|
|
246
|
+
"yyyy/MM/dd": "yyyy/MM/dd",
|
|
247
|
+
"yyyy/MM/dd HH:mm": "yyyy/MM/dd HH:mm",
|
|
248
248
|
"yyyy.MM.dd": "yyyy.MM.dd",
|
|
249
249
|
"MM/dd/yyyy h:mm AM/PM": "MM/dd/yyyy h:mm AM/PM",
|
|
250
250
|
"MM/dd/yyyy": "MM/dd/yyyy",
|
|
251
251
|
"M/d/yyyy": "M/d/yyyy",
|
|
252
252
|
"MM/dd/yy": "MM/dd/yy",
|
|
253
253
|
"dd/MM/yyyy": "dd/MM/yyyy",
|
|
254
|
-
"dd-MM-yyyy": "dd
|
|
254
|
+
"dd-MM-yyyy": "dd-MM-yyyy",
|
|
255
255
|
"dd.MM.yyyy": "dd.MM.yyyy",
|
|
256
|
-
named: "
|
|
256
|
+
"named-mdy-full": "mmmm d, yyyy",
|
|
257
|
+
"named-mdy-abbr": "mmm d, yyyy",
|
|
258
|
+
"named-dmy-full": "d mmmm yyyy",
|
|
259
|
+
"named-dmy-abbr": "d mmm yyyy",
|
|
260
|
+
"named-abbr-dashes": "mmm-d-yyyy"
|
|
257
261
|
};
|
|
258
262
|
ct.fa = map[df.formatType] || "dd/MM/yyyy";
|
|
259
263
|
m = SSF.format(ct.fa, v);
|
|
@@ -273,6 +277,7 @@ export function update(fmt, v) {
|
|
|
273
277
|
return SSF.format(fmt, v);
|
|
274
278
|
}
|
|
275
279
|
export function is_date(fmt, v) {
|
|
280
|
+
console.log(SSF.is_date(fmt, v), "is_date");
|
|
276
281
|
return SSF.is_date(fmt, v);
|
|
277
282
|
}
|
|
278
283
|
function fuzzynum(s) {
|
package/es/modules/formula.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export declare class FormulaCache {
|
|
|
20
20
|
rangetosheet?: string;
|
|
21
21
|
rangedrag_column_start?: boolean;
|
|
22
22
|
rangedrag_row_start?: boolean;
|
|
23
|
+
rangeSelectionActive?: boolean | null;
|
|
24
|
+
keyboardRangeSelectionLock?: boolean;
|
|
25
|
+
formulaEditorOwner?: "cell" | "fx" | null;
|
|
23
26
|
functionRangeIndex?: number[];
|
|
24
27
|
functionlistMap: any;
|
|
25
28
|
execFunctionExist?: any[];
|
|
@@ -44,8 +47,20 @@ export declare function setCaretPosition(ctx: Context, textDom: HTMLElement, chi
|
|
|
44
47
|
export declare function getrangeseleciton(): ParentNode | ChildNode | null | undefined;
|
|
45
48
|
export declare function rangeHightlightselected(ctx: Context, $editor: HTMLDivElement): void;
|
|
46
49
|
export declare function functionHTMLGenerate(txt: string): string;
|
|
50
|
+
export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): number | null;
|
|
51
|
+
export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
|
|
52
|
+
export declare function setFormulaEditorOwner(ctx: Context, owner: "cell" | "fx" | null): void;
|
|
53
|
+
export declare function getFormulaEditorOwner(ctx: Context): "cell" | "fx" | null;
|
|
54
|
+
export declare function hasIncompleteTruncatedCellRangeSyntax(formulaText: string): boolean;
|
|
55
|
+
export declare function isBareCellOrRangeOnlyFormula(formulaText: string): boolean;
|
|
56
|
+
export declare function suppressFormulaRangeSelectionForInitialEdit(ctx: Context): void;
|
|
57
|
+
export declare function isCaretAtValidFormulaRangeInsertionPoint(editor: HTMLElement | null): boolean;
|
|
58
|
+
export declare function markRangeSelectionDirty(ctx: Context): void;
|
|
59
|
+
export declare function getFormulaRangeIndexForKeyboardSync($editor: HTMLDivElement): number | null;
|
|
47
60
|
export declare function handleFormulaInput(ctx: Context, $copyTo: HTMLDivElement | null | undefined, $editor: HTMLDivElement, kcode: number, preText?: string, refreshRangeSelect?: boolean): void;
|
|
48
61
|
export declare function israngeseleciton(ctx: Context, istooltip?: boolean): boolean;
|
|
62
|
+
export declare function isFormulaReferenceInputMode(ctx: Context): boolean;
|
|
63
|
+
export declare function maybeRecoverDirtyRangeSelection(ctx: Context): boolean;
|
|
49
64
|
export declare function functionStrChange(txt: string, type: string, rc: "row" | "col", orient: string | null, stindex: number, step: number): string;
|
|
50
65
|
export declare function rangeSetValue(ctx: Context, cellInput: HTMLDivElement, selected: any, fxInput?: HTMLDivElement | null): void;
|
|
51
66
|
export declare function onFormulaRangeDragEnd(ctx: Context): void;
|
|
@@ -53,3 +68,11 @@ export declare function rangeDrag(ctx: Context, e: MouseEvent, cellInput: HTMLDi
|
|
|
53
68
|
export declare function rangeDragColumn(ctx: Context, e: MouseEvent, cellInput: HTMLDivElement, scrollLeft: number, scrollTop: number, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
|
|
54
69
|
export declare function rangeDragRow(ctx: Context, e: MouseEvent, cellInput: HTMLDivElement, scrollLeft: number, scrollTop: number, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
|
|
55
70
|
export declare function functionCopy(ctx: Context, txt: string, mode: string, step: number): string;
|
|
71
|
+
type MoveReferenceRect = {
|
|
72
|
+
rowStart: number;
|
|
73
|
+
rowEnd: number;
|
|
74
|
+
colStart: number;
|
|
75
|
+
colEnd: number;
|
|
76
|
+
};
|
|
77
|
+
export declare function functionMoveReference(txt: string, formulaSheetName: string, movedSheetName: string, sourceRect: MoveReferenceRect, targetRowStart: number, targetColStart: number): string;
|
|
78
|
+
export {};
|