Skip to content

Commit 563874f

Browse files
committed
initialize webview
1 parent 9241fef commit 563874f

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/editor/commands/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from 'vscode'
22
import start from './start'
3+
import ReactPanel from '../views/createWebview'
34

45
// import runTest from './runTest'
56
// import loadSolution from './loadSolution'
@@ -8,6 +9,7 @@ import start from './start'
89
const COMMANDS = {
910
// TUTORIAL_SETUP: 'coderoad.tutorial_setup',
1011
START: 'coderoad.start',
12+
OPEN_WEBVIEW: 'coderoad.open_webview'
1113
// RUN_TEST: 'coderoad.test_run',
1214
// LOAD_SOLUTION: 'coderoad.solution_load',
1315
// QUIT: 'coderoad.quit',
@@ -19,6 +21,10 @@ export default (context: vscode.ExtensionContext): void => {
1921
[COMMANDS.START]: async function startCommand(): Promise<void> {
2022
return start(context)
2123
},
24+
[COMMANDS.OPEN_WEBVIEW]: () => {
25+
console.log('webview createOrShow')
26+
ReactPanel.createOrShow(context.extensionPath);
27+
}
2228
// [COMMANDS.RUN_TEST]: runTest,
2329
// [COMMANDS.LOAD_SOLUTION]: loadSolution,
2430
// [COMMANDS.QUIT]: () => quit(context.subscriptions),

src/editor/views/createWebview.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class ReactPanel {
2121
public static async createOrShow(extensionPath: string): Promise<void> {
2222
const hasActiveEditor = vscode.window.activeTextEditor
2323

24-
if (!hasActiveEditor) {
25-
throw new Error('Should have an open file on launch')
26-
}
27-
const column = vscode.ViewColumn.Two
24+
// if (!hasActiveEditor) {
25+
// throw new Error('Should have an open file on launch')
26+
// }
27+
const column = vscode.ViewColumn.One
2828

2929
// If we already have a panel, show it.
3030
// Otherwise, create a new panel.

src/state/actions/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { assign } from 'xstate'
22
import * as CR from 'typings'
3-
import * as storage from '../../services/storage'
4-
import * as git from '../../services/git'
3+
import * as vscode from 'vscode'
54

65
let initialTutorial: CR.Tutorial | undefined
76
let initialProgress: CR.Progress = {
@@ -46,5 +45,8 @@ export default {
4645
return position
4746
}
4847
}),
49-
48+
createWebview() {
49+
console.log('execute coderoad.open_webview')
50+
vscode.commands.executeCommand('coderoad.open_webview')
51+
}
5052
}

src/state/machine.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const machine = Machine<
2525
},
2626
},
2727
NewTutorial: {
28+
onEntry: ['createWebview'],
2829
initial: 'SelectTutorial',
2930
states: {
3031
SelectTutorial: {

0 commit comments

Comments
 (0)