Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ag-grid-enterprise/clipboard

Package Overview
Dependencies
Maintainers
0
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag-grid-enterprise/clipboard - npm Package Compare versions

Comparing version 32.1.0 to 32.2.0

48

dist/package/main.cjs.js

@@ -80,6 +80,6 @@ var __defProp = Object.defineProperty;

postConstruct() {
if (this.rowModel.getType() === "clientSide") {
if ((0, import_core._isClientSideRowModel)(this.gos)) {
this.clientSideRowModel = this.rowModel;
}
this.ctrlsService.whenReady((p) => {
this.ctrlsService.whenReady(this, (p) => {
this.gridCtrl = p.gridCtrl;

@@ -452,5 +452,2 @@ });

}
if (rowNode.group && column.isValueActive()) {
return;
}
const processedValue = this.processCell(

@@ -498,8 +495,8 @@ rowNode,

const copyParams = { includeHeaders, includeGroupHeaders };
const shouldCopyRows = !this.gos.get("suppressCopyRowsToClipboard");
const selection = this.gos.get("selection");
let cellClearType = null;
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange(this.rangeService)) {
if (this.shouldCopyCells(selection)) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = 0 /* CellRange */;
} else if (shouldCopyRows && !this.selectionService.isEmpty()) {
} else if (this.shouldCopyRows(selection)) {
this.copySelectedRowsToClipboard(copyParams);

@@ -515,2 +512,24 @@ cellClearType = 1 /* SelectedRows */;

}
shouldCopyCells(selection) {
if (!this.rangeService || this.rangeService.isEmpty()) {
return false;
}
if (selection) {
return selection.mode === "cell";
} else {
const suppressCopySingleCellRanges = this.gos.get("suppressCopySingleCellRanges");
const shouldSkip = !this.rangeService.isMoreThanOneCell() && suppressCopySingleCellRanges;
return !shouldSkip;
}
}
shouldCopyRows(selection) {
if (this.selectionService.isEmpty()) {
return false;
}
if (selection) {
return selection.mode !== "cell" && (selection.copySelectedRows ?? false);
} else {
return !this.gos.get("suppressCopyRowsToClipboard");
}
}
clearCellsAfterCopy(type) {

@@ -547,8 +566,5 @@ this.eventService.dispatchEvent({ type: "keyShortcutChangedCellStart" });

}
const emptyValue = this.valueService.parseValue(column, rowNode, "", rowNode.getValueFromValueService(column)) ?? null;
const emptyValue = this.valueService.getDeleteValue(column, rowNode);
rowNode.setDataValue(column, emptyValue, "clipboardService");
}
shouldSkipSingleCellRange(rangeService) {
return this.gos.get("suppressCopySingleCellRanges") && !rangeService.isMoreThanOneCell();
}
iterateActiveRanges(onlyFirst, rowCallback, columnCallback) {

@@ -823,4 +839,4 @@ if (!this.rangeService || this.rangeService.isEmpty()) {

this.executeOnTempElement((element) => {
const eDocument = this.gos.getDocument();
const focusedElementBefore = this.gos.getActiveDomElement();
const eDocument = (0, import_core._getDocument)(this.gos);
const focusedElementBefore = (0, import_core._getActiveDomElement)(this.gos);
element.value = data || " ";

@@ -841,3 +857,3 @@ element.select();

executeOnTempElement(callbackNow, callbackAfter) {
const eDoc = this.gos.getDocument();
const eDoc = (0, import_core._getDocument)(this.gos);
const eTempInput = eDoc.createElement("textarea");

@@ -879,3 +895,3 @@ eTempInput.style.width = "1px";

// enterprise-modules/clipboard/src/version.ts
var VERSION = "32.1.0";
var VERSION = "32.2.0";

@@ -882,0 +898,0 @@ // enterprise-modules/clipboard/src/clipboardModule.ts

@@ -1,6 +0,6 @@

var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(p,e)=>{for(var t in e)__defProp(p,t,{get:e[t],enumerable:!0})},__copyProps=(p,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of __getOwnPropNames(e))!__hasOwnProp.call(p,o)&&o!==t&&__defProp(p,o,{get:()=>e[o],enumerable:!(s=__getOwnPropDesc(e,o))||s.enumerable});return p},__toCommonJS=p=>__copyProps(__defProp({},"__esModule",{value:!0}),p),main_exports={};__export(main_exports,{ClipboardModule:()=>ClipboardModule}),module.exports=__toCommonJS(main_exports);var import_core2=require("@ag-grid-community/core"),import_csv_export=require("@ag-grid-community/csv-export"),import_core3=require("@ag-grid-enterprise/core");function copyToClipboard(p,e){p.clipboardService?.copyToClipboard(e)}function cutToClipboard(p,e){p.clipboardService?.cutToClipboard(e)}function copySelectedRowsToClipboard(p,e){p.clipboardService?.copySelectedRowsToClipboard(e)}function copySelectedRangeToClipboard(p,e){p.clipboardService?.copySelectedRangeToClipboard(e)}function copySelectedRangeDown(p){p.clipboardService?.copyRangeDown()}function pasteFromClipboard(p){p.clipboardService?.pasteFromClipboard()}var import_core=require("@ag-grid-community/core"),SOURCE_PASTE="paste",EXPORT_TYPE_DRAG_COPY="dragCopy",EXPORT_TYPE_CLIPBOARD="clipboard",apiError=p=>`AG Grid: Unable to use the Clipboard API (navigator.clipboard.${p}()). 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.`,ClipboardService=class S extends import_core.BeanStub{constructor(){super(...arguments),this.beanName="clipboardService",this.lastPasteOperationTime=0,this.navigatorApiFailed=!1}wireBeans(e){this.csvCreator=e.csvCreator,this.selectionService=e.selectionService,this.rowModel=e.rowModel,this.ctrlsService=e.ctrlsService,this.valueService=e.valueService,this.focusService=e.focusService,this.rowRenderer=e.rowRenderer,this.visibleColsService=e.visibleColsService,this.funcColsService=e.funcColsService,this.cellNavigationService=e.cellNavigationService,this.cellPositionUtils=e.cellPositionUtils,this.rowPositionUtils=e.rowPositionUtils,this.rangeService=e.rangeService}postConstruct(){this.rowModel.getType()==="clientSide"&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady(e=>{this.gridCtrl=e.gridCtrl})}pasteFromClipboard(){!this.gos.get("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch(t=>{(0,import_core._warnOnce)(`${t}
var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(d,e)=>{for(var t in e)__defProp(d,t,{get:e[t],enumerable:!0})},__copyProps=(d,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of __getOwnPropNames(e))!__hasOwnProp.call(d,o)&&o!==t&&__defProp(d,o,{get:()=>e[o],enumerable:!(s=__getOwnPropDesc(e,o))||s.enumerable});return d},__toCommonJS=d=>__copyProps(__defProp({},"__esModule",{value:!0}),d),main_exports={};__export(main_exports,{ClipboardModule:()=>ClipboardModule}),module.exports=__toCommonJS(main_exports);var import_core2=require("@ag-grid-community/core"),import_csv_export=require("@ag-grid-community/csv-export"),import_core3=require("@ag-grid-enterprise/core");function copyToClipboard(d,e){d.clipboardService?.copyToClipboard(e)}function cutToClipboard(d,e){d.clipboardService?.cutToClipboard(e)}function copySelectedRowsToClipboard(d,e){d.clipboardService?.copySelectedRowsToClipboard(e)}function copySelectedRangeToClipboard(d,e){d.clipboardService?.copySelectedRangeToClipboard(e)}function copySelectedRangeDown(d){d.clipboardService?.copyRangeDown()}function pasteFromClipboard(d){d.clipboardService?.pasteFromClipboard()}var import_core=require("@ag-grid-community/core"),SOURCE_PASTE="paste",EXPORT_TYPE_DRAG_COPY="dragCopy",EXPORT_TYPE_CLIPBOARD="clipboard",apiError=d=>`AG Grid: Unable to use the Clipboard API (navigator.clipboard.${d}()). 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.`,ClipboardService=class S extends import_core.BeanStub{constructor(){super(...arguments),this.beanName="clipboardService",this.lastPasteOperationTime=0,this.navigatorApiFailed=!1}wireBeans(e){this.csvCreator=e.csvCreator,this.selectionService=e.selectionService,this.rowModel=e.rowModel,this.ctrlsService=e.ctrlsService,this.valueService=e.valueService,this.focusService=e.focusService,this.rowRenderer=e.rowRenderer,this.visibleColsService=e.visibleColsService,this.funcColsService=e.funcColsService,this.cellNavigationService=e.cellNavigationService,this.cellPositionUtils=e.cellPositionUtils,this.rowPositionUtils=e.rowPositionUtils,this.rangeService=e.rangeService}postConstruct(){(0,import_core._isClientSideRowModel)(this.gos)&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady(this,e=>{this.gridCtrl=e.gridCtrl})}pasteFromClipboard(){!this.gos.get("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch(t=>{(0,import_core._warnOnce)(`${t}
${apiError("readText")}`),this.navigatorApiFailed=!0,this.pasteFromClipboardLegacy()}):this.pasteFromClipboardLegacy()}pasteFromClipboardLegacy(){let e=!1;const t=s=>{const o=new Date().getTime();o-this.lastPasteOperationTime<50&&(e=!0,s.preventDefault()),this.lastPasteOperationTime=o};this.executeOnTempElement(s=>{s.addEventListener("paste",t),s.focus({preventScroll:!0})},s=>{const o=s.value;e?this.refocusLastFocusedCell():this.processClipboardData(o),s.removeEventListener("paste",t)})}refocusLastFocusedCell(){const e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})}getClipboardDelimiter(){const e=this.gos.get("clipboardDelimiter");return(0,import_core._exists)(e)?e:" "}processClipboardData(e){if(e==null)return;let t=S.stringToArray(e,this.getClipboardDelimiter());const s=this.gos.getCallback("processDataFromClipboard");if(s&&(t=s({data:t})),t==null)return;this.gos.get("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(t);const o=(i,l,r,a)=>{this.rangeService?.isMoreThanOneCell()&&!this.hasOnlyOneValueToPaste(t)?this.pasteIntoActiveRange(this.rangeService,t,i,l,a):this.pasteStartingFromFocusedCell(t,i,l,r,a)};this.doPasteOperation(o)}static stringToArray(e,t=","){const s=[],o=l=>l==="\r"||l===`
`;let i=!1;if(e==="")return[[""]];for(let l=0,r=0,a=0;a<e.length;a++){const n=e[a-1],u=e[a],c=e[a+1],h=()=>{s[l]||(s[l]=[]),s[l][r]||(s[l][r]="")};if(h(),u==='"'&&(i?c==='"'?(s[l][r]+='"',a++):i=!1:(n===void 0||n===t||o(n))&&(i=!0)),!i&&u!=='"'){if(u===t){r++,h();continue}else if(o(u)){r=0,l++,h(),u==="\r"&&c===`
`&&a++;continue}}s[l][r]+=u}return s}doPasteOperation(e){const t="clipboard";this.eventService.dispatchEvent({type:"pasteStart",source:t});let s;if(this.clientSideRowModel){const a=this.gos.get("aggregateOnlyChangedColumns");s=new import_core.ChangedPath(a,this.clientSideRowModel.getRootNode())}const o={},i=[],l=this.focusService.getFocusedCell();e(o,i,l,s);const r=[...i];s&&(this.clientSideRowModel.doAggregate(s),s.forEachChangedNodeDepthFirst(a=>{r.push(a)})),this.rowRenderer.refreshCells({rowNodes:r}),this.dispatchFlashCells(o),this.fireRowChanged(i),this.refocusLastFocusedCell(),this.eventService.dispatchEvent({type:"pasteEnd",source:t})}pasteIntoActiveRange(e,t,s,o,i){const l=this.getRangeSize(e)%t.length!=0;let r=0,a=0;const n=(u,c,h,d)=>{if(d-r>=t.length){if(l)return;r+=a,a=0}const C=t[d-r];o.push(c);const w=this.gos.getCallback("processCellFromClipboard");h.forEach((v,f)=>{if(!v.isCellEditable(c)||v.isSuppressPaste(c))return;f>=C.length&&(f=f%C.length);const b=this.processCell(c,v,C[f],EXPORT_TYPE_DRAG_COPY,w,!0);c.setDataValue(v,b,SOURCE_PASTE),i&&i.addParentNode(c.parent,[v]);const{rowIndex:m,rowPinned:R}=u,y=this.cellPositionUtils.createIdFromValues({rowIndex:m,column:v,rowPinned:R});s[y]=!0}),a++};this.iterateActiveRanges(!1,n)}getDisplayedColumnsStartingAt(e){let t=e;const s=[];for(;t!=null;)s.push(t),t=this.visibleColsService.getColAfter(t);return s}pasteStartingFromFocusedCell(e,t,s,o,i){if(!o)return;const l={rowIndex:o.rowIndex,rowPinned:o.rowPinned},r=this.getDisplayedColumnsStartingAt(o.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,s,t,i):this.pasteMultipleValues(e,l,s,r,t,EXPORT_TYPE_CLIPBOARD,i)}isPasteSingleValueIntoRange(e){return this.hasOnlyOneValueToPaste(e)&&this.rangeService!=null&&!this.rangeService.isEmpty()}pasteSingleValueIntoRange(e,t,s,o){const i=e[0][0],l=(r,a,n)=>{t.push(a),n.forEach(u=>this.updateCellValue(a,u,i,s,EXPORT_TYPE_CLIPBOARD,o))};this.iterateActiveRanges(!1,l)}hasOnlyOneValueToPaste(e){return e.length===1&&e[0].length===1}copyRangeDown(){if(!this.rangeService||this.rangeService.isEmpty())return;const e=[],t=(s,o,i,l)=>{const r=this.gos.getCallback("processCellForClipboard"),a=this.gos.getCallback("processCellFromClipboard"),n=(u,c,h)=>{e.length?(o.push(c),h.forEach((d,g)=>{if(!d.isCellEditable(c)||d.isSuppressPaste(c))return;const C=this.processCell(c,d,e[g],EXPORT_TYPE_DRAG_COPY,a,!0);c.setDataValue(d,C,SOURCE_PASTE),l&&l.addParentNode(c.parent,[d]);const{rowIndex:w,rowPinned:v}=u,f=this.cellPositionUtils.createIdFromValues({rowIndex:w,column:d,rowPinned:v});s[f]=!0})):h.forEach(d=>{const g=this.processCell(c,d,this.valueService.getValue(d,c),EXPORT_TYPE_DRAG_COPY,r,!1,!0);e.push(g)})};this.iterateActiveRanges(!0,n)};this.doPasteOperation(t)}removeLastLineIfBlank(e){const t=(0,import_core._last)(e);if(t&&t.length===1&&t[0]===""){if(e.length===1)return;(0,import_core._removeFromArray)(e,t)}}fireRowChanged(e){this.gos.get("editType")==="fullRow"&&e.forEach(t=>{this.eventService.dispatchEvent({type:"rowValueChanged",node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned})})}pasteMultipleValues(e,t,s,o,i,l,r){let a=t;const n=this.clientSideRowModel!=null&&!this.gos.get("enableGroupEdit")&&!this.gos.get("treeData"),u=()=>{for(;;){if(!a)return null;const c=this.rowPositionUtils.getRowNode(a);if(a=this.cellNavigationService.getRowBelow({rowPinned:a.rowPinned,rowIndex:a.rowIndex}),c==null)return null;if(!(c.detail||c.footer||n&&c.group))return c}};e.forEach(c=>{const h=u();h&&(c.forEach((d,g)=>this.updateCellValue(h,o[g],d,i,l,r)),s.push(h))})}updateCellValue(e,t,s,o,i,l){if(!e||!t||!t.isCellEditable(e)||t.isSuppressPaste(e)||e.group&&t.isValueActive())return;const r=this.processCell(e,t,s,i,this.gos.getCallback("processCellFromClipboard"),!0);e.setDataValue(t,r,SOURCE_PASTE);const{rowIndex:a,rowPinned:n}=e,u=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:t,rowPinned:n});o[u]=!0,l&&l.addParentNode(e.parent,[t])}copyToClipboard(e={}){this.copyOrCutToClipboard(e)}cutToClipboard(e={},t="api"){this.gos.get("suppressCutToClipboard")||(this.eventService.dispatchEvent({type:"cutStart",source:t}),this.copyOrCutToClipboard(e,!0),this.eventService.dispatchEvent({type:"cutEnd",source:t}))}copyOrCutToClipboard(e,t){let{includeHeaders:s,includeGroupHeaders:o}=e;s==null&&(s=this.gos.get("copyHeadersToClipboard")),o==null&&(o=this.gos.get("copyGroupHeadersToClipboard"));const i={includeHeaders:s,includeGroupHeaders:o},l=!this.gos.get("suppressCopyRowsToClipboard");let r=null;this.rangeService&&!this.rangeService.isEmpty()&&!this.shouldSkipSingleCellRange(this.rangeService)?(this.copySelectedRangeToClipboard(i),r=0):l&&!this.selectionService.isEmpty()?(this.copySelectedRowsToClipboard(i),r=1):this.focusService.isAnyCellFocused()&&(this.copyFocusedCellToClipboard(i),r=2),t&&r!==null&&this.clearCellsAfterCopy(r)}clearCellsAfterCopy(e){if(this.eventService.dispatchEvent({type:"keyShortcutChangedCellStart"}),e===0)this.rangeService.clearCellRangeCellValues({cellEventSource:"clipboardService"});else if(e===1)this.clearSelectedRows();else{const t=this.focusService.getFocusedCell();if(t==null)return;const s=this.rowPositionUtils.getRowNode(t);s&&this.clearCellValue(s,t.column)}this.eventService.dispatchEvent({type:"keyShortcutChangedCellEnd"})}clearSelectedRows(){const e=this.selectionService.getSelectedNodes(),t=this.visibleColsService.getAllCols();for(const s of e)for(const o of t)this.clearCellValue(s,o)}clearCellValue(e,t){if(!t.isCellEditable(e))return;const s=this.valueService.parseValue(t,e,"",e.getValueFromValueService(t))??null;e.setDataValue(t,s,"clipboardService")}shouldSkipSingleCellRange(e){return this.gos.get("suppressCopySingleCellRanges")&&!e.isMoreThanOneCell()}iterateActiveRanges(e,t,s){if(!this.rangeService||this.rangeService.isEmpty())return;const o=this.rangeService.getCellRanges();e?this.iterateActiveRange(o[0],t,s,!0):o.forEach((i,l)=>this.iterateActiveRange(i,t,s,l===o.length-1))}iterateActiveRange(e,t,s,o){if(!this.rangeService)return;let i=this.rangeService.getRangeStartRow(e);const l=this.rangeService.getRangeEndRow(e);s&&e.columns&&s(e.columns);let r=0,a=!1;for(;!a&&i!=null;){const n=this.rowPositionUtils.getRowNode(i);a=this.rowPositionUtils.sameRow(i,l),t(i,n,e.columns,r++,a&&o),i=this.cellNavigationService.getRowBelow(i)}}copySelectedRangeToClipboard(e={}){if(!this.rangeService||this.rangeService.isEmpty())return;const t=this.rangeService.areAllRangesAbleToMerge(),{data:s,cellsToFlash:o}=t?this.buildDataFromMergedRanges(this.rangeService,e):this.buildDataFromRanges(this.rangeService,e);this.copyDataToClipboard(s),this.dispatchFlashCells(o)}buildDataFromMergedRanges(e,t){const s=new Set,o=e.getCellRanges(),i=new Map,l=[],r={};o.forEach(c=>{c.columns.forEach(g=>s.add(g));const{rowPositions:h,cellsToFlash:d}=this.getRangeRowPositionsAndCellsToFlash(e,c);h.forEach(g=>{const C=`${g.rowIndex}-${g.rowPinned||"null"}`;i.get(C)||(i.set(C,!0),l.push(g))}),Object.assign(r,d)});const a=this.visibleColsService.getAllCols(),n=Array.from(s);return n.sort((c,h)=>{const d=a.indexOf(c),g=a.indexOf(h);return d-g}),{data:this.buildExportParams({columns:n,rowPositions:l,includeHeaders:t.includeHeaders,includeGroupHeaders:t.includeGroupHeaders}),cellsToFlash:r}}buildDataFromRanges(e,t){const s=e.getCellRanges(),o=[],i={};return s.forEach(l=>{const{rowPositions:r,cellsToFlash:a}=this.getRangeRowPositionsAndCellsToFlash(e,l);Object.assign(i,a),o.push(this.buildExportParams({columns:l.columns,rowPositions:r,includeHeaders:t.includeHeaders,includeGroupHeaders:t.includeGroupHeaders}))}),{data:o.join(`
`&&a++;continue}}s[l][r]+=u}return s}doPasteOperation(e){const t="clipboard";this.eventService.dispatchEvent({type:"pasteStart",source:t});let s;if(this.clientSideRowModel){const a=this.gos.get("aggregateOnlyChangedColumns");s=new import_core.ChangedPath(a,this.clientSideRowModel.getRootNode())}const o={},i=[],l=this.focusService.getFocusedCell();e(o,i,l,s);const r=[...i];s&&(this.clientSideRowModel.doAggregate(s),s.forEachChangedNodeDepthFirst(a=>{r.push(a)})),this.rowRenderer.refreshCells({rowNodes:r}),this.dispatchFlashCells(o),this.fireRowChanged(i),this.refocusLastFocusedCell(),this.eventService.dispatchEvent({type:"pasteEnd",source:t})}pasteIntoActiveRange(e,t,s,o,i){const l=this.getRangeSize(e)%t.length!=0;let r=0,a=0;const n=(u,c,h,p)=>{if(p-r>=t.length){if(l)return;r+=a,a=0}const C=t[p-r];o.push(c);const w=this.gos.getCallback("processCellFromClipboard");h.forEach((v,f)=>{if(!v.isCellEditable(c)||v.isSuppressPaste(c))return;f>=C.length&&(f=f%C.length);const b=this.processCell(c,v,C[f],EXPORT_TYPE_DRAG_COPY,w,!0);c.setDataValue(v,b,SOURCE_PASTE),i&&i.addParentNode(c.parent,[v]);const{rowIndex:m,rowPinned:R}=u,y=this.cellPositionUtils.createIdFromValues({rowIndex:m,column:v,rowPinned:R});s[y]=!0}),a++};this.iterateActiveRanges(!1,n)}getDisplayedColumnsStartingAt(e){let t=e;const s=[];for(;t!=null;)s.push(t),t=this.visibleColsService.getColAfter(t);return s}pasteStartingFromFocusedCell(e,t,s,o,i){if(!o)return;const l={rowIndex:o.rowIndex,rowPinned:o.rowPinned},r=this.getDisplayedColumnsStartingAt(o.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,s,t,i):this.pasteMultipleValues(e,l,s,r,t,EXPORT_TYPE_CLIPBOARD,i)}isPasteSingleValueIntoRange(e){return this.hasOnlyOneValueToPaste(e)&&this.rangeService!=null&&!this.rangeService.isEmpty()}pasteSingleValueIntoRange(e,t,s,o){const i=e[0][0],l=(r,a,n)=>{t.push(a),n.forEach(u=>this.updateCellValue(a,u,i,s,EXPORT_TYPE_CLIPBOARD,o))};this.iterateActiveRanges(!1,l)}hasOnlyOneValueToPaste(e){return e.length===1&&e[0].length===1}copyRangeDown(){if(!this.rangeService||this.rangeService.isEmpty())return;const e=[],t=(s,o,i,l)=>{const r=this.gos.getCallback("processCellForClipboard"),a=this.gos.getCallback("processCellFromClipboard"),n=(u,c,h)=>{e.length?(o.push(c),h.forEach((p,g)=>{if(!p.isCellEditable(c)||p.isSuppressPaste(c))return;const C=this.processCell(c,p,e[g],EXPORT_TYPE_DRAG_COPY,a,!0);c.setDataValue(p,C,SOURCE_PASTE),l&&l.addParentNode(c.parent,[p]);const{rowIndex:w,rowPinned:v}=u,f=this.cellPositionUtils.createIdFromValues({rowIndex:w,column:p,rowPinned:v});s[f]=!0})):h.forEach(p=>{const g=this.processCell(c,p,this.valueService.getValue(p,c),EXPORT_TYPE_DRAG_COPY,r,!1,!0);e.push(g)})};this.iterateActiveRanges(!0,n)};this.doPasteOperation(t)}removeLastLineIfBlank(e){const t=(0,import_core._last)(e);if(t&&t.length===1&&t[0]===""){if(e.length===1)return;(0,import_core._removeFromArray)(e,t)}}fireRowChanged(e){this.gos.get("editType")==="fullRow"&&e.forEach(t=>{this.eventService.dispatchEvent({type:"rowValueChanged",node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned})})}pasteMultipleValues(e,t,s,o,i,l,r){let a=t;const n=this.clientSideRowModel!=null&&!this.gos.get("enableGroupEdit")&&!this.gos.get("treeData"),u=()=>{for(;;){if(!a)return null;const c=this.rowPositionUtils.getRowNode(a);if(a=this.cellNavigationService.getRowBelow({rowPinned:a.rowPinned,rowIndex:a.rowIndex}),c==null)return null;if(!(c.detail||c.footer||n&&c.group))return c}};e.forEach(c=>{const h=u();h&&(c.forEach((p,g)=>this.updateCellValue(h,o[g],p,i,l,r)),s.push(h))})}updateCellValue(e,t,s,o,i,l){if(!e||!t||!t.isCellEditable(e)||t.isSuppressPaste(e))return;const r=this.processCell(e,t,s,i,this.gos.getCallback("processCellFromClipboard"),!0);e.setDataValue(t,r,SOURCE_PASTE);const{rowIndex:a,rowPinned:n}=e,u=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:t,rowPinned:n});o[u]=!0,l&&l.addParentNode(e.parent,[t])}copyToClipboard(e={}){this.copyOrCutToClipboard(e)}cutToClipboard(e={},t="api"){this.gos.get("suppressCutToClipboard")||(this.eventService.dispatchEvent({type:"cutStart",source:t}),this.copyOrCutToClipboard(e,!0),this.eventService.dispatchEvent({type:"cutEnd",source:t}))}copyOrCutToClipboard(e,t){let{includeHeaders:s,includeGroupHeaders:o}=e;s==null&&(s=this.gos.get("copyHeadersToClipboard")),o==null&&(o=this.gos.get("copyGroupHeadersToClipboard"));const i={includeHeaders:s,includeGroupHeaders:o},l=this.gos.get("selection");let r=null;this.shouldCopyCells(l)?(this.copySelectedRangeToClipboard(i),r=0):this.shouldCopyRows(l)?(this.copySelectedRowsToClipboard(i),r=1):this.focusService.isAnyCellFocused()&&(this.copyFocusedCellToClipboard(i),r=2),t&&r!==null&&this.clearCellsAfterCopy(r)}shouldCopyCells(e){if(!this.rangeService||this.rangeService.isEmpty())return!1;if(e)return e.mode==="cell";{const t=this.gos.get("suppressCopySingleCellRanges");return!(!this.rangeService.isMoreThanOneCell()&&t)}}shouldCopyRows(e){return this.selectionService.isEmpty()?!1:e?e.mode!=="cell"&&(e.copySelectedRows??!1):!this.gos.get("suppressCopyRowsToClipboard")}clearCellsAfterCopy(e){if(this.eventService.dispatchEvent({type:"keyShortcutChangedCellStart"}),e===0)this.rangeService.clearCellRangeCellValues({cellEventSource:"clipboardService"});else if(e===1)this.clearSelectedRows();else{const t=this.focusService.getFocusedCell();if(t==null)return;const s=this.rowPositionUtils.getRowNode(t);s&&this.clearCellValue(s,t.column)}this.eventService.dispatchEvent({type:"keyShortcutChangedCellEnd"})}clearSelectedRows(){const e=this.selectionService.getSelectedNodes(),t=this.visibleColsService.getAllCols();for(const s of e)for(const o of t)this.clearCellValue(s,o)}clearCellValue(e,t){if(!t.isCellEditable(e))return;const s=this.valueService.getDeleteValue(t,e);e.setDataValue(t,s,"clipboardService")}iterateActiveRanges(e,t,s){if(!this.rangeService||this.rangeService.isEmpty())return;const o=this.rangeService.getCellRanges();e?this.iterateActiveRange(o[0],t,s,!0):o.forEach((i,l)=>this.iterateActiveRange(i,t,s,l===o.length-1))}iterateActiveRange(e,t,s,o){if(!this.rangeService)return;let i=this.rangeService.getRangeStartRow(e);const l=this.rangeService.getRangeEndRow(e);s&&e.columns&&s(e.columns);let r=0,a=!1;for(;!a&&i!=null;){const n=this.rowPositionUtils.getRowNode(i);a=this.rowPositionUtils.sameRow(i,l),t(i,n,e.columns,r++,a&&o),i=this.cellNavigationService.getRowBelow(i)}}copySelectedRangeToClipboard(e={}){if(!this.rangeService||this.rangeService.isEmpty())return;const t=this.rangeService.areAllRangesAbleToMerge(),{data:s,cellsToFlash:o}=t?this.buildDataFromMergedRanges(this.rangeService,e):this.buildDataFromRanges(this.rangeService,e);this.copyDataToClipboard(s),this.dispatchFlashCells(o)}buildDataFromMergedRanges(e,t){const s=new Set,o=e.getCellRanges(),i=new Map,l=[],r={};o.forEach(c=>{c.columns.forEach(g=>s.add(g));const{rowPositions:h,cellsToFlash:p}=this.getRangeRowPositionsAndCellsToFlash(e,c);h.forEach(g=>{const C=`${g.rowIndex}-${g.rowPinned||"null"}`;i.get(C)||(i.set(C,!0),l.push(g))}),Object.assign(r,p)});const a=this.visibleColsService.getAllCols(),n=Array.from(s);return n.sort((c,h)=>{const p=a.indexOf(c),g=a.indexOf(h);return p-g}),{data:this.buildExportParams({columns:n,rowPositions:l,includeHeaders:t.includeHeaders,includeGroupHeaders:t.includeGroupHeaders}),cellsToFlash:r}}buildDataFromRanges(e,t){const s=e.getCellRanges(),o=[],i={};return s.forEach(l=>{const{rowPositions:r,cellsToFlash:a}=this.getRangeRowPositionsAndCellsToFlash(e,l);Object.assign(i,a),o.push(this.buildExportParams({columns:l.columns,rowPositions:r,includeHeaders:t.includeHeaders,includeGroupHeaders:t.includeGroupHeaders}))}),{data:o.join(`
`),cellsToFlash:i}}getRangeRowPositionsAndCellsToFlash(e,t){const s=[],o={},i=e.getRangeStartRow(t),l=e.getRangeEndRow(t);let r=i;for(;r&&(s.push(r),t.columns.forEach(a=>{const{rowIndex:n,rowPinned:u}=r,c=this.cellPositionUtils.createIdFromValues({rowIndex:n,column:a,rowPinned:u});o[c]=!0}),!this.rowPositionUtils.sameRow(r,l));)r=this.cellNavigationService.getRowBelow(r);return{rowPositions:s,cellsToFlash:o}}getCellsToFlashFromRowNodes(e){const t=this.visibleColsService.getAllCols(),s={};for(let o=0;o<e.length;o++){const{rowIndex:i,rowPinned:l}=e[o];if(i!=null)for(let r=0;r<t.length;r++){const a=t[r],n=this.cellPositionUtils.createIdFromValues({rowIndex:i,column:a,rowPinned:l});s[n]=!0}}return s}copyFocusedCellToClipboard(e={}){const t=this.focusService.getFocusedCell();if(t==null)return;const s=this.cellPositionUtils.createId(t),o={rowPinned:t.rowPinned,rowIndex:t.rowIndex},i=t.column,l=this.buildExportParams({columns:[i],rowPositions:[o],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(l),this.dispatchFlashCells({[s]:!0})}copySelectedRowsToClipboard(e={}){const{columnKeys:t,includeHeaders:s,includeGroupHeaders:o}=e,i=this.buildExportParams({columns:t,includeHeaders:s,includeGroupHeaders:o});this.copyDataToClipboard(i);const l=this.selectionService.getSelectedNodes()||[];this.dispatchFlashCells(this.getCellsToFlashFromRowNodes(l))}buildExportParams(e){const{columns:t,rowPositions:s,includeHeaders:o=!1,includeGroupHeaders:i=!1}=e,l={columnKeys:t,rowPositions:s,skipColumnHeaders:!o,skipColumnGroupHeaders:!i,suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!s,processCellCallback:this.gos.getCallback("processCellForClipboard"),processRowGroupCallback:r=>this.processRowGroupCallback(r),processHeaderCallback:this.gos.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gos.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(l,!0)}processRowGroupCallback(e){const{node:t,column:s}=e,o=this.gos.get("treeData"),i=this.gos.get("suppressGroupMaintainValueType");let r=(()=>{if(o||i||!s)return t.key;const n=t.groupData?.[s.getId()];return!n||!t.rowGroupColumn||t.rowGroupColumn.getColDef().useValueFormatterForExport===!1?n:this.valueService.formatValue(t.rowGroupColumn,t,n)??n})();if(e.node.footer){let n="";r&&r.length&&(n=` ${r}`),r=`Total${n}`}const a=this.gos.getCallback("processCellForClipboard");if(a){let n=t.rowGroupColumn;return!n&&t.footer&&t.level===-1&&(n=this.funcColsService.getRowGroupColumns()[0]),a({value:r,node:t,column:n,type:"clipboard",formatValue:u=>this.valueService.formatValue(n,t,u)??u,parseValue:u=>this.valueService.parseValue(n,t,u,this.valueService.getValue(n,t))})}return r}dispatchFlashCells(e){window.setTimeout(()=>{this.eventService.dispatchEvent({type:"flashCells",cells:e})},0)}processCell(e,t,s,o,i,l,r){return i?i({column:t,node:e,value:s,type:o,formatValue:n=>this.valueService.formatValue(t,e??null,n)??n,parseValue:n=>this.valueService.parseValue(t,e??null,n,this.valueService.getValue(t,e))}):l&&t.getColDef().useValueParserForImport!==!1?this.valueService.parseValue(t,e??null,s,this.valueService.getValue(t,e)):r&&t.getColDef().useValueFormatterForExport!==!1?this.valueService.formatValue(t,e??null,s)??s:s}copyDataToClipboard(e){const t=this.gos.getCallback("sendToClipboard");if(t){t({data:e});return}if(!this.gos.get("suppressClipboardApi")&&navigator.clipboard){navigator.clipboard.writeText(e).catch(o=>{(0,import_core._warnOnce)(`${o}
${apiError("writeText")}`),this.copyDataToClipboardLegacy(e)});return}this.copyDataToClipboardLegacy(e)}copyDataToClipboardLegacy(e){this.executeOnTempElement(t=>{const s=this.gos.getDocument(),o=this.gos.getActiveDomElement();t.value=e||" ",t.select(),t.focus({preventScroll:!0}),s.execCommand("copy")||(0,import_core._warnOnce)("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."),o!=null&&o.focus!=null&&o.focus({preventScroll:!0})})}executeOnTempElement(e,t){const s=this.gos.getDocument(),o=s.createElement("textarea");o.style.width="1px",o.style.height="1px",o.style.top=s.documentElement.scrollTop+"px",o.style.left=s.documentElement.scrollLeft+"px",o.style.position="absolute",o.style.opacity="0";const i=this.gridCtrl.getGui();i.appendChild(o);try{e(o)}catch{(0,import_core._warnOnce)("Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout(()=>{t(o),i.removeChild(o)},100):i.removeChild(o)}getRangeSize(e){const t=e.getCellRanges();let s=0,o=0;return t.length>0&&(s=e.getRangeStartRow(t[0]).rowIndex,o=e.getRangeEndRow(t[0]).rowIndex),s-o+1}},VERSION="32.1.0",ClipboardCoreModule=(0,import_core2._defineModule)({version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-core`,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]}),ClipboardApiModule=(0,import_core2._defineModule)({version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-api`,apiFunctions:{copyToClipboard,cutToClipboard,copySelectedRowsToClipboard,copySelectedRangeToClipboard,copySelectedRangeDown,pasteFromClipboard},dependantModules:[ClipboardCoreModule]}),ClipboardModule=(0,import_core2._defineModule)({version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,dependantModules:[ClipboardCoreModule,ClipboardApiModule]});
${apiError("writeText")}`),this.copyDataToClipboardLegacy(e)});return}this.copyDataToClipboardLegacy(e)}copyDataToClipboardLegacy(e){this.executeOnTempElement(t=>{const s=(0,import_core._getDocument)(this.gos),o=(0,import_core._getActiveDomElement)(this.gos);t.value=e||" ",t.select(),t.focus({preventScroll:!0}),s.execCommand("copy")||(0,import_core._warnOnce)("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."),o!=null&&o.focus!=null&&o.focus({preventScroll:!0})})}executeOnTempElement(e,t){const s=(0,import_core._getDocument)(this.gos),o=s.createElement("textarea");o.style.width="1px",o.style.height="1px",o.style.top=s.documentElement.scrollTop+"px",o.style.left=s.documentElement.scrollLeft+"px",o.style.position="absolute",o.style.opacity="0";const i=this.gridCtrl.getGui();i.appendChild(o);try{e(o)}catch{(0,import_core._warnOnce)("Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout(()=>{t(o),i.removeChild(o)},100):i.removeChild(o)}getRangeSize(e){const t=e.getCellRanges();let s=0,o=0;return t.length>0&&(s=e.getRangeStartRow(t[0]).rowIndex,o=e.getRangeEndRow(t[0]).rowIndex),s-o+1}},VERSION="32.2.0",ClipboardCoreModule=(0,import_core2._defineModule)({version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-core`,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]}),ClipboardApiModule=(0,import_core2._defineModule)({version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-api`,apiFunctions:{copyToClipboard,cutToClipboard,copySelectedRowsToClipboard,copySelectedRangeToClipboard,copySelectedRangeDown,pasteFromClipboard},dependantModules:[ClipboardCoreModule]}),ClipboardModule=(0,import_core2._defineModule)({version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,dependantModules:[ClipboardCoreModule,ClipboardApiModule]});
{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.1.0",
"version": "32.2.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -16,5 +16,5 @@ "main": "./dist/package/main.cjs.js",

"dependencies": {
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
"@ag-grid-community/core": "32.2.0",
"@ag-grid-community/csv-export": "32.2.0",
"@ag-grid-enterprise/core": "32.2.0"
},

@@ -21,0 +21,0 @@ "devDependencies": {

{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.1.0",
"version": "32.2.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -16,5 +16,5 @@ "main": "./src/main.js",

"dependencies": {
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
"@ag-grid-community/core": "32.2.0",
"@ag-grid-community/csv-export": "32.2.0",
"@ag-grid-enterprise/core": "32.2.0"
},

@@ -21,0 +21,0 @@ "devDependencies": {

@@ -45,6 +45,7 @@ import type { BeanCollection, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, NamedBean, RowPositionUtils } from '@ag-grid-community/core';

private copyOrCutToClipboard;
private shouldCopyCells;
private shouldCopyRows;
private clearCellsAfterCopy;
private clearSelectedRows;
private clearCellValue;
private shouldSkipSingleCellRange;
private iterateActiveRanges;

@@ -51,0 +52,0 @@ private iterateActiveRange;

@@ -1,1 +0,1 @@

export declare const VERSION = "32.1.0";
export declare const VERSION = "32.2.0";
{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.1.0",
"version": "32.2.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -16,5 +16,5 @@ "main": "./dist/package/main.cjs.js",

"dependencies": {
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
"@ag-grid-community/core": "32.2.0",
"@ag-grid-community/csv-export": "32.2.0",
"@ag-grid-enterprise/core": "32.2.0"
},

@@ -21,0 +21,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc