@leafer-in/editor 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +25 -223
- package/dist/editor.esm.js +21 -219
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +26 -225
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.js +1 -1
- package/package.json +5 -5
- package/src/display/EditSelect.ts +2 -1
- package/src/display/Stroker.ts +18 -4
- package/src/index.ts +3 -2
- package/types/index.d.ts +1 -0
package/dist/editor.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as n,Line as r,Polygon as a,Group as h,Box as l,Event as c,defineKey as d,UI as g,Paint as u,Rect as f,Answer as p,Bounds as m,LeafList as v,PointHelper as b,AroundHelper as y,MathHelper as _,Matrix as w,Debug as E,PropertyEvent as k,LeafHelper as L,DataHelper as x,RenderEvent as T,getPointData as O,Creator as S,dataType as M}from"@leafer-ui/draw";import{PointerEvent as C,DragEvent as P,MoveEvent as B,ZoomEvent as R,RotateEvent as V,KeyEvent as I}from"@leafer-ui/core";const{M:H,L:D,C:z,Q:A,Z:Z,N:W,D:X,X:Y,G:F,F:G,O:U,P:N,U:j}=t,K={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case H:case D:$(t,e,i,o,1),o+=3;break;case z:$(t,e,i,o,3),o+=7;break;case A:$(t,e,i,o,2),o+=5;break;case Z:o+=1;break;case W:$(t,e,i,o,2),o+=5;break;case X:$(t,e,i,o,2),o+=9;break;case Y:$(t,e,i,o,2),o+=6;break;case F:$(t,e,i,o,2),o+=9;break;case G:$(t,e,i,o,2),o+=5;break;case U:t[o]=F,t.splice(o+4,0,t[o+3],0),$(t,e,i,o,2),o+=9,n+=2;break;case N:t[o]=G,t.splice(o+4,0,t[o+3]),$(t,e,i,o,2),o+=5,n+=1;break;case j:$(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,r=o?n+2*o:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:$}=K,q=e.get(),{topLeft:Q,top:J,topRight:tt,right:et,bottom:it,left:st}=i;function ot(t,e,i){t.pathInputed?rt(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function nt(t,e,i){const{app:s}=t,o=s&&s.editor;let n=e;if(o.editing){const s=t.__layout;let{width:r,height:a}=s.boxBounds;switch(r*=i-e,a*=e-i,o.resizeDirection){case J:case it:n=i,s.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case st:case et:s.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case Q:case tt:s.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__;r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function rt(t,e,i){K.scale(t.__.path,e,i),t.path=t.__.path}function at(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):K.scalePoints(s,e,i),t.points=s}function ht(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)q.a=e,q.d=i,s[t].transform(q,!0)}const lt=s.prototype;function ct(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function dt(t){return t?t instanceof Array?t:[t]:[]}lt.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},lt.__scaleResize=function(t,e){ot(this,t,e)},lt.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},lt.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?nt(this,t,e):ot(this,t,e)},n.prototype.__scaleResize=function(t,e){rt(this,t,e)},r.prototype.__scaleResize=function(t,e){this.pathInputed?rt(this,t,e):this.points?at(this,t,e):this.width*=t},a.prototype.__scaleResize=function(t,e){this.pathInputed?rt(this,t,e):this.points?at(this,t,e):ot(this,t,e)},h.prototype.__scaleResize=function(t,e){ht(this,t,e)},l.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?ht(this,t,e):(ot(this,t,e),this.__.resizeChildren&&ht(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class gt extends c{get list(){return dt(this.value)}get oldList(){return dt(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}gt.SELECT="editor.select",gt.HOVER="editor.hover";class ut extends gt{constructor(t,e){super(t,e)}}ut.MOVE="editor.move";class ft extends gt{constructor(t,e){super(t,e)}}ft.SCALE="editor.scale";class pt extends gt{constructor(t,e){super(t,e)}}pt.ROTATE="editor.rotate";class mt extends gt{constructor(t,e){super(t,e)}}function vt(t){return(e,i)=>{const s="_"+i;d(e,i,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}mt.SKEW="editor.skew";const bt=e.get(),{abs:yt}=Math,{copy:_t,scale:wt}=e;class Et extends g{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:n,strokeWidth:r,fill:a}=o,{bounds:h}=e;for(let l=0;l<i.length;l++){s=i[l];const{worldTransform:c,worldRenderBounds:d}=s;if(h&&h.hit(d,e.matrix)){const i=yt(c.scaleX),h=yt(c.scaleY);if(i!==h){_t(bt,c),wt(bt,1/i,1/h),t.setWorld(bt,e.matrix),t.beginPath(),o.strokeWidth=r;const{x:n,y:a,width:l,height:d}=s.__layout.boxBounds;t.rect(n*i,a*h,l*i,d*h)}else t.setWorld(c,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),o.strokeWidth=r/yt(c.scaleX);n&&("string"==typeof n?u.stroke(n,this,t):u.strokes(n,this,t)),a&&("string"==typeof a?u.fill(a,this,t):u.fills(a,this,t))}}o.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}ct([vt((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],Et.prototype,"target",void 0);class kt extends h{constructor(t){super(t),this.strokeArea=new f({strokeAlign:"center"}),this.fillArea=new f,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:Lt,Yes:xt,NoAndSkip:Tt,YesAndSkip:Ot}=p,St={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?Ot:Tt;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?Ot:Lt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return xt}return Lt}return t.isBranch?Tt:Lt}},{findOne:Mt}=St;class Ct extends h{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new Et,this.targetStroker=new Et,this.bounds=new m,this.selectArea=new kt,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInnerPoint(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new v(e.app.find(St.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!Mt(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new v(this.editor.editBox.rect)};return Mt(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Mt(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(gt.HOVER,this.onHover,this),t.on_(gt.SELECT,this.onSelect,this),e.on_(C.MOVE,this.onPointerMove,this),e.on_(C.BEFORE_DOWN,this.onBeforeDown,this),e.on_(C.TAP,this.onTap,this),e.on_(P.START,this.onDragStart,this,!0),e.on_(P.DRAG,this.onDrag,this),e.on_(P.END,this.onDragEnd,this),e.on_(B.MOVE,this.onAutoMove,this),e.on_([R.ZOOM,B.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Pt,top:Bt,topRight:Rt,right:Vt,bottomRight:It,bottom:Ht,bottomLeft:Dt,left:zt}=i,{toPoint:At}=y,{within:Zt}=_,Wt={getScaleData(t,e,i,s,o,n,r,a){let h,l={},c=1,d=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,y=v<0?-1:1,_=b<0?-1:1,w=a?v:y*g.width/p,E=a?b:_*g.height/m;s.x*=a?v:y,s.y*=a?b:_,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const k=(-s.y+m)/m,L=(s.x+p)/p,x=(s.y+m)/m,T=(-s.x+p)/p;switch(i){case Bt:d=k,h="bottom";break;case Vt:c=L,h="left";break;case Ht:d=x,h="top";break;case zt:c=T,h="right";break;case Pt:d=k,c=T,h="bottom-right";break;case Rt:d=k,c=L,h="bottom-left";break;case It:d=x,c=L,h="top-left";break;case Dt:d=x,c=T,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case Bt:case Ht:t=d;break;case zt:case Vt:t=c;break;default:t=Math.sqrt(Math.abs(c*d))}c=c<0?-t:t,d=d<0?-t:t}}if(c/=w,d/=E,!r){const{worldTransform:e}=t;c<0&&(c=1/g.width/e.scaleX),d<0&&(d=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;c=Zt(e*c,u)/e}if(f){const e=g.height*t.scaleY;d=Zt(e*d,f)/e}return At(n||h,g,l,!0),{origin:l,scaleX:c,scaleY:d,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case Pt:n="bottom-right";break;case Rt:n="bottom-left";break;case It:n="top-left";break;case Dt:n="top-right";break;default:n="center"}return At(o||n,t,r,!0),{origin:r,rotation:b.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case Bt:n={x:.5,y:0},o="bottom",a=1;break;case Ht:n={x:.5,y:1},o="top",a=1;break;case zt:n={x:0,y:.5},o="right",h=1;break;case Vt:n={x:1,y:.5},o="left",h=1}const{width:l,height:c}=t;n.x=n.x*l,n.y=n.y*c,At(s||o,t,r,!0);const d=b.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-d:h=d,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case zt:t=Vt;break;case Pt:t=Rt;break;case Dt:t=It;break;case Vt:t=zt;break;case Rt:t=Pt;break;case It:t=Dt}if(i)switch(t){case Bt:t=Ht;break;case Pt:t=Dt;break;case Rt:t=It;break;case Ht:t=Bt;break;case Dt:t=Pt;break;case It:t=Rt}return t}},Xt={};function Yt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:a,resizeable:h,rotateable:l,skewable:c}=t.mergeConfig,{pointType:d}=s,{flippedX:g,flippedY:u}=i;let f="resize"===d;f&&l&&(e.metaKey||e.ctrlKey||!h)&&(f=!1);const p=c&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(Wt.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(_.formatRotation(o,!0)/2);const{url:m,x:v,y:b}=p,y=m+o;Xt[y]?s.cursor=Xt[y]:Xt[y]=s.cursor={url:Gt(m,o),x:v,y:b}}function Ft(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function Gt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Ut extends l{}const Nt=["top","right","bottom","left"];class jt extends h{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new h,this.rect=new l({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Ut({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new h({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:a,circle:h,buttons:l}=this,c=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Ut({name:"rotate-point",around:c[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Ut({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Ut({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,h,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:c,resizeable:d,rotateable:g,hideOnSmall:u}=e,f="number"==typeof u?u:10,p=!(u&&i<f&&s<f);let m,v,b,_={};for(let o=0;o<8;o++)y.toPoint(y.directionData[o],t,_),v=a[o],m=h[o],b=l[Math.floor(o/2)],v.set(_),m.set(_),b.set(_),v.visible=b.visible=p&&!(!d&&!g),m.visible=p&&g&&d&&!e.rotatePoint,o%2&&(v.visible=m.visible=p&&!!c,(o+1)/2%2?(b.width=i,v.width>i-30&&(v.visible=!1)):(b.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));n.visible=p&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=p&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=Nt.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=Nt.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?Wt.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n,offsetX:0,offsetY:0};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),Yt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof o))||t.find((t=>t instanceof o));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,this.onDrag,this),t.on_(P.END,this.onDragEnd,this),t.on_(C.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(C.ENTER,(e=>{this.enterPoint=t,Yt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(gt.SELECT,this.onSelect,this),t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,e.onMove,e),t.on_(P.END,this.onDragEnd,this),t.on_(C.ENTER,(()=>Ft(e))),t.on_(C.DOUBLE_TAP,this.onDoubleTap,this),t.on_(C.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class Kt extends g{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:o}=i.editBox,{width:n,height:r}=o.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const $t='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',qt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${$t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${$t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${$t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},Qt=new m;function Jt(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(Qt.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),s.add(e)}const te=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),ee=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),ie={group(t,e,i){t.sort(ee);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new h(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(te);const r=new w(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch&&!t.isBranchLeaf){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(te),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(ee),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},se=E.get("EditToolCreator");function oe(){return t=>{re.register(t)}}const ne=oe,re={list:{},register(t){const{tag:e}=t.prototype;ae[e]&&se.repeat(e),ae[e]=t},get:(t,e)=>new ae[t](e)},{list:ae}=re;class he extends gt{constructor(t,e){super(t,e)}}he.BEFORE_OPEN="innerEditor.before_open",he.OPEN="innerEditor.open",he.BEFORE_CLOSE="innerEditor.before_close",he.CLOSE="innerEditor.close";class le extends gt{constructor(t,e){super(t,e)}}le.GROUP="editor.group",le.BEFORE_UNGROUP="editor.before_ungroup",le.UNGROUP="editor.ungroup",le.OPEN="editor.open_group",le.CLOSE="editor.close_group";const{updateMatrix:ce}=L,de={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},ge="top-left";class ue extends f{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(k.CHANGE,(e=>{if(this.checkChange&&de[e.attrName]){const{attrName:i,newValue:s,oldValue:o}=e,n="s"===i[0]?(s||1)/(o||1):(s||0)-(o||0);this.canChange=!1;const r=this.__;r[i]=o,ce(this.parent),ce(this);const a=new w(this.__world);switch(r[i]=s,this.__layout.rotationChange(),ce(this),this.changedTransform=new w(this.__world).divide(a),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf(ge,n);break;case"scaleX":t.scaleOf(ge,n,1);break;case"scaleY":t.scaleOf(ge,1,n);break;case"skewX":t.skewOf(ge,n,0);break;case"skewY":t.skewOf(ge,0,n)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class fe extends h{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=x.clone(qt),this.leafList=new v,this.openedGroupList=new v,this.simulateTarget=new ue(this),this.editBox=new jt(this),this.editToolList={},this.selector=new Ct(this),this.editMask=new Kt(this),this.targetEventIds=[],t&&(this.config=x.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Jt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||re.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof B){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(P.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof R)"zoom"===o&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=Wt.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,Wt.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof V){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=Wt.getRotateData(a.boxBounds,n,t.getBoxPoint(a),a.getBoxPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=_.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,_.float(l,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=Wt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Wt.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const o=new ut(ut.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new ft(ft.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.scaleOf(t,e,i))))),a=new ft(ft.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new w(L.getFlipTransform(e,t)),o=new ft(ft.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new pt(pt.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.skewOf(t,e,i))))),a=new mt(mt.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(L.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new w(e.worldTransform);return t(),new w(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=ie.group(this.list,this.element,t),this.emitGroupEvent(le.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(le.BEFORE_UNGROUP,t))),this.target=ie.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(le.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(le.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(le.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!L.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new le(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&re.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||re.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(he.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(he.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(he.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(he.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new he(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(ie.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(ie.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(T.START,this.update,this),t.on_(T.CHILD_START,this.forceRender,this),t.on_(B.BEFORE_MOVE,this.onMove,this,!0),t.on_(R.BEFORE_ZOOM,this.onScale,this,!0),t.on_(V.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([I.HOLD,I.UP],(t=>{Yt(this,t)})),t.on_(I.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}ct([vt((function(t,e){t.emitEvent(new gt(gt.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],fe.prototype,"hoverTarget",void 0),ct([vt((function(t,e){const{target:i}=t;i?t.leafList=i instanceof v?i:new v(i):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new gt(gt.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&Jt(t),Ft(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],fe.prototype,"target",void 0);class pe{static registerInnerEditor(){re.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new h,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let me=class extends pe{static registerEditTool(){re.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:c}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:c}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};me=ct([oe()],me);const{left:ve,right:be}=i,{move:ye,copy:_e,toNumberPoints:we}=b;let Ee=class extends me{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===ve;if(n.pathInputed){const{path:t}=n.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,n.points=t}else{const t=O(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=we(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(ye(t,n,r),s&&ye(e,-n,-r)):(s&&ye(t,-n,-r),ye(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),_e(s[7],i),_e(e[7],i),_e(s[3],a),_e(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===ve||t===be,s[t].visible=a,e[t].visible=!r&&a}};Ee=ct([oe()],Ee),S.editor=function(t){return new fe(t)},M(!1)(l.prototype,"textBox"),d(g.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),d(g.prototype,"editInner",{get:()=>"PathEditor"}),d(h.prototype,"editInner",{get:()=>""}),d(o.prototype,"editInner",{get:()=>"TextEditor"}),g.setEditConfig=function(t){d(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},g.setEditOuter=function(t){d(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},g.setEditInner=function(t){d(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{jt as EditBox,Wt as EditDataHelper,Ut as EditPoint,Ct as EditSelect,St as EditSelectHelper,me as EditTool,re as EditToolCreator,fe as Editor,gt as EditorEvent,le as EditorGroupEvent,ie as EditorHelper,ut as EditorMoveEvent,pt as EditorRotateEvent,ft as EditorScaleEvent,mt as EditorSkewEvent,pe as InnerEditor,he as InnerEditorEvent,Ee as LineEditTool,K as PathScaler,kt as SelectArea,Et as Stroker,oe as registerEditTool,ne as registerInnerEditor,ot as scaleResize,nt as scaleResizeFontSize,ht as scaleResizeGroup,rt as scaleResizePath,at as scaleResizePoints};
|
|
1
|
+
export*from"@leafer-in/resize";import{Event as t,defineKey as e,getMatrixData as i,getBoundsData as s,UI as o,Paint as n,MatrixHelper as r,BoundsHelper as a,LeafBoundsHelper as h,Group as l,Rect as d,Answer as c,Bounds as g,LeafList as u,PointHelper as f,AroundHelper as p,MathHelper as m,Direction9 as v,Box as b,Text as y,Matrix as w,Debug as E,PropertyEvent as L,LeafHelper as k,DataHelper as _,RenderEvent as x,getPointData as T,Creator as O,dataType as M}from"@leafer-ui/draw";import{PointerEvent as S,DragEvent as P,MoveEvent as C,ZoomEvent as V,RotateEvent as B,KeyEvent as H}from"@leafer-ui/core";function I(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function R(t){return t?t instanceof Array?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class D extends t{get list(){return R(this.value)}get oldList(){return R(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}D.SELECT="editor.select",D.HOVER="editor.hover";class A extends D{constructor(t,e){super(t,e)}}A.MOVE="editor.move";class Z extends D{constructor(t,e){super(t,e)}}Z.SCALE="editor.scale";class z extends D{constructor(t,e){super(t,e)}}z.ROTATE="editor.rotate";class W extends D{constructor(t,e){super(t,e)}}function F(t){return(i,s)=>{const o="_"+s;e(i,s,{get(){return this[o]},set(e){const i=this[o];i!==e&&(this[o]=e,t(this,i))}})}}W.SKEW="editor.skew";const{abs:Y}=Math,{copy:X,scale:G}=r,{setListWithFn:U}=a,{worldBounds:N}=h,j=i(),K=s();class $ extends o{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(U(K,t,N),this.set(K)):this.width=this.height=1}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:r,strokeWidth:a,fill:h}=o,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:g}=s;if(!l||l.hit(g,e.matrix)){const i=Y(c.scaleX),l=Y(c.scaleY);if(i!==l){X(j,c),G(j,1/i,1/l),t.setWorld(j,e.matrix),t.beginPath(),o.strokeWidth=a;const{x:n,y:r,width:h,height:d}=s.__layout.boxBounds;t.rect(n*i,r*l,h*i,d*l)}else t.setWorld(c,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),o.strokeWidth=a/Y(c.scaleX);r&&("string"==typeof r?n.stroke(r,this,t):n.strokes(r,this,t)),h&&("string"==typeof h?n.fill(h,this,t):n.fills(h,this,t))}}o.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}I([F((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],$.prototype,"target",void 0);class q extends l{constructor(t){super(t),this.strokeArea=new d({strokeAlign:"center"}),this.fillArea=new d,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:J,Yes:Q,NoAndSkip:tt,YesAndSkip:et}=c,it={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?et:tt;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?et:J;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Q}return J}return t.isBranch?tt:J}},{findOne:st}=it;class ot extends l{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new $,this.targetStroker=new $,this.bounds=new g,this.selectArea=new q,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInnerPoint(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new u(e.app.find(it.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!st(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new u(this.editor.editBox.rect)};return st(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):st(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(D.HOVER,this.onHover,this),t.on_(D.SELECT,this.onSelect,this),e.on_(S.MOVE,this.onPointerMove,this),e.on_(S.BEFORE_DOWN,this.onBeforeDown,this),e.on_(S.TAP,this.onTap,this),e.on_(P.START,this.onDragStart,this,!0),e.on_(P.DRAG,this.onDrag,this),e.on_(P.END,this.onDragEnd,this),e.on_(C.MOVE,this.onAutoMove,this),e.on_([V.ZOOM,C.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:nt,top:rt,topRight:at,right:ht,bottomRight:lt,bottom:dt,bottomLeft:ct,left:gt}=v,{toPoint:ut}=p,{within:ft}=m,pt={getScaleData(t,e,i,s,o,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,y=v<0?-1:1,w=b<0?-1:1,E=a?v:y*g.width/p,L=a?b:w*g.height/m;s.x*=a?v:y,s.y*=a?b:w,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const k=(-s.y+m)/m,_=(s.x+p)/p,x=(s.y+m)/m,T=(-s.x+p)/p;switch(i){case rt:c=k,h="bottom";break;case ht:d=_,h="left";break;case dt:c=x,h="top";break;case gt:d=T,h="right";break;case nt:c=k,d=T,h="bottom-right";break;case at:c=k,d=_,h="bottom-left";break;case lt:c=x,d=_,h="top-left";break;case ct:c=x,d=T,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case rt:case dt:t=c;break;case gt:case ht:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=E,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=ft(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=ft(e*c,f)/e}return ut(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case nt:n="bottom-right";break;case at:n="bottom-left";break;case lt:n="top-left";break;case ct:n="top-right";break;default:n="center"}return ut(o||n,t,r,!0),{origin:r,rotation:f.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case rt:n={x:.5,y:0},o="bottom",a=1;break;case dt:n={x:.5,y:1},o="top",a=1;break;case gt:n={x:0,y:.5},o="right",h=1;break;case ht:n={x:1,y:.5},o="left",h=1}const{width:l,height:d}=t;n.x=n.x*l,n.y=n.y*d,ut(s||o,t,r,!0);const c=f.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case gt:t=ht;break;case nt:t=at;break;case ct:t=lt;break;case ht:t=gt;break;case at:t=nt;break;case lt:t=ct}if(i)switch(t){case rt:t=dt;break;case nt:t=ct;break;case at:t=lt;break;case dt:t=rt;break;case ct:t=nt;break;case lt:t=at}return t}},mt={};function vt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:a,resizeable:h,rotateable:l,skewable:d}=t.mergeConfig,{pointType:c}=s,{flippedX:g,flippedY:u}=i;let f="resize"===c;f&&l&&(e.metaKey||e.ctrlKey||!h)&&(f=!1);const p=d&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(pt.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(m.formatRotation(o,!0)/2);const{url:v,x:b,y:y}=p,w=v+o;mt[w]?s.cursor=mt[w]:mt[w]=s.cursor={url:yt(v,o),x:b,y:y}}function bt(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function yt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class wt extends b{}const Et=["top","right","bottom","left"];class Lt extends l{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new l,this.rect=new b({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new wt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new l({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new wt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new wt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new wt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,h,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=e,f="number"==typeof u?u:10,m=!(u&&i<f&&s<f);let v,b,y,w={};for(let o=0;o<8;o++)p.toPoint(p.directionData[o],t,w),b=a[o],v=h[o],y=l[Math.floor(o/2)],b.set(w),v.set(w),y.set(w),b.visible=y.visible=m&&!(!c&&!g),v.visible=m&&g&&c&&!e.rotatePoint,o%2&&(b.visible=v.visible=m&&!!d,(o+1)/2%2?(y.width=i,b.width>i-30&&(b.visible=!1)):(y.height=s,b.rotation=90,b.width>s-30&&(b.visible=!1)));n.visible=m&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=m&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=Et.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=Et.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?pt.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n,offsetX:0,offsetY:0};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),vt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof y))||t.find((t=>t instanceof y));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,this.onDrag,this),t.on_(P.END,this.onDragEnd,this),t.on_(S.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(S.ENTER,(e=>{this.enterPoint=t,vt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(D.SELECT,this.onSelect,this),t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,e.onMove,e),t.on_(P.END,this.onDragEnd,this),t.on_(S.ENTER,(()=>bt(e))),t.on_(S.DOUBLE_TAP,this.onDoubleTap,this),t.on_(S.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class kt extends o{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:o}=i.editBox,{width:n,height:r}=o.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const _t='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',xt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${_t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${_t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${_t}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},Tt=new g;function Ot(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(Tt.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),s.add(e)}const Mt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),St=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Pt={group(t,e,i){t.sort(St);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new l(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(Mt);const r=new w(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch&&!t.isBranchLeaf){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(Mt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(St),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Ct=E.get("EditToolCreator");function Vt(){return t=>{Ht.register(t)}}const Bt=Vt,Ht={list:{},register(t){const{tag:e}=t.prototype;It[e]&&Ct.repeat(e),It[e]=t},get:(t,e)=>new It[t](e)},{list:It}=Ht;class Rt extends D{constructor(t,e){super(t,e)}}Rt.BEFORE_OPEN="innerEditor.before_open",Rt.OPEN="innerEditor.open",Rt.BEFORE_CLOSE="innerEditor.before_close",Rt.CLOSE="innerEditor.close";class Dt extends D{constructor(t,e){super(t,e)}}Dt.GROUP="editor.group",Dt.BEFORE_UNGROUP="editor.before_ungroup",Dt.UNGROUP="editor.ungroup",Dt.OPEN="editor.open_group",Dt.CLOSE="editor.close_group";const{updateMatrix:At}=k,Zt={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},zt="top-left";class Wt extends d{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(L.CHANGE,(e=>{if(this.checkChange&&Zt[e.attrName]){const{attrName:i,newValue:s,oldValue:o}=e,n="s"===i[0]?(s||1)/(o||1):(s||0)-(o||0);this.canChange=!1;const r=this.__;r[i]=o,At(this.parent),At(this);const a=new w(this.__world);switch(r[i]=s,this.__layout.rotationChange(),At(this),this.changedTransform=new w(this.__world).divide(a),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf(zt,n);break;case"scaleX":t.scaleOf(zt,n,1);break;case"scaleY":t.scaleOf(zt,1,n);break;case"skewX":t.skewOf(zt,n,0);break;case"skewY":t.skewOf(zt,0,n)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Ft extends l{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=_.clone(xt),this.leafList=new u,this.openedGroupList=new u,this.simulateTarget=new Wt(this),this.editBox=new Lt(this),this.editToolList={},this.selector=new ot(this),this.editMask=new kt(this),this.targetEventIds=[],t&&(this.config=_.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Ot(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||Ht.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof C){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(P.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof V)"zoom"===o&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=pt.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,pt.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof B){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=pt.getRotateData(a.boxBounds,n,t.getBoxPoint(a),a.getBoxPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=m.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,m.float(l,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=pt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),pt.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const o=new A(A.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new Z(Z.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.scaleOf(t,e,i))))),a=new Z(Z.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new w(k.getFlipTransform(e,t)),o=new Z(Z.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new z(z.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.skewOf(t,e,i))))),a=new W(W.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(k.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new w(e.worldTransform);return t(),new w(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=Pt.group(this.list,this.element,t),this.emitGroupEvent(Dt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Dt.BEFORE_UNGROUP,t))),this.target=Pt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Dt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Dt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Dt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!k.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Dt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&Ht.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||Ht.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(Rt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Rt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Rt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Rt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Rt(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Pt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Pt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(x.START,this.update,this),t.on_(x.CHILD_START,this.forceRender,this),t.on_(C.BEFORE_MOVE,this.onMove,this,!0),t.on_(V.BEFORE_ZOOM,this.onScale,this,!0),t.on_(B.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([H.HOLD,H.UP],(t=>{vt(this,t)})),t.on_(H.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}I([F((function(t,e){t.emitEvent(new D(D.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Ft.prototype,"hoverTarget",void 0),I([F((function(t,e){const{target:i}=t;i?t.leafList=i instanceof u?i:new u(i):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new D(D.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&Ot(t),bt(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Ft.prototype,"target",void 0);class Yt{static registerInnerEditor(){Ht.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new l,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let Xt=class extends Yt{static registerEditTool(){Ht.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};Xt=I([Vt()],Xt);const{left:Gt,right:Ut}=v,{move:Nt,copy:jt,toNumberPoints:Kt}=f;let $t=class extends Xt{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===Gt;if(n.pathInputed){const{path:t}=n.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,n.points=t}else{const t=T(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=Kt(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(Nt(t,n,r),s&&Nt(e,-n,-r)):(s&&Nt(t,-n,-r),Nt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),jt(s[7],i),jt(e[7],i),jt(s[3],a),jt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Gt||t===Ut,s[t].visible=a,e[t].visible=!r&&a}};$t=I([Vt()],$t),O.editor=function(t){return new Ft(t)},M(!1)(b.prototype,"textBox"),e(o.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),e(o.prototype,"editInner",{get:()=>"PathEditor"}),e(l.prototype,"editInner",{get:()=>""}),e(y.prototype,"editInner",{get:()=>"TextEditor"}),o.setEditConfig=function(t){e(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},o.setEditOuter=function(t){e(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},o.setEditInner=function(t){e(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{Lt as EditBox,pt as EditDataHelper,wt as EditPoint,ot as EditSelect,it as EditSelectHelper,Xt as EditTool,Ht as EditToolCreator,Ft as Editor,D as EditorEvent,Dt as EditorGroupEvent,Pt as EditorHelper,A as EditorMoveEvent,z as EditorRotateEvent,Z as EditorScaleEvent,W as EditorSkewEvent,Yt as InnerEditor,Rt as InnerEditorEvent,$t as LineEditTool,q as SelectArea,$ as Stroker,Vt as registerEditTool,Bt as registerInnerEditor};
|
package/dist/editor.js
CHANGED
|
@@ -1,219 +1,7 @@
|
|
|
1
1
|
this.LeaferIN = this.LeaferIN || {};
|
|
2
|
-
this.LeaferIN.editor = (function (exports, draw, core) {
|
|
2
|
+
this.LeaferIN.editor = (function (exports, resize, draw, core) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = draw.PathCommandMap;
|
|
6
|
-
const PathScaler = {
|
|
7
|
-
scale(data, scaleX, scaleY) {
|
|
8
|
-
if (!data)
|
|
9
|
-
return;
|
|
10
|
-
let command;
|
|
11
|
-
let i = 0, len = data.length;
|
|
12
|
-
while (i < len) {
|
|
13
|
-
command = data[i];
|
|
14
|
-
switch (command) {
|
|
15
|
-
case M:
|
|
16
|
-
case L:
|
|
17
|
-
scalePoints(data, scaleX, scaleY, i, 1);
|
|
18
|
-
i += 3;
|
|
19
|
-
break;
|
|
20
|
-
case C:
|
|
21
|
-
scalePoints(data, scaleX, scaleY, i, 3);
|
|
22
|
-
i += 7;
|
|
23
|
-
break;
|
|
24
|
-
case Q:
|
|
25
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
26
|
-
i += 5;
|
|
27
|
-
break;
|
|
28
|
-
case Z:
|
|
29
|
-
i += 1;
|
|
30
|
-
break;
|
|
31
|
-
case N:
|
|
32
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
33
|
-
i += 5;
|
|
34
|
-
break;
|
|
35
|
-
case D:
|
|
36
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
37
|
-
i += 9;
|
|
38
|
-
break;
|
|
39
|
-
case X:
|
|
40
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
41
|
-
i += 6;
|
|
42
|
-
break;
|
|
43
|
-
case G:
|
|
44
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
45
|
-
i += 9;
|
|
46
|
-
break;
|
|
47
|
-
case F:
|
|
48
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
49
|
-
i += 5;
|
|
50
|
-
break;
|
|
51
|
-
case O:
|
|
52
|
-
data[i] = G;
|
|
53
|
-
data.splice(i + 4, 0, data[i + 3], 0);
|
|
54
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
55
|
-
i += 7 + 2;
|
|
56
|
-
len += 2;
|
|
57
|
-
break;
|
|
58
|
-
case P:
|
|
59
|
-
data[i] = F;
|
|
60
|
-
data.splice(i + 4, 0, data[i + 3]);
|
|
61
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
62
|
-
i += 4 + 1;
|
|
63
|
-
len += 1;
|
|
64
|
-
break;
|
|
65
|
-
case U:
|
|
66
|
-
scalePoints(data, scaleX, scaleY, i, 2);
|
|
67
|
-
i += 6;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
scalePoints(data, scaleX, scaleY, start, pointCount) {
|
|
73
|
-
for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
|
|
74
|
-
data[i] *= scaleX;
|
|
75
|
-
data[i + 1] *= scaleY;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const { scalePoints } = PathScaler;
|
|
80
|
-
|
|
81
|
-
const matrix$1 = draw.MatrixHelper.get();
|
|
82
|
-
const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = draw.Direction9;
|
|
83
|
-
function scaleResize(leaf, scaleX, scaleY) {
|
|
84
|
-
if (leaf.pathInputed) {
|
|
85
|
-
scaleResizePath(leaf, scaleX, scaleY);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
if (scaleX !== 1)
|
|
89
|
-
leaf.width *= scaleX;
|
|
90
|
-
if (scaleY !== 1)
|
|
91
|
-
leaf.height *= scaleY;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function scaleResizeFontSize(leaf, scaleX, scaleY) {
|
|
95
|
-
const { app } = leaf;
|
|
96
|
-
const editor = app && app.editor;
|
|
97
|
-
let fontScale = scaleX;
|
|
98
|
-
if (editor.editing) {
|
|
99
|
-
const layout = leaf.__layout;
|
|
100
|
-
let { width, height } = layout.boxBounds;
|
|
101
|
-
width *= scaleY - scaleX;
|
|
102
|
-
height *= scaleX - scaleY;
|
|
103
|
-
switch (editor.resizeDirection) {
|
|
104
|
-
case top$1:
|
|
105
|
-
case bottom$1:
|
|
106
|
-
fontScale = scaleY;
|
|
107
|
-
layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
|
|
108
|
-
break;
|
|
109
|
-
case left$2:
|
|
110
|
-
case right$2:
|
|
111
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
|
|
112
|
-
break;
|
|
113
|
-
case topLeft$1:
|
|
114
|
-
case topRight$1:
|
|
115
|
-
layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
leaf.fontSize *= fontScale;
|
|
120
|
-
const data = leaf.__;
|
|
121
|
-
if (!data.__autoWidth)
|
|
122
|
-
leaf.width *= fontScale;
|
|
123
|
-
if (!data.__autoHeight)
|
|
124
|
-
leaf.height *= fontScale;
|
|
125
|
-
}
|
|
126
|
-
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
127
|
-
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
128
|
-
leaf.path = leaf.__.path;
|
|
129
|
-
}
|
|
130
|
-
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
131
|
-
const { points } = leaf;
|
|
132
|
-
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
133
|
-
leaf.points = points;
|
|
134
|
-
}
|
|
135
|
-
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
136
|
-
const { children } = group;
|
|
137
|
-
for (let i = 0; i < children.length; i++) {
|
|
138
|
-
matrix$1.a = scaleX;
|
|
139
|
-
matrix$1.d = scaleY;
|
|
140
|
-
children[i].transform(matrix$1, true);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const leaf = draw.Leaf.prototype;
|
|
145
|
-
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
146
|
-
const data = this;
|
|
147
|
-
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
148
|
-
data.scaleX *= scaleX;
|
|
149
|
-
data.scaleY *= scaleY;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (scaleX < 0)
|
|
153
|
-
data.scaleX *= -1, scaleX = -scaleX;
|
|
154
|
-
if (scaleY < 0)
|
|
155
|
-
data.scaleY *= -1, scaleY = -scaleY;
|
|
156
|
-
this.__scaleResize(scaleX, scaleY);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
160
|
-
scaleResize(this, scaleX, scaleY);
|
|
161
|
-
};
|
|
162
|
-
leaf.resizeWidth = function (width) {
|
|
163
|
-
const scale = width / this.getBounds('box', 'local').width;
|
|
164
|
-
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
165
|
-
};
|
|
166
|
-
leaf.resizeHeight = function (height) {
|
|
167
|
-
const scale = height / this.getBounds('box', 'local').height;
|
|
168
|
-
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
169
|
-
};
|
|
170
|
-
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
171
|
-
if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
|
|
172
|
-
scaleResizeFontSize(this, scaleX, scaleY);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
scaleResize(this, scaleX, scaleY);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
draw.Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
179
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
180
|
-
};
|
|
181
|
-
draw.Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
182
|
-
if (this.pathInputed) {
|
|
183
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
184
|
-
}
|
|
185
|
-
else if (this.points) {
|
|
186
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
this.width *= scaleX;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
draw.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
193
|
-
if (this.pathInputed) {
|
|
194
|
-
scaleResizePath(this, scaleX, scaleY);
|
|
195
|
-
}
|
|
196
|
-
else if (this.points) {
|
|
197
|
-
scaleResizePoints(this, scaleX, scaleY);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
scaleResize(this, scaleX, scaleY);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
draw.Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
204
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
205
|
-
};
|
|
206
|
-
draw.Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
207
|
-
if (this.__.__autoSize && this.children.length) {
|
|
208
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
scaleResize(this, scaleX, scaleY);
|
|
212
|
-
if (this.__.resizeChildren)
|
|
213
|
-
scaleResizeGroup(this, scaleX, scaleY);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
5
|
/******************************************************************************
|
|
218
6
|
Copyright (c) Microsoft Corporation.
|
|
219
7
|
|
|
@@ -300,9 +88,12 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
300
88
|
};
|
|
301
89
|
}
|
|
302
90
|
|
|
303
|
-
const matrix = draw.MatrixHelper.get();
|
|
304
91
|
const { abs } = Math;
|
|
305
92
|
const { copy: copy$1, scale } = draw.MatrixHelper;
|
|
93
|
+
const { setListWithFn } = draw.BoundsHelper;
|
|
94
|
+
const { worldBounds } = draw.LeafBoundsHelper;
|
|
95
|
+
const matrix = draw.getMatrixData();
|
|
96
|
+
const bounds$1 = draw.getBoundsData();
|
|
306
97
|
class Stroker extends draw.UI {
|
|
307
98
|
constructor() {
|
|
308
99
|
super();
|
|
@@ -313,6 +104,17 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
313
104
|
setTarget(target, style) {
|
|
314
105
|
this.set(style);
|
|
315
106
|
this.target = target;
|
|
107
|
+
this.update();
|
|
108
|
+
}
|
|
109
|
+
update() {
|
|
110
|
+
const { list } = this;
|
|
111
|
+
if (list.length) {
|
|
112
|
+
setListWithFn(bounds$1, list, worldBounds);
|
|
113
|
+
this.set(bounds$1);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.width = this.height = 1;
|
|
117
|
+
}
|
|
316
118
|
}
|
|
317
119
|
__draw(canvas, options) {
|
|
318
120
|
const { list } = this;
|
|
@@ -322,7 +124,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
322
124
|
for (let i = 0; i < list.length; i++) {
|
|
323
125
|
leaf = list[i];
|
|
324
126
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
325
|
-
if (bounds
|
|
127
|
+
if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
|
|
326
128
|
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
327
129
|
if (aScaleX !== aScaleY) {
|
|
328
130
|
copy$1(matrix, worldTransform);
|
|
@@ -362,7 +164,6 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
362
164
|
function onTarget$1(stroker) {
|
|
363
165
|
const value = stroker.target;
|
|
364
166
|
stroker.list = value ? (value instanceof Array ? value : [value]) : [];
|
|
365
|
-
stroker.forceUpdate();
|
|
366
167
|
}
|
|
367
168
|
|
|
368
169
|
class SelectArea extends draw.Group {
|
|
@@ -447,8 +248,8 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
447
248
|
}
|
|
448
249
|
}
|
|
449
250
|
update() {
|
|
450
|
-
|
|
451
|
-
|
|
251
|
+
this.hoverStroker.update();
|
|
252
|
+
this.targetStroker.update();
|
|
452
253
|
}
|
|
453
254
|
onPointerMove(e) {
|
|
454
255
|
const { app, editor } = this;
|
|
@@ -2117,17 +1918,17 @@ ${filterStyle}
|
|
|
2117
1918
|
exports.EditorSkewEvent = EditorSkewEvent;
|
|
2118
1919
|
exports.InnerEditor = InnerEditor;
|
|
2119
1920
|
exports.InnerEditorEvent = InnerEditorEvent;
|
|
2120
|
-
exports.PathScaler = PathScaler;
|
|
2121
1921
|
exports.SelectArea = SelectArea;
|
|
2122
1922
|
exports.Stroker = Stroker;
|
|
2123
1923
|
exports.registerEditTool = registerEditTool;
|
|
2124
1924
|
exports.registerInnerEditor = registerInnerEditor;
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
1925
|
+
Object.keys(resize).forEach(function (k) {
|
|
1926
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1927
|
+
enumerable: true,
|
|
1928
|
+
get: function () { return resize[k]; }
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
2130
1931
|
|
|
2131
1932
|
return exports;
|
|
2132
1933
|
|
|
2133
|
-
})({}, LeaferUI, LeaferUI);
|
|
1934
|
+
})({}, LeaferIN.resize, LeaferUI, LeaferUI);
|