Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d8c8fa

Browse files
authored
Merge pull requestcoderoad#16 from ShMcK/feature/integrate
Feature/integrate
2 parentse2665b5 +0002042 commit3d8c8fa

File tree

8 files changed

+56
-41
lines changed

8 files changed

+56
-41
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import*asvscodefrom'vscode'
2-
import*asCRfrom'typings'
31
import*aspathfrom'path'
2+
import*asCRfrom'typings'
3+
import*asvscodefrom'vscode'
44

55
/**
66
* Manages React webview panels
@@ -71,7 +71,7 @@ class ReactWebView {
7171
if(callback){
7272
// listen for when webview is loaded
7373
// unfortunately there is no easy way of doing this
74-
letwebPanelListener=setInterval(()=>{
74+
constwebPanelListener=setInterval(()=>{
7575
if(this.loaded){
7676
setTimeout(callback)
7777
clearInterval(webPanelListener)
@@ -80,6 +80,27 @@ class ReactWebView {
8080
}
8181
}
8282

83+
publicasyncpostMessage(action:CR.Action):Promise<void>{
84+
// Send a message to the webview webview.
85+
// You can send any JSON serializable data.
86+
constsuccess=awaitthis.panel.webview.postMessage(action)
87+
if(!success){
88+
thrownewError(`Message post failure:${JSON.stringify(action)}`)
89+
}
90+
}
91+
92+
publicdispose():void{
93+
// Clean up our resources
94+
this.panel.dispose()
95+
96+
while(this.disposables.length){
97+
constx=this.disposables.pop()
98+
if(x){
99+
x.dispose()
100+
}
101+
}
102+
}
103+
83104
privatecreateWebviewPanel(column:number):vscode.WebviewPanel{
84105
constviewType='CodeRoad'
85106
consttitle='CodeRoad'
@@ -103,27 +124,6 @@ class ReactWebView {
103124
returntext
104125
}
105126

106-
publicasyncpostMessage(action:CR.Action):Promise<void>{
107-
// Send a message to the webview webview.
108-
// You can send any JSON serializable data.
109-
constsuccess=awaitthis.panel.webview.postMessage(action)
110-
if(!success){
111-
thrownewError(`Message post failure:${JSON.stringify(action)}`)
112-
}
113-
}
114-
115-
publicdispose():void{
116-
// Clean up our resources
117-
this.panel.dispose()
118-
119-
while(this.disposables.length){
120-
constx=this.disposables.pop()
121-
if(x){
122-
x.dispose()
123-
}
124-
}
125-
}
126-
127127
privategetHtmlForWebview():string{
128128
// eslint-disable-next-line
129129
constmanifest=require(path.join(this.extensionPath,'build','asset-manifest.json'))
@@ -151,6 +151,8 @@ class ReactWebView {
151151
<meta name="theme-color" content="#000000">
152152
<title>React App</title>
153153
<link rel="manifest" href="./manifest.json" />
154+
<!-- TODO: load styles through package -->
155+
<link rel="stylesheet" href="https://unpkg.com/@alifd/next/dist/next.css" />
154156
<link rel="stylesheet" type="text/css" href="${styleUri}">
155157
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'nonce-${n1}' 'nonce-${n2}' 'nonce-${n3}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
156158
<base href="${vscode.Uri.file(path.join(this.extensionPath,'build')).with({

‎src/editor/commands/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import*asvscodefrom'vscode'
21
import{join}from'path'
3-
import{setStorage}from'../storage'
2+
import*asCRfrom'typings'
3+
import*asvscodefrom'vscode'
44
importReactWebViewfrom'../ReactWebView'
5+
import{setStorage}from'../storage'
56
import{isEmptyWorkspace}from'../workspace'
6-
import*asCRfrom'typings'
77
importrunTestfrom'./runTest'
88

99
constCOMMANDS={
@@ -44,7 +44,6 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
4444

4545
// activate machine
4646
webview=newReactWebView(context.extensionPath)
47-
console.log('webview',webview.panel.webview.postMessage)
4847
machine.activate()
4948
},
5049
// open React webview

‎tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"class-name":true,
99
"semicolon": [true,"never"],
1010
"triple-equals":true,
11-
"interface-name": [true,"never-prefix"]
11+
"interface-name": [true,"never-prefix"],
12+
"object-literal-sort-keys":false
1213
},
1314
"defaultSeverity":"warning",
1415
"no-submodule-imports":false

‎web-app/.storybook/config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
import'@alifd/next/dist/next.css'
1+
//import '@alifd/next/dist/next.css'
22
import{configure}from'@storybook/react'
33
import'../src/styles/index.css'
44

5+
// setup acquireVsCodeApi mock
6+
//@ts-ignore
7+
global.acquireVsCodeApi=()=>({
8+
postMessage(event:string){
9+
console.log('postMessage',event)
10+
}
11+
})
12+
13+
514
// automatically import all files ending in *.stories.tsx
615
constreq=require.context('../stories',true,/\.stories\.tsx$/)
716

‎web-app/src/Routes.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import*asReactfrom'react'
22

3-
importLoadingfrom'./components/Loading'
43
importCondfrom'./components/Cond'
5-
importNewPagefrom'./containers/New'
4+
importLoadingfrom'./components/Loading'
65
importContinuePagefrom'./containers/Continue'
6+
importNewPagefrom'./containers/New'
77
importTutorialPagefrom'./containers/Tutorial'
88

99
interfaceProps{
1010
state:any
1111
}
1212

13+
conststyles={
14+
page:{
15+
width:window.innerWidth,
16+
height:window.innerHeight,
17+
backgroundColor:'white',
18+
},
19+
}
20+
1321
constRoutes=({ state}:Props)=>{
1422
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
1523
return(
16-
<div>
24+
<divstyle={styles.page}>
1725
<Condstate={state}path="SelectTutorial.Startup">
1826
<Loading/>
1927
</Cond>

‎web-app/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
importReactDOMfrom'react-dom'
33
importAppfrom'./App'
44

5+
// base styles
56
import'./styles/index.css'
67

78
ReactDOM.render(<App/>,document.getElementById('root')asHTMLElement)

‎web-app/src/utils/vscode.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { Action } from 'typings'
22

33
declarevaracquireVsCodeApi:any
44

5-
//@ts-ignore
6-
constvscode=window.acquireVsCodeApi ?acquireVsCodeApi() :{
7-
postMessage(event:string){
8-
console.log('postMessage',event)
9-
}
10-
}
5+
constvscode=acquireVsCodeApi()
116

127
exportfunctionsend(event:string|Action){
138
returnvscode.postMessage(event)

‎web-app/stories/Stage.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ function someExample(a) {
3838
`,
3939
},
4040
hints:[],
41-
status:{active:false,complete:true},
41+
status:{active:true,complete:false},
4242
},
4343
step3Id:{
4444
content:{
4545
title:'Divide',
4646
text:'Write a function `divide` that divides',
4747
},
4848
hints:[],
49-
status:{active:true,complete:false},
49+
status:{active:false,complete:false},
5050
},
5151
})}
5252
stage={object('stage',demo.data.stages.stage1Id)}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp