@univerjs/sheets-ui 0.6.0-nightly.202502201606 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +901 -899
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/umd/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
`,C===`\r
|
|
6
6
|
`)continue}else C=`${h.substring(p[v],p[v+1]-1)}\r
|
|
7
7
|
`;const b=[];S==null||S.forEach(P=>{P.st>=p[v]&&P.ed<=p[v+1]&&b.push({st:P.st-p[v],ed:P.ed-p[v],ts:P.ts})});const E=[];f==null||f.forEach(P=>{P.startIndex>=p[v]&&P.endIndex<=p[v+1]&&E.push({...P,startIndex:P.startIndex-p[v],endIndex:P.endIndex-p[v]})});const y=this._generateDocumentDataModelSnapshot({body:{dataStream:C,textRuns:b,paragraphs:vr(C),customRanges:E}}),R=Object.keys(t.getMatrix()).length===0;t.setValue(R?0:t.getLength(),0,{v:C,p:y}),s.push({})}}else if(h){const p=`${h}\r
|
|
8
|
-
`,v={dataStream:p,textRuns:S,paragraphs:vr(p),payloads:g,customRanges:f};if(!(f!=null&&f.length))t.setValue(0,0,Va({v:h},h,S));else{const C=this._generateDocumentDataModelSnapshot({body:v});t.setValue(0,0,Va({v:h,p:C},h,S))}s.push({})}return c&&c.forEach((p,v)=>{const C=t.getDataRange().endRow+1,{cellMatrix:b,rowProperties:E,colProperties:y}=this._parseTable(p,v);b&&b.forValue((R,P,O)=>{t.setValue(C+R,P,O)}),y&&l.push(...y),s.push(...E)}),this.dispose(),{rowProperties:s,colProperties:l,cellMatrix:t}}_getStyleBySelectorText(o,e){var i;const t=(i=this._styleMap.get(o))==null?void 0:i.getPropertyValue(e);return t||""}_getStyle(o,e){const t=Ua(e),i=o.style;let r="";for(let s=0;s<Wa.length;s++){const l=Wa[s];if(l==="background"){let d="";o.classList.forEach(h=>{d=this._getStyleBySelectorText(`.${h}`,"background-color")||this._getStyleBySelectorText(`.${h}`,l)});const u=i.getPropertyValue("background-color")||d||this._getStyleBySelectorText(`#${o.id}`,"background-color")||this._getStyleBySelectorText(`#${o.id}`,l)||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||this._getStyleBySelectorText(o.nodeName,"background-color")||t["background-color"]||"";u&&(r+=`background:${u};`);continue}if(l==="text-decoration"){let d="";o.classList.forEach(h=>{d=this._getStyleBySelectorText(`.${h}`,"text-decoration-line")||this._getStyleBySelectorText(`.${h}`,l)});const u=i.getPropertyValue("text-decoration-line")||i.getPropertyValue("text-decoration")||d||this._getStyleBySelectorText(`#${o.id}`,"text-decoration-line")||this._getStyleBySelectorText(`#${o.id}`,l)||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||this._getStyleBySelectorText(o.nodeName,"text-decoration-line")||t["text-decoration-line"]||"";u&&(r+=`text-decoration:${u};`);continue}let c="";o.classList.forEach(d=>{c=this._getStyleBySelectorText(`.${d}`,l)}),c=i.getPropertyValue(l)||this._getStyleBySelectorText(`#${o.id}`,l)||c||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||t[l]||"",c&&(r+=`${l}:${c};`)}return r}_parseTable(o,e){var l,c;const t=new a.ObjectMatrix,i=(l=ih(o))!=null?l:[],{rowProperties:r=[]}=nh(o),s=this._parseTableByHtml(this._dom,e,(c=this._getCurrentSkeleton())==null?void 0:c.skeleton);return s&&s.forValue((d,u,h)=>{var f,p,v,C,b,E,y,R,P,O,k,D,N,H,V,U,W,B,F,z,x,X,Y,J;let S=I.handleStringToStyle(void 0,h.style);if((C=(v=(p=(f=h==null?void 0:h.richTextParma)==null?void 0:f.p)==null?void 0:p.body)==null?void 0:v.textRuns)!=null&&C.length){const ie=(E=(b=h==null?void 0:h.richTextParma)==null?void 0:b.v)==null?void 0:E.length;for(let $=0;$<((O=(P=(R=(y=h==null?void 0:h.richTextParma)==null?void 0:y.p)==null?void 0:R.body)==null?void 0:P.textRuns)==null?void 0:O.length);$++){const re=(N=(D=(k=h==null?void 0:h.richTextParma)==null?void 0:k.p)==null?void 0:D.body)==null?void 0:N.textRuns[$];re.st===0&&re.ed===ie&&(S={...re.ts,...S},(U=(V=(H=h==null?void 0:h.richTextParma)==null?void 0:H.p)==null?void 0:V.body)==null||U.textRuns.splice($,1),$--)}((z=(F=(B=(W=h==null?void 0:h.richTextParma)==null?void 0:W.p)==null?void 0:B.body)==null?void 0:F.textRuns)==null?void 0:z.length)===0&&(h.content=(x=h==null?void 0:h.richTextParma)==null?void 0:x.v,delete h.richTextParma)}const g=(J=(Y=(X=h==null?void 0:h.richTextParma)==null?void 0:X.p)==null?void 0:Y.body)!=null&&J.textRuns?{v:h.richTextParma.v,p:h.richTextParma.p,s:S,rowSpan:h.rowSpan,colSpan:h.colSpan}:{v:h.content,s:S,rowSpan:h.rowSpan,colSpan:h.colSpan};t.setValue(d,u,g)}),{rowProperties:r,colProperties:i,cellMatrix:t}}_parseTableByHtml(o,e,t){var c,d;const i=new a.ObjectMatrix,r=o.querySelectorAll("table")[e];if(!r)return i;const s=this._getStyle(r,""),l=r==null?void 0:r.querySelectorAll("tr");for(let u=0;u<l.length;u++){const h=l[u],S=this._getStyle(h,s),g=h.querySelectorAll("td, th");let f=0;for(let p=0;p<g.length;){const v=g[p];let C="";const b=Number(v.getAttribute("rowSpan"))||1,E=Number(v.getAttribute("colSpan"))||1;if(C=this._getStyle(v,S),u>0){const O=i.getValue(u-1,f);if((c=O==null?void 0:O.style)!=null&&c.includes("border-bottom")&&C.includes("border-top")){const k=xa(O.style,"border-bottom");k&&I.textTrim(k.substr(k.indexOf(":")+1))!=="none"&&(C=C.replace(/border-top:[^;]+;/,""))}}if(p>0){const O=i.getValue(u,f-1);if((d=O==null?void 0:O.style)!=null&&d.includes("border-right")&&C.includes("border-left")){const k=xa(O.style,"border-right");k&&I.textTrim(k.substr(k.indexOf(":")+1))!=="none"&&(C=C.replace(/border-left:[^;]+;/,""))}}const{cellText:y,cellRichStyle:R}=this._getCellTextAndRichText(v,C,t),P={rowSpan:b,colSpan:E,content:y,style:C,richTextParma:{p:R,v:y}};if(i.getValue(u,f)){f+=1;continue}else b>1||E>1?rh(i,C,P,{colSpan:E,rowSpan:b,rowIndex:u,colSetValueIndex:f}):i.setValue(u,f,P),f+=E,p++}}return i}_parseCellHtml(o,e,t,i=new Map,r){var s;for(const l of e)if(l.nodeType===Node.TEXT_NODE){const c=(s=l.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;o&&i.has(o)&&(d=i.get(o)),t.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&t.textRuns.push({st:t.dataStream.length-c.length,ed:t.dataStream.length,ts:d})}else{if(l.nodeType===Node.COMMENT_NODE||l.nodeName==="STYLE")continue;if(l.nodeType===Node.ELEMENT_NODE){const c=this._getStyle(l,r),d=o?i.get(o):{},u=Ua(c),h=Ki(l,u);i.set(l,{...d,...h});const{childNodes:S}=l;this._parseCellHtml(l,S,t,i,c)}}}_getCellTextAndRichText(o,e,t){var l;let i="",r;if(/<[^>]+>/.test(o.innerHTML)&&t){const c={dataStream:"",textRuns:[]};this._parseCellHtml(null,o.childNodes,c,void 0,e);const d=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,u=d==null?void 0:d.getSnapshot(),h=`${c.dataStream}\r
|
|
8
|
+
`,v={dataStream:p,textRuns:S,paragraphs:vr(p),payloads:g,customRanges:f};if(!(f!=null&&f.length))t.setValue(0,0,Va({v:h},h,S));else{const C=this._generateDocumentDataModelSnapshot({body:v});t.setValue(0,0,Va({v:h,p:C},h,S))}s.push({})}return c&&c.forEach((p,v)=>{const C=t.getDataRange().endRow+1,{cellMatrix:b,rowProperties:E,colProperties:y}=this._parseTable(p,v);b&&b.forValue((R,P,O)=>{t.setValue(C+R,P,O)}),y&&l.push(...y),s.push(...E)}),this.dispose(),{rowProperties:s,colProperties:l,cellMatrix:t}}_getStyleBySelectorText(o,e){var i;const t=(i=this._styleMap.get(o))==null?void 0:i.getPropertyValue(e);return t||""}_getStyle(o,e){const t=Ua(e),i=o.style;let r="";for(let s=0;s<Wa.length;s++){const l=Wa[s];if(l==="background"){let d="";o.classList.forEach(h=>{d=this._getStyleBySelectorText(`.${h}`,"background-color")||this._getStyleBySelectorText(`.${h}`,l)});const u=i.getPropertyValue("background-color")||d||this._getStyleBySelectorText(`#${o.id}`,"background-color")||this._getStyleBySelectorText(`#${o.id}`,l)||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||this._getStyleBySelectorText(o.nodeName,"background-color")||t["background-color"]||"";u&&(r+=`background:${u};`);continue}if(l==="text-decoration"){let d="";o.classList.forEach(h=>{d=this._getStyleBySelectorText(`.${h}`,"text-decoration-line")||this._getStyleBySelectorText(`.${h}`,l)});const u=i.getPropertyValue("text-decoration-line")||i.getPropertyValue("text-decoration")||d||this._getStyleBySelectorText(`#${o.id}`,"text-decoration-line")||this._getStyleBySelectorText(`#${o.id}`,l)||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||this._getStyleBySelectorText(o.nodeName,"text-decoration-line")||t["text-decoration-line"]||"";u&&(r+=`text-decoration:${u};`);continue}let c="";o.classList.forEach(d=>{c=this._getStyleBySelectorText(`.${d}`,l)}),c=i.getPropertyValue(l)||this._getStyleBySelectorText(`#${o.id}`,l)||c||this._getStyleBySelectorText(o.nodeName.toLowerCase(),l)||t[l]||"",c&&(r+=`${l}:${c};`)}return r}_parseTable(o,e){var l,c;const t=new a.ObjectMatrix,i=(l=ih(o))!=null?l:[],{rowProperties:r=[]}=nh(o),s=this._parseTableByHtml(this._dom,e,(c=this._getCurrentSkeleton())==null?void 0:c.skeleton);return s&&s.forValue((d,u,h)=>{var f,p,v,C,b,E,y,R,P,O,k,D,N,H,V,U,W,B,F,z,x,X,Y,J;let S=I.handleStringToStyle(void 0,h.style);if((C=(v=(p=(f=h==null?void 0:h.richTextParma)==null?void 0:f.p)==null?void 0:p.body)==null?void 0:v.textRuns)!=null&&C.length){const ie=(E=(b=h==null?void 0:h.richTextParma)==null?void 0:b.v)==null?void 0:E.length;for(let $=0;$<((O=(P=(R=(y=h==null?void 0:h.richTextParma)==null?void 0:y.p)==null?void 0:R.body)==null?void 0:P.textRuns)==null?void 0:O.length);$++){const re=(N=(D=(k=h==null?void 0:h.richTextParma)==null?void 0:k.p)==null?void 0:D.body)==null?void 0:N.textRuns[$];re.st===0&&re.ed===ie&&(S={...re.ts,...S},(U=(V=(H=h==null?void 0:h.richTextParma)==null?void 0:H.p)==null?void 0:V.body)==null||U.textRuns.splice($,1),$--)}((z=(F=(B=(W=h==null?void 0:h.richTextParma)==null?void 0:W.p)==null?void 0:B.body)==null?void 0:F.textRuns)==null?void 0:z.length)===0&&(h.content=(x=h==null?void 0:h.richTextParma)==null?void 0:x.v,delete h.richTextParma)}const g=(J=(Y=(X=h==null?void 0:h.richTextParma)==null?void 0:X.p)==null?void 0:Y.body)!=null&&J.textRuns?{v:h.richTextParma.v,p:h.richTextParma.p,s:S,rowSpan:h.rowSpan,colSpan:h.colSpan}:{v:h.content,s:S,rowSpan:h.rowSpan,colSpan:h.colSpan};t.setValue(d,u,g)}),{rowProperties:r,colProperties:i,cellMatrix:t}}_parseTableByHtml(o,e,t){var c,d;const i=new a.ObjectMatrix,r=o.querySelectorAll("table")[e];if(!r)return i;const s=this._getStyle(r,""),l=r==null?void 0:r.querySelectorAll("tr");for(let u=0;u<l.length;u++){const h=l[u],S=this._getStyle(h,s),g=h.querySelectorAll("td, th");let f=0;for(let p=0;p<g.length;){const v=g[p];let C="";const b=Number(v.getAttribute("rowSpan"))||1,E=Number(v.getAttribute("colSpan"))||1;if(C=this._getStyle(v,S),u>0){const O=i.getValue(u-1,f);if((c=O==null?void 0:O.style)!=null&&c.includes("border-bottom")&&C.includes("border-top")){const k=xa(O.style,"border-bottom");k&&I.textTrim(k.substr(k.indexOf(":")+1))!=="none"&&(C=C.replace(/border-top:[^;]+;/,""))}}if(p>0){const O=i.getValue(u,f-1);if((d=O==null?void 0:O.style)!=null&&d.includes("border-right")&&C.includes("border-left")){const k=xa(O.style,"border-right");k&&I.textTrim(k.substr(k.indexOf(":")+1))!=="none"&&(C=C.replace(/border-left:[^;]+;/,""))}}const{cellText:y,cellRichStyle:R}=this._getCellTextAndRichText(v,C,t),P={rowSpan:b,colSpan:E,content:y,style:C,richTextParma:{p:R,v:y}};if(i.getValue(u,f)){f+=1;continue}else b>1||E>1?rh(i,C,P,{colSpan:E,rowSpan:b,rowIndex:u,colSetValueIndex:f}):i.setValue(u,f,P),f+=E,p++}}return i}_parseCellHtml(o,e,t,i=new Map,r){var s;for(const l of e)if(l.nodeType===Node.TEXT_NODE){const c=(s=l.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;o&&i.has(o)&&(d=i.get(o)),t.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&t.textRuns.push({st:t.dataStream.length-c.length,ed:t.dataStream.length,ts:d})}else{if(l.nodeType===Node.COMMENT_NODE||l.nodeName==="STYLE")continue;if(l.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(l.nodeType===Node.ELEMENT_NODE){const c=this._getStyle(l,r),d=o?i.get(o):{},u=Ua(c),h=Ki(l,u);i.set(l,{...d,...h});const{childNodes:S}=l;this._parseCellHtml(l,S,t,i,c)}}}_getCellTextAndRichText(o,e,t){var l;let i="",r;if(/<[^>]+>/.test(o.innerHTML)&&t){const c={dataStream:"",textRuns:[]};this._parseCellHtml(null,o.childNodes,c,void 0,e);const d=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,u=d==null?void 0:d.getSnapshot(),h=`${c.dataStream}\r
|
|
9
9
|
`,S={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:vr(h)}};d==null||d.reset(S),r=d==null?void 0:d.getSnapshot(),i=c.dataStream}else i=oh(o.innerHTML.replace(/[\r\n]/g,""));return{cellText:i,cellRichStyle:r}}_generateDocumentDataModelSnapshot(o){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,i=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...i==null?void 0:i.getSnapshot(),...o};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(o,e,t,i){var r,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")i.push({index:((r=t==null?void 0:t.paragraphs)==null?void 0:r.length)||0});else if(c.nodeType===Node.TEXT_NODE){if(((s=c.nodeValue)==null?void 0:s.trim())==="")continue;const d=(l=c.nodeValue)==null?void 0:l.replace(/[\r\n]/g,"");let u;o&&this._styleCache.has(o)&&(u=this._styleCache.get(o));const h={dataStream:"",textRuns:[]};t.dataStream+=d,h.dataStream+=d,u&&Object.getOwnPropertyNames(u).length&&(t.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}),h.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}))}else{if(a.skipParseTagNames.includes(c.nodeName.toLowerCase()))continue;if(c.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(c.nodeType===Node.ELEMENT_NODE){if(c.nodeName==="STYLE")continue;const d=c,u=this._processBeforeLink(d,{body:t}),h=o?this._styleCache.get(o):{},S=this._styleRules.find(({filter:v})=>La(c,v)),g=S?S.getStyle(c):Ki(c);this._styleCache.set(c,{...h,...g});const{childNodes:f}=c;this.process(c,f,t,i);const p=this._afterProcessRules.find(({filter:v})=>La(c,v));p&&p.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(o,e){return e.body.dataStream.length}_processAfterLink(o,e,t){var s,l;const i=e.body,r=o;r.tagName.toUpperCase()==="A"&&(i.customRanges=(s=i.customRanges)!=null?s:[],i.customRanges.push({startIndex:t,endIndex:i.dataStream.length-1,rangeId:(l=r.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:r.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};T(Xo,"_pluginList",[]);let vn=Xo;function nh(n){const o=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(o);if(!e)return{rowProperties:[],rowCount:0};const i=Array.from(e).map(r=>Ba(r[1])).map(r=>{if(!r.height){const s=r.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);r.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return r});return{rowProperties:i,rowCount:i.length}}function Ua(n){const o={};return n.split(";").forEach(t=>{const[i,r]=t.split(":");o[i]=r}),o}function Ba(n){if(!n)return{};const o={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,i,,r,s]=t,l=r!==void 0?r:s;o[i]=l}return o}function ih(n){const o=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(o),t=/<col([\s\S]*?)>/g;let i;if(e!=null&&e[2]?i=e[2].matchAll(t):i=n.matchAll(t),!i)return null;const r=Array.from(i).map(l=>Ba(l[1])),s=[];return r.forEach(l=>{const c=Number(l.span);if(c)for(let d=0;d<c;d++){const u={...l};delete u.span,s.push(u)}else s.push(l)}),s}function oh(n){const o={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return n.replace(/<|>|&|"|'| |<br>/g,e=>o[e])}function xa(n,o){if(!n||!o)return null;const e=new RegExp(`(${o}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function rh(n,o,e,t){const{rowSpan:i,colSpan:r,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+i;c++)for(let d=l;d<l+r;d++)c===s&&d===l?n.setValue(c,d,{...e,style:o}):n.setValue(c,d,{style:o})}const sh={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const o=Ki(n);return{st:{s:a.BooleanNumber.TRUE},...o}}}],afterProcessRules:[{filter(n){return n.tagName==="DIV"&&/ace-line/i.test(n.className)},handler(n){n.paragraphs==null&&(n.paragraphs=[]),n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+="\r"}}]},ah={name:"univer-doc-paste-plugin-univer",checkPasteType(n){return/UniverNormal/i.test(n)},stylesRules:[],afterProcessRules:[{filter(n){return n.tagName==="P"&&/UniverNormal/i.test(n.className)},handler(n,o){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Ha(o);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},lh={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const o=Ki(n);return{bl:a.BooleanNumber.TRUE,...o}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,o){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Ha(o);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var It=(n=>(n.COPY="COPY",n.CUT="CUT",n))(It||{});function ch(n,o,e,t,i){const r=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=Cr(r),l=Ir(s),c=o.map(d=>{if(!i.has(`${n}-${d}`)){const u=t.getValue(n,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=n;h<n+u.rowSpan;h++)for(let S=d;S<d+u.colSpan;S++)i.add(`${h}-${S}`);return dh(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function dh(n,o,e,t){const i=t.getValue(n,o),r=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,o,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(d=>!!d),s=Cr(r),l=Ir(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,o))||""},"");return`<td${l}>${c}</td>`}function uh(n,o){return`<colgroup>${n.map(t=>{const i=o.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),r=Cr(i);return`<col ${Ir(r)}>`}).join("")}</colgroup>`}function Cr(n){return n.reduce((o,e)=>(Object.keys(e).forEach(i=>{o[i]?o[i]+=`;${e[i]}`:o[i]=e[i]}),o),{})}function Ir(n){return Object.keys(n).reduce((o,e)=>(o+=` ${e}="${n[e]}"`,o),"")}class hh{convert(o,e,t){const{cols:i,rows:r}=e;if(!i.length)return"";const s=uh(i,t),l=[],c=new Set;return r.forEach(u=>{l.push(ch(u,i,t,o,c))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
10
10
|
<tbody>${l.join("")}</tbody></table>`}}const mh=(n,o,e=!1)=>{const t=h=>h.endRow-h.startRow+1,i=h=>h.endColumn-h.startColumn+1,r=t(o)%t(n),s=i(o)%i(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:i(n)-1},c=Math.floor(t(o)/t(n)),d=Math.floor(i(o)/i(n)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let S=1;S<=d;S++){const g=t(n)*(h-1),f=i(n)*(S-1),p={startRow:g+o.startRow,endRow:g+o.startRow,startColumn:f+o.startColumn,endColumn:f+o.startColumn};u.push({repeatRelativeRange:l,startRange:p})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const S=t(n)*(h-1),g=0,f={startRow:S+o.startRow,endRow:S+o.startRow,startColumn:g+o.startColumn,endColumn:g+o.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(r&&!s&&!e)for(let h=1;h<=d;h++){const g=i(n)*(h-1),f={startRow:0+o.startRow,endRow:0+o.startRow,startColumn:g+o.startColumn,endColumn:g+o.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:o.startRow,endRow:o.startRow,startColumn:o.startColumn,endColumn:o.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function Fa(n){return n?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(e=>e.test(n)):!1}function Sh(n){if(!n)return!1;const o=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(o)||[]).length>0}function gh(...n){if(n.length===1)return n[0];const o=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((i,r,s)=>{o.setValue(i,r,{...o.getValue(i,r),...s})})}),o.getMatrix()}function fh(n,o){return n.id===o.id&&n.params.unitId===o.params.unitId&&n.params.subUnitId===o.params.subUnitId}function _r(n){const o=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const i=n[e],r=[i];for(;e+t<n.length&&fh(i,n[e+t]);)r.push(n[e+t]),t+=1;const s=gh(...r.map(l=>l.params.cellValue||{}));o.push({...i,params:{...i.params,cellValue:s}})}else o.push(n[e]);e+=t}return o}function br(n,o){const{startRow:e,endRow:t,startColumn:i,endColumn:r}=n;for(let s=e;s<=t;s++)for(let l=i;l<=r;l++)if(o.rows.includes(s)&&o.cols.includes(l))return!0}function za(n,o){const{startRow:e,endRow:t,startColumn:i,endColumn:r}=o;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=i;s<=r;s++)if(!n.cols.includes(s))return!1;return!0}function ph(n){const o=n.trim().split(`
|
|
11
11
|
`);let e="<table>";return o.forEach(t=>{const i=t.split(" ");e+="<tr>",i.forEach(r=>{e+=`<td>${r}</td>`}),e+="</tr>"}),e+="</table>",e}var vh=Object.getOwnPropertyDescriptor,Ch=(n,o,e,t)=>{for(var i=t>1?void 0:t?vh(o,e):o,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=s(i)||i);return i},ke=(n,o)=>(e,t)=>o(e,t,n);const fe={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border",SPECIAL_PASTE_FORMULA:"special-paste-formula"},Ih={[I.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[I.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[I.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[I.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};vn.use(lh),vn.use(sh),vn.use(ah);const Ue=a.createIdentifier("sheet.clipboard-service");w.SheetClipboardService=class extends a.Disposable{constructor(e,t,i,r,s,l,c,d,u,h,S,g,f,p){super();T(this,"_clipboardHooks",[]);T(this,"_clipboardHooks$",new A.BehaviorSubject([]));T(this,"clipboardHooks$",this._clipboardHooks$.asObservable());T(this,"_htmlToUSM");T(this,"_usmToHtml");T(this,"_copyContentCache");T(this,"_copyMarkId",null);T(this,"_pasteOptionsCache$",new A.BehaviorSubject(null));T(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());T(this,"_showMenu$",new A.BehaviorSubject(!1));T(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=i,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=S,this._localeService=g,this._errorService=f,this._injector=p,this._htmlToUSM=new vn({getCurrentSkeleton:()=>{var v;return(v=this._renderManagerService.withCurrentTypeOfUnit(a.UniverInstanceType.UNIVER_SHEET,w.SheetSkeletonManagerService))==null?void 0:v.getCurrentParam()}}),this._usmToHtml=new hh,this._copyContentCache=new $u,this.disposeWithMe(this._htmlToUSM),this._initUnitDisposed()}setShowMenu(e){this._showMenu$.next(e)}getPasteMenuVisible(){return this._showMenu$.getValue()}getPasteOptionsCache(){return this._pasteOptionsCache$.getValue()}copyContentCache(){return this._copyContentCache}generateCopyContent(e,t,i){return this._generateCopyContent(e,t,i,this._clipboardHooks)}async copy(e=It.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=i.getActiveSheet();if(!r)return!1;const s=this._clipboardHooks,l=i.getUnitId(),c=r.getSheetId();s.forEach(v=>{var C;return(C=v.onBeforeCopy)==null?void 0:C.call(v,l,c,t.range,e)});const d=this.generateCopyContent(l,c,t.range);if(s.forEach(v=>{var C;return(C=v.onAfterCopy)==null?void 0:C.call(v)}),!d)return!1;const{html:u,plain:h,matrixFragment:S,copyId:g,discreteRange:f}=d;this._copyContentCache.set(g,{unitId:i.getUnitId(),subUnitId:r.getSheetId(),range:f,matrix:S,copyType:e}),await this._clipboardInterfaceService.write(h,u),this._markSelectionService.removeAllShapes();const p=Da(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:p}),!0}async cut(){return this.copy(It.CUT)}async paste(e,t=fe.DEFAULT_PASTE){const i=e.types,r=i.indexOf(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=i.indexOf(I.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=i.findIndex(d=>I.imageMimeTypeSet.has(d)),c=l===-1||!Sh(s);if(s&&c)return this._platformService.isWindows&&Fa(s)&&this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),this._pasteHTML(s,t);if(l!==-1){const d=i[l],u=await e.getType(d);if(u){const h=Ih[d],S=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([S],t)}}return r?this._pastePlainText(r,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,i){const r=Fa(e!=null?e:"");return i&&!r?this._pasteFiles(i,fe.DEFAULT_PASTE):e?this._pasteHTML(e,fe.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(ph(t),fe.DEFAULT_PASTE):this._pastePlainText(t,fe.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const i=this._injector.get(a.IUndoRedoService),r=i.pitchTopUndoElement();r&&a.sequenceExecute(r.undoMutations,this._commandService)&&i.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,fe[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(i=>i.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(i=>{const r=i.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const i=this._clipboardHooks.indexOf(e);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,i,r){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=r.reduce((R,P)=>{var k;const O=(k=P.getFilteredOutRows)==null?void 0:k.call(P,i);return O==null||O.forEach(D=>R.add(D)),R},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:S}=i,g=l.getMatrixWithMergedCells(u,d,S,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let p=u;const v=new a.ObjectMatrix,C={rows:[],cols:[]};for(let R=u;R<=S;R++)if(!c.has(R)){C.rows.push(R);for(let P=d;P<=h;P++){const O=g.getValue(R,P);if(O){const k=a.Tools.deepClone(O);v.setValue(p-u,P-d,{...$n(),...k}),delete k.displayV,f.setValue(p-u,P-d,{...$n(),...k})}else v.setValue(p-u,P-d,$n()),f.setValue(p-u,P-d,$n()),g.setValue(R,P,$n())}p+=1}for(let R=d;R<=h;R++)C.cols.push(R);let b=this._usmToHtml.convert(g,C,r);const E=Xa(v),y=Qu();return b=b.replace(/(<[a-z]+)/,(R,P)=>`${P} data-copy-id="${y}"`),{copyId:y,plain:E,html:b,matrixFragment:f,discreteRange:C}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _executePaste(e){const t=this._getPastingTarget();if(!t.subUnitId||!t.selection)return!1;const i=this._injector.invoke(g=>sn(t.selection.range,g,t.unitId,t.subUnitId));if(!i)return!1;const{unitId:r,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(g=>{var f;return c.push(g)&&((f=g.onBeforePaste)==null?void 0:f.call(g,{unitId:r,subUnitId:s,range:i}))===!1}))return c.forEach(g=>{var f;return(f=g.onAfterPaste)==null?void 0:f.call(g,!1)}),!1;const u=[],h=[];c.forEach(g=>{const f=e(g,{unitId:r,subUnitId:s,range:i});f&&(u.push(...f.redos),h.push(...f.undos))});const S=u.every(g=>this._commandService.executeCommand(g.id,g.params));return S&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),S}async _pasteFiles(e,t){return this._executePaste((i,r)=>{var s;return(s=i.onPasteFiles)==null?void 0:s.call(i,r,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((i,r)=>{var s;return(s=i.onPastePlainText)==null?void 0:s.call(i,r,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var i;return(i=e.onPasteUnrecognized)==null?void 0:i.call(e,t)})}async _pasteHTML(e,t){const i=Ju(e);return i&&this._copyContentCache.get(i)?this._pasteInternal(i,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:i,colProperties:r,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const c=(h=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:h.getSheetBySheetId(l.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d.length&&d.some(g=>br(g,l.pastedRange)&&!za(l.pastedRange,g))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:i,colProperties:r,cellMatrix:s},l,t)}async _pasteInternal(e,t){var P,O;const i=a.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:l,subUnitId:c}=i||{};if(!s||!i||!r||!l||!c||!s||!i)return!1;const d=(P=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:P.getStyles();s.forValue((k,D,N)=>{if(typeof N.s=="string"){const H=a.Tools.deepClone(N);H.s=d==null?void 0:d.getStyleByCell(N),s.setValue(k,D,H)}if(N.colSpan||N.rowSpan)for(let H=0;H<N.rowSpan;H++)for(let V=0;V<N.colSpan;V++){if(H===0&&V===0)continue;const U=k+H,W=D+V;s.setValue(U,W,{s:d==null?void 0:d.getStyleByCell(N)})}});const u=this._getPastedRange(s);if(!u)return!1;const h=(O=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:O.getSheetBySheetId(u.subUnitId);if(!h)return!1;const S=h==null?void 0:h.getMergeData();if(S&&S.some(D=>br(D,u.pastedRange)&&!za(u.pastedRange,D)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const g=this._univerInstanceService.getUnit(l);if(!g)return!1;const f=g.getSheetBySheetId(c);if(!f)return!1;const p=f.getColumnManager(),v=f.getRowManager(),C=f.getConfig().defaultColumnWidth,b=f.getConfig().defaultRowHeight,E=[],y=[];if(r.cols.forEach(k=>{const D=p.getColumnOrCreate(k);E.push({width:`${D.w||C}`})}),r.rows.forEach(k=>{const D=v.getRowOrCreate(k),{ah:N=b,h:H=b}=D,V=Math.max(N,H);y.push({height:`${V}`})}),i.copyType===It.CUT){const k=u.pastedRange.rows[0],D=r.rows[r.rows.length-1]-r.rows[0]+k;u.pastedRange.rows=Array.from(new Array(D+1).keys()).slice(k)}const R=this._pasteUSM({cellMatrix:s,colProperties:E,rowProperties:y},u,t,{range:r,unitId:i.unitId,subUnitId:i.subUnitId,copyType:i.copyType,copyId:e});return i.copyType===It.CUT&&(this._copyContentCache.set(e,{...i,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),R}_pasteUSM(e,t,i,r){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,S=h.cols.length,g=this._clipboardHooks,f=[];if(g.some(O=>{var k;return f.push(O)&&((k=O.onBeforePaste)==null?void 0:k.call(O,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(O=>{var k;return(k=O.onAfterPaste)==null?void 0:k.call(O,!1)}),!1;if(!c)return!1;const v=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,C={copyType:(r==null?void 0:r.copyType)||It.COPY,copyId:r==null?void 0:r.copyId,pasteType:i};let b=[],E=[];const y=f.filter(O=>!O.specialPasteInfo&&O.id!==fe.DEFAULT_PASTE||i===O.id);y.forEach(O=>{var N,H,V;if(s){const U=(N=O.onPasteRows)==null?void 0:N.call(O,{range:h,unitId:d,subUnitId:u},s,{pasteType:i});U&&(b.push(...U.redos),E.push(...U.undos))}const k=(H=O.onPasteColumns)==null?void 0:H.call(O,{range:h,unitId:d,subUnitId:u},l||new Array(S).map(()=>({})),{pasteType:i});k&&(b.push(...k.redos),E.push(...k.undos));const D=(V=O.onPasteCells)==null?void 0:V.call(O,v,{range:h,unitId:d,subUnitId:u},c,C);D&&(b.push(...D.redos),E.push(...D.undos))});const R=this._getSetSelectionOperation(d,u,h,c,i);R&&b.push(R),b=_r(b),E=_r(E),E.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:E,redoMutationsInfo:b});const P=b.every(O=>this._commandService.syncExecuteCommand(O.id,O.params));return P&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:E,redoMutations:b}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:i,source:r}),this.setShowMenu(!0)),y.forEach(O=>{var k;return(k=O.onAfterPaste)==null?void 0:k.call(O,P)}),P}_getSetSelectionOperation(e,t,i,r,s){var R;const l=(R=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:R.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=i,u=c[0],h=d[0],S=c[c.length-1],g=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},p=m.getPrimaryForRange(f,l),v=r.getValue(0,0),C=(v==null?void 0:v.rowSpan)||1,b=(v==null?void 0:v.colSpan)||1;if((s===fe.DEFAULT_PASTE||s===fe.SPECIAL_PASTE_BESIDES_BORDER||s===fe.SPECIAL_PASTE_FORMAT)&&(C>1||b>1)){const P={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+b-1};p.startRow=P.startRow,p.endRow=P.endRow,p.startColumn=P.startColumn,p.endColumn=P.endColumn,p.isMerged=!0,p.isMergedMainCell=!0}const y={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:S,startColumn:h,endColumn:g},primary:p,style:null}]};return{id:m.SetSelectionsOperation.id,params:y}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),i=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:i}}_transformPastedData(e,t,i){const r=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=r;if(!c||!s)return null;const d=this._injector.invoke(H=>sn(s.range,H,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=Pt([d]),{startRow:S,startColumn:g,endRow:f,endColumn:p}=u,v=f-S+1,C=p-g+1,b=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),E=b==null?void 0:b.getActiveSheet();if(!E)return null;const R=E.getMergeData().filter(H=>d.rows.includes(H.startRow)&&d.cols.includes(H.startColumn)),P=R[0];let O=0,k=0,D=0,N=0;if(P&&(O=P.startRow,k=P.startColumn,D=P.endRow,N=P.endColumn),v%e===0&&C%t===0)if(R.length>0&&(v!==e||C!==t))if(O===d.rows[0]&&k===d.cols[0]&&D===d.rows[v-1]&&N===d.cols[C-1])if(Th(i))for(let V=0;V<v;V++)for(let U=0;U<C;U++){const W=i.getValue(V%e,U%t);W&&i.setValue(V,U,W)}else i.forValue((V,U,W)=>{W.s=null,delete W.colSpan,delete W.rowSpan});else for(let H=0;H<v;H++)for(let V=0;V<C;V++){const U=i.getValue(H%e,V%t);U&&i.setValue(H,V,U)}else for(let H=0;H<v;H++)for(let V=0;V<C;V++){const U=i.getValue(H%e,V%t);U&&i.setValue(H,V,U)}else if(R.length>0){const{row:H,col:V}=h(S,g);if(this._topLeftCellsMatch(e,t,{topRow:H,leftCol:V})){const W=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=W.rows,d.cols=W.cols}else{if(f>P.endRow||p>P.endColumn)return null;i.forValue((W,B,F)=>{F.s=null,delete F.colSpan,delete F.rowSpan})}}else{const H=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=H.rows,d.cols=H.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var E;const t=this._getPastingTarget(),{selection:i,unitId:r,subUnitId:s}=t;if(!s||!i)return null;const l=this._injector.invoke(y=>sn(i.range,y,r,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),S=h-u+1,g=d-c+1;if(S<=0||g<=0)return null;const f=l.rows.length,p=l.cols.length,v=(E=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:E.getSheetBySheetId(s);if(!v)return null;const C=v==null?void 0:v.getMergeData();if(f%S===0&&p%g===0&&!(C==null?void 0:C.some(R=>br(R,l)))){for(let R=0;R<f;R++)for(let P=0;P<p;P++){const O=e.getValue(R%S,P%g);O&&e.setValue(R,P,O)}return{pastedRange:l,unitId:r,subUnitId:s}}const b=this._expandOrShrinkRowsCols(r,s,l,g,S);return l.rows=b.rows,l.cols=b.cols,{pastedRange:l,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,t,i,r,s){const{rows:l,cols:c}=i,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,S;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let g=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(g)||h.push(g),g++}if(c.length>=r)S=c.slice(0,r);else{S=c.slice(0);let g=c[c.length-1]+1;for(;S.length<r;)S.push(g),g++}return{rows:h,cols:S}}_topLeftCellsMatch(e,t,i){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=i,d=bh(l+e-1,c,c+t-1,s),u=Eh(c+t-1,l,l+e-1,s);return!d&&!u}removeMarkSelection(){this._copyMarkId&&(this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null)}_initUnitDisposed(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&this.copyContentCache().clearWithUnitId(e.getUnitId())}))}disposePasteOptionsCache(){this.setShowMenu(!1),this.updatePasteOptionsCache(null)}},w.SheetClipboardService=Ch([ke(0,a.ILogService),ke(1,a.IUniverInstanceService),ke(2,a.Inject(m.SheetsSelectionsService)),ke(3,I.IClipboardInterfaceService),ke(4,a.IUndoRedoService),ke(5,a.ICommandService),ke(6,Nt),ke(7,I.INotificationService),ke(8,I.IPlatformService),ke(9,M.IRenderManagerService),ke(10,a.Inject(a.ThemeService)),ke(11,a.Inject(a.LocaleService)),ke(12,a.Inject(a.ErrorService)),ke(13,a.Inject(a.Injector))],w.SheetClipboardService);function Xa(n){let o="";const e=n.getLength();return n.forRow((t,i)=>{const r=[];i.forEach(s=>{const l=n.getValue(t,s);if(l){const c=_h(l);r.push(c)}}),o+=r.join(" "),t!==e-1&&(o+=`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet normal ui-plugin-sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
"@univerjs/icons": "^0.2.20",
|
|
63
63
|
"@univerjs/protocol": "0.1.43",
|
|
64
64
|
"clsx": "^2.1.1",
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/docs": "0.6.
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/engine-
|
|
73
|
-
"@univerjs/telemetry": "0.6.
|
|
74
|
-
"@univerjs/ui": "0.6.
|
|
65
|
+
"@univerjs/core": "0.6.1",
|
|
66
|
+
"@univerjs/design": "0.6.1",
|
|
67
|
+
"@univerjs/docs": "0.6.1",
|
|
68
|
+
"@univerjs/docs-ui": "0.6.1",
|
|
69
|
+
"@univerjs/engine-formula": "0.6.1",
|
|
70
|
+
"@univerjs/engine-numfmt": "0.6.1",
|
|
71
|
+
"@univerjs/sheets": "0.6.1",
|
|
72
|
+
"@univerjs/engine-render": "0.6.1",
|
|
73
|
+
"@univerjs/telemetry": "0.6.1",
|
|
74
|
+
"@univerjs/ui": "0.6.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"less": "^4.2.2",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"typescript": "^5.7.3",
|
|
83
83
|
"vite": "^6.1.1",
|
|
84
84
|
"vitest": "^3.0.6",
|
|
85
|
-
"@univerjs-infra/shared": "0.6.
|
|
85
|
+
"@univerjs-infra/shared": "0.6.1"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"test": "vitest run",
|