Skip to content

Commit

Permalink
release: v9.1.1
Browse files Browse the repository at this point in the history
Merge pull request #6652 from maribethb/rc/v9.1.1
  • Loading branch information
maribethb authored Nov 21, 2022
2 parents 4a16495 + c6d8dcb commit 3d5f53e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
54 changes: 29 additions & 25 deletions core/mutator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ import type {WorkspaceSvg} from './workspace_svg.js';
export class Mutator extends Icon {
private quarkNames: string[];

/** Workspace in the mutator's bubble. */
private workspace: WorkspaceSvg|null = null;
/**
* Workspace in the mutator's bubble.
* Due to legacy code in procedure block definitions, this name
* cannot change.
*/
private workspace_: WorkspaceSvg|null = null;

/** Width of workspace. */
private workspaceWidth = 0;
Expand Down Expand Up @@ -107,7 +111,7 @@ export class Mutator extends Icon {
* @internal
*/
getWorkspace(): WorkspaceSvg|null {
return this.workspace;
return this.workspace_;
}

/**
Expand Down Expand Up @@ -200,22 +204,22 @@ export class Mutator extends Icon {
if (hasFlyout) {
workspaceOptions.languageTree = toolbox.convertToolboxDefToJson(quarkXml);
}
this.workspace = this.newWorkspaceSvg(workspaceOptions);
this.workspace.internalIsMutator = true;
this.workspace.addChangeListener(eventUtils.disableOrphans);
this.workspace_ = this.newWorkspaceSvg(workspaceOptions);
this.workspace_.internalIsMutator = true;
this.workspace_.addChangeListener(eventUtils.disableOrphans);

// Mutator flyouts go inside the mutator workspace's <g> rather than in
// a top level SVG. Instead of handling scale themselves, mutators
// inherit scale from the parent workspace.
// To fix this, scale needs to be applied at a different level in the DOM.
const flyoutSvg = hasFlyout ? this.workspace.addFlyout(Svg.G) : null;
const background = this.workspace.createDom('blocklyMutatorBackground');
const flyoutSvg = hasFlyout ? this.workspace_.addFlyout(Svg.G) : null;
const background = this.workspace_.createDom('blocklyMutatorBackground');

if (flyoutSvg) {
// Insert the flyout after the <rect> but before the block canvas so that
// the flyout is underneath in z-order. This makes blocks layering during
// dragging work properly.
background.insertBefore(flyoutSvg, this.workspace.svgBlockCanvas_);
background.insertBefore(flyoutSvg, this.workspace_.svgBlockCanvas_);
}
this.svgDialog.appendChild(background);

Expand Down Expand Up @@ -253,15 +257,15 @@ export class Mutator extends Icon {
/** Resize the bubble to match the size of the workspace. */
private resizeBubble() {
// If the bubble exists, the workspace also exists.
if (!this.workspace) {
if (!this.workspace_) {
return;
}
const doubleBorderWidth = 2 * Bubble.BORDER_WIDTH;
const canvas = this.workspace.getCanvas();
const canvas = this.workspace_.getCanvas();
const workspaceSize = canvas.getBBox();
let width = workspaceSize.width + workspaceSize.x;
let height = workspaceSize.height + doubleBorderWidth * 3;
const flyout = this.workspace.getFlyout();
const flyout = this.workspace_.getFlyout();
if (flyout) {
const flyoutScrollMetrics =
flyout.getWorkspace().getMetricsManager().getScrollMetrics();
Expand All @@ -285,20 +289,20 @@ export class Mutator extends Icon {
width + doubleBorderWidth, height + doubleBorderWidth);
this.svgDialog!.setAttribute('width', `${width}`);
this.svgDialog!.setAttribute('height', `${height}`);
this.workspace.setCachedParentSvgSize(width, height);
this.workspace_.setCachedParentSvgSize(width, height);
}

if (isRtl) {
// Scroll the workspace to always left-align.
canvas.setAttribute('transform', `translate(${this.workspaceWidth}, 0)`);
}
this.workspace.resize();
this.workspace_.resize();
}

/** A method handler for when the bubble is moved. */
private onBubbleMove() {
if (this.workspace) {
this.workspace.recordDragTargets();
if (this.workspace_) {
this.workspace_.recordDragTargets();
}
}

Expand All @@ -321,7 +325,7 @@ export class Mutator extends Icon {
block.workspace, this.createEditor(), block.pathObject.svgPath,
(this.iconXY_ as Coordinate), null, null);
// The workspace was created in createEditor.
const ws = this.workspace!;
const ws = this.workspace_!;
// Expose this mutator's block's ID on its top-level SVG group.
this.bubble_.setSvgId(block.id);
this.bubble_.registerMoveEvent(this.onBubbleMove.bind(this));
Expand Down Expand Up @@ -374,8 +378,8 @@ export class Mutator extends Icon {
} else {
// Dispose of the bubble.
this.svgDialog = null;
this.workspace!.dispose();
this.workspace = null;
this.workspace_!.dispose();
this.workspace_ = null;
this.rootBlock = null;
this.bubble_?.dispose();
this.bubble_ = null;
Expand Down Expand Up @@ -420,8 +424,8 @@ export class Mutator extends Icon {
* Bump down any block that's too high.
*/
private updateWorkspace() {
if (!this.workspace!.isDragging()) {
const blocks = this.workspace!.getTopBlocks(false);
if (!this.workspace_!.isDragging()) {
const blocks = this.workspace_!.getTopBlocks(false);
const MARGIN = 20;

for (let b = 0, block; block = blocks[b]; b++) {
Expand All @@ -434,7 +438,7 @@ export class Mutator extends Icon {
// Bump any block overlapping the flyout back inside.
if (block.RTL) {
let right = -MARGIN;
const flyout = this.workspace!.getFlyout();
const flyout = this.workspace_!.getFlyout();
if (flyout) {
right -= flyout.getWidth();
}
Expand All @@ -448,7 +452,7 @@ export class Mutator extends Icon {
}

// When the mutator's workspace changes, update the source block.
if (this.rootBlock && this.rootBlock.workspace === this.workspace) {
if (this.rootBlock && this.rootBlock.workspace === this.workspace_) {
const existingGroup = eventUtils.getGroup();
if (!existingGroup) {
eventUtils.setGroup(true);
Expand Down Expand Up @@ -488,7 +492,7 @@ export class Mutator extends Icon {

// Don't update the bubble until the drag has ended, to avoid moving
// blocks under the cursor.
if (!this.workspace!.isDragging()) {
if (!this.workspace_!.isDragging()) {
setTimeout(() => this.resizeBubble(), 0);
}
eventUtils.setGroup(existingGroup);
Expand All @@ -503,7 +507,7 @@ export class Mutator extends Icon {

/** Update the styles on all blocks in the mutator. */
updateBlockStyle() {
const ws = this.workspace;
const ws = this.workspace_;

if (ws && ws.getAllBlocks(false)) {
const workspaceBlocks = ws.getAllBlocks(false);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockly",
"version": "9.1.0",
"version": "9.1.1",
"description": "Blockly is a library for building visual programming editors.",
"keywords": [
"blockly"
Expand Down

0 comments on commit 3d5f53e

Please sign in to comment.