@ishibashi0112/spreadsheet-grid-core 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/clipboardController.cjs +3 -1
- package/dist/controllers/clipboardController.d.ts +8 -0
- package/dist/controllers/clipboardController.js +251 -135
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +109 -103
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +17 -0
- package/dist/controllers/findController.js +149 -93
- package/dist/controllers/findReplaceController.cjs +1 -0
- package/dist/controllers/findReplaceController.d.ts +61 -0
- package/dist/controllers/findReplaceController.js +324 -0
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +4 -0
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +52 -51
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +10 -10
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +5 -0
- package/dist/engine/features.js +39 -15
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +29 -27
- package/dist/engine/gridApi.cjs +2 -2
- package/dist/engine/gridApi.d.ts +6 -1
- package/dist/engine/gridApi.js +29 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +20 -0
- package/dist/logic/clipboardHtml.cjs +1 -0
- package/dist/logic/clipboardHtml.d.ts +40 -0
- package/dist/logic/clipboardHtml.js +168 -0
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.js +35 -11
- package/dist/logic/findReplace.cjs +1 -0
- package/dist/logic/findReplace.d.ts +35 -0
- package/dist/logic/findReplace.js +84 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +22 -0
- package/dist/logic/localeTextFeatures.js +24 -3
- package/dist/logic/selectionOverlayGeometry.cjs +1 -1
- package/dist/logic/selectionOverlayGeometry.d.ts +14 -0
- package/dist/logic/selectionOverlayGeometry.js +36 -4
- package/dist/model/gridTypes.core.d.ts +95 -3
- package/dist/utils/clipboard.cjs +5 -4
- package/dist/utils/clipboard.d.ts +10 -1
- package/dist/utils/clipboard.js +48 -33
- package/package.json +1 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/multiSelect.cjs"),r=require("../utils/shadowDom.cjs"),i=require("../logic/detailRow.cjs"),a=require("../model/gridSelectors.cjs"),o=require("../logic/selectLabels.cjs"),s=require("../logic/geometry.cjs"),c=require("../logic/domGuards.cjs"),l=require("../logic/editorValues.cjs"),u=require("../utils/clipboard.cjs"),d=require("../logic/labelRows.cjs"),f=require("../logic/newRow.cjs"),p=require("../logic/pasteFill.cjs"),m=require("../logic/clearCells.cjs"),h=require("./liveUiState.cjs");var g=e=>e.replace(/\r\n?/g,`
|
|
2
|
-
`).replace(/\n+$/,``),_=e=>{let t=r.getActiveElement(e instanceof Node?e:null);return t instanceof HTMLElement&&t!==t.ownerDocument.body?t:e},v=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},
|
|
2
|
+
`).replace(/\n+$/,``),_=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},ee=e=>{let t=r.getActiveElement(e instanceof Node?e:null);return t instanceof HTMLElement&&t!==t.ownerDocument.body?t:e},v=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},te=(e,t)=>{if(e?.type===`cell`){let n=a.normalizeCellRange(e.range);return t.row>=n.start.row&&t.row<=n.end.row&&t.col>=n.start.col&&t.col<=n.end.col?n.start:t}return e?.type===`col`?{row:0,col:Math.min(e.startCol,e.endCol)}:e?.type===`row`?{row:Math.min(e.startRow,e.endRow),col:0}:t},ne=(e,t)=>{let n,r;if(e?.type===`cell`)n=Math.min(e.range.start.row,e.range.end.row),r=Math.max(e.range.start.row,e.range.end.row);else if(e?.type===`row`)n=Math.min(e.startRow,e.endRow),r=Math.max(e.startRow,e.endRow);else return!1;r=Math.min(r,t.getRowCount()-1);for(let e=Math.max(n,0);e<=r;e+=1)if(t.getRow(e)==null&&t.getLabelRow?.(e)===void 0)return!0;return!1},re=(e,t,n)=>{let r={row:e.row,rowKey:n,rowIndex:t,columnKey:e.column.key,colIndex:e.colIndex,text:e.text,reason:e.reason};return e.reason===`invalid`&&(r.value=e.value,r.message=e.message),r},y=()=>{let r=null,y=e=>{r=e},b=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},x=e=>{let{rowModel:t}=e,n=u.filterClipboardColumns(e.visibleColumns),r=t.getRowCount();if(r===0||n.length===0)return``;let i=b(e),a=e.localeTexts?.multiSelectSeparator,s=[];for(let e=0;e<r;e+=1){let r=t.getRow(e);if(!r||i&&!i(r,e))continue;let c=t.getTreeRow?.(e)?.aggregates;s.push(u.joinTsvRow(n.map(e=>c!==void 0&&e.key in c?o.formatCellClipboardText(e,c[e.key],r,a):u.formatClipboardCell(r,e,a))))}return u.joinTsvLines(s)},S=(e,t)=>{if(!t)return null;let{rowModel:n,visibleColumns:r}=e,i=n.getRowCount()-1;if(v(t,f.getSelectableRowCount(n),r.length))return{columns:u.filterClipboardColumns(r),startRow:0,endRow:i};if(t.type===`cell`){let e=a.normalizeCellRange(t.range);return{columns:u.filterClipboardColumns(r.slice(e.start.col,e.end.col+1)),startRow:e.start.row,endRow:Math.min(e.end.row,i)}}if(t.type===`row`){let e=a.normalizeRowRange(t.startRow,t.endRow);return{columns:u.filterClipboardColumns(r),startRow:e.startRow,endRow:Math.min(e.endRow,i)}}let o=a.normalizeColumnRange(t.startCol,t.endCol);return{columns:u.filterClipboardColumns(r.slice(o.startCol,o.endCol+1)),startRow:0,endRow:i}},C=(e,t,n=!1)=>{let r=w(e,t);if(!n||r===``)return{text:r,header:null};let i=S(e,t);if(i===null||i.columns.length===0)return{text:r,header:null};let a=u.buildClipboardHeaderText(u.resolveClipboardHeaderLayout(e.columnGroupTree,i.columns),i.columns);return{text:`${a}\n${r}`,header:a}},w=(e,t)=>{let{rowModel:n,visibleColumns:r}=e;return v(t,f.getSelectableRowCount(n),r.length)?x(e):u.serializeSelectionToTsv(n.getRow,n.getRowCount(),r,t,b(e),n.getTreeRow?e=>n.getTreeRow?.(e)?.aggregates:void 0,e.localeTexts?.multiSelectSeparator)},T=(e,t,n)=>{let{rowModel:r,visibleColumns:i,readOnly:a,onRowsChange:o,applyServerSideCellEdits:s}=e;if(a||!o&&!s)return;let c=m.resolveClearTarget(t,null,r.getRowCount(),i.length);if(c===null)return;let l=[];for(let e=c.startRow;e<=c.endRow;e+=1)l.push(r.getRow(e)==null?void 0:r.getRowKey(e));let u=[];for(let e=c.startCol;e<=c.endCol;e+=1)u.push(i[e]?.key??``);return{text:n,...c,rowKeys:l,columnKeys:u}},E=(e,t,n,r)=>{let i=S(e,n);if(i===null||i.columns.length===0||i.endRow<i.startRow||(i.endRow-i.startRow+1)*i.columns.length>2e4)return null;let{rowModel:a,visibleColumns:o}=e,s=b(e),c=[];for(let e=i.startRow;e<=i.endRow;e+=1){let t=a.getRow(e);!t||s&&!s(t,e)||c.push({row:t,viewIndex:e,aggregates:a.getTreeRow?.(e)?.aggregates})}if(c.length===0)return null;let l=e.columnGroupTree??null,d=e.getConditionalFormatStats?.(),f=t.createClipboardColorResolver(e.getCopyColorHost?.()??null);try{return t.buildClipboardHtml({columns:i.columns,rows:c,header:r?u.resolveClipboardHeaderLayout(l,i.columns):null,groupAlign:e=>l?.groups.get(e)?.definition.headerAlign,conditionalFormat:d?{stats:d,chipContext:(t,n,r)=>({row:t.row,rowIndex:t.viewIndex,sourceRowIndex:a.getSourceIndex(t.viewIndex)??t.viewIndex,rowKey:a.getRowKey(t.viewIndex)??t.viewIndex,colIndex:o.indexOf(n),value:r,column:n,isActive:!1,isSelected:!0,isEditing:!1,readOnly:e.readOnly})}:void 0,separator:e.localeTexts?.multiSelectSeparator,colors:f})}finally{f.dispose()}},D=null,O=async e=>{if(r===null)return;let t=r,n=h.readLiveUiState(t),i=n.selection??(n.activeCell?{type:`cell`,range:{start:n.activeCell,end:n.activeCell}}:null),a=i!==null&&i.type===`cell`&&i.range.start.row===i.range.end.row&&i.range.start.col===i.range.end.col,o=!e&&t.copyHeaders===!0&&!a,{text:s,header:c}=C(t,i,o);if(!s)return;let l=null;if(t.richCopy)try{l=E(t,t.richCopy,i,o)}catch(e){process.env.NODE_ENV!==`production`&&console.error(`[SpreadsheetGrid] 書式つきのコピー(copyFormat="rich")の表を作れなかったため、文字だけをコピーしました。
|
|
3
|
+
[SpreadsheetGrid] Could not build the rich copy (copyFormat="rich"); copied the text only.`,e)}if((t.richCopy&&l!==null?await t.richCopy.writeRichToClipboard(s,l):await u.writeTextToClipboard(s))&&i){if(c===null)D=null;else{let e=g(s);D={selection:i,header:c,length:e.length,fingerprint:_(e)}}let n=e?T(t,i,s):void 0;n===void 0?t.onCopied?.(i):t.onCopied?.(i,n)}},k=()=>O(!1),A=()=>O(!0),ie=(e,t)=>{let n=e.getLiveCopiedRange?.()??null,r=n?.cut;if(n===null||r===void 0)return null;let i=g(t);if(i!==g(r.text))return null;let{rowModel:a,visibleColumns:o}=e;if(r.endRow>=a.getRowCount()||r.endCol>=o.length)return null;for(let e=0;e<r.rowKeys.length;e+=1){let t=r.startRow+e;if((a.getRow(t)==null?void 0:a.getRowKey(t))!==r.rowKeys[e])return null}for(let e=0;e<r.columnKeys.length;e+=1)if(o[r.startCol+e]?.key!==r.columnKeys[e])return null;return g(C(e,n.selection).text)===i?r:null},ae=e=>{let t=D;if(t===null)return e;let n=g(e);if(n.length!==t.length||_(n)!==t.fingerprint)return e;let r=e.replace(/\r\n?/g,`
|
|
4
|
+
`),i=`${t.header}\n`;return r.startsWith(i)?r.slice(i.length):e},oe=(e,r,i)=>{let{rowModel:a,visibleColumns:s,readOnly:c,canEditCell:u}=e;for(let d=r.startRow;d<=r.endRow;d+=1){let f=a.getRow(d);if(f!=null)for(let p=r.startCol;p<=r.endCol;p+=1){let r=s[p];if(r===void 0||i(d,p)||!t.isViewCellEditable({readOnly:c,canEditCell:u},a,d,p,f,r))continue;let m=t.getCellValue(f,r);if(m==null||m===``)continue;let h=n.isMultiSelectCell(r,f);if(typeof m==`object`&&!h)return!1;let g=e.localeTexts?.multiSelectSeparator,_=l.resolveCellParser(r,g)(o.formatCellClipboardText(r,m,f,g),f);if(h){if(!n.isSameMultiSelectValue(_,m))return!1;continue}if(!Object.is(_,m)&&(typeof _==`object`||String(_)!==String(m)))return!1}}return!0};return{update:y,handleCopy:k,handleCut:A,handlePaste:n=>{if(r===null)return;let a=r,{rows:o,rowModel:l,columns:f,visibleColumns:g,readOnly:_,canEditCell:v,rowKeyGetter:y,createRow:x,createOverflowColumn:S,onRowsChange:C,onColumnsChange:w,applyServerSideCellEdits:T,onPasteSkipped:E,localeTexts:D,pasteFillsSelection:O=!0,dispatch:k}=r,A=h.readLiveUiState(r);if(h.isEditingAtEvent(r)||c.shouldIgnoreGridKeydown(ee(n.target??null))||_||!C&&!T||!A.activeCell)return;let se=n.clipboardData?.getData(`text/plain`)??``;if(!se)return;n.preventDefault();let ce=ae(se),j=u.parseClipboardText(ce);if(j.length===0)return;let M=ie(a,ce),le=O&&M===null?p.expandPasteMatrixToSelection(j,A.selection,A.activeCell,l,g):null,N=le!==null&&T&&ne(A.selection,l)?j:le??j,P=E?[]:null,ue=()=>{let e=P?.filter(e=>!(e.reason===`readOnly`&&e.text===``));e!==void 0&&e.length>0&&E?.({cells:e})},de=N.reduce((e,t)=>Math.max(e,t.length),0);if(de===0)return;let F=te(A.selection,A.activeCell),I={row:d.findFirstPasteRow(l,F.row),col:u.resolvePasteColumnIndexes(g,F.col,1)[0]??F.col},L=I.row,R=I.col,z=u.resolvePasteColumnIndexes(g,R,de),B=z[z.length-1]??R,V=l.getLabelRow!==void 0||l.getGroupRow!==void 0?d.resolvePasteTargetViewIndexes(l,L,N.length):null,H=e=>V?V[e-L]:e,U=V?V[V.length-1]:I.row+Math.max(N.length-1,0),W=M===null?null:{type:`cell`,range:{start:{row:M.startRow,col:M.startCol},end:{row:M.endRow,col:M.endCol}}},G;if(M!==null){let e=new Set;for(let t=0;t<N.length;t+=1)e.add(H(L+t));let t=new Set(z),n=b(a);G=(r,a)=>{if(e.has(r)&&t.has(a))return!0;let o=g[a];if(o===void 0||i.isSyntheticColumnKey(o.key))return!0;let s=l.getRow(r);if(s==null||l.getLabelRow?.(r)!==void 0||l.getGroupRow?.(r)!==void 0)return!0;let c=l.getTreeRow?.(r)?.aggregates;return c!==void 0&&o.key in c?!0:n!==void 0&&!n(s,r)}}let K=M!==null&&G!==void 0&&!oe(a,M,G),fe=e=>{M!==null&&e!==``&&(K=!0)},pe=(e,t)=>N.some((n,r)=>n.some((n,i)=>n!==``&&(e(r)||(z[i]??t)>=t)));if(T){let n=u.buildClipboardCellEdits(e=>l.getRow(H(e)),g,N,L,R,(e,n,r,i)=>t.isViewCellEditable({readOnly:_,canEditCell:v},l,H(e),n,r,i),P!==null||M!==null?e=>{if(fe(e.text),P===null)return;let t=H(e.rowIndex);P.push(re(e,t,l.getRowKey(t)??t))}:void 0,D).map(e=>({...e,viewIndex:H(e.viewIndex)}));M!==null&&pe(e=>{let t=H(L+e);return t>=l.getRowCount()||l.getRow(t)==null},g.length)&&(K=!0);let r=W===null||K?[]:m.buildClearCellEdits({getRow:e=>l.getRow(e),columns:g,selection:W,activeCell:null,viewRowCount:l.getRowCount(),canWriteCell:(e,n,r,i)=>t.isViewCellEditable({readOnly:_,canEditCell:v},l,e,n,r,i),skipCell:G});(n.length>0||r.length>0)&&T([...r,...n]);let i=s.clamp(U,0,Math.max(l.getRowCount()-1,0)),o=s.clamp(B,0,Math.max(g.length-1,0));k(e.gridActions.startSelection(I)),k(e.gridActions.updateSelection({row:i,col:o})),k(e.gridActions.endSelection()),k(e.gridActions.activateCell(I)),M!==null&&a.onCutPasted?.(),ue();return}if(!C)return;let q=l.newRow,me=q!==void 0&&L>=q.index;if(l.getSourceIndex(L)===void 0&&!me)return;let he=I.col,J=[...o],Y=[...g],X=q===void 0?l.getRowCount():q.index,ge=J.length,_e=e=>{let t=H(e);return t<X?l.getSourceIndex(t):ge+(t-X)},ve=Math.max(U+1-X,0),ye=J.length+ve,Z=me&&ve>0?q?.peekRow():void 0;if(ye>J.length&&x)for(Z!==void 0&&J.push(Z);J.length<ye;)J.push(x());let be=B+1,Q=[];if(be>Y.length&&w&&S)for(;Y.length<be;){let e=S(Y.length);Y.push(e),Q.push(e)}let xe=(e,t,n)=>(e<X?l.getRowKey(e):y?.(t,n)??n)??n,Se=u.applyClipboardMatrixToRows(J,_e,Y,N,L,he,(e,n,r,i,a)=>{let o=H(a);return t.isCellEditable({readOnly:_,canEditCell:v},o,n,r,i,{sourceRowIndex:e,rowKey:xe(o,r,e)})},P!==null||M!==null?e=>{if(fe(e.text),P===null)return;let t=H(e.rowIndex),n=e.sourceRowIndex??t;P.push(re(e,t,xe(t,e.row,n)))}:void 0,D),$=Se!==J;M!==null&&pe(e=>{let t=_e(L+e);return t===void 0||t>=J.length},Y.length)&&(K=!0);let Ce=$?Se:o,we=W===null||K?Ce:m.clearCellsInSelection({rows:Ce,resolveSourceIndex:e=>l.getSourceIndex(e),columns:g,selection:W,activeCell:null,viewRowCount:l.getRowCount(),canWriteCell:(e,n,r,i,a)=>t.isViewCellEditable({readOnly:_,canEditCell:v},l,a,n,r,i),skipCell:G}).nextRows;if(!$&&P!==null){let e=P.filter(e=>e.rowIndex<X&&e.colIndex<g.length);P.length=0,P.push(...e)}let Te=s.clamp(U,0,Math.max($&&J.length>o.length?U:X-1,0)),Ee=s.clamp(B,0,Math.max(($?Y:g).length-1,0));$?(q!==void 0&&J.length>o.length&&(Z!==void 0&&q.takeRow(),q.noteAppended(J.length-o.length)),Q.length>0&&w?.(f?[...f,...Q]:Y),C(we)):we!==o&&C(we),k(e.gridActions.startSelection(I)),k(e.gridActions.updateSelection({row:Te,col:Ee})),k(e.gridActions.endSelection()),k(e.gridActions.activateCell(I)),M!==null&&a.onCutPasted?.(),ue()}}};exports.computeIsWholeGridSelected=v,exports.createClipboardController=y,exports.resolvePasteAnchor=te;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
2
|
import type { CellCoord, GridColumn, GridRowKey, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
3
|
import type { GridCopiedRange, GridCutSource } from '../model/gridStore.js';
|
|
4
|
+
import type { ColumnGroupTree } from '../logic/columnGroupCells.js';
|
|
5
|
+
import type { ConditionalFormatStatsMap } from '../logic/conditionalFormat.js';
|
|
6
|
+
import type { RichCopyParts } from '../logic/clipboardHtml.js';
|
|
4
7
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
5
8
|
import type { ValidationLocaleText } from '../logic/validation.js';
|
|
6
9
|
export type ClipboardEventLike = {
|
|
@@ -33,6 +36,11 @@ export type ClipboardControllerArgs<T extends object> = {
|
|
|
33
36
|
onCopied?: (selection: NonNullable<GridSelection>, cut?: GridCutSource) => void;
|
|
34
37
|
getLiveCopiedRange?: (() => GridCopiedRange | null) | undefined;
|
|
35
38
|
onCutPasted?: (() => void) | undefined;
|
|
39
|
+
copyHeaders?: boolean | undefined;
|
|
40
|
+
columnGroupTree?: ColumnGroupTree | null | undefined;
|
|
41
|
+
richCopy?: RichCopyParts | undefined;
|
|
42
|
+
getCopyColorHost?: (() => Element | null) | undefined;
|
|
43
|
+
getConditionalFormatStats?: (() => ConditionalFormatStatsMap) | undefined;
|
|
36
44
|
};
|
|
37
45
|
export type ClipboardController<T extends object> = {
|
|
38
46
|
update: (args: ClipboardControllerArgs<T>) => void;
|
|
@@ -3,22 +3,26 @@ import { getCellValue as t, isCellEditable as n, isViewCellEditable as r } from
|
|
|
3
3
|
import { isMultiSelectCell as i, isSameMultiSelectValue as a } from "../logic/multiSelect.js";
|
|
4
4
|
import { getActiveElement as o } from "../utils/shadowDom.js";
|
|
5
5
|
import { isSyntheticColumnKey as s } from "../logic/detailRow.js";
|
|
6
|
-
import { normalizeCellRange as c } from "../model/gridSelectors.js";
|
|
7
|
-
import { formatCellClipboardText as
|
|
8
|
-
import { clamp as
|
|
9
|
-
import { shouldIgnoreGridKeydown as
|
|
10
|
-
import { resolveCellParser as
|
|
11
|
-
import { applyClipboardMatrixToRows as
|
|
6
|
+
import { normalizeCellRange as c, normalizeColumnRange as l, normalizeRowRange as u } from "../model/gridSelectors.js";
|
|
7
|
+
import { formatCellClipboardText as d } from "../logic/selectLabels.js";
|
|
8
|
+
import { clamp as f } from "../logic/geometry.js";
|
|
9
|
+
import { shouldIgnoreGridKeydown as p } from "../logic/domGuards.js";
|
|
10
|
+
import { resolveCellParser as m } from "../logic/editorValues.js";
|
|
11
|
+
import { applyClipboardMatrixToRows as h, buildClipboardCellEdits as g, buildClipboardHeaderText as _, filterClipboardColumns as v, formatClipboardCell as y, joinTsvLines as b, joinTsvRow as x, parseClipboardText as ee, resolveClipboardHeaderLayout as S, resolvePasteColumnIndexes as te, serializeSelectionToTsv as C, writeTextToClipboard as w } from "../utils/clipboard.js";
|
|
12
12
|
import { findFirstPasteRow as ne, resolvePasteTargetViewIndexes as re } from "../logic/labelRows.js";
|
|
13
|
-
import { getSelectableRowCount as
|
|
13
|
+
import { getSelectableRowCount as T } from "../logic/newRow.js";
|
|
14
14
|
import { expandPasteMatrixToSelection as ie } from "../logic/pasteFill.js";
|
|
15
|
-
import { buildClearCellEdits as ae, clearCellsInSelection as oe, resolveClearTarget as
|
|
15
|
+
import { buildClearCellEdits as ae, clearCellsInSelection as oe, resolveClearTarget as E } from "../logic/clearCells.js";
|
|
16
16
|
import { isEditingAtEvent as se, readLiveUiState as ce } from "./liveUiState.js";
|
|
17
17
|
//#region src/controllers/clipboardController.ts
|
|
18
|
-
var
|
|
18
|
+
var D = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), O = (e) => {
|
|
19
|
+
let t = 2166136261;
|
|
20
|
+
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
21
|
+
return t >>> 0;
|
|
22
|
+
}, le = (e) => {
|
|
19
23
|
let t = o(e instanceof Node ? e : null);
|
|
20
24
|
return t instanceof HTMLElement && t !== t.ownerDocument.body ? t : e;
|
|
21
|
-
},
|
|
25
|
+
}, k = (e, t, n) => {
|
|
22
26
|
if (t === 0 || n === 0 || e?.type !== "cell") return !1;
|
|
23
27
|
let { start: r, end: i } = e.range, a = Math.min(r.row, i.row), o = Math.min(r.col, i.col), s = Math.max(r.row, i.row), c = Math.max(r.col, i.col);
|
|
24
28
|
return a === 0 && o === 0 && s === t - 1 && c === n - 1;
|
|
@@ -53,33 +57,79 @@ var C = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), le = (e) => {
|
|
|
53
57
|
reason: e.reason
|
|
54
58
|
};
|
|
55
59
|
return e.reason === "invalid" && (r.value = e.value, r.message = e.message), r;
|
|
56
|
-
},
|
|
57
|
-
let o = null,
|
|
60
|
+
}, A = () => {
|
|
61
|
+
let o = null, A = (e) => {
|
|
58
62
|
o = e;
|
|
59
|
-
},
|
|
63
|
+
}, j = (e) => {
|
|
60
64
|
let { isRowExportable: t, rowModel: n } = e;
|
|
61
65
|
if (t) return (e, r) => t(e, {
|
|
62
66
|
viewRowIndex: r,
|
|
63
67
|
rowKey: n.getRowKey(r) ?? r
|
|
64
68
|
});
|
|
65
|
-
},
|
|
66
|
-
let { rowModel: t } = e, n =
|
|
69
|
+
}, M = (e) => {
|
|
70
|
+
let { rowModel: t } = e, n = v(e.visibleColumns), r = t.getRowCount();
|
|
67
71
|
if (r === 0 || n.length === 0) return "";
|
|
68
|
-
let i =
|
|
72
|
+
let i = j(e), a = e.localeTexts?.multiSelectSeparator, o = [];
|
|
69
73
|
for (let e = 0; e < r; e += 1) {
|
|
70
74
|
let r = t.getRow(e);
|
|
71
75
|
if (!r || i && !i(r, e)) continue;
|
|
72
76
|
let s = t.getTreeRow?.(e)?.aggregates;
|
|
73
|
-
o.push(
|
|
77
|
+
o.push(x(n.map((e) => s !== void 0 && e.key in s ? d(e, s[e.key], r, a) : y(r, e, a))));
|
|
74
78
|
}
|
|
75
|
-
return
|
|
76
|
-
},
|
|
79
|
+
return b(o);
|
|
80
|
+
}, N = (e, t) => {
|
|
81
|
+
if (!t) return null;
|
|
82
|
+
let { rowModel: n, visibleColumns: r } = e, i = n.getRowCount() - 1;
|
|
83
|
+
if (k(t, T(n), r.length)) return {
|
|
84
|
+
columns: v(r),
|
|
85
|
+
startRow: 0,
|
|
86
|
+
endRow: i
|
|
87
|
+
};
|
|
88
|
+
if (t.type === "cell") {
|
|
89
|
+
let e = c(t.range);
|
|
90
|
+
return {
|
|
91
|
+
columns: v(r.slice(e.start.col, e.end.col + 1)),
|
|
92
|
+
startRow: e.start.row,
|
|
93
|
+
endRow: Math.min(e.end.row, i)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (t.type === "row") {
|
|
97
|
+
let e = u(t.startRow, t.endRow);
|
|
98
|
+
return {
|
|
99
|
+
columns: v(r),
|
|
100
|
+
startRow: e.startRow,
|
|
101
|
+
endRow: Math.min(e.endRow, i)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
let a = l(t.startCol, t.endCol);
|
|
105
|
+
return {
|
|
106
|
+
columns: v(r.slice(a.startCol, a.endCol + 1)),
|
|
107
|
+
startRow: 0,
|
|
108
|
+
endRow: i
|
|
109
|
+
};
|
|
110
|
+
}, P = (e, t, n = !1) => {
|
|
111
|
+
let r = F(e, t);
|
|
112
|
+
if (!n || r === "") return {
|
|
113
|
+
text: r,
|
|
114
|
+
header: null
|
|
115
|
+
};
|
|
116
|
+
let i = N(e, t);
|
|
117
|
+
if (i === null || i.columns.length === 0) return {
|
|
118
|
+
text: r,
|
|
119
|
+
header: null
|
|
120
|
+
};
|
|
121
|
+
let a = _(S(e.columnGroupTree, i.columns), i.columns);
|
|
122
|
+
return {
|
|
123
|
+
text: `${a}\n${r}`,
|
|
124
|
+
header: a
|
|
125
|
+
};
|
|
126
|
+
}, F = (e, t) => {
|
|
77
127
|
let { rowModel: n, visibleColumns: r } = e;
|
|
78
|
-
return
|
|
79
|
-
},
|
|
128
|
+
return k(t, T(n), r.length) ? M(e) : C(n.getRow, n.getRowCount(), r, t, j(e), n.getTreeRow ? (e) => n.getTreeRow?.(e)?.aggregates : void 0, e.localeTexts?.multiSelectSeparator);
|
|
129
|
+
}, pe = (e, t, n) => {
|
|
80
130
|
let { rowModel: r, visibleColumns: i, readOnly: a, onRowsChange: o, applyServerSideCellEdits: s } = e;
|
|
81
131
|
if (a || !o && !s) return;
|
|
82
|
-
let c =
|
|
132
|
+
let c = E(t, null, r.getRowCount(), i.length);
|
|
83
133
|
if (c === null) return;
|
|
84
134
|
let l = [];
|
|
85
135
|
for (let e = c.startRow; e <= c.endRow; e += 1) l.push(r.getRow(e) == null ? void 0 : r.getRowKey(e));
|
|
@@ -91,7 +141,49 @@ var C = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), le = (e) => {
|
|
|
91
141
|
rowKeys: l,
|
|
92
142
|
columnKeys: u
|
|
93
143
|
};
|
|
94
|
-
},
|
|
144
|
+
}, I = (e, t, n, r) => {
|
|
145
|
+
let i = N(e, n);
|
|
146
|
+
if (i === null || i.columns.length === 0 || i.endRow < i.startRow || (i.endRow - i.startRow + 1) * i.columns.length > 2e4) return null;
|
|
147
|
+
let { rowModel: a, visibleColumns: o } = e, s = j(e), c = [];
|
|
148
|
+
for (let e = i.startRow; e <= i.endRow; e += 1) {
|
|
149
|
+
let t = a.getRow(e);
|
|
150
|
+
!t || s && !s(t, e) || c.push({
|
|
151
|
+
row: t,
|
|
152
|
+
viewIndex: e,
|
|
153
|
+
aggregates: a.getTreeRow?.(e)?.aggregates
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (c.length === 0) return null;
|
|
157
|
+
let l = e.columnGroupTree ?? null, u = e.getConditionalFormatStats?.(), d = t.createClipboardColorResolver(e.getCopyColorHost?.() ?? null);
|
|
158
|
+
try {
|
|
159
|
+
return t.buildClipboardHtml({
|
|
160
|
+
columns: i.columns,
|
|
161
|
+
rows: c,
|
|
162
|
+
header: r ? S(l, i.columns) : null,
|
|
163
|
+
groupAlign: (e) => l?.groups.get(e)?.definition.headerAlign,
|
|
164
|
+
conditionalFormat: u ? {
|
|
165
|
+
stats: u,
|
|
166
|
+
chipContext: (t, n, r) => ({
|
|
167
|
+
row: t.row,
|
|
168
|
+
rowIndex: t.viewIndex,
|
|
169
|
+
sourceRowIndex: a.getSourceIndex(t.viewIndex) ?? t.viewIndex,
|
|
170
|
+
rowKey: a.getRowKey(t.viewIndex) ?? t.viewIndex,
|
|
171
|
+
colIndex: o.indexOf(n),
|
|
172
|
+
value: r,
|
|
173
|
+
column: n,
|
|
174
|
+
isActive: !1,
|
|
175
|
+
isSelected: !0,
|
|
176
|
+
isEditing: !1,
|
|
177
|
+
readOnly: e.readOnly
|
|
178
|
+
})
|
|
179
|
+
} : void 0,
|
|
180
|
+
separator: e.localeTexts?.multiSelectSeparator,
|
|
181
|
+
colors: d
|
|
182
|
+
});
|
|
183
|
+
} finally {
|
|
184
|
+
d.dispose();
|
|
185
|
+
}
|
|
186
|
+
}, L = null, R = async (e) => {
|
|
95
187
|
if (o === null) return;
|
|
96
188
|
let t = o, n = ce(t), r = n.selection ?? (n.activeCell ? {
|
|
97
189
|
type: "cell",
|
|
@@ -99,16 +191,33 @@ var C = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), le = (e) => {
|
|
|
99
191
|
start: n.activeCell,
|
|
100
192
|
end: n.activeCell
|
|
101
193
|
}
|
|
102
|
-
} : null), i =
|
|
103
|
-
if (
|
|
104
|
-
|
|
194
|
+
} : null), i = r !== null && r.type === "cell" && r.range.start.row === r.range.end.row && r.range.start.col === r.range.end.col, a = !e && t.copyHeaders === !0 && !i, { text: s, header: c } = P(t, r, a);
|
|
195
|
+
if (!s) return;
|
|
196
|
+
let l = null;
|
|
197
|
+
if (t.richCopy) try {
|
|
198
|
+
l = I(t, t.richCopy, r, a);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
process.env.NODE_ENV !== "production" && console.error("[SpreadsheetGrid] 書式つきのコピー(copyFormat=\"rich\")の表を作れなかったため、文字だけをコピーしました。\n[SpreadsheetGrid] Could not build the rich copy (copyFormat=\"rich\"); copied the text only.", e);
|
|
201
|
+
}
|
|
202
|
+
if ((t.richCopy && l !== null ? await t.richCopy.writeRichToClipboard(s, l) : await w(s)) && r) {
|
|
203
|
+
if (c === null) L = null;
|
|
204
|
+
else {
|
|
205
|
+
let e = D(s);
|
|
206
|
+
L = {
|
|
207
|
+
selection: r,
|
|
208
|
+
header: c,
|
|
209
|
+
length: e.length,
|
|
210
|
+
fingerprint: O(e)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
let n = e ? pe(t, r, s) : void 0;
|
|
105
214
|
n === void 0 ? t.onCopied?.(r) : t.onCopied?.(r, n);
|
|
106
215
|
}
|
|
107
|
-
},
|
|
216
|
+
}, z = () => R(!1), B = () => R(!0), me = (e, t) => {
|
|
108
217
|
let n = e.getLiveCopiedRange?.() ?? null, r = n?.cut;
|
|
109
218
|
if (n === null || r === void 0) return null;
|
|
110
|
-
let i =
|
|
111
|
-
if (i !==
|
|
219
|
+
let i = D(t);
|
|
220
|
+
if (i !== D(r.text)) return null;
|
|
112
221
|
let { rowModel: a, visibleColumns: o } = e;
|
|
113
222
|
if (r.endRow >= a.getRowCount() || r.endCol >= o.length) return null;
|
|
114
223
|
for (let e = 0; e < r.rowKeys.length; e += 1) {
|
|
@@ -116,72 +225,79 @@ var C = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), le = (e) => {
|
|
|
116
225
|
if ((a.getRow(t) == null ? void 0 : a.getRowKey(t)) !== r.rowKeys[e]) return null;
|
|
117
226
|
}
|
|
118
227
|
for (let e = 0; e < r.columnKeys.length; e += 1) if (o[r.startCol + e]?.key !== r.columnKeys[e]) return null;
|
|
119
|
-
return
|
|
120
|
-
}, he = (e
|
|
121
|
-
let
|
|
228
|
+
return D(P(e, n.selection).text) === i ? r : null;
|
|
229
|
+
}, he = (e) => {
|
|
230
|
+
let t = L;
|
|
231
|
+
if (t === null) return e;
|
|
232
|
+
let n = D(e);
|
|
233
|
+
if (n.length !== t.length || O(n) !== t.fingerprint) return e;
|
|
234
|
+
let r = e.replace(/\r\n?/g, "\n"), i = `${t.header}\n`;
|
|
235
|
+
return r.startsWith(i) ? r.slice(i.length) : e;
|
|
236
|
+
}, ge = (e, n, o) => {
|
|
237
|
+
let { rowModel: s, visibleColumns: c, readOnly: l, canEditCell: u } = e;
|
|
122
238
|
for (let f = n.startRow; f <= n.endRow; f += 1) {
|
|
123
239
|
let p = s.getRow(f);
|
|
124
|
-
if (p != null) for (let
|
|
125
|
-
let n = c[
|
|
126
|
-
if (n === void 0 || o(f,
|
|
127
|
-
readOnly:
|
|
128
|
-
canEditCell:
|
|
129
|
-
}, s, f,
|
|
130
|
-
let
|
|
131
|
-
if (
|
|
132
|
-
let
|
|
133
|
-
if (typeof
|
|
134
|
-
let
|
|
135
|
-
if (
|
|
136
|
-
if (!a(
|
|
240
|
+
if (p != null) for (let h = n.startCol; h <= n.endCol; h += 1) {
|
|
241
|
+
let n = c[h];
|
|
242
|
+
if (n === void 0 || o(f, h) || !r({
|
|
243
|
+
readOnly: l,
|
|
244
|
+
canEditCell: u
|
|
245
|
+
}, s, f, h, p, n)) continue;
|
|
246
|
+
let g = t(p, n);
|
|
247
|
+
if (g == null || g === "") continue;
|
|
248
|
+
let _ = i(n, p);
|
|
249
|
+
if (typeof g == "object" && !_) return !1;
|
|
250
|
+
let v = e.localeTexts?.multiSelectSeparator, y = m(n, v)(d(n, g, p, v), p);
|
|
251
|
+
if (_) {
|
|
252
|
+
if (!a(y, g)) return !1;
|
|
137
253
|
continue;
|
|
138
254
|
}
|
|
139
|
-
if (!Object.is(
|
|
255
|
+
if (!Object.is(y, g) && (typeof y == "object" || String(y) !== String(g))) return !1;
|
|
140
256
|
}
|
|
141
257
|
}
|
|
142
258
|
return !0;
|
|
143
259
|
};
|
|
144
260
|
return {
|
|
145
|
-
update:
|
|
146
|
-
handleCopy:
|
|
147
|
-
handleCut:
|
|
261
|
+
update: A,
|
|
262
|
+
handleCopy: z,
|
|
263
|
+
handleCut: B,
|
|
148
264
|
handlePaste: (t) => {
|
|
149
265
|
if (o === null) return;
|
|
150
|
-
let i = o, { rows: a, rowModel: c, columns: l, visibleColumns:
|
|
151
|
-
if (se(o) ||
|
|
266
|
+
let i = o, { rows: a, rowModel: c, columns: l, visibleColumns: u, readOnly: d, canEditCell: m, rowKeyGetter: _, createRow: v, createOverflowColumn: y, onRowsChange: b, onColumnsChange: x, applyServerSideCellEdits: S, onPasteSkipped: C, localeTexts: w, pasteFillsSelection: T = !0, dispatch: E } = o, D = ce(o);
|
|
267
|
+
if (se(o) || p(le(t.target ?? null)) || d || !b && !S || !D.activeCell) return;
|
|
152
268
|
let O = t.clipboardData?.getData("text/plain") ?? "";
|
|
153
269
|
if (!O) return;
|
|
154
270
|
t.preventDefault();
|
|
155
|
-
let k =
|
|
156
|
-
if (
|
|
157
|
-
let
|
|
158
|
-
let e =
|
|
271
|
+
let k = he(O), A = ee(k);
|
|
272
|
+
if (A.length === 0) return;
|
|
273
|
+
let M = me(i, k), N = T && M === null ? ie(A, D.selection, D.activeCell, c, u) : null, P = N !== null && S && de(D.selection, c) ? A : N ?? A, F = C ? [] : null, pe = () => {
|
|
274
|
+
let e = F?.filter((e) => !(e.reason === "readOnly" && e.text === ""));
|
|
159
275
|
e !== void 0 && e.length > 0 && C?.({ cells: e });
|
|
160
|
-
},
|
|
161
|
-
if (
|
|
162
|
-
let
|
|
163
|
-
row: ne(c,
|
|
164
|
-
col: te(
|
|
165
|
-
},
|
|
276
|
+
}, I = P.reduce((e, t) => Math.max(e, t.length), 0);
|
|
277
|
+
if (I === 0) return;
|
|
278
|
+
let L = ue(D.selection, D.activeCell), R = {
|
|
279
|
+
row: ne(c, L.row),
|
|
280
|
+
col: te(u, L.col, 1)[0] ?? L.col
|
|
281
|
+
}, z = R.row, B = R.col, V = te(u, B, I), H = V[V.length - 1] ?? B, U = c.getLabelRow !== void 0 || c.getGroupRow !== void 0 ? re(c, z, P.length) : null, W = (e) => U ? U[e - z] : e, G = U ? U[U.length - 1] : R.row + Math.max(P.length - 1, 0), K = M === null ? null : {
|
|
166
282
|
type: "cell",
|
|
167
283
|
range: {
|
|
168
284
|
start: {
|
|
169
|
-
row:
|
|
170
|
-
col:
|
|
285
|
+
row: M.startRow,
|
|
286
|
+
col: M.startCol
|
|
171
287
|
},
|
|
172
288
|
end: {
|
|
173
|
-
row:
|
|
174
|
-
col:
|
|
289
|
+
row: M.endRow,
|
|
290
|
+
col: M.endCol
|
|
175
291
|
}
|
|
176
292
|
}
|
|
177
|
-
},
|
|
178
|
-
if (
|
|
293
|
+
}, q;
|
|
294
|
+
if (M !== null) {
|
|
179
295
|
let e = /* @__PURE__ */ new Set();
|
|
180
|
-
for (let t = 0; t <
|
|
181
|
-
let t = new Set(
|
|
182
|
-
|
|
296
|
+
for (let t = 0; t < P.length; t += 1) e.add(W(z + t));
|
|
297
|
+
let t = new Set(V), n = j(i);
|
|
298
|
+
q = (r, i) => {
|
|
183
299
|
if (e.has(r) && t.has(i)) return !0;
|
|
184
|
-
let a =
|
|
300
|
+
let a = u[i];
|
|
185
301
|
if (a === void 0 || s(a.key)) return !0;
|
|
186
302
|
let o = c.getRow(r);
|
|
187
303
|
if (o == null || c.getLabelRow?.(r) !== void 0 || c.getGroupRow?.(r) !== void 0) return !0;
|
|
@@ -189,100 +305,100 @@ var C = (e) => e.replace(/\r\n?/g, "\n").replace(/\n+$/, ""), le = (e) => {
|
|
|
189
305
|
return l !== void 0 && a.key in l ? !0 : n !== void 0 && !n(o, r);
|
|
190
306
|
};
|
|
191
307
|
}
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
},
|
|
308
|
+
let J = M !== null && q !== void 0 && !ge(i, M, q), _e = (e) => {
|
|
309
|
+
M !== null && e !== "" && (J = !0);
|
|
310
|
+
}, ve = (e, t) => P.some((n, r) => n.some((n, i) => n !== "" && (e(r) || (V[i] ?? t) >= t)));
|
|
195
311
|
if (S) {
|
|
196
|
-
let t =
|
|
197
|
-
readOnly:
|
|
198
|
-
canEditCell:
|
|
199
|
-
}, c,
|
|
200
|
-
if (
|
|
201
|
-
let t =
|
|
202
|
-
|
|
312
|
+
let t = g((e) => c.getRow(W(e)), u, P, z, B, (e, t, n, i) => r({
|
|
313
|
+
readOnly: d,
|
|
314
|
+
canEditCell: m
|
|
315
|
+
}, c, W(e), t, n, i), F !== null || M !== null ? (e) => {
|
|
316
|
+
if (_e(e.text), F === null) return;
|
|
317
|
+
let t = W(e.rowIndex);
|
|
318
|
+
F.push(fe(e, t, c.getRowKey(t) ?? t));
|
|
203
319
|
} : void 0, w).map((e) => ({
|
|
204
320
|
...e,
|
|
205
|
-
viewIndex:
|
|
321
|
+
viewIndex: W(e.viewIndex)
|
|
206
322
|
}));
|
|
207
|
-
|
|
208
|
-
let t =
|
|
323
|
+
M !== null && ve((e) => {
|
|
324
|
+
let t = W(z + e);
|
|
209
325
|
return t >= c.getRowCount() || c.getRow(t) == null;
|
|
210
|
-
},
|
|
211
|
-
let n =
|
|
326
|
+
}, u.length) && (J = !0);
|
|
327
|
+
let n = K === null || J ? [] : ae({
|
|
212
328
|
getRow: (e) => c.getRow(e),
|
|
213
|
-
columns:
|
|
214
|
-
selection:
|
|
329
|
+
columns: u,
|
|
330
|
+
selection: K,
|
|
215
331
|
activeCell: null,
|
|
216
332
|
viewRowCount: c.getRowCount(),
|
|
217
333
|
canWriteCell: (e, t, n, i) => r({
|
|
218
|
-
readOnly:
|
|
219
|
-
canEditCell:
|
|
334
|
+
readOnly: d,
|
|
335
|
+
canEditCell: m
|
|
220
336
|
}, c, e, t, n, i),
|
|
221
|
-
skipCell:
|
|
337
|
+
skipCell: q
|
|
222
338
|
});
|
|
223
339
|
(t.length > 0 || n.length > 0) && S([...n, ...t]);
|
|
224
|
-
let a =
|
|
225
|
-
E(e.startSelection(
|
|
340
|
+
let a = f(G, 0, Math.max(c.getRowCount() - 1, 0)), o = f(H, 0, Math.max(u.length - 1, 0));
|
|
341
|
+
E(e.startSelection(R)), E(e.updateSelection({
|
|
226
342
|
row: a,
|
|
227
343
|
col: o
|
|
228
|
-
})), E(e.endSelection()), E(e.activateCell(
|
|
344
|
+
})), E(e.endSelection()), E(e.activateCell(R)), M !== null && i.onCutPasted?.(), pe();
|
|
229
345
|
return;
|
|
230
346
|
}
|
|
231
347
|
if (!b) return;
|
|
232
|
-
let
|
|
233
|
-
if (c.getSourceIndex(
|
|
234
|
-
let
|
|
235
|
-
let t =
|
|
236
|
-
return t <
|
|
237
|
-
},
|
|
238
|
-
if (
|
|
239
|
-
let Ee =
|
|
240
|
-
if (Ee >
|
|
241
|
-
let e = y(
|
|
242
|
-
|
|
348
|
+
let Y = c.newRow, ye = Y !== void 0 && z >= Y.index;
|
|
349
|
+
if (c.getSourceIndex(z) === void 0 && !ye) return;
|
|
350
|
+
let be = R.col, X = [...a], Z = [...u], Q = Y === void 0 ? c.getRowCount() : Y.index, xe = X.length, Se = (e) => {
|
|
351
|
+
let t = W(e);
|
|
352
|
+
return t < Q ? c.getSourceIndex(t) : xe + (t - Q);
|
|
353
|
+
}, Ce = Math.max(G + 1 - Q, 0), we = X.length + Ce, Te = ye && Ce > 0 ? Y?.peekRow() : void 0;
|
|
354
|
+
if (we > X.length && v) for (Te !== void 0 && X.push(Te); X.length < we;) X.push(v());
|
|
355
|
+
let Ee = H + 1, De = [];
|
|
356
|
+
if (Ee > Z.length && x && y) for (; Z.length < Ee;) {
|
|
357
|
+
let e = y(Z.length);
|
|
358
|
+
Z.push(e), De.push(e);
|
|
243
359
|
}
|
|
244
|
-
let
|
|
245
|
-
let o =
|
|
360
|
+
let Oe = (e, t, n) => (e < Q ? c.getRowKey(e) : _?.(t, n) ?? n) ?? n, ke = h(X, Se, Z, P, z, be, (e, t, r, i, a) => {
|
|
361
|
+
let o = W(a);
|
|
246
362
|
return n({
|
|
247
|
-
readOnly:
|
|
248
|
-
canEditCell:
|
|
363
|
+
readOnly: d,
|
|
364
|
+
canEditCell: m
|
|
249
365
|
}, o, t, r, i, {
|
|
250
366
|
sourceRowIndex: e,
|
|
251
|
-
rowKey:
|
|
367
|
+
rowKey: Oe(o, r, e)
|
|
252
368
|
});
|
|
253
|
-
},
|
|
254
|
-
if (
|
|
255
|
-
let t =
|
|
256
|
-
|
|
257
|
-
} : void 0, w),
|
|
258
|
-
|
|
259
|
-
let t =
|
|
260
|
-
return t === void 0 || t >=
|
|
261
|
-
},
|
|
262
|
-
let
|
|
263
|
-
rows:
|
|
369
|
+
}, F !== null || M !== null ? (e) => {
|
|
370
|
+
if (_e(e.text), F === null) return;
|
|
371
|
+
let t = W(e.rowIndex), n = e.sourceRowIndex ?? t;
|
|
372
|
+
F.push(fe(e, t, Oe(t, e.row, n)));
|
|
373
|
+
} : void 0, w), $ = ke !== X;
|
|
374
|
+
M !== null && ve((e) => {
|
|
375
|
+
let t = Se(z + e);
|
|
376
|
+
return t === void 0 || t >= X.length;
|
|
377
|
+
}, Z.length) && (J = !0);
|
|
378
|
+
let Ae = $ ? ke : a, je = K === null || J ? Ae : oe({
|
|
379
|
+
rows: Ae,
|
|
264
380
|
resolveSourceIndex: (e) => c.getSourceIndex(e),
|
|
265
|
-
columns:
|
|
266
|
-
selection:
|
|
381
|
+
columns: u,
|
|
382
|
+
selection: K,
|
|
267
383
|
activeCell: null,
|
|
268
384
|
viewRowCount: c.getRowCount(),
|
|
269
385
|
canWriteCell: (e, t, n, i, a) => r({
|
|
270
|
-
readOnly:
|
|
271
|
-
canEditCell:
|
|
386
|
+
readOnly: d,
|
|
387
|
+
canEditCell: m
|
|
272
388
|
}, c, a, t, n, i),
|
|
273
|
-
skipCell:
|
|
389
|
+
skipCell: q
|
|
274
390
|
}).nextRows;
|
|
275
|
-
if (
|
|
276
|
-
let e =
|
|
277
|
-
|
|
391
|
+
if (!$ && F !== null) {
|
|
392
|
+
let e = F.filter((e) => e.rowIndex < Q && e.colIndex < u.length);
|
|
393
|
+
F.length = 0, F.push(...e);
|
|
278
394
|
}
|
|
279
|
-
let
|
|
280
|
-
|
|
281
|
-
row:
|
|
282
|
-
col:
|
|
283
|
-
})), E(e.endSelection()), E(e.activateCell(
|
|
395
|
+
let Me = f(G, 0, Math.max($ && X.length > a.length ? G : Q - 1, 0)), Ne = f(H, 0, Math.max(($ ? Z : u).length - 1, 0));
|
|
396
|
+
$ ? (Y !== void 0 && X.length > a.length && (Te !== void 0 && Y.takeRow(), Y.noteAppended(X.length - a.length)), De.length > 0 && x?.(l ? [...l, ...De] : Z), b(je)) : je !== a && b(je), E(e.startSelection(R)), E(e.updateSelection({
|
|
397
|
+
row: Me,
|
|
398
|
+
col: Ne
|
|
399
|
+
})), E(e.endSelection()), E(e.activateCell(R)), M !== null && i.onCutPasted?.(), pe();
|
|
284
400
|
}
|
|
285
401
|
};
|
|
286
402
|
};
|
|
287
403
|
//#endregion
|
|
288
|
-
export {
|
|
404
|
+
export { k as computeIsWholeGridSelected, A as createClipboardController, ue as resolvePasteAnchor };
|