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
3
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.0.2 to 32.1.0

39

dist/package/main.cjs.js

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

this.refocusLastFocusedCell();
const event = {
this.eventService.dispatchEvent({
type: "pasteEnd",
source
};
this.eventService.dispatchEvent(event);
});
}

@@ -407,3 +406,3 @@ pasteIntoActiveRange(rangeService, clipboardData, cellsToFlash, updatedRowNodes, changedPath) {

rowNodes.forEach((rowNode) => {
const event = {
this.eventService.dispatchEvent({
type: "rowValueChanged",

@@ -414,4 +413,3 @@ node: rowNode,

rowPinned: rowNode.rowPinned
};
this.eventService.dispatchEvent(event);
});
});

@@ -482,13 +480,11 @@ }

}
const startEvent = {
this.eventService.dispatchEvent({
type: "cutStart",
source
};
this.eventService.dispatchEvent(startEvent);
});
this.copyOrCutToClipboard(params, true);
const endEvent = {
this.eventService.dispatchEvent({
type: "cutEnd",
source
};
this.eventService.dispatchEvent(endEvent);
});
}

@@ -771,7 +767,6 @@ copyOrCutToClipboard(params, cut) {

window.setTimeout(() => {
const event = {
this.eventService.dispatchEvent({
type: "flashCells",
cells: cellsToFlash
};
this.eventService.dispatchEvent(event);
});
}, 0);

@@ -882,6 +877,6 @@ }

// enterprise-modules/clipboard/src/version.ts
var VERSION = "32.0.2";
var VERSION = "32.1.0";
// enterprise-modules/clipboard/src/clipboardModule.ts
var ClipboardCoreModule = {
var ClipboardCoreModule = (0, import_core2._defineModule)({
version: VERSION,

@@ -891,4 +886,4 @@ moduleName: `${import_core2.ModuleNames.ClipboardModule}-core`,

dependantModules: [import_core3.EnterpriseCoreModule, import_csv_export.CsvExportModule]
};
var ClipboardApiModule = {
});
var ClipboardApiModule = (0, import_core2._defineModule)({
version: VERSION,

@@ -905,7 +900,7 @@ moduleName: `${import_core2.ModuleNames.ClipboardModule}-api`,

dependantModules: [ClipboardCoreModule]
};
var ClipboardModule = {
});
var ClipboardModule = (0, import_core2._defineModule)({
version: VERSION,
moduleName: import_core2.ModuleNames.ClipboardModule,
dependantModules: [ClipboardCoreModule, ClipboardApiModule]
};
});
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}
${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,n)=>{this.rangeService?.isMoreThanOneCell()&&!this.hasOnlyOneValueToPaste(t)?this.pasteIntoActiveRange(this.rangeService,t,i,l,n):this.pasteStartingFromFocusedCell(t,i,l,r,n)};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,n=0;n<e.length;n++){const a=e[n-1],u=e[n],c=e[n+1],h=()=>{s[l]||(s[l]=[]),s[l][r]||(s[l][r]="")};if(h(),u==='"'&&(i?c==='"'?(s[l][r]+='"',n++):i=!1:(a===void 0||a===t||o(a))&&(i=!0)),!i&&u!=='"'){if(u===t){r++,h();continue}else if(o(u)){r=0,l++,h(),u==="\r"&&c===`
`&&n++;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();const n={type:"pasteEnd",source:t};this.eventService.dispatchEvent(n)}pasteIntoActiveRange(e,t,s,o,i){const l=this.getRangeSize(e)%t.length!=0;let r=0,n=0;const a=(u,c,h,d)=>{if(d-r>=t.length){if(l)return;r+=n,n=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}),n++};this.iterateActiveRanges(!1,a)}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,n,a)=>{t.push(n),a.forEach(u=>this.updateCellValue(n,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"),n=this.gos.getCallback("processCellFromClipboard"),a=(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,n,!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,a)};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=>{const s={type:"rowValueChanged",node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned};this.eventService.dispatchEvent(s)})}pasteMultipleValues(e,t,s,o,i,l,r){let n=t;const a=this.clientSideRowModel!=null&&!this.gos.get("enableGroupEdit")&&!this.gos.get("treeData"),u=()=>{for(;;){if(!n)return null;const c=this.rowPositionUtils.getRowNode(n);if(n=this.cellNavigationService.getRowBelow({rowPinned:n.rowPinned,rowIndex:n.rowIndex}),c==null)return null;if(!(c.detail||c.footer||a&&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:n,rowPinned:a}=e,u=this.cellPositionUtils.createIdFromValues({rowIndex:n,column:t,rowPinned:a});o[u]=!0,l&&l.addParentNode(e.parent,[t])}copyToClipboard(e={}){this.copyOrCutToClipboard(e)}cutToClipboard(e={},t="api"){if(this.gos.get("suppressCutToClipboard"))return;const s={type:"cutStart",source:t};this.eventService.dispatchEvent(s),this.copyOrCutToClipboard(e,!0);const o={type:"cutEnd",source:t};this.eventService.dispatchEvent(o)}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,n=!1;for(;!n&&i!=null;){const a=this.rowPositionUtils.getRowNode(i);n=this.rowPositionUtils.sameRow(i,l),t(i,a,e.columns,r++,n&&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 n=this.visibleColsService.getAllCols(),a=Array.from(s);return a.sort((c,h)=>{const d=n.indexOf(c),g=n.indexOf(h);return d-g}),{data:this.buildExportParams({columns:a,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:n}=this.getRangeRowPositionsAndCellsToFlash(e,l);Object.assign(i,n),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(n=>{const{rowIndex:a,rowPinned:u}=r,c=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:n,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 n=t[r],a=this.cellPositionUtils.createIdFromValues({rowIndex:i,column:n,rowPinned:l});s[a]=!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 a=t.groupData?.[s.getId()];return!a||!t.rowGroupColumn||t.rowGroupColumn.getColDef().useValueFormatterForExport===!1?a:this.valueService.formatValue(t.rowGroupColumn,t,a)??a})();if(e.node.footer){let a="";r&&r.length&&(a=` ${r}`),r=`Total${a}`}const n=this.gos.getCallback("processCellForClipboard");if(n){let a=t.rowGroupColumn;return!a&&t.footer&&t.level===-1&&(a=this.funcColsService.getRowGroupColumns()[0]),n({value:r,node:t,column:a,type:"clipboard",formatValue:u=>this.valueService.formatValue(a,t,u)??u,parseValue:u=>this.valueService.parseValue(a,t,u,this.valueService.getValue(a,t))})}return r}dispatchFlashCells(e){window.setTimeout(()=>{const t={type:"flashCells",cells:e};this.eventService.dispatchEvent(t)},0)}processCell(e,t,s,o,i,l,r){return i?i({column:t,node:e,value:s,type:o,formatValue:a=>this.valueService.formatValue(t,e??null,a)??a,parseValue:a=>this.valueService.parseValue(t,e??null,a,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.0.2",ClipboardCoreModule={version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-core`,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]},ClipboardApiModule={version:VERSION,moduleName:`${import_core2.ModuleNames.ClipboardModule}-api`,apiFunctions:{copyToClipboard,cutToClipboard,copySelectedRowsToClipboard,copySelectedRangeToClipboard,copySelectedRangeDown,pasteFromClipboard},dependantModules:[ClipboardCoreModule]},ClipboardModule={version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,dependantModules:[ClipboardCoreModule,ClipboardApiModule]};
${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(`
`),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]});
{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.0.2",
"version": "32.1.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.0.2",
"@ag-grid-community/csv-export": "32.0.2",
"@ag-grid-enterprise/core": "32.0.2"
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
},

@@ -59,2 +59,2 @@ "devDependencies": {

}
}
}
{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.0.2",
"version": "32.1.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.0.2",
"@ag-grid-community/csv-export": "32.0.2",
"@ag-grid-enterprise/core": "32.0.2"
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
},

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

@@ -1,4 +0,3 @@

import type { Module } from '@ag-grid-community/core';
export declare const ClipboardCoreModule: Module;
export declare const ClipboardApiModule: Module;
export declare const ClipboardModule: Module;
export declare const ClipboardCoreModule: import("@ag-grid-community/core").Module;
export declare const ClipboardApiModule: import("@ag-grid-community/core").Module;
export declare const ClipboardModule: import("@ag-grid-community/core").Module;

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

export declare const VERSION = "32.0.2";
export declare const VERSION = "32.1.0";
{
"name": "@ag-grid-enterprise/clipboard",
"version": "32.0.2",
"version": "32.1.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.0.2",
"@ag-grid-community/csv-export": "32.0.2",
"@ag-grid-enterprise/core": "32.0.2"
"@ag-grid-community/core": "32.1.0",
"@ag-grid-community/csv-export": "32.1.0",
"@ag-grid-enterprise/core": "32.1.0"
},

@@ -59,2 +59,2 @@ "devDependencies": {

}
}
}

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