@zh-keyboard/vue 1.1.1 → 1.1.2

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.
@@ -1,1429 +1,992 @@
1
- var Pe = Object.defineProperty;
2
- var _e = (e, o, i) => o in e ? Pe(e, o, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[o] = i;
3
- var R = (e, o, i) => _e(e, typeof o != "symbol" ? o + "" : o, i);
4
- import { onMounted as Q, nextTick as fe, watch as X, getCurrentScope as Ee, onScopeDispose as $e, getCurrentInstance as me, toValue as B, shallowRef as G, computed as S, watchEffect as q, unref as n, ref as $, onUnmounted as de, onBeforeUnmount as Se, defineComponent as I, createElementBlock as x, openBlock as b, Fragment as L, renderList as V, toDisplayString as D, createVNode as Le, createElementVNode as g, withModifiers as C, normalizeStyle as pe, normalizeClass as O, mergeModels as se, useModel as ke, createBlock as K, createCommentVNode as W, createTextVNode as ie, withDirectives as Te, vShow as Re } from "vue";
5
- function ee(e) {
6
- return Ee() ? ($e(e), !0) : !1;
7
- }
8
- const De = typeof window < "u" && typeof document < "u";
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, getCurrentInstance as l, getCurrentScope as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as h, onMounted as g, onScopeDispose as _, onUnmounted as v, openBlock as y, ref as b, renderList as x, shallowRef as S, toDisplayString as C, toValue as w, unref as T, useModel as E, vShow as D, watch as O, watchEffect as k, withDirectives as A, withModifiers as j } from "vue";
2
+ import { CanvasDrawer as M, calculateKeyboardPosition as N, createKeyRepeater as P, delToInputElement as F, getHandwritingRecognizer as I, getKeyboardConfig as L, getPinyinEngine as R, isInputElement as z, writeToInputElement as ee } from "@zh-keyboard/core";
3
+ export * from "@zh-keyboard/core";
4
+ //#region ../../node_modules/.pnpm/@vueuse+shared@13.1.0_vue@3.5.13_typescript@5.8.3_/node_modules/@vueuse/shared/index.mjs
5
+ function B(e) {
6
+ return u() ? (_(e), !0) : !1;
7
+ }
8
+ var V = typeof window < "u" && typeof document < "u";
9
9
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
10
- const Me = (e) => e != null, He = Object.prototype.toString, Ve = (e) => He.call(e) === "[object Object]", re = () => {
11
- };
12
- function Be(e, o) {
13
- function i(...a) {
14
- return new Promise((r, s) => {
15
- Promise.resolve(e(() => o.apply(this, a), { fn: o, thisArg: this, args: a })).then(r).catch(s);
16
- });
17
- }
18
- return i;
19
- }
20
- function Ie(e, o = {}) {
21
- let i, a, r = re;
22
- const s = (c) => {
23
- clearTimeout(c), r(), r = re;
24
- };
25
- let f;
26
- return (c) => {
27
- const y = B(e), h = B(o.maxWait);
28
- return i && s(i), y <= 0 || h !== void 0 && h <= 0 ? (a && (s(a), a = null), Promise.resolve(c())) : new Promise((u, p) => {
29
- r = o.rejectOnCancel ? p : u, f = c, h && !a && (a = setTimeout(() => {
30
- i && s(i), a = null, u(f());
31
- }, h)), i = setTimeout(() => {
32
- a && s(a), a = null, u(c());
33
- }, y);
34
- });
35
- };
36
- }
37
- function j(e) {
38
- return Array.isArray(e) ? e : [e];
39
- }
40
- function Ae(e) {
41
- return me();
42
- }
43
- function Ke(e, o = 200, i = {}) {
44
- return Be(
45
- Ie(o, i),
46
- e
47
- );
48
- }
49
- function We(e, o = !0, i) {
50
- Ae() ? Q(e, i) : o ? e() : fe(e);
51
- }
52
- function Oe(e, o, i) {
53
- return X(
54
- e,
55
- o,
56
- {
57
- ...i,
58
- immediate: !0
59
- }
60
- );
61
- }
62
- const Y = De ? window : void 0;
63
- function H(e) {
64
- var o;
65
- const i = B(e);
66
- return (o = i == null ? void 0 : i.$el) != null ? o : i;
67
- }
68
- function J(...e) {
69
- const o = [], i = () => {
70
- o.forEach((v) => v()), o.length = 0;
71
- }, a = (v, c, y, h) => (v.addEventListener(c, y, h), () => v.removeEventListener(c, y, h)), r = S(() => {
72
- const v = j(B(e[0])).filter((c) => c != null);
73
- return v.every((c) => typeof c != "string") ? v : void 0;
74
- }), s = Oe(
75
- () => {
76
- var v, c;
77
- return [
78
- (c = (v = r.value) == null ? void 0 : v.map((y) => H(y))) != null ? c : [Y].filter((y) => y != null),
79
- j(B(r.value ? e[1] : e[0])),
80
- j(n(r.value ? e[2] : e[1])),
81
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
82
- B(r.value ? e[3] : e[2])
83
- ];
84
- },
85
- ([v, c, y, h]) => {
86
- if (i(), !(v != null && v.length) || !(c != null && c.length) || !(y != null && y.length))
87
- return;
88
- const u = Ve(h) ? { ...h } : h;
89
- o.push(
90
- ...v.flatMap(
91
- (p) => c.flatMap(
92
- (d) => y.map((m) => a(p, d, m, u))
93
- )
94
- )
95
- );
96
- },
97
- { flush: "post" }
98
- ), f = () => {
99
- s(), i();
100
- };
101
- return ee(i), f;
102
- }
103
- function Ne() {
104
- const e = G(!1), o = me();
105
- return o && Q(() => {
106
- e.value = !0;
107
- }, o), e;
108
- }
109
- function he(e) {
110
- const o = Ne();
111
- return S(() => (o.value, !!e()));
112
- }
113
- function Ue(e, o, i = {}) {
114
- const { window: a = Y, ...r } = i;
115
- let s;
116
- const f = he(() => a && "MutationObserver" in a), v = () => {
117
- s && (s.disconnect(), s = void 0);
118
- }, c = S(() => {
119
- const p = B(e), d = j(p).map(H).filter(Me);
120
- return new Set(d);
121
- }), y = X(
122
- () => c.value,
123
- (p) => {
124
- v(), f.value && p.size && (s = new MutationObserver(o), p.forEach((d) => s.observe(d, r)));
125
- },
126
- { immediate: !0, flush: "post" }
127
- ), h = () => s == null ? void 0 : s.takeRecords(), u = () => {
128
- y(), v();
129
- };
130
- return ee(u), {
131
- isSupported: f,
132
- stop: u,
133
- takeRecords: h
134
- };
135
- }
136
- function Fe(e, o, i = {}) {
137
- const {
138
- window: a = Y,
139
- document: r = a == null ? void 0 : a.document,
140
- flush: s = "sync"
141
- } = i;
142
- if (!a || !r)
143
- return re;
144
- let f;
145
- const v = (h) => {
146
- f == null || f(), f = h;
147
- }, c = q(() => {
148
- const h = H(e);
149
- if (h) {
150
- const { stop: u } = Ue(
151
- r,
152
- (p) => {
153
- p.map((m) => [...m.removedNodes]).flat().some((m) => m === h || m.contains(h)) && o(p);
154
- },
155
- {
156
- window: a,
157
- childList: !0,
158
- subtree: !0
159
- }
160
- );
161
- v(u);
162
- }
163
- }, { flush: s }), y = () => {
164
- c(), v();
165
- };
166
- return ee(y), y;
167
- }
168
- function Ze(e = {}) {
169
- var o;
170
- const {
171
- window: i = Y,
172
- deep: a = !0,
173
- triggerOnRemoval: r = !1
174
- } = e, s = (o = e.document) != null ? o : i == null ? void 0 : i.document, f = () => {
175
- var y;
176
- let h = s == null ? void 0 : s.activeElement;
177
- if (a)
178
- for (; h != null && h.shadowRoot; )
179
- h = (y = h == null ? void 0 : h.shadowRoot) == null ? void 0 : y.activeElement;
180
- return h;
181
- }, v = G(), c = () => {
182
- v.value = f();
183
- };
184
- if (i) {
185
- const y = {
186
- capture: !0,
187
- passive: !0
188
- };
189
- J(
190
- i,
191
- "blur",
192
- (h) => {
193
- h.relatedTarget === null && c();
194
- },
195
- y
196
- ), J(
197
- i,
198
- "focus",
199
- c,
200
- y
201
- );
202
- }
203
- return r && Fe(v, c, { document: s }), c(), v;
204
- }
205
- function Xe(e, o, i = {}) {
206
- const { window: a = Y, ...r } = i;
207
- let s;
208
- const f = he(() => a && "ResizeObserver" in a), v = () => {
209
- s && (s.disconnect(), s = void 0);
210
- }, c = S(() => {
211
- const u = B(e);
212
- return Array.isArray(u) ? u.map((p) => H(p)) : [H(u)];
213
- }), y = X(
214
- c,
215
- (u) => {
216
- if (v(), f.value && a) {
217
- s = new ResizeObserver(o);
218
- for (const p of u)
219
- p && s.observe(p, r);
220
- }
221
- },
222
- { immediate: !0, flush: "post" }
223
- ), h = () => {
224
- v(), y();
225
- };
226
- return ee(h), {
227
- isSupported: f,
228
- stop: h
229
- };
230
- }
231
- function ge(e, o = { width: 0, height: 0 }, i = {}) {
232
- const { window: a = Y, box: r = "content-box" } = i, s = S(() => {
233
- var u, p;
234
- return (p = (u = H(e)) == null ? void 0 : u.namespaceURI) == null ? void 0 : p.includes("svg");
235
- }), f = G(o.width), v = G(o.height), { stop: c } = Xe(
236
- e,
237
- ([u]) => {
238
- const p = r === "border-box" ? u.borderBoxSize : r === "content-box" ? u.contentBoxSize : u.devicePixelContentBoxSize;
239
- if (a && s.value) {
240
- const d = H(e);
241
- if (d) {
242
- const m = d.getBoundingClientRect();
243
- f.value = m.width, v.value = m.height;
244
- }
245
- } else if (p) {
246
- const d = j(p);
247
- f.value = d.reduce((m, { inlineSize: P }) => m + P, 0), v.value = d.reduce((m, { blockSize: P }) => m + P, 0);
248
- } else
249
- f.value = u.contentRect.width, v.value = u.contentRect.height;
250
- },
251
- i
252
- );
253
- We(() => {
254
- const u = H(e);
255
- u && (f.value = "offsetWidth" in u ? u.offsetWidth : o.width, v.value = "offsetHeight" in u ? u.offsetHeight : o.height);
256
- });
257
- const y = X(
258
- () => H(e),
259
- (u) => {
260
- f.value = u ? o.width : 0, v.value = u ? o.height : 0;
261
- }
262
- );
263
- function h() {
264
- c(), y();
265
- }
266
- return {
267
- width: f,
268
- height: v,
269
- stop: h
270
- };
271
- }
272
- var Ye = class {
273
- constructor(e, o = {}) {
274
- R(this, "canvas");
275
- R(this, "ctx");
276
- R(this, "lastX", 0);
277
- R(this, "lastY", 0);
278
- R(this, "strokeData", []);
279
- R(this, "clearTimerId", null);
280
- R(this, "isDrawing", !1);
281
- R(this, "options");
282
- R(this, "handleStart", (e) => {
283
- e.preventDefault(), this.isDrawing = !0;
284
- const { offsetX: o, offsetY: i } = this.getEventCoordinates(e);
285
- this.startDrawing(o, i), this.resetClearTimer();
286
- });
287
- R(this, "handleMove", (e) => {
288
- if (!this.isDrawing) return;
289
- e.preventDefault();
290
- const { offsetX: o, offsetY: i } = this.getEventCoordinates(e);
291
- this.draw(o, i), this.resetClearTimer();
292
- });
293
- R(this, "handleEnd", (e) => {
294
- this.isDrawing && (e.preventDefault(), this.isDrawing = !1, this.endStroke(), this.startClearTimer(), this.options.onDrawEnd && this.options.onDrawEnd());
295
- });
296
- this.canvas = e, this.options = {
297
- clearDelay: 1e3,
298
- ...o
299
- };
300
- const i = this.canvas.getContext("2d");
301
- if (!i) throw new Error("Failed to get 2D rendering context");
302
- this.ctx = i, this.setupCanvas(), this.attachEvents();
303
- }
304
- setupCanvas() {
305
- this.ctx.lineJoin = "round", this.ctx.lineCap = "round", this.ctx.lineWidth = 3, this.ctx.strokeStyle = "#000", this.clearCanvas(), this.drawGrid();
306
- }
307
- drawGrid() {
308
- const e = this.canvas.width, o = this.canvas.height;
309
- 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(e, o / 2), this.ctx.moveTo(e / 2, 0), this.ctx.lineTo(e / 2, o), this.ctx.stroke(), this.ctx.setLineDash([]), this.ctx.beginPath(), this.ctx.rect(0, 0, e, o), this.ctx.stroke(), this.ctx.restore();
310
- }
311
- clearCanvas() {
312
- this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.drawGrid(), this.strokeData = [], this.resetClearTimer();
313
- }
314
- startDrawing(e, o) {
315
- this.lastX = e, this.lastY = o, this.ctx.strokeStyle = "#000", this.ctx.lineWidth = 3, this.ctx.setLineDash([]), this.strokeData.push(e, o, 0);
316
- }
317
- draw(e, o) {
318
- this.ctx.beginPath(), this.ctx.moveTo(this.lastX, this.lastY), this.ctx.lineTo(e, o), this.ctx.stroke(), this.lastX = e, this.lastY = o, this.strokeData.push(e, o, 0);
319
- }
320
- endStroke() {
321
- this.strokeData.length >= 3 && (this.strokeData[this.strokeData.length - 1] = 1);
322
- }
323
- getStrokeData() {
324
- return this.strokeData;
325
- }
326
- resetClearTimer() {
327
- this.clearTimerId && (window.clearTimeout(this.clearTimerId), this.clearTimerId = null);
328
- }
329
- startClearTimer() {
330
- this.resetClearTimer(), this.clearTimerId = window.setTimeout(() => {
331
- this.clearCanvas(), this.clearTimerId = null;
332
- }, this.options.clearDelay);
333
- }
334
- getEventCoordinates(e) {
335
- if (e instanceof MouseEvent) return {
336
- offsetX: e.offsetX,
337
- offsetY: e.offsetY
338
- };
339
- {
340
- const o = e.touches[0] || e.changedTouches[0], i = e.target.getBoundingClientRect();
341
- return {
342
- offsetX: o.clientX - i.left,
343
- offsetY: o.clientY - i.top
344
- };
345
- }
346
- }
347
- attachEvents() {
348
- 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);
349
- }
350
- detachEvents() {
351
- 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);
352
- }
353
- destroy() {
354
- this.detachEvents(), this.resetClearTimer();
355
- }
356
- getCanvas() {
357
- return this.canvas;
358
- }
359
- getContext() {
360
- return this.ctx;
361
- }
362
- };
363
- let le = {
364
- defaultMode: "en",
365
- enableHandwriting: !1,
366
- position: "static",
367
- disableWhenNoFocus: !0
368
- }, ye = null, be = null;
369
- function Z() {
370
- return le;
371
- }
372
- function fn(e) {
373
- le = {
374
- ...le,
375
- ...e
376
- };
377
- }
378
- function mn(e) {
379
- ye = e;
380
- }
381
- function ae() {
382
- return ye;
383
- }
384
- function pn(e) {
385
- be = e;
386
- }
387
- function je() {
388
- return be;
389
- }
390
- function Ge(e, o, i, a = 0) {
391
- if (!e || !o || i === "static") return null;
392
- let r, s;
393
- if (i === "bottom")
394
- r = window.innerHeight - o.offsetHeight, s = 0;
395
- else {
396
- const f = e.getBoundingClientRect(), v = o.offsetWidth;
397
- r = f.bottom + window.scrollY + a, s = f.left + window.scrollX + f.width / 2 - v / 2;
398
- const c = window.innerWidth;
399
- s + v > c && (s = c - v - 10), s < 10 && (s = 10);
400
- }
401
- return {
402
- top: `${r}px`,
403
- left: `${s}px`
404
- };
405
- }
406
- function ue(e) {
407
- if (!e) return !1;
408
- if (e.tagName === "TEXTAREA") return !0;
409
- if (e.tagName === "INPUT") {
410
- const i = (e.type || "text").toLowerCase();
411
- return ![
412
- "checkbox",
413
- "radio",
414
- "button",
415
- "submit",
416
- "reset",
417
- "file",
418
- "image",
419
- "range",
420
- "color",
421
- "hidden",
422
- "date",
423
- "datetime-local",
424
- "month",
425
- "week",
426
- "time"
427
- ].includes(i);
428
- }
429
- return !1;
430
- }
431
- function kn() {
432
- if (document.activeElement && ue(document.activeElement)) return document.activeElement;
433
- throw new Error("输入框没有被激活");
434
- }
435
- function qe(e, o, i) {
436
- e.value = o, tt(e, i), e.dispatchEvent(new Event("input", { bubbles: !0 }));
437
- }
438
- function Je(e, o, i, a = "") {
439
- return e.slice(0, o) + a + e.slice(o + i);
440
- }
441
- function we(e, o = "") {
442
- const i = Number(e.getAttribute("maxlength"));
443
- let a = e.selectionStart ?? 0;
444
- const r = e.selectionEnd ?? a;
445
- let s;
446
- if (o.length > 0) s = r - a;
447
- else {
448
- const c = r - a;
449
- if (c > 0) s = c;
450
- else if (a > 0)
451
- s = 1, a--;
452
- else return;
453
- }
454
- if (o.length > 0 && i && e.value.length - s + o.length > i) return;
455
- const f = Je(e.value, a, s, o), v = a + o.length;
456
- qe(e, f, v);
457
- }
458
- function Qe(e, o) {
459
- we(e, o);
460
- }
461
- function et(e) {
462
- we(e);
463
- }
464
- function tt(e, o) {
465
- e.selectionStart = o, e.selectionEnd = o;
466
- }
467
- function nt(e = {}) {
468
- const o = e.delay ?? 400, i = e.interval ?? 60;
469
- let a, r;
470
- function s() {
471
- a && (clearTimeout(a), a = void 0), r && (clearInterval(r), r = void 0);
472
- }
473
- function f(v) {
474
- s(), v(), a = setTimeout(() => {
475
- r = setInterval(() => {
476
- v();
477
- }, i);
478
- }, o);
479
- }
480
- return {
481
- start: f,
482
- stop: s
483
- };
484
- }
485
- function ot(e = !1) {
486
- const o = $(!1), i = $(0);
487
- async function a() {
488
- const s = ae();
489
- if (s)
490
- try {
491
- o.value = await s.initialize({
492
- onProgress: (f) => {
493
- i.value = f;
494
- }
495
- });
496
- } catch (f) {
497
- console.error("初始化手写识别服务失败:", f), o.value = !1;
498
- }
499
- else
500
- console.warn("未注册手写识别服务"), o.value = !1;
501
- }
502
- async function r() {
503
- const s = ae();
504
- if (s && o.value)
505
- try {
506
- await s.close(), o.value = !1;
507
- } catch (f) {
508
- console.error("关闭手写识别服务失败:", f);
509
- }
510
- }
511
- return Q(() => {
512
- e && a();
513
- }), de(() => {
514
- r();
515
- }), {
516
- recognizerInitialized: o,
517
- recognizerProgress: i
518
- };
519
- }
520
- const ce = "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", ve = "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";
521
- function te() {
522
- const e = nt();
523
- function o(a, r) {
524
- var s, f;
525
- a.preventDefault(), (f = (s = a.currentTarget) == null ? void 0 : s.setPointerCapture) == null || f.call(s, a.pointerId), e.start(r);
526
- }
527
- function i() {
528
- e.stop();
529
- }
530
- return Se(() => {
531
- e.stop();
532
- }), {
533
- startRepeat: o,
534
- stopRepeat: i
535
- };
536
- }
537
- const st = { class: "zhk-candidate-list" }, it = ["onClick"], xe = /* @__PURE__ */ I({
538
- __name: "CandidateList",
539
- props: {
540
- candidates: {}
541
- },
542
- emits: ["select"],
543
- setup(e, { emit: o }) {
544
- const i = o;
545
- function a(r) {
546
- i("select", r);
547
- }
548
- return (r, s) => (b(), x("div", st, [
549
- (b(!0), x(L, null, V(r.candidates, (f, v) => (b(), x("button", {
550
- key: `candidate-${v}`,
551
- class: "zhk-candidate-list__item",
552
- onClick: (c) => a(v)
553
- }, D(f), 9, it))), 128))
554
- ]));
555
- }
556
- }), rt = { class: "handwriting-input" }, lt = { class: "handwriting-content" }, at = { class: "handwriting-buttons" }, ut = { class: "handwriting-canvas-container" }, dt = {
557
- key: 0,
558
- class: "handwriting-loading"
559
- }, ct = { class: "progress-bar" }, vt = { class: "progress-text" }, ft = { class: "handwriting-buttons" }, mt = /* @__PURE__ */ I({
560
- __name: "HandwritingInput",
561
- props: {
562
- recognizerInitialized: { type: Boolean },
563
- recognizerProgress: {}
564
- },
565
- emits: ["key", "exit"],
566
- setup(e, { emit: o }) {
567
- const i = e, a = o, r = $(null);
568
- let s = null;
569
- const f = $(!1), { width: v, height: c } = ge(r);
570
- function y() {
571
- s && s.clearCanvas();
572
- }
573
- function h() {
574
- r.value && (s && s.destroy(), r.value.width = v.value, r.value.height = c.value, s = new Ye(r.value, {
575
- onDrawEnd: m
576
- }));
577
- }
578
- const u = $([]), { startRepeat: p, stopRepeat: d } = te();
579
- async function m() {
580
- if (!s || s.getStrokeData().length === 0 || f.value)
581
- return;
582
- const z = ae();
583
- if (z) {
584
- f.value = !0;
585
- try {
586
- const t = [...s.getStrokeData()], k = await z.recognize(t);
587
- u.value = k;
588
- } catch (t) {
589
- console.error("识别笔迹失败:", t);
590
- } finally {
591
- f.value = !1;
592
- }
593
- } else
594
- console.warn("手写识别服务不可用");
595
- }
596
- de(() => {
597
- s && s.destroy();
598
- }), q(() => {
599
- r.value && (v.value || c.value) && i.recognizerInitialized && fe(() => {
600
- h();
601
- });
602
- });
603
- function P(z) {
604
- const t = u.value[z];
605
- t && (a("key", { key: t }), u.value = [], y());
606
- }
607
- return (z, t) => (b(), x("div", rt, [
608
- Le(xe, {
609
- candidates: u.value,
610
- onSelect: P
611
- }, null, 8, ["candidates"]),
612
- g("div", lt, [
613
- g("div", at, [
614
- g("button", {
615
- class: "handwriting-btn handwriting-btn--function",
616
- onPointerdown: t[0] || (t[0] = (k) => n(p)(k, () => a("key", { key: "。" }))),
617
- onPointerup: t[1] || (t[1] = //@ts-ignore
618
- (...k) => n(d) && n(d)(...k)),
619
- onPointerleave: t[2] || (t[2] = //@ts-ignore
620
- (...k) => n(d) && n(d)(...k)),
621
- onPointercancel: t[3] || (t[3] = //@ts-ignore
622
- (...k) => n(d) && n(d)(...k)),
623
- onContextmenu: t[4] || (t[4] = C(() => {
624
- }, ["prevent"]))
625
- }, "", 32),
626
- g("button", {
627
- class: "handwriting-btn handwriting-btn--function",
628
- onPointerdown: t[5] || (t[5] = (k) => n(p)(k, () => a("key", { key: "?" }))),
629
- onPointerup: t[6] || (t[6] = //@ts-ignore
630
- (...k) => n(d) && n(d)(...k)),
631
- onPointerleave: t[7] || (t[7] = //@ts-ignore
632
- (...k) => n(d) && n(d)(...k)),
633
- onPointercancel: t[8] || (t[8] = //@ts-ignore
634
- (...k) => n(d) && n(d)(...k)),
635
- onContextmenu: t[9] || (t[9] = C(() => {
636
- }, ["prevent"]))
637
- }, " ", 32),
638
- g("button", {
639
- class: "handwriting-btn handwriting-btn--function",
640
- onPointerdown: t[10] || (t[10] = (k) => n(p)(k, () => a("key", { key: "!" }))),
641
- onPointerup: t[11] || (t[11] = //@ts-ignore
642
- (...k) => n(d) && n(d)(...k)),
643
- onPointerleave: t[12] || (t[12] = //@ts-ignore
644
- (...k) => n(d) && n(d)(...k)),
645
- onPointercancel: t[13] || (t[13] = //@ts-ignore
646
- (...k) => n(d) && n(d)(...k)),
647
- onContextmenu: t[14] || (t[14] = C(() => {
648
- }, ["prevent"]))
649
- }, " ", 32),
650
- g("button", {
651
- class: "handwriting-btn handwriting-btn--function",
652
- onPointerdown: t[15] || (t[15] = (k) => n(p)(k, () => a("key", { key: "、" }))),
653
- onPointerup: t[16] || (t[16] = //@ts-ignore
654
- (...k) => n(d) && n(d)(...k)),
655
- onPointerleave: t[17] || (t[17] = //@ts-ignore
656
- (...k) => n(d) && n(d)(...k)),
657
- onPointercancel: t[18] || (t[18] = //@ts-ignore
658
- (...k) => n(d) && n(d)(...k)),
659
- onContextmenu: t[19] || (t[19] = C(() => {
660
- }, ["prevent"]))
661
- }, "", 32)
662
- ]),
663
- g("div", ut, [
664
- z.recognizerInitialized ? (b(), x("canvas", {
665
- key: 1,
666
- ref_key: "canvasRef",
667
- ref: r,
668
- class: "handwriting-canvas"
669
- }, null, 512)) : (b(), x("div", dt, [
670
- t[37] || (t[37] = g("div", { class: "loading-text" }, " 正在加载手写识别... ", -1)),
671
- g("div", ct, [
672
- g("div", {
673
- class: "progress-fill",
674
- style: pe({ width: `${z.recognizerProgress * 100}%` })
675
- }, null, 4)
676
- ]),
677
- g("div", vt, D(Math.round(z.recognizerProgress * 100)) + "% ", 1)
678
- ]))
679
- ]),
680
- g("div", ft, [
681
- g("button", {
682
- class: "handwriting-btn handwriting-btn--function",
683
- onPointerdown: t[20] || (t[20] = (k) => n(p)(k, () => a("key", { key: "delete", isControl: !0 }))),
684
- onPointerup: t[21] || (t[21] = //@ts-ignore
685
- (...k) => n(d) && n(d)(...k)),
686
- onPointerleave: t[22] || (t[22] = //@ts-ignore
687
- (...k) => n(d) && n(d)(...k)),
688
- onPointercancel: t[23] || (t[23] = //@ts-ignore
689
- (...k) => n(d) && n(d)(...k)),
690
- onContextmenu: t[24] || (t[24] = C(() => {
691
- }, ["prevent"]))
692
- }, t[38] || (t[38] = [
693
- g("img", {
694
- src: ce,
695
- alt: "删除"
696
- }, null, -1)
697
- ]), 32),
698
- g("button", {
699
- class: "handwriting-btn handwriting-btn--function",
700
- onClick: t[25] || (t[25] = (k) => a("exit")),
701
- onContextmenu: t[26] || (t[26] = C(() => {
702
- }, ["prevent"]))
703
- }, " 拼音 ", 32),
704
- g("button", {
705
- class: "handwriting-btn handwriting-btn--function",
706
- onPointerdown: t[27] || (t[27] = (k) => n(p)(k, () => a("key", { key: "," }))),
707
- onPointerup: t[28] || (t[28] = //@ts-ignore
708
- (...k) => n(d) && n(d)(...k)),
709
- onPointerleave: t[29] || (t[29] = //@ts-ignore
710
- (...k) => n(d) && n(d)(...k)),
711
- onPointercancel: t[30] || (t[30] = //@ts-ignore
712
- (...k) => n(d) && n(d)(...k)),
713
- onContextmenu: t[31] || (t[31] = C(() => {
714
- }, ["prevent"]))
715
- }, " , ", 32),
716
- g("button", {
717
- class: "handwriting-btn handwriting-btn--function",
718
- onPointerdown: t[32] || (t[32] = (k) => n(p)(k, () => a("key", { key: "enter", isControl: !0 }))),
719
- onPointerup: t[33] || (t[33] = //@ts-ignore
720
- (...k) => n(d) && n(d)(...k)),
721
- onPointerleave: t[34] || (t[34] = //@ts-ignore
722
- (...k) => n(d) && n(d)(...k)),
723
- onPointercancel: t[35] || (t[35] = //@ts-ignore
724
- (...k) => n(d) && n(d)(...k)),
725
- onContextmenu: t[36] || (t[36] = C(() => {
726
- }, ["prevent"]))
727
- }, t[39] || (t[39] = [
728
- g("img", {
729
- src: ve,
730
- alt: "回车"
731
- }, null, -1)
732
- ]), 32)
733
- ])
734
- ])
735
- ]));
736
- }
737
- }), pt = "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", ze = "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", kt = "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", ht = { class: "zhk-selection" }, gt = { class: "zhk-selection__list" }, yt = ["onClick"], bt = /* @__PURE__ */ I({
738
- __name: "CandidateSelection",
739
- props: {
740
- candidates: {}
741
- },
742
- emits: ["select", "close"],
743
- setup(e, { emit: o }) {
744
- const i = o;
745
- function a(f) {
746
- i("select", f);
747
- }
748
- function r() {
749
- i("close");
750
- }
751
- function s(f) {
752
- const v = Array.from(f).length;
753
- return v >= 2 && v <= 3 ? 2 : v >= 4 ? 3 : 1;
754
- }
755
- return (f, v) => (b(), x("div", ht, [
756
- g("div", gt, [
757
- (b(!0), x(L, null, V(f.candidates, (c, y) => (b(), x("div", {
758
- key: y,
759
- class: O(["zhk-selection__text", [`zhk-selection__text--span-${s(c)}`]]),
760
- onClick: (h) => a(y)
761
- }, D(c), 11, yt))), 128))
762
- ]),
763
- g("div", { class: "zhk-selection__func" }, [
764
- g("button", {
765
- class: "zhk-selection__func-btn",
766
- onClick: r
767
- }, " 返回 ")
768
- ])
769
- ]));
770
- }
771
- }), wt = { class: "zhk-candidate" }, xt = { class: "zhk-candidate__container" }, zt = {
772
- key: 0,
773
- class: "zhk-candidate__pinyin"
774
- }, Ct = { class: "zhk-candidate__bottom-container" }, Pt = /* @__PURE__ */ I({
775
- __name: "CandidateBar",
776
- props: {
777
- modelValue: {
778
- required: !0
779
- },
780
- modelModifiers: {}
781
- },
782
- emits: /* @__PURE__ */ se(["key", "input"], ["update:modelValue"]),
783
- setup(e, { expose: o, emit: i }) {
784
- const a = i, r = ke(e, "modelValue");
785
- let s = null;
786
- const f = $(null), v = S(() => {
787
- var u;
788
- return ((u = f.value) == null ? void 0 : u.candidates.map((p) => p.text)) ?? [];
789
- }), c = $(!1);
790
- Q(async () => {
791
- if (s = je(), !s)
792
- throw new Error("未找到拼音引擎实例,请确保已正确注册引擎");
793
- r.value && (f.value = await s.processInput(r.value));
794
- }), de(() => {
795
- s == null || s.processInput("").catch(() => {
796
- }), s = null;
797
- }), X(r, async (u) => {
798
- const p = s;
799
- if (p) {
800
- if (u === "") {
801
- p.processInput("").catch(() => {
802
- }), f.value = null;
803
- return;
804
- }
805
- f.value = await p.processInput(u);
806
- }
807
- });
808
- async function y(u) {
809
- if (!s)
810
- return;
811
- const p = await s.pickCandidate(u);
812
- f.value = p, p.preeditBody || (a("input", p.committed || ""), r.value = "", f.value = null, c.value = !1);
813
- }
814
- o({
815
- handleSelection: y
816
- });
817
- const h = S(() => {
818
- const u = f.value;
819
- return u ? u.preeditHead + u.preeditBody : "";
820
- });
821
- return (u, p) => (b(), x("div", wt, [
822
- g("div", xt, [
823
- h.value ? (b(), x("div", zt, D(h.value), 1)) : W("", !0),
824
- g("div", Ct, [
825
- v.value.length > 0 ? (b(), K(xe, {
826
- key: 0,
827
- candidates: v.value,
828
- onSelect: y
829
- }, null, 8, ["candidates"])) : W("", !0),
830
- v.value.length > 0 ? (b(), x("button", {
831
- key: 1,
832
- class: "zhk-candidate__more",
833
- onClick: p[0] || (p[0] = (d) => c.value = !0)
834
- }, p[2] || (p[2] = [
835
- g("img", {
836
- src: kt,
837
- alt: "更多"
838
- }, null, -1)
839
- ]))) : W("", !0)
840
- ])
841
- ]),
842
- c.value ? (b(), K(bt, {
843
- key: 0,
844
- candidates: v.value,
845
- onSelect: y,
846
- onClose: p[1] || (p[1] = (d) => c.value = !1)
847
- }, null, 8, ["candidates"])) : W("", !0)
848
- ]));
849
- }
850
- }), _t = { class: "zhk-base" }, Et = { class: "zhk-base__row" }, $t = ["onPointerdown"], St = ["disabled"], Lt = {
851
- key: 1,
852
- src: pt,
853
- class: "zhk-base__key-icon",
854
- alt: "Shift"
855
- }, Tt = ["onPointerdown"], Rt = { class: "zhk-base__row" }, Dt = { class: "zhk-base__toggle-main" }, Mt = { class: "zhk-base__toggle-sub" }, Ht = /* @__PURE__ */ I({
856
- __name: "KeyboardBase",
857
- props: /* @__PURE__ */ se({
858
- enableHandwriting: { type: Boolean }
859
- }, {
860
- modelValue: {
861
- default: "en"
862
- },
863
- modelModifiers: {}
864
- }),
865
- emits: /* @__PURE__ */ se(["key"], ["update:modelValue"]),
866
- setup(e, { emit: o }) {
867
- const i = e, a = o, r = ke(e, "modelValue"), s = S(() => r.value === "en_cap"), f = S(() => r.value === "zh"), v = S(() => f.value ? !0 : s.value);
868
- function c(M, l = !1) {
869
- a("key", { key: M, isControl: l });
870
- }
871
- function y() {
872
- f.value ? r.value = "hand" : r.value = s.value ? "en" : "en_cap";
873
- }
874
- function h() {
875
- r.value = "num";
876
- }
877
- function u() {
878
- r.value = "symbol";
879
- }
880
- const p = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"], d = [
881
- ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
882
- ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
883
- ["z", "x", "c", "v", "b", "n", "m"]
884
- ], m = $(""), P = $(null), { startRepeat: z, stopRepeat: t } = te();
885
- function k() {
886
- if (r.value === "zh" && m.value) {
887
- m.value = m.value.slice(0, -1);
888
- return;
889
- }
890
- c("delete", !0);
891
- }
892
- function N() {
893
- var M;
894
- if (r.value === "zh" && m.value) {
895
- (M = P.value) == null || M.handleSelection(0);
896
- return;
897
- }
898
- c(" ");
899
- }
900
- function ne() {
901
- if (r.value === "zh" && m.value) {
902
- c(m.value), m.value = "";
903
- return;
904
- }
905
- c("enter", !0);
906
- }
907
- function U(M) {
908
- if (r.value === "zh") {
909
- m.value += M;
910
- return;
911
- }
912
- const l = s.value ? M.toUpperCase() : M;
913
- c(l);
914
- }
915
- function oe() {
916
- r.value = r.value === "zh" ? "en" : "zh";
917
- }
918
- const E = S(() => i.enableHandwriting ? "手写" : "-"), T = S(() => !i.enableHandwriting);
919
- return (M, l) => (b(), x("div", _t, [
920
- g("div", Et, [
921
- r.value === "zh" ? (b(), K(Pt, {
922
- key: 0,
923
- ref_key: "candidateBarRef",
924
- ref: P,
925
- modelValue: m.value,
926
- "onUpdate:modelValue": l[0] || (l[0] = (w) => m.value = w),
927
- onInput: l[1] || (l[1] = (w) => c(w, !1))
928
- }, null, 8, ["modelValue"])) : (b(), x(L, { key: 1 }, V(p, (w, F) => g("button", {
929
- key: `number-${F}`,
930
- class: "zhk-base__key zhk-base__key--letter",
931
- onPointerdown: (_) => n(z)(_, () => U(w)),
932
- onPointerup: l[2] || (l[2] = //@ts-ignore
933
- (..._) => n(t) && n(t)(..._)),
934
- onPointerleave: l[3] || (l[3] = //@ts-ignore
935
- (..._) => n(t) && n(t)(..._)),
936
- onPointercancel: l[4] || (l[4] = //@ts-ignore
937
- (..._) => n(t) && n(t)(..._)),
938
- onContextmenu: l[5] || (l[5] = C(() => {
939
- }, ["prevent"]))
940
- }, D(w), 41, $t)), 64))
941
- ]),
942
- (b(), x(L, null, V(d, (w, F) => g("div", {
943
- key: `row-${F}`,
944
- class: "zhk-base__row"
945
- }, [
946
- F === 2 ? (b(), x("button", {
947
- key: 0,
948
- class: O(["zhk-base__key zhk-base__key--function zhk-base__key--shift", {
949
- "zhk-base__key--active": !f.value && s.value,
950
- "zhk-base__key--disabled": f.value && T.value
951
- }]),
952
- disabled: f.value && T.value,
953
- onClick: y,
954
- onContextmenu: l[6] || (l[6] = C(() => {
955
- }, ["prevent"]))
956
- }, [
957
- f.value ? (b(), x(L, { key: 0 }, [
958
- ie(D(E.value), 1)
959
- ], 64)) : (b(), x("img", Lt))
960
- ], 42, St)) : W("", !0),
961
- (b(!0), x(L, null, V(w, (_, Ce) => (b(), x("button", {
962
- key: `key-${F}-${Ce}`,
963
- class: "zhk-base__key zhk-base__key--letter",
964
- onPointerdown: (A) => n(z)(A, () => U(_)),
965
- onPointerup: l[7] || (l[7] = //@ts-ignore
966
- (...A) => n(t) && n(t)(...A)),
967
- onPointerleave: l[8] || (l[8] = //@ts-ignore
968
- (...A) => n(t) && n(t)(...A)),
969
- onPointercancel: l[9] || (l[9] = //@ts-ignore
970
- (...A) => n(t) && n(t)(...A)),
971
- onContextmenu: l[10] || (l[10] = C(() => {
972
- }, ["prevent"]))
973
- }, D(v.value ? _.toUpperCase() : _), 41, Tt))), 128)),
974
- F === 2 ? (b(), x("button", {
975
- key: 1,
976
- class: "zhk-base__key zhk-base__key--function zhk-base__key--delete",
977
- onPointerdown: l[11] || (l[11] = (_) => n(z)(_, () => k())),
978
- onPointerup: l[12] || (l[12] = //@ts-ignore
979
- (..._) => n(t) && n(t)(..._)),
980
- onPointerleave: l[13] || (l[13] = //@ts-ignore
981
- (..._) => n(t) && n(t)(..._)),
982
- onPointercancel: l[14] || (l[14] = //@ts-ignore
983
- (..._) => n(t) && n(t)(..._)),
984
- onContextmenu: l[15] || (l[15] = C(() => {
985
- }, ["prevent"]))
986
- }, l[39] || (l[39] = [
987
- g("img", {
988
- src: ce,
989
- class: "zhk-base__key-icon",
990
- alt: "Delete"
991
- }, null, -1)
992
- ]), 32)) : W("", !0)
993
- ])), 64)),
994
- g("div", Rt, [
995
- g("button", {
996
- class: "zhk-base__key zhk-base__key--function",
997
- onClick: u,
998
- onContextmenu: l[16] || (l[16] = C(() => {
999
- }, ["prevent"]))
1000
- }, " 符 ", 32),
1001
- g("button", {
1002
- class: "zhk-base__key zhk-base__key--function",
1003
- onClick: h,
1004
- onContextmenu: l[17] || (l[17] = C(() => {
1005
- }, ["prevent"]))
1006
- }, " 123 ", 32),
1007
- g("button", {
1008
- class: "zhk-base__key",
1009
- onPointerdown: l[18] || (l[18] = (w) => n(z)(w, () => c(","))),
1010
- onPointerup: l[19] || (l[19] = //@ts-ignore
1011
- (...w) => n(t) && n(t)(...w)),
1012
- onPointerleave: l[20] || (l[20] = //@ts-ignore
1013
- (...w) => n(t) && n(t)(...w)),
1014
- onPointercancel: l[21] || (l[21] = //@ts-ignore
1015
- (...w) => n(t) && n(t)(...w)),
1016
- onContextmenu: l[22] || (l[22] = C(() => {
1017
- }, ["prevent"]))
1018
- }, " , ", 32),
1019
- g("button", {
1020
- class: "zhk-base__key zhk-base__key--space",
1021
- onPointerdown: l[23] || (l[23] = (w) => n(z)(w, () => N())),
1022
- onPointerup: l[24] || (l[24] = //@ts-ignore
1023
- (...w) => n(t) && n(t)(...w)),
1024
- onPointerleave: l[25] || (l[25] = //@ts-ignore
1025
- (...w) => n(t) && n(t)(...w)),
1026
- onPointercancel: l[26] || (l[26] = //@ts-ignore
1027
- (...w) => n(t) && n(t)(...w)),
1028
- onContextmenu: l[27] || (l[27] = C(() => {
1029
- }, ["prevent"]))
1030
- }, l[40] || (l[40] = [
1031
- g("img", {
1032
- src: ze,
1033
- class: "zhk-base__key-icon",
1034
- alt: "Space"
1035
- }, null, -1)
1036
- ]), 32),
1037
- g("button", {
1038
- class: "zhk-base__key",
1039
- onPointerdown: l[28] || (l[28] = (w) => n(z)(w, () => c("。"))),
1040
- onPointerup: l[29] || (l[29] = //@ts-ignore
1041
- (...w) => n(t) && n(t)(...w)),
1042
- onPointerleave: l[30] || (l[30] = //@ts-ignore
1043
- (...w) => n(t) && n(t)(...w)),
1044
- onPointercancel: l[31] || (l[31] = //@ts-ignore
1045
- (...w) => n(t) && n(t)(...w)),
1046
- onContextmenu: l[32] || (l[32] = C(() => {
1047
- }, ["prevent"]))
1048
- }, " 。 ", 32),
1049
- g("button", {
1050
- class: "zhk-base__key zhk-base__key--function",
1051
- onClick: oe,
1052
- onContextmenu: l[33] || (l[33] = C(() => {
1053
- }, ["prevent"]))
1054
- }, [
1055
- g("span", Dt, D(r.value === "zh" ? "中" : "英"), 1),
1056
- g("span", Mt, "/" + D(r.value === "zh" ? "英" : "中"), 1)
1057
- ], 32),
1058
- g("button", {
1059
- class: "zhk-base__key zhk-base__key--function",
1060
- onPointerdown: l[34] || (l[34] = (w) => n(z)(w, () => ne())),
1061
- onPointerup: l[35] || (l[35] = //@ts-ignore
1062
- (...w) => n(t) && n(t)(...w)),
1063
- onPointerleave: l[36] || (l[36] = //@ts-ignore
1064
- (...w) => n(t) && n(t)(...w)),
1065
- onPointercancel: l[37] || (l[37] = //@ts-ignore
1066
- (...w) => n(t) && n(t)(...w)),
1067
- onContextmenu: l[38] || (l[38] = C(() => {
1068
- }, ["prevent"]))
1069
- }, l[41] || (l[41] = [
1070
- g("img", {
1071
- src: ve,
1072
- class: "zhk-base__key-icon",
1073
- alt: "Enter"
1074
- }, null, -1)
1075
- ]), 32)
1076
- ])
1077
- ]));
1078
- }
1079
- }), Vt = { class: "num-keyboard" }, Bt = { class: "num-keyboard__container" }, It = { class: "num-keyboard__left" }, At = { class: "num-keyboard__rows" }, Kt = ["onClick", "onPointerdown"], Wt = {
1080
- key: 1,
1081
- src: ze,
1082
- class: "zhk-base__key-icon",
1083
- alt: "Space"
1084
- }, Ot = { class: "num-keyboard__right" }, Nt = ["onPointerdown"], Ut = ["src", "alt"], Ft = { key: 1 }, Zt = /* @__PURE__ */ I({
1085
- __name: "NumericKeyboard",
1086
- props: {
1087
- keyboardRows: { default: () => Z().numKeys || [
1088
- ["1", "2", "3"],
1089
- ["4", "5", "6"],
1090
- ["7", "8", "9"],
1091
- ["back", "0", "space"]
1092
- ] }
1093
- },
1094
- emits: ["key", "exit"],
1095
- setup(e, { emit: o }) {
1096
- const i = o, a = [
1097
- { key: "delete", icon: ce, text: "", alt: "Delete" },
1098
- { key: ".", icon: "", text: ".", alt: "." },
1099
- { key: "@", icon: "", text: "@", alt: "@" },
1100
- { key: "enter", icon: ve, text: "", alt: "Enter" }
1101
- ];
1102
- function r(h) {
1103
- i("key", { key: h });
1104
- }
1105
- function s(h, u = !0) {
1106
- i("key", { key: h, isControl: u });
1107
- }
1108
- function f() {
1109
- i("exit");
1110
- }
1111
- const { startRepeat: v, stopRepeat: c } = te();
1112
- function y(h, u) {
1113
- h === "back" || (h === "space" && (h = " "), h === "delete" || h === "enter" ? v(u, () => s(h)) : v(u, () => r(h)));
1114
- }
1115
- return (h, u) => (b(), x("div", Vt, [
1116
- g("div", Bt, [
1117
- g("div", It, [
1118
- g("div", At, [
1119
- (b(!0), x(L, null, V(h.keyboardRows, (p, d) => (b(), x("div", {
1120
- key: `row-${d}`,
1121
- class: "num-keyboard__row"
1122
- }, [
1123
- (b(!0), x(L, null, V(p, (m, P) => (b(), x("button", {
1124
- key: `key-${d}-${P}`,
1125
- class: O(["num-keyboard__key", {
1126
- "num-keyboard__key--back": m === "back",
1127
- "num-keyboard__key--space": m === "space"
1128
- }]),
1129
- onClick: (z) => m === "back" && f(),
1130
- onPointerdown: (z) => y(m, z),
1131
- onPointerup: u[0] || (u[0] = //@ts-ignore
1132
- (...z) => n(c) && n(c)(...z)),
1133
- onPointerleave: u[1] || (u[1] = //@ts-ignore
1134
- (...z) => n(c) && n(c)(...z)),
1135
- onPointercancel: u[2] || (u[2] = //@ts-ignore
1136
- (...z) => n(c) && n(c)(...z)),
1137
- onContextmenu: u[3] || (u[3] = C(() => {
1138
- }, ["prevent"]))
1139
- }, [
1140
- m === "back" ? (b(), x(L, { key: 0 }, [
1141
- ie(" 返回 ")
1142
- ], 64)) : m === "space" ? (b(), x("img", Wt)) : (b(), x(L, { key: 2 }, [
1143
- ie(D(m), 1)
1144
- ], 64))
1145
- ], 42, Kt))), 128))
1146
- ]))), 128))
1147
- ])
1148
- ]),
1149
- g("div", Ot, [
1150
- (b(), x(L, null, V(a, (p, d) => g("button", {
1151
- key: `func-${d}`,
1152
- class: "num-keyboard__key num-keyboard__key--function",
1153
- onPointerdown: (m) => y(p.key, m),
1154
- onPointerup: u[4] || (u[4] = //@ts-ignore
1155
- (...m) => n(c) && n(c)(...m)),
1156
- onPointerleave: u[5] || (u[5] = //@ts-ignore
1157
- (...m) => n(c) && n(c)(...m)),
1158
- onPointercancel: u[6] || (u[6] = //@ts-ignore
1159
- (...m) => n(c) && n(c)(...m)),
1160
- onContextmenu: u[7] || (u[7] = C(() => {
1161
- }, ["prevent"]))
1162
- }, [
1163
- p.icon ? (b(), x("img", {
1164
- key: 0,
1165
- src: p.icon,
1166
- class: "num-keyboard__key-icon",
1167
- alt: p.alt
1168
- }, null, 8, Ut)) : (b(), x("span", Ft, D(p.text), 1))
1169
- ], 40, Nt)), 64))
1170
- ])
1171
- ])
1172
- ]));
1173
- }
1174
- }), Xt = "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", Yt = "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", jt = { class: "symbol-keyboard" }, Gt = { class: "symbol-keyboard__content" }, qt = { class: "symbol-keyboard__functions" }, Jt = { class: "symbol-keyboard__lang-selector" }, Qt = { class: "symbol-keyboard__control-group" }, en = ["src"], tn = ["src"], nn = { class: "symbol-keyboard__symbols-container" }, on = { class: "symbol-keyboard__symbols-grid" }, sn = ["onClick", "onPointerdown"], rn = "!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°", ln = "!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°", an = /* @__PURE__ */ I({
1175
- __name: "SymbolKeyboard",
1176
- emits: ["key", "exit"],
1177
- setup(e, { emit: o }) {
1178
- const i = o, a = $("en"), r = S(() => a.value === "zh" ? ln : rn), s = $(!1), { startRepeat: f, stopRepeat: v } = te();
1179
- function c(d, m) {
1180
- s.value && f(m, () => y(d));
1181
- }
1182
- function y(d) {
1183
- i("key", { key: d }), s.value || i("exit");
1184
- }
1185
- function h() {
1186
- i("exit");
1187
- }
1188
- function u(d) {
1189
- a.value = d;
1190
- }
1191
- function p() {
1192
- s.value = !s.value;
1193
- }
1194
- return (d, m) => (b(), x("div", jt, [
1195
- g("div", Gt, [
1196
- g("div", qt, [
1197
- g("div", Jt, [
1198
- g("button", {
1199
- class: O(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": a.value === "zh" }]),
1200
- onClick: m[0] || (m[0] = (P) => u("zh")),
1201
- onContextmenu: m[1] || (m[1] = C(() => {
1202
- }, ["prevent"]))
1203
- }, " 中文 ", 34),
1204
- g("button", {
1205
- class: O(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": a.value === "en" }]),
1206
- onClick: m[2] || (m[2] = (P) => u("en")),
1207
- onContextmenu: m[3] || (m[3] = C(() => {
1208
- }, ["prevent"]))
1209
- }, " 英文 ", 34)
1210
- ]),
1211
- g("div", Qt, [
1212
- g("button", {
1213
- class: O(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock", { "symbol-keyboard__key--locked": s.value }]),
1214
- onClick: p,
1215
- onContextmenu: m[4] || (m[4] = C(() => {
1216
- }, ["prevent"]))
1217
- }, [
1218
- s.value ? (b(), x("img", {
1219
- key: 1,
1220
- src: n(Yt),
1221
- alt: "Lock closed"
1222
- }, null, 8, tn)) : (b(), x("img", {
1223
- key: 0,
1224
- src: n(Xt),
1225
- alt: "Lock open"
1226
- }, null, 8, en))
1227
- ], 34),
1228
- g("button", {
1229
- class: "symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",
1230
- onClick: h,
1231
- onContextmenu: m[5] || (m[5] = C(() => {
1232
- }, ["prevent"]))
1233
- }, " 返回 ", 32)
1234
- ])
1235
- ]),
1236
- g("div", nn, [
1237
- g("div", on, [
1238
- (b(!0), x(L, null, V(r.value, (P, z) => (b(), x("button", {
1239
- key: `key-${z}`,
1240
- class: "symbol-keyboard__key",
1241
- onClick: (t) => !s.value && y(P),
1242
- onPointerdown: (t) => c(P, t),
1243
- onPointerup: m[6] || (m[6] = //@ts-ignore
1244
- (...t) => n(v) && n(v)(...t)),
1245
- onPointerleave: m[7] || (m[7] = //@ts-ignore
1246
- (...t) => n(v) && n(v)(...t)),
1247
- onPointercancel: m[8] || (m[8] = //@ts-ignore
1248
- (...t) => n(v) && n(v)(...t)),
1249
- onContextmenu: m[9] || (m[9] = C(() => {
1250
- }, ["prevent"]))
1251
- }, D(P), 41, sn))), 128))
1252
- ])
1253
- ])
1254
- ])
1255
- ]));
1256
- }
1257
- }), un = {
1258
- key: 0,
1259
- class: "zhk__disabled-overlay"
1260
- }, dn = /* @__PURE__ */ I({
1261
- __name: "ZhKeyboard",
1262
- props: {
1263
- /**
1264
- * 默认的键盘模式
1265
- */
1266
- defaultMode: {
1267
- type: String,
1268
- default: () => Z().defaultMode ?? "en"
1269
- },
1270
- /**
1271
- * 是否启用手写输入
1272
- */
1273
- enableHandwriting: {
1274
- type: Boolean,
1275
- default: () => Z().enableHandwriting ?? !1
1276
- },
1277
- /**
1278
- * 键盘定位模式
1279
- * @default 'static'
1280
- */
1281
- position: {
1282
- type: String,
1283
- default: () => Z().position ?? "static"
1284
- },
1285
- /**
1286
- * 浮动模式下键盘与输入框的距离
1287
- * @default 10
1288
- */
1289
- floatMarginTop: {
1290
- type: Number,
1291
- default: () => Z().floatMarginTop ?? 0
1292
- },
1293
- /**
1294
- * 当没有input获得焦点时是否禁用键盘
1295
- * @default true
1296
- */
1297
- disableWhenNoFocus: {
1298
- type: Boolean,
1299
- default: () => Z().disableWhenNoFocus ?? !0
1300
- },
1301
- /**
1302
- * 数字键盘的行配置
1303
- */
1304
- numKeys: {
1305
- type: Array || void 0
1306
- }
1307
- },
1308
- emits: ["key"],
1309
- setup(e, { emit: o }) {
1310
- const i = e, a = o, r = $(i.defaultMode), s = $(i.defaultMode), f = $([]), v = $(!1), c = $(null), y = $(null), { recognizerInitialized: h, recognizerProgress: u } = ot(i.enableHandwriting);
1311
- X(r, (E, T) => {
1312
- E !== T && (s.value = T);
1313
- });
1314
- const p = Ze(), d = S(() => p.value && ue(p.value) ? p.value : null), m = S(() => i.position === "static" || !!(p.value && ue(p.value))), { height: P } = ge(y);
1315
- q(() => {
1316
- if (d.value) {
1317
- const E = d.value.dataset.inputmode;
1318
- E && (r.value = E);
1319
- }
1320
- });
1321
- const z = S(() => i.disableWhenNoFocus === !1 ? !1 : !d.value);
1322
- function t() {
1323
- if (!P.value)
1324
- return;
1325
- const E = Ge(
1326
- d.value,
1327
- y.value,
1328
- i.position,
1329
- i.floatMarginTop
1330
- );
1331
- c.value = E;
1332
- }
1333
- q(t);
1334
- const k = Ke(t, 100);
1335
- J(window, "scroll", k, { passive: !0 }), J(window, "resize", k, { passive: !0 });
1336
- function N(E) {
1337
- if (E.isControl) {
1338
- switch (E.key) {
1339
- case "delete":
1340
- et(d.value);
1341
- break;
1342
- case "more":
1343
- v.value = !0;
1344
- break;
1345
- }
1346
- return;
1347
- } else
1348
- ne(E.key);
1349
- a("key", E);
1350
- }
1351
- function ne(E) {
1352
- Qe(d.value, E);
1353
- }
1354
- function U() {
1355
- r.value === "hand" ? s.value = "zh" : ["num", "symbol"].includes(s.value) && (s.value = i.defaultMode), r.value = s.value;
1356
- }
1357
- function oe(E) {
1358
- f.value = E;
1359
- }
1360
- return (E, T) => Te((b(), x("div", {
1361
- ref_key: "keyboardRef",
1362
- ref: y,
1363
- class: O(["zhk", {
1364
- "zhk--floating": e.position === "float",
1365
- "zhk--bottom": e.position === "bottom",
1366
- "zhk--disabled": z.value
1367
- }]),
1368
- style: pe({
1369
- "--keyboard-height": `${n(P)}px`,
1370
- ...c.value
1371
- }),
1372
- onMousedown: T[1] || (T[1] = C(() => {
1373
- }, ["prevent"]))
1374
- }, [
1375
- z.value || !m.value || !n(P) ? (b(), x("div", un, T[2] || (T[2] = [
1376
- g("span", null, "请选择输入框以启用键盘", -1)
1377
- ]))) : (b(), x(L, { key: 1 }, [
1378
- r.value === "hand" ? (b(), K(mt, {
1379
- key: 0,
1380
- "recognizer-initialized": n(h),
1381
- "recognizer-progress": n(u),
1382
- onKey: N,
1383
- onExit: U,
1384
- onRecognize: oe
1385
- }, null, 8, ["recognizer-initialized", "recognizer-progress"])) : r.value === "num" ? (b(), K(Zt, {
1386
- key: 1,
1387
- "keyboard-rows": e.numKeys,
1388
- onKey: N,
1389
- onExit: U
1390
- }, null, 8, ["keyboard-rows"])) : r.value === "symbol" ? (b(), K(an, {
1391
- key: 2,
1392
- onKey: N,
1393
- onExit: U
1394
- })) : r.value === "en" || r.value === "en_cap" || r.value === "zh" ? (b(), K(Ht, {
1395
- key: 3,
1396
- modelValue: r.value,
1397
- "onUpdate:modelValue": T[0] || (T[0] = (M) => r.value = M),
1398
- "enable-handwriting": e.enableHandwriting,
1399
- onKey: N
1400
- }, null, 8, ["modelValue", "enable-handwriting"])) : W("", !0)
1401
- ], 64))
1402
- ], 38)), [
1403
- [Re, m.value]
1404
- ]);
1405
- }
1406
- }), hn = {
1407
- install: (e) => {
1408
- e.component("ZhKeyboard", dn);
1409
- }
1410
- };
1411
- export {
1412
- Ye as CanvasDrawer,
1413
- dn as ZhKeyboard,
1414
- Ge as calculateKeyboardPosition,
1415
- nt as createKeyRepeater,
1416
- hn as default,
1417
- et as delToInputElement,
1418
- ae as getHandwritingRecognizer,
1419
- kn as getInputElement,
1420
- Z as getKeyboardConfig,
1421
- je as getPinyinEngine,
1422
- ue as isInputElement,
1423
- tt as moveCursor,
1424
- mn as registerHandwritingRecognizer,
1425
- pn as registerPinyinEngine,
1426
- fn as setKeyboardConfig,
1427
- Qe as writeToInputElement
1428
- };
1429
- //# sourceMappingURL=zh-keyboard-vue.js.map
10
+ var te = (e) => e != null, H = Object.prototype.toString, ne = (e) => H.call(e) === "[object Object]", U = () => {};
11
+ function re(e, t) {
12
+ function n(...n) {
13
+ return new Promise((r, i) => {
14
+ Promise.resolve(e(() => t.apply(this, n), {
15
+ fn: t,
16
+ thisArg: this,
17
+ args: n
18
+ })).then(r).catch(i);
19
+ });
20
+ }
21
+ return n;
22
+ }
23
+ function ie(e, t = {}) {
24
+ let n, r, i = U, a = (e) => {
25
+ clearTimeout(e), i(), i = U;
26
+ }, o;
27
+ return (s) => {
28
+ let c = w(e), l = w(t.maxWait);
29
+ return n && a(n), c <= 0 || l !== void 0 && l <= 0 ? (r &&= (a(r), null), Promise.resolve(s())) : new Promise((e, u) => {
30
+ i = t.rejectOnCancel ? u : e, o = s, l && !r && (r = setTimeout(() => {
31
+ n && a(n), r = null, e(o());
32
+ }, l)), n = setTimeout(() => {
33
+ r && a(r), r = null, e(s());
34
+ }, c);
35
+ });
36
+ };
37
+ }
38
+ function W(e) {
39
+ return Array.isArray(e) ? e : [e];
40
+ }
41
+ function ae(e) {
42
+ return e || l();
43
+ }
44
+ function oe(e, t = 200, n = {}) {
45
+ return re(ie(t, n), e);
46
+ }
47
+ function se(e, t = !0, n) {
48
+ ae(n) ? g(e, n) : t ? e() : f(e);
49
+ }
50
+ function ce(e, t, n) {
51
+ return O(e, t, {
52
+ ...n,
53
+ immediate: !0
54
+ });
55
+ }
56
+ //#endregion
57
+ //#region ../../node_modules/.pnpm/@vueuse+core@13.1.0_vue@3.5.13_typescript@5.8.3_/node_modules/@vueuse/core/index.mjs
58
+ var G = V ? window : void 0;
59
+ V && window.document, V && window.navigator, V && window.location;
60
+ function K(e) {
61
+ let t = w(e);
62
+ return t?.$el ?? t;
63
+ }
64
+ function q(...e) {
65
+ let n = [], r = () => {
66
+ n.forEach((e) => e()), n.length = 0;
67
+ }, i = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), a = t(() => {
68
+ let t = W(w(e[0])).filter((e) => e != null);
69
+ return t.every((e) => typeof e != "string") ? t : void 0;
70
+ }), o = ce(() => [
71
+ a.value?.map((e) => K(e)) ?? [G].filter((e) => e != null),
72
+ W(w(a.value ? e[1] : e[0])),
73
+ W(T(a.value ? e[2] : e[1])),
74
+ w(a.value ? e[3] : e[2])
75
+ ], ([e, t, a, o]) => {
76
+ if (r(), !e?.length || !t?.length || !a?.length) return;
77
+ let s = ne(o) ? { ...o } : o;
78
+ n.push(...e.flatMap((e) => t.flatMap((t) => a.map((n) => i(e, t, n, s)))));
79
+ }, { flush: "post" });
80
+ return B(r), () => {
81
+ o(), r();
82
+ };
83
+ }
84
+ function le() {
85
+ let e = S(!1), t = l();
86
+ return t && g(() => {
87
+ e.value = !0;
88
+ }, t), e;
89
+ }
90
+ function J(e) {
91
+ let n = le();
92
+ return t(() => (n.value, !!e()));
93
+ }
94
+ function ue(e, n, r = {}) {
95
+ let { window: i = G, ...a } = r, o, s = J(() => i && "MutationObserver" in i), c = () => {
96
+ o &&= (o.disconnect(), void 0);
97
+ }, l = t(() => {
98
+ let t = W(w(e)).map(K).filter(te);
99
+ return new Set(t);
100
+ }), u = O(() => l.value, (e) => {
101
+ c(), s.value && e.size && (o = new MutationObserver(n), e.forEach((e) => o.observe(e, a)));
102
+ }, {
103
+ immediate: !0,
104
+ flush: "post"
105
+ }), d = () => o?.takeRecords(), f = () => {
106
+ u(), c();
107
+ };
108
+ return B(f), {
109
+ isSupported: s,
110
+ stop: f,
111
+ takeRecords: d
112
+ };
113
+ }
114
+ function de(e, t, n = {}) {
115
+ let { window: r = G, document: i = r?.document, flush: a = "sync" } = n;
116
+ if (!r || !i) return U;
117
+ let o, s = (e) => {
118
+ o?.(), o = e;
119
+ }, c = k(() => {
120
+ let n = K(e);
121
+ if (n) {
122
+ let { stop: e } = ue(i, (e) => {
123
+ e.map((e) => [...e.removedNodes]).flat().some((e) => e === n || e.contains(n)) && t(e);
124
+ }, {
125
+ window: r,
126
+ childList: !0,
127
+ subtree: !0
128
+ });
129
+ s(e);
130
+ }
131
+ }, { flush: a }), l = () => {
132
+ c(), s();
133
+ };
134
+ return B(l), l;
135
+ }
136
+ function fe(e = {}) {
137
+ let { window: t = G, deep: n = !0, triggerOnRemoval: r = !1 } = e, i = e.document ?? t?.document, a = () => {
138
+ let e = i?.activeElement;
139
+ if (n) for (; e?.shadowRoot;) e = e?.shadowRoot?.activeElement;
140
+ return e;
141
+ }, o = S(), s = () => {
142
+ o.value = a();
143
+ };
144
+ if (t) {
145
+ let e = {
146
+ capture: !0,
147
+ passive: !0
148
+ };
149
+ q(t, "blur", (e) => {
150
+ e.relatedTarget === null && s();
151
+ }, e), q(t, "focus", s, e);
152
+ }
153
+ return r && de(o, s, { document: i }), s(), o;
154
+ }
155
+ function pe(e, n, r = {}) {
156
+ let { window: i = G, ...a } = r, o, s = J(() => i && "ResizeObserver" in i), c = () => {
157
+ o &&= (o.disconnect(), void 0);
158
+ }, l = O(t(() => {
159
+ let t = w(e);
160
+ return Array.isArray(t) ? t.map((e) => K(e)) : [K(t)];
161
+ }), (e) => {
162
+ if (c(), s.value && i) {
163
+ o = new ResizeObserver(n);
164
+ for (let t of e) t && o.observe(t, a);
165
+ }
166
+ }, {
167
+ immediate: !0,
168
+ flush: "post"
169
+ }), u = () => {
170
+ c(), l();
171
+ };
172
+ return B(u), {
173
+ isSupported: s,
174
+ stop: u
175
+ };
176
+ }
177
+ function Y(e, n = {
178
+ width: 0,
179
+ height: 0
180
+ }, r = {}) {
181
+ let { window: i = G, box: a = "content-box" } = r, o = t(() => (K(e)?.namespaceURI)?.includes("svg")), s = S(n.width), c = S(n.height), { stop: l } = pe(e, ([t]) => {
182
+ let n = a === "border-box" ? t.borderBoxSize : a === "content-box" ? t.contentBoxSize : t.devicePixelContentBoxSize;
183
+ if (i && o.value) {
184
+ let t = K(e);
185
+ if (t) {
186
+ let e = t.getBoundingClientRect();
187
+ s.value = e.width, c.value = e.height;
188
+ }
189
+ } else if (n) {
190
+ let e = W(n);
191
+ s.value = e.reduce((e, { inlineSize: t }) => e + t, 0), c.value = e.reduce((e, { blockSize: t }) => e + t, 0);
192
+ } else s.value = t.contentRect.width, c.value = t.contentRect.height;
193
+ }, r);
194
+ se(() => {
195
+ let t = K(e);
196
+ t && (s.value = "offsetWidth" in t ? t.offsetWidth : n.width, c.value = "offsetHeight" in t ? t.offsetHeight : n.height);
197
+ });
198
+ let u = O(() => K(e), (e) => {
199
+ s.value = e ? n.width : 0, c.value = e ? n.height : 0;
200
+ });
201
+ function d() {
202
+ l(), u();
203
+ }
204
+ return {
205
+ width: s,
206
+ height: c,
207
+ stop: d
208
+ };
209
+ }
210
+ //#endregion
211
+ //#region src/utils/useHandwritingRecognizer.ts
212
+ function me(e = !1) {
213
+ let t = b(!1), n = b(0);
214
+ async function r() {
215
+ let e = I();
216
+ if (e) try {
217
+ t.value = await e.initialize({ onProgress: (e) => {
218
+ n.value = e;
219
+ } });
220
+ } catch (e) {
221
+ console.error("初始化手写识别服务失败:", e), t.value = !1;
222
+ }
223
+ else console.warn("未注册手写识别服务"), t.value = !1;
224
+ }
225
+ async function i() {
226
+ let e = I();
227
+ if (e && t.value) try {
228
+ await e.close(), t.value = !1;
229
+ } catch (e) {
230
+ console.error("关闭手写识别服务失败:", e);
231
+ }
232
+ }
233
+ return g(() => {
234
+ e && r();
235
+ }), v(() => {
236
+ i();
237
+ }), {
238
+ recognizerInitialized: t,
239
+ recognizerProgress: n
240
+ };
241
+ }
242
+ //#endregion
243
+ //#region src/assets/icons/keyboard-backspace.svg
244
+ var he = "data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e", ge = "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";
245
+ //#endregion
246
+ //#region src/hooks/useKeyRepeater.ts
247
+ function X() {
248
+ let e = P();
249
+ function t(t, n) {
250
+ t.preventDefault(), t.currentTarget?.setPointerCapture?.(t.pointerId), e.start(n);
251
+ }
252
+ function n() {
253
+ e.stop();
254
+ }
255
+ return h(() => {
256
+ e.stop();
257
+ }), {
258
+ startRepeat: t,
259
+ stopRepeat: n
260
+ };
261
+ }
262
+ //#endregion
263
+ //#region src/components/CandidateList.vue?vue&type=script&setup=true&lang.ts
264
+ var _e = { class: "zhk-candidate-list" }, ve = ["onClick"], Z = /* @__PURE__ */ c({
265
+ __name: "CandidateList",
266
+ props: { candidates: {} },
267
+ emits: ["select"],
268
+ setup(t, { emit: n }) {
269
+ let r = n;
270
+ function a(e) {
271
+ r("select", e);
272
+ }
273
+ return (t, n) => (y(), i("div", _e, [(y(!0), i(e, null, x(t.candidates, (e, t) => (y(), i("button", {
274
+ key: `candidate-${t}`,
275
+ class: "zhk-candidate-list__item",
276
+ onClick: (e) => a(t)
277
+ }, C(e), 9, ve))), 128))]));
278
+ }
279
+ }), ye = { class: "handwriting-input" }, be = { class: "handwriting-content" }, xe = { class: "handwriting-buttons" }, Se = { class: "handwriting-canvas-container" }, Ce = {
280
+ key: 0,
281
+ class: "handwriting-loading"
282
+ }, we = { class: "progress-bar" }, Te = { class: "progress-text" }, Ee = { class: "handwriting-buttons" }, De = /* @__PURE__ */ c({
283
+ __name: "HandwritingInput",
284
+ props: {
285
+ recognizerInitialized: { type: Boolean },
286
+ recognizerProgress: {}
287
+ },
288
+ emits: ["key", "exit"],
289
+ setup(e, { emit: t }) {
290
+ let n = e, r = t, o = b(null), c = null, l = b(!1), { width: u, height: d } = Y(o);
291
+ function p() {
292
+ c && c.clearCanvas();
293
+ }
294
+ function h() {
295
+ o.value && (c && c.destroy(), o.value.width = u.value, o.value.height = d.value, c = new M(o.value, { onDrawEnd: S }));
296
+ }
297
+ let g = b([]), { startRepeat: _, stopRepeat: x } = X();
298
+ async function S() {
299
+ if (!c || c.getStrokeData().length === 0 || l.value) return;
300
+ let e = I();
301
+ if (e) {
302
+ l.value = !0;
303
+ try {
304
+ let t = [...c.getStrokeData()];
305
+ g.value = await e.recognize(t);
306
+ } catch (e) {
307
+ console.error("识别笔迹失败:", e);
308
+ } finally {
309
+ l.value = !1;
310
+ }
311
+ } else console.warn("手写识别服务不可用");
312
+ }
313
+ v(() => {
314
+ c && c.destroy();
315
+ }), k(() => {
316
+ o.value && (u.value || d.value) && n.recognizerInitialized && f(() => {
317
+ h();
318
+ });
319
+ });
320
+ function w(e) {
321
+ let t = g.value[e];
322
+ t && (r("key", { key: t }), g.value = [], p());
323
+ }
324
+ return (e, t) => (y(), i("div", ye, [s(Z, {
325
+ candidates: g.value,
326
+ onSelect: w
327
+ }, null, 8, ["candidates"]), a("div", be, [
328
+ a("div", xe, [
329
+ a("button", {
330
+ class: "handwriting-btn handwriting-btn--function",
331
+ onPointerdown: t[0] ||= (e) => T(_)(e, () => r("key", { key: "。" })),
332
+ onPointerup: t[1] ||= (...e) => T(x) && T(x)(...e),
333
+ onPointerleave: t[2] ||= (...e) => T(x) && T(x)(...e),
334
+ onPointercancel: t[3] ||= (...e) => T(x) && T(x)(...e),
335
+ onContextmenu: t[4] ||= j(() => {}, ["prevent"])
336
+ }, " 。 ", 32),
337
+ a("button", {
338
+ class: "handwriting-btn handwriting-btn--function",
339
+ onPointerdown: t[5] ||= (e) => T(_)(e, () => r("key", { key: "?" })),
340
+ onPointerup: t[6] ||= (...e) => T(x) && T(x)(...e),
341
+ onPointerleave: t[7] ||= (...e) => T(x) && T(x)(...e),
342
+ onPointercancel: t[8] ||= (...e) => T(x) && T(x)(...e),
343
+ onContextmenu: t[9] ||= j(() => {}, ["prevent"])
344
+ }, " ? ", 32),
345
+ a("button", {
346
+ class: "handwriting-btn handwriting-btn--function",
347
+ onPointerdown: t[10] ||= (e) => T(_)(e, () => r("key", { key: "!" })),
348
+ onPointerup: t[11] ||= (...e) => T(x) && T(x)(...e),
349
+ onPointerleave: t[12] ||= (...e) => T(x) && T(x)(...e),
350
+ onPointercancel: t[13] ||= (...e) => T(x) && T(x)(...e),
351
+ onContextmenu: t[14] ||= j(() => {}, ["prevent"])
352
+ }, " ! ", 32),
353
+ a("button", {
354
+ class: "handwriting-btn handwriting-btn--function",
355
+ onPointerdown: t[15] ||= (e) => T(_)(e, () => r("key", { key: "、" })),
356
+ onPointerup: t[16] ||= (...e) => T(x) && T(x)(...e),
357
+ onPointerleave: t[17] ||= (...e) => T(x) && T(x)(...e),
358
+ onPointercancel: t[18] ||= (...e) => T(x) && T(x)(...e),
359
+ onContextmenu: t[19] ||= j(() => {}, ["prevent"])
360
+ }, " 、 ", 32)
361
+ ]),
362
+ a("div", Se, [e.recognizerInitialized ? (y(), i("canvas", {
363
+ key: 1,
364
+ ref_key: "canvasRef",
365
+ ref: o,
366
+ class: "handwriting-canvas"
367
+ }, null, 512)) : (y(), i("div", Ce, [
368
+ t[37] ||= a("div", { class: "loading-text" }, " 正在加载手写识别... ", -1),
369
+ a("div", we, [a("div", {
370
+ class: "progress-fill",
371
+ style: m({ width: `${e.recognizerProgress * 100}%` })
372
+ }, null, 4)]),
373
+ a("div", Te, C(Math.round(e.recognizerProgress * 100)) + "% ", 1)
374
+ ]))]),
375
+ a("div", Ee, [
376
+ a("button", {
377
+ class: "handwriting-btn handwriting-btn--function",
378
+ onPointerdown: t[20] ||= (e) => T(_)(e, () => r("key", {
379
+ key: "delete",
380
+ isControl: !0
381
+ })),
382
+ onPointerup: t[21] ||= (...e) => T(x) && T(x)(...e),
383
+ onPointerleave: t[22] ||= (...e) => T(x) && T(x)(...e),
384
+ onPointercancel: t[23] ||= (...e) => T(x) && T(x)(...e),
385
+ onContextmenu: t[24] ||= j(() => {}, ["prevent"])
386
+ }, t[38] ||= [a("img", {
387
+ src: "data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e",
388
+ alt: "删除"
389
+ }, null, -1)], 32),
390
+ a("button", {
391
+ class: "handwriting-btn handwriting-btn--function",
392
+ onClick: t[25] ||= (e) => r("exit"),
393
+ onContextmenu: t[26] ||= j(() => {}, ["prevent"])
394
+ }, " 拼音 ", 32),
395
+ a("button", {
396
+ class: "handwriting-btn handwriting-btn--function",
397
+ onPointerdown: t[27] ||= (e) => T(_)(e, () => r("key", { key: "," })),
398
+ onPointerup: t[28] ||= (...e) => T(x) && T(x)(...e),
399
+ onPointerleave: t[29] ||= (...e) => T(x) && T(x)(...e),
400
+ onPointercancel: t[30] ||= (...e) => T(x) && T(x)(...e),
401
+ onContextmenu: t[31] ||= j(() => {}, ["prevent"])
402
+ }, " , ", 32),
403
+ a("button", {
404
+ class: "handwriting-btn handwriting-btn--function",
405
+ onPointerdown: t[32] ||= (e) => T(_)(e, () => r("key", {
406
+ key: "enter",
407
+ isControl: !0
408
+ })),
409
+ onPointerup: t[33] ||= (...e) => T(x) && T(x)(...e),
410
+ onPointerleave: t[34] ||= (...e) => T(x) && T(x)(...e),
411
+ onPointercancel: t[35] ||= (...e) => T(x) && T(x)(...e),
412
+ onContextmenu: t[36] ||= j(() => {}, ["prevent"])
413
+ }, t[39] ||= [a("img", {
414
+ src: "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",
415
+ alt: "回车"
416
+ }, null, -1)], 32)
417
+ ])
418
+ ])]));
419
+ }
420
+ }), Oe = "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", ke = "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", Ae = { class: "zhk-selection" }, je = { class: "zhk-selection__list" }, Me = ["onClick"], Ne = /* @__PURE__ */ c({
421
+ __name: "CandidateSelection",
422
+ props: { candidates: {} },
423
+ emits: ["select", "close"],
424
+ setup(t, { emit: n }) {
425
+ let r = n;
426
+ function o(e) {
427
+ r("select", e);
428
+ }
429
+ function s() {
430
+ r("close");
431
+ }
432
+ function c(e) {
433
+ let t = Array.from(e).length;
434
+ return t >= 2 && t <= 3 ? 2 : t >= 4 ? 3 : 1;
435
+ }
436
+ return (t, n) => (y(), i("div", Ae, [a("div", je, [(y(!0), i(e, null, x(t.candidates, (e, t) => (y(), i("div", {
437
+ key: t,
438
+ class: p(["zhk-selection__text", [`zhk-selection__text--span-${c(e)}`]]),
439
+ onClick: (e) => o(t)
440
+ }, C(e), 11, Me))), 128))]), a("div", { class: "zhk-selection__func" }, [a("button", {
441
+ class: "zhk-selection__func-btn",
442
+ onClick: s
443
+ }, " 返回 ")])]));
444
+ }
445
+ }), Pe = { class: "zhk-candidate" }, Fe = { class: "zhk-candidate__container" }, Ie = {
446
+ key: 0,
447
+ class: "zhk-candidate__pinyin"
448
+ }, Le = { class: "zhk-candidate__bottom-container" }, Re = /* @__PURE__ */ c({
449
+ __name: "CandidateBar",
450
+ props: {
451
+ modelValue: { required: !0 },
452
+ modelModifiers: {}
453
+ },
454
+ emits: /* @__PURE__ */ d(["key", "input"], ["update:modelValue"]),
455
+ setup(e, { expose: o, emit: s }) {
456
+ let c = s, l = E(e, "modelValue"), u = null, d = b(null), f = t(() => d.value?.candidates.map((e) => e.text) ?? []), p = b(!1);
457
+ g(async () => {
458
+ if (u = R(), !u) throw Error("未找到拼音引擎实例,请确保已正确注册引擎");
459
+ l.value && (d.value = await u.processInput(l.value));
460
+ }), v(() => {
461
+ u?.processInput("").catch(() => {}), u = null;
462
+ }), O(l, async (e) => {
463
+ let t = u;
464
+ if (t) {
465
+ if (e === "") {
466
+ t.processInput("").catch(() => {}), d.value = null;
467
+ return;
468
+ }
469
+ d.value = await t.processInput(e);
470
+ }
471
+ });
472
+ async function m(e) {
473
+ if (!u) return;
474
+ let t = await u.pickCandidate(e);
475
+ d.value = t, t.preeditBody || (c("input", t.committed || ""), l.value = "", d.value = null, p.value = !1);
476
+ }
477
+ o({ handleSelection: m });
478
+ let h = t(() => {
479
+ let e = d.value;
480
+ return e ? e.preeditHead + e.preeditBody : "";
481
+ });
482
+ return (e, t) => (y(), i("div", Pe, [a("div", Fe, [h.value ? (y(), i("div", Ie, C(h.value), 1)) : r("", !0), a("div", Le, [f.value.length > 0 ? (y(), n(Z, {
483
+ key: 0,
484
+ candidates: f.value,
485
+ onSelect: m
486
+ }, null, 8, ["candidates"])) : r("", !0), f.value.length > 0 ? (y(), i("button", {
487
+ key: 1,
488
+ class: "zhk-candidate__more",
489
+ onClick: t[0] ||= (e) => p.value = !0
490
+ }, t[2] ||= [a("img", {
491
+ src: "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",
492
+ alt: "更多"
493
+ }, null, -1)])) : r("", !0)])]), p.value ? (y(), n(Ne, {
494
+ key: 0,
495
+ candidates: f.value,
496
+ onSelect: m,
497
+ onClose: t[1] ||= (e) => p.value = !1
498
+ }, null, 8, ["candidates"])) : r("", !0)]));
499
+ }
500
+ }), ze = { class: "zhk-base" }, Be = { class: "zhk-base__row" }, Ve = ["onPointerdown"], He = ["disabled"], Ue = {
501
+ key: 1,
502
+ src: Oe,
503
+ class: "zhk-base__key-icon",
504
+ alt: "Shift"
505
+ }, We = ["onPointerdown"], Ge = { class: "zhk-base__row" }, Ke = { class: "zhk-base__toggle-main" }, qe = { class: "zhk-base__toggle-sub" }, Je = /* @__PURE__ */ c({
506
+ __name: "KeyboardBase",
507
+ props: /* @__PURE__ */ d({ enableHandwriting: { type: Boolean } }, {
508
+ modelValue: { default: "en" },
509
+ modelModifiers: {}
510
+ }),
511
+ emits: /* @__PURE__ */ d(["key"], ["update:modelValue"]),
512
+ setup(s, { emit: c }) {
513
+ let l = s, u = c, d = E(s, "modelValue"), f = t(() => d.value === "en_cap"), m = t(() => d.value === "zh"), h = t(() => m.value ? !0 : f.value);
514
+ function g(e, t = !1) {
515
+ u("key", {
516
+ key: e,
517
+ isControl: t
518
+ });
519
+ }
520
+ function _() {
521
+ m.value ? d.value = "hand" : d.value = f.value ? "en" : "en_cap";
522
+ }
523
+ function v() {
524
+ d.value = "num";
525
+ }
526
+ function S() {
527
+ d.value = "symbol";
528
+ }
529
+ let w = [
530
+ "1",
531
+ "2",
532
+ "3",
533
+ "4",
534
+ "5",
535
+ "6",
536
+ "7",
537
+ "8",
538
+ "9",
539
+ "0"
540
+ ], D = [
541
+ [
542
+ "q",
543
+ "w",
544
+ "e",
545
+ "r",
546
+ "t",
547
+ "y",
548
+ "u",
549
+ "i",
550
+ "o",
551
+ "p"
552
+ ],
553
+ [
554
+ "a",
555
+ "s",
556
+ "d",
557
+ "f",
558
+ "g",
559
+ "h",
560
+ "j",
561
+ "k",
562
+ "l"
563
+ ],
564
+ [
565
+ "z",
566
+ "x",
567
+ "c",
568
+ "v",
569
+ "b",
570
+ "n",
571
+ "m"
572
+ ]
573
+ ], O = b(""), k = b(null), { startRepeat: A, stopRepeat: M } = X();
574
+ function N() {
575
+ if (d.value === "zh" && O.value) {
576
+ O.value = O.value.slice(0, -1);
577
+ return;
578
+ }
579
+ g("delete", !0);
580
+ }
581
+ function P() {
582
+ if (d.value === "zh" && O.value) {
583
+ k.value?.handleSelection(0);
584
+ return;
585
+ }
586
+ g(" ");
587
+ }
588
+ function F() {
589
+ if (d.value === "zh" && O.value) {
590
+ g(O.value), O.value = "";
591
+ return;
592
+ }
593
+ g("enter", !0);
594
+ }
595
+ function I(e) {
596
+ if (d.value === "zh") {
597
+ O.value += e;
598
+ return;
599
+ }
600
+ g(f.value ? e.toUpperCase() : e);
601
+ }
602
+ function L() {
603
+ d.value = d.value === "zh" ? "en" : "zh";
604
+ }
605
+ let R = t(() => l.enableHandwriting ? "手写" : "-"), z = t(() => !l.enableHandwriting);
606
+ return (t, s) => (y(), i("div", ze, [
607
+ a("div", Be, [d.value === "zh" ? (y(), n(Re, {
608
+ key: 0,
609
+ ref_key: "candidateBarRef",
610
+ ref: k,
611
+ modelValue: O.value,
612
+ "onUpdate:modelValue": s[0] ||= (e) => O.value = e,
613
+ onInput: s[1] ||= (e) => g(e, !1)
614
+ }, null, 8, ["modelValue"])) : (y(), i(e, { key: 1 }, x(w, (e, t) => a("button", {
615
+ key: `number-${t}`,
616
+ class: "zhk-base__key zhk-base__key--letter",
617
+ onPointerdown: (t) => T(A)(t, () => I(e)),
618
+ onPointerup: s[2] ||= (...e) => T(M) && T(M)(...e),
619
+ onPointerleave: s[3] ||= (...e) => T(M) && T(M)(...e),
620
+ onPointercancel: s[4] ||= (...e) => T(M) && T(M)(...e),
621
+ onContextmenu: s[5] ||= j(() => {}, ["prevent"])
622
+ }, C(e), 41, Ve)), 64))]),
623
+ (y(), i(e, null, x(D, (t, n) => a("div", {
624
+ key: `row-${n}`,
625
+ class: "zhk-base__row"
626
+ }, [
627
+ n === 2 ? (y(), i("button", {
628
+ key: 0,
629
+ class: p(["zhk-base__key zhk-base__key--function zhk-base__key--shift", {
630
+ "zhk-base__key--active": !m.value && f.value,
631
+ "zhk-base__key--disabled": m.value && z.value
632
+ }]),
633
+ disabled: m.value && z.value,
634
+ onClick: _,
635
+ onContextmenu: s[6] ||= j(() => {}, ["prevent"])
636
+ }, [m.value ? (y(), i(e, { key: 0 }, [o(C(R.value), 1)], 64)) : (y(), i("img", Ue))], 42, He)) : r("", !0),
637
+ (y(!0), i(e, null, x(t, (e, t) => (y(), i("button", {
638
+ key: `key-${n}-${t}`,
639
+ class: "zhk-base__key zhk-base__key--letter",
640
+ onPointerdown: (t) => T(A)(t, () => I(e)),
641
+ onPointerup: s[7] ||= (...e) => T(M) && T(M)(...e),
642
+ onPointerleave: s[8] ||= (...e) => T(M) && T(M)(...e),
643
+ onPointercancel: s[9] ||= (...e) => T(M) && T(M)(...e),
644
+ onContextmenu: s[10] ||= j(() => {}, ["prevent"])
645
+ }, C(h.value ? e.toUpperCase() : e), 41, We))), 128)),
646
+ n === 2 ? (y(), i("button", {
647
+ key: 1,
648
+ class: "zhk-base__key zhk-base__key--function zhk-base__key--delete",
649
+ onPointerdown: s[11] ||= (e) => T(A)(e, () => N()),
650
+ onPointerup: s[12] ||= (...e) => T(M) && T(M)(...e),
651
+ onPointerleave: s[13] ||= (...e) => T(M) && T(M)(...e),
652
+ onPointercancel: s[14] ||= (...e) => T(M) && T(M)(...e),
653
+ onContextmenu: s[15] ||= j(() => {}, ["prevent"])
654
+ }, s[39] ||= [a("img", {
655
+ src: "data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e",
656
+ class: "zhk-base__key-icon",
657
+ alt: "Delete"
658
+ }, null, -1)], 32)) : r("", !0)
659
+ ])), 64)),
660
+ a("div", Ge, [
661
+ a("button", {
662
+ class: "zhk-base__key zhk-base__key--function",
663
+ onClick: S,
664
+ onContextmenu: s[16] ||= j(() => {}, ["prevent"])
665
+ }, " 符 ", 32),
666
+ a("button", {
667
+ class: "zhk-base__key zhk-base__key--function",
668
+ onClick: v,
669
+ onContextmenu: s[17] ||= j(() => {}, ["prevent"])
670
+ }, " 123 ", 32),
671
+ a("button", {
672
+ class: "zhk-base__key",
673
+ onPointerdown: s[18] ||= (e) => T(A)(e, () => g(",")),
674
+ onPointerup: s[19] ||= (...e) => T(M) && T(M)(...e),
675
+ onPointerleave: s[20] ||= (...e) => T(M) && T(M)(...e),
676
+ onPointercancel: s[21] ||= (...e) => T(M) && T(M)(...e),
677
+ onContextmenu: s[22] ||= j(() => {}, ["prevent"])
678
+ }, " , ", 32),
679
+ a("button", {
680
+ class: "zhk-base__key zhk-base__key--space",
681
+ onPointerdown: s[23] ||= (e) => T(A)(e, () => P()),
682
+ onPointerup: s[24] ||= (...e) => T(M) && T(M)(...e),
683
+ onPointerleave: s[25] ||= (...e) => T(M) && T(M)(...e),
684
+ onPointercancel: s[26] ||= (...e) => T(M) && T(M)(...e),
685
+ onContextmenu: s[27] ||= j(() => {}, ["prevent"])
686
+ }, s[40] ||= [a("img", {
687
+ src: "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",
688
+ class: "zhk-base__key-icon",
689
+ alt: "Space"
690
+ }, null, -1)], 32),
691
+ a("button", {
692
+ class: "zhk-base__key",
693
+ onPointerdown: s[28] ||= (e) => T(A)(e, () => g("")),
694
+ onPointerup: s[29] ||= (...e) => T(M) && T(M)(...e),
695
+ onPointerleave: s[30] ||= (...e) => T(M) && T(M)(...e),
696
+ onPointercancel: s[31] ||= (...e) => T(M) && T(M)(...e),
697
+ onContextmenu: s[32] ||= j(() => {}, ["prevent"])
698
+ }, "", 32),
699
+ a("button", {
700
+ class: "zhk-base__key zhk-base__key--function",
701
+ onClick: L,
702
+ onContextmenu: s[33] ||= j(() => {}, ["prevent"])
703
+ }, [a("span", Ke, C(d.value === "zh" ? "中" : "英"), 1), a("span", qe, "/" + C(d.value === "zh" ? "英" : "中"), 1)], 32),
704
+ a("button", {
705
+ class: "zhk-base__key zhk-base__key--function",
706
+ onPointerdown: s[34] ||= (e) => T(A)(e, () => F()),
707
+ onPointerup: s[35] ||= (...e) => T(M) && T(M)(...e),
708
+ onPointerleave: s[36] ||= (...e) => T(M) && T(M)(...e),
709
+ onPointercancel: s[37] ||= (...e) => T(M) && T(M)(...e),
710
+ onContextmenu: s[38] ||= j(() => {}, ["prevent"])
711
+ }, s[41] ||= [a("img", {
712
+ src: "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",
713
+ class: "zhk-base__key-icon",
714
+ alt: "Enter"
715
+ }, null, -1)], 32)
716
+ ])
717
+ ]));
718
+ }
719
+ }), Ye = { class: "num-keyboard" }, Xe = { class: "num-keyboard__container" }, Ze = { class: "num-keyboard__left" }, Qe = { class: "num-keyboard__rows" }, $e = ["onClick", "onPointerdown"], et = {
720
+ key: 1,
721
+ src: ke,
722
+ class: "zhk-base__key-icon",
723
+ alt: "Space"
724
+ }, tt = { class: "num-keyboard__right" }, nt = ["onPointerdown"], rt = ["src", "alt"], it = { key: 1 }, at = /* @__PURE__ */ c({
725
+ __name: "NumericKeyboard",
726
+ props: { keyboardRows: { default: () => L().numKeys || [
727
+ [
728
+ "1",
729
+ "2",
730
+ "3"
731
+ ],
732
+ [
733
+ "4",
734
+ "5",
735
+ "6"
736
+ ],
737
+ [
738
+ "7",
739
+ "8",
740
+ "9"
741
+ ],
742
+ [
743
+ "back",
744
+ "0",
745
+ "space"
746
+ ]
747
+ ] } },
748
+ emits: ["key", "exit"],
749
+ setup(t, { emit: n }) {
750
+ let r = n, s = [
751
+ {
752
+ key: "delete",
753
+ icon: he,
754
+ text: "",
755
+ alt: "Delete"
756
+ },
757
+ {
758
+ key: ".",
759
+ icon: "",
760
+ text: ".",
761
+ alt: "."
762
+ },
763
+ {
764
+ key: "@",
765
+ icon: "",
766
+ text: "@",
767
+ alt: "@"
768
+ },
769
+ {
770
+ key: "enter",
771
+ icon: ge,
772
+ text: "",
773
+ alt: "Enter"
774
+ }
775
+ ];
776
+ function c(e) {
777
+ r("key", { key: e });
778
+ }
779
+ function l(e, t = !0) {
780
+ r("key", {
781
+ key: e,
782
+ isControl: t
783
+ });
784
+ }
785
+ function u() {
786
+ r("exit");
787
+ }
788
+ let { startRepeat: d, stopRepeat: f } = X();
789
+ function m(e, t) {
790
+ e === "back" || (e === "space" && (e = " "), e === "delete" || e === "enter" ? d(t, () => l(e)) : d(t, () => c(e)));
791
+ }
792
+ return (t, n) => (y(), i("div", Ye, [a("div", Xe, [a("div", Ze, [a("div", Qe, [(y(!0), i(e, null, x(t.keyboardRows, (t, r) => (y(), i("div", {
793
+ key: `row-${r}`,
794
+ class: "num-keyboard__row"
795
+ }, [(y(!0), i(e, null, x(t, (t, a) => (y(), i("button", {
796
+ key: `key-${r}-${a}`,
797
+ class: p(["num-keyboard__key", {
798
+ "num-keyboard__key--back": t === "back",
799
+ "num-keyboard__key--space": t === "space"
800
+ }]),
801
+ onClick: (e) => t === "back" && u(),
802
+ onPointerdown: (e) => m(t, e),
803
+ onPointerup: n[0] ||= (...e) => T(f) && T(f)(...e),
804
+ onPointerleave: n[1] ||= (...e) => T(f) && T(f)(...e),
805
+ onPointercancel: n[2] ||= (...e) => T(f) && T(f)(...e),
806
+ onContextmenu: n[3] ||= j(() => {}, ["prevent"])
807
+ }, [t === "back" ? (y(), i(e, { key: 0 }, [o(" 返回 ")], 64)) : t === "space" ? (y(), i("img", et)) : (y(), i(e, { key: 2 }, [o(C(t), 1)], 64))], 42, $e))), 128))]))), 128))])]), a("div", tt, [(y(), i(e, null, x(s, (e, t) => a("button", {
808
+ key: `func-${t}`,
809
+ class: "num-keyboard__key num-keyboard__key--function",
810
+ onPointerdown: (t) => m(e.key, t),
811
+ onPointerup: n[4] ||= (...e) => T(f) && T(f)(...e),
812
+ onPointerleave: n[5] ||= (...e) => T(f) && T(f)(...e),
813
+ onPointercancel: n[6] ||= (...e) => T(f) && T(f)(...e),
814
+ onContextmenu: n[7] ||= j(() => {}, ["prevent"])
815
+ }, [e.icon ? (y(), i("img", {
816
+ key: 0,
817
+ src: e.icon,
818
+ class: "num-keyboard__key-icon",
819
+ alt: e.alt
820
+ }, null, 8, rt)) : (y(), i("span", it, C(e.text), 1))], 40, nt)), 64))])])]));
821
+ }
822
+ }), ot = "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", st = "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", ct = { class: "symbol-keyboard" }, lt = { class: "symbol-keyboard__content" }, ut = { class: "symbol-keyboard__functions" }, dt = { class: "symbol-keyboard__lang-selector" }, ft = { class: "symbol-keyboard__control-group" }, pt = ["src"], Q = ["src"], mt = { class: "symbol-keyboard__symbols-container" }, ht = { class: "symbol-keyboard__symbols-grid" }, gt = ["onClick", "onPointerdown"], _t = "!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°", vt = "!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°", yt = /* @__PURE__ */ c({
823
+ __name: "SymbolKeyboard",
824
+ emits: ["key", "exit"],
825
+ setup(n, { emit: r }) {
826
+ let o = r, s = b("en"), c = t(() => s.value === "zh" ? vt : _t), l = b(!1), { startRepeat: u, stopRepeat: d } = X();
827
+ function f(e, t) {
828
+ l.value && u(t, () => m(e));
829
+ }
830
+ function m(e) {
831
+ o("key", { key: e }), l.value || o("exit");
832
+ }
833
+ function h() {
834
+ o("exit");
835
+ }
836
+ function g(e) {
837
+ s.value = e;
838
+ }
839
+ function _() {
840
+ l.value = !l.value;
841
+ }
842
+ return (t, n) => (y(), i("div", ct, [a("div", lt, [a("div", ut, [a("div", dt, [a("button", {
843
+ class: p(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": s.value === "zh" }]),
844
+ onClick: n[0] ||= (e) => g("zh"),
845
+ onContextmenu: n[1] ||= j(() => {}, ["prevent"])
846
+ }, " 中文 ", 34), a("button", {
847
+ class: p(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": s.value === "en" }]),
848
+ onClick: n[2] ||= (e) => g("en"),
849
+ onContextmenu: n[3] ||= j(() => {}, ["prevent"])
850
+ }, " 英文 ", 34)]), a("div", ft, [a("button", {
851
+ class: p(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock", { "symbol-keyboard__key--locked": l.value }]),
852
+ onClick: _,
853
+ onContextmenu: n[4] ||= j(() => {}, ["prevent"])
854
+ }, [l.value ? (y(), i("img", {
855
+ key: 1,
856
+ src: T(st),
857
+ alt: "Lock closed"
858
+ }, null, 8, Q)) : (y(), i("img", {
859
+ key: 0,
860
+ src: T(ot),
861
+ alt: "Lock open"
862
+ }, null, 8, pt))], 34), a("button", {
863
+ class: "symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",
864
+ onClick: h,
865
+ onContextmenu: n[5] ||= j(() => {}, ["prevent"])
866
+ }, " 返回 ", 32)])]), a("div", mt, [a("div", ht, [(y(!0), i(e, null, x(c.value, (e, t) => (y(), i("button", {
867
+ key: `key-${t}`,
868
+ class: "symbol-keyboard__key",
869
+ onClick: (t) => !l.value && m(e),
870
+ onPointerdown: (t) => f(e, t),
871
+ onPointerup: n[6] ||= (...e) => T(d) && T(d)(...e),
872
+ onPointerleave: n[7] ||= (...e) => T(d) && T(d)(...e),
873
+ onPointercancel: n[8] ||= (...e) => T(d) && T(d)(...e),
874
+ onContextmenu: n[9] ||= j(() => {}, ["prevent"])
875
+ }, C(e), 41, gt))), 128))])])])]));
876
+ }
877
+ }), bt = {
878
+ key: 0,
879
+ class: "zhk__disabled-overlay"
880
+ }, $ = /* @__PURE__ */ c({
881
+ __name: "ZhKeyboard",
882
+ props: {
883
+ defaultMode: {
884
+ type: String,
885
+ default: () => L().defaultMode ?? "en"
886
+ },
887
+ enableHandwriting: {
888
+ type: Boolean,
889
+ default: () => L().enableHandwriting ?? !1
890
+ },
891
+ position: {
892
+ type: String,
893
+ default: () => L().position ?? "static"
894
+ },
895
+ floatMarginTop: {
896
+ type: Number,
897
+ default: () => L().floatMarginTop ?? 0
898
+ },
899
+ disableWhenNoFocus: {
900
+ type: Boolean,
901
+ default: () => L().disableWhenNoFocus ?? !0
902
+ },
903
+ numKeys: { type: Array || void 0 }
904
+ },
905
+ emits: ["key"],
906
+ setup(o, { emit: s }) {
907
+ let c = o, l = s, u = b(c.defaultMode), d = b(c.defaultMode), f = b([]), h = b(!1), g = b(null), _ = b(null), { recognizerInitialized: v, recognizerProgress: x } = me(c.enableHandwriting);
908
+ O(u, (e, t) => {
909
+ e !== t && (d.value = t);
910
+ });
911
+ let S = fe(), C = t(() => S.value && z(S.value) ? S.value : null), w = t(() => c.position === "static" || !!(S.value && z(S.value))), { height: E } = Y(_);
912
+ k(() => {
913
+ if (C.value) {
914
+ let e = C.value.dataset.inputmode;
915
+ e && (u.value = e);
916
+ }
917
+ });
918
+ let M = t(() => c.disableWhenNoFocus === !1 ? !1 : !C.value);
919
+ function P() {
920
+ E.value && (g.value = N(C.value, _.value, c.position, c.floatMarginTop));
921
+ }
922
+ k(P);
923
+ let I = oe(P, 100);
924
+ q(window, "scroll", I, { passive: !0 }), q(window, "resize", I, { passive: !0 });
925
+ function L(e) {
926
+ if (e.isControl) {
927
+ switch (e.key) {
928
+ case "delete":
929
+ F(C.value);
930
+ break;
931
+ case "more":
932
+ h.value = !0;
933
+ break;
934
+ default: break;
935
+ }
936
+ return;
937
+ } else R(e.key);
938
+ l("key", e);
939
+ }
940
+ function R(e) {
941
+ ee(C.value, e);
942
+ }
943
+ function B() {
944
+ u.value === "hand" ? d.value = "zh" : ["num", "symbol"].includes(d.value) && (d.value = c.defaultMode), u.value = d.value;
945
+ }
946
+ function V(e) {
947
+ f.value = e;
948
+ }
949
+ return (t, s) => A((y(), i("div", {
950
+ ref_key: "keyboardRef",
951
+ ref: _,
952
+ class: p(["zhk", {
953
+ "zhk--floating": o.position === "float",
954
+ "zhk--bottom": o.position === "bottom",
955
+ "zhk--disabled": M.value
956
+ }]),
957
+ style: m({
958
+ "--keyboard-height": `${T(E)}px`,
959
+ ...g.value
960
+ }),
961
+ onMousedown: s[1] ||= j(() => {}, ["prevent"])
962
+ }, [M.value || !w.value || !T(E) ? (y(), i("div", bt, s[2] ||= [a("span", null, "请选择输入框以启用键盘", -1)])) : (y(), i(e, { key: 1 }, [u.value === "hand" ? (y(), n(De, {
963
+ key: 0,
964
+ "recognizer-initialized": T(v),
965
+ "recognizer-progress": T(x),
966
+ onKey: L,
967
+ onExit: B,
968
+ onRecognize: V
969
+ }, null, 8, ["recognizer-initialized", "recognizer-progress"])) : u.value === "num" ? (y(), n(at, {
970
+ key: 1,
971
+ "keyboard-rows": o.numKeys,
972
+ onKey: L,
973
+ onExit: B
974
+ }, null, 8, ["keyboard-rows"])) : u.value === "symbol" ? (y(), n(yt, {
975
+ key: 2,
976
+ onKey: L,
977
+ onExit: B
978
+ })) : u.value === "en" || u.value === "en_cap" || u.value === "zh" ? (y(), n(Je, {
979
+ key: 3,
980
+ modelValue: u.value,
981
+ "onUpdate:modelValue": s[0] ||= (e) => u.value = e,
982
+ "enable-handwriting": o.enableHandwriting,
983
+ onKey: L
984
+ }, null, 8, ["modelValue", "enable-handwriting"])) : r("", !0)], 64))], 38)), [[D, w.value]]);
985
+ }
986
+ }), xt = { install: (e) => {
987
+ e.component("ZhKeyboard", $);
988
+ } };
989
+ //#endregion
990
+ export { $ as ZhKeyboard, xt as default };
991
+
992
+ //# sourceMappingURL=zh-keyboard-vue.js.map