@tdh-keyboard/core 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 ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 dusionlike
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/dist/index.cjs ADDED
@@ -0,0 +1,397 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/canvas.ts
3
+ var CanvasDrawer = class {
4
+ canvas;
5
+ ctx;
6
+ lastX = 0;
7
+ lastY = 0;
8
+ strokeData = [];
9
+ clearTimerId = null;
10
+ isDrawing = false;
11
+ options;
12
+ constructor(canvas, options = {}) {
13
+ this.canvas = canvas;
14
+ this.options = {
15
+ clearDelay: 1e3,
16
+ ...options
17
+ };
18
+ const context = this.canvas.getContext("2d");
19
+ if (!context) throw new Error("Failed to get 2D rendering context");
20
+ this.ctx = context;
21
+ this.setupCanvas();
22
+ this.attachEvents();
23
+ }
24
+ setupCanvas() {
25
+ this.ctx.lineJoin = "round";
26
+ this.ctx.lineCap = "round";
27
+ this.ctx.lineWidth = 3;
28
+ this.ctx.strokeStyle = "#000";
29
+ this.clearCanvas();
30
+ this.drawGrid();
31
+ }
32
+ drawGrid() {
33
+ const width = this.canvas.width;
34
+ const height = this.canvas.height;
35
+ this.ctx.save();
36
+ this.ctx.strokeStyle = "#ddd";
37
+ this.ctx.lineWidth = 1;
38
+ this.ctx.setLineDash([3, 3]);
39
+ this.ctx.beginPath();
40
+ this.ctx.moveTo(0, height / 2);
41
+ this.ctx.lineTo(width, height / 2);
42
+ this.ctx.moveTo(width / 2, 0);
43
+ this.ctx.lineTo(width / 2, height);
44
+ this.ctx.stroke();
45
+ this.ctx.setLineDash([]);
46
+ this.ctx.beginPath();
47
+ this.ctx.rect(0, 0, width, height);
48
+ this.ctx.stroke();
49
+ this.ctx.restore();
50
+ }
51
+ clearCanvas() {
52
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
53
+ this.drawGrid();
54
+ this.strokeData = [];
55
+ this.resetClearTimer();
56
+ }
57
+ startDrawing(offsetX, offsetY) {
58
+ this.lastX = offsetX;
59
+ this.lastY = offsetY;
60
+ this.ctx.strokeStyle = "#000";
61
+ this.ctx.lineWidth = 3;
62
+ this.ctx.setLineDash([]);
63
+ this.strokeData.push(offsetX, offsetY, 0);
64
+ }
65
+ draw(offsetX, offsetY) {
66
+ this.ctx.beginPath();
67
+ this.ctx.moveTo(this.lastX, this.lastY);
68
+ this.ctx.lineTo(offsetX, offsetY);
69
+ this.ctx.stroke();
70
+ this.lastX = offsetX;
71
+ this.lastY = offsetY;
72
+ this.strokeData.push(offsetX, offsetY, 0);
73
+ }
74
+ endStroke() {
75
+ if (this.strokeData.length >= 3) this.strokeData[this.strokeData.length - 1] = 1;
76
+ }
77
+ getStrokeData() {
78
+ return this.strokeData;
79
+ }
80
+ resetClearTimer() {
81
+ if (this.clearTimerId) {
82
+ window.clearTimeout(this.clearTimerId);
83
+ this.clearTimerId = null;
84
+ }
85
+ }
86
+ startClearTimer() {
87
+ this.resetClearTimer();
88
+ this.clearTimerId = window.setTimeout(() => {
89
+ this.clearCanvas();
90
+ this.clearTimerId = null;
91
+ }, this.options.clearDelay);
92
+ }
93
+ getEventCoordinates(e) {
94
+ if (e instanceof MouseEvent) return {
95
+ offsetX: e.offsetX,
96
+ offsetY: e.offsetY
97
+ };
98
+ else {
99
+ const touch = e.touches[0] || e.changedTouches[0];
100
+ const rect = e.target.getBoundingClientRect();
101
+ return {
102
+ offsetX: touch.clientX - rect.left,
103
+ offsetY: touch.clientY - rect.top
104
+ };
105
+ }
106
+ }
107
+ handleStart = (e) => {
108
+ e.preventDefault();
109
+ this.isDrawing = true;
110
+ const { offsetX, offsetY } = this.getEventCoordinates(e);
111
+ this.startDrawing(offsetX, offsetY);
112
+ this.resetClearTimer();
113
+ };
114
+ handleMove = (e) => {
115
+ if (!this.isDrawing) return;
116
+ e.preventDefault();
117
+ const { offsetX, offsetY } = this.getEventCoordinates(e);
118
+ this.draw(offsetX, offsetY);
119
+ this.resetClearTimer();
120
+ };
121
+ handleEnd = (e) => {
122
+ if (!this.isDrawing) return;
123
+ e.preventDefault();
124
+ this.isDrawing = false;
125
+ this.endStroke();
126
+ this.startClearTimer();
127
+ if (this.options.onDrawEnd) this.options.onDrawEnd();
128
+ };
129
+ attachEvents() {
130
+ this.canvas.addEventListener("mousedown", this.handleStart);
131
+ this.canvas.addEventListener("mousemove", this.handleMove);
132
+ this.canvas.addEventListener("mouseup", this.handleEnd);
133
+ this.canvas.addEventListener("mouseleave", this.handleEnd);
134
+ this.canvas.addEventListener("touchstart", this.handleStart, { passive: false });
135
+ this.canvas.addEventListener("touchmove", this.handleMove, { passive: false });
136
+ this.canvas.addEventListener("touchend", this.handleEnd);
137
+ this.canvas.addEventListener("touchcancel", this.handleEnd);
138
+ }
139
+ detachEvents() {
140
+ this.canvas.removeEventListener("mousedown", this.handleStart);
141
+ this.canvas.removeEventListener("mousemove", this.handleMove);
142
+ this.canvas.removeEventListener("mouseup", this.handleEnd);
143
+ this.canvas.removeEventListener("mouseleave", this.handleEnd);
144
+ this.canvas.removeEventListener("touchstart", this.handleStart);
145
+ this.canvas.removeEventListener("touchmove", this.handleMove);
146
+ this.canvas.removeEventListener("touchend", this.handleEnd);
147
+ this.canvas.removeEventListener("touchcancel", this.handleEnd);
148
+ }
149
+ destroy() {
150
+ this.detachEvents();
151
+ this.resetClearTimer();
152
+ }
153
+ getCanvas() {
154
+ return this.canvas;
155
+ }
156
+ getContext() {
157
+ return this.ctx;
158
+ }
159
+ };
160
+ //#endregion
161
+ //#region src/config.ts
162
+ let globalConfig = {
163
+ defaultMode: "en",
164
+ enableHandwriting: false,
165
+ position: "static",
166
+ disableWhenNoFocus: true,
167
+ manual: false
168
+ };
169
+ let handwritingRecognizerInstance = null;
170
+ let pinyinEngineInstance = null;
171
+ /**
172
+ * 获取全局键盘配置
173
+ */
174
+ function getKeyboardConfig() {
175
+ return globalConfig;
176
+ }
177
+ /**
178
+ * 设置全局键盘配置
179
+ */
180
+ function setKeyboardConfig(config) {
181
+ globalConfig = {
182
+ ...globalConfig,
183
+ ...config
184
+ };
185
+ }
186
+ /**
187
+ * 注册手写识别服务
188
+ * @param recognizer 手写识别服务实现
189
+ */
190
+ function registerHandwritingRecognizer(recognizer) {
191
+ handwritingRecognizerInstance = recognizer;
192
+ }
193
+ /**
194
+ * 获取手写识别服务实例
195
+ * @returns 手写识别服务实例
196
+ */
197
+ function getHandwritingRecognizer() {
198
+ return handwritingRecognizerInstance;
199
+ }
200
+ /**
201
+ * 注册拼音引擎。
202
+ * 注册后,CandidateBar 将使用此引擎而非默认的 RIME 引擎。
203
+ * 适用于自定义引擎或 Worker 中运行的引擎。
204
+ * @param engine 拼音引擎实现
205
+ */
206
+ function registerPinyinEngine(engine) {
207
+ pinyinEngineInstance = engine;
208
+ }
209
+ /**
210
+ * 获取已注册的拼音引擎实例
211
+ * @returns 拼音引擎实例,未注册时返回 null
212
+ */
213
+ function getPinyinEngine() {
214
+ return pinyinEngineInstance;
215
+ }
216
+ //#endregion
217
+ //#region src/dom.ts
218
+ /**
219
+ * 计算键盘的显示位置
220
+ * @param inputElement 输入框元素
221
+ * @param keyboardElement 键盘元素
222
+ * @param positionMode 位置模式:'static'(静态,不计算位置)、'float'(浮动,根据输入框位置计算)、'bottom'(固定在底部)
223
+ * @returns 返回键盘的 top 和 left 位置,如果不需要计算则返回 null
224
+ */
225
+ function calculateKeyboardPosition(inputElement, keyboardElement, positionMode, floatMarginTop = 0) {
226
+ if (!keyboardElement || positionMode === "static") return null;
227
+ let top, left;
228
+ if (positionMode === "bottom") {
229
+ top = window.innerHeight - keyboardElement.offsetHeight;
230
+ left = 0;
231
+ } else {
232
+ if (!inputElement) return null;
233
+ const inputRect = inputElement.getBoundingClientRect();
234
+ const keyboardWidth = keyboardElement.offsetWidth;
235
+ top = inputRect.bottom + window.scrollY + floatMarginTop;
236
+ left = inputRect.left + window.scrollX + inputRect.width / 2 - keyboardWidth / 2;
237
+ const viewportWidth = window.innerWidth;
238
+ if (left + keyboardWidth > viewportWidth) left = viewportWidth - keyboardWidth - 10;
239
+ if (left < 10) left = 10;
240
+ }
241
+ return {
242
+ top: `${top}px`,
243
+ left: `${left}px`
244
+ };
245
+ }
246
+ //#endregion
247
+ //#region src/input.ts
248
+ /**
249
+ * 判断元素是否为可输入元素(支持文本输入的 input 或 textarea)
250
+ * @param el 要检测的元素
251
+ * @returns 如果是可输入元素则返回 true
252
+ */
253
+ function isInputElement(el) {
254
+ if (!el) return false;
255
+ if (el.tagName === "TEXTAREA") return true;
256
+ if (el.tagName === "INPUT") {
257
+ const inputType = (el.type || "text").toLowerCase();
258
+ return ![
259
+ "checkbox",
260
+ "radio",
261
+ "button",
262
+ "submit",
263
+ "reset",
264
+ "file",
265
+ "image",
266
+ "range",
267
+ "color",
268
+ "hidden",
269
+ "date",
270
+ "datetime-local",
271
+ "month",
272
+ "week",
273
+ "time"
274
+ ].includes(inputType);
275
+ }
276
+ return false;
277
+ }
278
+ /**
279
+ * 获取当前激活的输入元素
280
+ * @throws {Error} 如果当前没有激活的输入框
281
+ */
282
+ function getInputElement() {
283
+ if (document.activeElement && isInputElement(document.activeElement)) return document.activeElement;
284
+ else throw new Error("输入框没有被激活");
285
+ }
286
+ /**
287
+ * 更新输入框值并设置光标,触发 input 事件
288
+ */
289
+ function applyEdit(inputElement, value, cursor) {
290
+ inputElement.value = value;
291
+ moveCursor(inputElement, cursor);
292
+ inputElement.dispatchEvent(new Event("input", { bubbles: true }));
293
+ }
294
+ /**
295
+ * 通用字符串编辑:从 start 位置删除 deleteCount 个字符,并插入 insertText
296
+ */
297
+ function editString(text, start, deleteCount, insertText = "") {
298
+ return text.slice(0, start) + insertText + text.slice(start + deleteCount);
299
+ }
300
+ /**
301
+ * 通用输入框编辑:插入文本或删除字符
302
+ */
303
+ function processInputElement(inputElement, insertText = "") {
304
+ const maxlength = Number(inputElement.getAttribute("maxlength"));
305
+ let start = inputElement.selectionStart ?? 0;
306
+ const end = inputElement.selectionEnd ?? start;
307
+ let deleteCount;
308
+ if (insertText.length > 0) deleteCount = end - start;
309
+ else {
310
+ const selLen = end - start;
311
+ if (selLen > 0) deleteCount = selLen;
312
+ else if (start > 0) {
313
+ deleteCount = 1;
314
+ start--;
315
+ } else return;
316
+ }
317
+ if (insertText.length > 0 && maxlength && inputElement.value.length - deleteCount + insertText.length > maxlength) return;
318
+ applyEdit(inputElement, editString(inputElement.value, start, deleteCount, insertText), start + insertText.length);
319
+ }
320
+ /**
321
+ * 向输入框插入文本
322
+ * @param inputElement 输入框元素
323
+ * @param text 要插入的文本
324
+ */
325
+ function writeToInputElement(inputElement, text) {
326
+ processInputElement(inputElement, text);
327
+ }
328
+ /**
329
+ * 向输入框删除文本
330
+ * @param inputElement 输入框元素
331
+ */
332
+ function delToInputElement(inputElement) {
333
+ processInputElement(inputElement);
334
+ }
335
+ /**
336
+ * 设置输入框光标位置
337
+ * @param inputElement 输入框元素
338
+ * @param index 光标位置索引
339
+ */
340
+ function moveCursor(inputElement, index) {
341
+ inputElement.selectionStart = index;
342
+ inputElement.selectionEnd = index;
343
+ }
344
+ //#endregion
345
+ //#region src/repeat.ts
346
+ /**
347
+ * Create a small, framework-agnostic key repeater for long-press.
348
+ *
349
+ * - Calls `action()` immediately on start.
350
+ * - After `delay`, repeats with `interval` until `stop()` is called.
351
+ */
352
+ function createKeyRepeater(options = {}) {
353
+ const delay = options.delay ?? 400;
354
+ const interval = options.interval ?? 60;
355
+ let delayTimer;
356
+ let intervalTimer;
357
+ function stop() {
358
+ if (delayTimer) {
359
+ clearTimeout(delayTimer);
360
+ delayTimer = void 0;
361
+ }
362
+ if (intervalTimer) {
363
+ clearInterval(intervalTimer);
364
+ intervalTimer = void 0;
365
+ }
366
+ }
367
+ function start(action) {
368
+ stop();
369
+ action();
370
+ delayTimer = setTimeout(() => {
371
+ intervalTimer = setInterval(() => {
372
+ action();
373
+ }, interval);
374
+ }, delay);
375
+ }
376
+ return {
377
+ start,
378
+ stop
379
+ };
380
+ }
381
+ //#endregion
382
+ exports.CanvasDrawer = CanvasDrawer;
383
+ exports.calculateKeyboardPosition = calculateKeyboardPosition;
384
+ exports.createKeyRepeater = createKeyRepeater;
385
+ exports.delToInputElement = delToInputElement;
386
+ exports.getHandwritingRecognizer = getHandwritingRecognizer;
387
+ exports.getInputElement = getInputElement;
388
+ exports.getKeyboardConfig = getKeyboardConfig;
389
+ exports.getPinyinEngine = getPinyinEngine;
390
+ exports.isInputElement = isInputElement;
391
+ exports.moveCursor = moveCursor;
392
+ exports.registerHandwritingRecognizer = registerHandwritingRecognizer;
393
+ exports.registerPinyinEngine = registerPinyinEngine;
394
+ exports.setKeyboardConfig = setKeyboardConfig;
395
+ exports.writeToInputElement = writeToInputElement;
396
+
397
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/canvas.ts","../src/config.ts","../src/dom.ts","../src/input.ts","../src/repeat.ts"],"sourcesContent":["export interface CanvasDrawerOptions {\n onDrawEnd?: () => void\n clearDelay?: number\n}\n\nexport class CanvasDrawer {\n private canvas: HTMLCanvasElement\n private ctx: CanvasRenderingContext2D\n private lastX: number = 0\n private lastY: number = 0\n private strokeData: number[] = []\n private clearTimerId: number | null = null\n private isDrawing: boolean = false\n private options: CanvasDrawerOptions\n\n constructor(canvas: HTMLCanvasElement, options: CanvasDrawerOptions = {}) {\n this.canvas = canvas\n this.options = { clearDelay: 1000, ...options } // Default clearDelay is 1000ms\n const context = this.canvas.getContext('2d')\n if (!context) {\n throw new Error('Failed to get 2D rendering context')\n }\n this.ctx = context\n this.setupCanvas()\n this.attachEvents()\n }\n\n private setupCanvas(): void {\n this.ctx.lineJoin = 'round'\n this.ctx.lineCap = 'round'\n this.ctx.lineWidth = 3\n this.ctx.strokeStyle = '#000'\n this.clearCanvas()\n this.drawGrid()\n }\n\n drawGrid(): void {\n const width = this.canvas.width\n const height = this.canvas.height\n\n this.ctx.save()\n this.ctx.strokeStyle = '#ddd'\n this.ctx.lineWidth = 1\n this.ctx.setLineDash([3, 3])\n\n this.ctx.beginPath()\n this.ctx.moveTo(0, height / 2)\n this.ctx.lineTo(width, height / 2)\n this.ctx.moveTo(width / 2, 0)\n this.ctx.lineTo(width / 2, height)\n this.ctx.stroke()\n\n // 外边框用实线\n this.ctx.setLineDash([])\n this.ctx.beginPath()\n this.ctx.rect(0, 0, width, height)\n this.ctx.stroke()\n\n this.ctx.restore()\n }\n\n clearCanvas(): void {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n this.drawGrid()\n this.strokeData = [] // 清除笔迹数据\n this.resetClearTimer() // 清除画布时也重置计时器\n }\n\n startDrawing(offsetX: number, offsetY: number): void {\n this.lastX = offsetX\n this.lastY = offsetY\n // Restore drawing style for actual strokes\n this.ctx.strokeStyle = '#000'\n this.ctx.lineWidth = 3\n this.ctx.setLineDash([]) // Solid line\n\n // 记录起始点,0表示不是笔画的最后一点\n this.strokeData.push(offsetX, offsetY, 0)\n }\n\n draw(offsetX: number, offsetY: number): void {\n this.ctx.beginPath()\n this.ctx.moveTo(this.lastX, this.lastY)\n this.ctx.lineTo(offsetX, offsetY)\n this.ctx.stroke()\n this.lastX = offsetX\n this.lastY = offsetY\n\n // 记录绘制点,0表示不是笔画的最后一点\n this.strokeData.push(offsetX, offsetY, 0)\n }\n\n endStroke(): void {\n // 标记笔画的最后一点,将最后一组坐标的c设为1\n if (this.strokeData.length >= 3) {\n this.strokeData[this.strokeData.length - 1] = 1\n }\n }\n\n getStrokeData(): ReadonlyArray<number> {\n return this.strokeData\n }\n\n resetClearTimer(): void {\n if (this.clearTimerId) {\n window.clearTimeout(this.clearTimerId)\n this.clearTimerId = null\n }\n }\n\n startClearTimer(): void {\n this.resetClearTimer()\n this.clearTimerId = window.setTimeout(() => {\n this.clearCanvas()\n this.clearTimerId = null\n }, this.options.clearDelay)\n }\n\n private getEventCoordinates(e: MouseEvent | TouchEvent): { offsetX: number, offsetY: number } {\n if (e instanceof MouseEvent) {\n return { offsetX: e.offsetX, offsetY: e.offsetY }\n } else {\n const touch = (e as TouchEvent).touches[0] || (e as TouchEvent).changedTouches[0]\n const rect = (e.target as HTMLElement).getBoundingClientRect()\n return {\n offsetX: touch.clientX - rect.left,\n offsetY: touch.clientY - rect.top,\n }\n }\n }\n\n private handleStart = (e: MouseEvent | TouchEvent) => {\n e.preventDefault()\n this.isDrawing = true\n const { offsetX, offsetY } = this.getEventCoordinates(e)\n this.startDrawing(offsetX, offsetY)\n this.resetClearTimer()\n }\n\n private handleMove = (e: MouseEvent | TouchEvent) => {\n if (!this.isDrawing)\n return\n e.preventDefault()\n const { offsetX, offsetY } = this.getEventCoordinates(e)\n this.draw(offsetX, offsetY)\n this.resetClearTimer()\n }\n\n private handleEnd = (e: MouseEvent | TouchEvent) => {\n if (!this.isDrawing)\n return\n e.preventDefault()\n this.isDrawing = false\n this.endStroke()\n this.startClearTimer()\n if (this.options.onDrawEnd) {\n this.options.onDrawEnd()\n }\n }\n\n private attachEvents(): void {\n this.canvas.addEventListener('mousedown', this.handleStart)\n this.canvas.addEventListener('mousemove', this.handleMove)\n this.canvas.addEventListener('mouseup', this.handleEnd)\n this.canvas.addEventListener('mouseleave', this.handleEnd)\n\n this.canvas.addEventListener('touchstart', this.handleStart, { passive: false })\n this.canvas.addEventListener('touchmove', this.handleMove, { passive: false })\n this.canvas.addEventListener('touchend', this.handleEnd)\n this.canvas.addEventListener('touchcancel', this.handleEnd)\n }\n\n private detachEvents(): void {\n this.canvas.removeEventListener('mousedown', this.handleStart)\n this.canvas.removeEventListener('mousemove', this.handleMove)\n this.canvas.removeEventListener('mouseup', this.handleEnd)\n this.canvas.removeEventListener('mouseleave', this.handleEnd)\n\n this.canvas.removeEventListener('touchstart', this.handleStart)\n this.canvas.removeEventListener('touchmove', this.handleMove)\n this.canvas.removeEventListener('touchend', this.handleEnd)\n this.canvas.removeEventListener('touchcancel', this.handleEnd)\n }\n\n destroy(): void {\n this.detachEvents()\n this.resetClearTimer()\n }\n\n getCanvas(): HTMLCanvasElement {\n return this.canvas\n }\n\n getContext(): CanvasRenderingContext2D {\n return this.ctx\n }\n}\n","import type { HandwritingRecognizer } from './handwriting'\nimport type { PinyinEngine } from './pinyin-engine'\n\n/**\n * 键盘配置类型\n */\nexport interface KeyboardConfig {\n /**\n * 默认的键盘模式\n */\n defaultMode?: 'en' | 'zh' | 'hand' | 'num' | 'symbol'\n /**\n * 是否启用手写输入\n */\n enableHandwriting?: boolean\n /**\n * 键盘定位模式\n */\n position?: 'static' | 'float' | 'bottom'\n /**\n * 浮动模式下键盘与输入框的距离\n * @default 10\n */\n floatMarginTop?: number\n /**\n * 当没有input获得焦点时是否禁用键盘\n */\n disableWhenNoFocus?: boolean\n /**\n * 是否启用手动打开模式\n * 启用后不再根据焦点自动显示,需要通过实例方法手动调用 open / close / destroy。\n */\n manual?: boolean\n /**\n * 数字键盘的行配置\n */\n numKeys?: string[][]\n /**\n * RIME WASM 文件及数据文件的 URL 或路径前缀。\n * 用于默认 RIME 引擎加载(当未通过 registerPinyinEngine 注册自定义引擎时)。\n * @default '/rime'\n */\n wasmDir?: string\n}\n\n// 全局配置对象\nlet globalConfig: KeyboardConfig = {\n defaultMode: 'en',\n enableHandwriting: false,\n position: 'static',\n disableWhenNoFocus: true,\n manual: false,\n}\n\n// 全局变量用于存储手写识别服务实例\nlet handwritingRecognizerInstance: HandwritingRecognizer | null = null\n\n// 全局变量用于存储拼音引擎实例\nlet pinyinEngineInstance: PinyinEngine | null = null\n\n/**\n * 获取全局键盘配置\n */\nexport function getKeyboardConfig(): KeyboardConfig {\n return globalConfig\n}\n\n/**\n * 设置全局键盘配置\n */\nexport function setKeyboardConfig(config: KeyboardConfig): void {\n globalConfig = {\n ...globalConfig,\n ...config,\n }\n}\n\n/**\n * 注册手写识别服务\n * @param recognizer 手写识别服务实现\n */\nexport function registerHandwritingRecognizer(recognizer: HandwritingRecognizer): void {\n handwritingRecognizerInstance = recognizer\n}\n\n/**\n * 获取手写识别服务实例\n * @returns 手写识别服务实例\n */\nexport function getHandwritingRecognizer(): HandwritingRecognizer | null {\n return handwritingRecognizerInstance\n}\n\n/**\n * 注册拼音引擎。\n * 注册后,CandidateBar 将使用此引擎而非默认的 RIME 引擎。\n * 适用于自定义引擎或 Worker 中运行的引擎。\n * @param engine 拼音引擎实现\n */\nexport function registerPinyinEngine(engine: PinyinEngine): void {\n pinyinEngineInstance = engine\n}\n\n/**\n * 获取已注册的拼音引擎实例\n * @returns 拼音引擎实例,未注册时返回 null\n */\nexport function getPinyinEngine(): PinyinEngine | null {\n return pinyinEngineInstance\n}\n","export interface KeyboardPosition {\n top: string\n left: string\n}\n\n/**\n * 计算键盘的显示位置\n * @param inputElement 输入框元素\n * @param keyboardElement 键盘元素\n * @param positionMode 位置模式:'static'(静态,不计算位置)、'float'(浮动,根据输入框位置计算)、'bottom'(固定在底部)\n * @returns 返回键盘的 top 和 left 位置,如果不需要计算则返回 null\n */\nexport function calculateKeyboardPosition(\n inputElement: HTMLElement | null,\n keyboardElement: HTMLElement | null,\n positionMode: 'static' | 'float' | 'bottom',\n floatMarginTop = 0, // 浮动模式下键盘与输入框的距离\n): KeyboardPosition | null {\n // static 模式不需要计算位置,键盘元素不存在时也无法计算\n if (!keyboardElement || positionMode === 'static') {\n return null\n }\n\n let top, left\n\n // 如果模式为 'bottom',键盘固定在窗口底部\n if (positionMode === 'bottom') {\n top = window.innerHeight - keyboardElement.offsetHeight // 键盘顶部位置为窗口高度减去键盘高度\n left = 0 // 键盘左侧位置为0\n } else {\n if (!inputElement) {\n return null\n }\n // positionMode === 'float',键盘位置根据输入框浮动\n const inputRect = inputElement.getBoundingClientRect() // 获取输入框的位置和尺寸信息\n const keyboardWidth = keyboardElement.offsetWidth // 获取键盘的宽度\n\n // 初始计算:键盘顶部在输入框底部,水平居中对齐输入框中心\n top = inputRect.bottom + window.scrollY + floatMarginTop // 键盘顶部在输入框底部,并考虑页面滚动\n left = inputRect.left + window.scrollX + inputRect.width / 2 - keyboardWidth / 2 // 键盘左侧在输入框中心减去键盘宽度的一半,并考虑页面滚动\n\n const viewportWidth = window.innerWidth // 获取视口宽度\n // 如果键盘右侧超出视口,则将键盘左侧位置调整到视口内,并留出10px边距\n if (left + keyboardWidth > viewportWidth) {\n left = viewportWidth - keyboardWidth - 10\n }\n // 如果键盘左侧超出视口(或过于靠左),则将键盘左侧位置调整到视口内,并留出10px边距\n if (left < 10) {\n left = 10\n }\n }\n return { top: `${top}px`, left: `${left}px` }\n}\n","export type TextInputElement = HTMLInputElement | HTMLTextAreaElement\n\n/**\n * 判断元素是否为可输入元素(支持文本输入的 input 或 textarea)\n * @param el 要检测的元素\n * @returns 如果是可输入元素则返回 true\n */\nexport function isInputElement(el?: Element | null): el is TextInputElement {\n if (!el) {\n return false\n }\n if (el.tagName === 'TEXTAREA') {\n return true\n }\n\n if (el.tagName === 'INPUT') {\n // 获取输入框类型\n const inputElement = el as HTMLInputElement\n const inputType = (inputElement.type || 'text').toLowerCase()\n\n // 这些类型的input不支持文本输入\n const nonTextInputTypes = [\n 'checkbox',\n 'radio',\n 'button',\n 'submit',\n 'reset',\n 'file',\n 'image',\n 'range',\n 'color',\n 'hidden',\n 'date',\n 'datetime-local',\n 'month',\n 'week',\n 'time',\n ]\n\n return !nonTextInputTypes.includes(inputType)\n }\n\n // 不是 input 或 textarea\n return false\n}\n\n/**\n * 获取当前激活的输入元素\n * @throws {Error} 如果当前没有激活的输入框\n */\nexport function getInputElement() {\n if (document.activeElement && isInputElement(document.activeElement)) {\n return document.activeElement\n } else {\n throw new Error('输入框没有被激活')\n }\n}\n\n/**\n * 更新输入框值并设置光标,触发 input 事件\n */\nfunction applyEdit(inputElement: TextInputElement, value: string, cursor: number) {\n inputElement.value = value\n moveCursor(inputElement, cursor)\n inputElement.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\n/**\n * 通用字符串编辑:从 start 位置删除 deleteCount 个字符,并插入 insertText\n */\nfunction editString(text: string, start: number, deleteCount: number, insertText = ''): string {\n return text.slice(0, start) + insertText + text.slice(start + deleteCount)\n}\n\n/**\n * 通用输入框编辑:插入文本或删除字符\n */\nfunction processInputElement(\n inputElement: TextInputElement,\n insertText = '',\n) {\n const maxlength = Number(inputElement.getAttribute('maxlength'))\n let start = inputElement.selectionStart ?? 0\n const end = inputElement.selectionEnd ?? start\n let deleteCount: number\n if (insertText.length > 0) {\n // 插入或替换选区\n deleteCount = end - start\n } else {\n // 删除操作:优先删除选区,否则退格删除\n const selLen = end - start\n if (selLen > 0) {\n deleteCount = selLen\n } else if (start > 0) {\n deleteCount = 1\n start--\n } else {\n return\n }\n }\n // 插入时检查 maxlength\n if (\n insertText.length > 0\n && maxlength\n && inputElement.value.length - deleteCount + insertText.length > maxlength\n ) {\n return\n }\n const newValue = editString(inputElement.value, start, deleteCount, insertText)\n const newCursor = start + insertText.length\n applyEdit(inputElement, newValue, newCursor)\n}\n\n/**\n * 向输入框插入文本\n * @param inputElement 输入框元素\n * @param text 要插入的文本\n */\nexport function writeToInputElement(inputElement: TextInputElement, text: string) {\n processInputElement(inputElement, text)\n}\n\n/**\n * 向输入框删除文本\n * @param inputElement 输入框元素\n */\nexport function delToInputElement(inputElement: TextInputElement) {\n processInputElement(inputElement)\n}\n\n/**\n * 设置输入框光标位置\n * @param inputElement 输入框元素\n * @param index 光标位置索引\n */\nexport function moveCursor(inputElement: TextInputElement, index: number) {\n inputElement.selectionStart = index\n inputElement.selectionEnd = index\n}\n","export interface KeyRepeatOptions {\n /** Long-press delay before repeating starts (ms). */\n delay?: number\n /** Repeat interval after the initial delay (ms). */\n interval?: number\n}\n\nexport interface KeyRepeater {\n start: (action: () => void) => void\n stop: () => void\n}\n\n/**\n * Create a small, framework-agnostic key repeater for long-press.\n *\n * - Calls `action()` immediately on start.\n * - After `delay`, repeats with `interval` until `stop()` is called.\n */\nexport function createKeyRepeater(options: KeyRepeatOptions = {}): KeyRepeater {\n const delay = options.delay ?? 400\n const interval = options.interval ?? 60\n\n let delayTimer: ReturnType<typeof setTimeout> | undefined\n let intervalTimer: ReturnType<typeof setInterval> | undefined\n\n function stop() {\n if (delayTimer) {\n clearTimeout(delayTimer)\n delayTimer = undefined\n }\n if (intervalTimer) {\n clearInterval(intervalTimer)\n intervalTimer = undefined\n }\n }\n\n function start(action: () => void) {\n stop()\n\n action()\n\n delayTimer = setTimeout(() => {\n intervalTimer = setInterval(() => {\n action()\n }, interval)\n }, delay)\n }\n\n return { start, stop }\n}\n"],"mappings":";;AAKA,IAAa,eAAb,MAA0B;CACxB;CACA;CACA,QAAwB;CACxB,QAAwB;CACxB,aAA+B,EAAE;CACjC,eAAsC;CACtC,YAA6B;CAC7B;CAEA,YAAY,QAA2B,UAA+B,EAAE,EAAE;AACxE,OAAK,SAAS;AACd,OAAK,UAAU;GAAE,YAAY;GAAM,GAAG;GAAS;EAC/C,MAAM,UAAU,KAAK,OAAO,WAAW,KAAK;AAC5C,MAAI,CAAC,QACH,OAAM,IAAI,MAAM,qCAAqC;AAEvD,OAAK,MAAM;AACX,OAAK,aAAa;AAClB,OAAK,cAAc;;CAGrB,cAA4B;AAC1B,OAAK,IAAI,WAAW;AACpB,OAAK,IAAI,UAAU;AACnB,OAAK,IAAI,YAAY;AACrB,OAAK,IAAI,cAAc;AACvB,OAAK,aAAa;AAClB,OAAK,UAAU;;CAGjB,WAAiB;EACf,MAAM,QAAQ,KAAK,OAAO;EAC1B,MAAM,SAAS,KAAK,OAAO;AAE3B,OAAK,IAAI,MAAM;AACf,OAAK,IAAI,cAAc;AACvB,OAAK,IAAI,YAAY;AACrB,OAAK,IAAI,YAAY,CAAC,GAAG,EAAE,CAAC;AAE5B,OAAK,IAAI,WAAW;AACpB,OAAK,IAAI,OAAO,GAAG,SAAS,EAAE;AAC9B,OAAK,IAAI,OAAO,OAAO,SAAS,EAAE;AAClC,OAAK,IAAI,OAAO,QAAQ,GAAG,EAAE;AAC7B,OAAK,IAAI,OAAO,QAAQ,GAAG,OAAO;AAClC,OAAK,IAAI,QAAQ;AAGjB,OAAK,IAAI,YAAY,EAAE,CAAC;AACxB,OAAK,IAAI,WAAW;AACpB,OAAK,IAAI,KAAK,GAAG,GAAG,OAAO,OAAO;AAClC,OAAK,IAAI,QAAQ;AAEjB,OAAK,IAAI,SAAS;;CAGpB,cAAoB;AAClB,OAAK,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