|
|
import{c as Y,s as _,ah as Be,d as De,t as oe,o as R,f as j,w as Ce,M as xe,b as F,F as _e,r as Ze,n as Q,av as Wt,aw as Vt,g as ne,u as E,k as Re,h as W,j as Ie,v as ze,S as Ht,e as le,Q as Ft,y as ke,z as Me,p as Je,P as Pe,W as Ot,q as qt,m as qe,a as jt}from"./index-bVOhw2NF.js";import{u as Ut,_ as Gt,a as Kt}from"./vue-repl-jaFwbjhK.js";import{_ as Qt,u as Zt}from"./codemirror-editor-CFwWTn8s.js";import{G as Jt}from"./GridRect-B5GXph4N.js";import{u as We,a as en}from"./editor-ouq_SSv2.js";import"./helpers-CjmtV6uB.js";import{i as et,e as Ee}from"./common-CalHcBJp.js";import{f as tn,i as nn,j as on,k as an,c as sn}from"./index-C8mAaM2V.js";import{p as je,T as rn,o as ln}from"./style-D4sssT3k.js";function un(o,n){const e=Y(()=>{var l;return((l=o.value.container)==null?void 0:l.scaleRatio)||100}),t=_();function s(l){let v=!1;o.value.elements.forEach(x=>{x.selected&&(x.selected=!1,v=!0)}),t.value=!1,v||n.value.onMouseDown(l)}function c(l){for(let v=0;v<o.value.elements.length;v++){const x=o.value.elements[v],i=l.left<x.left&&l.left+l.width>x.left+x.width,k=l.top<x.top&&l.top+l.height>x.top+x.height;i&&k?x.selected=!0:x.selected=!1}}function p(){t.value=o.value.elements.some(l=>l.selected),t.value&&setTimeout(()=>{document.addEventListener("click",()=>{t.value=!1},{once:!0})})}function a(l,v){if(!v)return;const x=l.target,{clientX:i,clientY:k}=l,{left:h,top:m}=x.getBoundingClientRect(),f=i-h,M=k-m,d=f/(e.value/100),g=M/(e.value/100),r=et({name:"es-text",nameCn:"输入文本",dataMap:!1,isRemote:!1});r.left=d,r.top=g,r.props.options={text:"",inputingText:!0,link:"","font-family":"Microsoft Yahei",color:"#1890ff","font-size":20,"font-weight":"normal",paddingX:2,paddingY:2,"justify-content":"start","writing-mode":"horizontal-tb","letter-spacing":2,"border-width":0,"border-color":"#ffffff","border-radius":2,"background-color":"#CD171700",textFormat:"",gradientFontColor:"",valueColor:"",valueNumberConfig:!1,wanFormat:!1,valueDecimal:2,textEditable:!0},r.height=50,r.width=150,r.selected=!0,o.value.elements.push(r),setTimeout(()=>{const w=document.getElementById(r.id).querySelector(".val-widget");w&&w.focus()},200)}return{areaSelected:t,onEditorMouseDown:s,onAreaMove:c,onAreaUp:p,onAreaClick:a}}function Ve(){const o=_(!1);return Be(document,"keydown",n=>{n.code==="Space"&&(o.value=!0)}),Be(document,"keyup",n=>{n.code==="Space"&&(o.value=!1)}),o}function cn(o){const n=Ve(),e=document.querySelector(o);Be(e,"mousedown",a);let t=0,s=0,c=!1;const p={left:0,top:0};function a(x){p.left=e.scrollLeft,p.top=e.scrollTop,e.addEventListener("mousemove",l),e.addEventListener("mouseup",v),t=x.clientX,s=x.clientY,c=!0}function l(x){if(c&&n.value){const i=x.clientX-t,k=x.clientY-s;e.scrollTo({left:p.left-i,top:p.top-k})}}function v(){c=!1,e.removeEventListener("mousemove",l),e.removeEventListener("mouseup",v)}}function dn(o,n,e,t){const s=document.querySelector(o);let c=!1,p={},a={},l=[],v=null;function x(d){t.value&&(c?(clearTimeout(v),v=setTimeout(()=>{if(c=!0,d.ctrlKey||(a={x:d.offsetX,y:d.offsetY}),p.x===a.x&&p.y===a.y){clearTimeout(v),k();return}l.push({start:p,end:a}),p=a,f()},100)):v=setTimeout(()=>{c=!0,p={x:d.offsetX,y:d.offsetY},a={x:d.offsetX,y:d.offsetY},m()},100),s.addEventListener("mousemove",i),s.addEventListener("dblclick",h))}function i(d){if(c){if(d.ctrlKey){const g=[0,45,90,180,270,360];a={x:d.offsetX,y:d.offsetY};const r=a.x-p.x,y=a.y-p.y;let w=Math.atan2(y,r)*180/Math.PI;w<0&&(w+=360);let C=0;for(const X of g)(!C||Math.abs(w-X)<Math.abs(w-C))&&(C=X);const L=Math.sqrt(r*r+y*y),$=C*Math.PI/180;a.x=p.x+L*Math.cos($),a.y=p.y+L*Math.sin($)}else a={x:d.offsetX,y:d.offsetY};m()}}function k(){c=!1,p={},a={};const d=[];l.forEach((r,y)=>{y===0?d.push({x:r.start.x,y:r.start.y}):d.push({x:r.end.x,y:r.end.y})}),n(d),l=[],v=null;const g=s.querySelector(".pathContainer");s.removeChild(g),s.removeEventListener("mousemove",i),s.removeEventListener("dblclick",h),t.value=!1}function h(){clearTimeout(v),k()}function m(){const d=s.querySelector(".pathContainer");if(!d)M();else{const g=d.querySelector("path");let r="";if(l.length===0)r=`M${p.x}
|