Skip to content

Commit 6b69541

Browse files
committed
chore: Merge branch 'develop' into rc/v12.0.0
2 parents bc0e1c3 + 778b7d5 commit 6b69541

File tree

10 files changed

+714
-440
lines changed

10 files changed

+714
-440
lines changed

.github/workflows/conventional-label.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ name: conventional-release-labels
77
jobs:
88
label:
99
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
1013
steps:
1114
- uses: bcoe/conventional-release-labels@v1
1215
with:

core/block_svg.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,21 @@ export class BlockSvg
521521
this.updateCollapsed();
522522
}
523523

524+
/**
525+
* Traverses child blocks to see if any of them have a warning.
526+
*
527+
* @returns true if any child has a warning, false otherwise.
528+
*/
529+
private childHasWarning(): boolean {
530+
const children = this.getChildren(false);
531+
for (const child of children) {
532+
if (child.getIcon(WarningIcon.TYPE) || child.childHasWarning()) {
533+
return true;
534+
}
535+
}
536+
return false;
537+
}
538+
524539
/**
525540
* Makes sure that when the block is collapsed, it is rendered correctly
526541
* for that state.
@@ -544,10 +559,17 @@ export class BlockSvg
544559
this.updateDisabled();
545560
this.removeInput(collapsedInputName);
546561
dom.removeClass(this.svgGroup, 'blocklyCollapsed');
562+
this.setWarningText(null, BlockSvg.COLLAPSED_WARNING_ID);
547563
return;
548564
}
549565

550566
dom.addClass(this.svgGroup, 'blocklyCollapsed');
567+
if (this.childHasWarning()) {
568+
this.setWarningText(
569+
Msg['COLLAPSED_WARNINGS_WARNING'],
570+
BlockSvg.COLLAPSED_WARNING_ID,
571+
);
572+
}
551573

552574
const text = this.toString(internalConstants.COLLAPSE_CHARS);
553575
const field = this.getField(collapsedFieldName);

core/field_dropdown.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,11 @@ export class FieldDropdown extends Field<string> {
129129
// If we pass SKIP_SETUP, don't do *anything* with the menu generator.
130130
if (menuGenerator === Field.SKIP_SETUP) return;
131131

132-
if (Array.isArray(menuGenerator)) {
133-
this.validateOptions(menuGenerator);
134-
const trimmed = this.trimOptions(menuGenerator);
135-
this.menuGenerator_ = trimmed.options;
136-
this.prefixField = trimmed.prefix || null;
137-
this.suffixField = trimmed.suffix || null;
138-
} else {
139-
this.menuGenerator_ = menuGenerator;
140-
}
141-
142-
/**
143-
* The currently selected option. The field is initialized with the
144-
* first option selected.
145-
*/
146-
this.selectedOption = this.getOptions(false)[0];
132+
this.setOptions(menuGenerator);
147133

148134
if (config) {
149135
this.configure_(config);
150136
}
151-
this.setValue(this.selectedOption[1]);
152137
if (validator) {
153138
this.setValidator(validator);
154139
}
@@ -417,6 +402,28 @@ export class FieldDropdown extends Field<string> {
417402
return this.generatedOptions;
418403
}
419404

405+
/**
406+
* Update the options on this dropdown. This will reset the selected item to
407+
* the first item in the list.
408+
*
409+
* @param menuGenerator The array of options or a generator function.
410+
*/
411+
setOptions(menuGenerator: MenuGenerator) {
412+
if (Array.isArray(menuGenerator)) {
413+
this.validateOptions(menuGenerator);
414+
const trimmed = this.trimOptions(menuGenerator);
415+
this.menuGenerator_ = trimmed.options;
416+
this.prefixField = trimmed.prefix || null;
417+
this.suffixField = trimmed.suffix || null;
418+
} else {
419+
this.menuGenerator_ = menuGenerator;
420+
}
421+
// The currently selected option. The field is initialized with the
422+
// first option selected.
423+
this.selectedOption = this.getOptions(false)[0];
424+
this.setValue(this.selectedOption[1]);
425+
}
426+
420427
/**
421428
* Ensure that the input value is a valid language-neutral option.
422429
*

core/toolbox/toolbox.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
// Unused import preserved for side-effects. Remove if unneeded.
1515
import {BlockSvg} from '../block_svg.js';
16-
import type {BlocklyOptions} from '../blockly_options.js';
1716
import * as browserEvents from '../browser_events.js';
1817
import * as common from '../common.js';
1918
import {ComponentManager} from '../component_manager.js';
@@ -36,7 +35,6 @@ import {isSelectableToolboxItem} from '../interfaces/i_selectable_toolbox_item.j
3635
import type {IStyleable} from '../interfaces/i_styleable.js';
3736
import type {IToolbox} from '../interfaces/i_toolbox.js';
3837
import type {IToolboxItem} from '../interfaces/i_toolbox_item.js';
39-
import {Options} from '../options.js';
4038
import * as registry from '../registry.js';
4139
import type {KeyboardShortcut} from '../shortcut_registry.js';
4240
import * as Touch from '../touch.js';
@@ -333,18 +331,7 @@ export class Toolbox
333331
*/
334332
protected createFlyout_(): IFlyout {
335333
const workspace = this.workspace_;
336-
// TODO (#4247): Look into adding a makeFlyout method to Blockly Options.
337-
const workspaceOptions = new Options({
338-
'parentWorkspace': workspace,
339-
'rtl': workspace.RTL,
340-
'oneBasedIndex': workspace.options.oneBasedIndex,
341-
'horizontalLayout': workspace.horizontalLayout,
342-
'renderer': workspace.options.renderer,
343-
'rendererOverrides': workspace.options.rendererOverrides,
344-
'move': {
345-
'scrollbars': true,
346-
},
347-
} as BlocklyOptions);
334+
const workspaceOptions = workspace.copyOptionsForFlyout();
348335
// Options takes in either 'end' or 'start'. This has already been parsed to
349336
// be either 0 or 1, so set it after.
350337
workspaceOptions.toolboxPosition = workspace.options.toolboxPosition;

core/trashcan.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// Former goog.module ID: Blockly.Trashcan
1313

1414
// Unused import preserved for side-effects. Remove if unneeded.
15-
import type {BlocklyOptions} from './blockly_options.js';
1615
import * as browserEvents from './browser_events.js';
1716
import {ComponentManager} from './component_manager.js';
1817
import {DeleteArea} from './delete_area.js';
@@ -26,7 +25,6 @@ import type {IDraggable} from './interfaces/i_draggable.js';
2625
import type {IFlyout} from './interfaces/i_flyout.js';
2726
import type {IPositionable} from './interfaces/i_positionable.js';
2827
import type {UiMetrics} from './metrics_manager.js';
29-
import {Options} from './options.js';
3028
import * as uiPosition from './positionable_helpers.js';
3129
import * as registry from './registry.js';
3230
import type * as blocks from './serialization/blocks.js';
@@ -103,17 +101,7 @@ export class Trashcan
103101
}
104102

105103
// Create flyout options.
106-
const flyoutWorkspaceOptions = new Options({
107-
'scrollbars': true,
108-
'parentWorkspace': this.workspace,
109-
'rtl': this.workspace.RTL,
110-
'oneBasedIndex': this.workspace.options.oneBasedIndex,
111-
'renderer': this.workspace.options.renderer,
112-
'rendererOverrides': this.workspace.options.rendererOverrides,
113-
'move': {
114-
'scrollbars': true,
115-
},
116-
} as BlocklyOptions);
104+
const flyoutWorkspaceOptions = this.workspace.copyOptionsForFlyout();
117105
// Create vertical or horizontal flyout.
118106
if (this.workspace.horizontalLayout) {
119107
flyoutWorkspaceOptions.toolboxPosition =

core/workspace_svg.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -986,24 +986,36 @@ export class WorkspaceSvg
986986
}
987987

988988
/**
989-
* Add a flyout element in an element with the given tag name.
989+
* Creates a new set of options from this workspace's options with just the
990+
* values that are relevant to a flyout.
990991
*
991-
* @param tagName What type of tag the flyout belongs in.
992-
* @returns The element containing the flyout DOM.
993-
* @internal
992+
* @returns A subset of this workspace's options.
994993
*/
995-
addFlyout(tagName: string | Svg<SVGSVGElement> | Svg<SVGGElement>): Element {
996-
const workspaceOptions = new Options({
994+
copyOptionsForFlyout(): Options {
995+
return new Options({
997996
'parentWorkspace': this,
998997
'rtl': this.RTL,
999998
'oneBasedIndex': this.options.oneBasedIndex,
1000999
'horizontalLayout': this.horizontalLayout,
10011000
'renderer': this.options.renderer,
10021001
'rendererOverrides': this.options.rendererOverrides,
1002+
'plugins': this.options.plugins,
1003+
'modalInputs': this.options.modalInputs,
10031004
'move': {
10041005
'scrollbars': true,
10051006
},
10061007
} as BlocklyOptions);
1008+
}
1009+
1010+
/**
1011+
* Add a flyout element in an element with the given tag name.
1012+
*
1013+
* @param tagName What type of tag the flyout belongs in.
1014+
* @returns The element containing the flyout DOM.
1015+
* @internal
1016+
*/
1017+
addFlyout(tagName: string | Svg<SVGSVGElement> | Svg<SVGGElement>): Element {
1018+
const workspaceOptions = this.copyOptionsForFlyout();
10071019
workspaceOptions.toolboxPosition = this.options.toolboxPosition;
10081020
if (this.horizontalLayout) {
10091021
const HorizontalFlyout = registry.getClassFromOptions(

0 commit comments

Comments
 (0)