@aiquants/spreadsheet 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.js +658 -657
- package/package.json +4 -1
- package/src/keyboard/compositionGuard.ts +15 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/spreadsheet",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Excel-grade spreadsheet grid for React: multi-cell selection, TSV/HTML clipboard, in-place editing on top of @aiquants/virtualscroll",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
"CHANGELOG.md",
|
|
56
56
|
"LICENSE.md"
|
|
57
57
|
],
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@aiquants/input-method": "^0.1.0"
|
|
60
|
+
},
|
|
58
61
|
"peerDependencies": {
|
|
59
62
|
"@aiquants/virtualscroll": "^3.28.0",
|
|
60
63
|
"react": "^19.2.7",
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* for the "must this keydown be ignored?" question that the grid keymap and every popover
|
|
4
4
|
* keydown handler ask first. Two clauses, extracted verbatim from useGridKeyboard: (1) a
|
|
5
5
|
* keydown that arrives DURING composition (isComposing, or the legacy keyCode 229 that
|
|
6
|
-
* Chromium / Safari deliver for IME-processed keys) is never a
|
|
6
|
+
* Chromium / Safari deliver for IME-processed keys; `@aiquants/input-method`'s `isInputMethodKey`) is never a
|
|
7
|
+
* command; (2) Safari fires
|
|
7
8
|
* compositionend BEFORE the confirming Enter / Escape keydown, so those two keys are skipped
|
|
8
9
|
* inside a 50 ms window after the last compositionend. The window is deliberately limited to
|
|
9
10
|
* Enter / Escape — applying it to every key would eat the first post-confirmation keystroke on
|
|
@@ -12,12 +13,15 @@
|
|
|
12
13
|
* IME 変換中 keydown ガード (v0.8 §4.1.10) — グリッドキーマップと全ポップオーバーの keydown が
|
|
13
14
|
* 冒頭で問う「この keydown は無視すべきか」の単一真実源。useGridKeyboard から逐語抽出した 2 条:
|
|
14
15
|
* (1) 変換中の keydown (isComposing、または Chromium / Safari が IME 処理キーへ与えるレガシー
|
|
15
|
-
* keyCode 229) はコマンドではない、(2) Safari は確定 Enter / Escape の
|
|
16
|
+
* keyCode 229。`@aiquants/input-method` の `isInputMethodKey`) はコマンドではない、(2) Safari は確定 Enter / Escape の
|
|
17
|
+
* keydown より先に
|
|
16
18
|
* compositionend を発火するため、直近 compositionend から 50 ms 窓内の Enter / Escape をスキップ。
|
|
17
19
|
* 窓の対象を Enter / Escape に限定するのは必須 — 全キー対象にすると Chrome / Firefox で確定後の
|
|
18
20
|
* 1 打鍵を食う退行 (実測)。
|
|
19
21
|
*/
|
|
20
22
|
|
|
23
|
+
import { isInputMethodKey } from "@aiquants/input-method"
|
|
24
|
+
|
|
21
25
|
/** Safari compositionend→keydown skip window in ms. / Safari 順序差スキップ窓 (ms)。 */
|
|
22
26
|
export const COMPOSITION_SKIP_WINDOW_MS = 50
|
|
23
27
|
|
|
@@ -32,16 +36,18 @@ export const COMPOSITION_SKIP_WINDOW_MS = 50
|
|
|
32
36
|
export const COMPOSITION_CLEAR_MS = 100
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
|
-
* True when the keydown must be ignored: isComposing / keyCode 229
|
|
36
|
-
* COMPOSITION_SKIP_WINDOW_MS after the last compositionend (`compositionEndedAt` is that
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* True when the keydown must be ignored: isComposing / keyCode 229 (`@aiquants/input-method`'s `isInputMethodKey`), or
|
|
40
|
+
* Enter / Escape within COMPOSITION_SKIP_WINDOW_MS after the last compositionend (`compositionEndedAt` is that event's
|
|
41
|
+
* timeStamp, or null when no compositionend is pending). Pure — reads only the event. Throws `isInputMethodKey`'s
|
|
42
|
+
* TypeError for an event whose `isComposing` is not a boolean or whose `keyCode` is not a number.
|
|
43
|
+
* 無視すべき keydown なら true: isComposing / keyCode 229 (`@aiquants/input-method` の `isInputMethodKey`)、または直近
|
|
44
|
+
* compositionend (`compositionEndedAt` = その timeStamp、未保留なら null) から COMPOSITION_SKIP_WINDOW_MS 以内の
|
|
45
|
+
* Enter / Escape。純関数 — event しか読まない。`isComposing` が真偽値でない・`keyCode` が数でないイベントには
|
|
46
|
+
* `isInputMethodKey` の TypeError を投げる。
|
|
41
47
|
*/
|
|
42
48
|
export const isCompositionKeydown = (event: KeyboardEvent, compositionEndedAt: number | null): boolean => {
|
|
43
49
|
// 変換中の keydown と IME 処理キー (keyCode 229) は無条件に無視 (§6.6.2-1 の冒頭ガード)
|
|
44
|
-
if (event
|
|
50
|
+
if (isInputMethodKey(event)) {
|
|
45
51
|
return true
|
|
46
52
|
}
|
|
47
53
|
// Safari 順序差: compositionend 直後 (< 50ms) の Enter / Escape のみスキップ (対象限定必須 —
|