Skip to content

Commit

Permalink
fix karma tests
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed May 2, 2024
1 parent 44ab89b commit edbb5cd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pxtblocks/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Blockly from "blockly";
import { cleanOuterHTML, getFirstChildWithAttr } from "./xml";
import { promptTranslateBlock } from "./external";
import { createToolboxBlock } from "./toolbox";
import { DuplicateOnDragStrategy } from "./plugins/duplicateOnDrag";
import { DuplicateOnDragStrategy, setDuplicateOnDragStrategy } from "./plugins/duplicateOnDrag";

export function setBuiltinHelpInfo(block: any, id: string) {
const info = pxt.blocks.getBlockDefinition(id);
Expand All @@ -23,7 +23,7 @@ export function setHelpResources(block: Blockly.BlockSvg, id: string, name: stri
if (colour) block.setColour(colour);
if (undeletable) block.setDeletable(false);

block.setDragStrategy(new DuplicateOnDragStrategy(block));
setDuplicateOnDragStrategy(block);

let tb = document.getElementById('blocklyToolboxDefinition');
let xml: HTMLElement = tb ? getFirstChildWithAttr(tb, "block", "type", id) as HTMLElement : undefined;
Expand Down
6 changes: 2 additions & 4 deletions pxtblocks/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { initContextMenu } from "./contextMenu";
import { renderCodeCard } from "./codecardRenderer";
import { applyMonkeyPatches } from "./monkeyPatches";
import { FieldDropdown } from "./fields/field_dropdown";
import { DuplicateOnDragStrategy, setDraggableShadowBlocks } from "./plugins/duplicateOnDrag";
import { setDraggableShadowBlocks, setDuplicateOnDragStrategy } from "./plugins/duplicateOnDrag";


interface BlockDefinition {
Expand Down Expand Up @@ -217,9 +217,7 @@ function initBlock(block: Blockly.Block, info: pxtc.BlocksInfo, fn: pxtc.SymbolI
const helpUrl = pxt.blocks.getHelpUrl(fn);
if (helpUrl) block.setHelpUrl(helpUrl)

if ((block as Blockly.BlockSvg).setDragStrategy) {
(block as Blockly.BlockSvg).setDragStrategy(new DuplicateOnDragStrategy(block as Blockly.BlockSvg));
}
setDuplicateOnDragStrategy(block);

block.setColour(typeof color === "string" ? pxt.toolbox.getAccessibleBackground(color) : color);
let blockShape = provider.SHAPES.ROUND;
Expand Down
5 changes: 5 additions & 0 deletions pxtblocks/plugins/duplicateOnDrag/dragStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,8 @@ export class DuplicateOnDragStrategy implements Blockly.IDragStrategy {
this.dragging = false;
}
}


export function setDuplicateOnDragStrategy(block: Blockly.Block | Blockly.BlockSvg) {
(block as Blockly.BlockSvg).setDragStrategy?.(new DuplicateOnDragStrategy(block as Blockly.BlockSvg));
}
12 changes: 6 additions & 6 deletions pxtblocks/plugins/functions/blocks/argumentReporterBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE,
} from "../constants";
import { MsgKey } from "../msg";
import { DUPLICATE_ON_DRAG_MUTATION_KEY, DuplicateOnDragStrategy } from "../../duplicateOnDrag";
import { DUPLICATE_ON_DRAG_MUTATION_KEY, DuplicateOnDragStrategy, setDuplicateOnDragStrategy } from "../../duplicateOnDrag";
import { PathObject } from "../../renderer/pathObject";

type ArgumentReporterMixinType = typeof ARGUMENT_REPORTER_MIXIN;
Expand Down Expand Up @@ -57,7 +57,7 @@ Blockly.Blocks[ARGUMENT_REPORTER_BOOLEAN_BLOCK_TYPE] = {
extensions: ["output_boolean"],
});
this.typeName_ = "boolean";
this.setDragStrategy(new DuplicateOnDragStrategy(this));
setDuplicateOnDragStrategy(this);
},
};

Expand All @@ -77,7 +77,7 @@ Blockly.Blocks[ARGUMENT_REPORTER_STRING_BLOCK_TYPE] = {
extensions: ["output_string"],
});
this.typeName_ = "string";
this.setDragStrategy(new DuplicateOnDragStrategy(this));
setDuplicateOnDragStrategy(this);
},
};

Expand All @@ -97,7 +97,7 @@ Blockly.Blocks[ARGUMENT_REPORTER_NUMBER_BLOCK_TYPE] = {
extensions: ["output_number"],
});
this.typeName_ = "number";
this.setDragStrategy(new DuplicateOnDragStrategy(this));
setDuplicateOnDragStrategy(this);
},
};

Expand All @@ -117,7 +117,7 @@ Blockly.Blocks[ARGUMENT_REPORTER_ARRAY_BLOCK_TYPE] = {
extensions: ["output_array"],
});
this.typeName_ = "Array";
this.setDragStrategy(new DuplicateOnDragStrategy(this));
setDuplicateOnDragStrategy(this);
},
};

Expand All @@ -139,7 +139,7 @@ Blockly.Blocks[ARGUMENT_REPORTER_CUSTOM_BLOCK_TYPE] = {
output: null,
});
this.typeName_ = "";
this.setDragStrategy(new DuplicateOnDragStrategy(this));
setDuplicateOnDragStrategy(this);
},

mutationToDom(this: ArgumentReporterBlock) {
Expand Down

0 comments on commit edbb5cd

Please sign in to comment.