@fileverse-dev/fortune-core 1.2.56-patch-1 → 1.2.56-patch-3
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/paste.js +1 -2
- package/es/paste-table-helpers.js +19 -13
- package/lib/events/paste.js +1 -2
- package/lib/paste-table-helpers.js +19 -13
- package/package.json +1 -1
package/es/events/paste.js
CHANGED
|
@@ -77,7 +77,7 @@ export function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow)
|
|
|
77
77
|
var colOffset = destCol - srcCol;
|
|
78
78
|
var rowOffset = destRow - srcRow;
|
|
79
79
|
var hadInvalid = false;
|
|
80
|
-
var result = formula.replace(
|
|
80
|
+
var result = formula.replace(/\b(\$?)([A-Z]+)(\$?)(\d+)\b/g, function (__, absCol, colLetters, absRow, rowNum) {
|
|
81
81
|
var colIndex = columnLabelIndex(colLetters);
|
|
82
82
|
var rowIndex = parseInt(rowNum, 10);
|
|
83
83
|
if (!absCol) colIndex += colOffset;
|
|
@@ -1253,7 +1253,6 @@ export function handlePaste(ctx, e) {
|
|
|
1253
1253
|
} else if (txtdata.indexOf("fortune-copy-action-image") > -1) {} else {
|
|
1254
1254
|
if (txtdata.indexOf("table") > -1) {
|
|
1255
1255
|
handlePastedTable(ctx, txtdata, pasteHandler);
|
|
1256
|
-
resizePastedCellsToContent(ctx);
|
|
1257
1256
|
} else if (clipboardData.files.length === 1 && clipboardData.files[0].type.indexOf("image") > -1) {} else {
|
|
1258
1257
|
txtdata = clipboardData.getData("text/plain");
|
|
1259
1258
|
var isExcelFormula = txtdata.startsWith("=");
|
|
@@ -14,7 +14,7 @@ import { locale } from "./locale";
|
|
|
14
14
|
import { getQKBorder, saveHyperlink } from "./modules";
|
|
15
15
|
import { genarate } from "./modules/format";
|
|
16
16
|
import { getSheetIndex } from "./utils";
|
|
17
|
-
import { setRowHeight } from "
|
|
17
|
+
import { setRowHeight, setColumnWidth } from "./api";
|
|
18
18
|
export var DEFAULT_FONT_SIZE = 12;
|
|
19
19
|
var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
|
|
20
20
|
var patternReg = /{([^}]*)}/g;
|
|
@@ -128,7 +128,7 @@ function brToNewline(str) {
|
|
|
128
128
|
}
|
|
129
129
|
var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
130
130
|
var _a;
|
|
131
|
-
var _b, _c, _d;
|
|
131
|
+
var _b, _c, _d, _e;
|
|
132
132
|
var cell = {};
|
|
133
133
|
var rawText = (td.innerText || td.innerHTML || "").trim();
|
|
134
134
|
var isLineBreak = rawText.includes("<br />");
|
|
@@ -157,6 +157,13 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
157
157
|
cell.v = rawText;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
if (((_b = td.style) === null || _b === void 0 ? void 0 : _b.alignItems) === "center") {
|
|
161
|
+
cell.vt = 0;
|
|
162
|
+
} else if (((_c = td.style) === null || _c === void 0 ? void 0 : _c.alignItems) === "flex-end") {
|
|
163
|
+
cell.vt = 2;
|
|
164
|
+
} else if (((_d = td.style) === null || _d === void 0 ? void 0 : _d.alignItems) === "flex-start") {
|
|
165
|
+
cell.vt = 1;
|
|
166
|
+
}
|
|
160
167
|
var styleBlock = typeof classStyles[".".concat(td.className)] === "string" ? classStyles[".".concat(td.className)] : "";
|
|
161
168
|
var styles = parseInlineStyleBlock(styleBlock);
|
|
162
169
|
if (!_.isNil(styles.border)) td.style.border = styles.border;
|
|
@@ -181,17 +188,7 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
181
188
|
} else {
|
|
182
189
|
cell.ht = 1;
|
|
183
190
|
}
|
|
184
|
-
|
|
185
|
-
var vtStyle = typeof classStyles.td === "string" && ((_c = (_b = classStyles.td.match(regex)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : "") || "top";
|
|
186
|
-
var vt = td.style.verticalAlign || styles["vertical-align"] || vtStyle;
|
|
187
|
-
if (vt === "middle") {
|
|
188
|
-
cell.vt = 0;
|
|
189
|
-
} else if (vt === "top" || vt === "text-top") {
|
|
190
|
-
cell.vt = 1;
|
|
191
|
-
} else {
|
|
192
|
-
cell.vt = 2;
|
|
193
|
-
}
|
|
194
|
-
if (((_d = td === null || td === void 0 ? void 0 : td.style) === null || _d === void 0 ? void 0 : _d["overflow-wrap"]) === "anywhere") {
|
|
191
|
+
if (((_e = td === null || td === void 0 ? void 0 : td.style) === null || _e === void 0 ? void 0 : _e["overflow-wrap"]) === "anywhere") {
|
|
195
192
|
cell.tb = "2";
|
|
196
193
|
} else {
|
|
197
194
|
cell.tb = "2";
|
|
@@ -213,6 +210,15 @@ export function handlePastedTable(ctx, html, pasteHandler) {
|
|
|
213
210
|
if (!html.includes("table")) return;
|
|
214
211
|
var containerDiv = document.createElement("div");
|
|
215
212
|
containerDiv.innerHTML = html;
|
|
213
|
+
var tableColGropup = containerDiv.querySelectorAll("colgroup");
|
|
214
|
+
tableColGropup.forEach(function (colGroup, index) {
|
|
215
|
+
var _a;
|
|
216
|
+
var colWidth = colGroup === null || colGroup === void 0 ? void 0 : colGroup.getAttribute("width");
|
|
217
|
+
var intColWidth = parseInt(colWidth || "0", 10);
|
|
218
|
+
var anchorCol = ctx.luckysheet_select_save[0].column[0];
|
|
219
|
+
var absoluteCol = anchorCol + index;
|
|
220
|
+
setColumnWidth(ctx, (_a = {}, _a[absoluteCol] = intColWidth, _a));
|
|
221
|
+
});
|
|
216
222
|
var tableRows = containerDiv.querySelectorAll("table tr");
|
|
217
223
|
if (tableRows.length === 0) {
|
|
218
224
|
containerDiv.remove();
|
package/lib/events/paste.js
CHANGED
|
@@ -90,7 +90,7 @@ function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
|
|
|
90
90
|
var colOffset = destCol - srcCol;
|
|
91
91
|
var rowOffset = destRow - srcRow;
|
|
92
92
|
var hadInvalid = false;
|
|
93
|
-
var result = formula.replace(
|
|
93
|
+
var result = formula.replace(/\b(\$?)([A-Z]+)(\$?)(\d+)\b/g, function (__, absCol, colLetters, absRow, rowNum) {
|
|
94
94
|
var colIndex = columnLabelIndex(colLetters);
|
|
95
95
|
var rowIndex = parseInt(rowNum, 10);
|
|
96
96
|
if (!absCol) colIndex += colOffset;
|
|
@@ -1266,7 +1266,6 @@ function handlePaste(ctx, e) {
|
|
|
1266
1266
|
} else if (txtdata.indexOf("fortune-copy-action-image") > -1) {} else {
|
|
1267
1267
|
if (txtdata.indexOf("table") > -1) {
|
|
1268
1268
|
(0, _pasteTableHelpers.handlePastedTable)(ctx, txtdata, pasteHandler);
|
|
1269
|
-
resizePastedCellsToContent(ctx);
|
|
1270
1269
|
} else if (clipboardData.files.length === 1 && clipboardData.files[0].type.indexOf("image") > -1) {} else {
|
|
1271
1270
|
txtdata = clipboardData.getData("text/plain");
|
|
1272
1271
|
var isExcelFormula = txtdata.startsWith("=");
|
|
@@ -10,7 +10,7 @@ var _locale = require("./locale");
|
|
|
10
10
|
var _modules = require("./modules");
|
|
11
11
|
var _format = require("./modules/format");
|
|
12
12
|
var _utils = require("./utils");
|
|
13
|
-
var _api = require("
|
|
13
|
+
var _api = require("./api");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
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); }
|
|
16
16
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
@@ -136,7 +136,7 @@ function brToNewline(str) {
|
|
|
136
136
|
}
|
|
137
137
|
var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
138
138
|
var _a;
|
|
139
|
-
var _b, _c, _d;
|
|
139
|
+
var _b, _c, _d, _e;
|
|
140
140
|
var cell = {};
|
|
141
141
|
var rawText = (td.innerText || td.innerHTML || "").trim();
|
|
142
142
|
var isLineBreak = rawText.includes("<br />");
|
|
@@ -165,6 +165,13 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
165
165
|
cell.v = rawText;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
if (((_b = td.style) === null || _b === void 0 ? void 0 : _b.alignItems) === "center") {
|
|
169
|
+
cell.vt = 0;
|
|
170
|
+
} else if (((_c = td.style) === null || _c === void 0 ? void 0 : _c.alignItems) === "flex-end") {
|
|
171
|
+
cell.vt = 2;
|
|
172
|
+
} else if (((_d = td.style) === null || _d === void 0 ? void 0 : _d.alignItems) === "flex-start") {
|
|
173
|
+
cell.vt = 1;
|
|
174
|
+
}
|
|
168
175
|
var styleBlock = typeof classStyles[".".concat(td.className)] === "string" ? classStyles[".".concat(td.className)] : "";
|
|
169
176
|
var styles = parseInlineStyleBlock(styleBlock);
|
|
170
177
|
if (!_lodash.default.isNil(styles.border)) td.style.border = styles.border;
|
|
@@ -189,17 +196,7 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
|
189
196
|
} else {
|
|
190
197
|
cell.ht = 1;
|
|
191
198
|
}
|
|
192
|
-
|
|
193
|
-
var vtStyle = typeof classStyles.td === "string" && ((_c = (_b = classStyles.td.match(regex)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : "") || "top";
|
|
194
|
-
var vt = td.style.verticalAlign || styles["vertical-align"] || vtStyle;
|
|
195
|
-
if (vt === "middle") {
|
|
196
|
-
cell.vt = 0;
|
|
197
|
-
} else if (vt === "top" || vt === "text-top") {
|
|
198
|
-
cell.vt = 1;
|
|
199
|
-
} else {
|
|
200
|
-
cell.vt = 2;
|
|
201
|
-
}
|
|
202
|
-
if (((_d = td === null || td === void 0 ? void 0 : td.style) === null || _d === void 0 ? void 0 : _d["overflow-wrap"]) === "anywhere") {
|
|
199
|
+
if (((_e = td === null || td === void 0 ? void 0 : td.style) === null || _e === void 0 ? void 0 : _e["overflow-wrap"]) === "anywhere") {
|
|
203
200
|
cell.tb = "2";
|
|
204
201
|
} else {
|
|
205
202
|
cell.tb = "2";
|
|
@@ -221,6 +218,15 @@ function handlePastedTable(ctx, html, pasteHandler) {
|
|
|
221
218
|
if (!html.includes("table")) return;
|
|
222
219
|
var containerDiv = document.createElement("div");
|
|
223
220
|
containerDiv.innerHTML = html;
|
|
221
|
+
var tableColGropup = containerDiv.querySelectorAll("colgroup");
|
|
222
|
+
tableColGropup.forEach(function (colGroup, index) {
|
|
223
|
+
var _a;
|
|
224
|
+
var colWidth = colGroup === null || colGroup === void 0 ? void 0 : colGroup.getAttribute("width");
|
|
225
|
+
var intColWidth = parseInt(colWidth || "0", 10);
|
|
226
|
+
var anchorCol = ctx.luckysheet_select_save[0].column[0];
|
|
227
|
+
var absoluteCol = anchorCol + index;
|
|
228
|
+
(0, _api.setColumnWidth)(ctx, (_a = {}, _a[absoluteCol] = intColWidth, _a));
|
|
229
|
+
});
|
|
224
230
|
var tableRows = containerDiv.querySelectorAll("table tr");
|
|
225
231
|
if (tableRows.length === 0) {
|
|
226
232
|
containerDiv.remove();
|