@ag-grid-enterprise/clipboard
Advanced tools
Comparing version 28.2.1 to 29.0.0
@@ -25,2 +25,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core"; | ||
private refocusLastFocusedCell; | ||
private getClipboardDelimiter; | ||
private processClipboardData; | ||
@@ -49,2 +50,3 @@ private doPasteOperation; | ||
private buildExportParams; | ||
private processRowGroupCallback; | ||
private dispatchFlashCells; | ||
@@ -51,0 +53,0 @@ private processCell; |
@@ -6,3 +6,3 @@ "use strict"; | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -23,3 +23,9 @@ }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardService = void 0; | ||
var core_1 = require("@ag-grid-community/core"); | ||
var csv_1 = require("./csv"); | ||
// Matches value in changeDetectionService | ||
var SOURCE_PASTE = 'paste'; | ||
var EXPORT_TYPE_DRAG_COPY = 'dragCopy'; | ||
var EXPORT_TYPE_CLIPBOARD = 'clipboard'; | ||
var ClipboardService = /** @class */ (function (_super) { | ||
@@ -36,3 +42,3 @@ __extends(ClipboardService, _super); | ||
this.logger = this.loggerFactory.create('ClipboardService'); | ||
if (this.rowModel.getType() === core_1.Constants.ROW_MODEL_TYPE_CLIENT_SIDE) { | ||
if (this.rowModel.getType() === 'clientSide') { | ||
this.clientSideRowModel = this.rowModel; | ||
@@ -48,3 +54,3 @@ } | ||
// Method 1 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
// Some browsers (Firefox) do not allow Web Applications to read from | ||
@@ -110,2 +116,6 @@ // the clipboard so verify if not only the ClipboardAPI is available, | ||
}; | ||
ClipboardService.prototype.getClipboardDelimiter = function () { | ||
var delimiter = this.gridOptionsService.get('clipboardDelimiter'); | ||
return core_1._.exists(delimiter) ? delimiter : '\t'; | ||
}; | ||
ClipboardService.prototype.processClipboardData = function (data) { | ||
@@ -116,4 +126,4 @@ var _this = this; | ||
} | ||
var parsedData = core_1._.stringToArray(data, this.gridOptionsWrapper.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsWrapper.getProcessDataFromClipboardFunc(); | ||
var parsedData = csv_1.stringToArray(data, this.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard'); | ||
if (userFunc) { | ||
@@ -125,3 +135,3 @@ parsedData = userFunc({ data: parsedData }); | ||
} | ||
if (this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()) { | ||
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) { | ||
this.removeLastLineIfBlank(parsedData); | ||
@@ -143,4 +153,4 @@ } | ||
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) { | ||
var api = this.gridOptionsWrapper.getApi(); | ||
var columnApi = this.gridOptionsWrapper.getColumnApi(); | ||
var api = this.gridOptionsService.get('api'); | ||
var columnApi = this.gridOptionsService.get('columnApi'); | ||
var source = 'clipboard'; | ||
@@ -155,3 +165,3 @@ this.eventService.dispatchEvent({ | ||
if (this.clientSideRowModel) { | ||
var onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns(); | ||
var onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns'); | ||
changedPath = new core_1.ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode()); | ||
@@ -198,3 +208,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
columns.forEach(function (column, idx) { | ||
@@ -208,4 +218,4 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) { | ||
} | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, core_1.Constants.SOURCE_PASTE); | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -231,3 +241,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
else { | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, core_1.Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
} | ||
@@ -247,3 +257,3 @@ }; | ||
columns.forEach(function (column) { | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, core_1.Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
}); | ||
@@ -263,4 +273,4 @@ }; | ||
var pasteOperation = function (cellsToFlash, updatedRowNodes, focusedCell, changedPath) { | ||
var processCellForClipboardFunc = _this.gridOptionsWrapper.getProcessCellForClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellForClipboardFunc = _this.gridOptionsService.getCallback('processCellForClipboard'); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
var rowCallback = function (currentRow, rowNode, columns) { | ||
@@ -272,3 +282,3 @@ // take reference of first row, this is the one we will be using to copy from | ||
// get the initial values to copy down | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
firstRowValues.push(value); | ||
@@ -284,4 +294,4 @@ }); | ||
} | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, core_1.Constants.SOURCE_PASTE); | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -313,3 +323,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
var _this = this; | ||
if (!this.gridOptionsWrapper.isFullRowEdit()) { | ||
if (this.gridOptionsService.get('editType') !== 'fullRow') { | ||
return; | ||
@@ -333,3 +343,3 @@ } | ||
// so we should skip them when doing paste operations. | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsWrapper.isTreeData(); | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData(); | ||
var getNextGoodRowNode = function () { | ||
@@ -374,4 +384,4 @@ while (true) { | ||
} | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsWrapper.getProcessCellFromClipboardFunc()); | ||
rowNode.setDataValue(column, processedValue, core_1.Constants.SOURCE_PASTE); | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard')); | ||
rowNode.setDataValue(column, processedValue, SOURCE_PASTE); | ||
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned); | ||
@@ -389,9 +399,9 @@ cellsToFlash[cellId] = true; | ||
if (includeHeaders == null) { | ||
includeHeaders = this.gridOptionsWrapper.isCopyHeadersToClipboard(); | ||
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard'); | ||
} | ||
if (includeGroupHeaders == null) { | ||
includeGroupHeaders = this.gridOptionsWrapper.isCopyGroupHeadersToClipboard(); | ||
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard'); | ||
} | ||
var copyParams = { includeHeaders: includeHeaders, includeGroupHeaders: includeGroupHeaders }; | ||
var shouldCopyRows = !this.gridOptionsWrapper.isSuppressCopyRowsToClipboard(); | ||
var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard'); | ||
// Copy priority is Range > Row > Focus | ||
@@ -409,3 +419,3 @@ if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) { | ||
ClipboardService.prototype.shouldSkipSingleCellRange = function () { | ||
return this.gridOptionsWrapper.isSuppressCopySingleCellRanges() && !this.rangeService.isMoreThanOneCell(); | ||
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell(); | ||
}; | ||
@@ -556,2 +566,3 @@ ClipboardService.prototype.iterateActiveRanges = function (onlyFirst, rowCallback, columnCallback) { | ||
ClipboardService.prototype.buildExportParams = function (params) { | ||
var _this = this; | ||
var columns = params.columns, rowPositions = params.rowPositions, _a = params.includeHeaders, includeHeaders = _a === void 0 ? false : _a, _b = params.includeGroupHeaders, includeGroupHeaders = _b === void 0 ? false : _b; | ||
@@ -564,11 +575,37 @@ var exportParams = { | ||
suppressQuotes: true, | ||
columnSeparator: this.gridOptionsWrapper.getClipboardDelimiter(), | ||
columnSeparator: this.getClipboardDelimiter(), | ||
onlySelected: !rowPositions, | ||
processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc(), | ||
processRowGroupCallback: function (params) { return params.node.key; }, | ||
processHeaderCallback: this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(), | ||
processGroupHeaderCallback: this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc() | ||
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'), | ||
processRowGroupCallback: function (params) { return _this.processRowGroupCallback(params); }, | ||
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'), | ||
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard') | ||
}; | ||
return this.csvCreator.getDataAsCsv(exportParams, true); | ||
}; | ||
ClipboardService.prototype.processRowGroupCallback = function (params) { | ||
var node = params.node; | ||
var key = node.key; | ||
var value = key != null ? key : ''; | ||
if (params.node.footer) { | ||
var suffix = ''; | ||
if (key && key.length) { | ||
suffix = " " + key; | ||
} | ||
value = "Total" + suffix; | ||
} | ||
var processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
if (processCellForClipboard) { | ||
var column = node.rowGroupColumn; | ||
if (!column && node.footer && node.level === -1) { | ||
column = this.columnModel.getRowGroupColumns()[0]; | ||
} | ||
return processCellForClipboard({ | ||
value: value, | ||
node: node, | ||
column: column, | ||
type: 'clipboard' | ||
}); | ||
} | ||
return value; | ||
}; | ||
ClipboardService.prototype.dispatchFlashCells = function (cellsToFlash) { | ||
@@ -598,3 +635,3 @@ var _this = this; | ||
var _this = this; | ||
var userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc(); | ||
var userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard'); | ||
// method 1 - user provided func | ||
@@ -606,3 +643,3 @@ if (userProvidedFunc) { | ||
// method 2 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
if (allowNavigator && navigator.clipboard) { | ||
@@ -628,3 +665,3 @@ navigator.clipboard.writeText(data).catch(function (e) { | ||
this.executeOnTempElement(function (element) { | ||
var eDocument = _this.gridOptionsWrapper.getDocument(); | ||
var eDocument = _this.gridOptionsService.getDocument(); | ||
var focusedElementBefore = eDocument.activeElement; | ||
@@ -646,3 +683,3 @@ element.value = data || ' '; // has to be non-empty value or execCommand will not do anything | ||
ClipboardService.prototype.executeOnTempElement = function (callbackNow, callbackAfter) { | ||
var eDoc = this.gridOptionsWrapper.getDocument(); | ||
var eDoc = this.gridOptionsService.getDocument(); | ||
var eTempInput = eDoc.createElement('textarea'); | ||
@@ -649,0 +686,0 @@ eTempInput.style.width = '1px'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardModule = void 0; | ||
var core_1 = require("@ag-grid-community/core"); | ||
@@ -7,3 +8,5 @@ var core_2 = require("@ag-grid-enterprise/core"); | ||
var clipboardService_1 = require("./clipboard/clipboardService"); | ||
var version_1 = require("./version"); | ||
exports.ClipboardModule = { | ||
version: version_1.VERSION, | ||
moduleName: core_1.ModuleNames.ClipboardModule, | ||
@@ -10,0 +13,0 @@ beans: [clipboardService_1.ClipboardService], |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardModule = void 0; | ||
var clipboardModule_1 = require("./clipboardModule"); | ||
exports.ClipboardModule = clipboardModule_1.ClipboardModule; | ||
Object.defineProperty(exports, "ClipboardModule", { enumerable: true, get: function () { return clipboardModule_1.ClipboardModule; } }); |
@@ -25,2 +25,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core"; | ||
private refocusLastFocusedCell; | ||
private getClipboardDelimiter; | ||
private processClipboardData; | ||
@@ -49,2 +50,3 @@ private doPasteOperation; | ||
private buildExportParams; | ||
private processRowGroupCallback; | ||
private dispatchFlashCells; | ||
@@ -51,0 +53,0 @@ private processCell; |
@@ -9,3 +9,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardService = void 0; | ||
const core_1 = require("@ag-grid-community/core"); | ||
const csv_1 = require("./csv"); | ||
// Matches value in changeDetectionService | ||
const SOURCE_PASTE = 'paste'; | ||
const EXPORT_TYPE_DRAG_COPY = 'dragCopy'; | ||
const EXPORT_TYPE_CLIPBOARD = 'clipboard'; | ||
let ClipboardService = class ClipboardService extends core_1.BeanStub { | ||
@@ -19,3 +25,3 @@ constructor() { | ||
this.logger = this.loggerFactory.create('ClipboardService'); | ||
if (this.rowModel.getType() === core_1.Constants.ROW_MODEL_TYPE_CLIENT_SIDE) { | ||
if (this.rowModel.getType() === 'clientSide') { | ||
this.clientSideRowModel = this.rowModel; | ||
@@ -30,3 +36,3 @@ } | ||
// Method 1 - native clipboard API, available in modern chrome browsers | ||
const allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
const allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
// Some browsers (Firefox) do not allow Web Applications to read from | ||
@@ -91,2 +97,6 @@ // the clipboard so verify if not only the ClipboardAPI is available, | ||
} | ||
getClipboardDelimiter() { | ||
const delimiter = this.gridOptionsService.get('clipboardDelimiter'); | ||
return core_1._.exists(delimiter) ? delimiter : '\t'; | ||
} | ||
processClipboardData(data) { | ||
@@ -96,4 +106,4 @@ if (data == null) { | ||
} | ||
let parsedData = core_1._.stringToArray(data, this.gridOptionsWrapper.getClipboardDelimiter()); | ||
const userFunc = this.gridOptionsWrapper.getProcessDataFromClipboardFunc(); | ||
let parsedData = csv_1.stringToArray(data, this.getClipboardDelimiter()); | ||
const userFunc = this.gridOptionsService.getCallback('processDataFromClipboard'); | ||
if (userFunc) { | ||
@@ -105,3 +115,3 @@ parsedData = userFunc({ data: parsedData }); | ||
} | ||
if (this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()) { | ||
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) { | ||
this.removeLastLineIfBlank(parsedData); | ||
@@ -123,4 +133,4 @@ } | ||
doPasteOperation(pasteOperationFunc) { | ||
const api = this.gridOptionsWrapper.getApi(); | ||
const columnApi = this.gridOptionsWrapper.getColumnApi(); | ||
const api = this.gridOptionsService.get('api'); | ||
const columnApi = this.gridOptionsService.get('columnApi'); | ||
const source = 'clipboard'; | ||
@@ -135,3 +145,3 @@ this.eventService.dispatchEvent({ | ||
if (this.clientSideRowModel) { | ||
const onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns(); | ||
const onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns'); | ||
changedPath = new core_1.ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode()); | ||
@@ -177,3 +187,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
const processCellFromClipboardFunc = this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
const processCellFromClipboardFunc = this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
columns.forEach((column, idx) => { | ||
@@ -187,4 +197,4 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) { | ||
} | ||
const newValue = this.processCell(rowNode, column, currentRowData[idx], core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, core_1.Constants.SOURCE_PASTE); | ||
const newValue = this.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -210,3 +220,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
else { | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, core_1.Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
} | ||
@@ -224,3 +234,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
columns.forEach(column => this.updateCellValue(rowNode, column, value, cellsToFlash, core_1.Constants.EXPORT_TYPE_CLIPBOARD, changedPath)); | ||
columns.forEach(column => this.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath)); | ||
}; | ||
@@ -238,4 +248,4 @@ this.iterateActiveRanges(false, rowCallback); | ||
const pasteOperation = (cellsToFlash, updatedRowNodes, focusedCell, changedPath) => { | ||
const processCellForClipboardFunc = this.gridOptionsWrapper.getProcessCellForClipboardFunc(); | ||
const processCellFromClipboardFunc = this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
const processCellForClipboardFunc = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
const processCellFromClipboardFunc = this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
const rowCallback = (currentRow, rowNode, columns) => { | ||
@@ -247,3 +257,3 @@ // take reference of first row, this is the one we will be using to copy from | ||
// get the initial values to copy down | ||
const value = this.processCell(rowNode, column, this.valueService.getValue(column, rowNode), core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
const value = this.processCell(rowNode, column, this.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
firstRowValues.push(value); | ||
@@ -259,4 +269,4 @@ }); | ||
} | ||
const firstRowValue = this.processCell(rowNode, column, firstRowValues[index], core_1.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, core_1.Constants.SOURCE_PASTE); | ||
const firstRowValue = this.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -287,3 +297,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
fireRowChanged(rowNodes) { | ||
if (!this.gridOptionsWrapper.isFullRowEdit()) { | ||
if (this.gridOptionsService.get('editType') !== 'fullRow') { | ||
return; | ||
@@ -306,3 +316,3 @@ } | ||
// so we should skip them when doing paste operations. | ||
const skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsWrapper.isTreeData(); | ||
const skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData(); | ||
const getNextGoodRowNode = () => { | ||
@@ -345,4 +355,4 @@ while (true) { | ||
} | ||
const processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsWrapper.getProcessCellFromClipboardFunc()); | ||
rowNode.setDataValue(column, processedValue, core_1.Constants.SOURCE_PASTE); | ||
const processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard')); | ||
rowNode.setDataValue(column, processedValue, SOURCE_PASTE); | ||
const cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned); | ||
@@ -359,9 +369,9 @@ cellsToFlash[cellId] = true; | ||
if (includeHeaders == null) { | ||
includeHeaders = this.gridOptionsWrapper.isCopyHeadersToClipboard(); | ||
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard'); | ||
} | ||
if (includeGroupHeaders == null) { | ||
includeGroupHeaders = this.gridOptionsWrapper.isCopyGroupHeadersToClipboard(); | ||
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard'); | ||
} | ||
const copyParams = { includeHeaders, includeGroupHeaders }; | ||
const shouldCopyRows = !this.gridOptionsWrapper.isSuppressCopyRowsToClipboard(); | ||
const shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard'); | ||
// Copy priority is Range > Row > Focus | ||
@@ -379,3 +389,3 @@ if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) { | ||
shouldSkipSingleCellRange() { | ||
return this.gridOptionsWrapper.isSuppressCopySingleCellRanges() && !this.rangeService.isMoreThanOneCell(); | ||
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell(); | ||
} | ||
@@ -525,11 +535,37 @@ iterateActiveRanges(onlyFirst, rowCallback, columnCallback) { | ||
suppressQuotes: true, | ||
columnSeparator: this.gridOptionsWrapper.getClipboardDelimiter(), | ||
columnSeparator: this.getClipboardDelimiter(), | ||
onlySelected: !rowPositions, | ||
processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc(), | ||
processRowGroupCallback: (params) => params.node.key, | ||
processHeaderCallback: this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(), | ||
processGroupHeaderCallback: this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc() | ||
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'), | ||
processRowGroupCallback: (params) => this.processRowGroupCallback(params), | ||
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'), | ||
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard') | ||
}; | ||
return this.csvCreator.getDataAsCsv(exportParams, true); | ||
} | ||
processRowGroupCallback(params) { | ||
const { node } = params; | ||
const { key } = node; | ||
let value = key != null ? key : ''; | ||
if (params.node.footer) { | ||
let suffix = ''; | ||
if (key && key.length) { | ||
suffix = ` ${key}`; | ||
} | ||
value = `Total${suffix}`; | ||
} | ||
const processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
if (processCellForClipboard) { | ||
let column = node.rowGroupColumn; | ||
if (!column && node.footer && node.level === -1) { | ||
column = this.columnModel.getRowGroupColumns()[0]; | ||
} | ||
return processCellForClipboard({ | ||
value, | ||
node, | ||
column, | ||
type: 'clipboard' | ||
}); | ||
} | ||
return value; | ||
} | ||
dispatchFlashCells(cellsToFlash) { | ||
@@ -557,3 +593,3 @@ window.setTimeout(() => { | ||
copyDataToClipboard(data) { | ||
const userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc(); | ||
const userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard'); | ||
// method 1 - user provided func | ||
@@ -565,3 +601,3 @@ if (userProvidedFunc) { | ||
// method 2 - native clipboard API, available in modern chrome browsers | ||
const allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
const allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
if (allowNavigator && navigator.clipboard) { | ||
@@ -586,3 +622,3 @@ navigator.clipboard.writeText(data).catch((e) => { | ||
this.executeOnTempElement(element => { | ||
const eDocument = this.gridOptionsWrapper.getDocument(); | ||
const eDocument = this.gridOptionsService.getDocument(); | ||
const focusedElementBefore = eDocument.activeElement; | ||
@@ -604,3 +640,3 @@ element.value = data || ' '; // has to be non-empty value or execCommand will not do anything | ||
executeOnTempElement(callbackNow, callbackAfter) { | ||
const eDoc = this.gridOptionsWrapper.getDocument(); | ||
const eDoc = this.gridOptionsService.getDocument(); | ||
const eTempInput = eDoc.createElement('textarea'); | ||
@@ -607,0 +643,0 @@ eTempInput.style.width = '1px'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardModule = void 0; | ||
const core_1 = require("@ag-grid-community/core"); | ||
@@ -7,3 +8,5 @@ const core_2 = require("@ag-grid-enterprise/core"); | ||
const clipboardService_1 = require("./clipboard/clipboardService"); | ||
const version_1 = require("./version"); | ||
exports.ClipboardModule = { | ||
version: version_1.VERSION, | ||
moduleName: core_1.ModuleNames.ClipboardModule, | ||
@@ -10,0 +13,0 @@ beans: [clipboardService_1.ClipboardService], |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClipboardModule = void 0; | ||
var clipboardModule_1 = require("./clipboardModule"); | ||
exports.ClipboardModule = clipboardModule_1.ClipboardModule; | ||
Object.defineProperty(exports, "ClipboardModule", { enumerable: true, get: function () { return clipboardModule_1.ClipboardModule; } }); |
/** | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1 | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0 | ||
* @link https://www.ag-grid.com/ | ||
@@ -14,2 +14,82 @@ * @license Commercial | ||
// Based on https://stackoverflow.com/a/14991797 | ||
// This will parse a delimited string into an array of arrays. | ||
function stringToArray(strData, delimiter) { | ||
if (delimiter === void 0) { delimiter = ','; } | ||
var data = []; | ||
var isNewline = function (char) { return char === '\r' || char === '\n'; }; | ||
var insideQuotedField = false; | ||
if (strData === '') { | ||
return [['']]; | ||
} | ||
var _loop_1 = function (row, column, position) { | ||
var previousChar = strData[position - 1]; | ||
var currentChar = strData[position]; | ||
var nextChar = strData[position + 1]; | ||
var ensureDataExists = function () { | ||
if (!data[row]) { | ||
// create row if it doesn't exist | ||
data[row] = []; | ||
} | ||
if (!data[row][column]) { | ||
// create column if it doesn't exist | ||
data[row][column] = ''; | ||
} | ||
}; | ||
ensureDataExists(); | ||
if (currentChar === '"') { | ||
if (insideQuotedField) { | ||
if (nextChar === '"') { | ||
// unescape double quote | ||
data[row][column] += '"'; | ||
position++; | ||
} | ||
else { | ||
// exit quoted field | ||
insideQuotedField = false; | ||
} | ||
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; | ||
} | ||
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) { | ||
// enter quoted field | ||
insideQuotedField = true; | ||
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; | ||
} | ||
} | ||
if (!insideQuotedField) { | ||
if (currentChar === delimiter) { | ||
// move to next column | ||
column++; | ||
ensureDataExists(); | ||
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; | ||
} | ||
else if (isNewline(currentChar)) { | ||
// move to next row | ||
column = 0; | ||
row++; | ||
ensureDataExists(); | ||
if (currentChar === '\r' && nextChar === '\n') { | ||
// skip over second newline character if it exists | ||
position++; | ||
} | ||
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue"; | ||
} | ||
} | ||
// add current character to current column | ||
data[row][column] += currentChar; | ||
out_row_1 = row; | ||
out_column_1 = column; | ||
out_position_1 = position; | ||
}; | ||
var out_row_1, out_column_1, out_position_1; | ||
// iterate over each character, keep track of current row and column (of the returned array) | ||
for (var row = 0, column = 0, position = 0; position < strData.length; position++) { | ||
_loop_1(row, column, position); | ||
row = out_row_1; | ||
column = out_column_1; | ||
position = out_position_1; | ||
} | ||
return data; | ||
} | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
@@ -19,3 +99,3 @@ var extendStatics = function (d, b) { | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -35,2 +115,6 @@ }; | ||
}; | ||
// Matches value in changeDetectionService | ||
var SOURCE_PASTE = 'paste'; | ||
var EXPORT_TYPE_DRAG_COPY = 'dragCopy'; | ||
var EXPORT_TYPE_CLIPBOARD = 'clipboard'; | ||
var ClipboardService = /** @class */ (function (_super) { | ||
@@ -47,3 +131,3 @@ __extends(ClipboardService, _super); | ||
this.logger = this.loggerFactory.create('ClipboardService'); | ||
if (this.rowModel.getType() === core.Constants.ROW_MODEL_TYPE_CLIENT_SIDE) { | ||
if (this.rowModel.getType() === 'clientSide') { | ||
this.clientSideRowModel = this.rowModel; | ||
@@ -59,3 +143,3 @@ } | ||
// Method 1 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
// Some browsers (Firefox) do not allow Web Applications to read from | ||
@@ -121,2 +205,6 @@ // the clipboard so verify if not only the ClipboardAPI is available, | ||
}; | ||
ClipboardService.prototype.getClipboardDelimiter = function () { | ||
var delimiter = this.gridOptionsService.get('clipboardDelimiter'); | ||
return core._.exists(delimiter) ? delimiter : '\t'; | ||
}; | ||
ClipboardService.prototype.processClipboardData = function (data) { | ||
@@ -127,4 +215,4 @@ var _this = this; | ||
} | ||
var parsedData = core._.stringToArray(data, this.gridOptionsWrapper.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsWrapper.getProcessDataFromClipboardFunc(); | ||
var parsedData = stringToArray(data, this.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard'); | ||
if (userFunc) { | ||
@@ -136,3 +224,3 @@ parsedData = userFunc({ data: parsedData }); | ||
} | ||
if (this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()) { | ||
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) { | ||
this.removeLastLineIfBlank(parsedData); | ||
@@ -154,4 +242,4 @@ } | ||
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) { | ||
var api = this.gridOptionsWrapper.getApi(); | ||
var columnApi = this.gridOptionsWrapper.getColumnApi(); | ||
var api = this.gridOptionsService.get('api'); | ||
var columnApi = this.gridOptionsService.get('columnApi'); | ||
var source = 'clipboard'; | ||
@@ -166,3 +254,3 @@ this.eventService.dispatchEvent({ | ||
if (this.clientSideRowModel) { | ||
var onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns(); | ||
var onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns'); | ||
changedPath = new core.ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode()); | ||
@@ -209,3 +297,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
columns.forEach(function (column, idx) { | ||
@@ -219,4 +307,4 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) { | ||
} | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], core.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, core.Constants.SOURCE_PASTE); | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -242,3 +330,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
else { | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, core.Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
} | ||
@@ -258,3 +346,3 @@ }; | ||
columns.forEach(function (column) { | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, core.Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
}); | ||
@@ -274,4 +362,4 @@ }; | ||
var pasteOperation = function (cellsToFlash, updatedRowNodes, focusedCell, changedPath) { | ||
var processCellForClipboardFunc = _this.gridOptionsWrapper.getProcessCellForClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellForClipboardFunc = _this.gridOptionsService.getCallback('processCellForClipboard'); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
var rowCallback = function (currentRow, rowNode, columns) { | ||
@@ -283,3 +371,3 @@ // take reference of first row, this is the one we will be using to copy from | ||
// get the initial values to copy down | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), core.Constants.EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
firstRowValues.push(value); | ||
@@ -295,4 +383,4 @@ }); | ||
} | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], core.Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, core.Constants.SOURCE_PASTE); | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -324,3 +412,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
var _this = this; | ||
if (!this.gridOptionsWrapper.isFullRowEdit()) { | ||
if (this.gridOptionsService.get('editType') !== 'fullRow') { | ||
return; | ||
@@ -344,3 +432,3 @@ } | ||
// so we should skip them when doing paste operations. | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsWrapper.isTreeData(); | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData(); | ||
var getNextGoodRowNode = function () { | ||
@@ -385,4 +473,4 @@ while (true) { | ||
} | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsWrapper.getProcessCellFromClipboardFunc()); | ||
rowNode.setDataValue(column, processedValue, core.Constants.SOURCE_PASTE); | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard')); | ||
rowNode.setDataValue(column, processedValue, SOURCE_PASTE); | ||
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned); | ||
@@ -400,9 +488,9 @@ cellsToFlash[cellId] = true; | ||
if (includeHeaders == null) { | ||
includeHeaders = this.gridOptionsWrapper.isCopyHeadersToClipboard(); | ||
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard'); | ||
} | ||
if (includeGroupHeaders == null) { | ||
includeGroupHeaders = this.gridOptionsWrapper.isCopyGroupHeadersToClipboard(); | ||
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard'); | ||
} | ||
var copyParams = { includeHeaders: includeHeaders, includeGroupHeaders: includeGroupHeaders }; | ||
var shouldCopyRows = !this.gridOptionsWrapper.isSuppressCopyRowsToClipboard(); | ||
var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard'); | ||
// Copy priority is Range > Row > Focus | ||
@@ -420,3 +508,3 @@ if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) { | ||
ClipboardService.prototype.shouldSkipSingleCellRange = function () { | ||
return this.gridOptionsWrapper.isSuppressCopySingleCellRanges() && !this.rangeService.isMoreThanOneCell(); | ||
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell(); | ||
}; | ||
@@ -567,2 +655,3 @@ ClipboardService.prototype.iterateActiveRanges = function (onlyFirst, rowCallback, columnCallback) { | ||
ClipboardService.prototype.buildExportParams = function (params) { | ||
var _this = this; | ||
var columns = params.columns, rowPositions = params.rowPositions, _a = params.includeHeaders, includeHeaders = _a === void 0 ? false : _a, _b = params.includeGroupHeaders, includeGroupHeaders = _b === void 0 ? false : _b; | ||
@@ -575,11 +664,37 @@ var exportParams = { | ||
suppressQuotes: true, | ||
columnSeparator: this.gridOptionsWrapper.getClipboardDelimiter(), | ||
columnSeparator: this.getClipboardDelimiter(), | ||
onlySelected: !rowPositions, | ||
processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc(), | ||
processRowGroupCallback: function (params) { return params.node.key; }, | ||
processHeaderCallback: this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(), | ||
processGroupHeaderCallback: this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc() | ||
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'), | ||
processRowGroupCallback: function (params) { return _this.processRowGroupCallback(params); }, | ||
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'), | ||
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard') | ||
}; | ||
return this.csvCreator.getDataAsCsv(exportParams, true); | ||
}; | ||
ClipboardService.prototype.processRowGroupCallback = function (params) { | ||
var node = params.node; | ||
var key = node.key; | ||
var value = key != null ? key : ''; | ||
if (params.node.footer) { | ||
var suffix = ''; | ||
if (key && key.length) { | ||
suffix = " " + key; | ||
} | ||
value = "Total" + suffix; | ||
} | ||
var processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
if (processCellForClipboard) { | ||
var column = node.rowGroupColumn; | ||
if (!column && node.footer && node.level === -1) { | ||
column = this.columnModel.getRowGroupColumns()[0]; | ||
} | ||
return processCellForClipboard({ | ||
value: value, | ||
node: node, | ||
column: column, | ||
type: 'clipboard' | ||
}); | ||
} | ||
return value; | ||
}; | ||
ClipboardService.prototype.dispatchFlashCells = function (cellsToFlash) { | ||
@@ -609,3 +724,3 @@ var _this = this; | ||
var _this = this; | ||
var userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc(); | ||
var userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard'); | ||
// method 1 - user provided func | ||
@@ -617,3 +732,3 @@ if (userProvidedFunc) { | ||
// method 2 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
if (allowNavigator && navigator.clipboard) { | ||
@@ -639,3 +754,3 @@ navigator.clipboard.writeText(data).catch(function (e) { | ||
this.executeOnTempElement(function (element) { | ||
var eDocument = _this.gridOptionsWrapper.getDocument(); | ||
var eDocument = _this.gridOptionsService.getDocument(); | ||
var focusedElementBefore = eDocument.activeElement; | ||
@@ -657,3 +772,3 @@ element.value = data || ' '; // has to be non-empty value or execCommand will not do anything | ||
ClipboardService.prototype.executeOnTempElement = function (callbackNow, callbackAfter) { | ||
var eDoc = this.gridOptionsWrapper.getDocument(); | ||
var eDoc = this.gridOptionsService.getDocument(); | ||
var eTempInput = eDoc.createElement('textarea'); | ||
@@ -746,3 +861,7 @@ eTempInput.style.width = '1px'; | ||
// DO NOT UPDATE MANUALLY: Generated from script during build time | ||
var VERSION = '29.0.0'; | ||
var ClipboardModule = { | ||
version: VERSION, | ||
moduleName: core.ModuleNames.ClipboardModule, | ||
@@ -749,0 +868,0 @@ beans: [ClipboardService], |
/** | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1 | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0 | ||
* @link https://www.ag-grid.com/ | ||
@@ -7,6 +7,6 @@ * @license Commercial | ||
/** | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v28.2.1 | ||
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0 | ||
* @link https://www.ag-grid.com/ | ||
* @license Commercial | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@ag-grid-community/core"),o=require("@ag-grid-enterprise/core"),r=require("@ag-grid-community/csv-export"),i=(e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)},function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}),n=function(e,t,o,r){var i,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(n<3?i(s):n>3?i(t,o,s):i(t,o))||s);return n>3&&s&&Object.defineProperty(t,o,s),s},s=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.lastPasteOperationTime=0,t.navigatorApiFailed=!1,t}return i(o,e),o.prototype.init=function(){var e=this;this.logger=this.loggerFactory.create("ClipboardService"),this.rowModel.getType()===t.Constants.ROW_MODEL_TYPE_CLIENT_SIDE&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady((function(t){e.gridCtrl=t.gridCtrl}))},o.prototype.pasteFromClipboard=function(){var e=this;this.logger.log("pasteFromClipboard"),!this.gridOptionsWrapper.isSuppressClipboardApi()&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch((function(o){t._.doOnce((function(){console.warn(o),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")}),"clipboardApiError"),e.navigatorApiFailed=!0,e.pasteFromClipboardLegacy()})):this.pasteFromClipboardLegacy()},o.prototype.pasteFromClipboardLegacy=function(){var e=this,t=!1,o=function(o){var r=(new Date).getTime();r-e.lastPasteOperationTime<50&&(t=!0,o.preventDefault()),e.lastPasteOperationTime=r};this.executeOnTempElement((function(e){e.addEventListener("paste",o),e.focus({preventScroll:!0})}),(function(r){var i=r.value;t?e.refocusLastFocusedCell():e.processClipboardData(i),r.removeEventListener("paste",o)}))},o.prototype.refocusLastFocusedCell=function(){var e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})},o.prototype.processClipboardData=function(e){var o=this;if(null!=e){var r=t._.stringToArray(e,this.gridOptionsWrapper.getClipboardDelimiter()),i=this.gridOptionsWrapper.getProcessDataFromClipboardFunc();if(i&&(r=i({data:r})),null!=r){this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()&&this.removeLastLineIfBlank(r);this.doPasteOperation((function(e,t,i,n){o.rangeService&&o.rangeService.isMoreThanOneCell()&&!o.hasOnlyOneValueToPaste(r)?o.pasteIntoActiveRange(r,e,t,n):o.pasteStartingFromFocusedCell(r,e,t,i,n)}))}}},o.prototype.doPasteOperation=function(e){var o,r=this.gridOptionsWrapper.getApi(),i=this.gridOptionsWrapper.getColumnApi();if(this.eventService.dispatchEvent({type:t.Events.EVENT_PASTE_START,api:r,columnApi:i,source:"clipboard"}),this.clientSideRowModel){var n=this.gridOptionsWrapper.isAggregateOnlyChangedColumns();o=new t.ChangedPath(n,this.clientSideRowModel.getRootNode())}var s={},a=[];e(s,a,this.focusService.getFocusedCell(),o),o&&this.clientSideRowModel.doAggregate(o),this.rowRenderer.refreshCells(),this.dispatchFlashCells(s),this.fireRowChanged(a),this.refocusLastFocusedCell();var l={type:t.Events.EVENT_PASTE_END,source:"clipboard"};this.eventService.dispatchEvent(l)},o.prototype.pasteIntoActiveRange=function(e,o,r,i){var n=this,s=this.getRangeSize()%e.length!=0,a=0,l=0;this.iterateActiveRanges(!1,(function(p,c,d,u){if(u-a>=e.length){if(s)return;a+=l,l=0}var h=e[u-a];r.push(c);var g=n.gridOptionsWrapper.getProcessCellFromClipboardFunc();d.forEach((function(e,r){if(e.isCellEditable(c)&&!e.isSuppressPaste(c)){r>=h.length&&(r%=h.length);var s=n.processCell(c,e,h[r],t.Constants.EXPORT_TYPE_DRAG_COPY,g);c.setDataValue(e,s,t.Constants.SOURCE_PASTE),i&&i.addParentNode(c.parent,[e]);var a=n.cellPositionUtils.createIdFromValues(p.rowIndex,e,p.rowPinned);o[a]=!0}})),l++}))},o.prototype.pasteStartingFromFocusedCell=function(e,o,r,i,n){if(i){var s={rowIndex:i.rowIndex,rowPinned:i.rowPinned},a=this.columnModel.getDisplayedColumnsStartingAt(i.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,r,o,n):this.pasteMultipleValues(e,s,r,a,o,t.Constants.EXPORT_TYPE_CLIPBOARD,n)}},o.prototype.isPasteSingleValueIntoRange=function(e){return this.hasOnlyOneValueToPaste(e)&&null!=this.rangeService&&!this.rangeService.isEmpty()},o.prototype.pasteSingleValueIntoRange=function(e,o,r,i){var n=this,s=e[0][0];this.iterateActiveRanges(!1,(function(e,a,l){o.push(a),l.forEach((function(e){return n.updateCellValue(a,e,s,r,t.Constants.EXPORT_TYPE_CLIPBOARD,i)}))}))},o.prototype.hasOnlyOneValueToPaste=function(e){return 1===e.length&&1===e[0].length},o.prototype.copyRangeDown=function(){var e=this;if(this.rangeService&&!this.rangeService.isEmpty()){var o=[];this.doPasteOperation((function(r,i,n,s){var a=e.gridOptionsWrapper.getProcessCellForClipboardFunc(),l=e.gridOptionsWrapper.getProcessCellFromClipboardFunc();e.iterateActiveRanges(!0,(function(n,p,c){o.length?(i.push(p),c.forEach((function(i,a){if(i.isCellEditable(p)&&!i.isSuppressPaste(p)){var c=e.processCell(p,i,o[a],t.Constants.EXPORT_TYPE_DRAG_COPY,l);p.setDataValue(i,c,t.Constants.SOURCE_PASTE),s&&s.addParentNode(p.parent,[i]);var d=e.cellPositionUtils.createIdFromValues(n.rowIndex,i,n.rowPinned);r[d]=!0}}))):c.forEach((function(r){var i=e.processCell(p,r,e.valueService.getValue(r,p),t.Constants.EXPORT_TYPE_DRAG_COPY,a);o.push(i)}))}))}))}},o.prototype.removeLastLineIfBlank=function(e){var o=t._.last(e);if(o&&1===o.length&&""===o[0]){if(1===e.length)return;t._.removeFromArray(e,o)}},o.prototype.fireRowChanged=function(e){var o=this;this.gridOptionsWrapper.isFullRowEdit()&&e.forEach((function(e){var r={type:t.Events.EVENT_ROW_VALUE_CHANGED,node:e,data:e.data,rowIndex:e.rowIndex,rowPinned:e.rowPinned};o.eventService.dispatchEvent(r)}))},o.prototype.pasteMultipleValues=function(e,t,o,r,i,n,s){var a=this,l=t,p=null!=this.clientSideRowModel&&!this.gridOptionsWrapper.isTreeData();e.forEach((function(e){var t=function(){for(;;){if(!l)return null;var e=a.rowPositionUtils.getRowNode(l);if(l=a.cellNavigationService.getRowBelow({rowPinned:l.rowPinned,rowIndex:l.rowIndex}),null==e)return null;if(!(e.detail||e.footer||p&&e.group))return e}}();t&&(e.forEach((function(e,o){return a.updateCellValue(t,r[o],e,i,n,s)})),o.push(t))}))},o.prototype.updateCellValue=function(e,o,r,i,n,s){if(e&&o&&o.isCellEditable(e)&&!o.isSuppressPaste(e)){var a=this.processCell(e,o,r,n,this.gridOptionsWrapper.getProcessCellFromClipboardFunc());e.setDataValue(o,a,t.Constants.SOURCE_PASTE),i[this.cellPositionUtils.createIdFromValues(e.rowIndex,o,e.rowPinned)]=!0,s&&s.addParentNode(e.parent,[o])}},o.prototype.copyToClipboard=function(e){void 0===e&&(e={});var t=e.includeHeaders,o=e.includeGroupHeaders;this.logger.log("copyToClipboard: includeHeaders = "+t),null==t&&(t=this.gridOptionsWrapper.isCopyHeadersToClipboard()),null==o&&(o=this.gridOptionsWrapper.isCopyGroupHeadersToClipboard());var r={includeHeaders:t,includeGroupHeaders:o},i=!this.gridOptionsWrapper.isSuppressCopyRowsToClipboard();!this.rangeService||this.rangeService.isEmpty()||this.shouldSkipSingleCellRange()?i&&!this.selectionService.isEmpty()?this.copySelectedRowsToClipboard(r):this.focusService.isAnyCellFocused()&&this.copyFocusedCellToClipboard(r):this.copySelectedRangeToClipboard(r)},o.prototype.shouldSkipSingleCellRange=function(){return this.gridOptionsWrapper.isSuppressCopySingleCellRanges()&&!this.rangeService.isMoreThanOneCell()},o.prototype.iterateActiveRanges=function(e,t,o){var r=this;if(this.rangeService&&!this.rangeService.isEmpty()){var i=this.rangeService.getCellRanges();e?this.iterateActiveRange(i[0],t,o,!0):i.forEach((function(e,n){return r.iterateActiveRange(e,t,o,n===i.length-1)}))}},o.prototype.iterateActiveRange=function(e,t,o,r){if(this.rangeService){var i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e);o&&e.columns&&o(e.columns);for(var s=0,a=!1;!a&&null!=i;){var l=this.rowPositionUtils.getRowNode(i);a=this.rowPositionUtils.sameRow(i,n),t(i,l,e.columns,s++,a&&r),i=this.cellNavigationService.getRowBelow(i)}}},o.prototype.copySelectedRangeToClipboard=function(e){if(void 0===e&&(e={}),this.rangeService&&!this.rangeService.isEmpty()){var t=this.rangeService.areAllRangesAbleToMerge()?this.buildDataFromMergedRanges(e):this.buildDataFromRanges(e),o=t.data,r=t.cellsToFlash;this.copyDataToClipboard(o),this.dispatchFlashCells(r)}},o.prototype.buildDataFromMergedRanges=function(e){var t=this,o=new Set,r=this.rangeService.getCellRanges(),i=new Map,n=[],s={};r.forEach((function(e){e.columns.forEach((function(e){return o.add(e)}));var r=t.getRangeRowPositionsAndCellsToFlash(e),a=r.rowPositions,l=r.cellsToFlash;a.forEach((function(e){var t=e.rowIndex+"-"+(e.rowPinned||"null");i.get(t)||(i.set(t,!0),n.push(e))})),Object.assign(s,l)}));var a=this.columnModel.getAllDisplayedColumns(),l=Array.from(o);return l.sort((function(e,t){return a.indexOf(e)-a.indexOf(t)})),{data:this.buildExportParams({columns:l,rowPositions:n,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:s}},o.prototype.buildDataFromRanges=function(e){var t=this,o=this.rangeService.getCellRanges(),r=[],i={};return o.forEach((function(o){var n=t.getRangeRowPositionsAndCellsToFlash(o),s=n.rowPositions,a=n.cellsToFlash;Object.assign(i,a),r.push(t.buildExportParams({columns:o.columns,rowPositions:s,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))})),{data:r.join("\n"),cellsToFlash:i}},o.prototype.getRangeRowPositionsAndCellsToFlash=function(e){for(var t=this,o=[],r={},i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e),s=i;s&&(o.push(s),e.columns.forEach((function(e){var o=t.cellPositionUtils.createIdFromValues(s.rowIndex,e,s.rowPinned);r[o]=!0})),!this.rowPositionUtils.sameRow(s,n));)s=this.cellNavigationService.getRowBelow(s);return{rowPositions:o,cellsToFlash:r}},o.prototype.copyFocusedCellToClipboard=function(e){var t;void 0===e&&(e={});var o=this.focusService.getFocusedCell();if(null!=o){var r=this.cellPositionUtils.createId(o),i={rowPinned:o.rowPinned,rowIndex:o.rowIndex},n=o.column,s=this.buildExportParams({columns:[n],rowPositions:[i],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(s),this.dispatchFlashCells(((t={})[r]=!0,t))}},o.prototype.copySelectedRowsToClipboard=function(e){void 0===e&&(e={});var t=e.columnKeys,o=e.includeHeaders,r=e.includeGroupHeaders,i=this.buildExportParams({columns:t,includeHeaders:o,includeGroupHeaders:r});this.copyDataToClipboard(i)},o.prototype.buildExportParams=function(e){var t=e.columns,o=e.rowPositions,r=e.includeHeaders,i=void 0!==r&&r,n=e.includeGroupHeaders,s={columnKeys:t,rowPositions:o,skipColumnHeaders:!i,skipColumnGroupHeaders:!(void 0!==n&&n),suppressQuotes:!0,columnSeparator:this.gridOptionsWrapper.getClipboardDelimiter(),onlySelected:!o,processCellCallback:this.gridOptionsWrapper.getProcessCellForClipboardFunc(),processRowGroupCallback:function(e){return e.node.key},processHeaderCallback:this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(),processGroupHeaderCallback:this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc()};return this.csvCreator.getDataAsCsv(s,!0)},o.prototype.dispatchFlashCells=function(e){var o=this;window.setTimeout((function(){var r={type:t.Events.EVENT_FLASH_CELLS,cells:e};o.eventService.dispatchEvent(r)}),0)},o.prototype.processCell=function(e,t,o,r,i){return i?i({column:t,node:e,value:o,type:r}):o},o.prototype.copyDataToClipboard=function(e){var o=this,r=this.gridOptionsWrapper.getSendToClipboardFunc();r?r({data:e}):!this.gridOptionsWrapper.isSuppressClipboardApi()&&navigator.clipboard?navigator.clipboard.writeText(e).catch((function(r){t._.doOnce((function(){console.warn(r),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.")}),"clipboardApiError"),o.copyDataToClipboardLegacy(e)})):this.copyDataToClipboardLegacy(e)},o.prototype.copyDataToClipboardLegacy=function(e){var t=this;this.executeOnTempElement((function(o){var r=t.gridOptionsWrapper.getDocument(),i=r.activeElement;o.value=e||" ",o.select(),o.focus({preventScroll:!0}),r.execCommand("copy")||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."),null!=i&&null!=i.focus&&i.focus({preventScroll:!0})}))},o.prototype.executeOnTempElement=function(e,t){var o=this.gridOptionsWrapper.getDocument(),r=o.createElement("textarea");r.style.width="1px",r.style.height="1px",r.style.top=o.documentElement.scrollTop+"px",r.style.left=o.documentElement.scrollLeft+"px",r.style.position="absolute",r.style.opacity="0";var i=this.gridCtrl.getGui();i.appendChild(r);try{e(r)}catch(e){console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout((function(){t(r),i.removeChild(r)}),100):i.removeChild(r)},o.prototype.getRangeSize=function(){var e=this.rangeService.getCellRanges(),t=0,o=0;return e.length>0&&(t=this.rangeService.getRangeStartRow(e[0]).rowIndex,o=this.rangeService.getRangeEndRow(e[0]).rowIndex),t-o+1},n([t.Autowired("csvCreator")],o.prototype,"csvCreator",void 0),n([t.Autowired("loggerFactory")],o.prototype,"loggerFactory",void 0),n([t.Autowired("selectionService")],o.prototype,"selectionService",void 0),n([t.Optional("rangeService")],o.prototype,"rangeService",void 0),n([t.Autowired("rowModel")],o.prototype,"rowModel",void 0),n([t.Autowired("ctrlsService")],o.prototype,"ctrlsService",void 0),n([t.Autowired("valueService")],o.prototype,"valueService",void 0),n([t.Autowired("focusService")],o.prototype,"focusService",void 0),n([t.Autowired("rowRenderer")],o.prototype,"rowRenderer",void 0),n([t.Autowired("columnModel")],o.prototype,"columnModel",void 0),n([t.Autowired("cellNavigationService")],o.prototype,"cellNavigationService",void 0),n([t.Autowired("cellPositionUtils")],o.prototype,"cellPositionUtils",void 0),n([t.Autowired("rowPositionUtils")],o.prototype,"rowPositionUtils",void 0),n([t.PostConstruct],o.prototype,"init",null),o=n([t.Bean("clipboardService")],o)}(t.BeanStub),a={moduleName:t.ModuleNames.ClipboardModule,beans:[s],dependantModules:[o.EnterpriseCoreModule,r.CsvExportModule]};exports.ClipboardModule=a; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ag-grid-community/core"),t=require("@ag-grid-enterprise/core"),o=require("@ag-grid-community/csv-export");var r,i=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(e,t)},function(e,t){function o(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),n=function(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},a=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.lastPasteOperationTime=0,e.navigatorApiFailed=!1,e}return i(o,t),o.prototype.init=function(){var e=this;this.logger=this.loggerFactory.create("ClipboardService"),"clientSide"===this.rowModel.getType()&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady((function(t){e.gridCtrl=t.gridCtrl}))},o.prototype.pasteFromClipboard=function(){var t=this;this.logger.log("pasteFromClipboard"),!this.gridOptionsService.is("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch((function(o){e._.doOnce((function(){console.warn(o),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")}),"clipboardApiError"),t.navigatorApiFailed=!0,t.pasteFromClipboardLegacy()})):this.pasteFromClipboardLegacy()},o.prototype.pasteFromClipboardLegacy=function(){var e=this,t=!1,o=function(o){var r=(new Date).getTime();r-e.lastPasteOperationTime<50&&(t=!0,o.preventDefault()),e.lastPasteOperationTime=r};this.executeOnTempElement((function(e){e.addEventListener("paste",o),e.focus({preventScroll:!0})}),(function(r){var i=r.value;t?e.refocusLastFocusedCell():e.processClipboardData(i),r.removeEventListener("paste",o)}))},o.prototype.refocusLastFocusedCell=function(){var e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})},o.prototype.getClipboardDelimiter=function(){var t=this.gridOptionsService.get("clipboardDelimiter");return e._.exists(t)?t:"\t"},o.prototype.processClipboardData=function(e){var t=this;if(null!=e){var o=function(e,t){void 0===t&&(t=",");var o=[],r=function(e){return"\r"===e||"\n"===e},i=!1;if(""===e)return[[""]];for(var n,a,s,l=function(l,c,p){var d=e[p-1],u=e[p],h=e[p+1],g=function(){o[l]||(o[l]=[]),o[l][c]||(o[l][c]="")};if(g(),'"'===u){if(i)return'"'===h?(o[l][c]+='"',p++):i=!1,n=l,a=c,s=p,"continue";if(void 0===d||d===t||r(d))return i=!0,n=l,a=c,s=p,"continue"}if(!i){if(u===t)return c++,g(),n=l,a=c,s=p,"continue";if(r(u))return c=0,l++,g(),"\r"===u&&"\n"===h&&p++,n=l,a=c,s=p,"continue"}o[l][c]+=u,n=l,a=c,s=p},c=0,p=0,d=0;d<e.length;d++)l(c,p,d),c=n,p=a,d=s;return o}(e,this.getClipboardDelimiter()),r=this.gridOptionsService.getCallback("processDataFromClipboard");if(r&&(o=r({data:o})),null!=o){this.gridOptionsService.is("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(o);this.doPasteOperation((function(e,r,i,n){t.rangeService&&t.rangeService.isMoreThanOneCell()&&!t.hasOnlyOneValueToPaste(o)?t.pasteIntoActiveRange(o,e,r,n):t.pasteStartingFromFocusedCell(o,e,r,i,n)}))}}},o.prototype.doPasteOperation=function(t){var o,r=this.gridOptionsService.get("api"),i=this.gridOptionsService.get("columnApi");if(this.eventService.dispatchEvent({type:e.Events.EVENT_PASTE_START,api:r,columnApi:i,source:"clipboard"}),this.clientSideRowModel){var n=this.gridOptionsService.is("aggregateOnlyChangedColumns");o=new e.ChangedPath(n,this.clientSideRowModel.getRootNode())}var a={},s=[];t(a,s,this.focusService.getFocusedCell(),o),o&&this.clientSideRowModel.doAggregate(o),this.rowRenderer.refreshCells(),this.dispatchFlashCells(a),this.fireRowChanged(s),this.refocusLastFocusedCell();var l={type:e.Events.EVENT_PASTE_END,source:"clipboard"};this.eventService.dispatchEvent(l)},o.prototype.pasteIntoActiveRange=function(e,t,o,r){var i=this,n=this.getRangeSize()%e.length!=0,a=0,s=0;this.iterateActiveRanges(!1,(function(l,c,p,d){if(d-a>=e.length){if(n)return;a+=s,s=0}var u=e[d-a];o.push(c);var h=i.gridOptionsService.getCallback("processCellFromClipboard");p.forEach((function(e,o){if(e.isCellEditable(c)&&!e.isSuppressPaste(c)){o>=u.length&&(o%=u.length);var n=i.processCell(c,e,u[o],"dragCopy",h);c.setDataValue(e,n,"paste"),r&&r.addParentNode(c.parent,[e]);var a=i.cellPositionUtils.createIdFromValues(l.rowIndex,e,l.rowPinned);t[a]=!0}})),s++}))},o.prototype.pasteStartingFromFocusedCell=function(e,t,o,r,i){if(r){var n={rowIndex:r.rowIndex,rowPinned:r.rowPinned},a=this.columnModel.getDisplayedColumnsStartingAt(r.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,o,t,i):this.pasteMultipleValues(e,n,o,a,t,"clipboard",i)}},o.prototype.isPasteSingleValueIntoRange=function(e){return this.hasOnlyOneValueToPaste(e)&&null!=this.rangeService&&!this.rangeService.isEmpty()},o.prototype.pasteSingleValueIntoRange=function(e,t,o,r){var i=this,n=e[0][0];this.iterateActiveRanges(!1,(function(e,a,s){t.push(a),s.forEach((function(e){return i.updateCellValue(a,e,n,o,"clipboard",r)}))}))},o.prototype.hasOnlyOneValueToPaste=function(e){return 1===e.length&&1===e[0].length},o.prototype.copyRangeDown=function(){var e=this;if(this.rangeService&&!this.rangeService.isEmpty()){var t=[];this.doPasteOperation((function(o,r,i,n){var a=e.gridOptionsService.getCallback("processCellForClipboard"),s=e.gridOptionsService.getCallback("processCellFromClipboard");e.iterateActiveRanges(!0,(function(i,l,c){t.length?(r.push(l),c.forEach((function(r,a){if(r.isCellEditable(l)&&!r.isSuppressPaste(l)){var c=e.processCell(l,r,t[a],"dragCopy",s);l.setDataValue(r,c,"paste"),n&&n.addParentNode(l.parent,[r]);var p=e.cellPositionUtils.createIdFromValues(i.rowIndex,r,i.rowPinned);o[p]=!0}}))):c.forEach((function(o){var r=e.processCell(l,o,e.valueService.getValue(o,l),"dragCopy",a);t.push(r)}))}))}))}},o.prototype.removeLastLineIfBlank=function(t){var o=e._.last(t);if(o&&1===o.length&&""===o[0]){if(1===t.length)return;e._.removeFromArray(t,o)}},o.prototype.fireRowChanged=function(t){var o=this;"fullRow"===this.gridOptionsService.get("editType")&&t.forEach((function(t){var r={type:e.Events.EVENT_ROW_VALUE_CHANGED,node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned};o.eventService.dispatchEvent(r)}))},o.prototype.pasteMultipleValues=function(e,t,o,r,i,n,a){var s=this,l=t,c=null!=this.clientSideRowModel&&!this.gridOptionsService.isTreeData();e.forEach((function(e){var t=function(){for(;;){if(!l)return null;var e=s.rowPositionUtils.getRowNode(l);if(l=s.cellNavigationService.getRowBelow({rowPinned:l.rowPinned,rowIndex:l.rowIndex}),null==e)return null;if(!(e.detail||e.footer||c&&e.group))return e}}();t&&(e.forEach((function(e,o){return s.updateCellValue(t,r[o],e,i,n,a)})),o.push(t))}))},o.prototype.updateCellValue=function(e,t,o,r,i,n){if(e&&t&&t.isCellEditable(e)&&!t.isSuppressPaste(e)){var a=this.processCell(e,t,o,i,this.gridOptionsService.getCallback("processCellFromClipboard"));e.setDataValue(t,a,"paste"),r[this.cellPositionUtils.createIdFromValues(e.rowIndex,t,e.rowPinned)]=!0,n&&n.addParentNode(e.parent,[t])}},o.prototype.copyToClipboard=function(e){void 0===e&&(e={});var t=e.includeHeaders,o=e.includeGroupHeaders;this.logger.log("copyToClipboard: includeHeaders = "+t),null==t&&(t=this.gridOptionsService.is("copyHeadersToClipboard")),null==o&&(o=this.gridOptionsService.is("copyGroupHeadersToClipboard"));var r={includeHeaders:t,includeGroupHeaders:o},i=!this.gridOptionsService.is("suppressCopyRowsToClipboard");!this.rangeService||this.rangeService.isEmpty()||this.shouldSkipSingleCellRange()?i&&!this.selectionService.isEmpty()?this.copySelectedRowsToClipboard(r):this.focusService.isAnyCellFocused()&&this.copyFocusedCellToClipboard(r):this.copySelectedRangeToClipboard(r)},o.prototype.shouldSkipSingleCellRange=function(){return this.gridOptionsService.is("suppressCopySingleCellRanges")&&!this.rangeService.isMoreThanOneCell()},o.prototype.iterateActiveRanges=function(e,t,o){var r=this;if(this.rangeService&&!this.rangeService.isEmpty()){var i=this.rangeService.getCellRanges();e?this.iterateActiveRange(i[0],t,o,!0):i.forEach((function(e,n){return r.iterateActiveRange(e,t,o,n===i.length-1)}))}},o.prototype.iterateActiveRange=function(e,t,o,r){if(this.rangeService){var i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e);o&&e.columns&&o(e.columns);for(var a=0,s=!1;!s&&null!=i;){var l=this.rowPositionUtils.getRowNode(i);s=this.rowPositionUtils.sameRow(i,n),t(i,l,e.columns,a++,s&&r),i=this.cellNavigationService.getRowBelow(i)}}},o.prototype.copySelectedRangeToClipboard=function(e){if(void 0===e&&(e={}),this.rangeService&&!this.rangeService.isEmpty()){var t=this.rangeService.areAllRangesAbleToMerge()?this.buildDataFromMergedRanges(e):this.buildDataFromRanges(e),o=t.data,r=t.cellsToFlash;this.copyDataToClipboard(o),this.dispatchFlashCells(r)}},o.prototype.buildDataFromMergedRanges=function(e){var t=this,o=new Set,r=this.rangeService.getCellRanges(),i=new Map,n=[],a={};r.forEach((function(e){e.columns.forEach((function(e){return o.add(e)}));var r=t.getRangeRowPositionsAndCellsToFlash(e),s=r.rowPositions,l=r.cellsToFlash;s.forEach((function(e){var t=e.rowIndex+"-"+(e.rowPinned||"null");i.get(t)||(i.set(t,!0),n.push(e))})),Object.assign(a,l)}));var s=this.columnModel.getAllDisplayedColumns(),l=Array.from(o);return l.sort((function(e,t){return s.indexOf(e)-s.indexOf(t)})),{data:this.buildExportParams({columns:l,rowPositions:n,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:a}},o.prototype.buildDataFromRanges=function(e){var t=this,o=this.rangeService.getCellRanges(),r=[],i={};return o.forEach((function(o){var n=t.getRangeRowPositionsAndCellsToFlash(o),a=n.rowPositions,s=n.cellsToFlash;Object.assign(i,s),r.push(t.buildExportParams({columns:o.columns,rowPositions:a,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))})),{data:r.join("\n"),cellsToFlash:i}},o.prototype.getRangeRowPositionsAndCellsToFlash=function(e){for(var t=this,o=[],r={},i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e),a=i;a&&(o.push(a),e.columns.forEach((function(e){var o=t.cellPositionUtils.createIdFromValues(a.rowIndex,e,a.rowPinned);r[o]=!0})),!this.rowPositionUtils.sameRow(a,n));)a=this.cellNavigationService.getRowBelow(a);return{rowPositions:o,cellsToFlash:r}},o.prototype.copyFocusedCellToClipboard=function(e){var t;void 0===e&&(e={});var o=this.focusService.getFocusedCell();if(null!=o){var r=this.cellPositionUtils.createId(o),i={rowPinned:o.rowPinned,rowIndex:o.rowIndex},n=o.column,a=this.buildExportParams({columns:[n],rowPositions:[i],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(a),this.dispatchFlashCells(((t={})[r]=!0,t))}},o.prototype.copySelectedRowsToClipboard=function(e){void 0===e&&(e={});var t=e.columnKeys,o=e.includeHeaders,r=e.includeGroupHeaders,i=this.buildExportParams({columns:t,includeHeaders:o,includeGroupHeaders:r});this.copyDataToClipboard(i)},o.prototype.buildExportParams=function(e){var t=this,o=e.columns,r=e.rowPositions,i=e.includeHeaders,n=void 0!==i&&i,a=e.includeGroupHeaders,s={columnKeys:o,rowPositions:r,skipColumnHeaders:!n,skipColumnGroupHeaders:!(void 0!==a&&a),suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!r,processCellCallback:this.gridOptionsService.getCallback("processCellForClipboard"),processRowGroupCallback:function(e){return t.processRowGroupCallback(e)},processHeaderCallback:this.gridOptionsService.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gridOptionsService.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(s,!0)},o.prototype.processRowGroupCallback=function(e){var t=e.node,o=t.key,r=null!=o?o:"";if(e.node.footer){var i="";o&&o.length&&(i=" "+o),r="Total"+i}var n=this.gridOptionsService.getCallback("processCellForClipboard");if(n){var a=t.rowGroupColumn;return!a&&t.footer&&-1===t.level&&(a=this.columnModel.getRowGroupColumns()[0]),n({value:r,node:t,column:a,type:"clipboard"})}return r},o.prototype.dispatchFlashCells=function(t){var o=this;window.setTimeout((function(){var r={type:e.Events.EVENT_FLASH_CELLS,cells:t};o.eventService.dispatchEvent(r)}),0)},o.prototype.processCell=function(e,t,o,r,i){return i?i({column:t,node:e,value:o,type:r}):o},o.prototype.copyDataToClipboard=function(t){var o=this,r=this.gridOptionsService.getCallback("sendToClipboard");r?r({data:t}):!this.gridOptionsService.is("suppressClipboardApi")&&navigator.clipboard?navigator.clipboard.writeText(t).catch((function(r){e._.doOnce((function(){console.warn(r),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.")}),"clipboardApiError"),o.copyDataToClipboardLegacy(t)})):this.copyDataToClipboardLegacy(t)},o.prototype.copyDataToClipboardLegacy=function(e){var t=this;this.executeOnTempElement((function(o){var r=t.gridOptionsService.getDocument(),i=r.activeElement;o.value=e||" ",o.select(),o.focus({preventScroll:!0}),r.execCommand("copy")||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."),null!=i&&null!=i.focus&&i.focus({preventScroll:!0})}))},o.prototype.executeOnTempElement=function(e,t){var o=this.gridOptionsService.getDocument(),r=o.createElement("textarea");r.style.width="1px",r.style.height="1px",r.style.top=o.documentElement.scrollTop+"px",r.style.left=o.documentElement.scrollLeft+"px",r.style.position="absolute",r.style.opacity="0";var i=this.gridCtrl.getGui();i.appendChild(r);try{e(r)}catch(e){console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout((function(){t(r),i.removeChild(r)}),100):i.removeChild(r)},o.prototype.getRangeSize=function(){var e=this.rangeService.getCellRanges(),t=0,o=0;return e.length>0&&(t=this.rangeService.getRangeStartRow(e[0]).rowIndex,o=this.rangeService.getRangeEndRow(e[0]).rowIndex),t-o+1},n([e.Autowired("csvCreator")],o.prototype,"csvCreator",void 0),n([e.Autowired("loggerFactory")],o.prototype,"loggerFactory",void 0),n([e.Autowired("selectionService")],o.prototype,"selectionService",void 0),n([e.Optional("rangeService")],o.prototype,"rangeService",void 0),n([e.Autowired("rowModel")],o.prototype,"rowModel",void 0),n([e.Autowired("ctrlsService")],o.prototype,"ctrlsService",void 0),n([e.Autowired("valueService")],o.prototype,"valueService",void 0),n([e.Autowired("focusService")],o.prototype,"focusService",void 0),n([e.Autowired("rowRenderer")],o.prototype,"rowRenderer",void 0),n([e.Autowired("columnModel")],o.prototype,"columnModel",void 0),n([e.Autowired("cellNavigationService")],o.prototype,"cellNavigationService",void 0),n([e.Autowired("cellPositionUtils")],o.prototype,"cellPositionUtils",void 0),n([e.Autowired("rowPositionUtils")],o.prototype,"rowPositionUtils",void 0),n([e.PostConstruct],o.prototype,"init",null),o=n([e.Bean("clipboardService")],o)}(e.BeanStub),s={version:"29.0.0",moduleName:e.ModuleNames.ClipboardModule,beans:[a],dependantModules:[t.EnterpriseCoreModule,o.CsvExportModule]};exports.ClipboardModule=s; |
@@ -25,2 +25,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core"; | ||
private refocusLastFocusedCell; | ||
private getClipboardDelimiter; | ||
private processClipboardData; | ||
@@ -49,2 +50,3 @@ private doPasteOperation; | ||
private buildExportParams; | ||
private processRowGroupCallback; | ||
private dispatchFlashCells; | ||
@@ -51,0 +53,0 @@ private processCell; |
@@ -5,3 +5,3 @@ var __extends = (this && this.__extends) || (function () { | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -21,3 +21,8 @@ }; | ||
}; | ||
import { _, Autowired, Bean, BeanStub, ChangedPath, Constants, Events, PostConstruct, Optional, } from "@ag-grid-community/core"; | ||
import { _, Autowired, Bean, BeanStub, ChangedPath, Events, PostConstruct, Optional, } from "@ag-grid-community/core"; | ||
import { stringToArray } from "./csv"; | ||
// Matches value in changeDetectionService | ||
var SOURCE_PASTE = 'paste'; | ||
var EXPORT_TYPE_DRAG_COPY = 'dragCopy'; | ||
var EXPORT_TYPE_CLIPBOARD = 'clipboard'; | ||
var ClipboardService = /** @class */ (function (_super) { | ||
@@ -34,3 +39,3 @@ __extends(ClipboardService, _super); | ||
this.logger = this.loggerFactory.create('ClipboardService'); | ||
if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) { | ||
if (this.rowModel.getType() === 'clientSide') { | ||
this.clientSideRowModel = this.rowModel; | ||
@@ -46,3 +51,3 @@ } | ||
// Method 1 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
// Some browsers (Firefox) do not allow Web Applications to read from | ||
@@ -108,2 +113,6 @@ // the clipboard so verify if not only the ClipboardAPI is available, | ||
}; | ||
ClipboardService.prototype.getClipboardDelimiter = function () { | ||
var delimiter = this.gridOptionsService.get('clipboardDelimiter'); | ||
return _.exists(delimiter) ? delimiter : '\t'; | ||
}; | ||
ClipboardService.prototype.processClipboardData = function (data) { | ||
@@ -114,4 +123,4 @@ var _this = this; | ||
} | ||
var parsedData = _.stringToArray(data, this.gridOptionsWrapper.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsWrapper.getProcessDataFromClipboardFunc(); | ||
var parsedData = stringToArray(data, this.getClipboardDelimiter()); | ||
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard'); | ||
if (userFunc) { | ||
@@ -123,3 +132,3 @@ parsedData = userFunc({ data: parsedData }); | ||
} | ||
if (this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()) { | ||
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) { | ||
this.removeLastLineIfBlank(parsedData); | ||
@@ -141,4 +150,4 @@ } | ||
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) { | ||
var api = this.gridOptionsWrapper.getApi(); | ||
var columnApi = this.gridOptionsWrapper.getColumnApi(); | ||
var api = this.gridOptionsService.get('api'); | ||
var columnApi = this.gridOptionsService.get('columnApi'); | ||
var source = 'clipboard'; | ||
@@ -153,3 +162,3 @@ this.eventService.dispatchEvent({ | ||
if (this.clientSideRowModel) { | ||
var onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns(); | ||
var onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns'); | ||
changedPath = new ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode()); | ||
@@ -196,3 +205,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
columns.forEach(function (column, idx) { | ||
@@ -206,4 +215,4 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) { | ||
} | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, Constants.SOURCE_PASTE); | ||
var newValue = _this.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -229,3 +238,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
else { | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
} | ||
@@ -245,3 +254,3 @@ }; | ||
columns.forEach(function (column) { | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
return _this.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
}); | ||
@@ -261,4 +270,4 @@ }; | ||
var pasteOperation = function (cellsToFlash, updatedRowNodes, focusedCell, changedPath) { | ||
var processCellForClipboardFunc = _this.gridOptionsWrapper.getProcessCellForClipboardFunc(); | ||
var processCellFromClipboardFunc = _this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
var processCellForClipboardFunc = _this.gridOptionsService.getCallback('processCellForClipboard'); | ||
var processCellFromClipboardFunc = _this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
var rowCallback = function (currentRow, rowNode, columns) { | ||
@@ -270,3 +279,3 @@ // take reference of first row, this is the one we will be using to copy from | ||
// get the initial values to copy down | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), Constants.EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
var value = _this.processCell(rowNode, column, _this.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
firstRowValues.push(value); | ||
@@ -282,4 +291,4 @@ }); | ||
} | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, Constants.SOURCE_PASTE); | ||
var firstRowValue = _this.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -311,3 +320,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
var _this = this; | ||
if (!this.gridOptionsWrapper.isFullRowEdit()) { | ||
if (this.gridOptionsService.get('editType') !== 'fullRow') { | ||
return; | ||
@@ -331,3 +340,3 @@ } | ||
// so we should skip them when doing paste operations. | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsWrapper.isTreeData(); | ||
var skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData(); | ||
var getNextGoodRowNode = function () { | ||
@@ -372,4 +381,4 @@ while (true) { | ||
} | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsWrapper.getProcessCellFromClipboardFunc()); | ||
rowNode.setDataValue(column, processedValue, Constants.SOURCE_PASTE); | ||
var processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard')); | ||
rowNode.setDataValue(column, processedValue, SOURCE_PASTE); | ||
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned); | ||
@@ -387,9 +396,9 @@ cellsToFlash[cellId] = true; | ||
if (includeHeaders == null) { | ||
includeHeaders = this.gridOptionsWrapper.isCopyHeadersToClipboard(); | ||
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard'); | ||
} | ||
if (includeGroupHeaders == null) { | ||
includeGroupHeaders = this.gridOptionsWrapper.isCopyGroupHeadersToClipboard(); | ||
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard'); | ||
} | ||
var copyParams = { includeHeaders: includeHeaders, includeGroupHeaders: includeGroupHeaders }; | ||
var shouldCopyRows = !this.gridOptionsWrapper.isSuppressCopyRowsToClipboard(); | ||
var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard'); | ||
// Copy priority is Range > Row > Focus | ||
@@ -407,3 +416,3 @@ if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) { | ||
ClipboardService.prototype.shouldSkipSingleCellRange = function () { | ||
return this.gridOptionsWrapper.isSuppressCopySingleCellRanges() && !this.rangeService.isMoreThanOneCell(); | ||
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell(); | ||
}; | ||
@@ -554,2 +563,3 @@ ClipboardService.prototype.iterateActiveRanges = function (onlyFirst, rowCallback, columnCallback) { | ||
ClipboardService.prototype.buildExportParams = function (params) { | ||
var _this = this; | ||
var columns = params.columns, rowPositions = params.rowPositions, _a = params.includeHeaders, includeHeaders = _a === void 0 ? false : _a, _b = params.includeGroupHeaders, includeGroupHeaders = _b === void 0 ? false : _b; | ||
@@ -562,11 +572,37 @@ var exportParams = { | ||
suppressQuotes: true, | ||
columnSeparator: this.gridOptionsWrapper.getClipboardDelimiter(), | ||
columnSeparator: this.getClipboardDelimiter(), | ||
onlySelected: !rowPositions, | ||
processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc(), | ||
processRowGroupCallback: function (params) { return params.node.key; }, | ||
processHeaderCallback: this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(), | ||
processGroupHeaderCallback: this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc() | ||
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'), | ||
processRowGroupCallback: function (params) { return _this.processRowGroupCallback(params); }, | ||
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'), | ||
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard') | ||
}; | ||
return this.csvCreator.getDataAsCsv(exportParams, true); | ||
}; | ||
ClipboardService.prototype.processRowGroupCallback = function (params) { | ||
var node = params.node; | ||
var key = node.key; | ||
var value = key != null ? key : ''; | ||
if (params.node.footer) { | ||
var suffix = ''; | ||
if (key && key.length) { | ||
suffix = " " + key; | ||
} | ||
value = "Total" + suffix; | ||
} | ||
var processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
if (processCellForClipboard) { | ||
var column = node.rowGroupColumn; | ||
if (!column && node.footer && node.level === -1) { | ||
column = this.columnModel.getRowGroupColumns()[0]; | ||
} | ||
return processCellForClipboard({ | ||
value: value, | ||
node: node, | ||
column: column, | ||
type: 'clipboard' | ||
}); | ||
} | ||
return value; | ||
}; | ||
ClipboardService.prototype.dispatchFlashCells = function (cellsToFlash) { | ||
@@ -596,3 +632,3 @@ var _this = this; | ||
var _this = this; | ||
var userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc(); | ||
var userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard'); | ||
// method 1 - user provided func | ||
@@ -604,3 +640,3 @@ if (userProvidedFunc) { | ||
// method 2 - native clipboard API, available in modern chrome browsers | ||
var allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
var allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
if (allowNavigator && navigator.clipboard) { | ||
@@ -626,3 +662,3 @@ navigator.clipboard.writeText(data).catch(function (e) { | ||
this.executeOnTempElement(function (element) { | ||
var eDocument = _this.gridOptionsWrapper.getDocument(); | ||
var eDocument = _this.gridOptionsService.getDocument(); | ||
var focusedElementBefore = eDocument.activeElement; | ||
@@ -644,3 +680,3 @@ element.value = data || ' '; // has to be non-empty value or execCommand will not do anything | ||
ClipboardService.prototype.executeOnTempElement = function (callbackNow, callbackAfter) { | ||
var eDoc = this.gridOptionsWrapper.getDocument(); | ||
var eDoc = this.gridOptionsService.getDocument(); | ||
var eTempInput = eDoc.createElement('textarea'); | ||
@@ -647,0 +683,0 @@ eTempInput.style.width = '1px'; |
@@ -5,3 +5,5 @@ import { ModuleNames } from "@ag-grid-community/core"; | ||
import { ClipboardService } from "./clipboard/clipboardService"; | ||
import { VERSION } from "./version"; | ||
export var ClipboardModule = { | ||
version: VERSION, | ||
moduleName: ModuleNames.ClipboardModule, | ||
@@ -8,0 +10,0 @@ beans: [ClipboardService], |
@@ -25,2 +25,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core"; | ||
private refocusLastFocusedCell; | ||
private getClipboardDelimiter; | ||
private processClipboardData; | ||
@@ -49,2 +50,3 @@ private doPasteOperation; | ||
private buildExportParams; | ||
private processRowGroupCallback; | ||
private dispatchFlashCells; | ||
@@ -51,0 +53,0 @@ private processCell; |
@@ -7,3 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
}; | ||
import { _, Autowired, Bean, BeanStub, ChangedPath, Constants, Events, PostConstruct, Optional, } from "@ag-grid-community/core"; | ||
import { _, Autowired, Bean, BeanStub, ChangedPath, Events, PostConstruct, Optional, } from "@ag-grid-community/core"; | ||
import { stringToArray } from "./csv"; | ||
// Matches value in changeDetectionService | ||
const SOURCE_PASTE = 'paste'; | ||
const EXPORT_TYPE_DRAG_COPY = 'dragCopy'; | ||
const EXPORT_TYPE_CLIPBOARD = 'clipboard'; | ||
let ClipboardService = class ClipboardService extends BeanStub { | ||
@@ -17,3 +22,3 @@ constructor() { | ||
this.logger = this.loggerFactory.create('ClipboardService'); | ||
if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) { | ||
if (this.rowModel.getType() === 'clientSide') { | ||
this.clientSideRowModel = this.rowModel; | ||
@@ -28,3 +33,3 @@ } | ||
// Method 1 - native clipboard API, available in modern chrome browsers | ||
const allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
const allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
// Some browsers (Firefox) do not allow Web Applications to read from | ||
@@ -89,2 +94,6 @@ // the clipboard so verify if not only the ClipboardAPI is available, | ||
} | ||
getClipboardDelimiter() { | ||
const delimiter = this.gridOptionsService.get('clipboardDelimiter'); | ||
return _.exists(delimiter) ? delimiter : '\t'; | ||
} | ||
processClipboardData(data) { | ||
@@ -94,4 +103,4 @@ if (data == null) { | ||
} | ||
let parsedData = _.stringToArray(data, this.gridOptionsWrapper.getClipboardDelimiter()); | ||
const userFunc = this.gridOptionsWrapper.getProcessDataFromClipboardFunc(); | ||
let parsedData = stringToArray(data, this.getClipboardDelimiter()); | ||
const userFunc = this.gridOptionsService.getCallback('processDataFromClipboard'); | ||
if (userFunc) { | ||
@@ -103,3 +112,3 @@ parsedData = userFunc({ data: parsedData }); | ||
} | ||
if (this.gridOptionsWrapper.isSuppressLastEmptyLineOnPaste()) { | ||
if (this.gridOptionsService.is('suppressLastEmptyLineOnPaste')) { | ||
this.removeLastLineIfBlank(parsedData); | ||
@@ -121,4 +130,4 @@ } | ||
doPasteOperation(pasteOperationFunc) { | ||
const api = this.gridOptionsWrapper.getApi(); | ||
const columnApi = this.gridOptionsWrapper.getColumnApi(); | ||
const api = this.gridOptionsService.get('api'); | ||
const columnApi = this.gridOptionsService.get('columnApi'); | ||
const source = 'clipboard'; | ||
@@ -133,3 +142,3 @@ this.eventService.dispatchEvent({ | ||
if (this.clientSideRowModel) { | ||
const onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns(); | ||
const onlyChangedColumns = this.gridOptionsService.is('aggregateOnlyChangedColumns'); | ||
changedPath = new ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode()); | ||
@@ -175,3 +184,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
const processCellFromClipboardFunc = this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
const processCellFromClipboardFunc = this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
columns.forEach((column, idx) => { | ||
@@ -185,4 +194,4 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) { | ||
} | ||
const newValue = this.processCell(rowNode, column, currentRowData[idx], Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, Constants.SOURCE_PASTE); | ||
const newValue = this.processCell(rowNode, column, currentRowData[idx], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, newValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -208,3 +217,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
else { | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, Constants.EXPORT_TYPE_CLIPBOARD, changedPath); | ||
this.pasteMultipleValues(parsedData, currentRow, updatedRowNodes, columnsToPasteInto, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath); | ||
} | ||
@@ -222,3 +231,3 @@ } | ||
updatedRowNodes.push(rowNode); | ||
columns.forEach(column => this.updateCellValue(rowNode, column, value, cellsToFlash, Constants.EXPORT_TYPE_CLIPBOARD, changedPath)); | ||
columns.forEach(column => this.updateCellValue(rowNode, column, value, cellsToFlash, EXPORT_TYPE_CLIPBOARD, changedPath)); | ||
}; | ||
@@ -236,4 +245,4 @@ this.iterateActiveRanges(false, rowCallback); | ||
const pasteOperation = (cellsToFlash, updatedRowNodes, focusedCell, changedPath) => { | ||
const processCellForClipboardFunc = this.gridOptionsWrapper.getProcessCellForClipboardFunc(); | ||
const processCellFromClipboardFunc = this.gridOptionsWrapper.getProcessCellFromClipboardFunc(); | ||
const processCellForClipboardFunc = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
const processCellFromClipboardFunc = this.gridOptionsService.getCallback('processCellFromClipboard'); | ||
const rowCallback = (currentRow, rowNode, columns) => { | ||
@@ -245,3 +254,3 @@ // take reference of first row, this is the one we will be using to copy from | ||
// get the initial values to copy down | ||
const value = this.processCell(rowNode, column, this.valueService.getValue(column, rowNode), Constants.EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
const value = this.processCell(rowNode, column, this.valueService.getValue(column, rowNode), EXPORT_TYPE_DRAG_COPY, processCellForClipboardFunc); | ||
firstRowValues.push(value); | ||
@@ -257,4 +266,4 @@ }); | ||
} | ||
const firstRowValue = this.processCell(rowNode, column, firstRowValues[index], Constants.EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, Constants.SOURCE_PASTE); | ||
const firstRowValue = this.processCell(rowNode, column, firstRowValues[index], EXPORT_TYPE_DRAG_COPY, processCellFromClipboardFunc); | ||
rowNode.setDataValue(column, firstRowValue, SOURCE_PASTE); | ||
if (changedPath) { | ||
@@ -285,3 +294,3 @@ changedPath.addParentNode(rowNode.parent, [column]); | ||
fireRowChanged(rowNodes) { | ||
if (!this.gridOptionsWrapper.isFullRowEdit()) { | ||
if (this.gridOptionsService.get('editType') !== 'fullRow') { | ||
return; | ||
@@ -304,3 +313,3 @@ } | ||
// so we should skip them when doing paste operations. | ||
const skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsWrapper.isTreeData(); | ||
const skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.isTreeData(); | ||
const getNextGoodRowNode = () => { | ||
@@ -343,4 +352,4 @@ while (true) { | ||
} | ||
const processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsWrapper.getProcessCellFromClipboardFunc()); | ||
rowNode.setDataValue(column, processedValue, Constants.SOURCE_PASTE); | ||
const processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback('processCellFromClipboard')); | ||
rowNode.setDataValue(column, processedValue, SOURCE_PASTE); | ||
const cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned); | ||
@@ -357,9 +366,9 @@ cellsToFlash[cellId] = true; | ||
if (includeHeaders == null) { | ||
includeHeaders = this.gridOptionsWrapper.isCopyHeadersToClipboard(); | ||
includeHeaders = this.gridOptionsService.is('copyHeadersToClipboard'); | ||
} | ||
if (includeGroupHeaders == null) { | ||
includeGroupHeaders = this.gridOptionsWrapper.isCopyGroupHeadersToClipboard(); | ||
includeGroupHeaders = this.gridOptionsService.is('copyGroupHeadersToClipboard'); | ||
} | ||
const copyParams = { includeHeaders, includeGroupHeaders }; | ||
const shouldCopyRows = !this.gridOptionsWrapper.isSuppressCopyRowsToClipboard(); | ||
const shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard'); | ||
// Copy priority is Range > Row > Focus | ||
@@ -377,3 +386,3 @@ if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) { | ||
shouldSkipSingleCellRange() { | ||
return this.gridOptionsWrapper.isSuppressCopySingleCellRanges() && !this.rangeService.isMoreThanOneCell(); | ||
return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell(); | ||
} | ||
@@ -523,11 +532,37 @@ iterateActiveRanges(onlyFirst, rowCallback, columnCallback) { | ||
suppressQuotes: true, | ||
columnSeparator: this.gridOptionsWrapper.getClipboardDelimiter(), | ||
columnSeparator: this.getClipboardDelimiter(), | ||
onlySelected: !rowPositions, | ||
processCellCallback: this.gridOptionsWrapper.getProcessCellForClipboardFunc(), | ||
processRowGroupCallback: (params) => params.node.key, | ||
processHeaderCallback: this.gridOptionsWrapper.getProcessHeaderForClipboardFunc(), | ||
processGroupHeaderCallback: this.gridOptionsWrapper.getProcessGroupHeaderForClipboardFunc() | ||
processCellCallback: this.gridOptionsService.getCallback('processCellForClipboard'), | ||
processRowGroupCallback: (params) => this.processRowGroupCallback(params), | ||
processHeaderCallback: this.gridOptionsService.getCallback('processHeaderForClipboard'), | ||
processGroupHeaderCallback: this.gridOptionsService.getCallback('processGroupHeaderForClipboard') | ||
}; | ||
return this.csvCreator.getDataAsCsv(exportParams, true); | ||
} | ||
processRowGroupCallback(params) { | ||
const { node } = params; | ||
const { key } = node; | ||
let value = key != null ? key : ''; | ||
if (params.node.footer) { | ||
let suffix = ''; | ||
if (key && key.length) { | ||
suffix = ` ${key}`; | ||
} | ||
value = `Total${suffix}`; | ||
} | ||
const processCellForClipboard = this.gridOptionsService.getCallback('processCellForClipboard'); | ||
if (processCellForClipboard) { | ||
let column = node.rowGroupColumn; | ||
if (!column && node.footer && node.level === -1) { | ||
column = this.columnModel.getRowGroupColumns()[0]; | ||
} | ||
return processCellForClipboard({ | ||
value, | ||
node, | ||
column, | ||
type: 'clipboard' | ||
}); | ||
} | ||
return value; | ||
} | ||
dispatchFlashCells(cellsToFlash) { | ||
@@ -555,3 +590,3 @@ window.setTimeout(() => { | ||
copyDataToClipboard(data) { | ||
const userProvidedFunc = this.gridOptionsWrapper.getSendToClipboardFunc(); | ||
const userProvidedFunc = this.gridOptionsService.getCallback('sendToClipboard'); | ||
// method 1 - user provided func | ||
@@ -563,3 +598,3 @@ if (userProvidedFunc) { | ||
// method 2 - native clipboard API, available in modern chrome browsers | ||
const allowNavigator = !this.gridOptionsWrapper.isSuppressClipboardApi(); | ||
const allowNavigator = !this.gridOptionsService.is('suppressClipboardApi'); | ||
if (allowNavigator && navigator.clipboard) { | ||
@@ -584,3 +619,3 @@ navigator.clipboard.writeText(data).catch((e) => { | ||
this.executeOnTempElement(element => { | ||
const eDocument = this.gridOptionsWrapper.getDocument(); | ||
const eDocument = this.gridOptionsService.getDocument(); | ||
const focusedElementBefore = eDocument.activeElement; | ||
@@ -602,3 +637,3 @@ element.value = data || ' '; // has to be non-empty value or execCommand will not do anything | ||
executeOnTempElement(callbackNow, callbackAfter) { | ||
const eDoc = this.gridOptionsWrapper.getDocument(); | ||
const eDoc = this.gridOptionsService.getDocument(); | ||
const eTempInput = eDoc.createElement('textarea'); | ||
@@ -605,0 +640,0 @@ eTempInput.style.width = '1px'; |
@@ -5,3 +5,5 @@ import { ModuleNames } from "@ag-grid-community/core"; | ||
import { ClipboardService } from "./clipboard/clipboardService"; | ||
import { VERSION } from "./version"; | ||
export const ClipboardModule = { | ||
version: VERSION, | ||
moduleName: ModuleNames.ClipboardModule, | ||
@@ -8,0 +10,0 @@ beans: [ClipboardService], |
{ | ||
"name": "@ag-grid-enterprise/clipboard", | ||
"version": "28.2.1", | ||
"version": "29.0.0", | ||
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue", | ||
@@ -51,5 +51,5 @@ "main": "./dist/cjs/es5/main.js", | ||
"dependencies": { | ||
"@ag-grid-community/core": "~28.2.1", | ||
"@ag-grid-community/csv-export": "~28.2.1", | ||
"@ag-grid-enterprise/core": "~28.2.1" | ||
"@ag-grid-community/core": "~29.0.0", | ||
"@ag-grid-community/csv-export": "~29.0.0", | ||
"@ag-grid-enterprise/core": "~29.0.0" | ||
}, | ||
@@ -62,3 +62,3 @@ "devDependencies": { | ||
"ts-jest": "^25.4.0", | ||
"typescript": "~3.7.7", | ||
"typescript": "~4.0.8", | ||
"rimraf": "3.0.2" | ||
@@ -65,0 +65,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57
3613915
57204
+ Added@ag-grid-community/core@29.0.0(transitive)
+ Added@ag-grid-community/csv-export@29.0.0(transitive)
+ Added@ag-grid-enterprise/core@29.0.0(transitive)
- Removed@ag-grid-community/core@28.2.1(transitive)
- Removed@ag-grid-community/csv-export@28.2.1(transitive)
- Removed@ag-grid-enterprise/core@28.2.1(transitive)