Skip to content

Commit a7670af

Browse files
Tweak to tutorial, comprehensive editor support.
1 parent bf70ddb commit a7670af

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

webapp/src/components/NavigateRegionsOverlay.tsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface RectBounds {
1818
height: number;
1919
}
2020

21-
type RegionId = "mainmenu" | "simulator" | "toolbox" | "workspace" | "editortools" | "tutorial";
21+
type RegionId = "mainmenu" | "simulator" | "toolbox" | "editor" | "editortools" | "tutorial";
2222

2323
interface Region {
2424
id: RegionId;
@@ -112,30 +112,30 @@ const regions: Region[] = [
112112
}
113113
},
114114
{
115-
id: "workspace",
116-
ariaLabel: lf("Workspace"),
115+
id: "editor",
116+
ariaLabel: lf("Editor"),
117117
shortcutKey: "4",
118118
getBounds(projectView: IProjectView) {
119-
let workspaceSelector: string = undefined;
120-
if (projectView.isBlocksActive()) {
121-
workspaceSelector = ".blocklySvg";
122-
} else if (projectView.isPxtJsonEditor()) {
123-
workspaceSelector = "#pxtJsonEditor";
124-
} else if (projectView.isJavaScriptActive() || projectView.isPythonActive()) {
125-
workspaceSelector = "#monacoEditorArea";
126-
}
127-
const bounds = document.querySelector(workspaceSelector)?.getBoundingClientRect();
128-
if (!projectView.isPxtJsonEditor()) {
129-
// Use bounds that don't overlap the toolbox region.
130-
const toolbox = getToolboxBounds(projectView);
131-
const copied = DOMRect.fromRect(bounds);
132-
if (toolbox) {
133-
copied.x = toolbox.right;
134-
copied.width = bounds.width - toolbox.width;
119+
const editorSelectors = ["#pxtJsonEditor", "#githubEditor", "#blocksArea", "#serialEditor", "#assetEditor", "#monacoEditor"];
120+
for (const selector of editorSelectors) {
121+
const element = document.querySelector(selector) as HTMLElement | null;
122+
if (element.offsetParent !== null) {
123+
console.log(element);
124+
const bounds = element.getBoundingClientRect();
125+
if (selector === "#monacoEditor" || selector === "#blocksArea") {
126+
// Use bounds that don't overlap the toolbox region.
127+
const toolbox = getToolboxBounds(projectView);
128+
const copied = DOMRect.fromRect(bounds);
129+
if (toolbox) {
130+
copied.x = toolbox.right;
131+
copied.width = bounds.width - toolbox.width;
132+
}
133+
return copied;
134+
}
135+
return bounds;
135136
}
136-
return copied;
137137
}
138-
return bounds;
138+
return undefined;
139139
},
140140
focus(projectView: IProjectView) {
141141
if (projectView.isPxtJsonEditor()) {
@@ -159,7 +159,8 @@ const regions: Region[] = [
159159
{
160160
id: "tutorial",
161161
ariaLabel: lf("Tutorial"),
162-
shortcutKey: "u",
162+
// This isn't really in sequence but it's not usually present.
163+
shortcutKey: "0",
163164
getBounds() {
164165
return document.querySelector(".tutorialWrapper")?.getBoundingClientRect();
165166
},
@@ -209,7 +210,7 @@ export const NavigateRegionsOverlay = ({ parent }: NavigateRegionsOverlayProps)
209210
parent.hideNavigateRegions();
210211
}
211212

212-
if (!regionRects.get("workspace")) {
213+
if (!regionRects.get("editor")) {
213214
// Something is awry, bail out.
214215
parent.hideNavigateRegions();
215216
return null;

0 commit comments

Comments
 (0)