@lemon-fe/components 1.2.15 → 1.3.0-alpha.1
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/LICENSE +9 -0
- package/README.md +17 -0
- package/es/data-grid/cell-editors/date.d.ts +2 -2
- package/es/data-grid/cell-editors/number.d.ts +2 -2
- package/es/data-grid/cell-editors/row.d.ts +2 -2
- package/es/data-grid/cell-editors/select.d.ts +3 -3
- package/es/data-grid/cell-editors/text.d.ts +2 -2
- package/es/data-grid/cell-editors/utils.d.ts +1 -1
- package/es/data-grid/components/custom-panel/index.d.ts +1 -1
- package/es/data-grid/components/custom-panel/item.d.ts +1 -1
- package/es/data-grid/components/custom-panel/typings.d.ts +1 -1
- package/es/data-grid/index.d.ts +8 -7
- package/es/data-grid/index.js +3 -11
- package/es/data-grid/index.less +1 -1
- package/es/data-grid/renderer/actions-renderer.d.ts +1 -1
- package/es/data-grid/renderer/actions.d.ts +1 -1
- package/es/data-grid/renderer/cell-delete-renderer.d.ts +1 -1
- package/es/data-grid/renderer/cell-index-renderer.d.ts +1 -1
- package/es/data-grid/renderer/cell-renderer.d.ts +1 -1
- package/es/data-grid/renderer/detali-cell-renderer.d.ts +1 -1
- package/es/data-grid/renderer/header-renderer.d.ts +1 -1
- package/es/data-grid/typings.d.ts +2 -2
- package/es/data-grid/utils.d.ts +1 -1
- package/es/index.d.ts +4 -3
- package/es/index.js +4 -2
- package/es/select-view/index.d.ts +1 -1
- package/package.json +9 -18
- package/es/data-grid/modules/clipboard/clipboard/clipboardService.d.ts +0 -62
- package/es/data-grid/modules/clipboard/clipboard/clipboardService.js +0 -1007
- package/es/data-grid/modules/clipboard/clipboardModule.d.ts +0 -2
- package/es/data-grid/modules/clipboard/clipboardModule.js +0 -10
- package/es/data-grid/modules/clipboard/main.d.ts +0 -1
- package/es/data-grid/modules/clipboard/main.js +0 -1
- package/es/data-grid/modules/clipboard/version.d.ts +0 -1
- package/es/data-grid/modules/clipboard/version.js +0 -2
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/columnModelItem.d.ts +0 -26
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/columnModelItem.js +0 -94
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/columnToolPanel.d.ts +0 -32
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/columnToolPanel.js +0 -272
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/modelItemUtils.d.ts +0 -16
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/modelItemUtils.js +0 -209
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/pivotModePanel.d.ts +0 -9
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/pivotModePanel.js +0 -68
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsHeaderPanel.d.ts +0 -32
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsHeaderPanel.js +0 -150
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsListPanel.d.ts +0 -44
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsListPanel.js +0 -455
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsListPanelItemDragFeature.d.ts +0 -26
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsListPanelItemDragFeature.js +0 -224
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsPanel.d.ts +0 -24
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/primaryColsPanel.js +0 -123
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelColumnComp.d.ts +0 -37
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelColumnComp.js +0 -314
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelColumnGroupComp.d.ts +0 -51
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelColumnGroupComp.js +0 -406
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelContextMenu.d.ts +0 -24
- package/es/data-grid/modules/column-tool-panel/columnToolPanel/toolPanelContextMenu.js +0 -264
- package/es/data-grid/modules/column-tool-panel/columnsToolPanelModule.d.ts +0 -2
- package/es/data-grid/modules/column-tool-panel/columnsToolPanelModule.js +0 -29
- package/es/data-grid/modules/column-tool-panel/main.d.ts +0 -2
- package/es/data-grid/modules/column-tool-panel/main.js +0 -3
- package/es/data-grid/modules/column-tool-panel/version.d.ts +0 -1
- package/es/data-grid/modules/column-tool-panel/version.js +0 -2
- package/es/data-grid/modules/master-detail/main.d.ts +0 -1
- package/es/data-grid/modules/master-detail/main.js +0 -1
- package/es/data-grid/modules/master-detail/masterDetail/detailCellRenderer.d.ts +0 -14
- package/es/data-grid/modules/master-detail/masterDetail/detailCellRenderer.js +0 -144
- package/es/data-grid/modules/master-detail/masterDetail/detailCellRendererCtrl.d.ts +0 -19
- package/es/data-grid/modules/master-detail/masterDetail/detailCellRendererCtrl.js +0 -203
- package/es/data-grid/modules/master-detail/masterDetailModule.d.ts +0 -2
- package/es/data-grid/modules/master-detail/masterDetailModule.js +0 -18
- package/es/data-grid/modules/master-detail/version.d.ts +0 -1
- package/es/data-grid/modules/master-detail/version.js +0 -2
- package/es/data-grid/modules/menu/main.d.ts +0 -1
- package/es/data-grid/modules/menu/main.js +0 -1
- package/es/data-grid/modules/menu/menu/chartMenuItemMapper.d.ts +0 -13
- package/es/data-grid/modules/menu/menu/chartMenuItemMapper.js +0 -351
- package/es/data-grid/modules/menu/menu/contextMenu.d.ts +0 -13
- package/es/data-grid/modules/menu/menu/contextMenu.js +0 -267
- package/es/data-grid/modules/menu/menu/enterpriseMenu.d.ts +0 -66
- package/es/data-grid/modules/menu/menu/enterpriseMenu.js +0 -592
- package/es/data-grid/modules/menu/menu/menuItemMapper.d.ts +0 -13
- package/es/data-grid/modules/menu/menu/menuItemMapper.js +0 -328
- package/es/data-grid/modules/menu/menuModule.d.ts +0 -2
- package/es/data-grid/modules/menu/menuModule.js +0 -12
- package/es/data-grid/modules/menu/version.d.ts +0 -1
- package/es/data-grid/modules/menu/version.js +0 -2
- package/es/data-grid/modules/row-grouping/main.d.ts +0 -4
- package/es/data-grid/modules/row-grouping/main.js +0 -4
- package/es/data-grid/modules/row-grouping/rowGrouping/aggFuncService.d.ts +0 -23
- package/es/data-grid/modules/row-grouping/rowGrouping/aggFuncService.js +0 -250
- package/es/data-grid/modules/row-grouping/rowGrouping/aggregationStage.d.ts +0 -22
- package/es/data-grid/modules/row-grouping/rowGrouping/aggregationStage.js +0 -285
- package/es/data-grid/modules/row-grouping/rowGrouping/batchRemover.d.ts +0 -12
- package/es/data-grid/modules/row-grouping/rowGrouping/batchRemover.js +0 -77
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/baseDropZonePanel.d.ts +0 -75
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/baseDropZonePanel.js +0 -516
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/dropZoneColumnComp.d.ts +0 -40
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/dropZoneColumnComp.js +0 -367
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/gridHeaderDropZones.d.ts +0 -11
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/gridHeaderDropZones.js +0 -85
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/pivotDropZonePanel.d.ts +0 -17
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/pivotDropZonePanel.js +0 -139
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/rowGroupDropZonePanel.d.ts +0 -15
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/rowGroupDropZonePanel.js +0 -105
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/valueDropZonePanel.d.ts +0 -15
- package/es/data-grid/modules/row-grouping/rowGrouping/columnDropZones/valueDropZonePanel.js +0 -105
- package/es/data-grid/modules/row-grouping/rowGrouping/filterAggregatesStage.d.ts +0 -9
- package/es/data-grid/modules/row-grouping/rowGrouping/filterAggregatesStage.js +0 -136
- package/es/data-grid/modules/row-grouping/rowGrouping/groupFilter/groupFilter.d.ts +0 -39
- package/es/data-grid/modules/row-grouping/rowGrouping/groupFilter/groupFilter.js +0 -319
- package/es/data-grid/modules/row-grouping/rowGrouping/groupFilter/groupFloatingFilter.d.ts +0 -23
- package/es/data-grid/modules/row-grouping/rowGrouping/groupFilter/groupFloatingFilter.js +0 -163
- package/es/data-grid/modules/row-grouping/rowGrouping/groupStage.d.ts +0 -48
- package/es/data-grid/modules/row-grouping/rowGrouping/groupStage.js +0 -740
- package/es/data-grid/modules/row-grouping/rowGrouping/pivotColDefService.d.ts +0 -24
- package/es/data-grid/modules/row-grouping/rowGrouping/pivotColDefService.js +0 -396
- package/es/data-grid/modules/row-grouping/rowGrouping/pivotStage.d.ts +0 -19
- package/es/data-grid/modules/row-grouping/rowGrouping/pivotStage.js +0 -182
- package/es/data-grid/modules/row-grouping/rowGroupingModule.d.ts +0 -2
- package/es/data-grid/modules/row-grouping/rowGroupingModule.js +0 -28
- package/es/data-grid/modules/row-grouping/version.d.ts +0 -1
- package/es/data-grid/modules/row-grouping/version.js +0 -2
- package/es/data-grid/modules/side-bar/main.d.ts +0 -2
- package/es/data-grid/modules/side-bar/main.js +0 -2
- package/es/data-grid/modules/side-bar/sideBar/common/toolPanelColDefService.d.ts +0 -11
- package/es/data-grid/modules/side-bar/sideBar/common/toolPanelColDefService.js +0 -216
- package/es/data-grid/modules/side-bar/sideBar/horizontalResizeComp.d.ts +0 -19
- package/es/data-grid/modules/side-bar/sideBar/horizontalResizeComp.js +0 -108
- package/es/data-grid/modules/side-bar/sideBar/sideBarButtonComp.d.ts +0 -16
- package/es/data-grid/modules/side-bar/sideBar/sideBarButtonComp.js +0 -84
- package/es/data-grid/modules/side-bar/sideBar/sideBarButtonsComp.d.ts +0 -18
- package/es/data-grid/modules/side-bar/sideBar/sideBarButtonsComp.js +0 -89
- package/es/data-grid/modules/side-bar/sideBar/sideBarComp.d.ts +0 -28
- package/es/data-grid/modules/side-bar/sideBar/sideBarComp.js +0 -325
- package/es/data-grid/modules/side-bar/sideBar/sideBarDefParser.d.ts +0 -10
- package/es/data-grid/modules/side-bar/sideBar/sideBarDefParser.js +0 -95
- package/es/data-grid/modules/side-bar/sideBar/toolPanelWrapper.d.ts +0 -17
- package/es/data-grid/modules/side-bar/sideBar/toolPanelWrapper.js +0 -103
- package/es/data-grid/modules/side-bar/sideBarModule.d.ts +0 -2
- package/es/data-grid/modules/side-bar/sideBarModule.js +0 -22
- package/es/data-grid/modules/side-bar/version.d.ts +0 -1
- package/es/data-grid/modules/side-bar/version.js +0 -2
|
@@ -1,1007 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
14
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
-
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); }
|
|
18
|
-
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length,
|
|
20
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
21
|
-
d;
|
|
22
|
-
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
-
};
|
|
25
|
-
var ClipboardService_1;
|
|
26
|
-
import { _, Autowired, Bean, BeanStub, ChangedPath, Events, PostConstruct, Optional } from "@ag-grid-community/core";
|
|
27
|
-
// Matches value in changeDetectionService
|
|
28
|
-
var SOURCE_PASTE = 'paste';
|
|
29
|
-
var EXPORT_TYPE_DRAG_COPY = 'dragCopy';
|
|
30
|
-
var EXPORT_TYPE_CLIPBOARD = 'clipboard';
|
|
31
|
-
var CellClearType;
|
|
32
|
-
(function (CellClearType) {
|
|
33
|
-
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
|
|
34
|
-
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
|
|
35
|
-
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
|
|
36
|
-
})(CellClearType || (CellClearType = {}));
|
|
37
|
-
;
|
|
38
|
-
var ClipboardService = ClipboardService_1 = /*#__PURE__*/function (_BeanStub) {
|
|
39
|
-
_inherits(ClipboardService, _BeanStub);
|
|
40
|
-
var _super = _createSuper(ClipboardService);
|
|
41
|
-
function ClipboardService() {
|
|
42
|
-
var _this;
|
|
43
|
-
_classCallCheck(this, ClipboardService);
|
|
44
|
-
_this = _super.apply(this, arguments);
|
|
45
|
-
_this.lastPasteOperationTime = 0;
|
|
46
|
-
_this.navigatorApiFailed = false;
|
|
47
|
-
return _this;
|
|
48
|
-
}
|
|
49
|
-
_createClass(ClipboardService, [{
|
|
50
|
-
key: "init",
|
|
51
|
-
value: function init() {
|
|
52
|
-
var _this2 = this;
|
|
53
|
-
this.logger = this.loggerFactory.create('ClipboardService');
|
|
54
|
-
if (this.rowModel.getType() === 'clientSide') {
|
|
55
|
-
this.clientSideRowModel = this.rowModel;
|
|
56
|
-
}
|
|
57
|
-
this.ctrlsService.whenReady(function (p) {
|
|
58
|
-
_this2.gridCtrl = p.gridCtrl;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "pasteFromClipboard",
|
|
63
|
-
value: function pasteFromClipboard() {
|
|
64
|
-
var _this3 = this;
|
|
65
|
-
this.logger.log('pasteFromClipboard');
|
|
66
|
-
// Method 1 - native clipboard API, available in modern chrome browsers
|
|
67
|
-
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi');
|
|
68
|
-
// Some browsers (Firefox) do not allow Web Applications to read from
|
|
69
|
-
// the clipboard so verify if not only the ClipboardAPI is available,
|
|
70
|
-
// but also if the `readText` method is public.
|
|
71
|
-
if (allowNavigator && !this.navigatorApiFailed && navigator.clipboard && navigator.clipboard.readText) {
|
|
72
|
-
navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch(function (e) {
|
|
73
|
-
_.doOnce(function () {
|
|
74
|
-
console.warn(e);
|
|
75
|
-
console.warn('AG Grid: Unable to use the Clipboard API (navigator.clipboard.readText()). ' + 'The reason why it could not be used has been logged in the previous line. ' + 'For this reason the grid has defaulted to using a workaround which doesn\'t perform as well. ' + 'Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid ' + 'property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API');
|
|
76
|
-
}, 'clipboardApiError');
|
|
77
|
-
_this3.navigatorApiFailed = true;
|
|
78
|
-
_this3.pasteFromClipboardLegacy();
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
this.pasteFromClipboardLegacy();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "pasteFromClipboardLegacy",
|
|
86
|
-
value: function pasteFromClipboardLegacy() {
|
|
87
|
-
var _this4 = this;
|
|
88
|
-
// Method 2 - if modern API fails, the old school hack
|
|
89
|
-
var defaultPrevented = false;
|
|
90
|
-
var handlePasteEvent = function handlePasteEvent(e) {
|
|
91
|
-
var currentPastOperationTime = new Date().getTime();
|
|
92
|
-
if (currentPastOperationTime - _this4.lastPasteOperationTime < 50) {
|
|
93
|
-
defaultPrevented = true;
|
|
94
|
-
e.preventDefault();
|
|
95
|
-
}
|
|
96
|
-
_this4.lastPasteOperationTime = currentPastOperationTime;
|
|
97
|
-
};
|
|
98
|
-
this.executeOnTempElement(function (textArea) {
|
|
99
|
-
textArea.addEventListener('paste', handlePasteEvent);
|
|
100
|
-
textArea.focus({
|
|
101
|
-
preventScroll: true
|
|
102
|
-
});
|
|
103
|
-
}, function (element) {
|
|
104
|
-
var data = element.value;
|
|
105
|
-
if (!defaultPrevented) {
|
|
106
|
-
_this4.processClipboardData(data);
|
|
107
|
-
} else {
|
|
108
|
-
_this4.refocusLastFocusedCell();
|
|
109
|
-
}
|
|
110
|
-
element.removeEventListener('paste', handlePasteEvent);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "refocusLastFocusedCell",
|
|
115
|
-
value: function refocusLastFocusedCell() {
|
|
116
|
-
var focusedCell = this.focusService.getFocusedCell();
|
|
117
|
-
if (focusedCell) {
|
|
118
|
-
this.focusService.setFocusedCell({
|
|
119
|
-
rowIndex: focusedCell.rowIndex,
|
|
120
|
-
column: focusedCell.column,
|
|
121
|
-
rowPinned: focusedCell.rowPinned,
|
|
122
|
-
forceBrowserFocus: true
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
key: "getClipboardDelimiter",
|
|
128
|
-
value: function getClipboardDelimiter() {
|
|
129
|
-
var delimiter = this.gridOptionsService.get('clipboardDelimiter');
|
|
130
|
-
return _.exists(delimiter) ? delimiter : '\t';
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
|
-
key: "processClipboardData",
|
|
134
|
-
value: function processClipboardData(data) {
|
|
135
|
-
var _this5 = this;
|
|
136
|
-
if (data == null) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
var parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
|
|
140
|
-
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');
|
|
141
|
-
if (userFunc) {
|
|
142
|
-
parsedData = userFunc({
|
|
143
|
-
data: parsedData
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
if (parsedData == null) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) {
|
|
150
|
-
this.removeLastLineIfBlank(parsedData);
|
|
151
|
-
}
|
|
152
|
-
var pasteOperation = function pasteOperation(cellsToFlash, updatedRowNodes, focusedCell, changedPath) {
|
|
153
|
-
var rangeActive = _this5.rangeService && _this5.rangeService.isMoreThanOneCell();
|
|
154
|
-
var pasteIntoRange = rangeActive && !_this5.hasOnlyOneValueToPaste(parsedData);
|
|
155
|
-
if (pasteIntoRange) {
|
|
156
|
-
_this5.pasteIntoActiveRange(parsedData, cellsToFlash, updatedRowNodes, changedPath);
|
|
157
|
-
} else {
|
|
158
|
-
_this5.pasteStartingFromFocusedCell(parsedData, cellsToFlash, updatedRowNodes, focusedCell, changedPath);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
this.doPasteOperation(pasteOperation);
|
|
162
|
-
}
|
|
163
|
-
// This will parse a delimited string into an array of arrays.
|
|
164
|
-
}, {
|
|
165
|
-
key: "doPasteOperation",
|
|
166
|
-
value:
|
|
167
|
-
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
|
|
168
|
-
function doPasteOperation(pasteOperationFunc) {
|
|
169
|
-
var api = this.gridOptionsService.api;
|
|
170
|
-
var columnApi = this.gridOptionsService.columnApi;
|
|
171
|
-
var source = 'clipboard';
|
|
172
|
-
this.eventService.dispatchEvent({
|
|
173
|
-
type: Events.EVENT_PASTE_START,
|
|
174
|
-
api: api,
|
|
175
|
-
columnApi: columnApi,
|
|
176
|
-
source: source
|
|
177
|
-
});
|
|
178
|
-
var changedPath;
|
|
179
|
-
if (this.clientSideRowModel) {
|
|
180
|
-
var onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns');
|
|
181
|
-
changedPath = new ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode());
|
|
182
|
-
}
|
|
183
|
-
var cellsToFlash = {};
|
|
184
|
-
var updatedRowNodes = [];
|
|
185
|
-
var focusedCell = this.focusService.getFocusedCell();
|
|
186
|
-
pasteOperationFunc(cellsToFlash, updatedRowNodes, focusedCell, changedPath);
|
|
187
|
-
if (changedPath) {
|
|
188
|
-
this.clientSideRowModel.doAggregate(changedPath);
|
|
189
|
-
}
|
|
190
|
-
this.rowRenderer.refreshCells();
|
|
191
|
-
this.dispatchFlashCells(cellsToFlash);
|
|
192
|
-
this.fireRowChanged(updatedRowNodes);
|
|
193
|
-
// if using the clipboard hack with a temp element, then the focus has been lost,
|
|
194
|
-
// so need to put it back. otherwise paste operation loosed focus on cell and keyboard
|
|
195
|
-
// navigation stops.
|
|
196
|
-
this.refocusLastFocusedCell();
|
|
197
|
-
var event = {
|
|
198
|
-
type: Events.EVENT_PASTE_END,
|
|
199
|
-
source: source
|
|
200
|
-
};
|
|
201
|
-
this.eventService.dispatchEvent(event);
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "pasteIntoActiveRange",
|
|
205
|
-
value: function pasteIntoActiveRange(clipboardData, cellsToFlash, updatedRowNodes, changedPath) {
|
|
206
|
-
var _this6 = this;
|
|
207
|
-
// true if clipboard data can be evenly pasted into range, otherwise false
|
|
208
|
-
var abortRepeatingPasteIntoRows = this.getRangeSize() % clipboardData.length != 0;
|
|
209
|
-
var indexOffset = 0;
|
|
210
|
-
var dataRowIndex = 0;
|
|
211
|
-
var rowCallback = function rowCallback(currentRow, rowNode, columns, index) {
|
|
212
|
-
var atEndOfClipboardData = index - indexOffset >= clipboardData.length;
|
|
213
|
-
if (atEndOfClipboardData) {
|
|
214
|
-
if (abortRepeatingPasteIntoRows) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
// increment offset and reset data index to repeat paste of data
|
|
218
|
-
indexOffset += dataRowIndex;
|
|
219
|
-
dataRowIndex = 0;
|
|
220
|
-
}
|
|
221
|
-
var currentRowData = clipboardData[index - indexOffset];
|
|
222
|
-
// otherwise we are not the first row, so copy
|
|
223
|
-
updatedRowNodes.push(rowNode);
|
|
224
|
-
var processCellFromClipboardFunc = _this6.gridOptionsService.getCallback('processCellFromClipboard');
|
|
225
|
-
columns.forEach(function (column, idx) {
|
|
226
|
-
if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
// repeat data for columns we don't have data for - happens when to range is bigger than copied data range
|
|
230
|
-
if (idx >= currentRowData.length) {
|
|
231
|
-
idx = idx % currentRowData.length;
|
|
232
|
-
}
|
|
233
|
-
var newValue = _this6.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc);
|
|
234
|
-
rowNode.setDataValue(column, newValue, SOURCE_PASTE);
|
|
235
|
-
if (changedPath) {
|
|
236
|
-
changedPath.addParentNode(rowNode.parent, [column]);
|
|
237
|
-
}
|
|
238
|
-
var rowIndex = currentRow.rowIndex,
|
|
239
|
-
rowPinned = currentRow.rowPinned;
|
|
240
|
-
var cellId = _this6.cellPositionUtils.createIdFromValues({
|
|
241
|
-
rowIndex: rowIndex,
|
|
242
|
-
column: column,
|
|
243
|
-
rowPinned: rowPinned
|
|
244
|
-
});
|
|
245
|
-
cellsToFlash[cellId] = true;
|
|
246
|
-
});
|
|
247
|
-
dataRowIndex++;
|
|
248
|
-
};
|
|
249
|
-
this.iterateActiveRanges(false, rowCallback);
|
|
250
|
-
}
|
|
251
|
-
}, {
|
|
252
|
-
key: "pasteStartingFromFocusedCell",
|
|
253
|
-
value: function pasteStartingFromFocusedCell(parsedData, cellsToFlash, updatedRowNodes, focusedCell, changedPath) {
|
|
254
|
-
if (!focusedCell) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
var currentRow = {
|
|
258
|
-
rowIndex: focusedCell.rowIndex,
|
|
259
|
-
rowPinned: focusedCell.rowPinned
|
|
260
|
-
};
|
|
261
|
-
var columnsToPasteInto = this.columnModel.getDisplayedColumnsStartingAt(focusedCell.column);
|
|
262
|
-
if (this.isPasteSingleValueIntoRange(parsedData)) {
|
|
263
|
-
this.pasteSingleValueIntoRange(parsedData, updatedRowNodes, cellsToFlash, changedPath);
|
|
264
|
-
} else {
|
|
265
|
-
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
// if range is active, and only one cell, then we paste this cell into all cells in the active range.
|
|
269
|
-
}, {
|
|
270
|
-
key: "isPasteSingleValueIntoRange",
|
|
271
|
-
value: function isPasteSingleValueIntoRange(parsedData) {
|
|
272
|
-
return this.hasOnlyOneValueToPaste(parsedData) && this.rangeService != null && !this.rangeService.isEmpty();
|
|
273
|
-
}
|
|
274
|
-
}, {
|
|
275
|
-
key: "pasteSingleValueIntoRange",
|
|
276
|
-
value: function pasteSingleValueIntoRange(parsedData, updatedRowNodes, cellsToFlash, changedPath) {
|
|
277
|
-
var _this7 = this;
|
|
278
|
-
var value = parsedData[0][0];
|
|
279
|
-
var rowCallback = function rowCallback(currentRow, rowNode, columns) {
|
|
280
|
-
updatedRowNodes.push(rowNode);
|
|
281
|
-
columns.forEach(function (column) {
|
|
282
|
-
return _this7.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath);
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
this.iterateActiveRanges(false, rowCallback);
|
|
286
|
-
}
|
|
287
|
-
}, {
|
|
288
|
-
key: "hasOnlyOneValueToPaste",
|
|
289
|
-
value: function hasOnlyOneValueToPaste(parsedData) {
|
|
290
|
-
return parsedData.length === 1 && parsedData[0].length === 1;
|
|
291
|
-
}
|
|
292
|
-
}, {
|
|
293
|
-
key: "copyRangeDown",
|
|
294
|
-
value: function copyRangeDown() {
|
|
295
|
-
var _this8 = this;
|
|
296
|
-
if (!this.rangeService || this.rangeService.isEmpty()) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
var firstRowValues = [];
|
|
300
|
-
var pasteOperation = function pasteOperation(cellsToFlash, updatedRowNodes, focusedCell, changedPath) {
|
|
301
|
-
var processCellForClipboardFunc = _this8.gridOptionsService.getCallback('processCellForClipboard');
|
|
302
|
-
var processCellFromClipboardFunc = _this8.gridOptionsService.getCallback('processCellFromClipboard');
|
|
303
|
-
var rowCallback = function rowCallback(currentRow, rowNode, columns) {
|
|
304
|
-
// take reference of first row, this is the one we will be using to copy from
|
|
305
|
-
if (!firstRowValues.length) {
|
|
306
|
-
// two reasons for looping through columns
|
|
307
|
-
columns.forEach(function (column) {
|
|
308
|
-
// get the initial values to copy down
|
|
309
|
-
var value = _this8.processCell(rowNode, column, _this8.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc);
|
|
310
|
-
firstRowValues.push(value);
|
|
311
|
-
});
|
|
312
|
-
} else {
|
|
313
|
-
// otherwise we are not the first row, so copy
|
|
314
|
-
updatedRowNodes.push(rowNode);
|
|
315
|
-
columns.forEach(function (column, index) {
|
|
316
|
-
if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
var firstRowValue = _this8.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc);
|
|
320
|
-
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE);
|
|
321
|
-
if (changedPath) {
|
|
322
|
-
changedPath.addParentNode(rowNode.parent, [column]);
|
|
323
|
-
}
|
|
324
|
-
var rowIndex = currentRow.rowIndex,
|
|
325
|
-
rowPinned = currentRow.rowPinned;
|
|
326
|
-
var cellId = _this8.cellPositionUtils.createIdFromValues({
|
|
327
|
-
rowIndex: rowIndex,
|
|
328
|
-
column: column,
|
|
329
|
-
rowPinned: rowPinned
|
|
330
|
-
});
|
|
331
|
-
cellsToFlash[cellId] = true;
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
_this8.iterateActiveRanges(true, rowCallback);
|
|
336
|
-
};
|
|
337
|
-
this.doPasteOperation(pasteOperation);
|
|
338
|
-
}
|
|
339
|
-
}, {
|
|
340
|
-
key: "removeLastLineIfBlank",
|
|
341
|
-
value: function removeLastLineIfBlank(parsedData) {
|
|
342
|
-
// remove last row if empty, excel puts empty last row in
|
|
343
|
-
var lastLine = _.last(parsedData);
|
|
344
|
-
var lastLineIsBlank = lastLine && lastLine.length === 1 && lastLine[0] === '';
|
|
345
|
-
if (lastLineIsBlank) {
|
|
346
|
-
// do not remove the last empty line when that is the only line pasted
|
|
347
|
-
if (parsedData.length === 1) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
_.removeFromArray(parsedData, lastLine);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}, {
|
|
354
|
-
key: "fireRowChanged",
|
|
355
|
-
value: function fireRowChanged(rowNodes) {
|
|
356
|
-
var _this9 = this;
|
|
357
|
-
if (this.gridOptionsService.get('editType') !== 'fullRow') {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
rowNodes.forEach(function (rowNode) {
|
|
361
|
-
var event = {
|
|
362
|
-
type: Events.EVENT_ROW_VALUE_CHANGED,
|
|
363
|
-
node: rowNode,
|
|
364
|
-
data: rowNode.data,
|
|
365
|
-
rowIndex: rowNode.rowIndex,
|
|
366
|
-
rowPinned: rowNode.rowPinned
|
|
367
|
-
};
|
|
368
|
-
_this9.eventService.dispatchEvent(event);
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
}, {
|
|
372
|
-
key: "pasteMultipleValues",
|
|
373
|
-
value: function pasteMultipleValues(clipboardGridData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, type, changedPath) {
|
|
374
|
-
var _this10 = this;
|
|
375
|
-
var rowPointer = currentRow;
|
|
376
|
-
// if doing CSRM and NOT tree data, then it means groups are aggregates, which are read only,
|
|
377
|
-
// so we should skip them when doing paste operations.
|
|
378
|
-
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData();
|
|
379
|
-
var getNextGoodRowNode = function getNextGoodRowNode() {
|
|
380
|
-
while (true) {
|
|
381
|
-
if (!rowPointer) {
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
var res = _this10.rowPositionUtils.getRowNode(rowPointer);
|
|
385
|
-
// move to next row down for next set of values
|
|
386
|
-
rowPointer = _this10.cellNavigationService.getRowBelow({
|
|
387
|
-
rowPinned: rowPointer.rowPinned,
|
|
388
|
-
rowIndex: rowPointer.rowIndex
|
|
389
|
-
});
|
|
390
|
-
// if no more rows, return null
|
|
391
|
-
if (res == null) {
|
|
392
|
-
return null;
|
|
393
|
-
}
|
|
394
|
-
// skip details rows and footer rows, never paste into them as they don't hold data
|
|
395
|
-
var skipRow = res.detail || res.footer || skipGroupRows && res.group;
|
|
396
|
-
// skipping row means we go into the next iteration of the while loop
|
|
397
|
-
if (!skipRow) {
|
|
398
|
-
return res;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
clipboardGridData.forEach(function (clipboardRowData) {
|
|
403
|
-
var rowNode = getNextGoodRowNode();
|
|
404
|
-
// if we have come to end of rows in grid, then skip
|
|
405
|
-
if (!rowNode) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
clipboardRowData.forEach(function (value, index) {
|
|
409
|
-
return _this10.updateCellValue(rowNode, columnsToPasteInto[index], value, cellsToFlash, type, changedPath);
|
|
410
|
-
});
|
|
411
|
-
updatedRowNodes.push(rowNode);
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}, {
|
|
415
|
-
key: "updateCellValue",
|
|
416
|
-
value: function updateCellValue(rowNode, column, value, cellsToFlash, type, changedPath) {
|
|
417
|
-
if (!rowNode || !column || !column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard'));
|
|
421
|
-
rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
|
|
422
|
-
var rowIndex = rowNode.rowIndex,
|
|
423
|
-
rowPinned = rowNode.rowPinned;
|
|
424
|
-
var cellId = this.cellPositionUtils.createIdFromValues({
|
|
425
|
-
rowIndex: rowIndex,
|
|
426
|
-
column: column,
|
|
427
|
-
rowPinned: rowPinned
|
|
428
|
-
});
|
|
429
|
-
cellsToFlash[cellId] = true;
|
|
430
|
-
if (changedPath) {
|
|
431
|
-
changedPath.addParentNode(rowNode.parent, [column]);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}, {
|
|
435
|
-
key: "copyToClipboard",
|
|
436
|
-
value: function copyToClipboard() {
|
|
437
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
438
|
-
this.copyOrCutToClipboard(params);
|
|
439
|
-
}
|
|
440
|
-
}, {
|
|
441
|
-
key: "cutToClipboard",
|
|
442
|
-
value: function cutToClipboard() {
|
|
443
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
444
|
-
if (this.gridOptionsService.is('suppressCutToClipboard')) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
this.copyOrCutToClipboard(params, true);
|
|
448
|
-
}
|
|
449
|
-
}, {
|
|
450
|
-
key: "copyOrCutToClipboard",
|
|
451
|
-
value: function copyOrCutToClipboard(params, cut) {
|
|
452
|
-
var includeHeaders = params.includeHeaders,
|
|
453
|
-
includeGroupHeaders = params.includeGroupHeaders;
|
|
454
|
-
this.logger.log("copyToClipboard: includeHeaders = ".concat(includeHeaders));
|
|
455
|
-
// don't override 'includeHeaders' if it has been explicitly set to 'false'
|
|
456
|
-
if (includeHeaders == null) {
|
|
457
|
-
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard');
|
|
458
|
-
}
|
|
459
|
-
if (includeGroupHeaders == null) {
|
|
460
|
-
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard');
|
|
461
|
-
}
|
|
462
|
-
var copyParams = {
|
|
463
|
-
includeHeaders: includeHeaders,
|
|
464
|
-
includeGroupHeaders: includeGroupHeaders
|
|
465
|
-
};
|
|
466
|
-
var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
|
|
467
|
-
var cellClearType = null;
|
|
468
|
-
// Copy priority is Range > Row > Focus
|
|
469
|
-
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
|
|
470
|
-
this.copySelectedRangeToClipboard(copyParams);
|
|
471
|
-
cellClearType = CellClearType.CellRange;
|
|
472
|
-
} else if (shouldCopyRows && !this.selectionService.isEmpty()) {
|
|
473
|
-
this.copySelectedRowsToClipboard(copyParams);
|
|
474
|
-
cellClearType = CellClearType.SelectedRows;
|
|
475
|
-
} else if (this.focusService.isAnyCellFocused()) {
|
|
476
|
-
this.copyFocusedCellToClipboard(copyParams);
|
|
477
|
-
cellClearType = CellClearType.FocusedCell;
|
|
478
|
-
}
|
|
479
|
-
if (cut && cellClearType !== null) {
|
|
480
|
-
this.clearCellsAfterCopy(cellClearType);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}, {
|
|
484
|
-
key: "clearCellsAfterCopy",
|
|
485
|
-
value: function clearCellsAfterCopy(type) {
|
|
486
|
-
this.eventService.dispatchEvent({
|
|
487
|
-
type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START
|
|
488
|
-
});
|
|
489
|
-
if (type === CellClearType.CellRange) {
|
|
490
|
-
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
|
|
491
|
-
} else if (type === CellClearType.SelectedRows) {
|
|
492
|
-
this.clearSelectedRows();
|
|
493
|
-
} else {
|
|
494
|
-
var focusedCell = this.focusService.getFocusedCell();
|
|
495
|
-
if (focusedCell == null) {
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
var rowNode = this.rowPositionUtils.getRowNode(focusedCell);
|
|
499
|
-
if (rowNode) {
|
|
500
|
-
this.clearCellValue(rowNode, focusedCell.column);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
this.eventService.dispatchEvent({
|
|
504
|
-
type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
}, {
|
|
508
|
-
key: "clearSelectedRows",
|
|
509
|
-
value: function clearSelectedRows() {
|
|
510
|
-
var selected = this.selectionService.getSelectedNodes();
|
|
511
|
-
var columns = this.columnModel.getAllDisplayedColumns();
|
|
512
|
-
var _iterator = _createForOfIteratorHelper(selected),
|
|
513
|
-
_step;
|
|
514
|
-
try {
|
|
515
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
516
|
-
var row = _step.value;
|
|
517
|
-
var _iterator2 = _createForOfIteratorHelper(columns),
|
|
518
|
-
_step2;
|
|
519
|
-
try {
|
|
520
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
521
|
-
var col = _step2.value;
|
|
522
|
-
this.clearCellValue(row, col);
|
|
523
|
-
}
|
|
524
|
-
} catch (err) {
|
|
525
|
-
_iterator2.e(err);
|
|
526
|
-
} finally {
|
|
527
|
-
_iterator2.f();
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
} catch (err) {
|
|
531
|
-
_iterator.e(err);
|
|
532
|
-
} finally {
|
|
533
|
-
_iterator.f();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}, {
|
|
537
|
-
key: "clearCellValue",
|
|
538
|
-
value: function clearCellValue(rowNode, column) {
|
|
539
|
-
if (!column.isCellEditable(rowNode)) {
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
rowNode.setDataValue(column, null, 'clipboardService');
|
|
543
|
-
}
|
|
544
|
-
}, {
|
|
545
|
-
key: "shouldSkipSingleCellRange",
|
|
546
|
-
value: function shouldSkipSingleCellRange() {
|
|
547
|
-
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();
|
|
548
|
-
}
|
|
549
|
-
}, {
|
|
550
|
-
key: "iterateActiveRanges",
|
|
551
|
-
value: function iterateActiveRanges(onlyFirst, rowCallback, columnCallback) {
|
|
552
|
-
var _this11 = this;
|
|
553
|
-
if (!this.rangeService || this.rangeService.isEmpty()) {
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
var cellRanges = this.rangeService.getCellRanges();
|
|
557
|
-
if (onlyFirst) {
|
|
558
|
-
this.iterateActiveRange(cellRanges[0], rowCallback, columnCallback, true);
|
|
559
|
-
} else {
|
|
560
|
-
cellRanges.forEach(function (range, idx) {
|
|
561
|
-
return _this11.iterateActiveRange(range, rowCallback, columnCallback, idx === cellRanges.length - 1);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}, {
|
|
566
|
-
key: "iterateActiveRange",
|
|
567
|
-
value: function iterateActiveRange(range, rowCallback, columnCallback, isLastRange) {
|
|
568
|
-
if (!this.rangeService) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
var currentRow = this.rangeService.getRangeStartRow(range);
|
|
572
|
-
var lastRow = this.rangeService.getRangeEndRow(range);
|
|
573
|
-
if (columnCallback && range.columns) {
|
|
574
|
-
columnCallback(range.columns);
|
|
575
|
-
}
|
|
576
|
-
var rangeIndex = 0;
|
|
577
|
-
var isLastRow = false;
|
|
578
|
-
// the currentRow could be missing if the user sets the active range manually, and sets a range
|
|
579
|
-
// that is outside of the grid (eg. sets range rows 0 to 100, but grid has only 20 rows).
|
|
580
|
-
while (!isLastRow && currentRow != null) {
|
|
581
|
-
var rowNode = this.rowPositionUtils.getRowNode(currentRow);
|
|
582
|
-
isLastRow = this.rowPositionUtils.sameRow(currentRow, lastRow);
|
|
583
|
-
rowCallback(currentRow, rowNode, range.columns, rangeIndex++, isLastRow && isLastRange);
|
|
584
|
-
currentRow = this.cellNavigationService.getRowBelow(currentRow);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}, {
|
|
588
|
-
key: "copySelectedRangeToClipboard",
|
|
589
|
-
value: function copySelectedRangeToClipboard() {
|
|
590
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
591
|
-
if (!this.rangeService || this.rangeService.isEmpty()) {
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
var allRangesMerge = this.rangeService.areAllRangesAbleToMerge();
|
|
595
|
-
var _ref = allRangesMerge ? this.buildDataFromMergedRanges(params) : this.buildDataFromRanges(params),
|
|
596
|
-
data = _ref.data,
|
|
597
|
-
cellsToFlash = _ref.cellsToFlash;
|
|
598
|
-
this.copyDataToClipboard(data);
|
|
599
|
-
this.dispatchFlashCells(cellsToFlash);
|
|
600
|
-
}
|
|
601
|
-
}, {
|
|
602
|
-
key: "buildDataFromMergedRanges",
|
|
603
|
-
value: function buildDataFromMergedRanges(params) {
|
|
604
|
-
var _this12 = this;
|
|
605
|
-
var columnsSet = new Set();
|
|
606
|
-
var ranges = this.rangeService.getCellRanges();
|
|
607
|
-
var rowPositionsMap = new Map();
|
|
608
|
-
var allRowPositions = [];
|
|
609
|
-
var allCellsToFlash = {};
|
|
610
|
-
ranges.forEach(function (range) {
|
|
611
|
-
range.columns.forEach(function (col) {
|
|
612
|
-
return columnsSet.add(col);
|
|
613
|
-
});
|
|
614
|
-
var _this12$getRangeRowPo = _this12.getRangeRowPositionsAndCellsToFlash(range),
|
|
615
|
-
rowPositions = _this12$getRangeRowPo.rowPositions,
|
|
616
|
-
cellsToFlash = _this12$getRangeRowPo.cellsToFlash;
|
|
617
|
-
rowPositions.forEach(function (rowPosition) {
|
|
618
|
-
var rowPositionAsString = "".concat(rowPosition.rowIndex, "-").concat(rowPosition.rowPinned || 'null');
|
|
619
|
-
if (!rowPositionsMap.get(rowPositionAsString)) {
|
|
620
|
-
rowPositionsMap.set(rowPositionAsString, true);
|
|
621
|
-
allRowPositions.push(rowPosition);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
Object.assign(allCellsToFlash, cellsToFlash);
|
|
625
|
-
});
|
|
626
|
-
var allColumns = this.columnModel.getAllDisplayedColumns();
|
|
627
|
-
var exportedColumns = Array.from(columnsSet);
|
|
628
|
-
exportedColumns.sort(function (a, b) {
|
|
629
|
-
var posA = allColumns.indexOf(a);
|
|
630
|
-
var posB = allColumns.indexOf(b);
|
|
631
|
-
return posA - posB;
|
|
632
|
-
});
|
|
633
|
-
var data = this.buildExportParams({
|
|
634
|
-
columns: exportedColumns,
|
|
635
|
-
rowPositions: allRowPositions,
|
|
636
|
-
includeHeaders: params.includeHeaders,
|
|
637
|
-
includeGroupHeaders: params.includeGroupHeaders
|
|
638
|
-
});
|
|
639
|
-
return {
|
|
640
|
-
data: data,
|
|
641
|
-
cellsToFlash: allCellsToFlash
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
}, {
|
|
645
|
-
key: "buildDataFromRanges",
|
|
646
|
-
value: function buildDataFromRanges(params) {
|
|
647
|
-
var _this13 = this;
|
|
648
|
-
var ranges = this.rangeService.getCellRanges();
|
|
649
|
-
var data = [];
|
|
650
|
-
var allCellsToFlash = {};
|
|
651
|
-
ranges.forEach(function (range) {
|
|
652
|
-
var _this13$getRangeRowPo = _this13.getRangeRowPositionsAndCellsToFlash(range),
|
|
653
|
-
rowPositions = _this13$getRangeRowPo.rowPositions,
|
|
654
|
-
cellsToFlash = _this13$getRangeRowPo.cellsToFlash;
|
|
655
|
-
Object.assign(allCellsToFlash, cellsToFlash);
|
|
656
|
-
data.push(_this13.buildExportParams({
|
|
657
|
-
columns: range.columns,
|
|
658
|
-
rowPositions: rowPositions,
|
|
659
|
-
includeHeaders: params.includeHeaders,
|
|
660
|
-
includeGroupHeaders: params.includeGroupHeaders
|
|
661
|
-
}));
|
|
662
|
-
});
|
|
663
|
-
return {
|
|
664
|
-
data: data.join('\n'),
|
|
665
|
-
cellsToFlash: allCellsToFlash
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
}, {
|
|
669
|
-
key: "getRangeRowPositionsAndCellsToFlash",
|
|
670
|
-
value: function getRangeRowPositionsAndCellsToFlash(range) {
|
|
671
|
-
var _this14 = this;
|
|
672
|
-
var rowPositions = [];
|
|
673
|
-
var cellsToFlash = {};
|
|
674
|
-
var startRow = this.rangeService.getRangeStartRow(range);
|
|
675
|
-
var lastRow = this.rangeService.getRangeEndRow(range);
|
|
676
|
-
var node = startRow;
|
|
677
|
-
while (node) {
|
|
678
|
-
rowPositions.push(node);
|
|
679
|
-
range.columns.forEach(function (column) {
|
|
680
|
-
var _node = node,
|
|
681
|
-
rowIndex = _node.rowIndex,
|
|
682
|
-
rowPinned = _node.rowPinned;
|
|
683
|
-
var cellId = _this14.cellPositionUtils.createIdFromValues({
|
|
684
|
-
rowIndex: rowIndex,
|
|
685
|
-
column: column,
|
|
686
|
-
rowPinned: rowPinned
|
|
687
|
-
});
|
|
688
|
-
cellsToFlash[cellId] = true;
|
|
689
|
-
});
|
|
690
|
-
if (this.rowPositionUtils.sameRow(node, lastRow)) {
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
node = this.cellNavigationService.getRowBelow(node);
|
|
694
|
-
}
|
|
695
|
-
return {
|
|
696
|
-
rowPositions: rowPositions,
|
|
697
|
-
cellsToFlash: cellsToFlash
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
}, {
|
|
701
|
-
key: "copyFocusedCellToClipboard",
|
|
702
|
-
value: function copyFocusedCellToClipboard() {
|
|
703
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
704
|
-
var focusedCell = this.focusService.getFocusedCell();
|
|
705
|
-
if (focusedCell == null) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
var cellId = this.cellPositionUtils.createId(focusedCell);
|
|
709
|
-
var currentRow = {
|
|
710
|
-
rowPinned: focusedCell.rowPinned,
|
|
711
|
-
rowIndex: focusedCell.rowIndex
|
|
712
|
-
};
|
|
713
|
-
var column = focusedCell.column;
|
|
714
|
-
var data = this.buildExportParams({
|
|
715
|
-
columns: [column],
|
|
716
|
-
rowPositions: [currentRow],
|
|
717
|
-
includeHeaders: params.includeHeaders,
|
|
718
|
-
includeGroupHeaders: params.includeGroupHeaders
|
|
719
|
-
});
|
|
720
|
-
this.copyDataToClipboard(data);
|
|
721
|
-
this.dispatchFlashCells(_defineProperty({}, cellId, true));
|
|
722
|
-
}
|
|
723
|
-
}, {
|
|
724
|
-
key: "copySelectedRowsToClipboard",
|
|
725
|
-
value: function copySelectedRowsToClipboard() {
|
|
726
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
727
|
-
var columnKeys = params.columnKeys,
|
|
728
|
-
includeHeaders = params.includeHeaders,
|
|
729
|
-
includeGroupHeaders = params.includeGroupHeaders;
|
|
730
|
-
var data = this.buildExportParams({
|
|
731
|
-
columns: columnKeys,
|
|
732
|
-
includeHeaders: includeHeaders,
|
|
733
|
-
includeGroupHeaders: includeGroupHeaders
|
|
734
|
-
});
|
|
735
|
-
this.copyDataToClipboard(data);
|
|
736
|
-
}
|
|
737
|
-
}, {
|
|
738
|
-
key: "buildExportParams",
|
|
739
|
-
value: function buildExportParams(params) {
|
|
740
|
-
var _this15 = this;
|
|
741
|
-
var columns = params.columns,
|
|
742
|
-
rowPositions = params.rowPositions,
|
|
743
|
-
_params$includeHeader = params.includeHeaders,
|
|
744
|
-
includeHeaders = _params$includeHeader === void 0 ? false : _params$includeHeader,
|
|
745
|
-
_params$includeGroupH = params.includeGroupHeaders,
|
|
746
|
-
includeGroupHeaders = _params$includeGroupH === void 0 ? false : _params$includeGroupH;
|
|
747
|
-
var exportParams = {
|
|
748
|
-
columnKeys: columns,
|
|
749
|
-
rowPositions: rowPositions,
|
|
750
|
-
skipColumnHeaders: !includeHeaders,
|
|
751
|
-
skipColumnGroupHeaders: !includeGroupHeaders,
|
|
752
|
-
suppressQuotes: true,
|
|
753
|
-
columnSeparator: this.getClipboardDelimiter(),
|
|
754
|
-
onlySelected: !rowPositions,
|
|
755
|
-
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'),
|
|
756
|
-
processRowGroupCallback: function processRowGroupCallback(params) {
|
|
757
|
-
return _this15.processRowGroupCallback(params);
|
|
758
|
-
},
|
|
759
|
-
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'),
|
|
760
|
-
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard')
|
|
761
|
-
};
|
|
762
|
-
return this.csvCreator.getDataAsCsv(exportParams, true);
|
|
763
|
-
}
|
|
764
|
-
}, {
|
|
765
|
-
key: "processRowGroupCallback",
|
|
766
|
-
value: function processRowGroupCallback(params) {
|
|
767
|
-
var node = params.node;
|
|
768
|
-
var key = node.key;
|
|
769
|
-
var value = key != null ? key : '';
|
|
770
|
-
if (params.node.footer) {
|
|
771
|
-
var suffix = '';
|
|
772
|
-
if (key && key.length) {
|
|
773
|
-
suffix = " ".concat(key);
|
|
774
|
-
}
|
|
775
|
-
value = "Total".concat(suffix);
|
|
776
|
-
}
|
|
777
|
-
var processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard');
|
|
778
|
-
if (processCellForClipboard) {
|
|
779
|
-
var column = node.rowGroupColumn;
|
|
780
|
-
if (!column && node.footer && node.level === -1) {
|
|
781
|
-
column = this.columnModel.getRowGroupColumns()[0];
|
|
782
|
-
}
|
|
783
|
-
return processCellForClipboard({
|
|
784
|
-
value: value,
|
|
785
|
-
node: node,
|
|
786
|
-
column: column,
|
|
787
|
-
type: 'clipboard'
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
return value;
|
|
791
|
-
}
|
|
792
|
-
}, {
|
|
793
|
-
key: "dispatchFlashCells",
|
|
794
|
-
value: function dispatchFlashCells(cellsToFlash) {
|
|
795
|
-
var _this16 = this;
|
|
796
|
-
window.setTimeout(function () {
|
|
797
|
-
var event = {
|
|
798
|
-
type: Events.EVENT_FLASH_CELLS,
|
|
799
|
-
cells: cellsToFlash
|
|
800
|
-
};
|
|
801
|
-
_this16.eventService.dispatchEvent(event);
|
|
802
|
-
}, 0);
|
|
803
|
-
}
|
|
804
|
-
}, {
|
|
805
|
-
key: "processCell",
|
|
806
|
-
value: function processCell(rowNode, column, value, type, func) {
|
|
807
|
-
if (func) {
|
|
808
|
-
var params = {
|
|
809
|
-
column: column,
|
|
810
|
-
node: rowNode,
|
|
811
|
-
value: value,
|
|
812
|
-
type: type
|
|
813
|
-
};
|
|
814
|
-
return func(params);
|
|
815
|
-
}
|
|
816
|
-
return value;
|
|
817
|
-
}
|
|
818
|
-
}, {
|
|
819
|
-
key: "copyDataToClipboard",
|
|
820
|
-
value: function copyDataToClipboard(data) {
|
|
821
|
-
var _this17 = this;
|
|
822
|
-
var userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard');
|
|
823
|
-
// method 1 - user provided func
|
|
824
|
-
if (userProvidedFunc) {
|
|
825
|
-
userProvidedFunc({
|
|
826
|
-
data: data
|
|
827
|
-
});
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
// method 2 - native clipboard API, available in modern chrome browsers
|
|
831
|
-
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi');
|
|
832
|
-
if (allowNavigator && navigator.clipboard) {
|
|
833
|
-
navigator.clipboard.writeText(data).catch(function (e) {
|
|
834
|
-
_.doOnce(function () {
|
|
835
|
-
console.warn(e);
|
|
836
|
-
console.warn('AG Grid: Unable to use the Clipboard API (navigator.clipboard.writeText()). ' + 'The reason why it could not be used has been logged in the previous line. ' + 'For this reason the grid has defaulted to using a workaround which doesn\'t perform as well. ' + 'Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid ' + 'property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API.');
|
|
837
|
-
}, 'clipboardApiError');
|
|
838
|
-
_this17.copyDataToClipboardLegacy(data);
|
|
839
|
-
});
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
this.copyDataToClipboardLegacy(data);
|
|
843
|
-
}
|
|
844
|
-
}, {
|
|
845
|
-
key: "copyDataToClipboardLegacy",
|
|
846
|
-
value: function copyDataToClipboardLegacy(data) {
|
|
847
|
-
var _this18 = this;
|
|
848
|
-
// method 3 - if all else fails, the old school hack
|
|
849
|
-
this.executeOnTempElement(function (element) {
|
|
850
|
-
var eDocument = _this18.gridOptionsService.getDocument();
|
|
851
|
-
var focusedElementBefore = eDocument.activeElement;
|
|
852
|
-
element.value = data || ' '; // has to be non-empty value or execCommand will not do anything
|
|
853
|
-
element.select();
|
|
854
|
-
element.focus({
|
|
855
|
-
preventScroll: true
|
|
856
|
-
});
|
|
857
|
-
var result = eDocument.execCommand('copy');
|
|
858
|
-
if (!result) {
|
|
859
|
-
console.warn('AG Grid: Browser did not allow document.execCommand(\'copy\'). Ensure ' + 'api.copySelectedRowsToClipboard() is invoked via a user event, i.e. button click, otherwise ' + 'the browser will prevent it for security reasons.');
|
|
860
|
-
}
|
|
861
|
-
if (focusedElementBefore != null && focusedElementBefore.focus != null) {
|
|
862
|
-
focusedElementBefore.focus({
|
|
863
|
-
preventScroll: true
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
}, {
|
|
869
|
-
key: "executeOnTempElement",
|
|
870
|
-
value: function executeOnTempElement(callbackNow, callbackAfter) {
|
|
871
|
-
var eDoc = this.gridOptionsService.getDocument();
|
|
872
|
-
var eTempInput = eDoc.createElement('textarea');
|
|
873
|
-
eTempInput.style.width = '1px';
|
|
874
|
-
eTempInput.style.height = '1px';
|
|
875
|
-
// removing items from the DOM causes the document element to scroll to the
|
|
876
|
-
// position where the element was positioned. Here we set scrollTop / scrollLeft
|
|
877
|
-
// to prevent the document element from scrolling when we remove it from the DOM.
|
|
878
|
-
eTempInput.style.top = eDoc.documentElement.scrollTop + 'px';
|
|
879
|
-
eTempInput.style.left = eDoc.documentElement.scrollLeft + 'px';
|
|
880
|
-
eTempInput.style.position = 'absolute';
|
|
881
|
-
eTempInput.style.opacity = '0';
|
|
882
|
-
var guiRoot = this.gridCtrl.getGui();
|
|
883
|
-
guiRoot.appendChild(eTempInput);
|
|
884
|
-
try {
|
|
885
|
-
callbackNow(eTempInput);
|
|
886
|
-
} catch (err) {
|
|
887
|
-
console.warn('AG Grid: Browser does not support document.execCommand(\'copy\') for clipboard operations');
|
|
888
|
-
}
|
|
889
|
-
//It needs 100 otherwise OS X seemed to not always be able to paste... Go figure...
|
|
890
|
-
if (callbackAfter) {
|
|
891
|
-
window.setTimeout(function () {
|
|
892
|
-
callbackAfter(eTempInput);
|
|
893
|
-
guiRoot.removeChild(eTempInput);
|
|
894
|
-
}, 100);
|
|
895
|
-
} else {
|
|
896
|
-
guiRoot.removeChild(eTempInput);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}, {
|
|
900
|
-
key: "getRangeSize",
|
|
901
|
-
value: function getRangeSize() {
|
|
902
|
-
var ranges = this.rangeService.getCellRanges();
|
|
903
|
-
var startRangeIndex = 0;
|
|
904
|
-
var endRangeIndex = 0;
|
|
905
|
-
if (ranges.length > 0) {
|
|
906
|
-
startRangeIndex = this.rangeService.getRangeStartRow(ranges[0]).rowIndex;
|
|
907
|
-
endRangeIndex = this.rangeService.getRangeEndRow(ranges[0]).rowIndex;
|
|
908
|
-
}
|
|
909
|
-
return startRangeIndex - endRangeIndex + 1;
|
|
910
|
-
}
|
|
911
|
-
}], [{
|
|
912
|
-
key: "stringToArray",
|
|
913
|
-
value: function stringToArray(strData) {
|
|
914
|
-
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
|
|
915
|
-
var data = [];
|
|
916
|
-
var isNewline = function isNewline(char) {
|
|
917
|
-
return char === '\r' || char === '\n';
|
|
918
|
-
};
|
|
919
|
-
var insideQuotedField = false;
|
|
920
|
-
if (strData === '') {
|
|
921
|
-
return [['']];
|
|
922
|
-
}
|
|
923
|
-
// iterate over each character, keep track of current row and column (of the returned array)
|
|
924
|
-
var _loop = function _loop(_row, _column, _position) {
|
|
925
|
-
var previousChar = strData[_position - 1];
|
|
926
|
-
var currentChar = strData[_position];
|
|
927
|
-
var nextChar = strData[_position + 1];
|
|
928
|
-
var ensureDataExists = function ensureDataExists() {
|
|
929
|
-
if (!data[_row]) {
|
|
930
|
-
// create row if it doesn't exist
|
|
931
|
-
data[_row] = [];
|
|
932
|
-
}
|
|
933
|
-
if (!data[_row][_column]) {
|
|
934
|
-
// create column if it doesn't exist
|
|
935
|
-
data[_row][_column] = '';
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
ensureDataExists();
|
|
939
|
-
if (currentChar === '"') {
|
|
940
|
-
if (insideQuotedField) {
|
|
941
|
-
if (nextChar === '"') {
|
|
942
|
-
// unescape double quote
|
|
943
|
-
data[_row][_column] += '"';
|
|
944
|
-
_position++;
|
|
945
|
-
} else {
|
|
946
|
-
// exit quoted field
|
|
947
|
-
insideQuotedField = false;
|
|
948
|
-
}
|
|
949
|
-
row = _row, column = _column, position = _position;
|
|
950
|
-
return 0; // continue
|
|
951
|
-
} else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
|
|
952
|
-
// enter quoted field
|
|
953
|
-
insideQuotedField = true;
|
|
954
|
-
row = _row, column = _column, position = _position;
|
|
955
|
-
return 0; // continue
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
if (!insideQuotedField) {
|
|
959
|
-
if (currentChar === delimiter) {
|
|
960
|
-
// move to next column
|
|
961
|
-
_column++;
|
|
962
|
-
ensureDataExists();
|
|
963
|
-
row = _row, column = _column, position = _position;
|
|
964
|
-
return 0; // continue
|
|
965
|
-
} else if (isNewline(currentChar)) {
|
|
966
|
-
// move to next row
|
|
967
|
-
_column = 0;
|
|
968
|
-
_row++;
|
|
969
|
-
ensureDataExists();
|
|
970
|
-
if (currentChar === '\r' && nextChar === '\n') {
|
|
971
|
-
// skip over second newline character if it exists
|
|
972
|
-
_position++;
|
|
973
|
-
}
|
|
974
|
-
row = _row, column = _column, position = _position;
|
|
975
|
-
return 0; // continue
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
// add current character to current column
|
|
979
|
-
data[_row][_column] += currentChar;
|
|
980
|
-
row = _row, column = _column, position = _position;
|
|
981
|
-
},
|
|
982
|
-
_ret;
|
|
983
|
-
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
|
|
984
|
-
_ret = _loop(row, column, position);
|
|
985
|
-
if (_ret === 0) continue;
|
|
986
|
-
}
|
|
987
|
-
return data;
|
|
988
|
-
}
|
|
989
|
-
}]);
|
|
990
|
-
return ClipboardService;
|
|
991
|
-
}(BeanStub);
|
|
992
|
-
__decorate([Autowired('csvCreator')], ClipboardService.prototype, "csvCreator", void 0);
|
|
993
|
-
__decorate([Autowired('loggerFactory')], ClipboardService.prototype, "loggerFactory", void 0);
|
|
994
|
-
__decorate([Autowired('selectionService')], ClipboardService.prototype, "selectionService", void 0);
|
|
995
|
-
__decorate([Optional('rangeService')], ClipboardService.prototype, "rangeService", void 0);
|
|
996
|
-
__decorate([Autowired('rowModel')], ClipboardService.prototype, "rowModel", void 0);
|
|
997
|
-
__decorate([Autowired('ctrlsService')], ClipboardService.prototype, "ctrlsService", void 0);
|
|
998
|
-
__decorate([Autowired('valueService')], ClipboardService.prototype, "valueService", void 0);
|
|
999
|
-
__decorate([Autowired('focusService')], ClipboardService.prototype, "focusService", void 0);
|
|
1000
|
-
__decorate([Autowired('rowRenderer')], ClipboardService.prototype, "rowRenderer", void 0);
|
|
1001
|
-
__decorate([Autowired('columnModel')], ClipboardService.prototype, "columnModel", void 0);
|
|
1002
|
-
__decorate([Autowired('cellNavigationService')], ClipboardService.prototype, "cellNavigationService", void 0);
|
|
1003
|
-
__decorate([Autowired('cellPositionUtils')], ClipboardService.prototype, "cellPositionUtils", void 0);
|
|
1004
|
-
__decorate([Autowired('rowPositionUtils')], ClipboardService.prototype, "rowPositionUtils", void 0);
|
|
1005
|
-
__decorate([PostConstruct], ClipboardService.prototype, "init", null);
|
|
1006
|
-
ClipboardService = ClipboardService_1 = __decorate([Bean('clipboardService')], ClipboardService);
|
|
1007
|
-
export { ClipboardService };
|