Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion packages/plugins/field-bitmap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@blockly/field-bitmap",
"version": "13.1.0",
"private": true,
"description": "A field that lets users input a pixel grid with their mouse.",
"scripts": {
"audit:fix": "blockly-scripts auditFix",
Expand Down
31 changes: 5 additions & 26 deletions packages/plugins/field-bitmap/src/field-bitmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
this.bindEvent(dropdownEditor, 'pointerleave', this.onPointerEnd);
this.bindEvent(dropdownEditor, 'pointerdown', this.onPointerStart);
this.bindEvent(dropdownEditor, 'pointercancel', this.onPointerEnd);
this.bindEvent(dropdownEditor, 'keydown', this.onEditorKeyDown);
// Stop the browser from handling touch events and cancelling the event.
this.bindEvent(dropdownEditor, 'touchmove', (e: Event) => {
e.preventDefault();
Expand Down Expand Up @@ -424,26 +423,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
return grid;
}

/**
* Handles editor-level keyboard shortcuts.
* Ctrl/Cmd+Enter commits and closes; Escape reverts and closes.
*
* @param e The keydown event.
*/
private onEditorKeyDown(e: KeyboardEvent) {
const isEscape = e.key === 'Escape';
const isCommit = e.key === 'Enter' && (e.ctrlKey || e.metaKey);
if (!isEscape && !isCommit) return;

if (isEscape && this.initialValue !== null) {
this.setValue(this.initialValue, false);
}
Blockly.DropDownDiv.hideIfOwner(this);
Blockly.getFocusManager().focusNode(this);
e.preventDefault();
e.stopPropagation();
}

/**
* Handles keyboard navigation and activation inside the pixel grid.
*
Expand Down Expand Up @@ -737,7 +716,6 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
this.focusedPixelIndex = -1;
this.pointerIsDown = false;
this.valToPaintWith = undefined;
// Set this.initialValue back to null.
this.initialValue = null;

Blockly.DropDownDiv.getContentDiv().classList.remove(
Expand Down Expand Up @@ -843,10 +821,11 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
* Resets pointer state (e.g. After either a pointerup event or if the
* gesture is canceled).
*
* @param e The pointer event that ended the gesture.
* @param e The pointer event that ended the gesture, when available.
*/
private onPointerEnd(e: PointerEvent) {
private onPointerEnd(e?: PointerEvent) {
if (
e &&
e.currentTarget instanceof HTMLElement &&
e.currentTarget.hasPointerCapture?.(e.pointerId)
) {
Expand Down Expand Up @@ -938,10 +917,10 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
* @param eventName Name of the event to bind.
* @param callback Function to be called on specified event.
*/
private bindEvent<E extends Event>(
private bindEvent(
element: HTMLElement,
eventName: string,
callback: (e: E) => void,
callback: (e: PointerEvent) => void,
) {
this.boundEvents.push(
Blockly.browserEvents.bind(element, eventName, this, callback),
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/field-colour-hsv-sliders/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@blockly/field-colour-hsv-sliders",
"version": "13.1.0",
"private": true,
"description": "A Blockly colour field using HSV sliders.",
"scripts": {
"audit:fix": "blockly-scripts auditFix",
Expand Down
Loading