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

Commit4e94b71

Browse files
committed
resolve failing webview issue
1 parentd17c65a commit4e94b71

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

‎src/editor/ReactWebView.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,14 @@ class ReactWebView {
7878
// TODO: prevent window from moving to the left when no windows remain on rights
7979
}
8080

81-
publiccreateOrShow(column:number,callback?:()=>void):void{
81+
publiccreateOrShow(column:number):void{
8282
// If we already have a panel, show it.
8383
// Otherwise, create a new panel.
8484
if(this.panel&&this.panel.webview){
8585
this.panel.reveal(column)
8686
}else{
8787
this.panel=this.createWebviewPanel(column)
8888
}
89-
if(callback){
90-
// listen for when webview is loaded
91-
// unfortunately there is no easy way of doing this
92-
constwebPanelListener=setInterval(()=>{
93-
if(this.loaded){
94-
// callback tells editor the webview has loaded
95-
setTimeout(callback)
96-
clearInterval(webPanelListener)
97-
}
98-
},200)
99-
}
10089
}
10190

10291
publicasyncpostMessage(action:CR.Action):Promise<void>{
@@ -143,7 +132,7 @@ class ReactWebView {
143132
conststyles=[
144133
'main.css',
145134
// get style chunk
146-
//Object.keys(manifest.files).find(f => f.match(/^static\/css\/.+\.css$/)) || ''
135+
Object.keys(manifest.files).find(f=>f.match(/^static\/css\/.+\.css$/))||''
147136
].map(style=>getSrc(style))
148137

149138
// map over scripts
@@ -161,7 +150,6 @@ class ReactWebView {
161150
src:script.manifest ?getSrc(script.manifest) :script.file
162151
}))
163152

164-
165153
constindexHtml=`<!DOCTYPE html>
166154
<html lang='en'>
167155
<head>
@@ -173,14 +161,13 @@ class ReactWebView {
173161
174162
<link rel='stylesheet' href='https://unpkg.com/@alifd/next/dist/next.css' />
175163
${styles.map(styleUri=>`<link rel='stylesheet' type='text/css' href='${styleUri}'>`).join('\n')}
176-
177164
<meta http-equiv='Content-Security-Policy' content="font-src *; img-src vscode-resource: https:; script-src${scripts.map(script=>`'nonce-${script.nonce}'`).join(' ')}; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
178165
<base href='${buildUri}/'>
179166
</head>
180167
181168
<body>
182169
<noscript>You need to enable JavaScript to run this app.</noscript>
183-
<div id='root'>Loading...</div>
170+
<div id='root' style='background-color:white; padding: 1rem;'>Loading...</div>
184171
${scripts.map(s=>`<script nonce='${s.nonce}' src='${s.src}'></script>`).join('\n')}
185172
</body>
186173
</html>`

‎src/editor/commands/index.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
3737
return{
3838
// initialize
3939
[COMMANDS.START]:async()=>{
40+
console.log('start')
4041

4142
awaitisEmptyWorkspace()
4243

@@ -53,24 +54,13 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
5354

5455
// activate machine
5556
webview=newReactWebView(vscodeExt.extensionPath)
56-
if(webviewState==='INITIALIZING'){
57-
// machine.activate()
58-
}elseif(webviewState==='RESTARTING'){
59-
setTimeout(()=>{
60-
// timeout hack to make data update on new windows
61-
//@ts-ignore
62-
machine.refresh()
63-
},1000)
64-
}
6557
},
6658
// open React webview
6759
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.Two)=>{
60+
console.log('open webview')
6861
// setup 1x1 horizontal layout
6962
resetLayout()
70-
constcallback=()=>{
71-
// machine.send('WEBVIEW_INITIALIZED')
72-
}
73-
webview.createOrShow(column,callback)
63+
webview.createOrShow(column)
7464
},
7565
[COMMANDS.TEST_RUNNER_SETUP]:async(codingLanguage:G.EnumCodingLanguage)=>{
7666

@@ -90,6 +80,13 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
9080
[COMMANDS.OPEN_FILE]:async(relativeFilePath:string)=>{
9181
console.log(`OPEN_FILE${JSON.stringify(relativeFilePath)}`)
9282
try{
83+
// TODO: reenable after testing
84+
// const workspaceRoots: vscode.WorkspaceFolder[] | undefined = vscode.workspace.workspaceFolders
85+
// if (!workspaceRoots || !workspaceRoots.length) {
86+
// throw new Error('No workspace root path')
87+
// }
88+
// const rootWorkspace: vscode.WorkspaceFolder = workspaceRoots[0]
89+
// const absoluteFilePath = join(rootWorkspace.uri.path, relativeFilePath)
9390
constworkspaceRoot=vscode.workspace.rootPath
9491
if(!workspaceRoot){
9592
thrownewError('No workspace root path')

‎web-app/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importReactfrom'react'
1+
import*asReactfrom'react'
22
importReactDOMfrom'react-dom'
33
importAppfrom'./App'
44

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp