2 lines
5.9 KiB
JavaScript
2 lines
5.9 KiB
JavaScript
import{u as te}from"./chartEditStore-bfc6c223.js";import{u as re}from"./useSync.hook-dcdbd18a.js";import{bd as ne,g as se,aa as n,cH as D,cI as $,cJ as U,bq as g,b4 as L}from"./index-4ec2ce15.js";var G={exports:{}};(function(i){(function(c){var s,o={},m={16:!1,18:!1,17:!1,91:!1},P="all",v={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,command:91},W={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":189,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220},A=function(e){return W[e]||e.toUpperCase().charCodeAt(0)},T=[];for(s=1;s<20;s++)W["f"+s]=111+s;function O(e,t){for(var r=e.length;r--;)if(e[r]===t)return r;return-1}function F(e,t){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}var N={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey"};function x(e){for(s in m)m[s]=e[N[s]]}function B(e){var t,r,a,R,w,K;if(t=e.keyCode,O(T,t)==-1&&T.push(t),(t==93||t==224)&&(t=91),t in m){m[t]=!0;for(a in v)v[a]==t&&(E[a]=!0);return}if(x(e),!!E.filter.call(this,e)&&t in o){for(K=C(),R=0;R<o[t].length;R++)if(r=o[t][R],r.scope==K||r.scope=="all"){w=r.mods.length>0;for(a in m)(!m[a]&&O(r.mods,+a)>-1||m[a]&&O(r.mods,+a)==-1)&&(w=!1);(r.mods.length==0&&!m[16]&&!m[18]&&!m[17]&&!m[91]||w)&&r.method(e,r)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}}function z(e){var t=e.keyCode,r,a=O(T,t);if(a>=0&&T.splice(a,1),(t==93||t==224)&&(t=91),t in m){m[t]=!1;for(r in v)v[r]==t&&(E[r]=!1)}}function Y(){for(s in m)m[s]=!1;for(s in v)E[s]=!1}function E(e,t,r){var a,R;a=_(e),r===void 0&&(r=t,t="all");for(var w=0;w<a.length;w++)R=[],e=a[w].split("+"),e.length>1&&(R=M(e),e=[e[e.length-1]]),e=e[0],e=A(e),e in o||(o[e]=[]),o[e].push({shortcut:a[w],scope:t,method:r,key:a[w],mods:R})}function j(e,t){var r,a,R=[],w,K,S;for(r=_(e),K=0;K<r.length;K++){if(a=r[K].split("+"),a.length>1&&(R=M(a),e=a[a.length-1]),e=A(e),t===void 0&&(t=C()),!o[e])return;for(w=0;w<o[e].length;w++)S=o[e][w],S.scope===t&&F(S.mods,R)&&(o[e][w]={})}}function q(e){return typeof e=="string"&&(e=A(e)),O(T,e)!=-1}function J(){return T.slice(0)}function X(e){var t=(e.target||e.srcElement).tagName;return!(t=="INPUT"||t=="SELECT"||t=="TEXTAREA")}for(s in v)E[s]=!1;function Q(e){P=e||"all"}function C(){return P||"all"}function Z(e){var t,r,a;for(t in o)for(r=o[t],a=0;a<r.length;)r[a].scope===e?r.splice(a,1):a++}function _(e){var t;return e=e.replace(/\s/g,""),t=e.split(","),t[t.length-1]==""&&(t[t.length-2]+=","),t}function M(e){for(var t=e.slice(0,e.length-1),r=0;r<t.length;r++)t[r]=v[t[r]];return t}function b(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent&&e.attachEvent("on"+t,function(){r(window.event)})}b(document,"keydown",function(e){B(e)}),b(document,"keyup",z),b(window,"focus",Y);var V=c.key;function ee(){var e=c.key;return c.key=V,e}c.key=E,c.key.setScope=Q,c.key.getScope=C,c.key.deleteScope=Z,c.key.filter=X,c.key.isPressed=q,c.key.getPressedKeyCodes=J,c.key.noConflict=ee,c.key.unbind=j,i.exports=E})(ne)})(G);var oe=G.exports;const f=se(oe),h=te(),ae=re(),p=i=>`${D.CTRL}+${i}`,k=i=>`${D.SHIFT}+${i}`,l={[n.ARROW_UP]:p("up"),[n.ARROW_RIGHT]:p("right"),[n.ARROW_DOWN]:p("down"),[n.ARROW_LEFT]:p("left"),[n.COPY]:p("c"),[n.CUT]:p("x"),[n.PARSE]:p("v"),[n.DELETE]:"delete",[n.BACK]:p("z"),[n.FORWORD]:p(k("z")),[n.SAVE]:p("s"),[n.GROUP]:p("g"),[n.UN_GROUP]:p(k("g")),[n.LOCK]:p("l"),[n.UNLOCK]:p(k("l")),[n.HIDE]:p("h"),[n.SHOW]:p(k("h"))},d=i=>`${$.CTRL}+${i}`,y=i=>`${$.SHIFT}+${i}`,u={[n.ARROW_UP]:d("arrowup"),[n.ARROW_RIGHT]:d("arrowright"),[n.ARROW_DOWN]:d("arrowdown"),[n.ARROW_LEFT]:d("arrowleft"),[n.COPY]:d("c"),[n.CUT]:d("x"),[n.PARSE]:d("v"),[n.DELETE]:d("backspace"),[n.BACK]:d("z"),[n.FORWORD]:d(y("z")),[n.SAVE]:d("s"),[n.GROUP]:d("g"),[n.UN_GROUP]:d(y("g")),[n.LOCK]:d("l"),[n.UNLOCK]:d(y("l")),[n.HIDE]:d("h"),[n.SHOW]:d(y("h"))},H=[l.up,l.right,l.down,l.left,l.delete,l.copy,l.cut,l.parse,l.back,l.forward,l.save,l.group,l.unGroup,l.lock,l.unLock,l.hide,l.show],I=[u.up,u.right,u.down,u.left,u.delete,u.copy,u.cut,u.parse,u.back,u.forward,u.save,u.group,u.unGroup,u.lock,u.unLock,u.hide,u.show],ie=()=>{window.$KeyboardActive={ctrl:!1,space:!1},document.onkeydown=i=>{const{keyCode:c}=i;if(c==32&&i.target==document.body&&i.preventDefault(),[17,32].includes(c)&&window.$KeyboardActive)switch(U(i.keyCode),c){case 17:window.$KeyboardActive.ctrl=!0;break;case 32:window.$KeyboardActive.space=!0;break}},document.onkeyup=i=>{const{keyCode:c}=i;if(c==32&&i.target==document.body&&i.preventDefault(),[17,32].includes(c)&&window.$KeyboardActive)switch(U(),c){case 17:window.$KeyboardActive.ctrl=!1;break;case 32:window.$KeyboardActive.space=!1;break}}},ue=()=>{const c=(s,o)=>{switch(o){case s.up:f(o,g(()=>(h.setMove(n.ARROW_UP),!1),50));break;case s.right:f(o,g(()=>(h.setMove(n.ARROW_RIGHT),!1),50));break;case s.down:f(o,g(()=>(h.setMove(n.ARROW_DOWN),!1),50));break;case s.left:f(o,g(()=>(h.setMove(n.ARROW_LEFT),!1),50));break;case s.delete:f(o,L(()=>(h.removeComponentList(),!1),50));break;case s.copy:f(o,L(()=>(h.setCopy(),!1),50));break;case s.cut:f(o,L(()=>(h.setCut(),!1),50));break;case s.parse:f(o,g(()=>(h.setParse(),!1),50));break;case s.back:f(o,g(()=>(h.setBack(),!1),50));break;case s.forward:f(o,g(()=>(h.setForward(),!1),50));break;case s.group:f(o,g(()=>(h.setGroup(),!1),50));break;case s.unGroup:f(o,g(()=>(h.setUnGroup(),!1),50));break;case s.lock:f(o,g(()=>(h.setLock(),!1),50));break;case s.unLock:f(o,g(()=>(h.setUnLock(),!1),50));break;case s.hide:f(o,g(()=>(h.setHide(),!1),50));break;case s.show:f(o,g(()=>(h.setShow(),!1),50));break;case s.save:f(o,g(()=>(ae.dataSyncUpdate(),!1),200));break}};H.forEach(s=>{c(l,s)}),I.forEach(s=>{c(u,s)}),ie()},de=()=>{document.onkeydown=()=>{},document.onkeyup=()=>{},H.forEach(i=>{f.unbind(i)}),I.forEach(i=>{f.unbind(i)})};export{ue as a,de as u};
|