@univerjs/drawing-ui 0.6.10 → 0.7.0-beta.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/lib/cjs/index.js +2 -2
- package/lib/es/index.js +50 -44
- package/lib/index.css +1 -1
- package/lib/index.js +50 -44
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Je=Object.defineProperty;var Qe=(i,t,n)=>t in i?Je(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var Q=(i,t,n)=>Qe(i,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@univerjs/core"),M=require("@univerjs/drawing"),b=require("@univerjs/engine-render"),V=require("@univerjs/ui"),l=require("react/jsx-runtime"),_=require("react"),I=require("@univerjs/design"),De=require("rxjs");function xe(i,t,n,e){const r=e.getDrawingByParam(i);if(r==null)return;const s=M.getDrawingShapeKeyByDrawingSearch(i),a=n.getObject(s);if(a&&!(a instanceof b.Group))return;if(a!=null){a.addObject(t);return}const o=new b.Group(s);n.addObject(o,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(t);const{transform:c}=r;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,t){var s;const n=t?i.getUnit(t):i.getFocusedUnit();if(n==null)return;const e=n.getUnitId();let r;return n.type===p.UniverInstanceType.UNIVER_SHEET?r=(s=n.getActiveSheet())==null?void 0:s.getSheetId():(n.type===p.UniverInstanceType.UNIVER_DOC||n.type===p.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Te="COMPONENT_IMAGE_VIEWER";var en=Object.getOwnPropertyDescriptor,nn=(i,t,n,e)=>{for(var r=e>1?void 0:e?en(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ye=(i,t)=>(n,e)=>t(n,e,i);const je=50;exports.DrawingRenderService=class{constructor(t,n,e){this._drawingManagerService=t,this._imageIoService=n,this._dialogService=e}async renderImages(t,n){const{transform:e,drawingType:r,source:s,imageSourceType:a,srcRect:o,prstGeom:c,groupId:g,unitId:d,subUnitId:u,drawingId:h,isMultiTransform:f,transforms:S}=t;if(r!==p.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const v=f&&S?S:[e],C=[];for(const P of v){const{left:y,top:N,width:R,height:T,angle:j,flipX:D,flipY:x,skewX:O,skewY:E}=P,L=v.indexOf(P),A=M.getDrawingShapeKeyByDrawingSearch({unitId:d,subUnitId:u,drawingId:h},f?L:void 0),z=n.getObject(A);if(z!=null){z.transformByState({left:y,top:N,width:R,height:T,angle:j,flipX:D,flipY:x,skewX:O,skewY:E});continue}const $=this._drawingManagerService.getDrawingOrder(d,u),se=$.indexOf(h),ne={...P,zIndex:se===-1?$.length-1:se},te=this._imageIoService.getImageSourceCache(s,a);let oe=!1;if(te!=null)ne.image=te;else{if(a===M.ImageSourceType.UUID)try{ne.url=await this._imageIoService.getImage(s)}catch(Ie){console.error(Ie);continue}else ne.url=s;oe=!0}if(n.getObject(A))continue;ne.printable=!0;const q=new b.Image(A,ne);oe&&this._imageIoService.addImageSourceCache(s,a,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(q),g&&xe({drawingId:g,unitId:d,subUnitId:u},q,n,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),C.push(q))}return C}renderFloatDom(t,n){const{transform:e,drawingType:r,groupId:s,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:g,transforms:d}=t;if(r!==p.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const u=g&&d?d:[e],h=[];for(const f of u){const{left:S,top:v,width:C,height:P,angle:y,flipX:N,flipY:R,skewX:T,skewY:j}=f,D=u.indexOf(f),x=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},g?D:void 0),O=n.getObject(x);if(O!=null){O.transformByState({left:S,top:v,width:C,height:P,angle:y,flipX:N,flipY:R,skewX:T,skewY:j});continue}const E=this._drawingManagerService.getDrawingOrder(a,o),L=E.indexOf(c),A={...f,zIndex:L===-1?E.length-1:L};if(n.getObject(x))continue;A.printable=!1;const z=new b.Rect(x,A);this._drawingManagerService.getDrawingVisible()&&(n.addObject(z,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.allowTransform!==!1&&n.attachTransformerTo(z),s&&xe({drawingId:s,unitId:a,subUnitId:o},z,n,this._drawingManagerService),h.push(z))}return h}renderDrawing(t,n){const e=this._drawingManagerService.getDrawingByParam(t);if(e!=null)switch(e.drawingType){case p.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const s=`${t}-viewer-dialog`,a=window.innerWidth-je,o=window.innerHeight-je,c=this._adjustImageSize(e,r,a,o),g=this._dialogService.open({width:Math.max(c.width,200),id:s,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Te,props:{src:n,width:c.width,height:c.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(s),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const s=e/t,a=r/n,o=Math.min(s,a);return{width:Math.floor(t*o),height:Math.floor(n*o)}}};exports.DrawingRenderService=nn([ye(0,M.IDrawingManagerService),ye(1,M.IImageIoService),ye(2,V.IDialogService)],exports.DrawingRenderService);function ue(i,t){const n=[];return i.forEach(e=>{const{oKey:r,left:s,top:a,height:o,width:c,angle:g}=e,d=t.getDrawingOKey(r);if(d==null)return n.push(null),!0;const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v={unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:{left:s,top:a,height:o,width:c,angle:g}};S===p.DrawingTypeEnum.DRAWING_IMAGE&&(v.srcRect=e.srcRect),n.push(v)}),n}var B=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(B||{});const _e={id:"sheet.operation.set-image-align",type:p.CommandType.OPERATION,handler:(i,t)=>!0},tn="univer-image-common-panel-grid",rn="univer-image-common-panel-border",an="univer-image-common-panel-title",sn="univer-image-common-panel-row",on="univer-image-common-panel-row-vertical",cn="univer-image-common-panel-column",ln="univer-image-common-panel-column-center",gn="univer-image-common-panel-inline",mn="univer-image-common-panel-span2",dn="univer-image-common-panel-span3",un="univer-image-common-panel-input",m={imageCommonPanelGrid:tn,imageCommonPanelBorder:rn,imageCommonPanelTitle:an,imageCommonPanelRow:sn,imageCommonPanelRowVertical:on,imageCommonPanelColumn:cn,imageCommonPanelColumnCenter:ln,imageCommonPanelInline:gn,imageCommonPanelSpan2:mn,imageCommonPanelSpan3:dn,imageCommonPanelInput:un},hn=i=>{const t=V.useDependency(p.ICommandService),n=V.useDependency(p.LocaleService),{alignShow:e}=i,[r,s]=_.useState(B.default),a=[{label:n.t("image-panel.align.default"),value:B.default},{options:[{label:n.t("image-panel.align.left"),value:B.left},{label:n.t("image-panel.align.center"),value:B.center},{label:n.t("image-panel.align.right"),value:B.right}]},{options:[{label:n.t("image-panel.align.top"),value:B.top},{label:n.t("image-panel.align.middle"),value:B.middle},{label:n.t("image-panel.align.bottom"),value:B.bottom}]},{options:[{label:n.t("image-panel.align.horizon"),value:B.horizon},{label:n.t("image-panel.align.vertical"),value:B.vertical}]}];function o(g){s(g),t.executeCommand(_e.id,{alignType:g})}const c=g=>g?"block":"none";return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:c(e)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.align.title")})})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn),children:l.jsx(I.Select,{value:r,options:a,onChange:o})})})]})};var K=function(){return K=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},K.apply(this,arguments)},fn=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},X=_.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,s=i.extend,a=fn(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),c=_.useRef("_".concat(wn()));return Be(n,"".concat(e),{defIds:n.defIds,idSuffix:c.current},K({ref:t,className:o},a),s)});function Be(i,t,n,e,r){return _.createElement(i.tag,K(K({key:t},pn(i,n,r)),e),(Cn(i,n).children||[]).map(function(s,a){return Be(s,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function pn(i,t,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];a==="mask"&&typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Cn(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?K(K({},r),{attrs:K(K({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function wn(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"autofill",ref:t,icon:vn}))});Ue.displayName="Autofill";var Sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ae=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"bottom-single",ref:t,icon:Sn}))});Ae.displayName="BottomSingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Le=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"create-copy-single",ref:t,icon:_n}))});Le.displayName="CreateCopySingle";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},He=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"group-single",ref:t,icon:In}))});He.displayName="GroupSingle";var yn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"more-down-single",ref:t,icon:yn}))});Ge.displayName="MoreDownSingle";var bn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},Ve=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"move-down-single",ref:t,icon:bn}))});Ve.displayName="MoveDownSingle";var Pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},ke=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"move-up-single",ref:t,icon:Pn}))});ke.displayName="MoveUpSingle";var Rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},We=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"topmost-single",ref:t,icon:Rn}))});We.displayName="TopmostSingle";var Dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},$e=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"ungroup-single",ref:t,icon:Dn}))});$e.displayName="UngroupSingle";const xn=i=>{const{arrangeShow:t,drawings:n}=i,e=V.useDependency(p.LocaleService),r=V.useDependency(M.IDrawingManagerService),s=g=>g?"block":"none",[a,o]=_.useState(n);_.useEffect(()=>{const g=r.focus$.subscribe(d=>{o(d)});return()=>{g.unsubscribe()}},[]);const c=g=>{const d=a[0].unitId,u=a[0].subUnitId,h=a.map(f=>f.drawingId);r.featurePluginOrderUpdateNotification({unitId:d,subUnitId:u,drawingIds:h,arrangeType:g})};return l.jsxs("div",{className:m.imageCommonPanelGrid,style:{display:s(t)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:e.t("image-panel.arrange.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.forward)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(ke,{}),e.t("image-panel.arrange.forward")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.backward)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Ve,{}),e.t("image-panel.arrange.backward")]})})})]}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.front)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(We,{}),e.t("image-panel.arrange.front")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.back)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Ae,{}),e.t("image-panel.arrange.back")]})})})]})]})},jn=i=>{const t=V.useDependency(p.LocaleService),n=V.useDependency(b.IRenderManagerService),e=V.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:s}=i,[a,o]=_.useState(!1),[c,g]=_.useState(!0),[d,u]=_.useState(!0),h=C=>C?"block":"none",f=()=>{const C=e.getFocusDrawings(),{unitId:P,subUnitId:y}=C[0],N=p.Tools.generateRandomId(10),R=b.getGroupState(0,0,C.map(D=>D.transform||{})),T={unitId:P,subUnitId:y,drawingId:N,drawingType:p.DrawingTypeEnum.DRAWING_GROUP,transform:R},j=C.map(D=>{const x=D.transform||{left:0,top:0},{unitId:O,subUnitId:E,drawingId:L}=D;return{unitId:O,subUnitId:E,drawingId:L,transform:{...x,left:x.left-R.left,top:x.top-R.top},groupId:N}});e.featurePluginGroupUpdateNotification([{parent:T,children:j}])},S=C=>{if(C.drawingType!==p.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:P,subUnitId:y,drawingId:N,transform:R={width:0,height:0}}=C;if(R==null)return;const T=e.getDrawingsByGroup({unitId:P,subUnitId:y,drawingId:N});if(T.length===0)return;const j=T.map(D=>{const{transform:x}=D,{unitId:O,subUnitId:E,drawingId:L}=D,A=b.transformObjectOutOfGroup(x||{},R,R.width||0,R.height||0);return{unitId:O,subUnitId:E,drawingId:L,transform:{...x,...A},groupId:void 0}});return{parent:C,children:j}},v=()=>{const P=e.getFocusDrawings().map(y=>S(y)).filter(y=>y!=null);P.length!==0&&e.featurePluginUngroupUpdateNotification(P)};return _.useEffect(()=>{const C=s[0];if(C==null)return;const{unitId:P}=C,y=n.getRenderById(P),N=y==null?void 0:y.scene;if(N==null)return;const R=N.getTransformerByCreate(),T=R.clearControl$.subscribe(D=>{D===!0&&o(!1)}),j=R.changeStart$.subscribe(D=>{const{objects:x}=D,O=ue(x,e),E=O.filter($=>($==null?void 0:$.drawingType)===p.DrawingTypeEnum.DRAWING_GROUP);let L=!1,A=!1;O.length>1&&(L=!0),E.length>0&&(A=!0),o(L||A),g(L),u(A)});return()=>{j.unsubscribe(),T.unsubscribe()}},[]),l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:h(r===!0?a:!1)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.group.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:l.jsx(I.Button,{style:{display:h(c)},onClick:f,children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(He,{}),t.t("image-panel.group.group")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:l.jsx(I.Button,{style:{display:h(d)},onClick:v,children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx($e,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ie=20,Mn=20,On=[-3600,3600],he=300,Nn=i=>{var Re;const t=V.useDependency(p.LocaleService),n=V.useDependency(M.IDrawingManagerService),e=V.useDependency(b.IRenderManagerService),{drawings:r,transformShow:s}=i,a=r[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:d,drawingType:u}=a,h=e.getRenderById(c),f=h==null?void 0:h.scene;if(f==null)return;const S=(Re=f.getEngine())==null?void 0:Re.activeScene;if(S==null)return;const v=f.getTransformerByCreate(),{width:C=0,height:P=0,left:y=0,top:N=0,angle:R=0}=o,[T,j]=_.useState(C),[D,x]=_.useState(P),[O,E]=_.useState(y),[L,A]=_.useState(N),[z,$]=_.useState(R),[se,ne]=_.useState(v.keepRatio),te=(w,U,k,W)=>{const{width:G,height:J}=S,{ancestorLeft:F,ancestorTop:Y}=f;let Z=w,re=U,le=k,ge=W;return w+F<0&&(Z=-F),U+Y<0&&(re=-Y),le=G-Z-F,le<ie&&(le=ie),ge=J-re-Y,ge<ie&&(ge=ie),w+le+F>G&&(Z=G-k-F),U+ge+Y>J&&(re=J-W-Y),{limitLeft:Z,limitTop:re,limitWidth:le,limitHeight:ge}},oe=w=>{const{objects:U}=w,k=ue(U,n);if(k.length!==1)return;const W=k[0];if(W==null)return;const{transform:G}=W;if(G==null)return;const{width:J,height:F,left:Y,top:Z,angle:re}=G;J!=null&&j(J),F!=null&&x(F),Y!=null&&E(Y),Z!=null&&A(Z),re!=null&&$(re)};_.useEffect(()=>{const w=[v.changeStart$.subscribe(U=>{oe(U)}),v.changing$.subscribe(U=>{oe(U)}),v.changeEnd$.subscribe(U=>{oe(U)}),n.focus$.subscribe(U=>{if(U.length!==1)return;const k=n.getDrawingByParam(U[0]);if(k==null)return;const W=k.transform;if(W==null)return;const{width:G,height:J,left:F,top:Y,angle:Z}=W;G!=null&&j(G),J!=null&&x(J),F!=null&&E(F),Y!=null&&A(Y),Z!=null&&$(Z)})];return()=>{w.forEach(U=>U.unsubscribe())}},[]);const q=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitWidth:U,limitHeight:k}=te(O,L,w,D);w=Math.min(w,U);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{width:w}};if(se){let G=w/T*D;if(G=Math.max(G,Mn),G>k)return;x(G),W.transform.height=G}j(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},he),Ie=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitHeight:U,limitWidth:k}=te(O,L,T,w);w=Math.min(w,U);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{height:w}};if(se){let G=w/D*T;if(G=Math.max(G,ie),G>k)return;j(G),W.transform.width=G}x(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},he),Fe=p.debounce(w=>{if(w==null)return;const{limitLeft:U}=te(w,L,T,D);w=U;const k={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{left:w}};E(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},he),Ye=p.debounce(w=>{if(w==null)return;const{limitTop:U}=te(O,w,T,D);w=U;const k={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{top:w}};A(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},he),Ze=w=>{if(w==null)return;const[U,k]=On;w<U&&(w=U),w>k&&(w=k);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{angle:w}};$(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},Xe=w=>{ne(w),v.keepRatio=w},qe=w=>w?"block":"none";return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:qe(s)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.transform.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.width")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:T,onChange:w=>{q(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.height")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:D,onChange:w=>{Ie(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.lock")})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.Checkbox,{checked:se,onChange:Xe})})})]})})]}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.x")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:O,onChange:w=>{Fe(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.y")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:L,onChange:w=>{Ye(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.rotate")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:z,onChange:Ze,className:m.imageCommonPanelInput})})})]})})]})]})},pe={id:"sheet.operation.open-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0};var H=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(H||{});const de={id:"sheet.operation.Auto-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0},En=i=>{const t=V.useDependency(p.ICommandService),n=V.useDependency(p.LocaleService),{drawings:e,cropperShow:r}=i;if(e[0]==null)return;const[a,o]=_.useState(H.FREE),c=_.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:H.FREE},{label:"1:1",value:H.R1_1},{label:"16:9",value:H.R16_9},{label:"9:16",value:H.R9_16},{label:"5:4",value:H.R5_4},{label:"4:5",value:H.R4_5},{label:"4:3",value:H.R4_3},{label:"3:4",value:H.R3_4},{label:"3:2",value:H.R3_2},{label:"2:3",value:H.R2_3}];_.useEffect(()=>{const f=t.onCommandExecuted(S=>{if(S.id===ee.id){const v=S.params;v!=null&&v.isAuto||(c.current=!1)}});return()=>{f==null||f.dispose()}},[]);function d(f){o(f),c.current&&t.executeCommand(de.id,{cropType:f})}const u=f=>f?"block":"none",h=f=>{t.executeCommand(de.id,{cropType:f}),c.current=!0};return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:u(r)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.crop.title")})})}),l.jsxs("div",{className:I.clsx(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{h(a)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Le,{}),n.t("image-panel.crop.start")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Select,{value:a,options:g,onChange:d})})]})]})},Tn=i=>{const t=V.useDependency(M.IDrawingManagerService),n=V.useDependency(b.IRenderManagerService),e=V.useDependency(p.LocaleService),{drawings:r,hasArrange:s=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=i,d=r[0];if(d==null)return;const{unitId:u}=d,h=n.getRenderById(u),f=h==null?void 0:h.scene;if(f==null)return;const S=f.getTransformerByCreate(),[v,C]=_.useState(!0),[P,y]=_.useState(!0),[N,R]=_.useState(!1),[T,j]=_.useState(!0),[D,x]=_.useState(!1);return _.useEffect(()=>{const O=S.clearControl$.subscribe(A=>{A===!0&&(C(!1),y(!1),R(!1),j(!1),x(!0))}),E=S.changeStart$.subscribe(A=>{const{objects:z}=A,$=ue(z,t);$.length===0?(C(!1),y(!1),R(!1),j(!1),x(!0)):$.length===1?(C(!0),y(!0),R(!1),j(!0),x(!1)):(C(!0),y(!1),R(!0),j(!1),x(!1))}),L=t.focus$.subscribe(A=>{A.length===0?(C(!1),y(!1),R(!1),j(!1),x(!0)):A.length===1?(C(!0),y(!0),R(!1),j(!0),x(!1)):(C(!0),y(!1),R(!0),j(!1),x(!1))});return()=>{E.unsubscribe(),O.unsubscribe(),L.unsubscribe()}},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:D===!0?"block":"none",height:"100%"},children:l.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:l.jsx("span",{children:e.t("image-panel.null")})})}),l.jsx(xn,{arrangeShow:s===!0?v:!1,drawings:r}),l.jsx(Nn,{transformShow:a===!0?P:!1,drawings:r}),l.jsx(hn,{alignShow:o===!0?N:!1,drawings:r}),l.jsx(En,{cropperShow:c===!0?T:!1,drawings:r}),l.jsx(jn,{hasGroup:g,drawings:r})]})},ze=i=>{var v;const{popup:t}=i,n=(v=t==null?void 0:t.extraProps)==null?void 0:v.menuItems;if(!n)return null;const e=V.useDependency(p.ICommandService),r=V.useDependency(p.LocaleService),[s,a]=_.useState(!1),[o,c]=_.useState(!1),g=()=>{c(!0)},d=()=>{c(!1)},u=C=>{a(C)},h=C=>{e.executeCommand(C.commandId,C.commandParams),a(!1)},f=s||o,S=n.filter(C=>!C.disable);return l.jsx("div",{onMouseEnter:g,onMouseLeave:d,children:l.jsx(I.DropdownMenu,{align:"start",items:S.map(C=>({type:"item",children:r.t(C.label),onSelect:()=>h(C)})),open:s,onOpenChange:u,children:l.jsxs("div",{className:I.clsx(`
|
|
1
|
+
"use strict";var Je=Object.defineProperty;var Qe=(i,t,n)=>t in i?Je(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var Q=(i,t,n)=>Qe(i,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@univerjs/core"),M=require("@univerjs/drawing"),b=require("@univerjs/engine-render"),V=require("@univerjs/ui"),l=require("react/jsx-runtime"),_=require("react"),I=require("@univerjs/design"),De=require("rxjs");function xe(i,t,n,e){const r=e.getDrawingByParam(i);if(r==null)return;const s=M.getDrawingShapeKeyByDrawingSearch(i),a=n.getObject(s);if(a&&!(a instanceof b.Group))return;if(a!=null){a.addObject(t);return}const o=new b.Group(s);n.addObject(o,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(t);const{transform:c}=r;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,t){var s;const n=t?i.getUnit(t):i.getFocusedUnit();if(n==null)return;const e=n.getUnitId();let r;return n.type===p.UniverInstanceType.UNIVER_SHEET?r=(s=n.getActiveSheet())==null?void 0:s.getSheetId():(n.type===p.UniverInstanceType.UNIVER_DOC||n.type===p.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Te="COMPONENT_IMAGE_VIEWER";var en=Object.getOwnPropertyDescriptor,nn=(i,t,n,e)=>{for(var r=e>1?void 0:e?en(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ye=(i,t)=>(n,e)=>t(n,e,i);const je=50;exports.DrawingRenderService=class{constructor(t,n,e){this._drawingManagerService=t,this._imageIoService=n,this._dialogService=e}async renderImages(t,n){const{transform:e,drawingType:r,source:s,imageSourceType:a,srcRect:o,prstGeom:c,groupId:g,unitId:d,subUnitId:u,drawingId:h,isMultiTransform:f,transforms:S}=t;if(r!==p.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const v=f&&S?S:[e],C=[];for(const P of v){const{left:y,top:N,width:R,height:T,angle:j,flipX:D,flipY:x,skewX:O,skewY:E}=P,L=v.indexOf(P),A=M.getDrawingShapeKeyByDrawingSearch({unitId:d,subUnitId:u,drawingId:h},f?L:void 0),z=n.getObject(A);if(z!=null){z.transformByState({left:y,top:N,width:R,height:T,angle:j,flipX:D,flipY:x,skewX:O,skewY:E});continue}const $=this._drawingManagerService.getDrawingOrder(d,u),se=$.indexOf(h),ne={...P,zIndex:se===-1?$.length-1:se},te=this._imageIoService.getImageSourceCache(s,a);let oe=!1;if(te!=null)ne.image=te;else{if(a===M.ImageSourceType.UUID)try{ne.url=await this._imageIoService.getImage(s)}catch(Ie){console.error(Ie);continue}else ne.url=s;oe=!0}if(n.getObject(A))continue;ne.printable=!0;const q=new b.Image(A,ne);oe&&this._imageIoService.addImageSourceCache(s,a,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(q),g&&xe({drawingId:g,unitId:d,subUnitId:u},q,n,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),C.push(q))}return C}renderFloatDom(t,n){const{transform:e,drawingType:r,groupId:s,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:g,transforms:d}=t;if(r!==p.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const u=g&&d?d:[e],h=[];for(const f of u){const{left:S,top:v,width:C,height:P,angle:y,flipX:N,flipY:R,skewX:T,skewY:j}=f,D=u.indexOf(f),x=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},g?D:void 0),O=n.getObject(x);if(O!=null){O.transformByState({left:S,top:v,width:C,height:P,angle:y,flipX:N,flipY:R,skewX:T,skewY:j});continue}const E=this._drawingManagerService.getDrawingOrder(a,o),L=E.indexOf(c),A={...f,zIndex:L===-1?E.length-1:L};if(n.getObject(x))continue;A.printable=!1;const z=new b.Rect(x,A);this._drawingManagerService.getDrawingVisible()&&(n.addObject(z,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.allowTransform!==!1&&n.attachTransformerTo(z),s&&xe({drawingId:s,unitId:a,subUnitId:o},z,n,this._drawingManagerService),h.push(z))}return h}renderDrawing(t,n){const e=this._drawingManagerService.getDrawingByParam(t);if(e!=null)switch(e.drawingType){case p.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const s=`${t}-viewer-dialog`,a=window.innerWidth-je,o=window.innerHeight-je,c=this._adjustImageSize(e,r,a,o),g=this._dialogService.open({width:Math.max(c.width,200),id:s,children:{label:{name:Te,props:{src:n,width:c.width,height:c.height}}},destroyOnClose:!0,closable:!1,onClose:()=>{this._dialogService.close(s),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const s=e/t,a=r/n,o=Math.min(s,a);return{width:Math.floor(t*o),height:Math.floor(n*o)}}};exports.DrawingRenderService=nn([ye(0,M.IDrawingManagerService),ye(1,M.IImageIoService),ye(2,V.IDialogService)],exports.DrawingRenderService);function ue(i,t){const n=[];return i.forEach(e=>{const{oKey:r,left:s,top:a,height:o,width:c,angle:g}=e,d=t.getDrawingOKey(r);if(d==null)return n.push(null),!0;const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v={unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:{left:s,top:a,height:o,width:c,angle:g}};S===p.DrawingTypeEnum.DRAWING_IMAGE&&(v.srcRect=e.srcRect),n.push(v)}),n}var B=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(B||{});const _e={id:"sheet.operation.set-image-align",type:p.CommandType.OPERATION,handler:(i,t)=>!0},tn="univer-image-common-panel-grid",rn="univer-image-common-panel-border",an="univer-image-common-panel-title",sn="univer-image-common-panel-row",on="univer-image-common-panel-row-vertical",cn="univer-image-common-panel-column",ln="univer-image-common-panel-column-center",gn="univer-image-common-panel-inline",mn="univer-image-common-panel-span2",dn="univer-image-common-panel-span3",un="univer-image-common-panel-input",m={imageCommonPanelGrid:tn,imageCommonPanelBorder:rn,imageCommonPanelTitle:an,imageCommonPanelRow:sn,imageCommonPanelRowVertical:on,imageCommonPanelColumn:cn,imageCommonPanelColumnCenter:ln,imageCommonPanelInline:gn,imageCommonPanelSpan2:mn,imageCommonPanelSpan3:dn,imageCommonPanelInput:un},hn=i=>{const t=V.useDependency(p.ICommandService),n=V.useDependency(p.LocaleService),{alignShow:e}=i,[r,s]=_.useState(B.default),a=[{label:n.t("image-panel.align.default"),value:B.default},{options:[{label:n.t("image-panel.align.left"),value:B.left},{label:n.t("image-panel.align.center"),value:B.center},{label:n.t("image-panel.align.right"),value:B.right}]},{options:[{label:n.t("image-panel.align.top"),value:B.top},{label:n.t("image-panel.align.middle"),value:B.middle},{label:n.t("image-panel.align.bottom"),value:B.bottom}]},{options:[{label:n.t("image-panel.align.horizon"),value:B.horizon},{label:n.t("image-panel.align.vertical"),value:B.vertical}]}];function o(g){s(g),t.executeCommand(_e.id,{alignType:g})}const c=g=>g?"block":"none";return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:c(e)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.align.title")})})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn),children:l.jsx(I.Select,{value:r,options:a,onChange:o})})})]})};var K=function(){return K=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},K.apply(this,arguments)},fn=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},X=_.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,s=i.extend,a=fn(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),c=_.useRef("_".concat(wn()));return Be(n,"".concat(e),{defIds:n.defIds,idSuffix:c.current},K({ref:t,className:o},a),s)});function Be(i,t,n,e,r){return _.createElement(i.tag,K(K({key:t},pn(i,n,r)),e),(Cn(i,n).children||[]).map(function(s,a){return Be(s,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function pn(i,t,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];a==="mask"&&typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(s){var a=s[0],o=s[1];typeof o=="string"&&(e[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Cn(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?K(K({},r),{attrs:K(K({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function wn(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"autofill",ref:t,icon:vn}))});Ue.displayName="Autofill";var Sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ae=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"bottom-single",ref:t,icon:Sn}))});Ae.displayName="BottomSingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Le=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"create-copy-single",ref:t,icon:_n}))});Le.displayName="CreateCopySingle";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},He=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"group-single",ref:t,icon:In}))});He.displayName="GroupSingle";var yn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"more-down-single",ref:t,icon:yn}))});Ge.displayName="MoreDownSingle";var bn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},Ve=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"move-down-single",ref:t,icon:bn}))});Ve.displayName="MoveDownSingle";var Pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},ke=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"move-up-single",ref:t,icon:Pn}))});ke.displayName="MoveUpSingle";var Rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},We=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"topmost-single",ref:t,icon:Rn}))});We.displayName="TopmostSingle";var Dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},$e=_.forwardRef(function(i,t){return _.createElement(X,Object.assign({},i,{id:"ungroup-single",ref:t,icon:Dn}))});$e.displayName="UngroupSingle";const xn=i=>{const{arrangeShow:t,drawings:n}=i,e=V.useDependency(p.LocaleService),r=V.useDependency(M.IDrawingManagerService),s=g=>g?"block":"none",[a,o]=_.useState(n);_.useEffect(()=>{const g=r.focus$.subscribe(d=>{o(d)});return()=>{g.unsubscribe()}},[]);const c=g=>{const d=a[0].unitId,u=a[0].subUnitId,h=a.map(f=>f.drawingId);r.featurePluginOrderUpdateNotification({unitId:d,subUnitId:u,drawingIds:h,arrangeType:g})};return l.jsxs("div",{className:m.imageCommonPanelGrid,style:{display:s(t)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:e.t("image-panel.arrange.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.forward)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(ke,{}),e.t("image-panel.arrange.forward")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.backward)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Ve,{}),e.t("image-panel.arrange.backward")]})})})]}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.front)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(We,{}),e.t("image-panel.arrange.front")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{c(p.ArrangeTypeEnum.back)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Ae,{}),e.t("image-panel.arrange.back")]})})})]})]})},jn=i=>{const t=V.useDependency(p.LocaleService),n=V.useDependency(b.IRenderManagerService),e=V.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:s}=i,[a,o]=_.useState(!1),[c,g]=_.useState(!0),[d,u]=_.useState(!0),h=C=>C?"block":"none",f=()=>{const C=e.getFocusDrawings(),{unitId:P,subUnitId:y}=C[0],N=p.Tools.generateRandomId(10),R=b.getGroupState(0,0,C.map(D=>D.transform||{})),T={unitId:P,subUnitId:y,drawingId:N,drawingType:p.DrawingTypeEnum.DRAWING_GROUP,transform:R},j=C.map(D=>{const x=D.transform||{left:0,top:0},{unitId:O,subUnitId:E,drawingId:L}=D;return{unitId:O,subUnitId:E,drawingId:L,transform:{...x,left:x.left-R.left,top:x.top-R.top},groupId:N}});e.featurePluginGroupUpdateNotification([{parent:T,children:j}])},S=C=>{if(C.drawingType!==p.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:P,subUnitId:y,drawingId:N,transform:R={width:0,height:0}}=C;if(R==null)return;const T=e.getDrawingsByGroup({unitId:P,subUnitId:y,drawingId:N});if(T.length===0)return;const j=T.map(D=>{const{transform:x}=D,{unitId:O,subUnitId:E,drawingId:L}=D,A=b.transformObjectOutOfGroup(x||{},R,R.width||0,R.height||0);return{unitId:O,subUnitId:E,drawingId:L,transform:{...x,...A},groupId:void 0}});return{parent:C,children:j}},v=()=>{const P=e.getFocusDrawings().map(y=>S(y)).filter(y=>y!=null);P.length!==0&&e.featurePluginUngroupUpdateNotification(P)};return _.useEffect(()=>{const C=s[0];if(C==null)return;const{unitId:P}=C,y=n.getRenderById(P),N=y==null?void 0:y.scene;if(N==null)return;const R=N.getTransformerByCreate(),T=R.clearControl$.subscribe(D=>{D===!0&&o(!1)}),j=R.changeStart$.subscribe(D=>{const{objects:x}=D,O=ue(x,e),E=O.filter($=>($==null?void 0:$.drawingType)===p.DrawingTypeEnum.DRAWING_GROUP);let L=!1,A=!1;O.length>1&&(L=!0),E.length>0&&(A=!0),o(L||A),g(L),u(A)});return()=>{j.unsubscribe(),T.unsubscribe()}},[]),l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:h(r===!0?a:!1)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.group.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:l.jsx(I.Button,{style:{display:h(c)},onClick:f,children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(He,{}),t.t("image-panel.group.group")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:l.jsx(I.Button,{style:{display:h(d)},onClick:v,children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx($e,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ie=20,Mn=20,On=[-3600,3600],he=300,Nn=i=>{var Re;const t=V.useDependency(p.LocaleService),n=V.useDependency(M.IDrawingManagerService),e=V.useDependency(b.IRenderManagerService),{drawings:r,transformShow:s}=i,a=r[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:d,drawingType:u}=a,h=e.getRenderById(c),f=h==null?void 0:h.scene;if(f==null)return;const S=(Re=f.getEngine())==null?void 0:Re.activeScene;if(S==null)return;const v=f.getTransformerByCreate(),{width:C=0,height:P=0,left:y=0,top:N=0,angle:R=0}=o,[T,j]=_.useState(C),[D,x]=_.useState(P),[O,E]=_.useState(y),[L,A]=_.useState(N),[z,$]=_.useState(R),[se,ne]=_.useState(v.keepRatio),te=(w,U,k,W)=>{const{width:G,height:J}=S,{ancestorLeft:F,ancestorTop:Y}=f;let Z=w,re=U,le=k,ge=W;return w+F<0&&(Z=-F),U+Y<0&&(re=-Y),le=G-Z-F,le<ie&&(le=ie),ge=J-re-Y,ge<ie&&(ge=ie),w+le+F>G&&(Z=G-k-F),U+ge+Y>J&&(re=J-W-Y),{limitLeft:Z,limitTop:re,limitWidth:le,limitHeight:ge}},oe=w=>{const{objects:U}=w,k=ue(U,n);if(k.length!==1)return;const W=k[0];if(W==null)return;const{transform:G}=W;if(G==null)return;const{width:J,height:F,left:Y,top:Z,angle:re}=G;J!=null&&j(J),F!=null&&x(F),Y!=null&&E(Y),Z!=null&&A(Z),re!=null&&$(re)};_.useEffect(()=>{const w=[v.changeStart$.subscribe(U=>{oe(U)}),v.changing$.subscribe(U=>{oe(U)}),v.changeEnd$.subscribe(U=>{oe(U)}),n.focus$.subscribe(U=>{if(U.length!==1)return;const k=n.getDrawingByParam(U[0]);if(k==null)return;const W=k.transform;if(W==null)return;const{width:G,height:J,left:F,top:Y,angle:Z}=W;G!=null&&j(G),J!=null&&x(J),F!=null&&E(F),Y!=null&&A(Y),Z!=null&&$(Z)})];return()=>{w.forEach(U=>U.unsubscribe())}},[]);const q=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitWidth:U,limitHeight:k}=te(O,L,w,D);w=Math.min(w,U);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{width:w}};if(se){let G=w/T*D;if(G=Math.max(G,Mn),G>k)return;x(G),W.transform.height=G}j(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},he),Ie=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitHeight:U,limitWidth:k}=te(O,L,T,w);w=Math.min(w,U);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{height:w}};if(se){let G=w/D*T;if(G=Math.max(G,ie),G>k)return;j(G),W.transform.width=G}x(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},he),Fe=p.debounce(w=>{if(w==null)return;const{limitLeft:U}=te(w,L,T,D);w=U;const k={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{left:w}};E(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},he),Ye=p.debounce(w=>{if(w==null)return;const{limitTop:U}=te(O,w,T,D);w=U;const k={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{top:w}};A(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},he),Ze=w=>{if(w==null)return;const[U,k]=On;w<U&&(w=U),w>k&&(w=k);const W={unitId:c,subUnitId:g,drawingId:d,drawingType:u,transform:{angle:w}};$(w),n.featurePluginUpdateNotification([W]),v.refreshControls().changeNotification()},Xe=w=>{ne(w),v.keepRatio=w},qe=w=>w?"block":"none";return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:qe(s)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.transform.title")})})}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.width")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:T,onChange:w=>{q(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.height")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:D,onChange:w=>{Ie(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.lock")})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.Checkbox,{checked:se,onChange:Xe})})})]})})]}),l.jsxs("div",{className:m.imageCommonPanelRow,children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.x")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:O,onChange:w=>{Fe(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.y")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:L,onChange:w=>{Ye(w)},className:m.imageCommonPanelInput})})})]})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.rotate")})}),l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:m.imageCommonPanelColumn,children:l.jsx(I.InputNumber,{precision:1,value:z,onChange:Ze,className:m.imageCommonPanelInput})})})]})})]})]})},pe={id:"sheet.operation.open-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0};var H=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(H||{});const de={id:"sheet.operation.Auto-image-crop",type:p.CommandType.OPERATION,handler:(i,t)=>!0},En=i=>{const t=V.useDependency(p.ICommandService),n=V.useDependency(p.LocaleService),{drawings:e,cropperShow:r}=i;if(e[0]==null)return;const[a,o]=_.useState(H.FREE),c=_.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:H.FREE},{label:"1:1",value:H.R1_1},{label:"16:9",value:H.R16_9},{label:"9:16",value:H.R9_16},{label:"5:4",value:H.R5_4},{label:"4:5",value:H.R4_5},{label:"4:3",value:H.R4_3},{label:"3:4",value:H.R3_4},{label:"3:2",value:H.R3_2},{label:"2:3",value:H.R2_3}];_.useEffect(()=>{const f=t.onCommandExecuted(S=>{if(S.id===ee.id){const v=S.params;v!=null&&v.isAuto||(c.current=!1)}});return()=>{f==null||f.dispose()}},[]);function d(f){o(f),c.current&&t.executeCommand(de.id,{cropType:f})}const u=f=>f?"block":"none",h=f=>{t.executeCommand(de.id,{cropType:f}),c.current=!0};return l.jsxs("div",{className:I.clsx(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:u(r)},children:[l.jsx("div",{className:m.imageCommonPanelRow,children:l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.crop.title")})})}),l.jsxs("div",{className:I.clsx(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:[l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Button,{onClick:()=>{h(a)},children:l.jsxs("span",{className:m.imageCommonPanelInline,children:[l.jsx(Le,{}),n.t("image-panel.crop.start")]})})}),l.jsx("div",{className:I.clsx(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:l.jsx(I.Select,{value:a,options:g,onChange:d})})]})]})},Tn=i=>{const t=V.useDependency(M.IDrawingManagerService),n=V.useDependency(b.IRenderManagerService),e=V.useDependency(p.LocaleService),{drawings:r,hasArrange:s=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=i,d=r[0];if(d==null)return;const{unitId:u}=d,h=n.getRenderById(u),f=h==null?void 0:h.scene;if(f==null)return;const S=f.getTransformerByCreate(),[v,C]=_.useState(!0),[P,y]=_.useState(!0),[N,R]=_.useState(!1),[T,j]=_.useState(!0),[D,x]=_.useState(!1);return _.useEffect(()=>{const O=S.clearControl$.subscribe(A=>{A===!0&&(C(!1),y(!1),R(!1),j(!1),x(!0))}),E=S.changeStart$.subscribe(A=>{const{objects:z}=A,$=ue(z,t);$.length===0?(C(!1),y(!1),R(!1),j(!1),x(!0)):$.length===1?(C(!0),y(!0),R(!1),j(!0),x(!1)):(C(!0),y(!1),R(!0),j(!1),x(!1))}),L=t.focus$.subscribe(A=>{A.length===0?(C(!1),y(!1),R(!1),j(!1),x(!0)):A.length===1?(C(!0),y(!0),R(!1),j(!0),x(!1)):(C(!0),y(!1),R(!0),j(!1),x(!1))});return()=>{E.unsubscribe(),O.unsubscribe(),L.unsubscribe()}},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:D===!0?"block":"none",height:"100%"},children:l.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:l.jsx("span",{children:e.t("image-panel.null")})})}),l.jsx(xn,{arrangeShow:s===!0?v:!1,drawings:r}),l.jsx(Nn,{transformShow:a===!0?P:!1,drawings:r}),l.jsx(hn,{alignShow:o===!0?N:!1,drawings:r}),l.jsx(En,{cropperShow:c===!0?T:!1,drawings:r}),l.jsx(jn,{hasGroup:g,drawings:r})]})},ze=i=>{var v;const{popup:t}=i,n=(v=t==null?void 0:t.extraProps)==null?void 0:v.menuItems;if(!n)return null;const e=V.useDependency(p.ICommandService),r=V.useDependency(p.LocaleService),[s,a]=_.useState(!1),[o,c]=_.useState(!1),g=()=>{c(!0)},d=()=>{c(!1)},u=C=>{a(C)},h=C=>{e.executeCommand(C.commandId,C.commandParams),a(!1)},f=s||o,S=n.filter(C=>!C.disable);return l.jsx("div",{onMouseEnter:g,onMouseLeave:d,children:l.jsx(I.DropdownMenu,{align:"start",items:S.map(C=>({type:"item",children:r.t(C.label),onSelect:()=>h(C)})),open:s,onOpenChange:u,children:l.jsxs("div",{className:I.clsx(`
|
|
2
2
|
univer-flex univer-items-center univer-gap-2 univer-rounded univer-border univer-border-solid
|
|
3
3
|
univer-border-gray-200 univer-p-1
|
|
4
4
|
hover:univer-bg-gray-100
|
|
5
|
-
`,{"univer-bg-gray-100":s,"univer-bg-white":!s}),children:[l.jsx(Ue,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),f&&l.jsx(Ge,{className:"univer-text-[10px] univer-text-gray-400"})]})})})},Ke="COMPONENT_IMAGE_POPUP_MENU",Bn="drawing-ui.config",Me={},Pe={id:"sheet.operation.image-reset-size",type:p.CommandType.OPERATION,handler:(i,t)=>!0},Un=i=>{const{src:t}=i;return t?l.jsx("div",{children:l.jsx("img",{src:t,alt:"Univer Image Viewer",style:{width:"100%",height:"100%",position:"relative"}})}):null};var An=Object.getOwnPropertyDescriptor,Ln=(i,t,n,e)=>{for(var r=e>1?void 0:e?An(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Oe=(i,t)=>(n,e)=>t(n,e,i);let Ce=class extends p.Disposable{constructor(i,t){super(),this._componentManager=i,this._commandService=t,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ke,ze)),this.disposeWithMe(i.register(Te,Un))}_initCommands(){[pe,ee,Pe,_e,de].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};Ce=Ln([Oe(0,p.Inject(V.ComponentManager)),Oe(1,p.ICommandService)],Ce);var Hn=Object.getOwnPropertyDescriptor,Gn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Hn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},fe=(i,t)=>(n,e)=>t(n,e,i);let we=class extends p.Disposable{constructor(t,n,e,r){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=t,this._commandService=n,this._renderManagerService=e,this._drawingManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){const t=this._drawingManagerService.drawingManagerData,n=Ee(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(s=>{Object.keys(t[s]).forEach(a=>{const o=t[s][a].data;o==null||s!==e||a!==r||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:s,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===_e.id){const n=t.params;if(n==null)return;this._drawingAlign(n)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(t=>{this._groupDrawings(t)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(t=>{this._ungroupDrawings(t)}))}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const n=this._renderManagerService.getRenderById(t),e=n==null?void 0:n.scene;if(e==null)return null;const r=e.getTransformerByCreate();return{scene:e,transformer:r}}_groupDrawings(t){t.forEach(n=>{this._groupDrawing(n)})}_groupDrawing(t){const{parent:n,children:e}=t,{unitId:r,subUnitId:s,drawingId:a}=n,o=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const d=[];if(e.forEach(f=>{const S=M.getDrawingShapeKeyByDrawingSearch(f),v=c.getObjectIncludeInGroup(S);if(v==null||d.includes(v))return;d.push(v);const{transform:C}=f;C!=null&&(v.classType===b.RENDER_CLASS_TYPE.GROUP?v.transformByState({left:C.left,top:C.top}):v.transformByState(C))}),d.length===0)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:a}),h=new b.Group(u);c.addObject(h,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(h),h.addObjects(...d),n.transform&&h.transformByState({left:n.transform.left,top:n.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(h)}_ungroupDrawings(t){t.forEach(n=>{this._ungroupDrawing(n)})}_ungroupDrawing(t){const{parent:n,children:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(r==null)return;const{scene:s,transformer:a}=r;e.forEach(u=>{const h=M.getDrawingShapeKeyByDrawingSearch(u),f=s.getObjectIncludeInGroup(h);if(f==null)return!0;if(f==null)return;const{transform:S}=u;S!=null&&(f.classType===b.RENDER_CLASS_TYPE.GROUP?f.transformByState({left:S.left,top:S.top}):f.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(n),c=s.getObject(o),{width:g,height:d}=c;c.getObjects().forEach(u=>{c.removeSelfObjectAndTransform(u.oKey,g,d)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===B.default)return;const r=[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;e.forEach(d=>{const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v=this._drawingManagerService.getDrawingByParam({unitId:u,subUnitId:h,drawingId:f});if(v==null||v.transform==null)return;r.push({unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:v.transform});const{left:C=0,top:P=0,width:y=0,height:N=0}=v.transform;s=Math.min(s,C),a=Math.min(a,P),o=Math.max(o,C+y),c=Math.max(c,P+N),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,s,a,o,c,g))}_applyAlignType(t,n,e,r,s,a,o){const c=Math.round((s-e)/o*10)/10,g=Math.round((a-r)/o*10)/10,d=[],u=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(u==null)return;const{scene:h,transformer:f}=u;t.forEach((S,v)=>{const{unitId:C,subUnitId:P,drawingId:y,transform:N,drawingType:R}=S,{left:T=0,top:j=0,width:D=0,height:x=0}=N;let O=T,E=j;switch(n){case B.left:O=e;break;case B.center:O=e+(s-e)/2-D/2;break;case B.right:O=s-D;break;case B.top:E=r;break;case B.middle:E=r+(a-r)/2-x/2;break;case B.bottom:E=a-x;break;case B.horizon:O=e+c*v;break;case B.vertical:E=r+g*v;break}(O!==T||E!==j)&&d.push({unitId:C,subUnitId:P,drawingId:y,drawingType:R,transform:{left:O,top:E}})}),this._drawingManagerService.featurePluginUpdateNotification(d),f.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const s=e.transform,a=r.transform,{left:o=0,top:c=0,width:g=0,height:d=0}=s,{left:u=0,top:h=0,width:f=0,height:S=0}=a;switch(n){case B.left:return o-u;case B.center:return o+g/2-(u+f/2);case B.right:return o+g-(u+f);case B.top:return c-h;case B.middle:return c+d/2-(h+S/2);case B.bottom:return c+d-(h+S);case B.horizon:return o+g/2-(u+f/2);case B.vertical:return c+d/2-(h+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(t=>{this._drawingArrange(t)}))}_drawingArrange(t){const{unitId:n,subUnitId:e,drawingIds:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:a}=s;r.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=a.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const d=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const u of g)u.setProps({zIndex:d}),u.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{this._insertDrawing(t)}))}_insertDrawing(t){const n=[];t.forEach(e=>{const{unitId:r}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(r);if(a==null)return;const{scene:o}=a;n.includes(o)||n.push(o)}),n.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(n=>{var d;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const u of g)u.dispose();(d=o.getTransformer())==null||d.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(n=>{var D;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._drawingManagerService.getDrawingByParam(n);if(a==null)return;const{transform:o,drawingType:c}=a,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:d,transformer:u}=g;if(o==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:C=0,flipX:P=!1,flipY:y=!1,skewX:N=0,skewY:R=0}=o,T=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),j=d.getObject(T);if(j==null)return!0;j.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:P,flipY:y,skewX:N,skewY:R}),(D=d.getTransformer())==null||D.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:c}=o,{scene:g}=a,d=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),u=g.getObject(d);if(u==null||c==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:C=0,flipX:P=!1,flipY:y=!1,skewX:N=0,skewY:R=0}=c;u.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:P,flipY:y,skewX:N,skewY:R})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s,visible:a}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=c.getObject(g);if(d==null)return!0;a?d.show():d.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:s}=e;return p.checkIfMove(s,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(p.toDisposable(n.changeStart$.subscribe(r=>{const{objects:s}=r,a=Array.from(s.values()),o=[];e=a.map(c=>{const{left:g,top:d,height:u,width:h,angle:f,oKey:S,isInGroup:v}=c,C=this._drawingManagerService.getDrawingOKey(S);if(v||c instanceof b.Group){let P=c.ancestorGroup;if(P==null&&c instanceof b.Group&&(P=c),P==null)return null;const y=this._drawingManagerService.getDrawingOKey(P.oKey);if(y){const{unitId:N,subUnitId:R,drawingId:T}=y;o.push({unitId:N,subUnitId:R,drawingId:T});const{left:j,top:D,height:x,width:O,angle:E}=P;return{left:j,top:D,height:x,width:O,angle:E}}}else if(C!=null){const{unitId:P,subUnitId:y,drawingId:N}=C;return o.push({unitId:P,subUnitId:y,drawingId:N}),{left:g,top:d,height:u,width:h,angle:f}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(p.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:s}=r,a=this._filterUpdateParams(ue(s,this._drawingManagerService),e);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};we=Gn([fe(0,p.IUniverInstanceService),fe(1,p.ICommandService),fe(2,b.IRenderManagerService),fe(3,M.IDrawingManagerService)],we);class me extends b.Shape{constructor(n,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(n,e);Q(this,"_srcRect");Q(this,"_prstGeom");Q(this,"_applyTransform");Q(this,"_dragPadding",8);Q(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(n,e){this._srcRect=n,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var n;super.dispose(),(n=this._cacheCanvas)==null||n.dispose(),this._srcRect=null}isHit(n){const e=this.getInverseCoord(n);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(n){const e=this._dragPadding;return n.x>=e-this.strokeWidth/2&&n.x<=this.width+this.strokeWidth/2-e&&n.y>=e-this.strokeWidth/2&&n.y<=this.height+this.strokeWidth/2-e}render(n,e){return this.visible?(n.save(),this._draw(n),n.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(n){var c,g;const r=this.getScene().getEngine(),{width:s,height:a}=r;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:s,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(n.getTransform()),this._clipForApplyObject(o),this._applyCache(n),o.restore())}_clipForApplyObject(n){let e=0;if(this._prstGeom!=null&&(e=1),n.globalCompositeOperation="destination-out",n.beginPath(),e===0){const r=this.transform.getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.rect(0,0,this.width,this.height),n.fill()}}_applyProps(){if(this._applyTransform==null)return;let n=0,e=0,r=0,s=0;const{left:a=0,top:o=0,width:c=0,height:g=0,angle:d}=this._applyTransform;if(this._srcRect!=null){const{left:f=0,top:S=0,right:v=0,bottom:C=0}=this._srcRect;n=f,e=S,r=v,s=C}const u=a+n,h=o+e;this.transformByState({left:u,top:h,width:a+c-r-u,height:o+g-s-h,angle:d})}_applyCache(n){if(!n||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),n.save(),n.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),n.drawImage(this._cacheCanvas.getCanvasEle(),0,0),n.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const n=this.getScene();if(n==null)return;this._cacheCanvas=new b.Canvas;const e=n.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var r;(r=this._cacheCanvas)==null||r.setSize(e.width,e.height),this.makeDirty(!0)})}}var Vn=Object.getOwnPropertyDescriptor,kn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Vn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ce=(i,t)=>(n,e)=>t(n,e,i);let ve=class extends p.Disposable{constructor(t,n,e,r,s,a){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=s,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==de.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const s=r[0],{unitId:a,subUnitId:o,drawingId:c}=s,g=this._renderManagerService.getRenderById(a),d=g==null?void 0:g.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const h=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),f=d.getObject(h);if(!(f instanceof b.Image)){this._messageService.show({type:I.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}f!=null&&(this._updateCropperObject(e,f),this._commandService.executeCommand(pe.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(t,n,e,r,s,a){const o=e/r,c=s/a;let g=e,d=r;o>c?g=r*c:d=e/c;const u=(e-g)/2,h=(r-d)/2;return{left:b.precisionTo(u,1),top:b.precisionTo(h,1),right:b.precisionTo(e-(u+g),1),bottom:b.precisionTo(r-(h+d),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:s,height:a}=n.calculateTransformWithSrcRect();let o;switch(t){case H.R1_1:o=this._calculateSrcRectByRatio(e,r,s,a,1,1);break;case H.R16_9:o=this._calculateSrcRectByRatio(e,r,s,a,16,9);break;case H.R9_16:o=this._calculateSrcRectByRatio(e,r,s,a,9,16);break;case H.R5_4:o=this._calculateSrcRectByRatio(e,r,s,a,5,4);break;case H.R4_5:o=this._calculateSrcRectByRatio(e,r,s,a,4,5);break;case H.R4_3:o=this._calculateSrcRectByRatio(e,r,s,a,4,3);break;case H.R3_4:o=this._calculateSrcRectByRatio(e,r,s,a,3,4);break;case H.R3_2:o=this._calculateSrcRectByRatio(e,r,s,a,3,2);break;case H.R2_3:o=this._calculateSrcRectByRatio(e,r,s,a,2,3);break;case H.FREE:}if(o==null)return;n.setSrcRect(o);const{left:c=0,top:g=0,bottom:d=0,right:u=0}=o;n.transformByStateCloseCropper({left:e+c,top:r+g,width:s-u-c,height:a-d-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==pe.id)return;const n=t.params;if(n==null)return;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._renderManagerService.getRenderById(e),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:s})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=o.getObject(g);if(d==null)return;if(!(d instanceof b.Image)){this._messageService.show({type:I.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const u=o.getTransformer();u==null||u.clearControls();const h=new me(`${g}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});o.addObject(h,d.getLayerIndex()+1).attachTransformerTo(h),u==null||u.createControlForCopper(h),this._addHoverForImageCopper(h),d.openRenderByCropper(),u==null||u.refreshControls(),h.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:r,drawingId:s}])}))}_searchCropObject(t){const n=t.getAllObjectsByOrder();for(const e of n)if(e instanceof me)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const r=e.getUnitId(),s=this._renderManagerService.getRenderById(r),a=s==null?void 0:s.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const g=a.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const d=this._getSrcRectByTransformState(c,o),u=this._drawingManagerService.getDrawingOKey(c.oKey);if(u!=null){const{left:h,top:f,height:S,width:v}=o;this._drawingManagerService.featurePluginUpdateNotification([{...u,transform:{...u.transform,left:h,top:f,height:S,width:v},srcRect:d.srcRectAngle}])}c.setSrcRect({...d.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(De.switchMap(n=>n?n.activeSheet$:De.of(null)));this.disposeWithMe(t.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(t){const n=t.oKey,e=n.slice(0,n.length-5),r=t.getScene();if(!r)return null;const s=r.getObject(e);return s==null?null:s}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:s}=r,a=s.values().next().value;if(a==null||!(a instanceof me))return;const{left:o,top:c,height:g,width:d,angle:u}=a;e={left:o,top:c,height:g,width:d,angle:u},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:s}=r,a=s.values().next().value;if(a==null||!(a instanceof me))return;const{left:o,top:c,height:g,width:d,angle:u}=a;if(!p.checkIfMove({left:o,top:c,height:g,width:d,angle:u},e))return;const h=this._getApplyObjectByCropObject(a);if(h==null)return;const f=this._getSrcRectByTransformState(h,a);a.refreshSrcRect(f.srcRect,h.getState()),n.createControlForCopper(a)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(t){const n=t.getTransformerByCreate();this.disposeWithMe(n.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(t,n){const{left:e,top:r,height:s,width:a,strokeWidth:o,angle:c}=n,{left:g,top:d,width:u,height:h,angle:f,strokeWidth:S}=t,v=e-g,C=r-d,P={left:v,top:C,right:u-v-a,bottom:h-C-s},y={...P};if(f!==0){const N=e+a/2,R=r+s/2,T=new b.Vector2(N,R),j=u/2+g,D=h/2+d,x=new b.Vector2(j,D),O=new b.Vector2(g,d);O.rotateByPoint(b.degToRad(f),x);const E=O.clone();E.rotateByPoint(b.degToRad(-f),T);const L=e-E.x,A=r-E.y;y.left=L,y.top=A,y.right=u-L-a,y.bottom=h-A-s}return{srcRect:P,srcRectAngle:y}}};ve=kn([ce(0,p.ICommandService),ce(1,M.IDrawingManagerService),ce(2,b.IRenderManagerService),ce(3,p.IUniverInstanceService),ce(4,V.IMessageService),ce(5,p.Inject(p.LocaleService))],ve);var Wn=Object.getOwnPropertyDescriptor,$n=(i,t,n,e)=>{for(var r=e>1?void 0:e?Wn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ae=(i,t)=>(n,e)=>t(n,e,i);let Se=class extends p.Disposable{constructor(i,t,n,e,r,s,a){super(),this._commandService=i,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=s,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Pe.id){const t=i.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const t=this._renderManagerService.getRenderById(i),n=t==null?void 0:t.scene;if(n==null)return null;const e=n.getTransformerByCreate();return{scene:n,transformer:e}}_resetImageSize(i){const t=[],n=[];i.forEach(e=>{const{unitId:r,subUnitId:s,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:a}),d=c.getObject(g);if(d==null)return!0;const u=this._drawingManagerService.getDrawingByParam(e);if(u==null)return!0;if(u.drawingType!==p.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();const{width:h,height:f}=d.getNativeSize();n.includes(c)===!1&&n.push(c),t.push({...u,transform:{...u.transform,height:f,width:h,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async t=>{var c;const{unitId:n,subUnitId:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n),s=(c=Ee(this._currentUniverService,n))==null?void 0:c.subUnitId;if(r==null||s!==e)return;const a=this._drawingManagerService.getDrawingByParam(t);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,r.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const g of o)this._addHoverForImage(g),this._addDialogForImage(g)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(t=>{const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:g,source:d,imageSourceType:u}=s;if(o!==p.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(n);if(h==null)return;const{scene:f,transformer:S}=h;if(a==null)return!0;const v=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=f.getObject(v);if(C==null)return!0;C.setSrcRect(c),C.setPrstGeom(g),d!=null&&d.length>0&&(u===p.ImageSourceType.BASE64||u===p.ImageSourceType.URL)&&C.changeSource(d)})}))}_addHoverForImage(i){this.disposeWithMe(p.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(p.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(p.toDisposable(i.onDblclick$.subscribeEvent(()=>{const t=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Se=$n([ae(0,p.ICommandService),ae(1,b.IRenderManagerService),ae(2,M.IDrawingManagerService),ae(3,V.IDialogService),ae(4,M.IImageIoService),ae(5,p.IUniverInstanceService),ae(6,p.Inject(exports.DrawingRenderService))],Se);var zn=Object.getOwnPropertyDescriptor,Kn=(i,t,n,e)=>{for(var r=e>1?void 0:e?zn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Ne=(i,t)=>(n,e)=>t(n,e,i);const Fn="UNIVER_DRAWING_UI_PLUGIN";var be;exports.UniverDrawingUIPlugin=(be=class extends p.Plugin{constructor(t=Me,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...s}=p.merge({},Me,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Bn,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(we),this._injector.get(Ce),this._injector.get(ve),this._injector.get(Se)}_initDependencies(){[[exports.DrawingRenderService],[we],[Ce],[ve],[Se]].forEach(n=>this._injector.add(n))}},Q(be,"pluginName",Fn),be);exports.UniverDrawingUIPlugin=Kn([Ne(1,p.Inject(p.Injector)),Ne(2,p.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=de;exports.COMPONENT_IMAGE_POPUP_MENU=Ke;exports.CloseImageCropOperation=ee;exports.DrawingCommonPanel=Tn;exports.ImageCropperObject=me;exports.ImagePopupMenu=ze;exports.ImageResetSizeOperation=Pe;exports.OpenImageCropOperation=pe;exports.SetDrawingAlignOperation=_e;exports.getUpdateParams=ue;
|
|
5
|
+
`,{"univer-bg-gray-100":s,"univer-bg-white":!s}),children:[l.jsx(Ue,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),f&&l.jsx(Ge,{className:"univer-text-[10px] univer-text-gray-400"})]})})})},Ke="COMPONENT_IMAGE_POPUP_MENU",Bn="drawing-ui.config",Me={},Pe={id:"sheet.operation.image-reset-size",type:p.CommandType.OPERATION,handler:(i,t)=>!0},Un=i=>{const{src:t}=i;return t?l.jsx("div",{className:"univer-py-2",children:l.jsx("img",{className:"univer-relative univer-block univer-size-full",src:t,alt:"Univer Image Viewer"})}):null};var An=Object.getOwnPropertyDescriptor,Ln=(i,t,n,e)=>{for(var r=e>1?void 0:e?An(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Oe=(i,t)=>(n,e)=>t(n,e,i);let Ce=class extends p.Disposable{constructor(i,t){super(),this._componentManager=i,this._commandService=t,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ke,ze)),this.disposeWithMe(i.register(Te,Un))}_initCommands(){[pe,ee,Pe,_e,de].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};Ce=Ln([Oe(0,p.Inject(V.ComponentManager)),Oe(1,p.ICommandService)],Ce);var Hn=Object.getOwnPropertyDescriptor,Gn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Hn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},fe=(i,t)=>(n,e)=>t(n,e,i);let we=class extends p.Disposable{constructor(t,n,e,r){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=t,this._commandService=n,this._renderManagerService=e,this._drawingManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){const t=this._drawingManagerService.drawingManagerData,n=Ee(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(s=>{Object.keys(t[s]).forEach(a=>{const o=t[s][a].data;o==null||s!==e||a!==r||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:s,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===_e.id){const n=t.params;if(n==null)return;this._drawingAlign(n)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(t=>{this._groupDrawings(t)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(t=>{this._ungroupDrawings(t)}))}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const n=this._renderManagerService.getRenderById(t),e=n==null?void 0:n.scene;if(e==null)return null;const r=e.getTransformerByCreate();return{scene:e,transformer:r}}_groupDrawings(t){t.forEach(n=>{this._groupDrawing(n)})}_groupDrawing(t){const{parent:n,children:e}=t,{unitId:r,subUnitId:s,drawingId:a}=n,o=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const d=[];if(e.forEach(f=>{const S=M.getDrawingShapeKeyByDrawingSearch(f),v=c.getObjectIncludeInGroup(S);if(v==null||d.includes(v))return;d.push(v);const{transform:C}=f;C!=null&&(v.classType===b.RENDER_CLASS_TYPE.GROUP?v.transformByState({left:C.left,top:C.top}):v.transformByState(C))}),d.length===0)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:a}),h=new b.Group(u);c.addObject(h,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(h),h.addObjects(...d),n.transform&&h.transformByState({left:n.transform.left,top:n.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(h)}_ungroupDrawings(t){t.forEach(n=>{this._ungroupDrawing(n)})}_ungroupDrawing(t){const{parent:n,children:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(r==null)return;const{scene:s,transformer:a}=r;e.forEach(u=>{const h=M.getDrawingShapeKeyByDrawingSearch(u),f=s.getObjectIncludeInGroup(h);if(f==null)return!0;if(f==null)return;const{transform:S}=u;S!=null&&(f.classType===b.RENDER_CLASS_TYPE.GROUP?f.transformByState({left:S.left,top:S.top}):f.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(n),c=s.getObject(o),{width:g,height:d}=c;c.getObjects().forEach(u=>{c.removeSelfObjectAndTransform(u.oKey,g,d)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===B.default)return;const r=[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;e.forEach(d=>{const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v=this._drawingManagerService.getDrawingByParam({unitId:u,subUnitId:h,drawingId:f});if(v==null||v.transform==null)return;r.push({unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:v.transform});const{left:C=0,top:P=0,width:y=0,height:N=0}=v.transform;s=Math.min(s,C),a=Math.min(a,P),o=Math.max(o,C+y),c=Math.max(c,P+N),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,s,a,o,c,g))}_applyAlignType(t,n,e,r,s,a,o){const c=Math.round((s-e)/o*10)/10,g=Math.round((a-r)/o*10)/10,d=[],u=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(u==null)return;const{scene:h,transformer:f}=u;t.forEach((S,v)=>{const{unitId:C,subUnitId:P,drawingId:y,transform:N,drawingType:R}=S,{left:T=0,top:j=0,width:D=0,height:x=0}=N;let O=T,E=j;switch(n){case B.left:O=e;break;case B.center:O=e+(s-e)/2-D/2;break;case B.right:O=s-D;break;case B.top:E=r;break;case B.middle:E=r+(a-r)/2-x/2;break;case B.bottom:E=a-x;break;case B.horizon:O=e+c*v;break;case B.vertical:E=r+g*v;break}(O!==T||E!==j)&&d.push({unitId:C,subUnitId:P,drawingId:y,drawingType:R,transform:{left:O,top:E}})}),this._drawingManagerService.featurePluginUpdateNotification(d),f.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const s=e.transform,a=r.transform,{left:o=0,top:c=0,width:g=0,height:d=0}=s,{left:u=0,top:h=0,width:f=0,height:S=0}=a;switch(n){case B.left:return o-u;case B.center:return o+g/2-(u+f/2);case B.right:return o+g-(u+f);case B.top:return c-h;case B.middle:return c+d/2-(h+S/2);case B.bottom:return c+d-(h+S);case B.horizon:return o+g/2-(u+f/2);case B.vertical:return c+d/2-(h+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(t=>{this._drawingArrange(t)}))}_drawingArrange(t){const{unitId:n,subUnitId:e,drawingIds:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:a}=s;r.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=a.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const d=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const u of g)u.setProps({zIndex:d}),u.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{this._insertDrawing(t)}))}_insertDrawing(t){const n=[];t.forEach(e=>{const{unitId:r}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(r);if(a==null)return;const{scene:o}=a;n.includes(o)||n.push(o)}),n.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(n=>{var d;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const u of g)u.dispose();(d=o.getTransformer())==null||d.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(n=>{var D;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._drawingManagerService.getDrawingByParam(n);if(a==null)return;const{transform:o,drawingType:c}=a,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:d,transformer:u}=g;if(o==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:C=0,flipX:P=!1,flipY:y=!1,skewX:N=0,skewY:R=0}=o,T=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),j=d.getObject(T);if(j==null)return!0;j.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:P,flipY:y,skewX:N,skewY:R}),(D=d.getTransformer())==null||D.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._getSceneAndTransformerByDrawingSearch(e);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:c}=o,{scene:g}=a,d=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),u=g.getObject(d);if(u==null||c==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:C=0,flipX:P=!1,flipY:y=!1,skewX:N=0,skewY:R=0}=c;u.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:P,flipY:y,skewX:N,skewY:R})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s,visible:a}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=c.getObject(g);if(d==null)return!0;a?d.show():d.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:s}=e;return p.checkIfMove(s,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(p.toDisposable(n.changeStart$.subscribe(r=>{const{objects:s}=r,a=Array.from(s.values()),o=[];e=a.map(c=>{const{left:g,top:d,height:u,width:h,angle:f,oKey:S,isInGroup:v}=c,C=this._drawingManagerService.getDrawingOKey(S);if(v||c instanceof b.Group){let P=c.ancestorGroup;if(P==null&&c instanceof b.Group&&(P=c),P==null)return null;const y=this._drawingManagerService.getDrawingOKey(P.oKey);if(y){const{unitId:N,subUnitId:R,drawingId:T}=y;o.push({unitId:N,subUnitId:R,drawingId:T});const{left:j,top:D,height:x,width:O,angle:E}=P;return{left:j,top:D,height:x,width:O,angle:E}}}else if(C!=null){const{unitId:P,subUnitId:y,drawingId:N}=C;return o.push({unitId:P,subUnitId:y,drawingId:N}),{left:g,top:d,height:u,width:h,angle:f}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(p.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:s}=r,a=this._filterUpdateParams(ue(s,this._drawingManagerService),e);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};we=Gn([fe(0,p.IUniverInstanceService),fe(1,p.ICommandService),fe(2,b.IRenderManagerService),fe(3,M.IDrawingManagerService)],we);class me extends b.Shape{constructor(n,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(n,e);Q(this,"_srcRect");Q(this,"_prstGeom");Q(this,"_applyTransform");Q(this,"_dragPadding",8);Q(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(n,e){this._srcRect=n,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var n;super.dispose(),(n=this._cacheCanvas)==null||n.dispose(),this._srcRect=null}isHit(n){const e=this.getInverseCoord(n);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(n){const e=this._dragPadding;return n.x>=e-this.strokeWidth/2&&n.x<=this.width+this.strokeWidth/2-e&&n.y>=e-this.strokeWidth/2&&n.y<=this.height+this.strokeWidth/2-e}render(n,e){return this.visible?(n.save(),this._draw(n),n.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(n){var c,g;const r=this.getScene().getEngine(),{width:s,height:a}=r;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:s,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(n.getTransform()),this._clipForApplyObject(o),this._applyCache(n),o.restore())}_clipForApplyObject(n){let e=0;if(this._prstGeom!=null&&(e=1),n.globalCompositeOperation="destination-out",n.beginPath(),e===0){const r=this.transform.getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.rect(0,0,this.width,this.height),n.fill()}}_applyProps(){if(this._applyTransform==null)return;let n=0,e=0,r=0,s=0;const{left:a=0,top:o=0,width:c=0,height:g=0,angle:d}=this._applyTransform;if(this._srcRect!=null){const{left:f=0,top:S=0,right:v=0,bottom:C=0}=this._srcRect;n=f,e=S,r=v,s=C}const u=a+n,h=o+e;this.transformByState({left:u,top:h,width:a+c-r-u,height:o+g-s-h,angle:d})}_applyCache(n){if(!n||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),n.save(),n.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),n.drawImage(this._cacheCanvas.getCanvasEle(),0,0),n.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const n=this.getScene();if(n==null)return;this._cacheCanvas=new b.Canvas;const e=n.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var r;(r=this._cacheCanvas)==null||r.setSize(e.width,e.height),this.makeDirty(!0)})}}var Vn=Object.getOwnPropertyDescriptor,kn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Vn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ce=(i,t)=>(n,e)=>t(n,e,i);let ve=class extends p.Disposable{constructor(t,n,e,r,s,a){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=s,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==de.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const s=r[0],{unitId:a,subUnitId:o,drawingId:c}=s,g=this._renderManagerService.getRenderById(a),d=g==null?void 0:g.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const h=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),f=d.getObject(h);if(!(f instanceof b.Image)){this._messageService.show({type:I.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}f!=null&&(this._updateCropperObject(e,f),this._commandService.executeCommand(pe.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(t,n,e,r,s,a){const o=e/r,c=s/a;let g=e,d=r;o>c?g=r*c:d=e/c;const u=(e-g)/2,h=(r-d)/2;return{left:b.precisionTo(u,1),top:b.precisionTo(h,1),right:b.precisionTo(e-(u+g),1),bottom:b.precisionTo(r-(h+d),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:s,height:a}=n.calculateTransformWithSrcRect();let o;switch(t){case H.R1_1:o=this._calculateSrcRectByRatio(e,r,s,a,1,1);break;case H.R16_9:o=this._calculateSrcRectByRatio(e,r,s,a,16,9);break;case H.R9_16:o=this._calculateSrcRectByRatio(e,r,s,a,9,16);break;case H.R5_4:o=this._calculateSrcRectByRatio(e,r,s,a,5,4);break;case H.R4_5:o=this._calculateSrcRectByRatio(e,r,s,a,4,5);break;case H.R4_3:o=this._calculateSrcRectByRatio(e,r,s,a,4,3);break;case H.R3_4:o=this._calculateSrcRectByRatio(e,r,s,a,3,4);break;case H.R3_2:o=this._calculateSrcRectByRatio(e,r,s,a,3,2);break;case H.R2_3:o=this._calculateSrcRectByRatio(e,r,s,a,2,3);break;case H.FREE:}if(o==null)return;n.setSrcRect(o);const{left:c=0,top:g=0,bottom:d=0,right:u=0}=o;n.transformByStateCloseCropper({left:e+c,top:r+g,width:s-u-c,height:a-d-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==pe.id)return;const n=t.params;if(n==null)return;const{unitId:e,subUnitId:r,drawingId:s}=n,a=this._renderManagerService.getRenderById(e),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:s})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=o.getObject(g);if(d==null)return;if(!(d instanceof b.Image)){this._messageService.show({type:I.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const u=o.getTransformer();u==null||u.clearControls();const h=new me(`${g}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});o.addObject(h,d.getLayerIndex()+1).attachTransformerTo(h),u==null||u.createControlForCopper(h),this._addHoverForImageCopper(h),d.openRenderByCropper(),u==null||u.refreshControls(),h.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:r,drawingId:s}])}))}_searchCropObject(t){const n=t.getAllObjectsByOrder();for(const e of n)if(e instanceof me)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const r=e.getUnitId(),s=this._renderManagerService.getRenderById(r),a=s==null?void 0:s.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const g=a.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const d=this._getSrcRectByTransformState(c,o),u=this._drawingManagerService.getDrawingOKey(c.oKey);if(u!=null){const{left:h,top:f,height:S,width:v}=o;this._drawingManagerService.featurePluginUpdateNotification([{...u,transform:{...u.transform,left:h,top:f,height:S,width:v},srcRect:d.srcRectAngle}])}c.setSrcRect({...d.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(De.switchMap(n=>n?n.activeSheet$:De.of(null)));this.disposeWithMe(t.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(t){const n=t.oKey,e=n.slice(0,n.length-5),r=t.getScene();if(!r)return null;const s=r.getObject(e);return s==null?null:s}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:s}=r,a=s.values().next().value;if(a==null||!(a instanceof me))return;const{left:o,top:c,height:g,width:d,angle:u}=a;e={left:o,top:c,height:g,width:d,angle:u},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:s}=r,a=s.values().next().value;if(a==null||!(a instanceof me))return;const{left:o,top:c,height:g,width:d,angle:u}=a;if(!p.checkIfMove({left:o,top:c,height:g,width:d,angle:u},e))return;const h=this._getApplyObjectByCropObject(a);if(h==null)return;const f=this._getSrcRectByTransformState(h,a);a.refreshSrcRect(f.srcRect,h.getState()),n.createControlForCopper(a)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(t){const n=t.getTransformerByCreate();this.disposeWithMe(n.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(t,n){const{left:e,top:r,height:s,width:a,strokeWidth:o,angle:c}=n,{left:g,top:d,width:u,height:h,angle:f,strokeWidth:S}=t,v=e-g,C=r-d,P={left:v,top:C,right:u-v-a,bottom:h-C-s},y={...P};if(f!==0){const N=e+a/2,R=r+s/2,T=new b.Vector2(N,R),j=u/2+g,D=h/2+d,x=new b.Vector2(j,D),O=new b.Vector2(g,d);O.rotateByPoint(b.degToRad(f),x);const E=O.clone();E.rotateByPoint(b.degToRad(-f),T);const L=e-E.x,A=r-E.y;y.left=L,y.top=A,y.right=u-L-a,y.bottom=h-A-s}return{srcRect:P,srcRectAngle:y}}};ve=kn([ce(0,p.ICommandService),ce(1,M.IDrawingManagerService),ce(2,b.IRenderManagerService),ce(3,p.IUniverInstanceService),ce(4,V.IMessageService),ce(5,p.Inject(p.LocaleService))],ve);var Wn=Object.getOwnPropertyDescriptor,$n=(i,t,n,e)=>{for(var r=e>1?void 0:e?Wn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},ae=(i,t)=>(n,e)=>t(n,e,i);let Se=class extends p.Disposable{constructor(i,t,n,e,r,s,a){super(),this._commandService=i,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=s,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Pe.id){const t=i.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const t=this._renderManagerService.getRenderById(i),n=t==null?void 0:t.scene;if(n==null)return null;const e=n.getTransformerByCreate();return{scene:n,transformer:e}}_resetImageSize(i){const t=[],n=[];i.forEach(e=>{const{unitId:r,subUnitId:s,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:a}),d=c.getObject(g);if(d==null)return!0;const u=this._drawingManagerService.getDrawingByParam(e);if(u==null)return!0;if(u.drawingType!==p.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();const{width:h,height:f}=d.getNativeSize();n.includes(c)===!1&&n.push(c),t.push({...u,transform:{...u.transform,height:f,width:h,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async t=>{var c;const{unitId:n,subUnitId:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n),s=(c=Ee(this._currentUniverService,n))==null?void 0:c.subUnitId;if(r==null||s!==e)return;const a=this._drawingManagerService.getDrawingByParam(t);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,r.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const g of o)this._addHoverForImage(g),this._addDialogForImage(g)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(t=>{const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:g,source:d,imageSourceType:u}=s;if(o!==p.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(n);if(h==null)return;const{scene:f,transformer:S}=h;if(a==null)return!0;const v=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=f.getObject(v);if(C==null)return!0;C.setSrcRect(c),C.setPrstGeom(g),d!=null&&d.length>0&&(u===p.ImageSourceType.BASE64||u===p.ImageSourceType.URL)&&C.changeSource(d)})}))}_addHoverForImage(i){this.disposeWithMe(p.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(p.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(p.toDisposable(i.onDblclick$.subscribeEvent(()=>{const t=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Se=$n([ae(0,p.ICommandService),ae(1,b.IRenderManagerService),ae(2,M.IDrawingManagerService),ae(3,V.IDialogService),ae(4,M.IImageIoService),ae(5,p.IUniverInstanceService),ae(6,p.Inject(exports.DrawingRenderService))],Se);var zn=Object.getOwnPropertyDescriptor,Kn=(i,t,n,e)=>{for(var r=e>1?void 0:e?zn(t,n):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=a(r)||r);return r},Ne=(i,t)=>(n,e)=>t(n,e,i);const Fn="UNIVER_DRAWING_UI_PLUGIN";var be;exports.UniverDrawingUIPlugin=(be=class extends p.Plugin{constructor(t=Me,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...s}=p.merge({},Me,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Bn,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(we),this._injector.get(Ce),this._injector.get(ve),this._injector.get(Se)}_initDependencies(){[[exports.DrawingRenderService],[we],[Ce],[ve],[Se]].forEach(n=>this._injector.add(n))}},Q(be,"pluginName",Fn),be);exports.UniverDrawingUIPlugin=Kn([Ne(1,p.Inject(p.Injector)),Ne(2,p.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=de;exports.COMPONENT_IMAGE_POPUP_MENU=Ke;exports.CloseImageCropOperation=ee;exports.DrawingCommonPanel=Tn;exports.ImageCropperObject=me;exports.ImagePopupMenu=ze;exports.ImageResetSizeOperation=Pe;exports.OpenImageCropOperation=pe;exports.SetDrawingAlignOperation=_e;exports.getUpdateParams=ue;
|
package/lib/es/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var Bn = (i, t, n) => t in i ? En(i, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var ee = (i, t, n) => Bn(i, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { UniverInstanceType as Oe, DrawingTypeEnum as ne, CommandType as ve, ICommandService as me, LocaleService as te, ArrangeTypeEnum as be, Tools as jn, debounce as Ie, Inject as Le, Disposable as xe, checkIfMove as sn, toDisposable as Ce, IUniverInstanceService as Ke, ImageSourceType as Xe, Injector as Un, IConfigService as An, Plugin as Hn, merge as Ln } from "@univerjs/core";
|
|
5
5
|
import { getDrawingShapeKeyByDrawingSearch as G, ImageSourceType as xn, IDrawingManagerService as re, IImageIoService as cn, SetDrawingSelectedOperation as Ne } from "@univerjs/drawing";
|
|
6
|
-
import { Group as we, DRAWING_OBJECT_LAYER_INDEX as De, Image as ze, Rect as ln, IRenderManagerService as ue, getGroupState as
|
|
7
|
-
import { IDialogService as gn, useDependency as
|
|
6
|
+
import { Group as we, DRAWING_OBJECT_LAYER_INDEX as De, Image as ze, Rect as ln, IRenderManagerService as ue, getGroupState as kn, transformObjectOutOfGroup as Vn, RENDER_CLASS_TYPE as Je, Shape as Gn, Canvas as Wn, precisionTo as ye, CURSOR_TYPE as Te, Vector2 as Ge, degToRad as qe } from "@univerjs/engine-render";
|
|
7
|
+
import { IDialogService as gn, useDependency as k, ComponentManager as $n, IMessageService as zn } from "@univerjs/ui";
|
|
8
8
|
import { jsxs as j, jsx as u, Fragment as Fn } from "react/jsx-runtime";
|
|
9
9
|
import { useState as x, forwardRef as Z, useRef as mn, createElement as X, useEffect as _e } from "react";
|
|
10
10
|
import { clsx as B, Select as dn, Button as le, InputNumber as pe, Checkbox as Kn, DropdownMenu as Yn, MessageType as Qe } from "@univerjs/design";
|
|
@@ -84,8 +84,8 @@ let Ee = class {
|
|
|
84
84
|
if (o === xn.UUID)
|
|
85
85
|
try {
|
|
86
86
|
q.url = await this._imageIoService.getImage(r);
|
|
87
|
-
} catch (
|
|
88
|
-
console.error(
|
|
87
|
+
} catch (Ve) {
|
|
88
|
+
console.error(Ve);
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
91
|
else
|
|
@@ -141,7 +141,6 @@ let Ee = class {
|
|
|
141
141
|
const r = `${i}-viewer-dialog`, o = window.innerWidth - nn, a = window.innerHeight - nn, s = this._adjustImageSize(n, e, o, a), c = this._dialogService.open({
|
|
142
142
|
width: Math.max(s.width, 200),
|
|
143
143
|
id: r,
|
|
144
|
-
style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
|
|
145
144
|
children: {
|
|
146
145
|
label: {
|
|
147
146
|
name: hn,
|
|
@@ -153,7 +152,7 @@ let Ee = class {
|
|
|
153
152
|
}
|
|
154
153
|
},
|
|
155
154
|
destroyOnClose: !0,
|
|
156
|
-
|
|
155
|
+
closable: !1,
|
|
157
156
|
onClose: () => {
|
|
158
157
|
this._dialogService.close(r), c.dispose();
|
|
159
158
|
}
|
|
@@ -177,7 +176,7 @@ Ee = qn([
|
|
|
177
176
|
We(1, cn),
|
|
178
177
|
We(2, gn)
|
|
179
178
|
], Ee);
|
|
180
|
-
function
|
|
179
|
+
function ke(i, t) {
|
|
181
180
|
const n = [];
|
|
182
181
|
return i.forEach((e) => {
|
|
183
182
|
const { oKey: r, left: o, top: a, height: s, width: c, angle: l } = e, m = t.getDrawingOKey(r);
|
|
@@ -217,7 +216,7 @@ const Ye = {
|
|
|
217
216
|
imageCommonPanelSpan3: ct,
|
|
218
217
|
imageCommonPanelInput: lt
|
|
219
218
|
}, gt = (i) => {
|
|
220
|
-
const t =
|
|
219
|
+
const t = k(me), n = k(te), { alignShow: e } = i, [r, o] = x(D.default), a = [
|
|
221
220
|
{
|
|
222
221
|
label: n.t("image-panel.align.default"),
|
|
223
222
|
value: D.default
|
|
@@ -397,7 +396,7 @@ var It = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em"
|
|
|
397
396
|
});
|
|
398
397
|
yn.displayName = "UngroupSingle";
|
|
399
398
|
const yt = (i) => {
|
|
400
|
-
const { arrangeShow: t, drawings: n } = i, e =
|
|
399
|
+
const { arrangeShow: t, drawings: n } = i, e = k(te), r = k(re), o = (l) => l ? "block" : "none", [a, s] = x(n);
|
|
401
400
|
_e(() => {
|
|
402
401
|
const l = r.focus$.subscribe((m) => {
|
|
403
402
|
s(m);
|
|
@@ -442,8 +441,8 @@ const yt = (i) => {
|
|
|
442
441
|
] })
|
|
443
442
|
] });
|
|
444
443
|
}, Pt = (i) => {
|
|
445
|
-
const t =
|
|
446
|
-
const p = e.getFocusDrawings(), { unitId: S, subUnitId: _ } = p[0], M = jn.generateRandomId(10), I =
|
|
444
|
+
const t = k(te), n = k(ue), e = k(re), { hasGroup: r, drawings: o } = i, [a, s] = x(!1), [c, l] = x(!0), [m, d] = x(!0), h = (p) => p ? "block" : "none", f = () => {
|
|
445
|
+
const p = e.getFocusDrawings(), { unitId: S, subUnitId: _ } = p[0], M = jn.generateRandomId(10), I = kn(0, 0, p.map((b) => b.transform || {})), N = {
|
|
447
446
|
unitId: S,
|
|
448
447
|
subUnitId: _,
|
|
449
448
|
drawingId: M,
|
|
@@ -477,7 +476,7 @@ const yt = (i) => {
|
|
|
477
476
|
if (N.length === 0)
|
|
478
477
|
return;
|
|
479
478
|
const P = N.map((b) => {
|
|
480
|
-
const { transform: y } = b, { unitId: R, subUnitId: O, drawingId: U } = b, T =
|
|
479
|
+
const { transform: y } = b, { unitId: R, subUnitId: O, drawingId: U } = b, T = Vn(y || {}, I, I.width || 0, I.height || 0);
|
|
481
480
|
return {
|
|
482
481
|
unitId: R,
|
|
483
482
|
subUnitId: O,
|
|
@@ -509,7 +508,7 @@ const yt = (i) => {
|
|
|
509
508
|
const I = M.getTransformerByCreate(), N = I.clearControl$.subscribe((b) => {
|
|
510
509
|
b === !0 && s(!1);
|
|
511
510
|
}), P = I.changeStart$.subscribe((b) => {
|
|
512
|
-
const { objects: y } = b, R =
|
|
511
|
+
const { objects: y } = b, R = ke(y, e), O = R.filter((W) => (W == null ? void 0 : W.drawingType) === ne.DRAWING_GROUP);
|
|
513
512
|
let U = !1, T = !1;
|
|
514
513
|
R.length > 1 && (U = !0), O.length > 0 && (T = !0), s(U || T), l(U), d(T);
|
|
515
514
|
});
|
|
@@ -531,7 +530,7 @@ const yt = (i) => {
|
|
|
531
530
|
] });
|
|
532
531
|
}, se = 20, Rt = 20, Mt = [-3600, 3600], Pe = 300, Ot = (i) => {
|
|
533
532
|
var Ze;
|
|
534
|
-
const t =
|
|
533
|
+
const t = k(te), n = k(re), e = k(ue), { drawings: r, transformShow: o } = i, a = r[0];
|
|
535
534
|
if (a == null)
|
|
536
535
|
return;
|
|
537
536
|
const s = a.transform;
|
|
@@ -549,23 +548,23 @@ const yt = (i) => {
|
|
|
549
548
|
left: _ = 0,
|
|
550
549
|
top: M = 0,
|
|
551
550
|
angle: I = 0
|
|
552
|
-
} = s, [N, P] = x(p), [b, y] = x(S), [R, O] = x(_), [U, T] = x(M), [ie, W] = x(I), [q, Se] = x(w.keepRatio), ae = (C, E, L,
|
|
551
|
+
} = s, [N, P] = x(p), [b, y] = x(S), [R, O] = x(_), [U, T] = x(M), [ie, W] = x(I), [q, Se] = x(w.keepRatio), ae = (C, E, L, V) => {
|
|
553
552
|
const { width: H, height: Q } = v, { ancestorLeft: F, ancestorTop: K } = f;
|
|
554
|
-
let Y = C, oe = E, he = L, fe =
|
|
555
|
-
return C + F < 0 && (Y = -F), E + K < 0 && (oe = -K), he = H - Y - F, he < se && (he = se), fe = Q - oe - K, fe < se && (fe = se), C + he + F > H && (Y = H - L - F), E + fe + K > Q && (oe = Q -
|
|
553
|
+
let Y = C, oe = E, he = L, fe = V;
|
|
554
|
+
return C + F < 0 && (Y = -F), E + K < 0 && (oe = -K), he = H - Y - F, he < se && (he = se), fe = Q - oe - K, fe < se && (fe = se), C + he + F > H && (Y = H - L - F), E + fe + K > Q && (oe = Q - V - K), {
|
|
556
555
|
limitLeft: Y,
|
|
557
556
|
limitTop: oe,
|
|
558
557
|
limitWidth: he,
|
|
559
558
|
limitHeight: fe
|
|
560
559
|
};
|
|
561
560
|
}, z = (C) => {
|
|
562
|
-
const { objects: E } = C, L =
|
|
561
|
+
const { objects: E } = C, L = ke(E, n);
|
|
563
562
|
if (L.length !== 1)
|
|
564
563
|
return;
|
|
565
|
-
const
|
|
566
|
-
if (
|
|
564
|
+
const V = L[0];
|
|
565
|
+
if (V == null)
|
|
567
566
|
return;
|
|
568
|
-
const { transform: H } =
|
|
567
|
+
const { transform: H } = V;
|
|
569
568
|
if (H == null)
|
|
570
569
|
return;
|
|
571
570
|
const {
|
|
@@ -594,8 +593,8 @@ const yt = (i) => {
|
|
|
594
593
|
const L = n.getDrawingByParam(E[0]);
|
|
595
594
|
if (L == null)
|
|
596
595
|
return;
|
|
597
|
-
const
|
|
598
|
-
if (
|
|
596
|
+
const V = L.transform;
|
|
597
|
+
if (V == null)
|
|
599
598
|
return;
|
|
600
599
|
const {
|
|
601
600
|
width: H,
|
|
@@ -603,7 +602,7 @@ const yt = (i) => {
|
|
|
603
602
|
left: F,
|
|
604
603
|
top: K,
|
|
605
604
|
angle: Y
|
|
606
|
-
} =
|
|
605
|
+
} = V;
|
|
607
606
|
H != null && P(H), Q != null && y(Q), F != null && O(F), K != null && T(K), Y != null && W(Y);
|
|
608
607
|
})
|
|
609
608
|
];
|
|
@@ -611,34 +610,34 @@ const yt = (i) => {
|
|
|
611
610
|
C.forEach((E) => E.unsubscribe());
|
|
612
611
|
};
|
|
613
612
|
}, []);
|
|
614
|
-
const
|
|
613
|
+
const Ve = Ie((C) => {
|
|
615
614
|
if (C == null)
|
|
616
615
|
return;
|
|
617
616
|
C = Math.max(C, se);
|
|
618
617
|
const { limitWidth: E, limitHeight: L } = ae(R, U, C, b);
|
|
619
618
|
C = Math.min(C, E);
|
|
620
|
-
const
|
|
619
|
+
const V = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { width: C } };
|
|
621
620
|
if (q) {
|
|
622
621
|
let H = C / N * b;
|
|
623
622
|
if (H = Math.max(H, Rt), H > L)
|
|
624
623
|
return;
|
|
625
|
-
y(H),
|
|
624
|
+
y(H), V.transform.height = H;
|
|
626
625
|
}
|
|
627
|
-
P(C), n.featurePluginUpdateNotification([
|
|
626
|
+
P(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
|
|
628
627
|
}, Pe), Rn = Ie((C) => {
|
|
629
628
|
if (C == null)
|
|
630
629
|
return;
|
|
631
630
|
C = Math.max(C, se);
|
|
632
631
|
const { limitHeight: E, limitWidth: L } = ae(R, U, N, C);
|
|
633
632
|
C = Math.min(C, E);
|
|
634
|
-
const
|
|
633
|
+
const V = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { height: C } };
|
|
635
634
|
if (q) {
|
|
636
635
|
let H = C / b * N;
|
|
637
636
|
if (H = Math.max(H, se), H > L)
|
|
638
637
|
return;
|
|
639
|
-
P(H),
|
|
638
|
+
P(H), V.transform.width = H;
|
|
640
639
|
}
|
|
641
|
-
y(C), n.featurePluginUpdateNotification([
|
|
640
|
+
y(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
|
|
642
641
|
}, Pe), Mn = Ie((C) => {
|
|
643
642
|
if (C == null)
|
|
644
643
|
return;
|
|
@@ -658,8 +657,8 @@ const yt = (i) => {
|
|
|
658
657
|
return;
|
|
659
658
|
const [E, L] = Mt;
|
|
660
659
|
C < E && (C = E), C > L && (C = L);
|
|
661
|
-
const
|
|
662
|
-
W(C), n.featurePluginUpdateNotification([
|
|
660
|
+
const V = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { angle: C } };
|
|
661
|
+
W(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
|
|
663
662
|
}, Dn = (C) => {
|
|
664
663
|
Se(C), w.keepRatio = C;
|
|
665
664
|
}, Tn = (C) => C ? "block" : "none";
|
|
@@ -669,7 +668,7 @@ const yt = (i) => {
|
|
|
669
668
|
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
670
669
|
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.width") }) }),
|
|
671
670
|
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: N, onChange: (C) => {
|
|
672
|
-
|
|
671
|
+
Ve(C);
|
|
673
672
|
}, className: g.imageCommonPanelInput }) }) })
|
|
674
673
|
] }) }),
|
|
675
674
|
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
@@ -717,7 +716,7 @@ const Be = {
|
|
|
717
716
|
type: ve.OPERATION,
|
|
718
717
|
handler: (i, t) => !0
|
|
719
718
|
}, Nt = (i) => {
|
|
720
|
-
const t =
|
|
719
|
+
const t = k(me), n = k(te), { drawings: e, cropperShow: r } = i;
|
|
721
720
|
if (e[0] == null)
|
|
722
721
|
return;
|
|
723
722
|
const [a, s] = x(A.FREE), c = mn(!1), l = [
|
|
@@ -796,7 +795,7 @@ const Be = {
|
|
|
796
795
|
] })
|
|
797
796
|
] });
|
|
798
797
|
}, er = (i) => {
|
|
799
|
-
const t =
|
|
798
|
+
const t = k(re), n = k(ue), e = k(te), { drawings: r, hasArrange: o = !0, hasTransform: a = !0, hasAlign: s = !0, hasCropper: c = !0, hasGroup: l = !0 } = i, m = r[0];
|
|
800
799
|
if (m == null)
|
|
801
800
|
return;
|
|
802
801
|
const { unitId: d } = m, h = n.getRenderById(d), f = h == null ? void 0 : h.scene;
|
|
@@ -807,7 +806,7 @@ const Be = {
|
|
|
807
806
|
const R = v.clearControl$.subscribe((T) => {
|
|
808
807
|
T === !0 && (p(!1), _(!1), I(!1), P(!1), y(!0));
|
|
809
808
|
}), O = v.changeStart$.subscribe((T) => {
|
|
810
|
-
const { objects: ie } = T, W =
|
|
809
|
+
const { objects: ie } = T, W = ke(ie, t);
|
|
811
810
|
W.length === 0 ? (p(!1), _(!1), I(!1), P(!1), y(!0)) : W.length === 1 ? (p(!0), _(!0), I(!1), P(!0), y(!1)) : (p(!0), _(!1), I(!0), P(!1), y(!1));
|
|
812
811
|
}), U = t.focus$.subscribe((T) => {
|
|
813
812
|
T.length === 0 ? (p(!1), _(!1), I(!1), P(!1), y(!0)) : T.length === 1 ? (p(!0), _(!0), I(!1), P(!0), y(!1)) : (p(!0), _(!1), I(!0), P(!1), y(!1));
|
|
@@ -827,7 +826,7 @@ const Be = {
|
|
|
827
826
|
var w;
|
|
828
827
|
const { popup: t } = i, n = (w = t == null ? void 0 : t.extraProps) == null ? void 0 : w.menuItems;
|
|
829
828
|
if (!n) return null;
|
|
830
|
-
const e =
|
|
829
|
+
const e = k(me), r = k(te), [o, a] = x(!1), [s, c] = x(!1), l = () => {
|
|
831
830
|
c(!0);
|
|
832
831
|
}, m = () => {
|
|
833
832
|
c(!1);
|
|
@@ -885,7 +884,14 @@ const Be = {
|
|
|
885
884
|
handler: (i, t) => !0
|
|
886
885
|
}, Bt = (i) => {
|
|
887
886
|
const { src: t } = i;
|
|
888
|
-
return t ? /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u(
|
|
887
|
+
return t ? /* @__PURE__ */ u("div", { className: "univer-py-2", children: /* @__PURE__ */ u(
|
|
888
|
+
"img",
|
|
889
|
+
{
|
|
890
|
+
className: "univer-relative univer-block univer-size-full",
|
|
891
|
+
src: t,
|
|
892
|
+
alt: "Univer Image Viewer"
|
|
893
|
+
}
|
|
894
|
+
) }) : null;
|
|
889
895
|
};
|
|
890
896
|
var jt = Object.getOwnPropertyDescriptor, Ut = (i, t, n, e) => {
|
|
891
897
|
for (var r = e > 1 ? void 0 : e ? jt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
@@ -1357,7 +1363,7 @@ let Ue = class extends xe {
|
|
|
1357
1363
|
), this.disposeWithMe(
|
|
1358
1364
|
Ce(
|
|
1359
1365
|
n.changeEnd$.subscribe((r) => {
|
|
1360
|
-
const { objects: o } = r, a = this._filterUpdateParams(
|
|
1366
|
+
const { objects: o } = r, a = this._filterUpdateParams(ke(o, this._drawingManagerService), e);
|
|
1361
1367
|
a.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(a);
|
|
1362
1368
|
})
|
|
1363
1369
|
)
|
|
@@ -1727,8 +1733,8 @@ Ae = xt([
|
|
|
1727
1733
|
de(4, zn),
|
|
1728
1734
|
de(5, Le(te))
|
|
1729
1735
|
], Ae);
|
|
1730
|
-
var
|
|
1731
|
-
for (var r = e > 1 ? void 0 : e ?
|
|
1736
|
+
var kt = Object.getOwnPropertyDescriptor, Vt = (i, t, n, e) => {
|
|
1737
|
+
for (var r = e > 1 ? void 0 : e ? kt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
1732
1738
|
(a = i[o]) && (r = a(r) || r);
|
|
1733
1739
|
return r;
|
|
1734
1740
|
}, ce = (i, t) => (n, e) => t(n, e, i);
|
|
@@ -1866,7 +1872,7 @@ let He = class extends xe {
|
|
|
1866
1872
|
);
|
|
1867
1873
|
}
|
|
1868
1874
|
};
|
|
1869
|
-
He =
|
|
1875
|
+
He = Vt([
|
|
1870
1876
|
ce(0, me),
|
|
1871
1877
|
ce(1, ue),
|
|
1872
1878
|
ce(2, re),
|
|
@@ -1924,5 +1930,5 @@ export {
|
|
|
1924
1930
|
Fe as OpenImageCropOperation,
|
|
1925
1931
|
Ye as SetDrawingAlignOperation,
|
|
1926
1932
|
on as UniverDrawingUIPlugin,
|
|
1927
|
-
|
|
1933
|
+
ke as getUpdateParams
|
|
1928
1934
|
};
|