@kubohiroya/turbowarp-plus-editor-code-views 0.7.1 → 0.8.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 +1 -1
- package/README.md +1 -1
- package/dist/code-workspace-registry.d.ts +18 -0
- package/dist/code-workspace-registry.js +29 -0
- package/dist/palette-visibility-dialog.d.ts +1 -5
- package/dist/palette-visibility-dialog.js +4 -8
- package/dist/variable-merge.js +4 -1
- package/dist/workspace.js +3 -0
- package/package.json +1 -1
- package/src/code-workspace-registry.ts +32 -0
- package/src/palette-visibility-dialog.tsx +5 -16
- package/src/styles.css +0 -7
- package/src/variable-merge.ts +3 -1
- package/src/workspace.ts +3 -0
package/README.ja.md
CHANGED
|
@@ -67,7 +67,7 @@ MPL-2.0。turbowarp-plus-editor の `packages/editor-views` と `packages/editor
|
|
|
67
67
|
| `paletteGroupSets(locale, projectSets)` | 「標準」「表現」「変数・リスト」「基本の制御」と、作品のセット |
|
|
68
68
|
| `attachPaletteMenuButton(menu, getLocale, getItems)` | カテゴリの一覧の末尾(横配置では右端、縦配置では下端)に ▼ のボタンを置く。押すと、ホストが渡す項目のメニューを出す。項目は「ブロックグループの表示・非表示の設定」(`paletteVisibilityMenuLabel`)と、ホストの機能拡張に関する項目 |
|
|
69
69
|
|
|
70
|
-
`./palette-visibility-dialog` の `openPaletteVisibilityDialog(document, props)` は「パレット内のブロックグループの表示・非表示の設定」の画面を開く。機能拡張の各行は `@kubohiroya/turbowarp-extension-security-dialog/react` の `ExtensionRow` で描くので、拡張の追加の画面と同じ見た目になる。適用すると、出すグループと、この画面で足したセットを `onApply` に渡す。`newSprite`
|
|
70
|
+
`./palette-visibility-dialog` の `openPaletteVisibilityDialog(document, props)` は「パレット内のブロックグループの表示・非表示の設定」の画面を開く。機能拡張の各行は `@kubohiroya/turbowarp-extension-security-dialog/react` の `ExtensionRow` で描くので、拡張の追加の画面と同じ見た目になる。適用すると、出すグループと、この画面で足したセットを `onApply` に渡す。`newSprite` を渡すと、追加したばかりのスプライトについて尋ねる画面になり、見出しの下に「新しいスプライト「名前」」と出す。
|
|
71
71
|
|
|
72
72
|
ホストは `@kubohiroya/turbowarp-extension-security-dialog`(0.9.0 以上)を入れ、その `styles.css` も読み込む。設定を画面状態のスライスとして登録するのはホストの役目である。1つの機能拡張の中を複数のグループに分けて選ぶ機能は、VM がグループごとのカテゴリを作れるようになってから足す。
|
|
73
73
|
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ Each sprite and the stage can choose which block groups the palette shows: the s
|
|
|
67
67
|
| `paletteGroupSets(locale, projectSets)` | Standard, Expression, Variables and lists, Basic control, and the project's own sets |
|
|
68
68
|
| `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 |
|
|
69
69
|
|
|
70
|
-
`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
|
|
70
|
+
`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 and names it as a new sprite.
|
|
71
71
|
|
|
72
72
|
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.
|
|
73
73
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record a workspace as one that shows a target's code.
|
|
3
|
+
* @param {object} workspace The workspace.
|
|
4
|
+
* @returns {() => void} A function that removes the record.
|
|
5
|
+
*/
|
|
6
|
+
export declare const registerCodeWorkspace: (workspace: object) => () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a workspace shows a target's code: it was recorded here, or it sends its events to
|
|
9
|
+
* `vm.blockListener` directly.
|
|
10
|
+
* @param {object} vm The VM.
|
|
11
|
+
* @param {object} workspace The workspace.
|
|
12
|
+
* @returns {boolean} Whether it is a code workspace.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isCodeWorkspace: (vm: {
|
|
15
|
+
blockListener?: unknown;
|
|
16
|
+
}, workspace: {
|
|
17
|
+
listeners_?: unknown[];
|
|
18
|
+
} | null | undefined) => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspaces that show a target's code and send their edits to the VM.
|
|
3
|
+
*
|
|
4
|
+
* Without the code area's own attachment the GUI adds `vm.blockListener` to the workspace, so a
|
|
5
|
+
* module can recognise it by that listener. With `attachCodeWorkspace` the GUI adds the
|
|
6
|
+
* attachment's own listener instead, which wraps `vm.blockListener`; the attachment records its
|
|
7
|
+
* workspace here so other modules still recognise it.
|
|
8
|
+
*/
|
|
9
|
+
const codeWorkspaces = new WeakSet();
|
|
10
|
+
/**
|
|
11
|
+
* Record a workspace as one that shows a target's code.
|
|
12
|
+
* @param {object} workspace The workspace.
|
|
13
|
+
* @returns {() => void} A function that removes the record.
|
|
14
|
+
*/
|
|
15
|
+
export const registerCodeWorkspace = (workspace) => {
|
|
16
|
+
codeWorkspaces.add(workspace);
|
|
17
|
+
return () => {
|
|
18
|
+
codeWorkspaces.delete(workspace);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Whether a workspace shows a target's code: it was recorded here, or it sends its events to
|
|
23
|
+
* `vm.blockListener` directly.
|
|
24
|
+
* @param {object} vm The VM.
|
|
25
|
+
* @param {object} workspace The workspace.
|
|
26
|
+
* @returns {boolean} Whether it is a code workspace.
|
|
27
|
+
*/
|
|
28
|
+
export const isCodeWorkspace = (vm, workspace) => !!workspace && (codeWorkspaces.has(workspace) ||
|
|
29
|
+
(!!vm.blockListener && Array.isArray(workspace.listeners_) && workspace.listeners_.includes(vm.blockListener)));
|
|
@@ -12,8 +12,6 @@ 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;
|
|
17
15
|
}
|
|
18
16
|
export interface PaletteVisibilityDialogProps {
|
|
19
17
|
locale?: string;
|
|
@@ -25,7 +23,7 @@ export interface PaletteVisibilityDialogProps {
|
|
|
25
23
|
used: ReadonlyMap<string, number>;
|
|
26
24
|
extensions: readonly PaletteExtension[];
|
|
27
25
|
sets: readonly PaletteGroupSet[];
|
|
28
|
-
/** Asked for a sprite just added:
|
|
26
|
+
/** Asked for a sprite just added: the screen names it as a new sprite. */
|
|
29
27
|
newSprite?: boolean;
|
|
30
28
|
onApply(choice: PaletteVisibilityChoice): void;
|
|
31
29
|
onCancel(): void;
|
|
@@ -35,7 +33,6 @@ interface DialogState {
|
|
|
35
33
|
addedSets: PaletteGroupSet[];
|
|
36
34
|
naming: boolean;
|
|
37
35
|
setName: string;
|
|
38
|
-
dontAskAgain: boolean;
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
41
38
|
* The screen that chooses which block groups the palette shows for one sprite or the stage: sets that
|
|
@@ -49,7 +46,6 @@ export declare class PaletteVisibilityDialog extends React.PureComponent<Palette
|
|
|
49
46
|
sprite: (name: string) => string;
|
|
50
47
|
stage: string;
|
|
51
48
|
newSprite: (name: string) => string;
|
|
52
|
-
dontAskAgain: string;
|
|
53
49
|
sets: string;
|
|
54
50
|
addSet: string;
|
|
55
51
|
setName: string;
|
|
@@ -15,14 +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}”`,
|
|
18
|
+
newSprite: (name) => `New sprite “${name}”`,
|
|
19
19
|
sets: 'Applicable sets', addSet: 'Add applicable set', setName: 'Set name', add: 'Add',
|
|
20
20
|
standard: 'Standard block groups', extensions: 'Extension block groups', used: (count) => `In use ${count}`,
|
|
21
21
|
hiddenInUse: (count) => `Hidden and in use: ${count}`, cancel: 'Cancel', apply: 'Apply', close: 'Close'
|
|
22
22
|
},
|
|
23
23
|
ja: {
|
|
24
24
|
title: 'パレット内のブロックグループの表示・非表示の設定', sprite: (name) => `スプライト「${name}」`, stage: '背景',
|
|
25
|
-
newSprite: (name) => `新しいスプライト「${name}」`,
|
|
25
|
+
newSprite: (name) => `新しいスプライト「${name}」`,
|
|
26
26
|
sets: '適用可能なセット', addSet: '適用可能なセットを追加', setName: 'セットの名前', add: '追加',
|
|
27
27
|
standard: '標準のブロックグループ', extensions: '機能拡張のブロックグループ', used: (count) => `使用中 ${count}`,
|
|
28
28
|
hiddenInUse: (count) => `非表示中・使用中 ${count} 件`, cancel: 'キャンセル', apply: '適用', close: '閉じる'
|
|
@@ -37,7 +37,7 @@ const isJapanese = (locale) => /^ja(?:-|$)/i.test(locale ?? '');
|
|
|
37
37
|
export class PaletteVisibilityDialog extends React.PureComponent {
|
|
38
38
|
constructor(props) {
|
|
39
39
|
super(props);
|
|
40
|
-
this.state = { shown: new Set(props.initial), addedSets: [], naming: false, setName: ''
|
|
40
|
+
this.state = { shown: new Set(props.initial), addedSets: [], naming: false, setName: '' };
|
|
41
41
|
}
|
|
42
42
|
get text() {
|
|
43
43
|
return isJapanese(this.props.locale) ? messages.ja : messages.en;
|
|
@@ -88,8 +88,7 @@ export class PaletteVisibilityDialog extends React.PureComponent {
|
|
|
88
88
|
}
|
|
89
89
|
apply() {
|
|
90
90
|
const order = [...this.standard(), ...this.props.extensions.map(extension => extension.id)];
|
|
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 } : {} });
|
|
91
|
+
this.props.onApply({ groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets });
|
|
93
92
|
}
|
|
94
93
|
render() {
|
|
95
94
|
const { locale, targetName, isStage, used, extensions, onCancel } = this.props;
|
|
@@ -134,9 +133,6 @@ export class PaletteVisibilityDialog extends React.PureComponent {
|
|
|
134
133
|
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)))))))),
|
|
135
134
|
React.createElement("footer", { className: "tw-palette-visibility-footer" },
|
|
136
135
|
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)),
|
|
140
136
|
React.createElement("span", null,
|
|
141
137
|
React.createElement("button", { type: "button", onClick: onCancel }, text.cancel),
|
|
142
138
|
React.createElement("button", { type: "button", className: "tw-palette-visibility-apply", onClick: () => this.apply() }, text.apply)))));
|
package/dist/variable-merge.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isCodeWorkspace as isRecordedCodeWorkspace } from "./code-workspace-registry.js";
|
|
1
2
|
import { applyPlan, planMerge, planScopeChange, refreshEditor, undoPlan } from "./variable-merge-plan.js";
|
|
2
3
|
export { applyPlan, findVariable, planMerge, planScopeChange, refreshEditor, undoPlan } from "./variable-merge-plan.js";
|
|
3
4
|
const MESSAGES = {
|
|
@@ -326,8 +327,10 @@ export function installVariableMerge(vm, ScratchBlocks, { document: fallbackDocu
|
|
|
326
327
|
const main = workspace?.targetWorkspace ?? workspace;
|
|
327
328
|
if (!main)
|
|
328
329
|
return false;
|
|
330
|
+
if (isRecordedCodeWorkspace(vm, main))
|
|
331
|
+
return true;
|
|
329
332
|
if (vm.blockListener && Array.isArray(main.listeners_))
|
|
330
|
-
return
|
|
333
|
+
return false;
|
|
331
334
|
return main === ScratchBlocks.getMainWorkspace?.();
|
|
332
335
|
};
|
|
333
336
|
const documentOf = (workspace) => {
|
package/dist/workspace.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { attachBlockDrag } from "./block-drag.js";
|
|
2
|
+
import { registerCodeWorkspace } from "./code-workspace-registry.js";
|
|
2
3
|
import { workspaceXML } from "./history.js";
|
|
3
4
|
import { isFoldedDefinition, removeObsoleteProcedureInputs, setFoldedDefinition } from "./procedure-edits.js";
|
|
4
5
|
import { decodeEdit, encodeEdit, isCommentEdit } from "./protocol.js";
|
|
@@ -375,6 +376,7 @@ function paintPreviewFolds(blocks, preview, target, label) {
|
|
|
375
376
|
}
|
|
376
377
|
export function attachCodeWorkspace({ vm, ScratchBlocks: blocks, workspace, options, onError, presentationElements = null }) {
|
|
377
378
|
const session = getCodeSession(vm);
|
|
379
|
+
const unregisterCodeWorkspace = registerCodeWorkspace(workspace);
|
|
378
380
|
const homeDocument = workspace.getInjectionDiv().ownerDocument;
|
|
379
381
|
const histories = new WeakMap();
|
|
380
382
|
const signature = target => target.blocks.toXML(target.comments);
|
|
@@ -645,6 +647,7 @@ export function attachCodeWorkspace({ vm, ScratchBlocks: blocks, workspace, opti
|
|
|
645
647
|
},
|
|
646
648
|
dispose() {
|
|
647
649
|
blockDrag.dispose();
|
|
650
|
+
unregisterCodeWorkspace();
|
|
648
651
|
shown?.disconnect();
|
|
649
652
|
visibility.dispose();
|
|
650
653
|
if (pendingFrame !== null)
|
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.8.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",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspaces that show a target's code and send their edits to the VM.
|
|
3
|
+
*
|
|
4
|
+
* Without the code area's own attachment the GUI adds `vm.blockListener` to the workspace, so a
|
|
5
|
+
* module can recognise it by that listener. With `attachCodeWorkspace` the GUI adds the
|
|
6
|
+
* attachment's own listener instead, which wraps `vm.blockListener`; the attachment records its
|
|
7
|
+
* workspace here so other modules still recognise it.
|
|
8
|
+
*/
|
|
9
|
+
const codeWorkspaces = new WeakSet<object>();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Record a workspace as one that shows a target's code.
|
|
13
|
+
* @param {object} workspace The workspace.
|
|
14
|
+
* @returns {() => void} A function that removes the record.
|
|
15
|
+
*/
|
|
16
|
+
export const registerCodeWorkspace = (workspace: object) => {
|
|
17
|
+
codeWorkspaces.add(workspace);
|
|
18
|
+
return () => {
|
|
19
|
+
codeWorkspaces.delete(workspace);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether a workspace shows a target's code: it was recorded here, or it sends its events to
|
|
25
|
+
* `vm.blockListener` directly.
|
|
26
|
+
* @param {object} vm The VM.
|
|
27
|
+
* @param {object} workspace The workspace.
|
|
28
|
+
* @returns {boolean} Whether it is a code workspace.
|
|
29
|
+
*/
|
|
30
|
+
export const isCodeWorkspace = (vm: {blockListener?: unknown}, workspace: {listeners_?: unknown[]} | null | undefined) =>
|
|
31
|
+
!!workspace && (codeWorkspaces.has(workspace) ||
|
|
32
|
+
(!!vm.blockListener && Array.isArray(workspace.listeners_) && workspace.listeners_.includes(vm.blockListener)));
|
|
@@ -16,8 +16,6 @@ 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;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export interface PaletteVisibilityDialogProps {
|
|
@@ -30,7 +28,7 @@ export interface PaletteVisibilityDialogProps {
|
|
|
30
28
|
used: ReadonlyMap<string, number>;
|
|
31
29
|
extensions: readonly PaletteExtension[];
|
|
32
30
|
sets: readonly PaletteGroupSet[];
|
|
33
|
-
/** Asked for a sprite just added:
|
|
31
|
+
/** Asked for a sprite just added: the screen names it as a new sprite. */
|
|
34
32
|
newSprite?: boolean;
|
|
35
33
|
onApply(choice: PaletteVisibilityChoice): void;
|
|
36
34
|
onCancel(): void;
|
|
@@ -49,14 +47,14 @@ const standardColors: Record<string, string> = {
|
|
|
49
47
|
const messages = {
|
|
50
48
|
en: {
|
|
51
49
|
title: 'Block groups shown in the palette', sprite: (name: string) => `Sprite “${name}”`, stage: 'Stage',
|
|
52
|
-
newSprite: (name: string) => `New sprite “${name}”`,
|
|
50
|
+
newSprite: (name: string) => `New sprite “${name}”`,
|
|
53
51
|
sets: 'Applicable sets', addSet: 'Add applicable set', setName: 'Set name', add: 'Add',
|
|
54
52
|
standard: 'Standard block groups', extensions: 'Extension block groups', used: (count: number) => `In use ${count}`,
|
|
55
53
|
hiddenInUse: (count: number) => `Hidden and in use: ${count}`, cancel: 'Cancel', apply: 'Apply', close: 'Close'
|
|
56
54
|
},
|
|
57
55
|
ja: {
|
|
58
56
|
title: 'パレット内のブロックグループの表示・非表示の設定', sprite: (name: string) => `スプライト「${name}」`, stage: '背景',
|
|
59
|
-
newSprite: (name: string) => `新しいスプライト「${name}」`,
|
|
57
|
+
newSprite: (name: string) => `新しいスプライト「${name}」`,
|
|
60
58
|
sets: '適用可能なセット', addSet: '適用可能なセットを追加', setName: 'セットの名前', add: '追加',
|
|
61
59
|
standard: '標準のブロックグループ', extensions: '機能拡張のブロックグループ', used: (count: number) => `使用中 ${count}`,
|
|
62
60
|
hiddenInUse: (count: number) => `非表示中・使用中 ${count} 件`, cancel: 'キャンセル', apply: '適用', close: '閉じる'
|
|
@@ -69,7 +67,6 @@ interface DialogState {
|
|
|
69
67
|
addedSets: PaletteGroupSet[];
|
|
70
68
|
naming: boolean;
|
|
71
69
|
setName: string;
|
|
72
|
-
dontAskAgain: boolean;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
/**
|
|
@@ -80,7 +77,7 @@ interface DialogState {
|
|
|
80
77
|
export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibilityDialogProps, DialogState> {
|
|
81
78
|
constructor(props: PaletteVisibilityDialogProps) {
|
|
82
79
|
super(props);
|
|
83
|
-
this.state = {shown: new Set(props.initial), addedSets: [], naming: false, setName: ''
|
|
80
|
+
this.state = {shown: new Set(props.initial), addedSets: [], naming: false, setName: ''};
|
|
84
81
|
}
|
|
85
82
|
get text() {
|
|
86
83
|
return isJapanese(this.props.locale) ? messages.ja : messages.en;
|
|
@@ -125,8 +122,7 @@ export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibili
|
|
|
125
122
|
}
|
|
126
123
|
apply() {
|
|
127
124
|
const order = [...this.standard(), ...this.props.extensions.map(extension => extension.id)];
|
|
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} : {}});
|
|
125
|
+
this.props.onApply({groups: order.filter(group => this.state.shown.has(group)), addedSets: this.state.addedSets});
|
|
130
126
|
}
|
|
131
127
|
render() {
|
|
132
128
|
const {locale, targetName, isStage, used, extensions, onCancel} = this.props;
|
|
@@ -210,13 +206,6 @@ export class PaletteVisibilityDialog extends React.PureComponent<PaletteVisibili
|
|
|
210
206
|
)}
|
|
211
207
|
<footer className="tw-palette-visibility-footer">
|
|
212
208
|
<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
|
-
)}
|
|
220
209
|
<span>
|
|
221
210
|
<button type="button" onClick={onCancel}>{text.cancel}</button>
|
|
222
211
|
<button type="button" className="tw-palette-visibility-apply" onClick={() => this.apply()}>
|
package/src/styles.css
CHANGED
package/src/variable-merge.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {isCodeWorkspace as isRecordedCodeWorkspace} from './code-workspace-registry.ts';
|
|
1
2
|
import {applyPlan, planMerge, planScopeChange, refreshEditor, undoPlan,
|
|
2
3
|
type Plan, type Refusal, type VmLike} from './variable-merge-plan.ts';
|
|
3
4
|
|
|
@@ -380,7 +381,8 @@ export function installVariableMerge (vm: VmLike & {blockListener?: unknown}, Sc
|
|
|
380
381
|
const isCodeWorkspace = (workspace: WorkspaceLike) => {
|
|
381
382
|
const main = workspace?.targetWorkspace ?? workspace;
|
|
382
383
|
if (!main) return false;
|
|
383
|
-
if (vm
|
|
384
|
+
if (isRecordedCodeWorkspace(vm, main)) return true;
|
|
385
|
+
if (vm.blockListener && Array.isArray(main.listeners_)) return false;
|
|
384
386
|
return main === ScratchBlocks.getMainWorkspace?.();
|
|
385
387
|
};
|
|
386
388
|
const documentOf = (workspace: WorkspaceLike) => {
|
package/src/workspace.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {attachBlockDrag} from './block-drag.ts';
|
|
2
|
+
import {registerCodeWorkspace} from './code-workspace-registry.ts';
|
|
2
3
|
import {workspaceXML, type CodeTarget} from './history.ts';
|
|
3
4
|
import {isFoldedDefinition, removeObsoleteProcedureInputs, setFoldedDefinition} from './procedure-edits.ts';
|
|
4
5
|
import {decodeEdit, encodeEdit, isCommentEdit} from './protocol.ts';
|
|
@@ -416,6 +417,7 @@ function paintPreviewFolds(blocks, preview, target, label: string) {
|
|
|
416
417
|
|
|
417
418
|
export function attachCodeWorkspace({vm, ScratchBlocks: blocks, workspace, options, onError, presentationElements = null as PresentationElements | null}) {
|
|
418
419
|
const session = getCodeSession(vm);
|
|
420
|
+
const unregisterCodeWorkspace = registerCodeWorkspace(workspace);
|
|
419
421
|
const homeDocument: Document = workspace.getInjectionDiv().ownerDocument;
|
|
420
422
|
const histories = new WeakMap();
|
|
421
423
|
const signature = target => target.blocks.toXML(target.comments);
|
|
@@ -678,6 +680,7 @@ export function attachCodeWorkspace({vm, ScratchBlocks: blocks, workspace, optio
|
|
|
678
680
|
},
|
|
679
681
|
dispose() {
|
|
680
682
|
blockDrag.dispose();
|
|
683
|
+
unregisterCodeWorkspace();
|
|
681
684
|
shown?.disconnect();
|
|
682
685
|
visibility.dispose();
|
|
683
686
|
if (pendingFrame !== null) cancelAnimationFrame(pendingFrame);
|