@kubohiroya/turbowarp-plus-editor-workbench 0.19.0 → 0.20.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/README.ja.md +2 -0
- package/README.md +2 -0
- package/dist/ime-key.d.ts +34 -0
- package/dist/ime-key.js +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sprite-tabs.js +12 -0
- package/dist/stage-input.js +3 -1
- package/package.json +7 -3
- package/src/ime-key.ts +77 -0
- package/src/index.ts +1 -0
- package/src/sprite-tabs.ts +11 -0
- package/src/stage-input.ts +4 -1
package/README.ja.md
CHANGED
|
@@ -144,6 +144,8 @@ Editor のルートから、`site/source.json` の GUI を `npm run build:pages`
|
|
|
144
144
|
|
|
145
145
|
`attachStageInput` は、ホストから渡された別ウィンドウの document とキャンバスを使って、入力の購読と解放を管理する。ポインター処理とドラッグ状態の解除はホストのコールバックを使用する。
|
|
146
146
|
|
|
147
|
+
日本語・中国語・韓国語の IME がオンのとき、ブラウザーは IME が受け取ったキーを `Process`(または IME が打つかな)と報告し、VM はこれを無視する。`attachStageInput` は `event.code` から元のキーを復元する。本体の document では、`@kubohiroya/turbowarp-plus-editor-workbench/ime-key` の `installImeKeyInput(document)` が capture 段階で `key` と `keyCode` を直し、ステージが読む前に同じ復元を行う。テキスト欄に向かうイベントは IME の報告のまま残す。
|
|
148
|
+
|
|
147
149
|
スプライト編集タブの中のペイン(素材と変数、メッセージ、設定フォーム、セクション切り替えのツールバー)は `@kubohiroya/turbowarp-plus-editor-sprite-panes` に移った。このパッケージはそれらをタブや分割に並べる。以前の配布アーカイブのソース `b0390c3` から移設したウィンドウ部品は、`@kubohiroya/turbowarp-plus-editor-windows` に移った。Scratch GUI の本家実装はこのパッケージに取り込んでいないため、GPL のコードを含まず、GPL のモジュールも import しない。ライセンスは MPL-2.0 とする。MPL-2.0 は GPL を二次ライセンスとして認めるので、GPL-3.0 の Editor に組み込んで配信できる。ソースに「Incompatible With Secondary Licenses」の表示は付けない。付けると Editor に組み込めなくなる。
|
|
148
150
|
|
|
149
151
|
## デバッガーのタブ
|
package/README.md
CHANGED
|
@@ -147,6 +147,8 @@ From the Editor root, build the GUI pinned in `site/source.json` with `npm run b
|
|
|
147
147
|
|
|
148
148
|
`attachStageInput` manages input subscriptions and cleanup using the separate window's document and canvas provided by the host. Pointer handling and drag cleanup use the host's callbacks.
|
|
149
149
|
|
|
150
|
+
With a Japanese, Chinese or Korean IME on, the browser reports the key the IME took as `Process` (or as the kana the IME would type), which the VM ignores. `attachStageInput` recovers the key from `event.code`, and `installImeKeyInput(document)` from `/turbowarp-plus-editor-workbench/ime-key` does the same for the main document by correcting `key` and `keyCode` in the capture phase, before the stage reads them. Events aimed at text fields keep what the IME reported.
|
|
151
|
+
|
|
150
152
|
The panes inside a sprite editing tab (assets and variables, messages, the properties form and the section toolbar) now live in `@kubohiroya/turbowarp-plus-editor-sprite-panes`; this package arranges them into tabs and splits. The window components, which came from the source of the previous release archive at `b0390c3`, now live in `@kubohiroya/turbowarp-plus-editor-windows`. The extraction kept the upstream Scratch GUI implementation in its original repository, so this package carries no GPL code and imports no GPL module. It is licensed MPL-2.0, which the GPL-3.0 Editor can still bundle because MPL-2.0 treats the GPL as a Secondary License. The source files carry no “Incompatible With Secondary Licenses” notice, and must not: that notice would make the package unusable in the Editor.
|
|
151
153
|
|
|
152
154
|
## Debugger tab
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys pressed while a Japanese, Chinese or Korean IME is on.
|
|
3
|
+
*
|
|
4
|
+
* The stage hands `event.key` to the VM. With an IME on, the browser reports a key that the IME
|
|
5
|
+
* takes as `Process` (keyCode 229), and in kana input mode some browsers report the kana it would
|
|
6
|
+
* type (`ち` for A). The VM drops `Process` and matches `ち` against no key, so "when [a] key
|
|
7
|
+
* pressed" and "key [space] pressed?" stay silent until the user turns the IME off. `event.code`
|
|
8
|
+
* still names the physical key, so the key the VM expects can be recovered from it.
|
|
9
|
+
*/
|
|
10
|
+
export type ScratchKey = {
|
|
11
|
+
key: string;
|
|
12
|
+
keyCode: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The key and keyCode of a physical key, for the keys Scratch has a name for.
|
|
16
|
+
* @param {string} code The event's `code`.
|
|
17
|
+
* @param {boolean} shiftKey Whether Shift was held, which makes a letter upper case.
|
|
18
|
+
* @returns {ScratchKey | null} The key, or null for a key Scratch has no name for.
|
|
19
|
+
*/
|
|
20
|
+
export declare const keyFromCode: (code: string, shiftKey?: boolean) => ScratchKey | null;
|
|
21
|
+
/**
|
|
22
|
+
* The key an event would have reported with the IME off, when the IME changed it.
|
|
23
|
+
* @param {KeyboardEvent} event The key event.
|
|
24
|
+
* @returns {ScratchKey | null} The recovered key, or null when the event needs no change.
|
|
25
|
+
*/
|
|
26
|
+
export declare const imeScratchKey: (event: Pick<KeyboardEvent, "key" | "code" | "keyCode" | "shiftKey">) => ScratchKey | null;
|
|
27
|
+
/**
|
|
28
|
+
* Correct key events that reach the document itself, before the stage's own listeners read them.
|
|
29
|
+
* Events aimed at a text field or a block's field editor are left alone, so typing with the IME
|
|
30
|
+
* still works there.
|
|
31
|
+
* @param {Document} document The document whose stage takes key input.
|
|
32
|
+
* @returns {() => void} A function that removes the correction.
|
|
33
|
+
*/
|
|
34
|
+
export declare function installImeKeyInput(document: Document): () => void;
|
package/dist/ime-key.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys pressed while a Japanese, Chinese or Korean IME is on.
|
|
3
|
+
*
|
|
4
|
+
* The stage hands `event.key` to the VM. With an IME on, the browser reports a key that the IME
|
|
5
|
+
* takes as `Process` (keyCode 229), and in kana input mode some browsers report the kana it would
|
|
6
|
+
* type (`ち` for A). The VM drops `Process` and matches `ち` against no key, so "when [a] key
|
|
7
|
+
* pressed" and "key [space] pressed?" stay silent until the user turns the IME off. `event.code`
|
|
8
|
+
* still names the physical key, so the key the VM expects can be recovered from it.
|
|
9
|
+
*/
|
|
10
|
+
/** A key the IME took, or a kana, ideographic or full-width character the IME would type. */
|
|
11
|
+
const imeKey = /^[ -ヿ!-゚]$/;
|
|
12
|
+
const namedKeys = {
|
|
13
|
+
Space: { key: ' ', keyCode: 32 },
|
|
14
|
+
Enter: { key: 'Enter', keyCode: 13 },
|
|
15
|
+
NumpadEnter: { key: 'Enter', keyCode: 13 },
|
|
16
|
+
Backspace: { key: 'Backspace', keyCode: 8 },
|
|
17
|
+
Escape: { key: 'Escape', keyCode: 27 },
|
|
18
|
+
ArrowLeft: { key: 'ArrowLeft', keyCode: 37 },
|
|
19
|
+
ArrowUp: { key: 'ArrowUp', keyCode: 38 },
|
|
20
|
+
ArrowRight: { key: 'ArrowRight', keyCode: 39 },
|
|
21
|
+
ArrowDown: { key: 'ArrowDown', keyCode: 40 }
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The key and keyCode of a physical key, for the keys Scratch has a name for.
|
|
25
|
+
* @param {string} code The event's `code`.
|
|
26
|
+
* @param {boolean} shiftKey Whether Shift was held, which makes a letter upper case.
|
|
27
|
+
* @returns {ScratchKey | null} The key, or null for a key Scratch has no name for.
|
|
28
|
+
*/
|
|
29
|
+
export const keyFromCode = (code, shiftKey = false) => {
|
|
30
|
+
const letter = /^Key([A-Z])$/.exec(code);
|
|
31
|
+
if (letter)
|
|
32
|
+
return { key: shiftKey ? letter[1] : letter[1].toLowerCase(), keyCode: letter[1].charCodeAt(0) };
|
|
33
|
+
const digit = /^(Digit|Numpad)([0-9])$/.exec(code);
|
|
34
|
+
if (digit)
|
|
35
|
+
return { key: digit[2], keyCode: (digit[1] === 'Digit' ? 48 : 96) + Number(digit[2]) };
|
|
36
|
+
return namedKeys[code] ?? null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The key an event would have reported with the IME off, when the IME changed it.
|
|
40
|
+
* @param {KeyboardEvent} event The key event.
|
|
41
|
+
* @returns {ScratchKey | null} The recovered key, or null when the event needs no change.
|
|
42
|
+
*/
|
|
43
|
+
export const imeScratchKey = (event) => {
|
|
44
|
+
const { key, code, keyCode, shiftKey } = event;
|
|
45
|
+
if (key !== 'Process' && keyCode !== 229 && !imeKey.test(key ?? ''))
|
|
46
|
+
return null;
|
|
47
|
+
return code ? keyFromCode(code, shiftKey) : null;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Correct key events that reach the document itself, before the stage's own listeners read them.
|
|
51
|
+
* Events aimed at a text field or a block's field editor are left alone, so typing with the IME
|
|
52
|
+
* still works there.
|
|
53
|
+
* @param {Document} document The document whose stage takes key input.
|
|
54
|
+
* @returns {() => void} A function that removes the correction.
|
|
55
|
+
*/
|
|
56
|
+
export function installImeKeyInput(document) {
|
|
57
|
+
const window = document.defaultView;
|
|
58
|
+
if (!window)
|
|
59
|
+
return () => { };
|
|
60
|
+
const correct = (event) => {
|
|
61
|
+
if (event.target !== document && event.target !== document.body)
|
|
62
|
+
return;
|
|
63
|
+
const recovered = imeScratchKey(event);
|
|
64
|
+
if (!recovered)
|
|
65
|
+
return;
|
|
66
|
+
Object.defineProperty(event, 'key', { value: recovered.key, configurable: true });
|
|
67
|
+
Object.defineProperty(event, 'keyCode', { value: recovered.keyCode, configurable: true });
|
|
68
|
+
Object.defineProperty(event, 'which', { value: recovered.keyCode, configurable: true });
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener('keydown', correct, true);
|
|
71
|
+
window.addEventListener('keyup', correct, true);
|
|
72
|
+
return () => {
|
|
73
|
+
window.removeEventListener('keydown', correct, true);
|
|
74
|
+
window.removeEventListener('keyup', correct, true);
|
|
75
|
+
};
|
|
76
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { attachExternalMonitorDrag } from './monitor-drag.ts';
|
|
2
2
|
export { attachStageInput } from './stage-input.ts';
|
|
3
|
+
export { imeScratchKey, installImeKeyInput, keyFromCode } from './ime-key.ts';
|
|
3
4
|
export { panelLayoutIconPath } from './sprite-layout-menu.ts';
|
|
4
5
|
type Axis = 'columns' | 'rows';
|
|
5
6
|
type Ratios = Record<Axis, number | null>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { attachExternalMonitorDrag } from "./monitor-drag.js";
|
|
2
2
|
export { attachStageInput } from "./stage-input.js";
|
|
3
|
+
export { imeScratchKey, installImeKeyInput, keyFromCode } from "./ime-key.js";
|
|
3
4
|
export { panelLayoutIconPath } from "./sprite-layout-menu.js";
|
|
4
5
|
const separatorSize = 8;
|
|
5
6
|
const keyboardStep = 16;
|
package/dist/sprite-tabs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { createDockview, DefaultTab, themeLight } from 'dockview';
|
|
4
|
+
import { connectOpenerDocument } from '@kubohiroya/turbowarp-plus-editor-windows/opener-document';
|
|
4
5
|
import { createSpriteLayoutMenu } from "./sprite-layout-menu.js";
|
|
5
6
|
import { NativeAssetPanel, SpriteAssetPane } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
6
7
|
import { SpriteEditorToolbar, spriteEditorSections } from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-editor-toolbar';
|
|
@@ -174,6 +175,8 @@ export function mountSpriteTabs(root, content, options) {
|
|
|
174
175
|
const openingGroups = new Set();
|
|
175
176
|
/** Panels that were in a separate window when the layout was saved, until the user reopens them. */
|
|
176
177
|
const reopenable = new Map();
|
|
178
|
+
// Each open panel window, connected to this document while it is open.
|
|
179
|
+
const openerConnections = new Map();
|
|
177
180
|
const originalTargets = () => vm.runtime.targets.filter(target => target.isOriginal);
|
|
178
181
|
// Whether tabs stand in a column at the left of each split. It is the user's preference for every project.
|
|
179
182
|
let verticalTabs = false;
|
|
@@ -382,7 +385,13 @@ export function mountSpriteTabs(root, content, options) {
|
|
|
382
385
|
doc.documentElement.lang = document.documentElement.lang;
|
|
383
386
|
doc.documentElement.style.cssText = document.documentElement.style.cssText;
|
|
384
387
|
doc.body.className = `${document.body.className} ${popouts.className ?? ''}`;
|
|
388
|
+
// Dockview copied the styles present now; views opened later bring their own.
|
|
389
|
+
openerConnections.set(child, connectOpenerDocument(doc, { opener: document, mirrorNewStyles: true }));
|
|
385
390
|
}, { once: true });
|
|
391
|
+
},
|
|
392
|
+
onWillClose({ window: child }) {
|
|
393
|
+
openerConnections.get(child)?.();
|
|
394
|
+
openerConnections.delete(child);
|
|
386
395
|
}
|
|
387
396
|
})
|
|
388
397
|
.then(opened => { if (opened)
|
|
@@ -1439,6 +1448,9 @@ export function mountSpriteTabs(root, content, options) {
|
|
|
1439
1448
|
disposeView(view);
|
|
1440
1449
|
content.remove();
|
|
1441
1450
|
dockview.dispose();
|
|
1451
|
+
for (const disconnect of openerConnections.values())
|
|
1452
|
+
disconnect();
|
|
1453
|
+
openerConnections.clear();
|
|
1442
1454
|
}
|
|
1443
1455
|
};
|
|
1444
1456
|
}
|
package/dist/stage-input.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { imeScratchKey } from "./ime-key.js";
|
|
1
2
|
/**
|
|
2
3
|
* Connect a stage to the document hosting its canvas. The stage supplies its
|
|
3
4
|
* pointer handlers and clears its own drag state when the document loses focus.
|
|
@@ -10,7 +11,8 @@ export function attachStageInput({ document, canvas, onMove, onUp, releasePointe
|
|
|
10
11
|
return;
|
|
11
12
|
if (event.ctrlKey || event.metaKey || event.altKey)
|
|
12
13
|
return;
|
|
13
|
-
const { code
|
|
14
|
+
const { code } = event;
|
|
15
|
+
const { key, keyCode } = imeScratchKey(event) ?? event;
|
|
14
16
|
const id = code || keyCode;
|
|
15
17
|
if (!keys.has(id)) {
|
|
16
18
|
const data = { key: key && key !== 'Dead' ? key : keyCode, keyCode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-plus-editor-workbench",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "The TurboWarp Plus Editor workbench: layout, dockable sprite tabs, stage, debugger tab and file menu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"default": "./dist/extension-file-menu.js"
|
|
47
47
|
},
|
|
48
48
|
"./info-menu.css": "./src/info-menu.css",
|
|
49
|
+
"./ime-key": {
|
|
50
|
+
"types": "./dist/ime-key.d.ts",
|
|
51
|
+
"default": "./dist/ime-key.js"
|
|
52
|
+
},
|
|
49
53
|
"./project-file-dialogs": {
|
|
50
54
|
"types": "./dist/project-file-dialogs.d.ts",
|
|
51
55
|
"default": "./dist/project-file-dialogs.js"
|
|
@@ -126,7 +130,7 @@
|
|
|
126
130
|
},
|
|
127
131
|
"devDependencies": {
|
|
128
132
|
"@kubohiroya/turbowarp-plus-editor-git": "0.22.0",
|
|
129
|
-
"@kubohiroya/turbowarp-plus-editor-windows": "0.2.
|
|
133
|
+
"@kubohiroya/turbowarp-plus-editor-windows": "0.2.1",
|
|
130
134
|
"@playwright/test": "1.64.1",
|
|
131
135
|
"@types/react": "18.3.31",
|
|
132
136
|
"@types/react-dom": "18.3.7",
|
|
@@ -148,7 +152,7 @@
|
|
|
148
152
|
},
|
|
149
153
|
"peerDependencies": {
|
|
150
154
|
"@kubohiroya/turbowarp-plus-editor-git": ">=0.21.0 <0.23.0",
|
|
151
|
-
"@kubohiroya/turbowarp-plus-editor-windows": ">=0.2.
|
|
155
|
+
"@kubohiroya/turbowarp-plus-editor-windows": ">=0.2.1 <0.3.0",
|
|
152
156
|
"react": ">=16.14",
|
|
153
157
|
"react-dom": ">=16.14"
|
|
154
158
|
},
|
package/src/ime-key.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys pressed while a Japanese, Chinese or Korean IME is on.
|
|
3
|
+
*
|
|
4
|
+
* The stage hands `event.key` to the VM. With an IME on, the browser reports a key that the IME
|
|
5
|
+
* takes as `Process` (keyCode 229), and in kana input mode some browsers report the kana it would
|
|
6
|
+
* type (`ち` for A). The VM drops `Process` and matches `ち` against no key, so "when [a] key
|
|
7
|
+
* pressed" and "key [space] pressed?" stay silent until the user turns the IME off. `event.code`
|
|
8
|
+
* still names the physical key, so the key the VM expects can be recovered from it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type ScratchKey = {key: string; keyCode: number};
|
|
12
|
+
|
|
13
|
+
/** A key the IME took, or a kana, ideographic or full-width character the IME would type. */
|
|
14
|
+
const imeKey = /^[ -ヿ!-゚]$/;
|
|
15
|
+
|
|
16
|
+
const namedKeys: Readonly<Record<string, ScratchKey>> = {
|
|
17
|
+
Space: {key: ' ', keyCode: 32},
|
|
18
|
+
Enter: {key: 'Enter', keyCode: 13},
|
|
19
|
+
NumpadEnter: {key: 'Enter', keyCode: 13},
|
|
20
|
+
Backspace: {key: 'Backspace', keyCode: 8},
|
|
21
|
+
Escape: {key: 'Escape', keyCode: 27},
|
|
22
|
+
ArrowLeft: {key: 'ArrowLeft', keyCode: 37},
|
|
23
|
+
ArrowUp: {key: 'ArrowUp', keyCode: 38},
|
|
24
|
+
ArrowRight: {key: 'ArrowRight', keyCode: 39},
|
|
25
|
+
ArrowDown: {key: 'ArrowDown', keyCode: 40}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The key and keyCode of a physical key, for the keys Scratch has a name for.
|
|
30
|
+
* @param {string} code The event's `code`.
|
|
31
|
+
* @param {boolean} shiftKey Whether Shift was held, which makes a letter upper case.
|
|
32
|
+
* @returns {ScratchKey | null} The key, or null for a key Scratch has no name for.
|
|
33
|
+
*/
|
|
34
|
+
export const keyFromCode = (code: string, shiftKey = false): ScratchKey | null => {
|
|
35
|
+
const letter = /^Key([A-Z])$/.exec(code);
|
|
36
|
+
if (letter) return {key: shiftKey ? letter[1] : letter[1].toLowerCase(), keyCode: letter[1].charCodeAt(0)};
|
|
37
|
+
const digit = /^(Digit|Numpad)([0-9])$/.exec(code);
|
|
38
|
+
if (digit) return {key: digit[2], keyCode: (digit[1] === 'Digit' ? 48 : 96) + Number(digit[2])};
|
|
39
|
+
return namedKeys[code] ?? null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The key an event would have reported with the IME off, when the IME changed it.
|
|
44
|
+
* @param {KeyboardEvent} event The key event.
|
|
45
|
+
* @returns {ScratchKey | null} The recovered key, or null when the event needs no change.
|
|
46
|
+
*/
|
|
47
|
+
export const imeScratchKey = (event: Pick<KeyboardEvent, 'key' | 'code' | 'keyCode' | 'shiftKey'>): ScratchKey | null => {
|
|
48
|
+
const {key, code, keyCode, shiftKey} = event;
|
|
49
|
+
if (key !== 'Process' && keyCode !== 229 && !imeKey.test(key ?? '')) return null;
|
|
50
|
+
return code ? keyFromCode(code, shiftKey) : null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Correct key events that reach the document itself, before the stage's own listeners read them.
|
|
55
|
+
* Events aimed at a text field or a block's field editor are left alone, so typing with the IME
|
|
56
|
+
* still works there.
|
|
57
|
+
* @param {Document} document The document whose stage takes key input.
|
|
58
|
+
* @returns {() => void} A function that removes the correction.
|
|
59
|
+
*/
|
|
60
|
+
export function installImeKeyInput (document: Document) {
|
|
61
|
+
const window = document.defaultView;
|
|
62
|
+
if (!window) return () => {};
|
|
63
|
+
const correct = (event: Event) => {
|
|
64
|
+
if (event.target !== document && event.target !== document.body) return;
|
|
65
|
+
const recovered = imeScratchKey(event as KeyboardEvent);
|
|
66
|
+
if (!recovered) return;
|
|
67
|
+
Object.defineProperty(event, 'key', {value: recovered.key, configurable: true});
|
|
68
|
+
Object.defineProperty(event, 'keyCode', {value: recovered.keyCode, configurable: true});
|
|
69
|
+
Object.defineProperty(event, 'which', {value: recovered.keyCode, configurable: true});
|
|
70
|
+
};
|
|
71
|
+
window.addEventListener('keydown', correct, true);
|
|
72
|
+
window.addEventListener('keyup', correct, true);
|
|
73
|
+
return () => {
|
|
74
|
+
window.removeEventListener('keydown', correct, true);
|
|
75
|
+
window.removeEventListener('keyup', correct, true);
|
|
76
|
+
};
|
|
77
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {attachExternalMonitorDrag} from './monitor-drag.ts';
|
|
2
2
|
export {attachStageInput} from './stage-input.ts';
|
|
3
|
+
export {imeScratchKey, installImeKeyInput, keyFromCode} from './ime-key.ts';
|
|
3
4
|
export {panelLayoutIconPath} from './sprite-layout-menu.ts';
|
|
4
5
|
|
|
5
6
|
type Axis = 'columns' | 'rows';
|
package/src/sprite-tabs.ts
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import {createPortal} from 'react-dom';
|
|
3
3
|
import {createDockview, DefaultTab, themeLight} from 'dockview';
|
|
4
4
|
import type {DockviewGroupPanel, GroupPanelPartInitParameters, IDockviewPanel, SerializedDockview} from 'dockview';
|
|
5
|
+
import {connectOpenerDocument} from '@kubohiroya/turbowarp-plus-editor-windows/opener-document';
|
|
5
6
|
import {createSpriteLayoutMenu} from './sprite-layout-menu.ts';
|
|
6
7
|
import {NativeAssetPanel, SpriteAssetPane} from '@kubohiroya/turbowarp-plus-editor-sprite-panes/sprite-asset-pane';
|
|
7
8
|
import type {NativeAssetPanelRenderer, NativeAssetSelector, SpriteAssetKind, SpriteAssetLayout, SpriteAssetPreviewItem,
|
|
@@ -341,6 +342,8 @@ export function mountSpriteTabs<Snapshot>(root: HTMLElement, content: HTMLElemen
|
|
|
341
342
|
const openingGroups = new Set<string>();
|
|
342
343
|
/** Panels that were in a separate window when the layout was saved, until the user reopens them. */
|
|
343
344
|
const reopenable = new Map<string, SavedPopout>();
|
|
345
|
+
// Each open panel window, connected to this document while it is open.
|
|
346
|
+
const openerConnections = new Map<Window, () => void>();
|
|
344
347
|
const originalTargets = () => vm.runtime.targets.filter(target => target.isOriginal);
|
|
345
348
|
// Whether tabs stand in a column at the left of each split. It is the user's preference for every project.
|
|
346
349
|
let verticalTabs = false;
|
|
@@ -531,7 +534,13 @@ export function mountSpriteTabs<Snapshot>(root: HTMLElement, content: HTMLElemen
|
|
|
531
534
|
doc.documentElement.lang = document.documentElement.lang;
|
|
532
535
|
doc.documentElement.style.cssText = document.documentElement.style.cssText;
|
|
533
536
|
doc.body.className = `${document.body.className} ${popouts.className ?? ''}`;
|
|
537
|
+
// Dockview copied the styles present now; views opened later bring their own.
|
|
538
|
+
openerConnections.set(child, connectOpenerDocument(doc, {opener: document, mirrorNewStyles: true}));
|
|
534
539
|
}, {once: true});
|
|
540
|
+
},
|
|
541
|
+
onWillClose({window: child}) {
|
|
542
|
+
openerConnections.get(child)?.();
|
|
543
|
+
openerConnections.delete(child);
|
|
535
544
|
}
|
|
536
545
|
})
|
|
537
546
|
.then(opened => { if (opened) reopenable.delete(panel.id); })
|
|
@@ -1504,6 +1513,8 @@ export function mountSpriteTabs<Snapshot>(root: HTMLElement, content: HTMLElemen
|
|
|
1504
1513
|
for (const view of views.values()) disposeView(view);
|
|
1505
1514
|
content.remove();
|
|
1506
1515
|
dockview.dispose();
|
|
1516
|
+
for (const disconnect of openerConnections.values()) disconnect();
|
|
1517
|
+
openerConnections.clear();
|
|
1507
1518
|
}
|
|
1508
1519
|
};
|
|
1509
1520
|
}
|
package/src/stage-input.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {imeScratchKey} from './ime-key.ts';
|
|
2
|
+
|
|
1
3
|
type Key = {key: string | number; keyCode: number};
|
|
2
4
|
|
|
3
5
|
interface StageInput {
|
|
@@ -21,7 +23,8 @@ export function attachStageInput({document, canvas, onMove, onUp, releasePointer
|
|
|
21
23
|
function keyDown(event: KeyboardEvent) {
|
|
22
24
|
if (event.target !== document && event.target !== document.body && event.target !== canvas) return;
|
|
23
25
|
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
24
|
-
const {code
|
|
26
|
+
const {code} = event;
|
|
27
|
+
const {key, keyCode} = imeScratchKey(event) ?? event;
|
|
25
28
|
const id = code || keyCode;
|
|
26
29
|
if (!keys.has(id)) {
|
|
27
30
|
const data = {key: key && key !== 'Dead' ? key : keyCode, keyCode};
|