@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
|
@@ -706,6 +706,32 @@ function compute(ctx, ruleArr, d) {
|
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
+
} else if (conditionName === "empty") {
|
|
710
|
+
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
711
|
+
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
712
|
+
var cell = _lodash.default.isNil(d[r]) || _lodash.default.isNil(d[r][c]) ? null : d[r][c];
|
|
713
|
+
var isEmpty = _lodash.default.isNil(cell) || _lodash.default.isNil(cell.v) || (0, _validation.isRealNull)(cell.v);
|
|
714
|
+
if (isEmpty) {
|
|
715
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
716
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
717
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
718
|
+
computeMap["".concat(r, "_").concat(c)].bold = bold_1;
|
|
719
|
+
computeMap["".concat(r, "_").concat(c)].italic = italic_1;
|
|
720
|
+
computeMap["".concat(r, "_").concat(c)].underline = underline_1;
|
|
721
|
+
computeMap["".concat(r, "_").concat(c)].strikethrough = strikethrough_1;
|
|
722
|
+
} else {
|
|
723
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
724
|
+
textColor: textColor_1,
|
|
725
|
+
cellColor: cellColor_1,
|
|
726
|
+
bold: bold_1,
|
|
727
|
+
italic: italic_1,
|
|
728
|
+
underline: underline_1,
|
|
729
|
+
strikethrough: strikethrough_1
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
709
735
|
} else if (conditionName === "between") {
|
|
710
736
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
711
737
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
package/lib/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/lib/modules/cell.js
CHANGED
|
@@ -41,6 +41,7 @@ var _formula = require("./formula");
|
|
|
41
41
|
var _inlineString = require("./inline-string");
|
|
42
42
|
var _validation = require("./validation");
|
|
43
43
|
var _text = require("./text");
|
|
44
|
+
var _locale = require("../locale");
|
|
44
45
|
var _sort = require("./sort");
|
|
45
46
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
46
47
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
@@ -102,6 +103,32 @@ function newlinesToBr(text) {
|
|
|
102
103
|
if (!text) return "";
|
|
103
104
|
return text.replace(/\r\n|\r|\n/g, "<br />");
|
|
104
105
|
}
|
|
106
|
+
function closeUnclosedParenthesesInFormula(formula) {
|
|
107
|
+
if (!formula.startsWith("=") || formula.length <= 1) return formula;
|
|
108
|
+
var body = formula.slice(1);
|
|
109
|
+
var depth = 0;
|
|
110
|
+
var inString = false;
|
|
111
|
+
for (var i = 0; i < body.length; i += 1) {
|
|
112
|
+
var ch = body[i];
|
|
113
|
+
if (inString) {
|
|
114
|
+
if (ch === '"') {
|
|
115
|
+
if (body[i + 1] === '"') {
|
|
116
|
+
i += 1;
|
|
117
|
+
} else {
|
|
118
|
+
inString = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (ch === '"') {
|
|
124
|
+
inString = true;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (ch === "(") depth += 1;else if (ch === ")") depth = Math.max(0, depth - 1);
|
|
128
|
+
}
|
|
129
|
+
if (depth <= 0) return formula;
|
|
130
|
+
return "".concat(formula).concat(")".repeat(depth));
|
|
131
|
+
}
|
|
105
132
|
function getCellValue(r, c, data, attr) {
|
|
106
133
|
var _a;
|
|
107
134
|
if (!attr) {
|
|
@@ -574,6 +601,8 @@ function cancelNormalSelected(ctx) {
|
|
|
574
601
|
ctx.formulaCache.rangestart = false;
|
|
575
602
|
ctx.formulaCache.rangedrag_column_start = false;
|
|
576
603
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
604
|
+
ctx.formulaCache.rangeSelectionActive = null;
|
|
605
|
+
ctx.formulaCache.formulaEditorOwner = null;
|
|
577
606
|
}
|
|
578
607
|
function updateCell(ctx, r, c, $input, value, canvas) {
|
|
579
608
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
@@ -649,6 +678,11 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
649
678
|
}
|
|
650
679
|
}
|
|
651
680
|
value = value || inputText;
|
|
681
|
+
if (_lodash.default.isString(value) && value.startsWith("=") && value.length > 1) {
|
|
682
|
+
value = closeUnclosedParenthesesInFormula(value);
|
|
683
|
+
} else if (_lodash.default.isPlainObject(value) && _lodash.default.isString(value.f) && value.f.startsWith("=") && value.f.length > 1) {
|
|
684
|
+
value.f = closeUnclosedParenthesesInFormula(value.f);
|
|
685
|
+
}
|
|
652
686
|
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;
|
|
653
687
|
if (shouldClearError) {
|
|
654
688
|
(0, _api.clearCellError)(ctx, r, c);
|
|
@@ -1008,37 +1042,68 @@ function getRangeByTxt(ctx, txt) {
|
|
|
1008
1042
|
return range;
|
|
1009
1043
|
}
|
|
1010
1044
|
function isAllSelectedCellsInStatus(ctx, attr, status) {
|
|
1011
|
-
var _a, _b
|
|
1045
|
+
var _a, _b;
|
|
1012
1046
|
if (!_lodash.default.isEmpty(ctx.luckysheetCellUpdate)) {
|
|
1013
1047
|
var w = window.getSelection();
|
|
1014
1048
|
if (!w) return false;
|
|
1015
1049
|
if (w.rangeCount === 0) return false;
|
|
1016
|
-
var
|
|
1017
|
-
if (
|
|
1050
|
+
var range_1 = w.getRangeAt(0);
|
|
1051
|
+
if (range_1.collapsed === true) {
|
|
1018
1052
|
return false;
|
|
1019
1053
|
}
|
|
1020
|
-
var endContainer =
|
|
1021
|
-
var startContainer =
|
|
1022
|
-
var
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1054
|
+
var endContainer = range_1.endContainer;
|
|
1055
|
+
var startContainer = range_1.startContainer;
|
|
1056
|
+
var toElement = function toElement(n) {
|
|
1057
|
+
if (!n) return null;
|
|
1058
|
+
if (n.nodeType === Node.ELEMENT_NODE) return n;
|
|
1059
|
+
return n.parentElement;
|
|
1060
|
+
};
|
|
1061
|
+
var startEl = toElement(startContainer);
|
|
1062
|
+
var endEl = toElement(endContainer);
|
|
1063
|
+
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);
|
|
1064
|
+
var isStyleActive_1 = function isStyleActive_1(element) {
|
|
1065
|
+
var computed = window.getComputedStyle(element);
|
|
1066
|
+
var fontWeight = (computed.fontWeight || "").toLowerCase();
|
|
1067
|
+
var fontStyle = (computed.fontStyle || "").toLowerCase();
|
|
1068
|
+
var textDecorationLine = (computed.textDecorationLine || computed.textDecoration || "").toLowerCase();
|
|
1069
|
+
var borderBottomWidth = (computed.borderBottomWidth || "").toLowerCase();
|
|
1070
|
+
if (status === 1) {
|
|
1071
|
+
if (attr === "bl") {
|
|
1072
|
+
if (fontWeight === "bold") return true;
|
|
1073
|
+
var n = Number(fontWeight);
|
|
1074
|
+
return !Number.isNaN(n) && n >= 600;
|
|
1075
|
+
}
|
|
1076
|
+
if (attr === "it") {
|
|
1077
|
+
return fontStyle === "italic" || fontStyle === "oblique";
|
|
1078
|
+
}
|
|
1079
|
+
if (attr === "cl") {
|
|
1080
|
+
return textDecorationLine.includes("line-through");
|
|
1081
|
+
}
|
|
1082
|
+
if (attr === "un") {
|
|
1083
|
+
return textDecorationLine.includes("underline") || borderBottomWidth !== "" && borderBottomWidth !== "0px" && borderBottomWidth !== "0";
|
|
1036
1084
|
}
|
|
1037
|
-
return _lodash.default.every(rangeSpans, function (s) {
|
|
1038
|
-
return !_lodash.default.isEmpty(s.style[cssField_1]);
|
|
1039
|
-
});
|
|
1040
1085
|
}
|
|
1086
|
+
return false;
|
|
1087
|
+
};
|
|
1088
|
+
var selectedElements_1 = [];
|
|
1089
|
+
if (editorRoot) {
|
|
1090
|
+
var spans = editorRoot.querySelectorAll("span");
|
|
1091
|
+
spans.forEach(function (span) {
|
|
1092
|
+
if (span.textContent && span.textContent.length > 0 && range_1.intersectsNode(span)) {
|
|
1093
|
+
selectedElements_1.push(span);
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
if (selectedElements_1.length === 0) {
|
|
1098
|
+
if (startEl) selectedElements_1.push(startEl);
|
|
1099
|
+
if (endEl && endEl !== startEl) selectedElements_1.push(endEl);
|
|
1100
|
+
}
|
|
1101
|
+
if (selectedElements_1.length === 0) {
|
|
1102
|
+
return false;
|
|
1041
1103
|
}
|
|
1104
|
+
return _lodash.default.every(selectedElements_1, function (el) {
|
|
1105
|
+
return isStyleActive_1(el);
|
|
1106
|
+
});
|
|
1042
1107
|
}
|
|
1043
1108
|
var cells = getFlattenedRange(ctx);
|
|
1044
1109
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
@@ -1074,7 +1139,7 @@ function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
|
|
|
1074
1139
|
if (key === "it" && valueNum !== 0) {
|
|
1075
1140
|
style.fontStyle = "italic";
|
|
1076
1141
|
}
|
|
1077
|
-
if (key === "fs" &&
|
|
1142
|
+
if (key === "fs" && !_lodash.default.isNil(value)) {
|
|
1078
1143
|
style.fontSize = "".concat(valueNum, "pt");
|
|
1079
1144
|
}
|
|
1080
1145
|
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)) {
|
|
@@ -1098,14 +1163,13 @@ function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
|
|
|
1098
1163
|
return style;
|
|
1099
1164
|
}
|
|
1100
1165
|
function getStyleByCell(ctx, d, r, c) {
|
|
1101
|
-
var _a;
|
|
1166
|
+
var _a, _b;
|
|
1102
1167
|
var style = {};
|
|
1103
1168
|
var checksAF = [];
|
|
1104
1169
|
var cf_compute = (0, _ConditionFormat.getComputeMap)(ctx);
|
|
1105
1170
|
var checksCF = (0, _ConditionFormat.checkCF)(r, c, cf_compute);
|
|
1106
1171
|
var cell = (_a = d === null || d === void 0 ? void 0 : d[r]) === null || _a === void 0 ? void 0 : _a[c];
|
|
1107
1172
|
if (!cell) return {};
|
|
1108
|
-
var isInline = (0, _inlineString.isInlineStringCell)(cell);
|
|
1109
1173
|
if ("bg" in cell) {
|
|
1110
1174
|
var value = normalizedCellAttr(cell, "bg");
|
|
1111
1175
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.cellColor) {
|
|
@@ -1136,7 +1200,9 @@ function getStyleByCell(ctx, d, r, c) {
|
|
|
1136
1200
|
}
|
|
1137
1201
|
if ("ff" in cell) {
|
|
1138
1202
|
var value = normalizedCellAttr(cell, "ff");
|
|
1139
|
-
|
|
1203
|
+
var fontarray = (0, _locale.locale)(ctx).fontarray;
|
|
1204
|
+
var ffIndex = parseInt(value, 10);
|
|
1205
|
+
style.fontFamily = Number.isNaN(ffIndex) ? value : (_b = fontarray[ffIndex]) !== null && _b !== void 0 ? _b : value;
|
|
1140
1206
|
}
|
|
1141
1207
|
if ("vt" in cell) {
|
|
1142
1208
|
var value = normalizedCellAttr(cell, "vt");
|
|
@@ -1146,12 +1212,52 @@ function getStyleByCell(ctx, d, r, c) {
|
|
|
1146
1212
|
style.alignItems = "flex-end";
|
|
1147
1213
|
}
|
|
1148
1214
|
}
|
|
1149
|
-
|
|
1150
|
-
style = _lodash.default.assign(style, getFontStyleByCell(cell, checksAF, checksCF));
|
|
1151
|
-
}
|
|
1215
|
+
style = _lodash.default.assign(style, getFontStyleByCell(cell, checksAF, checksCF));
|
|
1152
1216
|
return style;
|
|
1153
1217
|
}
|
|
1154
|
-
function
|
|
1218
|
+
function normalizeInlineStringClipboardStyle(style) {
|
|
1219
|
+
var decorations = new Set();
|
|
1220
|
+
var normalizedStyle = {
|
|
1221
|
+
color: style.color || "#000000",
|
|
1222
|
+
fontFamily: style.fontFamily || "Arial",
|
|
1223
|
+
fontSize: style.fontSize || "11pt",
|
|
1224
|
+
fontStyle: style.fontStyle || "normal",
|
|
1225
|
+
fontWeight: style.fontWeight || "400"
|
|
1226
|
+
};
|
|
1227
|
+
var backgroundColor = style.backgroundColor || style.background;
|
|
1228
|
+
if (backgroundColor && backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
1229
|
+
normalizedStyle.backgroundColor = backgroundColor;
|
|
1230
|
+
}
|
|
1231
|
+
if (typeof style.textDecoration === "string") {
|
|
1232
|
+
style.textDecoration.split(/\s+/).filter(Boolean).forEach(function (decoration) {
|
|
1233
|
+
return decorations.add(decoration);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
if (style.borderBottom) {
|
|
1237
|
+
decorations.add("underline");
|
|
1238
|
+
normalizedStyle.textDecorationSkipInk = "none";
|
|
1239
|
+
}
|
|
1240
|
+
if (decorations.size > 0) {
|
|
1241
|
+
normalizedStyle.textDecoration = Array.from(decorations).join(" ");
|
|
1242
|
+
}
|
|
1243
|
+
return normalizedStyle;
|
|
1244
|
+
}
|
|
1245
|
+
function buildClipboardCompatibleInlineRuns(text, styleAttr) {
|
|
1246
|
+
var normalizedText = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
1247
|
+
var segments = normalizedText.split("\n");
|
|
1248
|
+
return segments.map(function (segment, index) {
|
|
1249
|
+
var html = "";
|
|
1250
|
+
if (segment.length > 0) {
|
|
1251
|
+
html += "<span style='".concat(styleAttr, "'>").concat(segment, "</span>");
|
|
1252
|
+
}
|
|
1253
|
+
if (index < segments.length - 1) {
|
|
1254
|
+
html += "<span style='".concat(styleAttr, "'><br></span>");
|
|
1255
|
+
}
|
|
1256
|
+
return html;
|
|
1257
|
+
}).join("");
|
|
1258
|
+
}
|
|
1259
|
+
function getInlineStringHTML(r, c, data, options) {
|
|
1260
|
+
var _a;
|
|
1155
1261
|
var ct = getCellValue(r, c, data, "ct");
|
|
1156
1262
|
if ((0, _inlineString.isInlineStringCT)(ct)) {
|
|
1157
1263
|
var strings = ct.s;
|
|
@@ -1159,17 +1265,49 @@ function getInlineStringHTML(r, c, data) {
|
|
|
1159
1265
|
for (var i = 0; i < strings.length; i += 1) {
|
|
1160
1266
|
var strObj = strings[i];
|
|
1161
1267
|
if (strObj.v) {
|
|
1162
|
-
var
|
|
1268
|
+
var baseStyle = __assign(__assign({}, (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) ? (_a = options.inheritedStyle) !== null && _a !== void 0 ? _a : {} : {}), getFontStyleByCell(strObj));
|
|
1269
|
+
var style = (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) ? normalizeInlineStringClipboardStyle(baseStyle) : baseStyle;
|
|
1270
|
+
if (!style.fontWeight) {
|
|
1271
|
+
style.fontWeight = "400";
|
|
1272
|
+
}
|
|
1273
|
+
if (!style.fontStyle) {
|
|
1274
|
+
style.fontStyle = "normal";
|
|
1275
|
+
}
|
|
1276
|
+
if (!style.fontSize) {
|
|
1277
|
+
style.fontSize = "11pt";
|
|
1278
|
+
}
|
|
1279
|
+
if (!style.fontFamily) {
|
|
1280
|
+
style.fontFamily = "Arial";
|
|
1281
|
+
}
|
|
1163
1282
|
var link = strObj.link;
|
|
1164
1283
|
if ((link === null || link === void 0 ? void 0 : link.linkType) && (link === null || link === void 0 ? void 0 : link.linkAddress)) {
|
|
1165
1284
|
style.color = style.color || "rgb(0, 0, 255)";
|
|
1166
|
-
|
|
1285
|
+
if (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) {
|
|
1286
|
+
style.textDecoration = style.textDecoration ? "".concat(style.textDecoration, " underline") : "underline";
|
|
1287
|
+
style.textDecorationSkipInk = "none";
|
|
1288
|
+
} else {
|
|
1289
|
+
style.borderBottom = style.borderBottom || "1px solid rgb(0, 0, 255)";
|
|
1290
|
+
}
|
|
1167
1291
|
}
|
|
1168
|
-
var styleStr = _lodash.default.
|
|
1292
|
+
var styleStr = _lodash.default.toPairs(style).filter(function (_a) {
|
|
1293
|
+
var v = _a[1];
|
|
1294
|
+
return !_lodash.default.isNil(v) && v !== "" && v !== "undefined";
|
|
1295
|
+
}).map(function (_a) {
|
|
1296
|
+
var key = _a[0],
|
|
1297
|
+
v = _a[1];
|
|
1169
1298
|
return "".concat(_lodash.default.kebabCase(key), ":").concat(_lodash.default.isNumber(v) ? "".concat(v, "px") : v, ";");
|
|
1170
|
-
}).join("");
|
|
1171
|
-
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, "'"), "'") : "";
|
|
1172
|
-
|
|
1299
|
+
}).join(" ");
|
|
1300
|
+
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, "'"), "'") : "";
|
|
1301
|
+
if (options === null || options === void 0 ? void 0 : options.isRangeCopy) {
|
|
1302
|
+
if (options === null || options === void 0 ? void 0 : options.useSemanticMarkup) {
|
|
1303
|
+
value += buildClipboardCompatibleInlineRuns(strObj.v, styleStr);
|
|
1304
|
+
} else {
|
|
1305
|
+
var segmentText = strObj.v.replace(/\r\n/g, "<br>").replace(/\n/g, "<br>");
|
|
1306
|
+
value += "<span class=\"luckysheet-input-span\" index='".concat(i, "' style='").concat(styleStr, "'").concat(dataAttrs, ">").concat(segmentText, "</span>");
|
|
1307
|
+
}
|
|
1308
|
+
} else {
|
|
1309
|
+
value += "<span class=\"luckysheet-input-span\" index='".concat(i, "' style='").concat(styleStr, "'").concat(dataAttrs, ">").concat(strObj.v, "</span>");
|
|
1310
|
+
}
|
|
1173
1311
|
}
|
|
1174
1312
|
}
|
|
1175
1313
|
return value;
|
|
@@ -1257,6 +1395,12 @@ function getdatabyselection(ctx, range, sheetId) {
|
|
|
1257
1395
|
return data;
|
|
1258
1396
|
}
|
|
1259
1397
|
function luckysheetUpdateCell(ctx, row_index, col_index) {
|
|
1398
|
+
var _a;
|
|
1399
|
+
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
1400
|
+
var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
|
|
1401
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null && String(cell.f).trim() !== "") {
|
|
1402
|
+
(0, _formula.suppressFormulaRangeSelectionForInitialEdit)(ctx);
|
|
1403
|
+
}
|
|
1260
1404
|
ctx.luckysheetCellUpdate = [row_index, col_index];
|
|
1261
1405
|
}
|
|
1262
1406
|
function getDataBySelectionNoCopy(ctx, range) {
|
package/lib/modules/clipboard.js
CHANGED
|
@@ -4,10 +4,119 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
function getNodePlainText(node) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (node.nodeType === 3) {
|
|
10
|
+
return (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
|
|
11
|
+
}
|
|
12
|
+
if (node.nodeType !== 1) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
var element = node;
|
|
16
|
+
if (element.tagName === "BR") {
|
|
17
|
+
return "\n";
|
|
18
|
+
}
|
|
19
|
+
return Array.from(element.childNodes).map(function (child) {
|
|
20
|
+
return getNodePlainText(child);
|
|
21
|
+
}).join("");
|
|
22
|
+
}
|
|
23
|
+
function normalizeClipboardCellText(value) {
|
|
24
|
+
return value.replace(/\r\n/g, "\n").replace(/<br\s*\/?>/gi, "\n");
|
|
25
|
+
}
|
|
26
|
+
function formatTableCellForPlainText(value) {
|
|
27
|
+
var normalizedValue = normalizeClipboardCellText(value);
|
|
28
|
+
if (/["\n\t]/.test(normalizedValue)) {
|
|
29
|
+
return "\"".concat(normalizedValue.replace(/"/g, '""'), "\"");
|
|
30
|
+
}
|
|
31
|
+
return normalizedValue;
|
|
32
|
+
}
|
|
33
|
+
function tableToPlainText(table) {
|
|
34
|
+
var grid = [];
|
|
35
|
+
Array.from(table.rows).forEach(function (row, rowIndex) {
|
|
36
|
+
var _a;
|
|
37
|
+
(_a = grid[rowIndex]) !== null && _a !== void 0 ? _a : grid[rowIndex] = [];
|
|
38
|
+
var colIndex = 0;
|
|
39
|
+
Array.from(row.cells).forEach(function (cell) {
|
|
40
|
+
var _a;
|
|
41
|
+
while (grid[rowIndex][colIndex] !== undefined) {
|
|
42
|
+
colIndex += 1;
|
|
43
|
+
}
|
|
44
|
+
var cellText = Array.from(cell.childNodes).map(function (child) {
|
|
45
|
+
return getNodePlainText(child);
|
|
46
|
+
}).join("");
|
|
47
|
+
var rowSpan = Math.max(Number(cell.getAttribute("rowspan")) || 1, 1);
|
|
48
|
+
var colSpan = Math.max(Number(cell.getAttribute("colspan")) || 1, 1);
|
|
49
|
+
for (var r = 0; r < rowSpan; r += 1) {
|
|
50
|
+
var targetRow = rowIndex + r;
|
|
51
|
+
(_a = grid[targetRow]) !== null && _a !== void 0 ? _a : grid[targetRow] = [];
|
|
52
|
+
for (var c = 0; c < colSpan; c += 1) {
|
|
53
|
+
grid[targetRow][colIndex + c] = r === 0 && c === 0 ? cellText : "";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
colIndex += colSpan;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
var columnCount = grid.reduce(function (max, row) {
|
|
60
|
+
return Math.max(max, row.length);
|
|
61
|
+
}, 0);
|
|
62
|
+
return grid.map(function (row) {
|
|
63
|
+
return Array.from({
|
|
64
|
+
length: columnCount
|
|
65
|
+
}, function (_, index) {
|
|
66
|
+
var _a;
|
|
67
|
+
return (_a = row[index]) !== null && _a !== void 0 ? _a : "";
|
|
68
|
+
}).map(function (cell) {
|
|
69
|
+
return formatTableCellForPlainText(cell);
|
|
70
|
+
}).join("\t");
|
|
71
|
+
}).join("\n");
|
|
72
|
+
}
|
|
73
|
+
function legacyHtmlToPlainText(html) {
|
|
74
|
+
return html.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "");
|
|
75
|
+
}
|
|
76
|
+
function htmlToPlainText(html) {
|
|
77
|
+
var legacyPlainText = legacyHtmlToPlainText(html);
|
|
78
|
+
if (typeof document === "undefined" || !/<table[\s>]/i.test(html)) {
|
|
79
|
+
return legacyPlainText;
|
|
80
|
+
}
|
|
81
|
+
var container = document.createElement("div");
|
|
82
|
+
container.innerHTML = html;
|
|
83
|
+
var table = container.querySelector("table");
|
|
84
|
+
if (!table || table.rows.length === 0) {
|
|
85
|
+
return legacyPlainText;
|
|
86
|
+
}
|
|
87
|
+
return tableToPlainText(table);
|
|
88
|
+
}
|
|
89
|
+
function formatPlainTextForClipboard(plainText, isTableContent) {
|
|
90
|
+
if (isTableContent === void 0) {
|
|
91
|
+
isTableContent = false;
|
|
92
|
+
}
|
|
93
|
+
if (!isTableContent && plainText.includes("\n") && !plainText.includes("\t")) {
|
|
94
|
+
return "\"".concat(plainText.replace(/"/g, '""'), "\"");
|
|
95
|
+
}
|
|
96
|
+
return plainText;
|
|
97
|
+
}
|
|
7
98
|
var clipboard = function () {
|
|
8
99
|
function clipboard() {}
|
|
9
100
|
clipboard.writeHtml = function (str) {
|
|
10
|
-
var _a;
|
|
101
|
+
var _a, _b;
|
|
102
|
+
if (typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) === null || _a === void 0 ? void 0 : _a.write) === "function") {
|
|
103
|
+
var htmlStr = str;
|
|
104
|
+
var htmlBlob = new Blob([htmlStr], {
|
|
105
|
+
type: "text/html"
|
|
106
|
+
});
|
|
107
|
+
var isTableContent = /<table[\s>]/i.test(str);
|
|
108
|
+
var plainText = formatPlainTextForClipboard(htmlToPlainText(str), isTableContent);
|
|
109
|
+
var textBlob = new Blob([plainText], {
|
|
110
|
+
type: "text/plain"
|
|
111
|
+
});
|
|
112
|
+
navigator.clipboard.write([new ClipboardItem({
|
|
113
|
+
"text/html": htmlBlob,
|
|
114
|
+
"text/plain": textBlob
|
|
115
|
+
})]).catch(function (e) {
|
|
116
|
+
return console.error(e);
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
11
120
|
try {
|
|
12
121
|
var ele_1 = document.getElementById("fortune-copy-content");
|
|
13
122
|
if (!ele_1) {
|
|
@@ -18,7 +127,7 @@ var clipboard = function () {
|
|
|
18
127
|
ele_1.style.height = "0";
|
|
19
128
|
ele_1.style.width = "0";
|
|
20
129
|
ele_1.style.left = "-10000px";
|
|
21
|
-
(
|
|
130
|
+
(_b = document.querySelector(".fortune-container")) === null || _b === void 0 ? void 0 : _b.append(ele_1);
|
|
22
131
|
}
|
|
23
132
|
var previouslyFocusedElement_1 = document.activeElement;
|
|
24
133
|
ele_1.style.display = "block";
|
package/lib/modules/format.js
CHANGED
|
@@ -251,20 +251,24 @@ function genarate(value) {
|
|
|
251
251
|
v = datenum_local(dateObj);
|
|
252
252
|
ct.t = "d";
|
|
253
253
|
var map = {
|
|
254
|
-
"yyyy-MM-dd": "dd
|
|
255
|
-
"yyyy-MM-dd HH:mm": "dd
|
|
256
|
-
"yyyy-MM-ddTHH:mm": "dd
|
|
257
|
-
"yyyy/MM/dd": "
|
|
258
|
-
"yyyy/MM/dd HH:mm": "
|
|
254
|
+
"yyyy-MM-dd": "yyyy-MM-dd",
|
|
255
|
+
"yyyy-MM-dd HH:mm": "yyyy-MM-dd HH:mm",
|
|
256
|
+
"yyyy-MM-ddTHH:mm": "yyyy-MM-dd HH:mm",
|
|
257
|
+
"yyyy/MM/dd": "yyyy/MM/dd",
|
|
258
|
+
"yyyy/MM/dd HH:mm": "yyyy/MM/dd HH:mm",
|
|
259
259
|
"yyyy.MM.dd": "yyyy.MM.dd",
|
|
260
260
|
"MM/dd/yyyy h:mm AM/PM": "MM/dd/yyyy h:mm AM/PM",
|
|
261
261
|
"MM/dd/yyyy": "MM/dd/yyyy",
|
|
262
262
|
"M/d/yyyy": "M/d/yyyy",
|
|
263
263
|
"MM/dd/yy": "MM/dd/yy",
|
|
264
264
|
"dd/MM/yyyy": "dd/MM/yyyy",
|
|
265
|
-
"dd-MM-yyyy": "dd
|
|
265
|
+
"dd-MM-yyyy": "dd-MM-yyyy",
|
|
266
266
|
"dd.MM.yyyy": "dd.MM.yyyy",
|
|
267
|
-
named: "
|
|
267
|
+
"named-mdy-full": "mmmm d, yyyy",
|
|
268
|
+
"named-mdy-abbr": "mmm d, yyyy",
|
|
269
|
+
"named-dmy-full": "d mmmm yyyy",
|
|
270
|
+
"named-dmy-abbr": "d mmm yyyy",
|
|
271
|
+
"named-abbr-dashes": "mmm-d-yyyy"
|
|
268
272
|
};
|
|
269
273
|
ct.fa = map[df.formatType] || "dd/MM/yyyy";
|
|
270
274
|
m = _ssf.default.format(ct.fa, v);
|
|
@@ -284,6 +288,7 @@ function update(fmt, v) {
|
|
|
284
288
|
return _ssf.default.format(fmt, v);
|
|
285
289
|
}
|
|
286
290
|
function is_date(fmt, v) {
|
|
291
|
+
console.log(_ssf.default.is_date(fmt, v), "is_date");
|
|
287
292
|
return _ssf.default.is_date(fmt, v);
|
|
288
293
|
}
|
|
289
294
|
function fuzzynum(s) {
|
package/lib/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 {};
|