Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9283c4e
Improve the robustness of workspace SVG tests.
BenHenning Dec 6, 2024
803dcfb
chore(deps): bump eslint-plugin-jsdoc from 50.5.0 to 50.6.0 (#8690)
dependabot[bot] Dec 9, 2024
0cac191
chore(deps): bump prettier-plugin-organize-imports from 4.0.0 to 4.1.…
dependabot[bot] Dec 19, 2024
93e0319
chore(deps): bump eslint from 9.16.0 to 9.17.0 (#8697)
dependabot[bot] Dec 19, 2024
5054925
chore(deps): bump webdriverio from 9.0.9 to 9.4.2 (#8698)
dependabot[bot] Dec 19, 2024
ec6d3d3
chore(deps): bump concurrently from 9.0.1 to 9.1.2 (#8718)
dependabot[bot] Jan 6, 2025
f9b0221
chore(deps): bump @microsoft/api-extractor from 7.47.11 to 7.48.1 (#8…
dependabot[bot] Jan 6, 2025
dd6be31
fix: treat media files as binary while packaging them (#8706)
jfedor2 Jan 6, 2025
d7048d5
chore(deps): bump @blockly/dev-tools from 8.0.9 to 8.0.12 (#8708)
dependabot[bot] Jan 6, 2025
b8bb26f
fix: Fix serialization of the lists_split block. (#8702)
gonfunko Jan 6, 2025
bd7c86a
chore: Improve code health of generator tests. (#8703)
gonfunko Jan 6, 2025
77c695a
fix: Paste blocks copied from a mutator into the mutator. (#8719)
gonfunko Jan 6, 2025
f31a9f9
fix: Disallow adding comments to mutator workspaces. (#8720)
gonfunko Jan 6, 2025
2c29c01
Merge pull request #8701 from google/master
gonfunko Jan 6, 2025
547ff18
fix: Reposition the trashcan's flyout in response to workspace change…
gonfunko Jan 7, 2025
a42c2d1
feat: Add a BlockSvg.getStyle() method. (#8722)
gonfunko Jan 7, 2025
0c20129
fix: Fix bug that preventing scrolling menu items into view. (#8726)
gonfunko Jan 10, 2025
3a52aad
chore(deps): bump @blockly/theme-modern from 6.0.7 to 6.0.10 (#8728)
dependabot[bot] Jan 13, 2025
f9ef785
fix: Listen for keyboard shortcuts when the widget or dropdown divs h…
gonfunko Jan 14, 2025
6404107
fix: Fix display of multiline RTL strings in bubbles on Webkit. (#8733)
gonfunko Jan 14, 2025
a86ba15
fix: Fix the browser tests. (#8735)
gonfunko Jan 16, 2025
7a23c88
fix: Actually fix the browser tests. (#8736)
gonfunko Jan 16, 2025
16c8600
Merge pull request #8737 from google/master
gonfunko Jan 16, 2025
94794af
Merge branch 'develop' into improve-workspace-svg-test-robustness
BenHenning Jan 16, 2025
f866126
Merge pull request #8689 from BenHenning/improve-workspace-svg-test-r…
BenHenning Jan 16, 2025
a190539
fix: Fix dropdown text color in Zelos (#8741)
clementcontet Jan 20, 2025
3e4665e
chore(deps): bump globals from 15.12.0 to 15.14.0 (#8742)
dependabot[bot] Jan 20, 2025
34da1da
fix: Fix flaky connection checker test. (#8754)
gonfunko Jan 31, 2025
101ad82
chore(deps): bump @microsoft/api-documenter from 7.25.14 to 7.26.7 (#…
dependabot[bot] Feb 3, 2025
8fcc730
fix: Improve menu mouse/keyboard selection interaction. (#8749)
gonfunko Feb 4, 2025
db57976
chore(deps): bump typescript-eslint from 8.16.0 to 8.23.0 (#8761)
dependabot[bot] Feb 10, 2025
58406af
fix: Fix menu scrolling. (#8765)
gonfunko Feb 12, 2025
15d6ea2
Fix: #8194 by using a stepped animation for the wiggle (#8743)
RoboErikG Feb 12, 2025
29950fd
fix: Allow dragging blocks from the far lower right corner. (#8766)
gonfunko Feb 12, 2025
7e44e81
fix: Fix bug that prevented editing workspace comments on Firefox. (#…
gonfunko Feb 20, 2025
d016801
fix: Fix bug in IF block generators. (#8780)
michaela-mm Feb 24, 2025
dcd2d0e
fix: Fix a bug where selection outlines could be cut off when connect…
gonfunko Feb 27, 2025
fd55810
chore(deps): bump google-github-actions/deploy-appengine (#8755)
dependabot[bot] Mar 10, 2025
d3f0c6d
chore(deps): bump @hyperjump/json-schema from 1.9.8 to 1.11.0 (#8760)
dependabot[bot] Mar 10, 2025
810dd72
chore(deps): bump eslint-plugin-prettier from 5.2.1 to 5.2.3 (#8777)
dependabot[bot] Mar 10, 2025
87efad0
chore(deps): bump glob from 10.4.1 to 11.0.1 (#8730)
dependabot[bot] Mar 10, 2025
a1f7393
chore: Update permissions on GitHub actions. (#8808)
gonfunko Mar 18, 2025
df616e8
chore: Try adding additional permissions. (#8810)
gonfunko Mar 19, 2025
7401473
release: Merge branch 'develop' into rc/v11.2.2
gonfunko Mar 20, 2025
ae25b32
release: Update version number to 11.2.2
gonfunko Mar 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/appengine_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
path: _deploy/

- name: Deploy to App Engine
uses: google-github-actions/deploy-appengine@v2.1.4
uses: google-github-actions/deploy-appengine@v2.1.5
# For parameters see:
# https://github.com/google-github-actions/deploy-appengine#inputs
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/assign_reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
requested-reviewer:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Assign requested reviewer
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/conventional-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: bcoe/conventional-release-labels@v1
Expand Down
13 changes: 5 additions & 8 deletions blocks/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,22 +1046,19 @@ blocks['lists_split'] = {

/**
* Returns the state of this block as a JSON serializable object.
* This block does not need to serialize any specific state as it is already
* encoded in the dropdown values, but must have an implementation to avoid
* the backward compatible XML mutations being serialized.
*
* @returns The state of this block.
*/
saveExtraState: function (this: SplitBlock): null {
return null;
saveExtraState: function (this: SplitBlock): {mode: string} {
return {'mode': this.getFieldValue('MODE')};
},

/**
* Applies the given state to this block.
* No extra state is needed or expected as it is already encoded in the
* dropdown values.
*/
loadExtraState: function (this: SplitBlock) {},
loadExtraState: function (this: SplitBlock, state: {mode: string}) {
this.updateType_(state['mode']);
},
};

// Register provided blocks.
Expand Down
32 changes: 20 additions & 12 deletions core/block_animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,38 @@ export function disconnectUiEffect(block: BlockSvg) {
}
// Start the animation.
wobblingBlock = block;
disconnectUiStep(block, magnitude, new Date());
disconnectUiStep(block, magnitude, new Date(), 0);
}

/**
* Animate a brief wiggle of a disconnected block.
*
* @param block Block to animate.
* @param magnitude Maximum degrees skew (reversed for RTL).
* @param start Date of animation's start.
* @param start Date of animation's start for deciding when to stop.
* @param step Which step of the animation we're on.
*/
function disconnectUiStep(block: BlockSvg, magnitude: number, start: Date) {
function disconnectUiStep(
block: BlockSvg,
magnitude: number,
start: Date,
step: number,
) {
const DURATION = 200; // Milliseconds.
const WIGGLES = 3; // Half oscillations.

const ms = new Date().getTime() - start.getTime();
const percent = ms / DURATION;
const WIGGLES = [0.66, 1, 0.66, 0, -0.66, -1, -0.66, 0]; // Single cycle

let skew = '';
if (percent <= 1) {
const val = Math.round(
Math.sin(percent * Math.PI * WIGGLES) * (1 - percent) * magnitude,
);
if (start.getTime() + DURATION > new Date().getTime()) {
const val = Math.round(WIGGLES[step % WIGGLES.length] * magnitude);
skew = `skewX(${val})`;
disconnectPid = setTimeout(disconnectUiStep, 10, block, magnitude, start);
disconnectPid = setTimeout(
disconnectUiStep,
15,
block,
magnitude,
start,
step + 1,
);
}

block
Expand Down
13 changes: 11 additions & 2 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class BlockSvg
*
* @returns #RRGGBB string.
*/
getColourSecondary(): string | undefined {
getColourSecondary(): string {
return this.style.colourSecondary;
}

Expand All @@ -252,7 +252,7 @@ export class BlockSvg
*
* @returns #RRGGBB string.
*/
getColourTertiary(): string | undefined {
getColourTertiary(): string {
return this.style.colourTertiary;
}

Expand Down Expand Up @@ -1172,6 +1172,15 @@ export class BlockSvg
}
}

/**
* Returns the BlockStyle object used to style this block.
*
* @returns This block's style object.
*/
getStyle(): BlockStyle {
return this.style;
}

/**
* Move this block to the front of the visible workspace.
* <g> tags do not respect z-index so SVG renders them in the
Expand Down
47 changes: 28 additions & 19 deletions core/bubbles/text_bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Bubble} from './bubble.js';
* A bubble that displays non-editable text. Used by the warning icon.
*/
export class TextBubble extends Bubble {
private paragraph: SVGTextElement;
private paragraph: SVGGElement;

constructor(
private text: string,
Expand Down Expand Up @@ -48,43 +48,52 @@ export class TextBubble extends Bubble {
*/
private stringToSvg(text: string, container: SVGGElement) {
const paragraph = this.createParagraph(container);
const spans = this.createSpans(paragraph, text);
const fragments = this.createTextFragments(paragraph, text);
if (this.workspace.RTL)
this.rightAlignSpans(paragraph.getBBox().width, spans);
this.rightAlignTextFragments(paragraph.getBBox().width, fragments);
return paragraph;
}

/** Creates the paragraph container for this bubble's view's spans. */
private createParagraph(container: SVGGElement): SVGTextElement {
/** Creates the paragraph container for this bubble's view's text fragments. */
private createParagraph(container: SVGGElement): SVGGElement {
return dom.createSvgElement(
Svg.TEXT,
Svg.G,
{
'class': 'blocklyText blocklyBubbleText blocklyNoPointerEvents',
'y': Bubble.BORDER_WIDTH,
'transform': `translate(0,${Bubble.BORDER_WIDTH})`,
'style': `direction: ${this.workspace.RTL ? 'rtl' : 'ltr'}`,
},
container,
);
}

/** Creates the spans visualizing the text of this bubble. */
private createSpans(parent: SVGTextElement, text: string): SVGTSpanElement[] {
/** Creates the text fragments visualizing the text of this bubble. */
private createTextFragments(
parent: SVGGElement,
text: string,
): SVGTextElement[] {
let lineNum = 1;
return text.split('\n').map((line) => {
const tspan = dom.createSvgElement(
Svg.TSPAN,
{'dy': '1em', 'x': Bubble.BORDER_WIDTH},
const fragment = dom.createSvgElement(
Svg.TEXT,
{'y': `${lineNum}em`, 'x': Bubble.BORDER_WIDTH},
parent,
);
const textNode = document.createTextNode(line);
tspan.appendChild(textNode);
return tspan;
fragment.appendChild(textNode);
lineNum += 1;
return fragment;
});
}

/** Right aligns the given spans. */
private rightAlignSpans(maxWidth: number, spans: SVGTSpanElement[]) {
for (const span of spans) {
span.setAttribute('text-anchor', 'end');
span.setAttribute('x', `${maxWidth + Bubble.BORDER_WIDTH}`);
/** Right aligns the given text fragments. */
private rightAlignTextFragments(
maxWidth: number,
fragments: SVGTextElement[],
) {
for (const text of fragments) {
text.setAttribute('text-anchor', 'start');
text.setAttribute('x', `${maxWidth + Bubble.BORDER_WIDTH}`);
}
}

Expand Down
4 changes: 3 additions & 1 deletion core/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ function pasteFromData<T extends ICopyData>(
workspace: WorkspaceSvg,
coordinate?: Coordinate,
): ICopyable<T> | null {
workspace = workspace.getRootWorkspace() ?? workspace;
workspace = workspace.isMutator
? workspace
: (workspace.getRootWorkspace() ?? workspace);
return (globalRegistry
.getObject(globalRegistry.Type.PASTER, copyData.paster, false)
?.paste(copyData, workspace, coordinate) ?? null) as ICopyable<T> | null;
Expand Down
10 changes: 8 additions & 2 deletions core/comments/rendered_workspace_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,14 @@ export class RenderedWorkspaceComment
private startGesture(e: PointerEvent) {
const gesture = this.workspace.getGesture(e);
if (gesture) {
gesture.handleCommentStart(e, this);
this.workspace.getLayerManager()?.append(this, layers.BLOCK);
if (browserEvents.isTargetInput(e)) {
// If the text area was the focus, don't allow this event to bubble up
// and steal focus away from the editor/comment.
e.stopPropagation();
} else {
gesture.handleCommentStart(e, this);
this.workspace.getLayerManager()?.append(this, layers.BLOCK);
}
common.setSelected(this);
}
}
Expand Down
4 changes: 3 additions & 1 deletion core/contextmenu_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ export function registerCommentDuplicate() {
export function registerCommentCreate() {
const createOption: RegistryItem = {
displayText: () => Msg['ADD_COMMENT'],
preconditionFn: () => 'enabled',
preconditionFn: (scope: Scope) => {
return scope.workspace?.isMutator ? 'hidden' : 'enabled';
},
callback: (scope: Scope, e: PointerEvent) => {
const workspace = scope.workspace;
if (!workspace) return;
Expand Down
1 change: 1 addition & 0 deletions core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ input[type=number] {

.blocklyScrollbarBackground {
opacity: 0;
pointer-events: none;
}

.blocklyScrollbarHandle {
Expand Down
22 changes: 14 additions & 8 deletions core/field_dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {Coordinate} from './utils/coordinate.js';
import * as dom from './utils/dom.js';
import * as parsing from './utils/parsing.js';
import * as utilsString from './utils/string.js';
import * as style from './utils/style.js';
import {Svg} from './utils/svg.js';

/**
Expand Down Expand Up @@ -290,7 +291,7 @@ export class FieldDropdown extends Field<string> {

if (this.getConstants()!.FIELD_DROPDOWN_COLOURED_DIV) {
const primaryColour = block.getColour();
const borderColour = (this.sourceBlock_ as BlockSvg).style.colourTertiary;
const borderColour = (this.sourceBlock_ as BlockSvg).getColourTertiary();
dropDownDiv.setColour(primaryColour, borderColour);
}

Expand All @@ -303,6 +304,11 @@ export class FieldDropdown extends Field<string> {

if (this.selectedMenuItem) {
this.menu_!.setHighlighted(this.selectedMenuItem);
style.scrollIntoContainerView(
this.selectedMenuItem.getElement()!,
dropDownDiv.getContentDiv(),
true,
);
}

this.applyColour();
Expand Down Expand Up @@ -461,21 +467,21 @@ export class FieldDropdown extends Field<string> {
* Updates the dropdown arrow to match the colour/style of the block.
*/
override applyColour() {
const style = (this.sourceBlock_ as BlockSvg).style;
const sourceBlock = this.sourceBlock_ as BlockSvg;
if (this.borderRect_) {
this.borderRect_.setAttribute('stroke', style.colourTertiary);
this.borderRect_.setAttribute('stroke', sourceBlock.getColourTertiary());
if (this.menu_) {
this.borderRect_.setAttribute('fill', style.colourTertiary);
this.borderRect_.setAttribute('fill', sourceBlock.getColourTertiary());
} else {
this.borderRect_.setAttribute('fill', 'transparent');
}
}
// Update arrow's colour.
if (this.sourceBlock_ && this.arrow) {
if (this.sourceBlock_.isShadow()) {
this.arrow.style.fill = style.colourSecondary;
if (sourceBlock && this.arrow) {
if (sourceBlock.isShadow()) {
this.arrow.style.fill = sourceBlock.getColourSecondary();
} else {
this.arrow.style.fill = style.colourPrimary;
this.arrow.style.fill = sourceBlock.getColour();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/field_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export abstract class FieldInput<T extends InputTypes> extends Field<

if (!this.isFullBlockField() && this.borderRect_) {
this.borderRect_!.style.display = 'block';
this.borderRect_.setAttribute('stroke', block.style.colourTertiary);
this.borderRect_.setAttribute('stroke', block.getColourTertiary());
} else {
this.borderRect_!.style.display = 'none';
// In general, do *not* let fields control the color of blocks. Having the
Expand Down Expand Up @@ -429,8 +429,8 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
borderRadius = (bBox.bottom - bBox.top) / 2 + 'px';
// Pull stroke colour from the existing shadow block
const strokeColour = block.getParent()
? (block.getParent() as BlockSvg).style.colourTertiary
: (this.sourceBlock_ as BlockSvg).style.colourTertiary;
? (block.getParent() as BlockSvg).getColourTertiary()
: (this.sourceBlock_ as BlockSvg).getColourTertiary();
htmlInput.style.border = 1 * scale + 'px solid ' + strokeColour;
div!.style.borderRadius = borderRadius;
div!.style.transition = 'box-shadow 0.25s ease 0s';
Expand Down
2 changes: 1 addition & 1 deletion core/icons/comment_icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class CommentIcon extends Icon implements IHasBubble, ISerializable {

override applyColour(): void {
super.applyColour();
const colour = (this.sourceBlock as BlockSvg).style.colourPrimary;
const colour = (this.sourceBlock as BlockSvg).getColour();
this.textInputBubble?.setColour(colour);
}

Expand Down
2 changes: 1 addition & 1 deletion core/icons/mutator_icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class MutatorIcon extends Icon implements IHasBubble {

override applyColour(): void {
super.applyColour();
this.miniWorkspaceBubble?.setColour(this.sourceBlock.style.colourPrimary);
this.miniWorkspaceBubble?.setColour(this.sourceBlock.getColour());
this.miniWorkspaceBubble?.updateBlockStyles();
}

Expand Down
2 changes: 1 addition & 1 deletion core/icons/warning_icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class WarningIcon extends Icon implements IHasBubble {

override applyColour(): void {
super.applyColour();
this.textBubble?.setColour(this.sourceBlock.style.colourPrimary);
this.textBubble?.setColour(this.sourceBlock.getColour());
}

override updateCollapsed(): void {
Expand Down
Loading
Loading