k-vtable 1.0.25 → 1.0.27
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/cjs/PivotChart.js +6 -6
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/components/axis/axis.d.ts +5 -3
- package/cjs/components/axis/axis.js +20 -14
- package/cjs/components/axis/axis.js.map +1 -1
- package/cjs/components/axis/get-axis-attributes.d.ts +1 -0
- package/cjs/components/axis/get-axis-attributes.js +5 -2
- package/cjs/components/axis/get-axis-attributes.js.map +1 -1
- package/cjs/components/axis/get-axis-component-size.js +11 -5
- package/cjs/components/axis/get-axis-component-size.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +3 -3
- package/cjs/core/BaseTable.js +7 -7
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/dataset-pivot-table.js +2 -1
- package/cjs/dataset/dataset.js +2 -1
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/dataset/flatDataToObject.js +1 -2
- package/cjs/event/event.d.ts +9 -0
- package/cjs/event/event.js +158 -84
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/util.d.ts +1 -0
- package/cjs/event/util.js +13 -2
- package/cjs/event/util.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/chart-helper/get-axis-config.js +35 -22
- package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
- package/cjs/layout/chart-helper/get-chart-spec.js +6 -2
- package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/cjs/layout/pivot-header-layout.js +24 -6
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/plugins/index.js +1 -1
- package/cjs/scenegraph/graphic/active-cell-chart-list.d.ts +13 -0
- package/cjs/scenegraph/graphic/active-cell-chart-list.js +134 -0
- package/cjs/scenegraph/graphic/active-cell-chart-list.js.map +1 -0
- package/cjs/scenegraph/graphic/chart.d.ts +9 -2
- package/cjs/scenegraph/graphic/chart.js +87 -14
- package/cjs/scenegraph/graphic/chart.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +2 -1
- package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render.js +3 -3
- package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js +3 -3
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/column-helper.js +1 -1
- package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
- package/cjs/scenegraph/layout/update-width.js +1 -1
- package/cjs/scenegraph/layout/update-width.js.map +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.js +2 -2
- package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +9 -2
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/themes/theme-define.js +16 -16
- package/cjs/themes/theme-define.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +3 -3
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/table-engine.d.ts +17 -0
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/ts-types/theme.d.ts +12 -4
- package/cjs/ts-types/theme.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +3943 -3239
- package/dist/vtable.min.js +2 -2
- package/es/PivotChart.js +6 -6
- package/es/PivotChart.js.map +1 -1
- package/es/components/axis/axis.d.ts +5 -3
- package/es/components/axis/axis.js +19 -12
- package/es/components/axis/axis.js.map +1 -1
- package/es/components/axis/get-axis-attributes.d.ts +1 -0
- package/es/components/axis/get-axis-attributes.js +5 -2
- package/es/components/axis/get-axis-attributes.js.map +1 -1
- package/es/components/axis/get-axis-component-size.js +12 -4
- package/es/components/axis/get-axis-component-size.js.map +1 -1
- package/es/core/BaseTable.d.ts +3 -3
- package/es/core/BaseTable.js +7 -7
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/dataset-pivot-table.js +2 -1
- package/es/dataset/dataset.js +1 -1
- package/es/dataset/dataset.js.map +1 -1
- package/es/dataset/flatDataToObject.js +1 -2
- package/es/event/event.d.ts +9 -0
- package/es/event/event.js +158 -84
- package/es/event/event.js.map +1 -1
- package/es/event/util.d.ts +1 -0
- package/es/event/util.js +11 -0
- package/es/event/util.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/chart-helper/get-axis-config.js +34 -21
- package/es/layout/chart-helper/get-axis-config.js.map +1 -1
- package/es/layout/chart-helper/get-chart-spec.js +5 -3
- package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/es/layout/pivot-header-layout.js +24 -6
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/plugins/index.js +1 -1
- package/es/scenegraph/graphic/active-cell-chart-list.d.ts +13 -0
- package/es/scenegraph/graphic/active-cell-chart-list.js +123 -0
- package/es/scenegraph/graphic/active-cell-chart-list.js.map +1 -0
- package/es/scenegraph/graphic/chart.d.ts +9 -2
- package/es/scenegraph/graphic/chart.js +87 -13
- package/es/scenegraph/graphic/chart.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render-helper.js +2 -1
- package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render.js +3 -3
- package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/es/scenegraph/group-creater/cell-helper.js +3 -3
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/column-helper.js +1 -1
- package/es/scenegraph/group-creater/column-helper.js.map +1 -1
- package/es/scenegraph/layout/update-width.js +1 -1
- package/es/scenegraph/layout/update-width.js.map +1 -1
- package/es/scenegraph/refresh-node/update-chart.js +2 -2
- package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/es/scenegraph/scenegraph.js +9 -2
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/themes/theme-define.js +12 -12
- package/es/themes/theme-define.js.map +1 -1
- package/es/ts-types/base-table.d.ts +3 -3
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/table-engine.d.ts +17 -0
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/ts-types/theme.d.ts +12 -4
- package/es/ts-types/theme.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +7 -7
- package/cjs/layout/pivot-layout.d.ts +0 -1
- package/cjs/layout/pivot-layout.js +0 -1
- package/cjs/layout/pivot-layout.js.map +0 -1
- package/es/layout/pivot-layout.d.ts +0 -1
- package/es/layout/pivot-layout.js +0 -1
- package/es/layout/pivot-layout.js.map +0 -1
package/cjs/event/event.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare class EventManager {
|
|
|
43
43
|
private cutOperationTime;
|
|
44
44
|
lastClipboardContent: string;
|
|
45
45
|
cutCellRange: CellInfo[][] | null;
|
|
46
|
+
copySourceRange: {
|
|
47
|
+
startCol: number;
|
|
48
|
+
startRow: number;
|
|
49
|
+
} | null;
|
|
46
50
|
constructor(table: BaseTableAPI);
|
|
47
51
|
bindOuterEvent(): void;
|
|
48
52
|
updateEventBinder(): void;
|
|
@@ -68,14 +72,19 @@ export declare class EventManager {
|
|
|
68
72
|
enableScroll(): void;
|
|
69
73
|
disableScroll(): void;
|
|
70
74
|
handleCopy(e: KeyboardEvent, isCut?: boolean): Promise<void>;
|
|
75
|
+
private fallbackCopyToClipboard;
|
|
71
76
|
handleCut(e: KeyboardEvent): Promise<void>;
|
|
72
77
|
handlePaste(e: KeyboardEvent): void;
|
|
73
78
|
private executePaste;
|
|
79
|
+
private fallbackPasteFromClipboard;
|
|
80
|
+
private processPastedText;
|
|
74
81
|
private clearCutArea;
|
|
75
82
|
private checkClipboardChanged;
|
|
76
83
|
private saveClipboardContent;
|
|
77
84
|
private pasteHtmlToTable;
|
|
78
85
|
private _pasteValue;
|
|
79
86
|
private pasteTextToTable;
|
|
87
|
+
private parsePastedData;
|
|
88
|
+
private processCellValue;
|
|
80
89
|
private handlePasteValues;
|
|
81
90
|
}
|
package/cjs/event/event.js
CHANGED
|
@@ -30,14 +30,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
30
30
|
value: !0
|
|
31
31
|
}), exports.EventManager = void 0;
|
|
32
32
|
|
|
33
|
-
const vrender_1 = require("./../vrender"), TABLE_EVENT_TYPE_1 = require("../core/TABLE_EVENT_TYPE"), media_click_1 = require("./media-click"), drill_1 = require("./drill"), sparkline_event_1 = require("./sparkline-event"), stick_text_1 = require("../scenegraph/stick-text"), table_group_1 = require("./listener/table-group"), scroll_bar_1 = require("./listener/scroll-bar"), container_dom_1 = require("./listener/container-dom"), touch_1 = require("./listener/touch"), axis_click_1 = require("./self-event-listener/pivot-chart/axis-click"), axis_hover_1 = require("./self-event-listener/pivot-chart/axis-hover"), env_1 = require("../tools/env"), vutils_1 = require("@visactor/vutils"), scroll_1 = require("./scroll"), is_cell_select_highlight_1 = require("../state/select/is-cell-select-highlight"), checkbox_1 = require("./self-event-listener/list-table/checkbox"), button_1 = require("./component/button"), icon_1 = require("./self-event-listener/base-table/icon"), dropdown_menu_1 = require("./self-event-listener/base-table/dropdown-menu"), dbclick_auto_column_width_1 = require("./self-event-listener/base-table/dbclick-auto-column-width"),
|
|
33
|
+
const vrender_1 = require("./../vrender"), TABLE_EVENT_TYPE_1 = require("../core/TABLE_EVENT_TYPE"), media_click_1 = require("./media-click"), drill_1 = require("./drill"), sparkline_event_1 = require("./sparkline-event"), stick_text_1 = require("../scenegraph/stick-text"), table_group_1 = require("./listener/table-group"), scroll_bar_1 = require("./listener/scroll-bar"), container_dom_1 = require("./listener/container-dom"), touch_1 = require("./listener/touch"), util_1 = require("./util"), axis_click_1 = require("./self-event-listener/pivot-chart/axis-click"), axis_hover_1 = require("./self-event-listener/pivot-chart/axis-hover"), env_1 = require("../tools/env"), vutils_1 = require("@visactor/vutils"), scroll_1 = require("./scroll"), is_cell_select_highlight_1 = require("../state/select/is-cell-select-highlight"), checkbox_1 = require("./self-event-listener/list-table/checkbox"), button_1 = require("./component/button"), icon_1 = require("./self-event-listener/base-table/icon"), dropdown_menu_1 = require("./self-event-listener/base-table/dropdown-menu"), dbclick_auto_column_width_1 = require("./self-event-listener/base-table/dbclick-auto-column-width"), style_1 = require("../tools/style");
|
|
34
34
|
|
|
35
35
|
class EventManager {
|
|
36
36
|
constructor(table) {
|
|
37
37
|
this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0,
|
|
38
38
|
this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0,
|
|
39
|
-
this.lastClipboardContent = "", this.cutCellRange = null, this.
|
|
40
|
-
this.
|
|
39
|
+
this.lastClipboardContent = "", this.cutCellRange = null, this.copySourceRange = null,
|
|
40
|
+
this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new scroll_1.InertiaScroll(table.stateManager),
|
|
41
|
+
"node" === env_1.Env.mode || table.options.disableInteraction || (this.bindOuterEvent(),
|
|
41
42
|
setTimeout((() => {
|
|
42
43
|
this.bindSelfEvent();
|
|
43
44
|
}), 0));
|
|
@@ -251,46 +252,80 @@ class EventManager {
|
|
|
251
252
|
this._enableTableScroll = !1;
|
|
252
253
|
}
|
|
253
254
|
handleCopy(e, isCut = !1) {
|
|
254
|
-
var _a, _b;
|
|
255
|
+
var _a, _b, _c, _d, _e, _f;
|
|
255
256
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
256
257
|
const table = this.table;
|
|
257
|
-
!isCut && (this.cutWaitPaste = !1);
|
|
258
|
-
const
|
|
258
|
+
!isCut && (this.cutWaitPaste = !1), this.copySourceRange = null;
|
|
259
|
+
const sourceRanges = table.stateManager.select.ranges;
|
|
260
|
+
if (sourceRanges && 1 === sourceRanges.length) {
|
|
261
|
+
const sourceRange = sourceRanges[0];
|
|
262
|
+
this.copySourceRange = {
|
|
263
|
+
startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
|
|
264
|
+
startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
|
|
265
|
+
};
|
|
266
|
+
} else if (!(null == sourceRanges ? void 0 : sourceRanges.length)) return void (this.copySourceRange = null);
|
|
267
|
+
const data = this.table.getCopyValue(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.value);
|
|
259
268
|
if ((0, vutils_1.isValid)(data)) {
|
|
260
269
|
e.preventDefault();
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
270
|
+
const element = table.getElement();
|
|
271
|
+
element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
|
|
272
|
+
try {
|
|
273
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
274
|
+
let hasPermission = !0;
|
|
275
|
+
if (navigator.permissions && navigator.permissions.query) try {
|
|
276
|
+
hasPermission = "granted" === (yield navigator.permissions.query({
|
|
277
|
+
name: "clipboard-write"
|
|
278
|
+
})).state;
|
|
279
|
+
} catch (permissionError) {
|
|
280
|
+
hasPermission = !0;
|
|
281
|
+
}
|
|
282
|
+
if (hasPermission) try {
|
|
283
|
+
if (window.ClipboardItem) {
|
|
284
|
+
let htmlValues = data;
|
|
285
|
+
1 === table.stateManager.select.ranges.length && (null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue) || void 0 === _d ? void 0 : _d.html) && (htmlValues = this.table.getCopyValue(null === (_e = table.options.keyboardOptions) || void 0 === _e ? void 0 : _e.getCopyCellValue.html));
|
|
286
|
+
const dataHTML = (0, util_1.setDataToHTML)(htmlValues);
|
|
287
|
+
yield navigator.clipboard.write([ new ClipboardItem({
|
|
288
|
+
"text/html": new Blob([ dataHTML ], {
|
|
289
|
+
type: "text/html"
|
|
290
|
+
}),
|
|
291
|
+
"text/plain": new Blob([ data ], {
|
|
292
|
+
type: "text/plain"
|
|
293
|
+
})
|
|
294
|
+
}) ]);
|
|
295
|
+
} else yield navigator.clipboard.writeText(data);
|
|
296
|
+
} catch (clipboardError) {
|
|
297
|
+
this.fallbackCopyToClipboard(data, e);
|
|
298
|
+
} else this.fallbackCopyToClipboard(data, e);
|
|
299
|
+
} else this.fallbackCopyToClipboard(data, e);
|
|
300
|
+
table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.COPY_DATA, {
|
|
301
|
+
cellRange: table.stateManager.select.ranges,
|
|
302
|
+
copyData: data,
|
|
303
|
+
isCut: isCut
|
|
304
|
+
});
|
|
305
|
+
} catch (error) {
|
|
306
|
+
this.fallbackCopyToClipboard(data, e);
|
|
307
|
+
}
|
|
289
308
|
}
|
|
290
|
-
(null === (
|
|
309
|
+
(null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && ((0,
|
|
291
310
|
style_1.setActiveCellRangeState)(table), table.clearSelected());
|
|
292
311
|
}));
|
|
293
312
|
}
|
|
313
|
+
fallbackCopyToClipboard(data, e) {
|
|
314
|
+
try {
|
|
315
|
+
if (e.clipboardData) return void e.clipboardData.setData("text/plain", data);
|
|
316
|
+
document.activeElement && document.activeElement !== document.body && document.activeElement.blur();
|
|
317
|
+
const textArea = document.createElement("textarea");
|
|
318
|
+
textArea.value = data, textArea.style.position = "fixed", textArea.style.left = "-999999px",
|
|
319
|
+
textArea.style.top = "-999999px", textArea.style.opacity = "0", textArea.setAttribute("readonly", ""),
|
|
320
|
+
textArea.setAttribute("aria-hidden", "true"), document.body.appendChild(textArea),
|
|
321
|
+
textArea.focus(), textArea.select(), textArea.setSelectionRange(0, data.length);
|
|
322
|
+
try {
|
|
323
|
+
document.execCommand("copy");
|
|
324
|
+
} catch (execError) {} finally {
|
|
325
|
+
document.body.removeChild(textArea);
|
|
326
|
+
}
|
|
327
|
+
} catch (error) {}
|
|
328
|
+
}
|
|
294
329
|
handleCut(e) {
|
|
295
330
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
296
331
|
this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(),
|
|
@@ -310,32 +345,68 @@ class EventManager {
|
|
|
310
345
|
})) : this.executePaste(e);
|
|
311
346
|
}
|
|
312
347
|
executePaste(e) {
|
|
313
|
-
var _a, _b, _c
|
|
348
|
+
var _a, _b, _c;
|
|
314
349
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
315
350
|
const table = this.table;
|
|
316
|
-
if (table.
|
|
317
|
-
if (null === (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
});
|
|
351
|
+
if (!(null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) {
|
|
352
|
+
if (table.changeCellValues && (null === (_b = table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 0) try {
|
|
353
|
+
if (navigator.clipboard && navigator.clipboard.read) try {
|
|
354
|
+
const clipboardItems = yield navigator.clipboard.read();
|
|
355
|
+
let handled = !1;
|
|
356
|
+
for (const item of clipboardItems) {
|
|
357
|
+
if (item.types.includes("text/html")) {
|
|
358
|
+
yield this.pasteHtmlToTable(item), handled = !0;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
if (item.types.includes("text/plain")) {
|
|
362
|
+
yield this.pasteTextToTable(item), handled = !0;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
handled || (yield this.fallbackPasteFromClipboard(e));
|
|
367
|
+
} catch (clipboardError) {
|
|
368
|
+
yield this.fallbackPasteFromClipboard(e);
|
|
369
|
+
} else yield this.fallbackPasteFromClipboard(e);
|
|
370
|
+
} catch (error) {
|
|
371
|
+
yield this.fallbackPasteFromClipboard(e);
|
|
335
372
|
}
|
|
373
|
+
(null === (_c = table.keyboardOptions) || void 0 === _c ? void 0 : _c.showCopyCellBorder) && (0,
|
|
374
|
+
style_1.clearActiveCellRangeState)(table);
|
|
336
375
|
}
|
|
337
|
-
|
|
338
|
-
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
fallbackPasteFromClipboard(e) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
380
|
+
const table = this.table, ranges = table.stateManager.select.ranges, col = Math.min(ranges[0].start.col, ranges[0].end.col), row = Math.min(ranges[0].start.row, ranges[0].end.row);
|
|
381
|
+
try {
|
|
382
|
+
const element = table.getElement();
|
|
383
|
+
element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
|
|
384
|
+
const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
|
|
385
|
+
if (clipboardData) {
|
|
386
|
+
const pastedData = clipboardData.getData("text") || clipboardData.getData("Text");
|
|
387
|
+
if (pastedData) return void (yield this.processPastedText(pastedData, col, row));
|
|
388
|
+
}
|
|
389
|
+
} catch (error) {}
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
392
|
+
processPastedText(pastedData, col, row) {
|
|
393
|
+
var _a;
|
|
394
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
395
|
+
const table = this.table, rows = pastedData.split("\n"), values = [];
|
|
396
|
+
let processedValues;
|
|
397
|
+
rows.forEach((function(rowCells) {
|
|
398
|
+
const cells = rowCells.split("\t"), rowValues = [];
|
|
399
|
+
values.push(rowValues), cells.forEach((function(cell, cellIndex) {
|
|
400
|
+
cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
|
|
401
|
+
}));
|
|
402
|
+
})), (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
403
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
404
|
+
table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
405
|
+
col: col,
|
|
406
|
+
row: row,
|
|
407
|
+
pasteData: processedValues || values,
|
|
408
|
+
changedCellResults: changedCellResults
|
|
409
|
+
});
|
|
339
410
|
}));
|
|
340
411
|
}
|
|
341
412
|
clearCutArea(table) {
|
|
@@ -367,19 +438,21 @@ class EventManager {
|
|
|
367
438
|
let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
|
|
368
439
|
item.getType("text/html").then((blob => {
|
|
369
440
|
blob.text().then((pastedData => __awaiter(this, void 0, void 0, (function*() {
|
|
370
|
-
var _a, _b;
|
|
441
|
+
var _a, _b, _c;
|
|
371
442
|
if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
|
|
372
443
|
const matches = Array.from(pastedData.matchAll(regex));
|
|
373
444
|
for (const match of matches) {
|
|
374
445
|
const rowContent = match[1], rowValues = Array.from(rowContent.matchAll(cellRegex)).map((cellMatch => cellMatch[1].replace(/(<(?!br)([^>]+)>)/gi, "").replace(/<br(\s*|\/)>[\r\n]?/gim, "\n").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/	/gi, "\t").replace(/ /g, " ")));
|
|
375
446
|
values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
376
447
|
}
|
|
377
|
-
|
|
378
|
-
|
|
448
|
+
let processedValues;
|
|
449
|
+
pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
|
|
450
|
+
(null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
451
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
379
452
|
table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
380
453
|
col: col,
|
|
381
454
|
row: row,
|
|
382
|
-
pasteData: values,
|
|
455
|
+
pasteData: processedValues || values,
|
|
383
456
|
changedCellResults: changedCellResults
|
|
384
457
|
});
|
|
385
458
|
} else navigator.clipboard.read().then((clipboardItems => {
|
|
@@ -391,10 +464,11 @@ class EventManager {
|
|
|
391
464
|
}));
|
|
392
465
|
}
|
|
393
466
|
_pasteValue(pastedData) {
|
|
394
|
-
var _a;
|
|
467
|
+
var _a, _b;
|
|
395
468
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
396
469
|
const table = this.table, ranges = table.stateManager.select.ranges, selectRangeLength = ranges.length, col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row), maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
|
|
397
470
|
let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
|
|
471
|
+
let processedValues;
|
|
398
472
|
pastedData.split("\n").forEach((function(rowCells, rowIndex) {
|
|
399
473
|
var _a;
|
|
400
474
|
const cells = rowCells.split("\t"), rowValues = [];
|
|
@@ -402,43 +476,43 @@ class EventManager {
|
|
|
402
476
|
cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
|
|
403
477
|
})), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
404
478
|
})), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0,
|
|
405
|
-
values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1)
|
|
406
|
-
|
|
479
|
+
values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
|
|
480
|
+
(null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
|
|
481
|
+
const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
|
|
407
482
|
table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
408
483
|
col: col,
|
|
409
484
|
row: row,
|
|
410
|
-
pasteData: values,
|
|
485
|
+
pasteData: processedValues || values,
|
|
411
486
|
changedCellResults: changedCellResults
|
|
412
487
|
});
|
|
413
488
|
}));
|
|
414
489
|
}
|
|
415
490
|
pasteTextToTable(item) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
var _a;
|
|
421
|
-
const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n");
|
|
422
|
-
let values = [];
|
|
423
|
-
rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.forEach((function(rowCells, rowIndex) {
|
|
424
|
-
var _a;
|
|
425
|
-
const cells = rowCells.split("\t"), rowValues = [];
|
|
426
|
-
values.push(rowValues), cells.forEach((function(cell, cellIndex) {
|
|
427
|
-
cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, (match => new Array(Math.floor(match.length / 2)).fill('"').join("")))),
|
|
428
|
-
rowValues.push(cell);
|
|
429
|
-
})), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
|
|
430
|
-
})), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0,
|
|
431
|
-
values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
|
|
432
|
-
const changedCellResults = yield table.changeCellValues(col, row, values, !0);
|
|
491
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
492
|
+
const table = this.table, ranges = table.stateManager.select.ranges, selectRangeLength = ranges.length, col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row), maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
|
|
493
|
+
try {
|
|
494
|
+
const blob = yield item.getType("text/plain"), pastedData = yield blob.text(), values = this.parsePastedData(pastedData), pasteValuesRowCount = values.length, pasteValuesColCount = Math.max(...values.map((row => row.length)), 0), processedValues = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), changedCellResults = yield table.changeCellValues(col, row, processedValues, !0);
|
|
433
495
|
table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
|
|
434
496
|
col: col,
|
|
435
497
|
row: row,
|
|
436
|
-
pasteData:
|
|
498
|
+
pasteData: processedValues,
|
|
437
499
|
changedCellResults: changedCellResults
|
|
438
500
|
});
|
|
439
|
-
})
|
|
501
|
+
} catch (error) {}
|
|
440
502
|
}));
|
|
441
503
|
}
|
|
504
|
+
parsePastedData(pastedData) {
|
|
505
|
+
const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n"), values = [];
|
|
506
|
+
return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.forEach((rowCells => {
|
|
507
|
+
const rowValues = rowCells.split("\t").map((cell => this.processCellValue(cell)));
|
|
508
|
+
values.push(rowValues);
|
|
509
|
+
})), values;
|
|
510
|
+
}
|
|
511
|
+
processCellValue(cell) {
|
|
512
|
+
cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, (match => new Array(Math.floor(match.length / 2)).fill('"').join(""))));
|
|
513
|
+
const numValue = Number(cell);
|
|
514
|
+
return isNaN(numValue) ? cell : numValue;
|
|
515
|
+
}
|
|
442
516
|
handlePasteValues(values, rowCount, colCount, selectedRowCount, selectedColCount) {
|
|
443
517
|
if (selectedColCount > colCount || selectedRowCount > rowCount) {
|
|
444
518
|
if (selectedColCount % colCount == 0 && selectedRowCount % rowCount == 0) {
|