Skip to content

Commit c474c81

Browse files
riknollsrietkerk
andauthored
[Stable 12.2] Cherry pick hotfix changes to stable 12.2 (#11126)
* put imported tiles into a custom tilemap gallery (#11112) * allow users to delete project descriptions (#11113) * fix font for animation icon in animation field editor (#11114) * copilot generated: add media queries for print view (#11110) * fix tile gallery not showing up when editing tile (#11115) * prevent debugger toolbox from scrolling horizontally (#11120) * Fix blockly dropdown scroll and media not being copied properly (#11119) * add scroll to blockly dropdown content * fix piping of blockly media files * keep the error list collapsed if collapsed by user (#11121) * add monkey patch workaround for blockly focus issue when deleting block (#11122) * bring back the old mixer play instructions (#11123) * fix missing gallery, don't import gallery tiles into my tiles, fix null listener (#11125) --------- Co-authored-by: Sarah Rietkerk <49178322+srietkerk@users.noreply.github.com>
1 parent cc19e63 commit c474c81

21 files changed

Lines changed: 510 additions & 30 deletions

File tree

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ const buildSVGIcons = () => {
544544
}
545545

546546
const copyBlocklyMedia = () =>
547-
gulp.src("node_modules/blockly/media/*")
547+
gulp.src("node_modules/blockly/media/*", { encoding: false })
548548
.pipe(gulp.dest("webapp/public/blockly/media"))
549549

550550

localtypings/pxteditor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ declare namespace pxt.editor {
820820
simSerialActive?: boolean;
821821
deviceSerialActive?: boolean;
822822
errorListState?: ErrorListState;
823+
errorListCollapsedByUser?: boolean;
823824
screenshoting?: boolean;
824825
extensionsVisible?: boolean;
825826
isMultiplayerGame?: boolean; // Arcade: Does the current project contain multiplayer blocks?

pxtblocks/fields/field_tileset.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,20 @@ export class FieldTileset extends FieldImages implements FieldCustom {
289289
}
290290

291291
protected updateAssetListener() {
292+
if (!this.assetChangeListener) {
293+
this.assetChangeListener = () => {
294+
this.doValueUpdate_(this.getValue());
295+
this.forceRerender();
296+
};
297+
}
292298
const project = pxt.react.getTilemapProject();
293299
project.removeChangeListener(pxt.AssetType.Tile, this.assetChangeListener);
294300
if (this.selectedOption_) {
295301
project.addChangeListener(this.selectedOption_[2], this.assetChangeListener);
296302
}
297303
}
298304

299-
protected assetChangeListener = () => {
300-
this.doValueUpdate_(this.getValue());
301-
this.forceRerender();
302-
}
305+
protected assetChangeListener: () => void;
303306

304307
saveState(_doFullSerialization?: boolean) {
305308
let asset = this.localTile || this.selectedOption_?.[2];

pxtblocks/monkeyPatches/blockSvg.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,57 @@ export function monkeyPatchBlockSvg() {
2020
}
2121
}
2222
}
23+
24+
// This is duplicated exactly from Blockly.BlockSvg.prototype.dispose,
25+
// except the radius of the connection search is increased to make
26+
// it more likely to focus a nearby block instead of the workspace
27+
// when a block is deleted. See https://github.com/RaspberryPiFoundation/blockly/issues/9585
28+
Blockly.BlockSvg.prototype.dispose = function (this: Blockly.BlockSvg, healStack: boolean, animate: boolean) {
29+
this.disposing = true;
30+
31+
Blockly.Tooltip.dispose();
32+
Blockly.ContextMenu.hide();
33+
34+
// If this block (or a descendant) was focused, focus its parent or
35+
// workspace instead.
36+
const focusManager = Blockly.getFocusManager();
37+
if (
38+
this.getSvgRoot().contains(
39+
focusManager.getFocusedNode()?.getFocusableElement() ?? null,
40+
)
41+
) {
42+
let parent: Blockly.BlockSvg | undefined | null = this.getParent();
43+
if (!parent) {
44+
const connection = this.outputConnection ?? this.previousConnection;
45+
if (connection) {
46+
// By default, Blockly searches for nearby connections within a radius of 0
47+
// to only get blocks that are touching. As a result, it usually returns nothing
48+
// and focuses the root of the workspace. Instead, we use the workspace dimensions
49+
// to try and find a block that's on screen
50+
const workspace = this.workspace;
51+
const viewMetrics = workspace?.getMetrics();
52+
const radius = viewMetrics ? Math.max(viewMetrics.viewWidth, viewMetrics.viewHeight) / 2: 0;
53+
54+
const targetConnection = connection.closest(
55+
radius,
56+
new Blockly.utils.Coordinate(0, 0),
57+
).connection;
58+
parent = targetConnection?.getSourceBlock();
59+
}
60+
}
61+
if (parent) {
62+
focusManager.focusNode(parent);
63+
} else {
64+
setTimeout(() => focusManager.focusTree(this.workspace), 0);
65+
}
66+
}
67+
68+
if (animate) {
69+
this.unplug(healStack);
70+
Blockly.blockAnimations.disposeUiEffect(this);
71+
}
72+
73+
Blockly.Block.prototype.dispose.call(this, !!healStack);
74+
Blockly.utils.dom.removeNode(this.getSvgRoot());
75+
}
2376
}

pxtlib/tilemap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ namespace pxt {
15891589
}
15901590
if (entry.tilemapTile) {
15911591
tags.push("tile");
1592+
tags.push("category-" + namespaceName)
15921593
}
15931594
}
15941595

pxtsim/sound/audioContextManager.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,16 @@ namespace pxsim.AudioContextManager {
187187
export async function playInstructionsAsync(instructions: Uint8Array, isCancelled?: () => boolean, onPull?: SoundPreviewCallback) {
188188
soundEventCallback?.("playinstructions", instructions);
189189

190-
await AudioWorkletSource.initializeWorklet(context());
190+
const channel = new PlayInstructionsSource(context(), destination);
191191

192-
let channel: AudioWorkletSource;
193192
let finished = false;
194193

195194
if (onPull) {
196-
channel = new AudioWorkletSource(context(), destination);
197-
198-
initOscilloscope(onPull, channel.analyser, () => finished || isCancelled?.());
199-
}
200-
else {
201-
channel = AudioWorkletSource.getAvailableSource();
202-
203-
if (!channel) {
204-
channel = new AudioWorkletSource(context(), destination);
205-
}
195+
initOscilloscope(onPull, channel.analyser, () => finished || isCancelled?.() || channel.isDisposed());
206196
}
207197

208198
await channel.playInstructionsAsync(instructions, isCancelled);
199+
channel.dispose();
209200

210201
finished = true;
211202
}

0 commit comments

Comments
 (0)