Skip to content

Commit eb74678

Browse files
committed
chore: lint fixes
1 parent 2431971 commit eb74678

File tree

6 files changed

+54
-34
lines changed

6 files changed

+54
-34
lines changed

src/actions/arrow_navigation.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class ArrowNavigation {
5454
shortcut: ShortcutRegistry.KeyboardShortcut,
5555
): boolean => {
5656
const toolbox = workspace.getToolbox() as Toolbox;
57+
const flyout = workspace.getFlyout();
5758
let isHandled = false;
5859
switch (this.navigation.getState(workspace)) {
5960
case Constants.STATE.WORKSPACE:
@@ -70,7 +71,6 @@ export class ArrowNavigation {
7071
case Constants.STATE.TOOLBOX:
7172
// @ts-expect-error private method
7273
isHandled = toolbox && toolbox.selectChild();
73-
const flyout = workspace.getFlyout();
7474
if (!isHandled && flyout) {
7575
Blockly.getFocusManager().focusTree(flyout.getWorkspace());
7676
}
@@ -174,18 +174,22 @@ export class ArrowNavigation {
174174
}
175175
return isHandled;
176176
case Constants.STATE.TOOLBOX:
177-
if (!toolbox) return false;
178-
if (!toolbox.getSelectedItem()) {
179-
const firstItem = toolbox.getToolboxItems().find((item) => item.isSelectable()) ?? null;
180-
toolbox.setSelectedItem(firstItem);
181-
isHandled = true;
182-
} else {
183-
// @ts-expect-error private method
184-
isHandled = toolbox.selectNext();
185-
}
186-
const selectedItem = toolbox.getSelectedItem();
187-
if (selectedItem) {
188-
Blockly.getFocusManager().focusNode(selectedItem);
177+
if (toolbox) {
178+
if (!toolbox.getSelectedItem()) {
179+
const firstItem =
180+
toolbox
181+
.getToolboxItems()
182+
.find((item) => item.isSelectable()) ?? null;
183+
toolbox.setSelectedItem(firstItem);
184+
isHandled = true;
185+
} else {
186+
// @ts-expect-error private method
187+
isHandled = toolbox.selectNext();
188+
}
189+
const selectedItem = toolbox.getSelectedItem();
190+
if (selectedItem) {
191+
Blockly.getFocusManager().focusNode(selectedItem);
192+
}
189193
}
190194
return isHandled;
191195
default:
@@ -233,12 +237,13 @@ export class ArrowNavigation {
233237
}
234238
return isHandled;
235239
case Constants.STATE.TOOLBOX:
236-
if (!toolbox) return false;
237-
// @ts-expect-error private method
238-
isHandled = toolbox.selectPrevious();
239-
const selectedItem = toolbox.getSelectedItem();
240-
if (selectedItem) {
241-
Blockly.getFocusManager().focusNode(selectedItem);
240+
if (toolbox) {
241+
// @ts-expect-error private method
242+
isHandled = toolbox.selectPrevious();
243+
const selectedItem = toolbox.getSelectedItem();
244+
if (selectedItem) {
245+
Blockly.getFocusManager().focusNode(selectedItem);
246+
}
242247
}
243248
return isHandled;
244249
default:

src/actions/clipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
clipboard,
1414
ICopyData,
1515
LineCursor,
16-
getFocusManager
16+
getFocusManager,
1717
} from 'blockly';
1818
import * as Constants from '../constants';
1919
import type {BlockSvg, WorkspaceSvg} from 'blockly';

src/actions/enter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Field,
1515
FlyoutButton,
1616
WorkspaceSvg,
17-
getFocusManager
17+
getFocusManager,
1818
} from 'blockly/core';
1919

2020
import * as Constants from '../constants';

src/actions/exit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ShortcutRegistry,
99
utils as BlocklyUtils,
1010
getFocusManager,
11-
Gesture
11+
Gesture,
1212
} from 'blockly/core';
1313

1414
import * as Constants from '../constants';

src/navigation_controller.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ export class NavigationController {
205205
callback: (workspace) => {
206206
switch (this.navigation.getState(workspace)) {
207207
case Constants.STATE.WORKSPACE:
208-
Blockly.getFocusManager()
209-
.focusTree(
210-
workspace.getToolbox() ?? workspace.getFlyout() ?? workspace
211-
);
208+
Blockly.getFocusManager().focusTree(
209+
workspace.getToolbox() ?? workspace.getFlyout() ?? workspace,
210+
);
212211
return true;
213212
default:
214213
return false;

test/index.html

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,39 +97,55 @@
9797
font-weight: bold;
9898
}
9999

100-
.blocklyActiveFocus:is(.blocklyField,.blocklyPath,.blocklyHighlightedConnectionPath) {
100+
.blocklyActiveFocus:is(
101+
.blocklyField,
102+
.blocklyPath,
103+
.blocklyHighlightedConnectionPath
104+
) {
101105
stroke: #ffa200;
102106
stroke-width: 3px;
103107
outline-width: 0px;
104108
}
105-
.blocklyActiveFocus > .blocklyFlyoutBackground, .blocklyActiveFocus > .blocklyMainBackground {
109+
.blocklyActiveFocus > .blocklyFlyoutBackground,
110+
.blocklyActiveFocus > .blocklyMainBackground {
106111
stroke: #ffa200;
107112
stroke-width: 3px;
108113
}
109-
.blocklyActiveFocus:is(.blocklyFlyout,.blocklyWorkspace) {
114+
.blocklyActiveFocus:is(.blocklyFlyout, .blocklyWorkspace) {
110115
outline-width: 0px;
111116
}
112-
.blocklyActiveFocus:is(.blocklyToolbox,.blocklyToolboxCategoryContainer) {
117+
.blocklyActiveFocus:is(
118+
.blocklyToolbox,
119+
.blocklyToolboxCategoryContainer
120+
) {
113121
outline: 3px solid #ffa200;
114122
}
115-
.blocklyPassiveFocus:is(.blocklyField,.blocklyPath,.blocklyHighlightedConnectionPath) {
123+
.blocklyPassiveFocus:is(
124+
.blocklyField,
125+
.blocklyPath,
126+
.blocklyHighlightedConnectionPath
127+
) {
116128
stroke: #ffa200;
117129
stroke-dasharray: 5px 3px;
118130
stroke-width: 3px;
119131
}
120-
.blocklyPassiveFocus > .blocklyFlyoutBackground, .blocklyPassiveFocus > .blocklyMainBackground {
132+
.blocklyPassiveFocus > .blocklyFlyoutBackground,
133+
.blocklyPassiveFocus > .blocklyMainBackground {
121134
stroke: #ffa200;
122135
stroke-dasharray: 5px 3px;
123136
stroke-width: 3px;
124137
}
125-
.blocklyPassiveFocus:is(.blocklyToolbox,.blocklyToolboxCategoryContainer) {
138+
.blocklyPassiveFocus:is(
139+
.blocklyToolbox,
140+
.blocklyToolboxCategoryContainer
141+
) {
126142
border: 3px dashed #ffa200;
127143
}
128144
.blocklySelected:is(.blocklyPath) {
129145
stroke: #ffa200;
130146
stroke-width: 5;
131147
}
132-
.blocklySelected>.blocklyPathLight {
148+
.blocklySelected > .blocklyPathLight {
133149
display: none;
134150
}
135151
</style>

0 commit comments

Comments
 (0)