@kubohiroya/turbowarp-plus-editor-code-views 0.5.0 → 0.6.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
CHANGED
|
@@ -62,7 +62,7 @@ MPL-2.0。turbowarp-plus-editor の `packages/editor-views` と `packages/editor
|
|
|
62
62
|
| `paletteGroupSets(locale, projectSets)` | 「標準」「表現」「変数・リスト」「基本の制御」と、作品のセット |
|
|
63
63
|
| `attachPaletteMenuButton(menu, getLocale, getItems)` | カテゴリの一覧の末尾(横配置では右端、縦配置では下端)に ▼ のボタンを置く。押すと、ホストが渡す項目のメニューを出す。項目は「ブロックグループの表示・非表示の設定」(`paletteVisibilityMenuLabel`)と、ホストの機能拡張に関する項目 |
|
|
64
64
|
|
|
65
|
-
`./palette-visibility-dialog` の `openPaletteVisibilityDialog(document, props)` は「パレット内のブロックグループの表示・非表示の設定」の画面を開く。機能拡張の各行は `@kubohiroya/turbowarp-extension-security-dialog/react` の `ExtensionRow` で描くので、拡張の追加の画面と同じ見た目になる。適用すると、出すグループと、この画面で足したセットを `onApply`
|
|
65
|
+
`./palette-visibility-dialog` の `openPaletteVisibilityDialog(document, props)` は「パレット内のブロックグループの表示・非表示の設定」の画面を開く。機能拡張の各行は `@kubohiroya/turbowarp-extension-security-dialog/react` の `ExtensionRow` で描くので、拡張の追加の画面と同じ見た目になる。適用すると、出すグループと、この画面で足したセットを `onApply` に渡す。`newSprite` を渡すと、追加したばかりのスプライトについて尋ねる画面になり、「新しいスプライト「名前」」と「次回から尋ねない」のチェックを出す。チェックの値は `onApply` の `dontAskAgain` になる。
|
|
66
66
|
|
|
67
67
|
ホストは `@kubohiroya/turbowarp-extension-security-dialog`(0.9.0 以上)を入れ、その `styles.css` も読み込む。設定を画面状態のスライスとして登録するのはホストの役目である。1つの機能拡張の中を複数のグループに分けて選ぶ機能は、VM がグループごとのカテゴリを作れるようになってから足す。
|
|
68
68
|
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ Each sprite and the stage can choose which block groups the palette shows: the s
|
|
|
62
62
|
| `paletteGroupSets(locale, projectSets)` | Standard, Expression, Variables and lists, Basic control, and the project's own sets |
|
|
63
63
|
| `attachPaletteMenuButton(menu, getLocale, getItems)` | Puts a ▼ button at the end of the category menu (the right end of a horizontal palette, the bottom of a vertical one). Pressing it lists the items the host gives: the group settings (`paletteVisibilityMenuLabel`) and the host's extension items |
|
|
64
64
|
|
|
65
|
-
`openPaletteVisibilityDialog(document, props)` from `./palette-visibility-dialog` opens the screen that chooses the groups. Each extension is drawn with `ExtensionRow` from `@kubohiroya/turbowarp-extension-security-dialog/react`, so it looks the same as in the screen that adds extensions. Applying passes the groups to show, and the sets added in the screen, to `onApply`.
|
|
65
|
+
`openPaletteVisibilityDialog(document, props)` from `./palette-visibility-dialog` opens the screen that chooses the groups. Each extension is drawn with `ExtensionRow` from `@kubohiroya/turbowarp-extension-security-dialog/react`, so it looks the same as in the screen that adds extensions. Applying passes the groups to show, and the sets added in the screen, to `onApply`. With `newSprite`, the screen asks about a sprite just added: it names it as a new sprite and offers “Don’t ask next time”, whose value `onApply` receives as `dontAskAgain`.
|
|
66
66
|
|
|
67
67
|
The host installs `@kubohiroya/turbowarp-extension-security-dialog` (0.9.0 or later) and loads its `styles.css`, and registers the store as a screen-state slice. Choosing groups inside one extension comes once the VM can make a category per group.
|
|
68
68
|
|
|
@@ -12,6 +12,8 @@ export interface PaletteVisibilityChoice {
|
|
|
12
12
|
groups: string[];
|
|
13
13
|
/** Sets added in this dialog, to keep with the project. */
|
|
14
14
|
addedSets: PaletteGroupSet[];
|
|
15
|
+
/** For a new sprite: start the next new sprites with these groups instead of asking. */
|
|
16
|
+
dontAskAgain?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export interface PaletteVisibilityDialogProps {
|
|
17
19
|
locale?: string;
|
|
@@ -23,6 +25,8 @@ export interface PaletteVisibilityDialogProps {
|
|
|
23
25
|
used: ReadonlyMap<string, number>;
|
|
24
26
|
extensions: readonly PaletteExtension[];
|
|
25
27
|
sets: readonly PaletteGroupSet[];
|
|
28
|
+
/** Asked for a sprite just added: says so, and offers not to ask for the next ones. */
|
|
29
|
+
newSprite?: boolean;
|
|
26
30
|
onApply(choice: PaletteVisibilityChoice): void;
|
|
27
31
|
onCancel(): void;
|
|
28
32
|
}
|
|
@@ -31,6 +35,7 @@ interface DialogState {
|
|
|
31
35
|
addedSets: PaletteGroupSet[];
|
|
32
36
|
naming: boolean;
|
|
33
37
|
setName: string;
|
|
38
|
+
dontAskAgain: boolean;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* The screen that chooses which block groups the palette shows for one sprite or the stage: sets that
|
|
@@ -43,6 +48,8 @@ export declare class PaletteVisibilityDialog extends React.PureComponent<Palette
|
|
|
43
48
|
title: string;
|
|
44
49
|
sprite: (name: string) => string;
|
|
45
50
|
stage: string;
|
|
51
|
+
newSprite: (name: string) => string;
|
|
52
|
+
dontAskAgain: string;
|
|
46
53
|
sets: string;
|
|
47
54
|
addSet: string;
|
|
48
55
|
setName: string;
|
|
@@ -15,12 +15,14 @@ const standardColors = {
|
|
|
15
15
|
const messages = {
|
|
16
16
|
en: {
|
|
17
17
|
title: 'Block groups shown in the palette', sprite: (name) => `Sprite “${name}”`, stage: 'Stage',
|
|
18
|
+
newSprite: (name) => `New sprite “${name}”`, dontAskAgain: 'Don’t ask next time',
|
|
18
19
|
sets: 'Applicable sets', addSet: 'Add applicable set', setName: 'Set name', add: 'Add',
|
|
19
20
|
standard: 'Standard block groups', extensions: 'Extension block groups', used: (count) => `In use ${count}`,
|
|
20
21
|
hiddenInUse: (count) => `Hidden and in use: ${count}`, cancel: 'Cancel', apply: 'Apply', close: 'Close'
|
|
21
22
|
},
|
|
22
23
|
ja: {
|
|
23
24
|
title: 'パレット内のブロックグループの表示・非表示の設定', sprite: (name) => `スプライト「${name}」`, stage: '背景',
|
|
25
|
+
newSprite: (name) => `新しいスプライト「${name}」`, dontAskAgain: '次回から尋ねない',
|
|
24
26
|
sets: '適用可能なセット', addSet: '適用可能なセットを追加', setName: 'セットの名前', add: '追加',
|
|
25
27
|
standard: '標準のブロックグループ', extensions: '機能拡張のブロックグループ', used: (count) => `使用中 ${count}`,
|
|
26
28
|
hiddenInUse: (count) => `非表示中・使用中 ${count} 件`, cancel: 'キャンセル', apply: '適用', close: '閉じる'
|
|
@@ -35,7 +37,7 @@ const isJapanese = (locale) => /^ja(?:-|$)/i.test(locale ?? '');
|
|
|
35
37
|
export class PaletteVisibilityDialog extends React.PureComponent {
|
|
36
38
|
constructor(props) {
|
|
37
39
|
super(props);
|
|
38
|
-
this.state = { shown: new Set(props.initial), addedSets: [], naming: false, setName: '' };
|
|
40
|
+
this.state = { shown: new Set(props.initial), addedSets: [], naming: false, setName: '', dontAskAgain: false };
|
|
39
41
|
}
|
|
40
42
|
get text() {
|
|
41
43
|
return isJapanese(this.props.locale) ? messages.ja : messages.en;
|
|
@@ -86,7 +88,8 @@ export class PaletteVisibilityDialog extends React.PureComponent {
|
|
|
86
88
|
}
|
|
87
89
|
apply() {
|
|
88
90
|
const order = [...this.standard(), ...this.props.extensions.map(extension => extension.id)];
|
|
89
|
-
this.props.onApply({ groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets
|
|
91
|
+
this.props.onApply({ groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets,
|
|
92
|
+
...this.props.newSprite ? { dontAskAgain: this.state.dontAskAgain } : {} });
|
|
90
93
|
}
|
|
91
94
|
render() {
|
|
92
95
|
const { locale, targetName, isStage, used, extensions, onCancel } = this.props;
|
|
@@ -100,7 +103,7 @@ export class PaletteVisibilityDialog extends React.PureComponent {
|
|
|
100
103
|
React.createElement("header", { className: "tw-palette-visibility-header" },
|
|
101
104
|
React.createElement("div", null,
|
|
102
105
|
React.createElement("h2", null, text.title),
|
|
103
|
-
React.createElement("p", null, isStage ? text.stage : text.sprite(targetName))),
|
|
106
|
+
React.createElement("p", null, isStage ? text.stage : this.props.newSprite ? text.newSprite(targetName) : text.sprite(targetName))),
|
|
104
107
|
React.createElement("button", { type: "button", className: "tw-palette-visibility-close", "aria-label": text.close, title: text.close, onClick: onCancel }, "\u00D7")),
|
|
105
108
|
React.createElement("section", { "aria-label": text.sets },
|
|
106
109
|
React.createElement("h3", null, text.sets),
|
|
@@ -131,6 +134,9 @@ export class PaletteVisibilityDialog extends React.PureComponent {
|
|
|
131
134
|
React.createElement("ul", { className: "twextsec-rows" }, extensions.map(extension => (React.createElement(ExtensionRow, { key: extension.id, metadata: extension.metadata, ids: [extension.id], locale: locale, itemProps: { 'data-group': extension.id }, pick: { checked: shown.has(extension.id), onToggle: () => this.toggle(extension.id) } }, usedBadge(extension.id)))))))),
|
|
132
135
|
React.createElement("footer", { className: "tw-palette-visibility-footer" },
|
|
133
136
|
React.createElement("span", { role: "status" }, hiddenInUse > 0 ? text.hiddenInUse(hiddenInUse) : ''),
|
|
137
|
+
this.props.newSprite && (React.createElement("label", { className: "tw-palette-visibility-dont-ask" },
|
|
138
|
+
React.createElement("input", { type: "checkbox", checked: this.state.dontAskAgain, onChange: () => this.setState(({ dontAskAgain }) => ({ dontAskAgain: !dontAskAgain })) }),
|
|
139
|
+
text.dontAskAgain)),
|
|
134
140
|
React.createElement("span", null,
|
|
135
141
|
React.createElement("button", { type: "button", onClick: onCancel }, text.cancel),
|
|
136
142
|
React.createElement("button", { type: "button", className: "tw-palette-visibility-apply", onClick: () => this.apply() }, text.apply)))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-plus-editor-code-views",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Code views for TurboWarp Plus Editor: code in tabs and windows, the detached block palette, script layout and block field editing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -16,6 +16,8 @@ export interface PaletteVisibilityChoice {
|
|
|
16
16
|
groups: string[];
|
|
17
17
|
/** Sets added in this dialog, to keep with the project. */
|
|
18
18
|
addedSets: PaletteGroupSet[];
|
|
19
|
+
/** For a new sprite: start the next new sprites with these groups instead of asking. */
|
|
20
|
+
dontAskAgain?: boolean;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface PaletteVisibilityDialogProps {
|
|
@@ -28,6 +30,8 @@ export interface PaletteVisibilityDialogProps {
|
|
|
28
30
|
used: ReadonlyMap<string, number>;
|
|
29
31
|
extensions: readonly PaletteExtension[];
|
|
30
32
|
sets: readonly PaletteGroupSet[];
|
|
33
|
+
/** Asked for a sprite just added: says so, and offers not to ask for the next ones. */
|
|
34
|
+
newSprite?: boolean;
|
|
31
35
|
onApply(choice: PaletteVisibilityChoice): void;
|
|
32
36
|
onCancel(): void;
|
|
33
37
|
}
|
|
@@ -45,12 +49,14 @@ const standardColors: Record<string, string> = {
|
|
|
45
49
|
const messages = {
|
|
46
50
|
en: {
|
|
47
51
|
title: 'Block groups shown in the palette', sprite: (name: string) => `Sprite “${name}”`, stage: 'Stage',
|
|
52
|
+
newSprite: (name: string) => `New sprite “${name}”`, dontAskAgain: 'Don’t ask next time',
|
|
48
53
|
sets: 'Applicable sets', addSet: 'Add applicable set', setName: 'Set name', add: 'Add',
|
|
49
54
|
standard: 'Standard block groups', extensions: 'Extension block groups', used: (count: number) => `In use ${count}`,
|
|
50
55
|
hiddenInUse: (count: number) => `Hidden and in use: ${count}`, cancel: 'Cancel', apply: 'Apply', close: 'Close'
|
|
51
56
|
},
|
|
52
57
|
ja: {
|
|
53
58
|
title: 'パレット内のブロックグループの表示・非表示の設定', sprite: (name: string) => `スプライト「${name}」`, stage: '背景',
|
|
59
|
+
newSprite: (name: string) => `新しいスプライト「${name}」`, dontAskAgain: '次回から尋ねない',
|
|
54
60
|
sets: '適用可能なセット', addSet: '適用可能なセットを追加', setName: 'セットの名前', add: '追加',
|
|
55
61
|
standard: '標準のブロックグループ', extensions: '機能拡張のブロックグループ', used: (count: number) => `使用中 ${count}`,
|
|
56
62
|
hiddenInUse: (count: number) => `非表示中・使用中 ${count} 件`, cancel: 'キャンセル', apply: '適用', close: '閉じる'
|
|
@@ -63,6 +69,7 @@ interface DialogState {
|
|
|
63
69
|
addedSets: PaletteGroupSet[];
|
|
64
70
|
naming: boolean;
|
|
65
71
|
setName: string;
|
|
72
|
+
dontAskAgain: boolean;
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
/**
|
|
@@ -73,7 +80,7 @@ interface DialogState {
|
|
|
73
80
|
export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibilityDialogProps, DialogState> {
|
|
74
81
|
constructor(props: PaletteVisibilityDialogProps) {
|
|
75
82
|
super(props);
|
|
76
|
-
this.state = {shown: new Set(props.initial), addedSets: [], naming: false, setName: ''};
|
|
83
|
+
this.state = {shown: new Set(props.initial), addedSets: [], naming: false, setName: '', dontAskAgain: false};
|
|
77
84
|
}
|
|
78
85
|
get text() {
|
|
79
86
|
return isJapanese(this.props.locale) ? messages.ja : messages.en;
|
|
@@ -118,7 +125,8 @@ export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibili
|
|
|
118
125
|
}
|
|
119
126
|
apply() {
|
|
120
127
|
const order = [...this.standard(), ...this.props.extensions.map(extension => extension.id)];
|
|
121
|
-
this.props.onApply({groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets
|
|
128
|
+
this.props.onApply({groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets,
|
|
129
|
+
...this.props.newSprite ? {dontAskAgain: this.state.dontAskAgain} : {}});
|
|
122
130
|
}
|
|
123
131
|
render() {
|
|
124
132
|
const {locale, targetName, isStage, used, extensions, onCancel} = this.props;
|
|
@@ -135,7 +143,7 @@ export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibili
|
|
|
135
143
|
<header className="tw-palette-visibility-header">
|
|
136
144
|
<div>
|
|
137
145
|
<h2>{text.title}</h2>
|
|
138
|
-
<p>{isStage ? text.stage : text.sprite(targetName)}</p>
|
|
146
|
+
<p>{isStage ? text.stage : this.props.newSprite ? text.newSprite(targetName) : text.sprite(targetName)}</p>
|
|
139
147
|
</div>
|
|
140
148
|
<button type="button" className="tw-palette-visibility-close" aria-label={text.close} title={text.close}
|
|
141
149
|
onClick={onCancel}>×</button>
|
|
@@ -202,6 +210,13 @@ export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibili
|
|
|
202
210
|
)}
|
|
203
211
|
<footer className="tw-palette-visibility-footer">
|
|
204
212
|
<span role="status">{hiddenInUse > 0 ? text.hiddenInUse(hiddenInUse) : ''}</span>
|
|
213
|
+
{this.props.newSprite && (
|
|
214
|
+
<label className="tw-palette-visibility-dont-ask">
|
|
215
|
+
<input type="checkbox" checked={this.state.dontAskAgain}
|
|
216
|
+
onChange={() => this.setState(({dontAskAgain}) => ({dontAskAgain: !dontAskAgain}))} />
|
|
217
|
+
{text.dontAskAgain}
|
|
218
|
+
</label>
|
|
219
|
+
)}
|
|
205
220
|
<span>
|
|
206
221
|
<button type="button" onClick={onCancel}>{text.cancel}</button>
|
|
207
222
|
<button type="button" className="tw-palette-visibility-apply" onClick={() => this.apply()}>
|
package/src/styles.css
CHANGED