@tdh-keyboard/vue 1.0.0
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/LICENSE +190 -0
- package/README.md +275 -0
- package/dist/App.vue.d.ts +98 -0
- package/dist/components/CandidateBar.vue.d.ts +18 -0
- package/dist/components/CandidateList.vue.d.ts +9 -0
- package/dist/components/CandidateSelection.vue.d.ts +11 -0
- package/dist/components/HandwritingInput.vue.d.ts +14 -0
- package/dist/components/KeyboardBase.vue.d.ts +53 -0
- package/dist/components/KeyboardToolbar.vue.d.ts +15 -0
- package/dist/components/NumericKeyboard.vue.d.ts +14 -0
- package/dist/components/SymbolKeyboard.vue.d.ts +9 -0
- package/dist/components/TdhKeyboard.vue.d.ts +124 -0
- package/dist/hooks/useKeyRepeater.d.ts +4 -0
- package/dist/lib.d.ts +9 -0
- package/dist/main.d.ts +1 -0
- package/dist/style.css +2 -0
- package/dist/tdh-keyboard-vue.js +1104 -0
- package/dist/tdh-keyboard-vue.js.map +1 -0
- package/dist/tdh-keyboard-vue.umd.cjs +2 -0
- package/dist/tdh-keyboard-vue.umd.cjs.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/utils/useHandwritingRecognizer.d.ts +4 -0
- package/package.json +55 -0
|
@@ -0,0 +1,1104 @@
|
|
|
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 ee, watch as D, watchEffect as O, withDirectives as k, withModifiers as A } from "vue";
|
|
2
|
+
import { CanvasDrawer as j, calculateKeyboardPosition as M, createKeyRepeater as N, delToInputElement as te, getHandwritingRecognizer as P, getKeyboardConfig as F, getPinyinEngine as I, isInputElement as L, writeToInputElement as ne } from "@tdh-keyboard/core";
|
|
3
|
+
export * from "@tdh-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 R(e) {
|
|
6
|
+
return u() ? (_(e), !0) : !1;
|
|
7
|
+
}
|
|
8
|
+
var z = typeof window < "u" && typeof document < "u";
|
|
9
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
10
|
+
var B = (e) => e != null, V = Object.prototype.toString, H = (e) => V.call(e) === "[object Object]", U = () => {};
|
|
11
|
+
function W(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 G(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 K(e) {
|
|
39
|
+
return Array.isArray(e) ? e : [e];
|
|
40
|
+
}
|
|
41
|
+
function q(e) {
|
|
42
|
+
return e || l();
|
|
43
|
+
}
|
|
44
|
+
function re(e, t = 200, n = {}) {
|
|
45
|
+
return W(G(t, n), e);
|
|
46
|
+
}
|
|
47
|
+
function ie(e, t = !0, n) {
|
|
48
|
+
q(n) ? g(e, n) : t ? e() : f(e);
|
|
49
|
+
}
|
|
50
|
+
function J(e, t, n) {
|
|
51
|
+
return D(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 Y = z ? window : void 0;
|
|
59
|
+
z && window.document, z && window.navigator, z && window.location;
|
|
60
|
+
function X(e) {
|
|
61
|
+
let t = w(e);
|
|
62
|
+
return t?.$el ?? t;
|
|
63
|
+
}
|
|
64
|
+
function Z(...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 = K(w(e[0])).filter((e) => e != null);
|
|
69
|
+
return t.every((e) => typeof e != "string") ? t : void 0;
|
|
70
|
+
}), o = J(() => [
|
|
71
|
+
a.value?.map((e) => X(e)) ?? [Y].filter((e) => e != null),
|
|
72
|
+
K(w(a.value ? e[1] : e[0])),
|
|
73
|
+
K(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 = H(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 R(r), () => {
|
|
81
|
+
o(), r();
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function ae() {
|
|
85
|
+
let e = S(!1), t = l();
|
|
86
|
+
return t && g(() => {
|
|
87
|
+
e.value = !0;
|
|
88
|
+
}, t), e;
|
|
89
|
+
}
|
|
90
|
+
function Q(e) {
|
|
91
|
+
let n = ae();
|
|
92
|
+
return t(() => (n.value, !!e()));
|
|
93
|
+
}
|
|
94
|
+
function oe(e, n, r = {}) {
|
|
95
|
+
let { window: i = Y, ...a } = r, o, s = Q(() => i && "MutationObserver" in i), c = () => {
|
|
96
|
+
o &&= (o.disconnect(), void 0);
|
|
97
|
+
}, l = t(() => {
|
|
98
|
+
let t = K(w(e)).map(X).filter(B);
|
|
99
|
+
return new Set(t);
|
|
100
|
+
}), u = D(() => 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 R(f), {
|
|
109
|
+
isSupported: s,
|
|
110
|
+
stop: f,
|
|
111
|
+
takeRecords: d
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function se(e, t, n = {}) {
|
|
115
|
+
let { window: r = Y, 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 = O(() => {
|
|
120
|
+
let n = X(e);
|
|
121
|
+
if (n) {
|
|
122
|
+
let { stop: e } = oe(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 R(l), l;
|
|
135
|
+
}
|
|
136
|
+
function ce(e = {}) {
|
|
137
|
+
let { window: t = Y, 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
|
+
Z(t, "blur", (e) => {
|
|
150
|
+
e.relatedTarget === null && s();
|
|
151
|
+
}, e), Z(t, "focus", s, e);
|
|
152
|
+
}
|
|
153
|
+
return r && se(o, s, { document: i }), s(), o;
|
|
154
|
+
}
|
|
155
|
+
function le(e, n, r = {}) {
|
|
156
|
+
let { window: i = Y, ...a } = r, o, s = Q(() => i && "ResizeObserver" in i), c = () => {
|
|
157
|
+
o &&= (o.disconnect(), void 0);
|
|
158
|
+
}, l = D(t(() => {
|
|
159
|
+
let t = w(e);
|
|
160
|
+
return Array.isArray(t) ? t.map((e) => X(e)) : [X(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 R(u), {
|
|
173
|
+
isSupported: s,
|
|
174
|
+
stop: u
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function ue(e, n = {
|
|
178
|
+
width: 0,
|
|
179
|
+
height: 0
|
|
180
|
+
}, r = {}) {
|
|
181
|
+
let { window: i = Y, box: a = "content-box" } = r, o = t(() => (X(e)?.namespaceURI)?.includes("svg")), s = S(n.width), c = S(n.height), { stop: l } = le(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 = X(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 = K(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
|
+
ie(() => {
|
|
195
|
+
let t = X(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 = D(() => X(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 de(e = !1) {
|
|
213
|
+
let t = b(!1), n = b(0);
|
|
214
|
+
async function r() {
|
|
215
|
+
let e = P();
|
|
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 = P();
|
|
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 fe = "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", pe = "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 $() {
|
|
248
|
+
let e = N();
|
|
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 me = { class: "tdhk-candidate-list" }, he = ["onClick"], ge = /* @__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", me, [(y(!0), i(e, null, x(t.candidates, (e, t) => (y(), i("button", {
|
|
274
|
+
key: `candidate-${t}`,
|
|
275
|
+
class: "tdhk-candidate-list__item",
|
|
276
|
+
onClick: (e) => a(t)
|
|
277
|
+
}, C(e), 9, he))), 128))]));
|
|
278
|
+
}
|
|
279
|
+
}), _e = "data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='4.5'%20y='5.5'%20width='19'%20height='17'%20rx='3.5'%20stroke='%235E6773'%20stroke-width='2'/%3e%3cpath%20d='M8.5%2010H10'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M12%2010H13.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M15.5%2010H17'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010H20.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2014H10.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M12%2014H14.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2014H18.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M10%2018.5H18'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e", ve = "data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='6.5'%20y='3.5'%20width='15'%20height='21'%20rx='3.5'%20stroke='%235E6773'%20stroke-width='2'/%3e%3cpath%20d='M14%207H14.01'%20stroke='%235E6773'%20stroke-width='2.4'%20stroke-linecap='round'/%3e%3cpath%20d='M17.5%2016.5V14C17.5%2012.6193%2016.3807%2011.5%2015%2011.5C13.6193%2011.5%2012.5%2012.6193%2012.5%2014V19L11.25%2017.75C10.4697%2016.9697%209.20435%2016.9697%208.42401%2017.75C7.64366%2018.5303%207.64366%2019.7956%208.42401%2020.576L11.6766%2023.8284C12.0516%2024.2034%2012.5603%2024.4141%2013.0909%2024.4141H16C18.4853%2024.4141%2020.5%2022.3994%2020.5%2019.9141V16.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e", ye = { class: "tdhk-toolbar" }, be = ["aria-label", "disabled"], xe = ["src", "alt"], Se = /* @__PURE__ */ c({
|
|
280
|
+
__name: "KeyboardToolbar",
|
|
281
|
+
props: {
|
|
282
|
+
enableHandwriting: {
|
|
283
|
+
type: Boolean,
|
|
284
|
+
default: !1
|
|
285
|
+
},
|
|
286
|
+
isHandwritingMode: {
|
|
287
|
+
type: Boolean,
|
|
288
|
+
default: !1
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
emits: ["toggleKeyboard", "collapse"],
|
|
292
|
+
setup(e, { emit: n }) {
|
|
293
|
+
let r = e, o = n, s = t(() => r.isHandwritingMode ? "切换到输入键盘" : "切换到手写键盘"), c = t(() => r.isHandwritingMode ? _e : ve);
|
|
294
|
+
return (e, t) => (y(), i("div", ye, [
|
|
295
|
+
a("button", {
|
|
296
|
+
class: p(["tdhk-toolbar__button", { "tdhk-toolbar__button--disabled": !e.enableHandwriting }]),
|
|
297
|
+
type: "button",
|
|
298
|
+
"aria-label": s.value,
|
|
299
|
+
disabled: !e.enableHandwriting,
|
|
300
|
+
onClick: t[0] ||= (e) => o("toggleKeyboard"),
|
|
301
|
+
onContextmenu: t[1] ||= A(() => {}, ["prevent"])
|
|
302
|
+
}, [a("img", {
|
|
303
|
+
src: c.value,
|
|
304
|
+
class: "tdhk-toolbar__icon",
|
|
305
|
+
alt: s.value
|
|
306
|
+
}, null, 8, xe)], 42, be),
|
|
307
|
+
t[5] ||= a("div", { class: "tdhk-toolbar__spacer" }, null, -1),
|
|
308
|
+
t[6] ||= a("div", { class: "tdhk-toolbar__divider" }, null, -1),
|
|
309
|
+
a("button", {
|
|
310
|
+
class: "tdhk-toolbar__button tdhk-toolbar__button--collapse",
|
|
311
|
+
type: "button",
|
|
312
|
+
"aria-label": "收起键盘",
|
|
313
|
+
onClick: t[2] ||= (e) => o("collapse"),
|
|
314
|
+
onContextmenu: t[3] ||= A(() => {}, ["prevent"])
|
|
315
|
+
}, t[4] ||= [a("img", {
|
|
316
|
+
src: "data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2011L14%2018L21%2011'%20stroke='%235E6773'%20stroke-width='2.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",
|
|
317
|
+
class: "tdhk-toolbar__icon",
|
|
318
|
+
alt: "收起键盘"
|
|
319
|
+
}, null, -1)], 32)
|
|
320
|
+
]));
|
|
321
|
+
}
|
|
322
|
+
}), Ce = { class: "handwriting-input" }, we = { class: "handwriting-input__header" }, Te = {
|
|
323
|
+
key: 0,
|
|
324
|
+
class: "handwriting-input__candidates"
|
|
325
|
+
}, Ee = { class: "handwriting-content" }, De = { class: "handwriting-buttons" }, Oe = { class: "handwriting-canvas-container" }, ke = {
|
|
326
|
+
key: 0,
|
|
327
|
+
class: "handwriting-loading"
|
|
328
|
+
}, Ae = { class: "progress-bar" }, je = { class: "progress-text" }, Me = { class: "handwriting-buttons" }, Ne = /* @__PURE__ */ c({
|
|
329
|
+
__name: "HandwritingInput",
|
|
330
|
+
props: {
|
|
331
|
+
recognizerInitialized: { type: Boolean },
|
|
332
|
+
recognizerProgress: {}
|
|
333
|
+
},
|
|
334
|
+
emits: [
|
|
335
|
+
"key",
|
|
336
|
+
"exit",
|
|
337
|
+
"toggleKeyboard",
|
|
338
|
+
"switchToSymbol",
|
|
339
|
+
"collapse"
|
|
340
|
+
],
|
|
341
|
+
setup(e, { emit: t }) {
|
|
342
|
+
let r = e, o = t, c = b(null), l = null, u = b(!1), { width: d, height: p } = ue(c);
|
|
343
|
+
function h() {
|
|
344
|
+
l && l.clearCanvas();
|
|
345
|
+
}
|
|
346
|
+
function g() {
|
|
347
|
+
c.value && (l && l.destroy(), c.value.width = d.value, c.value.height = p.value, l = new j(c.value, { onDrawEnd: w }));
|
|
348
|
+
}
|
|
349
|
+
let _ = b([]), { startRepeat: x, stopRepeat: S } = $();
|
|
350
|
+
async function w() {
|
|
351
|
+
if (!l || l.getStrokeData().length === 0 || u.value) return;
|
|
352
|
+
let e = P();
|
|
353
|
+
if (e) {
|
|
354
|
+
u.value = !0;
|
|
355
|
+
try {
|
|
356
|
+
let t = [...l.getStrokeData()];
|
|
357
|
+
_.value = await e.recognize(t);
|
|
358
|
+
} catch (e) {
|
|
359
|
+
console.error("识别笔迹失败:", e);
|
|
360
|
+
} finally {
|
|
361
|
+
u.value = !1;
|
|
362
|
+
}
|
|
363
|
+
} else console.warn("手写识别服务不可用");
|
|
364
|
+
}
|
|
365
|
+
v(() => {
|
|
366
|
+
l && l.destroy();
|
|
367
|
+
}), O(() => {
|
|
368
|
+
c.value && (d.value || p.value) && r.recognizerInitialized && f(() => {
|
|
369
|
+
g();
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
function E(e) {
|
|
373
|
+
let t = _.value[e];
|
|
374
|
+
t && (o("key", { key: t }), _.value = [], h());
|
|
375
|
+
}
|
|
376
|
+
return (e, t) => (y(), i("div", Ce, [a("div", we, [_.value.length > 0 ? (y(), i("div", Te, [s(ge, {
|
|
377
|
+
candidates: _.value,
|
|
378
|
+
onSelect: E
|
|
379
|
+
}, null, 8, ["candidates"])])) : (y(), n(Se, {
|
|
380
|
+
key: 1,
|
|
381
|
+
"enable-handwriting": "",
|
|
382
|
+
"is-handwriting-mode": "",
|
|
383
|
+
onToggleKeyboard: t[0] ||= (e) => o("toggleKeyboard"),
|
|
384
|
+
onCollapse: t[1] ||= (e) => o("collapse")
|
|
385
|
+
}))]), a("div", Ee, [
|
|
386
|
+
a("div", De, [
|
|
387
|
+
a("button", {
|
|
388
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
389
|
+
onPointerdown: t[2] ||= (e) => T(x)(e, () => o("key", { key: "。" })),
|
|
390
|
+
onPointerup: t[3] ||= (...e) => T(S) && T(S)(...e),
|
|
391
|
+
onPointerleave: t[4] ||= (...e) => T(S) && T(S)(...e),
|
|
392
|
+
onPointercancel: t[5] ||= (...e) => T(S) && T(S)(...e),
|
|
393
|
+
onContextmenu: t[6] ||= A(() => {}, ["prevent"])
|
|
394
|
+
}, " 。 ", 32),
|
|
395
|
+
a("button", {
|
|
396
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
397
|
+
onPointerdown: t[7] ||= (e) => T(x)(e, () => o("key", { key: "?" })),
|
|
398
|
+
onPointerup: t[8] ||= (...e) => T(S) && T(S)(...e),
|
|
399
|
+
onPointerleave: t[9] ||= (...e) => T(S) && T(S)(...e),
|
|
400
|
+
onPointercancel: t[10] ||= (...e) => T(S) && T(S)(...e),
|
|
401
|
+
onContextmenu: t[11] ||= A(() => {}, ["prevent"])
|
|
402
|
+
}, " ? ", 32),
|
|
403
|
+
a("button", {
|
|
404
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
405
|
+
onPointerdown: t[12] ||= (e) => T(x)(e, () => o("key", { key: "!" })),
|
|
406
|
+
onPointerup: t[13] ||= (...e) => T(S) && T(S)(...e),
|
|
407
|
+
onPointerleave: t[14] ||= (...e) => T(S) && T(S)(...e),
|
|
408
|
+
onPointercancel: t[15] ||= (...e) => T(S) && T(S)(...e),
|
|
409
|
+
onContextmenu: t[16] ||= A(() => {}, ["prevent"])
|
|
410
|
+
}, " ! ", 32),
|
|
411
|
+
a("button", {
|
|
412
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
413
|
+
onClick: t[17] ||= (e) => o("switchToSymbol"),
|
|
414
|
+
onContextmenu: t[18] ||= A(() => {}, ["prevent"])
|
|
415
|
+
}, " 符 ", 32)
|
|
416
|
+
]),
|
|
417
|
+
a("div", Oe, [e.recognizerInitialized ? (y(), i("canvas", {
|
|
418
|
+
key: 1,
|
|
419
|
+
ref_key: "canvasRef",
|
|
420
|
+
ref: c,
|
|
421
|
+
class: "handwriting-canvas"
|
|
422
|
+
}, null, 512)) : (y(), i("div", ke, [
|
|
423
|
+
t[39] ||= a("div", { class: "loading-text" }, " 正在加载手写识别... ", -1),
|
|
424
|
+
a("div", Ae, [a("div", {
|
|
425
|
+
class: "progress-fill",
|
|
426
|
+
style: m({ width: `${e.recognizerProgress * 100}%` })
|
|
427
|
+
}, null, 4)]),
|
|
428
|
+
a("div", je, C(Math.round(e.recognizerProgress * 100)) + "% ", 1)
|
|
429
|
+
]))]),
|
|
430
|
+
a("div", Me, [
|
|
431
|
+
a("button", {
|
|
432
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
433
|
+
onPointerdown: t[19] ||= (e) => T(x)(e, () => o("key", {
|
|
434
|
+
key: "delete",
|
|
435
|
+
isControl: !0
|
|
436
|
+
})),
|
|
437
|
+
onPointerup: t[20] ||= (...e) => T(S) && T(S)(...e),
|
|
438
|
+
onPointerleave: t[21] ||= (...e) => T(S) && T(S)(...e),
|
|
439
|
+
onPointercancel: t[22] ||= (...e) => T(S) && T(S)(...e),
|
|
440
|
+
onContextmenu: t[23] ||= A(() => {}, ["prevent"])
|
|
441
|
+
}, t[40] ||= [a("img", {
|
|
442
|
+
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",
|
|
443
|
+
alt: "删除"
|
|
444
|
+
}, null, -1)], 32),
|
|
445
|
+
a("button", {
|
|
446
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
447
|
+
onPointerdown: t[24] ||= (e) => T(x)(e, () => o("key", { key: "、" })),
|
|
448
|
+
onPointerup: t[25] ||= (...e) => T(S) && T(S)(...e),
|
|
449
|
+
onPointerleave: t[26] ||= (...e) => T(S) && T(S)(...e),
|
|
450
|
+
onPointercancel: t[27] ||= (...e) => T(S) && T(S)(...e),
|
|
451
|
+
onContextmenu: t[28] ||= A(() => {}, ["prevent"])
|
|
452
|
+
}, " 、 ", 32),
|
|
453
|
+
a("button", {
|
|
454
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
455
|
+
onPointerdown: t[29] ||= (e) => T(x)(e, () => o("key", { key: "," })),
|
|
456
|
+
onPointerup: t[30] ||= (...e) => T(S) && T(S)(...e),
|
|
457
|
+
onPointerleave: t[31] ||= (...e) => T(S) && T(S)(...e),
|
|
458
|
+
onPointercancel: t[32] ||= (...e) => T(S) && T(S)(...e),
|
|
459
|
+
onContextmenu: t[33] ||= A(() => {}, ["prevent"])
|
|
460
|
+
}, " , ", 32),
|
|
461
|
+
a("button", {
|
|
462
|
+
class: "handwriting-btn handwriting-btn--function",
|
|
463
|
+
onPointerdown: t[34] ||= (e) => T(x)(e, () => o("key", {
|
|
464
|
+
key: "enter",
|
|
465
|
+
isControl: !0
|
|
466
|
+
})),
|
|
467
|
+
onPointerup: t[35] ||= (...e) => T(S) && T(S)(...e),
|
|
468
|
+
onPointerleave: t[36] ||= (...e) => T(S) && T(S)(...e),
|
|
469
|
+
onPointercancel: t[37] ||= (...e) => T(S) && T(S)(...e),
|
|
470
|
+
onContextmenu: t[38] ||= A(() => {}, ["prevent"])
|
|
471
|
+
}, t[41] ||= [a("img", {
|
|
472
|
+
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",
|
|
473
|
+
alt: "回车"
|
|
474
|
+
}, null, -1)], 32)
|
|
475
|
+
])
|
|
476
|
+
])]));
|
|
477
|
+
}
|
|
478
|
+
}), Pe = "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 = { class: "tdhk-selection" }, Ie = { class: "tdhk-selection__list" }, Le = ["onClick"], Re = /* @__PURE__ */ c({
|
|
479
|
+
__name: "CandidateSelection",
|
|
480
|
+
props: { candidates: {} },
|
|
481
|
+
emits: ["select", "close"],
|
|
482
|
+
setup(t, { emit: n }) {
|
|
483
|
+
let r = n;
|
|
484
|
+
function o(e) {
|
|
485
|
+
r("select", e);
|
|
486
|
+
}
|
|
487
|
+
function s() {
|
|
488
|
+
r("close");
|
|
489
|
+
}
|
|
490
|
+
function c(e) {
|
|
491
|
+
let t = Array.from(e).length;
|
|
492
|
+
return t >= 2 && t <= 3 ? 2 : t >= 4 ? 3 : 1;
|
|
493
|
+
}
|
|
494
|
+
return (t, n) => (y(), i("div", Fe, [a("div", Ie, [(y(!0), i(e, null, x(t.candidates, (e, t) => (y(), i("div", {
|
|
495
|
+
key: t,
|
|
496
|
+
class: p(["tdhk-selection__text", [`tdhk-selection__text--span-${c(e)}`]]),
|
|
497
|
+
onClick: (e) => o(t)
|
|
498
|
+
}, C(e), 11, Le))), 128))]), a("div", { class: "tdhk-selection__func" }, [a("button", {
|
|
499
|
+
class: "tdhk-selection__func-btn",
|
|
500
|
+
onClick: s
|
|
501
|
+
}, " 返回 ")])]));
|
|
502
|
+
}
|
|
503
|
+
}), ze = { class: "tdhk-candidate" }, Be = { class: "tdhk-candidate__container" }, Ve = {
|
|
504
|
+
key: 0,
|
|
505
|
+
class: "tdhk-candidate__pinyin"
|
|
506
|
+
}, He = { class: "tdhk-candidate__bottom-container" }, Ue = /* @__PURE__ */ c({
|
|
507
|
+
__name: "CandidateBar",
|
|
508
|
+
props: {
|
|
509
|
+
modelValue: { required: !0 },
|
|
510
|
+
modelModifiers: {}
|
|
511
|
+
},
|
|
512
|
+
emits: /* @__PURE__ */ d(["key", "input"], ["update:modelValue"]),
|
|
513
|
+
setup(e, { expose: o, emit: s }) {
|
|
514
|
+
let c = s, l = E(e, "modelValue"), u = null, d = b(null), f = t(() => d.value?.candidates.map((e) => e.text) ?? []), p = b(!1);
|
|
515
|
+
g(async () => {
|
|
516
|
+
if (u = I(), !u) throw Error("未找到拼音引擎实例,请确保已正确注册引擎");
|
|
517
|
+
l.value && (d.value = await u.processInput(l.value));
|
|
518
|
+
}), v(() => {
|
|
519
|
+
u?.processInput("").catch(() => {}), u = null;
|
|
520
|
+
}), D(l, async (e) => {
|
|
521
|
+
let t = u;
|
|
522
|
+
if (t) {
|
|
523
|
+
if (e === "") {
|
|
524
|
+
t.processInput("").catch(() => {}), d.value = null;
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
d.value = await t.processInput(e);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
async function m(e) {
|
|
531
|
+
if (!u) return;
|
|
532
|
+
let t = await u.pickCandidate(e);
|
|
533
|
+
d.value = t, t.preeditBody || (c("input", t.committed || ""), l.value = "", d.value = null, p.value = !1);
|
|
534
|
+
}
|
|
535
|
+
o({ handleSelection: m });
|
|
536
|
+
let h = t(() => {
|
|
537
|
+
let e = d.value;
|
|
538
|
+
return e ? e.preeditHead + e.preeditBody : "";
|
|
539
|
+
});
|
|
540
|
+
return (e, t) => (y(), i("div", ze, [a("div", Be, [h.value ? (y(), i("div", Ve, C(h.value), 1)) : r("", !0), a("div", He, [f.value.length > 0 ? (y(), n(ge, {
|
|
541
|
+
key: 0,
|
|
542
|
+
candidates: f.value,
|
|
543
|
+
onSelect: m
|
|
544
|
+
}, null, 8, ["candidates"])) : r("", !0), f.value.length > 0 ? (y(), i("button", {
|
|
545
|
+
key: 1,
|
|
546
|
+
class: "tdhk-candidate__more",
|
|
547
|
+
onClick: t[0] ||= (e) => p.value = !0
|
|
548
|
+
}, t[2] ||= [a("img", {
|
|
549
|
+
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",
|
|
550
|
+
alt: "更多"
|
|
551
|
+
}, null, -1)])) : r("", !0)])]), p.value ? (y(), n(Re, {
|
|
552
|
+
key: 0,
|
|
553
|
+
candidates: f.value,
|
|
554
|
+
onSelect: m,
|
|
555
|
+
onClose: t[1] ||= (e) => p.value = !1
|
|
556
|
+
}, null, 8, ["candidates"])) : r("", !0)]));
|
|
557
|
+
}
|
|
558
|
+
}), We = { class: "tdhk-base" }, Ge = { class: "tdhk-base__row tdhk-base__row--header" }, Ke = ["onPointerdown"], qe = { class: "tdhk-base__row" }, Je = { class: "tdhk-base__toggle-main" }, Ye = { class: "tdhk-base__toggle-sub" }, Xe = /* @__PURE__ */ c({
|
|
559
|
+
__name: "KeyboardBase",
|
|
560
|
+
props: /* @__PURE__ */ d({ enableHandwriting: { type: Boolean } }, {
|
|
561
|
+
modelValue: { default: "en" },
|
|
562
|
+
modelModifiers: {},
|
|
563
|
+
capsReturnToChinese: {
|
|
564
|
+
type: Boolean,
|
|
565
|
+
default: !1
|
|
566
|
+
},
|
|
567
|
+
capsReturnToChineseModifiers: {}
|
|
568
|
+
}),
|
|
569
|
+
emits: /* @__PURE__ */ d([
|
|
570
|
+
"key",
|
|
571
|
+
"collapse",
|
|
572
|
+
"toggleKeyboard"
|
|
573
|
+
], ["update:modelValue", "update:capsReturnToChinese"]),
|
|
574
|
+
setup(o, { emit: s }) {
|
|
575
|
+
let c = s, l = E(o, "modelValue"), u = E(o, "capsReturnToChinese"), d = t(() => l.value === "en_cap"), f = t(() => l.value === "zh"), m = t(() => f.value ? !0 : d.value), h = b(""), g = b(null), _ = t(() => f.value && h.value.length > 0);
|
|
576
|
+
function v(e, t = !1) {
|
|
577
|
+
c("key", {
|
|
578
|
+
key: e,
|
|
579
|
+
isControl: t
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function S() {
|
|
583
|
+
f.value ? (h.value = "", u.value = !0, l.value = "en_cap") : d.value && u.value ? (u.value = !1, l.value = "zh") : (u.value = !1, l.value = d.value ? "en" : "en_cap");
|
|
584
|
+
}
|
|
585
|
+
function w() {
|
|
586
|
+
l.value = "num";
|
|
587
|
+
}
|
|
588
|
+
function ee() {
|
|
589
|
+
l.value = "symbol";
|
|
590
|
+
}
|
|
591
|
+
let D = [
|
|
592
|
+
[
|
|
593
|
+
"q",
|
|
594
|
+
"w",
|
|
595
|
+
"e",
|
|
596
|
+
"r",
|
|
597
|
+
"t",
|
|
598
|
+
"y",
|
|
599
|
+
"u",
|
|
600
|
+
"i",
|
|
601
|
+
"o",
|
|
602
|
+
"p"
|
|
603
|
+
],
|
|
604
|
+
[
|
|
605
|
+
"a",
|
|
606
|
+
"s",
|
|
607
|
+
"d",
|
|
608
|
+
"f",
|
|
609
|
+
"g",
|
|
610
|
+
"h",
|
|
611
|
+
"j",
|
|
612
|
+
"k",
|
|
613
|
+
"l"
|
|
614
|
+
],
|
|
615
|
+
[
|
|
616
|
+
"z",
|
|
617
|
+
"x",
|
|
618
|
+
"c",
|
|
619
|
+
"v",
|
|
620
|
+
"b",
|
|
621
|
+
"n",
|
|
622
|
+
"m"
|
|
623
|
+
]
|
|
624
|
+
], { startRepeat: O, stopRepeat: k } = $();
|
|
625
|
+
function j() {
|
|
626
|
+
if (l.value === "zh" && h.value) {
|
|
627
|
+
h.value = h.value.slice(0, -1);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
v("delete", !0);
|
|
631
|
+
}
|
|
632
|
+
function M() {
|
|
633
|
+
if (l.value === "zh" && h.value) {
|
|
634
|
+
g.value?.handleSelection(0);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
v(" ");
|
|
638
|
+
}
|
|
639
|
+
function N() {
|
|
640
|
+
if (l.value === "zh" && h.value) {
|
|
641
|
+
v(h.value), h.value = "";
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
v("enter", !0);
|
|
645
|
+
}
|
|
646
|
+
function te(e) {
|
|
647
|
+
if (l.value === "zh") {
|
|
648
|
+
h.value += e;
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
v(d.value ? e.toUpperCase() : e);
|
|
652
|
+
}
|
|
653
|
+
function P() {
|
|
654
|
+
u.value = !1, l.value = l.value === "zh" ? "en" : "zh";
|
|
655
|
+
}
|
|
656
|
+
return (t, o) => (y(), i("div", We, [
|
|
657
|
+
a("div", Ge, [_.value ? (y(), n(Ue, {
|
|
658
|
+
key: 0,
|
|
659
|
+
ref_key: "candidateBarRef",
|
|
660
|
+
ref: g,
|
|
661
|
+
modelValue: h.value,
|
|
662
|
+
"onUpdate:modelValue": o[0] ||= (e) => h.value = e,
|
|
663
|
+
onInput: o[1] ||= (e) => v(e, !1)
|
|
664
|
+
}, null, 8, ["modelValue"])) : (y(), n(Se, {
|
|
665
|
+
key: 1,
|
|
666
|
+
"enable-handwriting": t.enableHandwriting,
|
|
667
|
+
onToggleKeyboard: o[2] ||= (e) => c("toggleKeyboard"),
|
|
668
|
+
onCollapse: o[3] ||= (e) => c("collapse")
|
|
669
|
+
}, null, 8, ["enable-handwriting"]))]),
|
|
670
|
+
(y(), i(e, null, x(D, (t, n) => a("div", {
|
|
671
|
+
key: `row-${n}`,
|
|
672
|
+
class: "tdhk-base__row"
|
|
673
|
+
}, [
|
|
674
|
+
n === 2 ? (y(), i("button", {
|
|
675
|
+
key: 0,
|
|
676
|
+
class: p(["tdhk-base__key tdhk-base__key--function tdhk-base__key--shift", { "tdhk-base__key--active": d.value }]),
|
|
677
|
+
onClick: S,
|
|
678
|
+
onContextmenu: o[4] ||= A(() => {}, ["prevent"])
|
|
679
|
+
}, o[37] ||= [a("img", {
|
|
680
|
+
src: "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",
|
|
681
|
+
class: "tdhk-base__key-icon",
|
|
682
|
+
alt: "Shift"
|
|
683
|
+
}, null, -1)], 34)) : r("", !0),
|
|
684
|
+
(y(!0), i(e, null, x(t, (e, t) => (y(), i("button", {
|
|
685
|
+
key: `key-${n}-${t}`,
|
|
686
|
+
class: "tdhk-base__key tdhk-base__key--letter",
|
|
687
|
+
onPointerdown: (t) => T(O)(t, () => te(e)),
|
|
688
|
+
onPointerup: o[5] ||= (...e) => T(k) && T(k)(...e),
|
|
689
|
+
onPointerleave: o[6] ||= (...e) => T(k) && T(k)(...e),
|
|
690
|
+
onPointercancel: o[7] ||= (...e) => T(k) && T(k)(...e),
|
|
691
|
+
onContextmenu: o[8] ||= A(() => {}, ["prevent"])
|
|
692
|
+
}, C(m.value ? e.toUpperCase() : e), 41, Ke))), 128)),
|
|
693
|
+
n === 2 ? (y(), i("button", {
|
|
694
|
+
key: 1,
|
|
695
|
+
class: "tdhk-base__key tdhk-base__key--function tdhk-base__key--delete",
|
|
696
|
+
onPointerdown: o[9] ||= (e) => T(O)(e, () => j()),
|
|
697
|
+
onPointerup: o[10] ||= (...e) => T(k) && T(k)(...e),
|
|
698
|
+
onPointerleave: o[11] ||= (...e) => T(k) && T(k)(...e),
|
|
699
|
+
onPointercancel: o[12] ||= (...e) => T(k) && T(k)(...e),
|
|
700
|
+
onContextmenu: o[13] ||= A(() => {}, ["prevent"])
|
|
701
|
+
}, o[38] ||= [a("img", {
|
|
702
|
+
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",
|
|
703
|
+
class: "tdhk-base__key-icon",
|
|
704
|
+
alt: "Delete"
|
|
705
|
+
}, null, -1)], 32)) : r("", !0)
|
|
706
|
+
])), 64)),
|
|
707
|
+
a("div", qe, [
|
|
708
|
+
a("button", {
|
|
709
|
+
class: "tdhk-base__key tdhk-base__key--function",
|
|
710
|
+
onClick: ee,
|
|
711
|
+
onContextmenu: o[14] ||= A(() => {}, ["prevent"])
|
|
712
|
+
}, " 符 ", 32),
|
|
713
|
+
a("button", {
|
|
714
|
+
class: "tdhk-base__key tdhk-base__key--function",
|
|
715
|
+
onClick: w,
|
|
716
|
+
onContextmenu: o[15] ||= A(() => {}, ["prevent"])
|
|
717
|
+
}, " 123 ", 32),
|
|
718
|
+
a("button", {
|
|
719
|
+
class: "tdhk-base__key",
|
|
720
|
+
onPointerdown: o[16] ||= (e) => T(O)(e, () => v(",")),
|
|
721
|
+
onPointerup: o[17] ||= (...e) => T(k) && T(k)(...e),
|
|
722
|
+
onPointerleave: o[18] ||= (...e) => T(k) && T(k)(...e),
|
|
723
|
+
onPointercancel: o[19] ||= (...e) => T(k) && T(k)(...e),
|
|
724
|
+
onContextmenu: o[20] ||= A(() => {}, ["prevent"])
|
|
725
|
+
}, " , ", 32),
|
|
726
|
+
a("button", {
|
|
727
|
+
class: "tdhk-base__key tdhk-base__key--space",
|
|
728
|
+
onPointerdown: o[21] ||= (e) => T(O)(e, () => M()),
|
|
729
|
+
onPointerup: o[22] ||= (...e) => T(k) && T(k)(...e),
|
|
730
|
+
onPointerleave: o[23] ||= (...e) => T(k) && T(k)(...e),
|
|
731
|
+
onPointercancel: o[24] ||= (...e) => T(k) && T(k)(...e),
|
|
732
|
+
onContextmenu: o[25] ||= A(() => {}, ["prevent"])
|
|
733
|
+
}, o[39] ||= [a("img", {
|
|
734
|
+
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",
|
|
735
|
+
class: "tdhk-base__key-icon",
|
|
736
|
+
alt: "Space"
|
|
737
|
+
}, null, -1)], 32),
|
|
738
|
+
a("button", {
|
|
739
|
+
class: "tdhk-base__key",
|
|
740
|
+
onPointerdown: o[26] ||= (e) => T(O)(e, () => v("。")),
|
|
741
|
+
onPointerup: o[27] ||= (...e) => T(k) && T(k)(...e),
|
|
742
|
+
onPointerleave: o[28] ||= (...e) => T(k) && T(k)(...e),
|
|
743
|
+
onPointercancel: o[29] ||= (...e) => T(k) && T(k)(...e),
|
|
744
|
+
onContextmenu: o[30] ||= A(() => {}, ["prevent"])
|
|
745
|
+
}, " 。 ", 32),
|
|
746
|
+
a("button", {
|
|
747
|
+
class: "tdhk-base__key tdhk-base__key--function",
|
|
748
|
+
onClick: P,
|
|
749
|
+
onContextmenu: o[31] ||= A(() => {}, ["prevent"])
|
|
750
|
+
}, [a("span", Je, C(f.value ? "中" : "英"), 1), a("span", Ye, "/" + C(f.value ? "英" : "中"), 1)], 32),
|
|
751
|
+
a("button", {
|
|
752
|
+
class: "tdhk-base__key tdhk-base__key--function",
|
|
753
|
+
onPointerdown: o[32] ||= (e) => T(O)(e, () => N()),
|
|
754
|
+
onPointerup: o[33] ||= (...e) => T(k) && T(k)(...e),
|
|
755
|
+
onPointerleave: o[34] ||= (...e) => T(k) && T(k)(...e),
|
|
756
|
+
onPointercancel: o[35] ||= (...e) => T(k) && T(k)(...e),
|
|
757
|
+
onContextmenu: o[36] ||= A(() => {}, ["prevent"])
|
|
758
|
+
}, o[40] ||= [a("img", {
|
|
759
|
+
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",
|
|
760
|
+
class: "tdhk-base__key-icon",
|
|
761
|
+
alt: "Enter"
|
|
762
|
+
}, null, -1)], 32)
|
|
763
|
+
])
|
|
764
|
+
]));
|
|
765
|
+
}
|
|
766
|
+
}), Ze = { class: "num-keyboard" }, Qe = { class: "num-keyboard__container" }, $e = { class: "num-keyboard__left" }, et = { class: "num-keyboard__rows" }, tt = ["onClick", "onPointerdown"], nt = {
|
|
767
|
+
key: 1,
|
|
768
|
+
src: Pe,
|
|
769
|
+
class: "tdhk-base__key-icon",
|
|
770
|
+
alt: "Space"
|
|
771
|
+
}, rt = { class: "num-keyboard__right" }, it = ["onPointerdown"], at = ["src", "alt"], ot = { key: 1 }, st = /* @__PURE__ */ c({
|
|
772
|
+
__name: "NumericKeyboard",
|
|
773
|
+
props: { keyboardRows: { default: () => F().numKeys || [
|
|
774
|
+
[
|
|
775
|
+
"1",
|
|
776
|
+
"2",
|
|
777
|
+
"3"
|
|
778
|
+
],
|
|
779
|
+
[
|
|
780
|
+
"4",
|
|
781
|
+
"5",
|
|
782
|
+
"6"
|
|
783
|
+
],
|
|
784
|
+
[
|
|
785
|
+
"7",
|
|
786
|
+
"8",
|
|
787
|
+
"9"
|
|
788
|
+
],
|
|
789
|
+
[
|
|
790
|
+
"back",
|
|
791
|
+
"0",
|
|
792
|
+
"space"
|
|
793
|
+
]
|
|
794
|
+
] } },
|
|
795
|
+
emits: ["key", "exit"],
|
|
796
|
+
setup(t, { emit: n }) {
|
|
797
|
+
let r = n, s = [
|
|
798
|
+
{
|
|
799
|
+
key: "delete",
|
|
800
|
+
icon: fe,
|
|
801
|
+
text: "",
|
|
802
|
+
alt: "Delete"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
key: ".",
|
|
806
|
+
icon: "",
|
|
807
|
+
text: ".",
|
|
808
|
+
alt: "."
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
key: "@",
|
|
812
|
+
icon: "",
|
|
813
|
+
text: "@",
|
|
814
|
+
alt: "@"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
key: "enter",
|
|
818
|
+
icon: pe,
|
|
819
|
+
text: "",
|
|
820
|
+
alt: "Enter"
|
|
821
|
+
}
|
|
822
|
+
];
|
|
823
|
+
function c(e) {
|
|
824
|
+
r("key", { key: e });
|
|
825
|
+
}
|
|
826
|
+
function l(e, t = !0) {
|
|
827
|
+
r("key", {
|
|
828
|
+
key: e,
|
|
829
|
+
isControl: t
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
function u() {
|
|
833
|
+
r("exit");
|
|
834
|
+
}
|
|
835
|
+
let { startRepeat: d, stopRepeat: f } = $();
|
|
836
|
+
function m(e, t) {
|
|
837
|
+
e === "back" || (e === "space" && (e = " "), e === "delete" || e === "enter" ? d(t, () => l(e)) : d(t, () => c(e)));
|
|
838
|
+
}
|
|
839
|
+
return (t, n) => (y(), i("div", Ze, [a("div", Qe, [a("div", $e, [a("div", et, [(y(!0), i(e, null, x(t.keyboardRows, (t, r) => (y(), i("div", {
|
|
840
|
+
key: `row-${r}`,
|
|
841
|
+
class: "num-keyboard__row"
|
|
842
|
+
}, [(y(!0), i(e, null, x(t, (t, a) => (y(), i("button", {
|
|
843
|
+
key: `key-${r}-${a}`,
|
|
844
|
+
class: p(["num-keyboard__key", {
|
|
845
|
+
"num-keyboard__key--back": t === "back",
|
|
846
|
+
"num-keyboard__key--space": t === "space"
|
|
847
|
+
}]),
|
|
848
|
+
onClick: (e) => t === "back" && u(),
|
|
849
|
+
onPointerdown: (e) => m(t, e),
|
|
850
|
+
onPointerup: n[0] ||= (...e) => T(f) && T(f)(...e),
|
|
851
|
+
onPointerleave: n[1] ||= (...e) => T(f) && T(f)(...e),
|
|
852
|
+
onPointercancel: n[2] ||= (...e) => T(f) && T(f)(...e),
|
|
853
|
+
onContextmenu: n[3] ||= A(() => {}, ["prevent"])
|
|
854
|
+
}, [t === "back" ? (y(), i(e, { key: 0 }, [o(" 返回 ")], 64)) : t === "space" ? (y(), i("img", nt)) : (y(), i(e, { key: 2 }, [o(C(t), 1)], 64))], 42, tt))), 128))]))), 128))])]), a("div", rt, [(y(), i(e, null, x(s, (e, t) => a("button", {
|
|
855
|
+
key: `func-${t}`,
|
|
856
|
+
class: "num-keyboard__key num-keyboard__key--function",
|
|
857
|
+
onPointerdown: (t) => m(e.key, t),
|
|
858
|
+
onPointerup: n[4] ||= (...e) => T(f) && T(f)(...e),
|
|
859
|
+
onPointerleave: n[5] ||= (...e) => T(f) && T(f)(...e),
|
|
860
|
+
onPointercancel: n[6] ||= (...e) => T(f) && T(f)(...e),
|
|
861
|
+
onContextmenu: n[7] ||= A(() => {}, ["prevent"])
|
|
862
|
+
}, [e.icon ? (y(), i("img", {
|
|
863
|
+
key: 0,
|
|
864
|
+
src: e.icon,
|
|
865
|
+
class: "num-keyboard__key-icon",
|
|
866
|
+
alt: e.alt
|
|
867
|
+
}, null, 8, at)) : (y(), i("span", ot, C(e.text), 1))], 40, it)), 64))])])]));
|
|
868
|
+
}
|
|
869
|
+
}), ct = "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", lt = "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", ut = { class: "symbol-keyboard" }, dt = { class: "symbol-keyboard__content" }, ft = { class: "symbol-keyboard__functions" }, pt = { class: "symbol-keyboard__lang-selector" }, mt = { class: "symbol-keyboard__control-group" }, ht = ["src"], gt = ["src"], _t = { class: "symbol-keyboard__symbols-container" }, vt = { class: "symbol-keyboard__symbols-grid" }, yt = ["onClick", "onPointerdown"], bt = "!@#$%^&*(){}[]<>/\\|:;\"',.?+-=_~`€£¥₹©®™°", xt = "!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°", St = /* @__PURE__ */ c({
|
|
870
|
+
__name: "SymbolKeyboard",
|
|
871
|
+
emits: ["key", "exit"],
|
|
872
|
+
setup(n, { emit: r }) {
|
|
873
|
+
let o = r, s = b("en"), c = t(() => s.value === "zh" ? xt : bt), l = b(!1), { startRepeat: u, stopRepeat: d } = $();
|
|
874
|
+
function f(e, t) {
|
|
875
|
+
l.value && u(t, () => m(e));
|
|
876
|
+
}
|
|
877
|
+
function m(e) {
|
|
878
|
+
o("key", { key: e }), l.value || o("exit");
|
|
879
|
+
}
|
|
880
|
+
function h() {
|
|
881
|
+
o("exit");
|
|
882
|
+
}
|
|
883
|
+
function g(e) {
|
|
884
|
+
s.value = e;
|
|
885
|
+
}
|
|
886
|
+
function _() {
|
|
887
|
+
l.value = !l.value;
|
|
888
|
+
}
|
|
889
|
+
return (t, n) => (y(), i("div", ut, [a("div", dt, [a("div", ft, [a("div", pt, [a("button", {
|
|
890
|
+
class: p(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": s.value === "zh" }]),
|
|
891
|
+
onClick: n[0] ||= (e) => g("zh"),
|
|
892
|
+
onContextmenu: n[1] ||= A(() => {}, ["prevent"])
|
|
893
|
+
}, " 中文 ", 34), a("button", {
|
|
894
|
+
class: p(["symbol-keyboard__lang-btn", { "symbol-keyboard__lang-btn--active": s.value === "en" }]),
|
|
895
|
+
onClick: n[2] ||= (e) => g("en"),
|
|
896
|
+
onContextmenu: n[3] ||= A(() => {}, ["prevent"])
|
|
897
|
+
}, " 英文 ", 34)]), a("div", mt, [a("button", {
|
|
898
|
+
class: p(["symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock", { "symbol-keyboard__key--locked": l.value }]),
|
|
899
|
+
onClick: _,
|
|
900
|
+
onContextmenu: n[4] ||= A(() => {}, ["prevent"])
|
|
901
|
+
}, [l.value ? (y(), i("img", {
|
|
902
|
+
key: 1,
|
|
903
|
+
src: T(lt),
|
|
904
|
+
alt: "Lock closed"
|
|
905
|
+
}, null, 8, gt)) : (y(), i("img", {
|
|
906
|
+
key: 0,
|
|
907
|
+
src: T(ct),
|
|
908
|
+
alt: "Lock open"
|
|
909
|
+
}, null, 8, ht))], 34), a("button", {
|
|
910
|
+
class: "symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back",
|
|
911
|
+
onClick: h,
|
|
912
|
+
onContextmenu: n[5] ||= A(() => {}, ["prevent"])
|
|
913
|
+
}, " 返回 ", 32)])]), a("div", _t, [a("div", vt, [(y(!0), i(e, null, x(c.value, (e, t) => (y(), i("button", {
|
|
914
|
+
key: `key-${t}`,
|
|
915
|
+
class: "symbol-keyboard__key",
|
|
916
|
+
onClick: (t) => !l.value && m(e),
|
|
917
|
+
onPointerdown: (t) => f(e, t),
|
|
918
|
+
onPointerup: n[6] ||= (...e) => T(d) && T(d)(...e),
|
|
919
|
+
onPointerleave: n[7] ||= (...e) => T(d) && T(d)(...e),
|
|
920
|
+
onPointercancel: n[8] ||= (...e) => T(d) && T(d)(...e),
|
|
921
|
+
onContextmenu: n[9] ||= A(() => {}, ["prevent"])
|
|
922
|
+
}, C(e), 41, yt))), 128))])])])]));
|
|
923
|
+
}
|
|
924
|
+
}), Ct = {
|
|
925
|
+
key: 0,
|
|
926
|
+
class: "tdhk__disabled-overlay"
|
|
927
|
+
}, wt = /* @__PURE__ */ c({
|
|
928
|
+
__name: "TdhKeyboard",
|
|
929
|
+
props: {
|
|
930
|
+
defaultMode: {
|
|
931
|
+
type: String,
|
|
932
|
+
default: () => F().defaultMode ?? "en"
|
|
933
|
+
},
|
|
934
|
+
enableHandwriting: {
|
|
935
|
+
type: Boolean,
|
|
936
|
+
default: () => F().enableHandwriting ?? !1
|
|
937
|
+
},
|
|
938
|
+
position: {
|
|
939
|
+
type: String,
|
|
940
|
+
default: () => F().position ?? "static"
|
|
941
|
+
},
|
|
942
|
+
floatMarginTop: {
|
|
943
|
+
type: Number,
|
|
944
|
+
default: () => F().floatMarginTop ?? 0
|
|
945
|
+
},
|
|
946
|
+
disableWhenNoFocus: {
|
|
947
|
+
type: Boolean,
|
|
948
|
+
default: () => F().disableWhenNoFocus ?? !0
|
|
949
|
+
},
|
|
950
|
+
manual: {
|
|
951
|
+
type: Boolean,
|
|
952
|
+
default: () => F().manual ?? !1
|
|
953
|
+
},
|
|
954
|
+
numKeys: { type: Array || void 0 }
|
|
955
|
+
},
|
|
956
|
+
emits: ["key"],
|
|
957
|
+
setup(o, { expose: s, emit: c }) {
|
|
958
|
+
let l = o, u = c;
|
|
959
|
+
function d(e) {
|
|
960
|
+
return e === "zh" || e === "en" || e === "en_cap";
|
|
961
|
+
}
|
|
962
|
+
function f(e) {
|
|
963
|
+
return d(e) ? e : "zh";
|
|
964
|
+
}
|
|
965
|
+
let h = b(l.defaultMode), g = b(!1), _ = b(f(l.defaultMode)), v = b(!1), x = b(!1), S = b([]), C = b(!1), w = b(null), E = b(null), j = b(null), N = b(!l.manual), P = b(!1), { recognizerInitialized: F, recognizerProgress: I } = de(l.enableHandwriting);
|
|
966
|
+
D(h, (e) => {
|
|
967
|
+
d(e) && (_.value = e);
|
|
968
|
+
});
|
|
969
|
+
let R = ce(), z = t(() => l.manual ? j.value : R.value && L(R.value) ? R.value : null), B = t(() => P.value || !N.value || g.value && !z.value ? !1 : l.manual || l.position === "static" || !!(R.value && L(R.value)));
|
|
970
|
+
D(z, (e, t) => {
|
|
971
|
+
!l.manual && !P.value && e && e !== t && (N.value = !0);
|
|
972
|
+
});
|
|
973
|
+
let { height: V } = ue(E);
|
|
974
|
+
O(() => {
|
|
975
|
+
if (N.value && z.value) {
|
|
976
|
+
g.value = !1;
|
|
977
|
+
let e = z.value.dataset.inputmode;
|
|
978
|
+
e && (v.value = !1, x.value = !1, d(e) ? _.value = e : e === "hand" && (_.value = "zh"), h.value = e);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
let H = t(() => l.manual ? !j.value : l.disableWhenNoFocus === !1 ? !1 : !z.value);
|
|
982
|
+
function U() {
|
|
983
|
+
V.value && (w.value = M(z.value, E.value, l.position, l.floatMarginTop));
|
|
984
|
+
}
|
|
985
|
+
O(U);
|
|
986
|
+
let W = re(U, 100);
|
|
987
|
+
Z(window, "scroll", W, { passive: !0 }), Z(window, "resize", W, { passive: !0 });
|
|
988
|
+
function G(e) {
|
|
989
|
+
if (e.isControl) {
|
|
990
|
+
switch (e.key) {
|
|
991
|
+
case "delete":
|
|
992
|
+
te(z.value);
|
|
993
|
+
break;
|
|
994
|
+
case "more":
|
|
995
|
+
C.value = !0;
|
|
996
|
+
break;
|
|
997
|
+
default: break;
|
|
998
|
+
}
|
|
999
|
+
return;
|
|
1000
|
+
} else K(e.key);
|
|
1001
|
+
u("key", e);
|
|
1002
|
+
}
|
|
1003
|
+
function K(e) {
|
|
1004
|
+
ne(z.value, e);
|
|
1005
|
+
}
|
|
1006
|
+
function q() {
|
|
1007
|
+
if (h.value === "symbol" && x.value) {
|
|
1008
|
+
x.value = !1, h.value = "hand";
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
x.value = !1, h.value = _.value;
|
|
1012
|
+
}
|
|
1013
|
+
function ie(e) {
|
|
1014
|
+
S.value = e;
|
|
1015
|
+
}
|
|
1016
|
+
function J() {
|
|
1017
|
+
if (l.enableHandwriting) {
|
|
1018
|
+
if (h.value === "hand") {
|
|
1019
|
+
h.value = _.value;
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
d(h.value) && (_.value = h.value, h.value = "hand");
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
function Y() {
|
|
1026
|
+
Q(), z.value?.blur();
|
|
1027
|
+
}
|
|
1028
|
+
function X() {
|
|
1029
|
+
x.value = !0, h.value = "symbol";
|
|
1030
|
+
}
|
|
1031
|
+
function ae(e) {
|
|
1032
|
+
P.value = !1, e ? (j.value = e, e.focus()) : R.value && L(R.value) && (j.value = R.value), g.value = !1, N.value = !0, U();
|
|
1033
|
+
}
|
|
1034
|
+
function Q() {
|
|
1035
|
+
g.value = !0, N.value = !1;
|
|
1036
|
+
}
|
|
1037
|
+
function oe() {
|
|
1038
|
+
Q(), j.value = null, w.value = null, S.value = [], C.value = !1, P.value = !0;
|
|
1039
|
+
}
|
|
1040
|
+
return D(() => l.manual, (e) => {
|
|
1041
|
+
if (!e) {
|
|
1042
|
+
N.value = !0, j.value = null, P.value = !1;
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
N.value = !1, j.value = null;
|
|
1046
|
+
}), s({
|
|
1047
|
+
open: ae,
|
|
1048
|
+
close: Q,
|
|
1049
|
+
destroy: oe
|
|
1050
|
+
}), (t, s) => k((y(), i("div", {
|
|
1051
|
+
ref_key: "keyboardRef",
|
|
1052
|
+
ref: E,
|
|
1053
|
+
class: p(["tdhk", {
|
|
1054
|
+
"tdhk--floating": o.position === "float",
|
|
1055
|
+
"tdhk--bottom": o.position === "bottom",
|
|
1056
|
+
"tdhk--disabled": H.value
|
|
1057
|
+
}]),
|
|
1058
|
+
style: m({
|
|
1059
|
+
"--keyboard-height": `${T(V)}px`,
|
|
1060
|
+
...w.value
|
|
1061
|
+
}),
|
|
1062
|
+
onMousedown: s[2] ||= A(() => {}, ["prevent"])
|
|
1063
|
+
}, [H.value || !B.value || !T(V) ? (y(), i("div", Ct, s[3] ||= [a("span", null, "请选择输入框以启用键盘", -1)])) : (y(), i(e, { key: 1 }, [h.value === "hand" ? (y(), n(Ne, {
|
|
1064
|
+
key: 0,
|
|
1065
|
+
"recognizer-initialized": T(F),
|
|
1066
|
+
"recognizer-progress": T(I),
|
|
1067
|
+
onKey: G,
|
|
1068
|
+
onExit: q,
|
|
1069
|
+
onToggleKeyboard: J,
|
|
1070
|
+
onSwitchToSymbol: X,
|
|
1071
|
+
onCollapse: Y,
|
|
1072
|
+
onRecognize: ie
|
|
1073
|
+
}, null, 8, ["recognizer-initialized", "recognizer-progress"])) : h.value === "num" ? (y(), n(st, {
|
|
1074
|
+
key: 1,
|
|
1075
|
+
"keyboard-rows": o.numKeys,
|
|
1076
|
+
onKey: G,
|
|
1077
|
+
onExit: q
|
|
1078
|
+
}, null, 8, ["keyboard-rows"])) : h.value === "symbol" ? (y(), n(St, {
|
|
1079
|
+
key: 2,
|
|
1080
|
+
onKey: G,
|
|
1081
|
+
onExit: q
|
|
1082
|
+
})) : h.value === "en" || h.value === "en_cap" || h.value === "zh" ? (y(), n(Xe, {
|
|
1083
|
+
key: 3,
|
|
1084
|
+
modelValue: h.value,
|
|
1085
|
+
"onUpdate:modelValue": s[0] ||= (e) => h.value = e,
|
|
1086
|
+
"caps-return-to-chinese": v.value,
|
|
1087
|
+
"onUpdate:capsReturnToChinese": s[1] ||= (e) => v.value = e,
|
|
1088
|
+
"enable-handwriting": o.enableHandwriting,
|
|
1089
|
+
onKey: G,
|
|
1090
|
+
onToggleKeyboard: J,
|
|
1091
|
+
onCollapse: Y
|
|
1092
|
+
}, null, 8, [
|
|
1093
|
+
"modelValue",
|
|
1094
|
+
"caps-return-to-chinese",
|
|
1095
|
+
"enable-handwriting"
|
|
1096
|
+
])) : r("", !0)], 64))], 38)), [[ee, B.value]]);
|
|
1097
|
+
}
|
|
1098
|
+
}), Tt = { install: (e) => {
|
|
1099
|
+
e.component("TdhKeyboard", wt);
|
|
1100
|
+
} };
|
|
1101
|
+
//#endregion
|
|
1102
|
+
export { wt as TdhKeyboard, Tt as default };
|
|
1103
|
+
|
|
1104
|
+
//# sourceMappingURL=tdh-keyboard-vue.js.map
|