@zh-keyboard/vue 1.0.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/components/HandwritingInput.vue.d.ts +0 -1
- package/dist/components/ZhKeyboard.vue.d.ts +77 -10
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/zh-keyboard-vue.js +638 -603
- package/dist/zh-keyboard-vue.js.map +1 -1
- package/dist/zh-keyboard-vue.umd.cjs +1 -1
- package/dist/zh-keyboard-vue.umd.cjs.map +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.ZhKeyboardVue={},E.Vue))})(this,function(E,e){"use strict";var Tt=Object.defineProperty;var Ht=(E,e,_)=>e in E?Tt(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>Ht(E,typeof e!="symbol"?e+"":e,_);function _(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}const ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const de=n=>n!=null,ce=Object.prototype.toString,fe=n=>ce.call(n)==="[object Object]",F=()=>{};function ue(n,o){function r(...a){return new Promise((l,i)=>{Promise.resolve(n(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(l).catch(i)})}return r}function me(n,o={}){let r,a,l=F;const i=u=>{clearTimeout(u),l(),l=F};let c;return u=>{const y=e.toValue(n),g=e.toValue(o.maxWait);return r&&i(r),y<=0||g!==void 0&&g<=0?(a&&(i(a),a=null),Promise.resolve(u())):new Promise((d,k)=>{l=o.rejectOnCancel?k:d,c=u,g&&!a&&(a=setTimeout(()=>{r&&i(r),a=null,d(c())},g)),r=setTimeout(()=>{a&&i(a),a=null,d(u())},y)})}}function T(n){return Array.isArray(n)?n:[n]}function pe(n){return e.getCurrentInstance()}function ke(n,o=200,r={}){return ue(me(o,r),n)}function he(n,o=!0,r){pe()?e.onMounted(n,r):o?n():e.nextTick(n)}function ge(n,o,r){return e.watch(n,o,{...r,immediate:!0})}const M=ae?window:void 0;function N(n){var o;const r=e.toValue(n);return(o=r==null?void 0:r.$el)!=null?o:r}function H(...n){const o=[],r=()=>{o.forEach(m=>m()),o.length=0},a=(m,u,y,g)=>(m.addEventListener(u,y,g),()=>m.removeEventListener(u,y,g)),l=e.computed(()=>{const m=T(e.toValue(n[0])).filter(u=>u!=null);return m.every(u=>typeof u!="string")?m:void 0}),i=ge(()=>{var m,u;return[(u=(m=l.value)==null?void 0:m.map(y=>N(y)))!=null?u:[M].filter(y=>y!=null),T(e.toValue(l.value?n[1]:n[0])),T(e.unref(l.value?n[2]:n[1])),e.toValue(l.value?n[3]:n[2])]},([m,u,y,g])=>{if(r(),!(m!=null&&m.length)||!(u!=null&&u.length)||!(y!=null&&y.length))return;const d=fe(g)?{...g}:g;o.push(...m.flatMap(k=>u.flatMap(f=>y.map(p=>a(k,f,p,d)))))},{flush:"post"}),c=()=>{i(),r()};return _(r),c}function ye(){const n=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{n.value=!0},o),n}function X(n){const o=ye();return e.computed(()=>(o.value,!!n()))}function be(n,o,r={}){const{window:a=M,...l}=r;let i;const c=X(()=>a&&"MutationObserver"in a),m=()=>{i&&(i.disconnect(),i=void 0)},u=e.computed(()=>{const k=e.toValue(n),f=T(k).map(N).filter(de);return new Set(f)}),y=e.watch(()=>u.value,k=>{m(),c.value&&k.size&&(i=new MutationObserver(o),k.forEach(f=>i.observe(f,l)))},{immediate:!0,flush:"post"}),g=()=>i==null?void 0:i.takeRecords(),d=()=>{y(),m()};return _(d),{isSupported:c,stop:d,takeRecords:g}}function we(n,o,r={}){const{window:a=M,document:l=a==null?void 0:a.document,flush:i="sync"}=r;if(!a||!l)return F;let c;const m=g=>{c==null||c(),c=g},u=e.watchEffect(()=>{const g=N(n);if(g){const{stop:d}=be(l,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===g||p.contains(g))&&o(k)},{window:a,childList:!0,subtree:!0});m(d)}},{flush:i}),y=()=>{u(),m()};return _(y),y}function Ee(n={}){var o;const{window:r=M,deep:a=!0,triggerOnRemoval:l=!1}=n,i=(o=n.document)!=null?o:r==null?void 0:r.document,c=()=>{var y;let g=i==null?void 0:i.activeElement;if(a)for(;g!=null&&g.shadowRoot;)g=(y=g==null?void 0:g.shadowRoot)==null?void 0:y.activeElement;return g},m=e.shallowRef(),u=()=>{m.value=c()};if(r){const y={capture:!0,passive:!0};H(r,"blur",g=>{g.relatedTarget===null&&u()},y),H(r,"focus",u,y)}return l&&we(m,u,{document:i}),u(),m}function Ce(n,o,r={}){const{window:a=M,...l}=r;let i;const c=X(()=>a&&"ResizeObserver"in a),m=()=>{i&&(i.disconnect(),i=void 0)},u=e.computed(()=>{const d=e.toValue(n);return Array.isArray(d)?d.map(k=>N(k)):[N(d)]}),y=e.watch(u,d=>{if(m(),c.value&&a){i=new ResizeObserver(o);for(const k of d)k&&i.observe(k,l)}},{immediate:!0,flush:"post"}),g=()=>{m(),y()};return _(g),{isSupported:c,stop:g}}function Y(n,o={width:0,height:0},r={}){const{window:a=M,box:l="content-box"}=r,i=e.computed(()=>{var d,k;return(k=(d=N(n))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),c=e.shallowRef(o.width),m=e.shallowRef(o.height),{stop:u}=Ce(n,([d])=>{const k=l==="border-box"?d.borderBoxSize:l==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&i.value){const f=N(n);if(f){const p=f.getBoundingClientRect();c.value=p.width,m.value=p.height}}else if(k){const f=T(k);c.value=f.reduce((p,{inlineSize:z})=>p+z,0),m.value=f.reduce((p,{blockSize:z})=>p+z,0)}else c.value=d.contentRect.width,m.value=d.contentRect.height},r);he(()=>{const d=N(n);d&&(c.value="offsetWidth"in d?d.offsetWidth:o.width,m.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(n),d=>{c.value=d?o.width:0,m.value=d?o.height:0});function g(){u(),y()}return{width:c,height:m,stop:g}}var G=class{constructor(n,o={}){x(this,"canvas");x(this,"ctx");x(this,"lastX",0);x(this,"lastY",0);x(this,"strokeData",[]);x(this,"clearTimerId",null);x(this,"isDrawing",!1);x(this,"options");x(this,"handleStart",n=>{n.preventDefault(),this.isDrawing=!0;const{offsetX:o,offsetY:r}=this.getEventCoordinates(n);this.startDrawing(o,r),this.resetClearTimer()});x(this,"handleMove",n=>{if(!this.isDrawing)return;n.preventDefault();const{offsetX:o,offsetY:r}=this.getEventCoordinates(n);this.draw(o,r),this.resetClearTimer()});x(this,"handleEnd",n=>{this.isDrawing&&(n.preventDefault(),this.isDrawing=!1,this.endStroke(),this.startClearTimer(),this.options.onDrawEnd&&this.options.onDrawEnd())});this.canvas=n,this.options={clearDelay:1e3,...o};const r=this.canvas.getContext("2d");if(!r)throw new Error("Failed to get 2D rendering context");this.ctx=r,this.setupCanvas(),this.attachEvents()}setupCanvas(){this.ctx.lineJoin="round",this.ctx.lineCap="round",this.ctx.lineWidth=3,this.ctx.strokeStyle="#000",this.clearCanvas(),this.drawGrid()}drawGrid(){const n=this.canvas.width,o=this.canvas.height;this.ctx.save(),this.ctx.strokeStyle="#ddd",this.ctx.lineWidth=1,this.ctx.setLineDash([3,3]),this.ctx.beginPath(),this.ctx.moveTo(0,o/2),this.ctx.lineTo(n,o/2),this.ctx.moveTo(n/2,0),this.ctx.lineTo(n/2,o),this.ctx.stroke(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(0,0,n,o),this.ctx.stroke(),this.ctx.restore()}clearCanvas(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawGrid(),this.strokeData=[],this.resetClearTimer()}startDrawing(n,o){this.lastX=n,this.lastY=o,this.ctx.strokeStyle="#000",this.ctx.lineWidth=3,this.ctx.setLineDash([]),this.strokeData.push(n,o,0)}draw(n,o){this.ctx.beginPath(),this.ctx.moveTo(this.lastX,this.lastY),this.ctx.lineTo(n,o),this.ctx.stroke(),this.lastX=n,this.lastY=o,this.strokeData.push(n,o,0)}endStroke(){this.strokeData.length>=3&&(this.strokeData[this.strokeData.length-1]=1)}getStrokeData(){return this.strokeData}resetClearTimer(){this.clearTimerId&&(window.clearTimeout(this.clearTimerId),this.clearTimerId=null)}startClearTimer(){this.resetClearTimer(),this.clearTimerId=window.setTimeout(()=>{this.clearCanvas(),this.clearTimerId=null},this.options.clearDelay)}getEventCoordinates(n){if(n instanceof MouseEvent)return{offsetX:n.offsetX,offsetY:n.offsetY};{const o=n.touches[0]||n.changedTouches[0],r=n.target.getBoundingClientRect();return{offsetX:o.clientX-r.left,offsetY:o.clientY-r.top}}}attachEvents(){this.canvas.addEventListener("mousedown",this.handleStart),this.canvas.addEventListener("mousemove",this.handleMove),this.canvas.addEventListener("mouseup",this.handleEnd),this.canvas.addEventListener("mouseleave",this.handleEnd),this.canvas.addEventListener("touchstart",this.handleStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.handleMove,{passive:!1}),this.canvas.addEventListener("touchend",this.handleEnd),this.canvas.addEventListener("touchcancel",this.handleEnd)}detachEvents(){this.canvas.removeEventListener("mousedown",this.handleStart),this.canvas.removeEventListener("mousemove",this.handleMove),this.canvas.removeEventListener("mouseup",this.handleEnd),this.canvas.removeEventListener("mouseleave",this.handleEnd),this.canvas.removeEventListener("touchstart",this.handleStart),this.canvas.removeEventListener("touchmove",this.handleMove),this.canvas.removeEventListener("touchend",this.handleEnd),this.canvas.removeEventListener("touchcancel",this.handleEnd)}destroy(){this.detachEvents(),this.resetClearTimer()}getCanvas(){return this.canvas}getContext(){return this.ctx}};let W={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},v=null,q=null;function $(){return W}function ze(n){W={...W,...n}}function Be(n){v=n}function I(){return v}function Ve(n){q=n}function J(){return q}function Q(n,o,r){if(!n||!o||r==="static")return null;let a,l;if(r==="bottom")a=window.innerHeight-o.offsetHeight,l=0;else{const i=n.getBoundingClientRect(),c=o.offsetWidth;a=i.bottom+window.scrollY,l=i.left+window.scrollX+i.width/2-c/2;const m=window.innerWidth;l+c>m&&(l=m-c-10),l<10&&(l=10)}return{top:`${a}px`,left:`${l}px`}}function A(n){if(!n)return!1;if(n.tagName==="TEXTAREA")return!0;if(n.tagName==="INPUT"){const r=(n.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(r)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(n,o,r){n.value=o,oe(n,r),n.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(n,o,r,a=""){return n.slice(0,o)+a+n.slice(o+r)}function ee(n,o=""){const r=Number(n.getAttribute("maxlength"));let a=n.selectionStart??0;const l=n.selectionEnd??a;let i;if(o.length>0)i=l-a;else{const u=l-a;if(u>0)i=u;else if(a>0)i=1,a--;else return}if(o.length>0&&r&&n.value.length-i+o.length>r)return;const c=_e(n.value,a,i,o),m=a+o.length;Pe(n,c,m)}function te(n,o){ee(n,o)}function ne(n){ee(n)}function oe(n,o){n.selectionStart=o,n.selectionEnd=o}function re(n={}){const o=n.delay??400,r=n.interval??60;let a,l;function i(){a&&(clearTimeout(a),a=void 0),l&&(clearInterval(l),l=void 0)}function c(m){i(),m(),a=setTimeout(()=>{l=setInterval(()=>{m()},r)},o)}return{start:c,stop:i}}function Ne(n=!1){const o=e.ref(!1),r=e.ref(0);async function a(){const i=I();if(i)try{o.value=await i.initialize({onProgress:c=>{r.value=c}})}catch(c){console.error("初始化手写识别服务失败:",c),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function l(){const i=I();if(i&&o.value)try{await i.close(),o.value=!1}catch(c){console.error("关闭手写识别服务失败:",c)}}return e.onMounted(()=>{n&&a()}),e.onUnmounted(()=>{l()}),{recognizerInitialized:o,recognizerProgress:r}}const O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z'%20/%3e%3c/svg%3e",U="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e";function K(){const n=re();function o(a,l){var i,c;a.preventDefault(),(c=(i=a.currentTarget)==null?void 0:i.setPointerCapture)==null||c.call(i,a.pointerId),n.start(l)}function r(){n.stop()}return e.onBeforeUnmount(()=>{n.stop()}),{startRepeat:o,stopRepeat:r}}const Se={class:"zhk-candidate-list"},Me=["onClick"],ie=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(n,{emit:o}){const r=o;function a(l){r("select",l)}return(l,i)=>(e.openBlock(),e.createElementBlock("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.candidates,(c,m)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${m}`,class:"zhk-candidate-list__item",onClick:u=>a(m)},e.toDisplayString(c),9,Me))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-buttons"},Re={class:"handwriting-canvas-container"},De={class:"progress-bar"},Te={class:"progress-text"},He=["width","height"],Ie={class:"handwriting-buttons"},Ae=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(n,{emit:o}){const r=n,a=o,l=e.ref(null),i=e.ref(null);let c=null;const m=e.ref(!1),{height:u}=Y(i);function y(){c&&c.clearCanvas()}function g(){l.value&&(c&&c.destroy(),c=new G(l.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:f}=K();async function p(){if(!c||c.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const t=[...c.getStrokeData()],h=await w.recognize(t);d.value=h}catch(t){console.error("识别笔迹失败:",t)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{c&&c.destroy()}),e.watchEffect(()=>{l.value&&u.value&&r.recognizerInitialized&&e.nextTick(()=>{g()})});function z(w){const t=d.value[w];t&&(a("key",{key:t}),d.value=[],y())}return(w,t)=>(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(ie,{candidates:d.value,onSelect:z},null,8,["candidates"]),e.createElementVNode("div",{ref_key:"containerRef",ref:i,class:"handwriting-content"},[e.createElementVNode("div",Le,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[0]||(t[0]=h=>e.unref(k)(h,()=>a("key",{key:"。"}))),onPointerup:t[1]||(t[1]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[2]||(t[2]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[3]||(t[3]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[4]||(t[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[5]||(t[5]=h=>e.unref(k)(h,()=>a("key",{key:"?"}))),onPointerup:t[6]||(t[6]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[7]||(t[7]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[8]||(t[8]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[9]||(t[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[10]||(t[10]=h=>e.unref(k)(h,()=>a("key",{key:"!"}))),onPointerup:t[11]||(t[11]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[12]||(t[12]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[13]||(t[13]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[14]||(t[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[15]||(t[15]=h=>e.unref(k)(h,()=>a("key",{key:"、"}))),onPointerup:t[16]||(t[16]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[17]||(t[17]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[18]||(t[18]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[19]||(t[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",Re,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:l,class:"handwriting-canvas",width:e.unref(u),height:e.unref(u)},null,8,He)):(e.openBlock(),e.createElementBlock("div",{key:0,class:"handwriting-loading",style:e.normalizeStyle({width:`${e.unref(u)}px`,height:`${e.unref(u)}px`})},[t[37]||(t[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",De,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",Te,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)],4))]),e.createElementVNode("div",Ie,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[20]||(t[20]=h=>e.unref(k)(h,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:t[21]||(t[21]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[22]||(t[22]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[23]||(t[23]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[24]||(t[24]=e.withModifiers(()=>{},["prevent"]))},t[38]||(t[38]=[e.createElementVNode("img",{src:O,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:t[25]||(t[25]=h=>a("exit")),onContextmenu:t[26]||(t[26]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[27]||(t[27]=h=>e.unref(k)(h,()=>a("key",{key:","}))),onPointerup:t[28]||(t[28]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[29]||(t[29]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[30]||(t[30]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[31]||(t[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:t[32]||(t[32]=h=>e.unref(k)(h,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:t[33]||(t[33]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointerleave:t[34]||(t[34]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onPointercancel:t[35]||(t[35]=(...h)=>e.unref(f)&&e.unref(f)(...h)),onContextmenu:t[36]||(t[36]=e.withModifiers(()=>{},["prevent"]))},t[39]||(t[39]=[e.createElementVNode("img",{src:U,alt:"回车"},null,-1)]),32)])],512)]))}}),Ke="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e",se="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e",Fe="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e",We={class:"zhk-selection"},Oe={class:"zhk-selection__list"},Ue=["onClick"],Ze=e.defineComponent({__name:"CandidateSelection",props:{candidates:{}},emits:["select","close"],setup(n,{emit:o}){const r=o;function a(c){r("select",c)}function l(){r("close")}function i(c){const m=Array.from(c).length;return m>=2&&m<=3?2:m>=4?3:1}return(c,m)=>(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.candidates,(u,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${i(u)}`]]),onClick:g=>a(y)},e.toDisplayString(u),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:l}," 返回 ")])]))}}),je={class:"zhk-candidate"},Xe={class:"zhk-candidate__container"},Ye={key:0,class:"zhk-candidate__pinyin"},Ge={class:"zhk-candidate__bottom-container"},ve=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(n,{expose:o,emit:r}){const a=r,l=e.useModel(n,"modelValue");let i=null;const c=e.ref(null),m=e.computed(()=>{var d;return((d=c.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),u=e.ref(!1);e.onMounted(async()=>{if(i=J(),!i)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");l.value&&(c.value=await i.processInput(l.value))}),e.onUnmounted(()=>{i==null||i.clearInput(),i=null}),e.watch(l,async d=>{const k=i;if(k){if(d===""){k.clearInput(),c.value=null;return}c.value=await k.processInput(d)}});async function y(d){if(!i)return;const k=await i.pickCandidate(d);c.value=k,k.preeditBody||(a("input",k.committed||""),l.value="",c.value=null,u.value=!1)}o({handleSelection:y});const g=e.computed(()=>{const d=c.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Xe,[g.value?(e.openBlock(),e.createElementBlock("div",Ye,e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ge,[m.value.length>0?(e.openBlock(),e.createBlock(ie,{key:0,candidates:m.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=f=>u.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:Fe,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),u.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:m.value,onSelect:y,onClose:k[1]||(k[1]=f=>u.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),qe={class:"zhk-base"},Je={class:"zhk-base__row"},Qe=["onPointerdown"],et=["disabled"],tt={key:1,src:Ke,class:"zhk-base__key-icon",alt:"Shift"},nt=["onPointerdown"],ot={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},it={class:"zhk-base__toggle-sub"},st=e.defineComponent({__name:"KeyboardBase",props:e.mergeModels({enableHandwriting:{type:Boolean}},{modelValue:{default:"en"},modelModifiers:{}}),emits:e.mergeModels(["key"],["update:modelValue"]),setup(n,{emit:o}){const r=n,a=o,l=e.useModel(n,"modelValue"),i=e.ref(!1),c=e.computed(()=>l.value==="zh"),m=e.computed(()=>c.value?!0:i.value);function u(P,s=!1){a("key",{key:P,isControl:s})}function y(){c.value?l.value="hand":i.value=!i.value}function g(){l.value="num"}function d(){l.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],f=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],p=e.ref(""),z=e.ref(null),{startRepeat:w,stopRepeat:t}=K();function h(){if(l.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}u("delete",!0)}function L(){var P;if(l.value==="zh"&&p.value){(P=z.value)==null||P.handleSelection(0);return}u(" ")}function Z(){if(l.value==="zh"&&p.value){u(p.value),p.value="";return}u("enter",!0)}function R(P){if(l.value==="zh"){p.value+=P;return}const s=i.value?P.toUpperCase():P;u(s)}function j(){l.value=l.value==="zh"?"en":"zh"}const C=e.computed(()=>r.enableHandwriting?"手写":"-"),V=e.computed(()=>!r.enableHandwriting);return(P,s)=>(e.openBlock(),e.createElementBlock("div",qe,[e.createElementVNode("div",Je,[l.value==="zh"?(e.openBlock(),e.createBlock(ve,{key:0,ref_key:"candidateBarRef",ref:z,modelValue:p.value,"onUpdate:modelValue":s[0]||(s[0]=b=>p.value=b),onInput:s[1]||(s[1]=b=>u(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,D)=>e.createElementVNode("button",{key:`number-${D}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:B=>e.unref(w)(B,()=>R(b)),onPointerup:s[2]||(s[2]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointerleave:s[3]||(s[3]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointercancel:s[4]||(s[4]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onContextmenu:s[5]||(s[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,Qe)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(f,(b,D)=>e.createElementVNode("div",{key:`row-${D}`,class:"zhk-base__row"},[D===2?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["zhk-base__key zhk-base__key--function zhk-base__key--shift",{"zhk-base__key--active":!c.value&&i.value,"zhk-base__key--disabled":c.value&&V.value}]),disabled:c.value&&V.value,onClick:y,onContextmenu:s[6]||(s[6]=e.withModifiers(()=>{},["prevent"]))},[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(C.value),1)],64)):(e.openBlock(),e.createElementBlock("img",tt))],42,et)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(B,Dt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${D}-${Dt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:S=>e.unref(w)(S,()=>R(B)),onPointerup:s[7]||(s[7]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onPointerleave:s[8]||(s[8]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onPointercancel:s[9]||(s[9]=(...S)=>e.unref(t)&&e.unref(t)(...S)),onContextmenu:s[10]||(s[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(m.value?B.toUpperCase():B),41,nt))),128)),D===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:s[11]||(s[11]=B=>e.unref(w)(B,()=>h())),onPointerup:s[12]||(s[12]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointerleave:s[13]||(s[13]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onPointercancel:s[14]||(s[14]=(...B)=>e.unref(t)&&e.unref(t)(...B)),onContextmenu:s[15]||(s[15]=e.withModifiers(()=>{},["prevent"]))},s[39]||(s[39]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",ot,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:s[16]||(s[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:g,onContextmenu:s[17]||(s[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[18]||(s[18]=b=>e.unref(w)(b,()=>u(","))),onPointerup:s[19]||(s[19]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[20]||(s[20]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[21]||(s[21]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[22]||(s[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:s[23]||(s[23]=b=>e.unref(w)(b,()=>L())),onPointerup:s[24]||(s[24]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[25]||(s[25]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[26]||(s[26]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[27]||(s[27]=e.withModifiers(()=>{},["prevent"]))},s[40]||(s[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:s[28]||(s[28]=b=>e.unref(w)(b,()=>u("。"))),onPointerup:s[29]||(s[29]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[30]||(s[30]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[31]||(s[31]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[32]||(s[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:j,onContextmenu:s[33]||(s[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(l.value==="zh"?"中":"英"),1),e.createElementVNode("span",it,"/"+e.toDisplayString(l.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:s[34]||(s[34]=b=>e.unref(w)(b,()=>Z())),onPointerup:s[35]||(s[35]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointerleave:s[36]||(s[36]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onPointercancel:s[37]||(s[37]=(...b)=>e.unref(t)&&e.unref(t)(...b)),onContextmenu:s[38]||(s[38]=e.withModifiers(()=>{},["prevent"]))},s[41]||(s[41]=[e.createElementVNode("img",{src:U,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),lt={class:"num-keyboard"},at={class:"num-keyboard__container"},dt={class:"num-keyboard__left"},ct={class:"num-keyboard__rows"},ft=["onClick","onPointerdown"],ut={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},mt={class:"num-keyboard__right"},pt=["onPointerdown"],kt=["src","alt"],ht={key:1},gt=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>$().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(n,{emit:o}){const r=o,a=[{key:"delete",icon:O,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:U,text:"",alt:"Enter"}];function l(g){r("key",{key:g})}function i(g,d=!0){r("key",{key:g,isControl:d})}function c(){r("exit")}const{startRepeat:m,stopRepeat:u}=K();function y(g,d){g==="back"||(g==="space"&&(g=" "),g==="delete"||g==="enter"?m(d,()=>i(g)):m(d,()=>l(g)))}return(g,d)=>(e.openBlock(),e.createElementBlock("div",lt,[e.createElementVNode("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.keyboardRows,(k,f)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${f}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,z)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${f}-${z}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&c(),onPointerdown:w=>y(p,w),onPointerup:d[0]||(d[0]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onPointerleave:d[1]||(d[1]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onPointercancel:d[2]||(d[2]=(...w)=>e.unref(u)&&e.unref(u)(...w)),onContextmenu:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[p==="back"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" 返回 ")],64)):p==="space"?(e.openBlock(),e.createElementBlock("img",ut)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ft))),128))]))),128))])]),e.createElementVNode("div",mt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,f)=>e.createElementVNode("button",{key:`func-${f}`,class:"num-keyboard__key num-keyboard__key--function",onPointerdown:p=>y(k.key,p),onPointerup:d[4]||(d[4]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onPointerleave:d[5]||(d[5]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onPointercancel:d[6]||(d[6]=(...p)=>e.unref(u)&&e.unref(u)(...p)),onContextmenu:d[7]||(d[7]=e.withModifiers(()=>{},["prevent"]))},[k.icon?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.icon,class:"num-keyboard__key-icon",alt:k.alt},null,8,kt)):(e.openBlock(),e.createElementBlock("span",ht,e.toDisplayString(k.text),1))],40,pt)),64))])])]))}}),yt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e",bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e",wt={class:"symbol-keyboard"},Et={class:"symbol-keyboard__content"},Ct={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Bt={class:"symbol-keyboard__control-group"},Vt=["src"],xt=["src"],Pt={class:"symbol-keyboard__symbols-container"},_t={class:"symbol-keyboard__symbols-grid"},Nt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",Mt="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",$t=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(n,{emit:o}){const r=o,a=e.ref("en"),l=e.computed(()=>a.value==="zh"?Mt:St),i=e.ref(!1),{startRepeat:c,stopRepeat:m}=K();function u(f,p){i.value&&c(p,()=>y(f))}function y(f){r("key",{key:f}),i.value||r("exit")}function g(){r("exit")}function d(f){a.value=f}function k(){i.value=!i.value}return(f,p)=>(e.openBlock(),e.createElementBlock("div",wt,[e.createElementVNode("div",Et,[e.createElementVNode("div",Ct,[e.createElementVNode("div",zt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="zh"}]),onClick:p[0]||(p[0]=z=>d("zh")),onContextmenu:p[1]||(p[1]=e.withModifiers(()=>{},["prevent"]))}," 中文 ",34),e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="en"}]),onClick:p[2]||(p[2]=z=>d("en")),onContextmenu:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))}," 英文 ",34)]),e.createElementVNode("div",Bt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":i.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[i.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(bt),alt:"Lock closed"},null,8,xt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(yt),alt:"Lock open"},null,8,Vt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:g,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",Pt,[e.createElementVNode("div",_t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(z,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:t=>!i.value&&y(z),onPointerdown:t=>u(z,t),onPointerup:p[6]||(p[6]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onPointerleave:p[7]||(p[7]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onPointercancel:p[8]||(p[8]=(...t)=>e.unref(m)&&e.unref(m)(...t)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(z),41,Nt))),128))])])])]))}}),Lt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{default:$().defaultMode??"en"},enableHandwriting:{type:Boolean,default:$().enableHandwriting??!1},position:{default:$().position??"static"},disableWhenNoFocus:{type:Boolean,default:$().disableWhenNoFocus??!0},numKeys:{}},emits:["key"],setup(n,{emit:o}){const r=n,a=o,l=e.ref(r.defaultMode),i=e.ref(r.defaultMode),c=e.ref([]),m=e.ref(!1),u=e.ref(null),y=e.ref(null),{recognizerInitialized:g,recognizerProgress:d}=Ne(r.enableHandwriting);e.watch(l,(C,V)=>{C!==V&&(i.value=V)});const k=Ee(),f=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>r.position==="static"||!!(k.value&&A(k.value))),{height:z}=Y(y);e.watchEffect(()=>{if(f.value){const C=f.value.dataset.inputmode;C&&(l.value=C)}});const w=e.computed(()=>r.disableWhenNoFocus===!1?!1:!f.value);function t(){if(!z.value)return;const C=Q(f.value,y.value,r.position);u.value=C}e.watchEffect(t);const h=ke(t,100);H(window,"scroll",h,{passive:!0}),H(window,"resize",h,{passive:!0});function L(C){if(C.isControl){switch(C.key){case"delete":ne(f.value);break;case"more":m.value=!0;break}return}else Z(C.key);a("key",C)}function Z(C){te(f.value,C)}function R(){["hand","num","symbol"].includes(i.value)&&(i.value=r.defaultMode),l.value=i.value}function j(C){c.value=C}return(C,V)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{ref_key:"keyboardRef",ref:y,class:e.normalizeClass(["zhk",{"zhk--floating":C.position==="float","zhk--bottom":C.position==="bottom","zhk--disabled":w.value}]),style:e.normalizeStyle({"--keyboard-height":`${e.unref(z)}px`,...u.value}),onMousedown:V[1]||(V[1]=e.withModifiers(()=>{},["prevent"]))},[w.value||!p.value||!e.unref(z)?(e.openBlock(),e.createElementBlock("div",Lt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l.value==="hand"?(e.openBlock(),e.createBlock(Ae,{key:0,"recognizer-initialized":e.unref(g),"recognizer-progress":e.unref(d),onKey:L,onExit:R,onRecognize:j},null,8,["recognizer-initialized","recognizer-progress"])):l.value==="num"?(e.openBlock(),e.createBlock(gt,{key:1,"keyboard-rows":C.numKeys,onKey:L,onExit:R},null,8,["keyboard-rows"])):l.value==="symbol"?(e.openBlock(),e.createBlock($t,{key:2,onKey:L,onExit:R})):l.value==="en"||l.value==="zh"?(e.openBlock(),e.createBlock(st,{key:3,modelValue:l.value,"onUpdate:modelValue":V[0]||(V[0]=P=>l.value=P),"enable-handwriting":C.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Rt={install:n=>{n.component("ZhKeyboard",le)}};E.CanvasDrawer=G,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=re,E.default=Rt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=$,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=Be,E.registerPinyinEngine=Ve,E.setKeyboardConfig=ze,E.writeToInputElement=te,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.ZhKeyboardVue={},E.Vue))})(this,function(E,e){"use strict";var Ht=Object.defineProperty;var It=(E,e,_)=>e in E?Ht(E,e,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[e]=_;var x=(E,e,_)=>It(E,typeof e!="symbol"?e+"":e,_);function _(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}const ae=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const de=t=>t!=null,ce=Object.prototype.toString,fe=t=>ce.call(t)==="[object Object]",W=()=>{};function ue(t,o){function r(...a){return new Promise((s,i)=>{Promise.resolve(t(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(s).catch(i)})}return r}function me(t,o={}){let r,a,s=W;const i=f=>{clearTimeout(f),s(),s=W};let m;return f=>{const y=e.toValue(t),g=e.toValue(o.maxWait);return r&&i(r),y<=0||g!==void 0&&g<=0?(a&&(i(a),a=null),Promise.resolve(f())):new Promise((d,k)=>{s=o.rejectOnCancel?k:d,m=f,g&&!a&&(a=setTimeout(()=>{r&&i(r),a=null,d(m())},g)),r=setTimeout(()=>{a&&i(a),a=null,d(f())},y)})}}function R(t){return Array.isArray(t)?t:[t]}function pe(t){return e.getCurrentInstance()}function ke(t,o=200,r={}){return ue(me(o,r),t)}function he(t,o=!0,r){pe()?e.onMounted(t,r):o?t():e.nextTick(t)}function ge(t,o,r){return e.watch(t,o,{...r,immediate:!0})}const $=ae?window:void 0;function N(t){var o;const r=e.toValue(t);return(o=r==null?void 0:r.$el)!=null?o:r}function H(...t){const o=[],r=()=>{o.forEach(u=>u()),o.length=0},a=(u,f,y,g)=>(u.addEventListener(f,y,g),()=>u.removeEventListener(f,y,g)),s=e.computed(()=>{const u=R(e.toValue(t[0])).filter(f=>f!=null);return u.every(f=>typeof f!="string")?u:void 0}),i=ge(()=>{var u,f;return[(f=(u=s.value)==null?void 0:u.map(y=>N(y)))!=null?f:[$].filter(y=>y!=null),R(e.toValue(s.value?t[1]:t[0])),R(e.unref(s.value?t[2]:t[1])),e.toValue(s.value?t[3]:t[2])]},([u,f,y,g])=>{if(r(),!(u!=null&&u.length)||!(f!=null&&f.length)||!(y!=null&&y.length))return;const d=fe(g)?{...g}:g;o.push(...u.flatMap(k=>f.flatMap(c=>y.map(p=>a(k,c,p,d)))))},{flush:"post"}),m=()=>{i(),r()};return _(r),m}function ye(){const t=e.shallowRef(!1),o=e.getCurrentInstance();return o&&e.onMounted(()=>{t.value=!0},o),t}function j(t){const o=ye();return e.computed(()=>(o.value,!!t()))}function be(t,o,r={}){const{window:a=$,...s}=r;let i;const m=j(()=>a&&"MutationObserver"in a),u=()=>{i&&(i.disconnect(),i=void 0)},f=e.computed(()=>{const k=e.toValue(t),c=R(k).map(N).filter(de);return new Set(c)}),y=e.watch(()=>f.value,k=>{u(),m.value&&k.size&&(i=new MutationObserver(o),k.forEach(c=>i.observe(c,s)))},{immediate:!0,flush:"post"}),g=()=>i==null?void 0:i.takeRecords(),d=()=>{y(),u()};return _(d),{isSupported:m,stop:d,takeRecords:g}}function we(t,o,r={}){const{window:a=$,document:s=a==null?void 0:a.document,flush:i="sync"}=r;if(!a||!s)return W;let m;const u=g=>{m==null||m(),m=g},f=e.watchEffect(()=>{const g=N(t);if(g){const{stop:d}=be(s,k=>{k.map(p=>[...p.removedNodes]).flat().some(p=>p===g||p.contains(g))&&o(k)},{window:a,childList:!0,subtree:!0});u(d)}},{flush:i}),y=()=>{f(),u()};return _(y),y}function Ee(t={}){var o;const{window:r=$,deep:a=!0,triggerOnRemoval:s=!1}=t,i=(o=t.document)!=null?o:r==null?void 0:r.document,m=()=>{var y;let g=i==null?void 0:i.activeElement;if(a)for(;g!=null&&g.shadowRoot;)g=(y=g==null?void 0:g.shadowRoot)==null?void 0:y.activeElement;return g},u=e.shallowRef(),f=()=>{u.value=m()};if(r){const y={capture:!0,passive:!0};H(r,"blur",g=>{g.relatedTarget===null&&f()},y),H(r,"focus",f,y)}return s&&we(u,f,{document:i}),f(),u}function Ce(t,o,r={}){const{window:a=$,...s}=r;let i;const m=j(()=>a&&"ResizeObserver"in a),u=()=>{i&&(i.disconnect(),i=void 0)},f=e.computed(()=>{const d=e.toValue(t);return Array.isArray(d)?d.map(k=>N(k)):[N(d)]}),y=e.watch(f,d=>{if(u(),m.value&&a){i=new ResizeObserver(o);for(const k of d)k&&i.observe(k,s)}},{immediate:!0,flush:"post"}),g=()=>{u(),y()};return _(g),{isSupported:m,stop:g}}function X(t,o={width:0,height:0},r={}){const{window:a=$,box:s="content-box"}=r,i=e.computed(()=>{var d,k;return(k=(d=N(t))==null?void 0:d.namespaceURI)==null?void 0:k.includes("svg")}),m=e.shallowRef(o.width),u=e.shallowRef(o.height),{stop:f}=Ce(t,([d])=>{const k=s==="border-box"?d.borderBoxSize:s==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(a&&i.value){const c=N(t);if(c){const p=c.getBoundingClientRect();m.value=p.width,u.value=p.height}}else if(k){const c=R(k);m.value=c.reduce((p,{inlineSize:C})=>p+C,0),u.value=c.reduce((p,{blockSize:C})=>p+C,0)}else m.value=d.contentRect.width,u.value=d.contentRect.height},r);he(()=>{const d=N(t);d&&(m.value="offsetWidth"in d?d.offsetWidth:o.width,u.value="offsetHeight"in d?d.offsetHeight:o.height)});const y=e.watch(()=>N(t),d=>{m.value=d?o.width:0,u.value=d?o.height:0});function g(){f(),y()}return{width:m,height:u,stop:g}}var Y=class{constructor(t,o={}){x(this,"canvas");x(this,"ctx");x(this,"lastX",0);x(this,"lastY",0);x(this,"strokeData",[]);x(this,"clearTimerId",null);x(this,"isDrawing",!1);x(this,"options");x(this,"handleStart",t=>{t.preventDefault(),this.isDrawing=!0;const{offsetX:o,offsetY:r}=this.getEventCoordinates(t);this.startDrawing(o,r),this.resetClearTimer()});x(this,"handleMove",t=>{if(!this.isDrawing)return;t.preventDefault();const{offsetX:o,offsetY:r}=this.getEventCoordinates(t);this.draw(o,r),this.resetClearTimer()});x(this,"handleEnd",t=>{this.isDrawing&&(t.preventDefault(),this.isDrawing=!1,this.endStroke(),this.startClearTimer(),this.options.onDrawEnd&&this.options.onDrawEnd())});this.canvas=t,this.options={clearDelay:1e3,...o};const r=this.canvas.getContext("2d");if(!r)throw new Error("Failed to get 2D rendering context");this.ctx=r,this.setupCanvas(),this.attachEvents()}setupCanvas(){this.ctx.lineJoin="round",this.ctx.lineCap="round",this.ctx.lineWidth=3,this.ctx.strokeStyle="#000",this.clearCanvas(),this.drawGrid()}drawGrid(){const t=this.canvas.width,o=this.canvas.height;this.ctx.save(),this.ctx.strokeStyle="#ddd",this.ctx.lineWidth=1,this.ctx.setLineDash([3,3]),this.ctx.beginPath(),this.ctx.moveTo(0,o/2),this.ctx.lineTo(t,o/2),this.ctx.moveTo(t/2,0),this.ctx.lineTo(t/2,o),this.ctx.stroke(),this.ctx.setLineDash([]),this.ctx.beginPath(),this.ctx.rect(0,0,t,o),this.ctx.stroke(),this.ctx.restore()}clearCanvas(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawGrid(),this.strokeData=[],this.resetClearTimer()}startDrawing(t,o){this.lastX=t,this.lastY=o,this.ctx.strokeStyle="#000",this.ctx.lineWidth=3,this.ctx.setLineDash([]),this.strokeData.push(t,o,0)}draw(t,o){this.ctx.beginPath(),this.ctx.moveTo(this.lastX,this.lastY),this.ctx.lineTo(t,o),this.ctx.stroke(),this.lastX=t,this.lastY=o,this.strokeData.push(t,o,0)}endStroke(){this.strokeData.length>=3&&(this.strokeData[this.strokeData.length-1]=1)}getStrokeData(){return this.strokeData}resetClearTimer(){this.clearTimerId&&(window.clearTimeout(this.clearTimerId),this.clearTimerId=null)}startClearTimer(){this.resetClearTimer(),this.clearTimerId=window.setTimeout(()=>{this.clearCanvas(),this.clearTimerId=null},this.options.clearDelay)}getEventCoordinates(t){if(t instanceof MouseEvent)return{offsetX:t.offsetX,offsetY:t.offsetY};{const o=t.touches[0]||t.changedTouches[0],r=t.target.getBoundingClientRect();return{offsetX:o.clientX-r.left,offsetY:o.clientY-r.top}}}attachEvents(){this.canvas.addEventListener("mousedown",this.handleStart),this.canvas.addEventListener("mousemove",this.handleMove),this.canvas.addEventListener("mouseup",this.handleEnd),this.canvas.addEventListener("mouseleave",this.handleEnd),this.canvas.addEventListener("touchstart",this.handleStart,{passive:!1}),this.canvas.addEventListener("touchmove",this.handleMove,{passive:!1}),this.canvas.addEventListener("touchend",this.handleEnd),this.canvas.addEventListener("touchcancel",this.handleEnd)}detachEvents(){this.canvas.removeEventListener("mousedown",this.handleStart),this.canvas.removeEventListener("mousemove",this.handleMove),this.canvas.removeEventListener("mouseup",this.handleEnd),this.canvas.removeEventListener("mouseleave",this.handleEnd),this.canvas.removeEventListener("touchstart",this.handleStart),this.canvas.removeEventListener("touchmove",this.handleMove),this.canvas.removeEventListener("touchend",this.handleEnd),this.canvas.removeEventListener("touchcancel",this.handleEnd)}destroy(){this.detachEvents(),this.resetClearTimer()}getCanvas(){return this.canvas}getContext(){return this.ctx}};let v={defaultMode:"en",enableHandwriting:!1,position:"static",disableWhenNoFocus:!0},G=null,q=null;function M(){return v}function Be(t){v={...v,...t}}function ze(t){G=t}function I(){return G}function Ve(t){q=t}function J(){return q}function Q(t,o,r,a=0){if(!t||!o||r==="static")return null;let s,i;if(r==="bottom")s=window.innerHeight-o.offsetHeight,i=0;else{const m=t.getBoundingClientRect(),u=o.offsetWidth;s=m.bottom+window.scrollY+a,i=m.left+window.scrollX+m.width/2-u/2;const f=window.innerWidth;i+u>f&&(i=f-u-10),i<10&&(i=10)}return{top:`${s}px`,left:`${i}px`}}function A(t){if(!t)return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){const r=(t.type||"text").toLowerCase();return!["checkbox","radio","button","submit","reset","file","image","range","color","hidden","date","datetime-local","month","week","time"].includes(r)}return!1}function xe(){if(document.activeElement&&A(document.activeElement))return document.activeElement;throw new Error("输入框没有被激活")}function Pe(t,o,r){t.value=o,oe(t,r),t.dispatchEvent(new Event("input",{bubbles:!0}))}function _e(t,o,r,a=""){return t.slice(0,o)+a+t.slice(o+r)}function ee(t,o=""){const r=Number(t.getAttribute("maxlength"));let a=t.selectionStart??0;const s=t.selectionEnd??a;let i;if(o.length>0)i=s-a;else{const f=s-a;if(f>0)i=f;else if(a>0)i=1,a--;else return}if(o.length>0&&r&&t.value.length-i+o.length>r)return;const m=_e(t.value,a,i,o),u=a+o.length;Pe(t,m,u)}function te(t,o){ee(t,o)}function ne(t){ee(t)}function oe(t,o){t.selectionStart=o,t.selectionEnd=o}function ie(t={}){const o=t.delay??400,r=t.interval??60;let a,s;function i(){a&&(clearTimeout(a),a=void 0),s&&(clearInterval(s),s=void 0)}function m(u){i(),u(),a=setTimeout(()=>{s=setInterval(()=>{u()},r)},o)}return{start:m,stop:i}}function Ne(t=!1){const o=e.ref(!1),r=e.ref(0);async function a(){const i=I();if(i)try{o.value=await i.initialize({onProgress:m=>{r.value=m}})}catch(m){console.error("初始化手写识别服务失败:",m),o.value=!1}else console.warn("未注册手写识别服务"),o.value=!1}async function s(){const i=I();if(i&&o.value)try{await i.close(),o.value=!1}catch(m){console.error("关闭手写识别服务失败:",m)}}return e.onMounted(()=>{t&&a()}),e.onUnmounted(()=>{s()}),{recognizerInitialized:o,recognizerProgress:r}}const F="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z'%20/%3e%3c/svg%3e",O="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e";function K(){const t=ie();function o(a,s){var i,m;a.preventDefault(),(m=(i=a.currentTarget)==null?void 0:i.setPointerCapture)==null||m.call(i,a.pointerId),t.start(s)}function r(){t.stop()}return e.onBeforeUnmount(()=>{t.stop()}),{startRepeat:o,stopRepeat:r}}const Me={class:"zhk-candidate-list"},Se=["onClick"],re=e.defineComponent({__name:"CandidateList",props:{candidates:{}},emits:["select"],setup(t,{emit:o}){const r=o;function a(s){r("select",s)}return(s,i)=>(e.openBlock(),e.createElementBlock("div",Me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.candidates,(m,u)=>(e.openBlock(),e.createElementBlock("button",{key:`candidate-${u}`,class:"zhk-candidate-list__item",onClick:f=>a(u)},e.toDisplayString(m),9,Se))),128))]))}}),$e={class:"handwriting-input"},Le={class:"handwriting-content"},Te={class:"handwriting-buttons"},De={class:"handwriting-canvas-container"},Re={key:0,class:"handwriting-loading"},He={class:"progress-bar"},Ie={class:"progress-text"},Ae={class:"handwriting-buttons"},Ke=e.defineComponent({__name:"HandwritingInput",props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:["key","exit"],setup(t,{emit:o}){const r=t,a=o,s=e.ref(null);let i=null;const m=e.ref(!1),{width:u,height:f}=X(s);function y(){i&&i.clearCanvas()}function g(){s.value&&(i&&i.destroy(),s.value.width=u.value,s.value.height=f.value,i=new Y(s.value,{onDrawEnd:p}))}const d=e.ref([]),{startRepeat:k,stopRepeat:c}=K();async function p(){if(!i||i.getStrokeData().length===0||m.value)return;const w=I();if(w){m.value=!0;try{const n=[...i.getStrokeData()],h=await w.recognize(n);d.value=h}catch(n){console.error("识别笔迹失败:",n)}finally{m.value=!1}}else console.warn("手写识别服务不可用")}e.onUnmounted(()=>{i&&i.destroy()}),e.watchEffect(()=>{s.value&&(u.value||f.value)&&r.recognizerInitialized&&e.nextTick(()=>{g()})});function C(w){const n=d.value[w];n&&(a("key",{key:n}),d.value=[],y())}return(w,n)=>(e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(re,{candidates:d.value,onSelect:C},null,8,["candidates"]),e.createElementVNode("div",Le,[e.createElementVNode("div",Te,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[0]||(n[0]=h=>e.unref(k)(h,()=>a("key",{key:"。"}))),onPointerup:n[1]||(n[1]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[2]||(n[2]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[3]||(n[3]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[4]||(n[4]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[5]||(n[5]=h=>e.unref(k)(h,()=>a("key",{key:"?"}))),onPointerup:n[6]||(n[6]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[7]||(n[7]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[8]||(n[8]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[9]||(n[9]=e.withModifiers(()=>{},["prevent"]))}," ? ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[10]||(n[10]=h=>e.unref(k)(h,()=>a("key",{key:"!"}))),onPointerup:n[11]||(n[11]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[12]||(n[12]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[13]||(n[13]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[14]||(n[14]=e.withModifiers(()=>{},["prevent"]))}," ! ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[15]||(n[15]=h=>e.unref(k)(h,()=>a("key",{key:"、"}))),onPointerup:n[16]||(n[16]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[17]||(n[17]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[18]||(n[18]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[19]||(n[19]=e.withModifiers(()=>{},["prevent"]))}," 、 ",32)]),e.createElementVNode("div",De,[w.recognizerInitialized?(e.openBlock(),e.createElementBlock("canvas",{key:1,ref_key:"canvasRef",ref:s,class:"handwriting-canvas"},null,512)):(e.openBlock(),e.createElementBlock("div",Re,[n[37]||(n[37]=e.createElementVNode("div",{class:"loading-text"}," 正在加载手写识别... ",-1)),e.createElementVNode("div",He,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${w.recognizerProgress*100}%`})},null,4)]),e.createElementVNode("div",Ie,e.toDisplayString(Math.round(w.recognizerProgress*100))+"% ",1)]))]),e.createElementVNode("div",Ae,[e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[20]||(n[20]=h=>e.unref(k)(h,()=>a("key",{key:"delete",isControl:!0}))),onPointerup:n[21]||(n[21]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[22]||(n[22]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[23]||(n[23]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[24]||(n[24]=e.withModifiers(()=>{},["prevent"]))},n[38]||(n[38]=[e.createElementVNode("img",{src:F,alt:"删除"},null,-1)]),32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onClick:n[25]||(n[25]=h=>a("exit")),onContextmenu:n[26]||(n[26]=e.withModifiers(()=>{},["prevent"]))}," 拼音 ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[27]||(n[27]=h=>e.unref(k)(h,()=>a("key",{key:","}))),onPointerup:n[28]||(n[28]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[29]||(n[29]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[30]||(n[30]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[31]||(n[31]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"handwriting-btn handwriting-btn--function",onPointerdown:n[32]||(n[32]=h=>e.unref(k)(h,()=>a("key",{key:"enter",isControl:!0}))),onPointerup:n[33]||(n[33]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointerleave:n[34]||(n[34]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onPointercancel:n[35]||(n[35]=(...h)=>e.unref(c)&&e.unref(c)(...h)),onContextmenu:n[36]||(n[36]=e.withModifiers(()=>{},["prevent"]))},n[39]||(n[39]=[e.createElementVNode("img",{src:O,alt:"回车"},null,-1)]),32)])])]))}}),We="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e",se="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e",ve="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e",Fe={class:"zhk-selection"},Oe={class:"zhk-selection__list"},Ue=["onClick"],Ze=e.defineComponent({__name:"CandidateSelection",props:{candidates:{}},emits:["select","close"],setup(t,{emit:o}){const r=o;function a(m){r("select",m)}function s(){r("close")}function i(m){const u=Array.from(m).length;return u>=2&&u<=3?2:u>=4?3:1}return(m,u)=>(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.candidates,(f,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["zhk-selection__text",[`zhk-selection__text--span-${i(f)}`]]),onClick:g=>a(y)},e.toDisplayString(f),11,Ue))),128))]),e.createElementVNode("div",{class:"zhk-selection__func"},[e.createElementVNode("button",{class:"zhk-selection__func-btn",onClick:s}," 返回 ")])]))}}),je={class:"zhk-candidate"},Xe={class:"zhk-candidate__container"},Ye={key:0,class:"zhk-candidate__pinyin"},Ge={class:"zhk-candidate__bottom-container"},qe=e.defineComponent({__name:"CandidateBar",props:{modelValue:{required:!0},modelModifiers:{}},emits:e.mergeModels(["key","input"],["update:modelValue"]),setup(t,{expose:o,emit:r}){const a=r,s=e.useModel(t,"modelValue");let i=null;const m=e.ref(null),u=e.computed(()=>{var d;return((d=m.value)==null?void 0:d.candidates.map(k=>k.text))??[]}),f=e.ref(!1);e.onMounted(async()=>{if(i=J(),!i)throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");s.value&&(m.value=await i.processInput(s.value))}),e.onUnmounted(()=>{i==null||i.processInput("").catch(()=>{}),i=null}),e.watch(s,async d=>{const k=i;if(k){if(d===""){k.processInput("").catch(()=>{}),m.value=null;return}m.value=await k.processInput(d)}});async function y(d){if(!i)return;const k=await i.pickCandidate(d);m.value=k,k.preeditBody||(a("input",k.committed||""),s.value="",m.value=null,f.value=!1)}o({handleSelection:y});const g=e.computed(()=>{const d=m.value;return d?d.preeditHead+d.preeditBody:""});return(d,k)=>(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Xe,[g.value?(e.openBlock(),e.createElementBlock("div",Ye,e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Ge,[u.value.length>0?(e.openBlock(),e.createBlock(re,{key:0,candidates:u.value,onSelect:y},null,8,["candidates"])):e.createCommentVNode("",!0),u.value.length>0?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-candidate__more",onClick:k[0]||(k[0]=c=>f.value=!0)},k[2]||(k[2]=[e.createElementVNode("img",{src:ve,alt:"更多"},null,-1)]))):e.createCommentVNode("",!0)])]),f.value?(e.openBlock(),e.createBlock(Ze,{key:0,candidates:u.value,onSelect:y,onClose:k[1]||(k[1]=c=>f.value=!1)},null,8,["candidates"])):e.createCommentVNode("",!0)]))}}),Je={class:"zhk-base"},Qe={class:"zhk-base__row"},et=["onPointerdown"],tt=["disabled"],nt={key:1,src:We,class:"zhk-base__key-icon",alt:"Shift"},ot=["onPointerdown"],it={class:"zhk-base__row"},rt={class:"zhk-base__toggle-main"},st={class:"zhk-base__toggle-sub"},lt=e.defineComponent({__name:"KeyboardBase",props:e.mergeModels({enableHandwriting:{type:Boolean}},{modelValue:{default:"en"},modelModifiers:{}}),emits:e.mergeModels(["key"],["update:modelValue"]),setup(t,{emit:o}){const r=t,a=o,s=e.useModel(t,"modelValue"),i=e.computed(()=>s.value==="en_cap"),m=e.computed(()=>s.value==="zh"),u=e.computed(()=>m.value?!0:i.value);function f(P,l=!1){a("key",{key:P,isControl:l})}function y(){m.value?s.value="hand":s.value=i.value?"en":"en_cap"}function g(){s.value="num"}function d(){s.value="symbol"}const k=["1","2","3","4","5","6","7","8","9","0"],c=[["q","w","e","r","t","y","u","i","o","p"],["a","s","d","f","g","h","j","k","l"],["z","x","c","v","b","n","m"]],p=e.ref(""),C=e.ref(null),{startRepeat:w,stopRepeat:n}=K();function h(){if(s.value==="zh"&&p.value){p.value=p.value.slice(0,-1);return}f("delete",!0)}function L(){var P;if(s.value==="zh"&&p.value){(P=C.value)==null||P.handleSelection(0);return}f(" ")}function U(){if(s.value==="zh"&&p.value){f(p.value),p.value="";return}f("enter",!0)}function T(P){if(s.value==="zh"){p.value+=P;return}const l=i.value?P.toUpperCase():P;f(l)}function Z(){s.value=s.value==="zh"?"en":"zh"}const z=e.computed(()=>r.enableHandwriting?"手写":"-"),V=e.computed(()=>!r.enableHandwriting);return(P,l)=>(e.openBlock(),e.createElementBlock("div",Je,[e.createElementVNode("div",Qe,[s.value==="zh"?(e.openBlock(),e.createBlock(qe,{key:0,ref_key:"candidateBarRef",ref:C,modelValue:p.value,"onUpdate:modelValue":l[0]||(l[0]=b=>p.value=b),onInput:l[1]||(l[1]=b=>f(b,!1))},null,8,["modelValue"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},e.renderList(k,(b,D)=>e.createElementVNode("button",{key:`number-${D}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:B=>e.unref(w)(B,()=>T(b)),onPointerup:l[2]||(l[2]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointerleave:l[3]||(l[3]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointercancel:l[4]||(l[4]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onContextmenu:l[5]||(l[5]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(b),41,et)),64))]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(c,(b,D)=>e.createElementVNode("div",{key:`row-${D}`,class:"zhk-base__row"},[D===2?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["zhk-base__key zhk-base__key--function zhk-base__key--shift",{"zhk-base__key--active":!m.value&&i.value,"zhk-base__key--disabled":m.value&&V.value}]),disabled:m.value&&V.value,onClick:y,onContextmenu:l[6]||(l[6]=e.withModifiers(()=>{},["prevent"]))},[m.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(z.value),1)],64)):(e.openBlock(),e.createElementBlock("img",nt))],42,tt)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(B,Rt)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${D}-${Rt}`,class:"zhk-base__key zhk-base__key--letter",onPointerdown:S=>e.unref(w)(S,()=>T(B)),onPointerup:l[7]||(l[7]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onPointerleave:l[8]||(l[8]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onPointercancel:l[9]||(l[9]=(...S)=>e.unref(n)&&e.unref(n)(...S)),onContextmenu:l[10]||(l[10]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(u.value?B.toUpperCase():B),41,ot))),128)),D===2?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zhk-base__key zhk-base__key--function zhk-base__key--delete",onPointerdown:l[11]||(l[11]=B=>e.unref(w)(B,()=>h())),onPointerup:l[12]||(l[12]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointerleave:l[13]||(l[13]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onPointercancel:l[14]||(l[14]=(...B)=>e.unref(n)&&e.unref(n)(...B)),onContextmenu:l[15]||(l[15]=e.withModifiers(()=>{},["prevent"]))},l[39]||(l[39]=[e.createElementVNode("img",{src:F,class:"zhk-base__key-icon",alt:"Delete"},null,-1)]),32)):e.createCommentVNode("",!0)])),64)),e.createElementVNode("div",it,[e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:d,onContextmenu:l[16]||(l[16]=e.withModifiers(()=>{},["prevent"]))}," 符 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:g,onContextmenu:l[17]||(l[17]=e.withModifiers(()=>{},["prevent"]))}," 123 ",32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:l[18]||(l[18]=b=>e.unref(w)(b,()=>f(","))),onPointerup:l[19]||(l[19]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[20]||(l[20]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[21]||(l[21]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[22]||(l[22]=e.withModifiers(()=>{},["prevent"]))}," , ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--space",onPointerdown:l[23]||(l[23]=b=>e.unref(w)(b,()=>L())),onPointerup:l[24]||(l[24]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[25]||(l[25]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[26]||(l[26]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[27]||(l[27]=e.withModifiers(()=>{},["prevent"]))},l[40]||(l[40]=[e.createElementVNode("img",{src:se,class:"zhk-base__key-icon",alt:"Space"},null,-1)]),32),e.createElementVNode("button",{class:"zhk-base__key",onPointerdown:l[28]||(l[28]=b=>e.unref(w)(b,()=>f("。"))),onPointerup:l[29]||(l[29]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[30]||(l[30]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[31]||(l[31]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[32]||(l[32]=e.withModifiers(()=>{},["prevent"]))}," 。 ",32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onClick:Z,onContextmenu:l[33]||(l[33]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("span",rt,e.toDisplayString(s.value==="zh"?"中":"英"),1),e.createElementVNode("span",st,"/"+e.toDisplayString(s.value==="zh"?"英":"中"),1)],32),e.createElementVNode("button",{class:"zhk-base__key zhk-base__key--function",onPointerdown:l[34]||(l[34]=b=>e.unref(w)(b,()=>U())),onPointerup:l[35]||(l[35]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointerleave:l[36]||(l[36]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onPointercancel:l[37]||(l[37]=(...b)=>e.unref(n)&&e.unref(n)(...b)),onContextmenu:l[38]||(l[38]=e.withModifiers(()=>{},["prevent"]))},l[41]||(l[41]=[e.createElementVNode("img",{src:O,class:"zhk-base__key-icon",alt:"Enter"},null,-1)]),32)])]))}}),at={class:"num-keyboard"},dt={class:"num-keyboard__container"},ct={class:"num-keyboard__left"},ft={class:"num-keyboard__rows"},ut=["onClick","onPointerdown"],mt={key:1,src:se,class:"zhk-base__key-icon",alt:"Space"},pt={class:"num-keyboard__right"},kt=["onPointerdown"],ht=["src","alt"],gt={key:1},yt=e.defineComponent({__name:"NumericKeyboard",props:{keyboardRows:{default:()=>M().numKeys||[["1","2","3"],["4","5","6"],["7","8","9"],["back","0","space"]]}},emits:["key","exit"],setup(t,{emit:o}){const r=o,a=[{key:"delete",icon:F,text:"",alt:"Delete"},{key:".",icon:"",text:".",alt:"."},{key:"@",icon:"",text:"@",alt:"@"},{key:"enter",icon:O,text:"",alt:"Enter"}];function s(g){r("key",{key:g})}function i(g,d=!0){r("key",{key:g,isControl:d})}function m(){r("exit")}const{startRepeat:u,stopRepeat:f}=K();function y(g,d){g==="back"||(g==="space"&&(g=" "),g==="delete"||g==="enter"?u(d,()=>i(g)):u(d,()=>s(g)))}return(g,d)=>(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",dt,[e.createElementVNode("div",ct,[e.createElementVNode("div",ft,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.keyboardRows,(k,c)=>(e.openBlock(),e.createElementBlock("div",{key:`row-${c}`,class:"num-keyboard__row"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k,(p,C)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${c}-${C}`,class:e.normalizeClass(["num-keyboard__key",{"num-keyboard__key--back":p==="back","num-keyboard__key--space":p==="space"}]),onClick:w=>p==="back"&&m(),onPointerdown:w=>y(p,w),onPointerup:d[0]||(d[0]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointerleave:d[1]||(d[1]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onPointercancel:d[2]||(d[2]=(...w)=>e.unref(f)&&e.unref(f)(...w)),onContextmenu:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[p==="back"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" 返回 ")],64)):p==="space"?(e.openBlock(),e.createElementBlock("img",mt)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(p),1)],64))],42,ut))),128))]))),128))])]),e.createElementVNode("div",pt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,(k,c)=>e.createElementVNode("button",{key:`func-${c}`,class:"num-keyboard__key num-keyboard__key--function",onPointerdown:p=>y(k.key,p),onPointerup:d[4]||(d[4]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointerleave:d[5]||(d[5]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onPointercancel:d[6]||(d[6]=(...p)=>e.unref(f)&&e.unref(f)(...p)),onContextmenu:d[7]||(d[7]=e.withModifiers(()=>{},["prevent"]))},[k.icon?(e.openBlock(),e.createElementBlock("img",{key:0,src:k.icon,class:"num-keyboard__key-icon",alt:k.alt},null,8,ht)):(e.openBlock(),e.createElementBlock("span",gt,e.toDisplayString(k.text),1))],40,kt)),64))])])]))}}),bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e",wt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e",Et={class:"symbol-keyboard"},Ct={class:"symbol-keyboard__content"},Bt={class:"symbol-keyboard__functions"},zt={class:"symbol-keyboard__lang-selector"},Vt={class:"symbol-keyboard__control-group"},xt=["src"],Pt=["src"],_t={class:"symbol-keyboard__symbols-container"},Nt={class:"symbol-keyboard__symbols-grid"},Mt=["onClick","onPointerdown"],St="!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°",$t="!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°",Lt=e.defineComponent({__name:"SymbolKeyboard",emits:["key","exit"],setup(t,{emit:o}){const r=o,a=e.ref("en"),s=e.computed(()=>a.value==="zh"?$t:St),i=e.ref(!1),{startRepeat:m,stopRepeat:u}=K();function f(c,p){i.value&&m(p,()=>y(c))}function y(c){r("key",{key:c}),i.value||r("exit")}function g(){r("exit")}function d(c){a.value=c}function k(){i.value=!i.value}return(c,p)=>(e.openBlock(),e.createElementBlock("div",Et,[e.createElementVNode("div",Ct,[e.createElementVNode("div",Bt,[e.createElementVNode("div",zt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="zh"}]),onClick:p[0]||(p[0]=C=>d("zh")),onContextmenu:p[1]||(p[1]=e.withModifiers(()=>{},["prevent"]))}," 中文 ",34),e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__lang-btn",{"symbol-keyboard__lang-btn--active":a.value==="en"}]),onClick:p[2]||(p[2]=C=>d("en")),onContextmenu:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))}," 英文 ",34)]),e.createElementVNode("div",Vt,[e.createElementVNode("button",{class:e.normalizeClass(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock",{"symbol-keyboard__key--locked":i.value}]),onClick:k,onContextmenu:p[4]||(p[4]=e.withModifiers(()=>{},["prevent"]))},[i.value?(e.openBlock(),e.createElementBlock("img",{key:1,src:e.unref(wt),alt:"Lock closed"},null,8,Pt)):(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(bt),alt:"Lock open"},null,8,xt))],34),e.createElementVNode("button",{class:"symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",onClick:g,onContextmenu:p[5]||(p[5]=e.withModifiers(()=>{},["prevent"]))}," 返回 ",32)])]),e.createElementVNode("div",_t,[e.createElementVNode("div",Nt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(C,w)=>(e.openBlock(),e.createElementBlock("button",{key:`key-${w}`,class:"symbol-keyboard__key",onClick:n=>!i.value&&y(C),onPointerdown:n=>f(C,n),onPointerup:p[6]||(p[6]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onPointerleave:p[7]||(p[7]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onPointercancel:p[8]||(p[8]=(...n)=>e.unref(u)&&e.unref(u)(...n)),onContextmenu:p[9]||(p[9]=e.withModifiers(()=>{},["prevent"]))},e.toDisplayString(C),41,Mt))),128))])])])]))}}),Tt={key:0,class:"zhk__disabled-overlay"},le=e.defineComponent({__name:"ZhKeyboard",props:{defaultMode:{type:String,default:()=>M().defaultMode??"en"},enableHandwriting:{type:Boolean,default:()=>M().enableHandwriting??!1},position:{type:String,default:()=>M().position??"static"},floatMarginTop:{type:Number,default:()=>M().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>M().disableWhenNoFocus??!0},numKeys:{type:Array||void 0}},emits:["key"],setup(t,{emit:o}){const r=t,a=o,s=e.ref(r.defaultMode),i=e.ref(r.defaultMode),m=e.ref([]),u=e.ref(!1),f=e.ref(null),y=e.ref(null),{recognizerInitialized:g,recognizerProgress:d}=Ne(r.enableHandwriting);e.watch(s,(z,V)=>{z!==V&&(i.value=V)});const k=Ee(),c=e.computed(()=>k.value&&A(k.value)?k.value:null),p=e.computed(()=>r.position==="static"||!!(k.value&&A(k.value))),{height:C}=X(y);e.watchEffect(()=>{if(c.value){const z=c.value.dataset.inputmode;z&&(s.value=z)}});const w=e.computed(()=>r.disableWhenNoFocus===!1?!1:!c.value);function n(){if(!C.value)return;const z=Q(c.value,y.value,r.position,r.floatMarginTop);f.value=z}e.watchEffect(n);const h=ke(n,100);H(window,"scroll",h,{passive:!0}),H(window,"resize",h,{passive:!0});function L(z){if(z.isControl){switch(z.key){case"delete":ne(c.value);break;case"more":u.value=!0;break}return}else U(z.key);a("key",z)}function U(z){te(c.value,z)}function T(){s.value==="hand"?i.value="zh":["num","symbol"].includes(i.value)&&(i.value=r.defaultMode),s.value=i.value}function Z(z){m.value=z}return(z,V)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{ref_key:"keyboardRef",ref:y,class:e.normalizeClass(["zhk",{"zhk--floating":t.position==="float","zhk--bottom":t.position==="bottom","zhk--disabled":w.value}]),style:e.normalizeStyle({"--keyboard-height":`${e.unref(C)}px`,...f.value}),onMousedown:V[1]||(V[1]=e.withModifiers(()=>{},["prevent"]))},[w.value||!p.value||!e.unref(C)?(e.openBlock(),e.createElementBlock("div",Tt,V[2]||(V[2]=[e.createElementVNode("span",null,"请选择输入框以启用键盘",-1)]))):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[s.value==="hand"?(e.openBlock(),e.createBlock(Ke,{key:0,"recognizer-initialized":e.unref(g),"recognizer-progress":e.unref(d),onKey:L,onExit:T,onRecognize:Z},null,8,["recognizer-initialized","recognizer-progress"])):s.value==="num"?(e.openBlock(),e.createBlock(yt,{key:1,"keyboard-rows":t.numKeys,onKey:L,onExit:T},null,8,["keyboard-rows"])):s.value==="symbol"?(e.openBlock(),e.createBlock(Lt,{key:2,onKey:L,onExit:T})):s.value==="en"||s.value==="en_cap"||s.value==="zh"?(e.openBlock(),e.createBlock(lt,{key:3,modelValue:s.value,"onUpdate:modelValue":V[0]||(V[0]=P=>s.value=P),"enable-handwriting":t.enableHandwriting,onKey:L},null,8,["modelValue","enable-handwriting"])):e.createCommentVNode("",!0)],64))],38)),[[e.vShow,p.value]])}}),Dt={install:t=>{t.component("ZhKeyboard",le)}};E.CanvasDrawer=Y,E.ZhKeyboard=le,E.calculateKeyboardPosition=Q,E.createKeyRepeater=ie,E.default=Dt,E.delToInputElement=ne,E.getHandwritingRecognizer=I,E.getInputElement=xe,E.getKeyboardConfig=M,E.getPinyinEngine=J,E.isInputElement=A,E.moveCursor=oe,E.registerHandwritingRecognizer=ze,E.registerPinyinEngine=Ve,E.setKeyboardConfig=Be,E.writeToInputElement=te,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
2
2
|
//# sourceMappingURL=zh-keyboard-vue.umd.cjs.map
|