Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
efec95c7
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
efec95c7
编写于
5月 20, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
allow workspace folder in notebook webview.
上级
3e9b7f50
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
8 deletion
+18
-8
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
...orkbench/contrib/notebook/browser/notebookEditorWidget.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+14
-4
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
浏览文件 @
efec95c7
...
...
@@ -364,7 +364,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}
async
setModel
(
textModel
:
NotebookTextModel
,
viewState
:
INotebookEditorViewState
|
undefined
,
options
:
EditorOptions
|
undefined
):
Promise
<
void
>
{
if
(
this
.
notebookViewModel
===
undefined
||
!
this
.
notebookViewModel
.
equal
(
textModel
)
||
this
.
webview
===
null
)
{
if
(
this
.
notebookViewModel
===
undefined
||
!
this
.
notebookViewModel
.
equal
(
textModel
))
{
this
.
detachModel
();
await
this
.
attachModel
(
textModel
,
viewState
);
}
...
...
@@ -454,8 +454,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
DOM
.
toggleClass
(
this
.
getDomNode
(),
'
notebook-editor-editable
'
,
!!
this
.
viewModel
!
.
metadata
?.
editable
);
}
private
createWebview
(
id
:
string
)
{
this
.
webview
=
this
.
instantiationService
.
createInstance
(
BackLayerWebView
,
this
,
id
);
private
createWebview
(
id
:
string
,
document
:
URI
)
{
this
.
webview
=
this
.
instantiationService
.
createInstance
(
BackLayerWebView
,
this
,
id
,
document
);
this
.
webview
.
webview
.
onDidBlur
(()
=>
this
.
updateEditorFocus
());
this
.
webview
.
webview
.
onDidFocus
(()
=>
this
.
updateEditorFocus
());
this
.
localStore
.
add
(
this
.
webview
.
onMessage
(
message
=>
{
...
...
@@ -467,7 +467,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
}
private
async
attachModel
(
textModel
:
NotebookTextModel
,
viewState
:
INotebookEditorViewState
|
undefined
)
{
this
.
createWebview
(
this
.
getId
());
this
.
createWebview
(
this
.
getId
()
,
textModel
.
uri
);
await
this
.
webview
!
.
waitForInitialization
();
this
.
eventDispatcher
=
new
NotebookEventDispatcher
();
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
efec95c7
...
...
@@ -21,6 +21,8 @@ import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookS
import
{
IWebviewService
,
WebviewElement
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
asWebviewUri
}
from
'
vs/workbench/contrib/webview/common/webviewUri
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
export
interface
IDimensionMessage
{
__vscode_notebook_message
:
boolean
;
...
...
@@ -144,10 +146,12 @@ export class BackLayerWebView extends Disposable {
constructor
(
public
notebookEditor
:
INotebookEditor
,
public
id
:
string
,
public
documentUri
:
URI
,
@
IWebviewService
readonly
webviewService
:
IWebviewService
,
@
IOpenerService
readonly
openerService
:
IOpenerService
,
@
INotebookService
private
readonly
notebookService
:
INotebookService
,
@
IEnvironmentService
private
readonly
environmentService
:
IEnvironmentService
,
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
IWorkbenchEnvironmentService
private
readonly
workbenchEnvironmentService
:
IWorkbenchEnvironmentService
,
)
{
super
();
...
...
@@ -168,9 +172,11 @@ export class BackLayerWebView extends Disposable {
resolveFunc
=
resolve
;
});
const
baseUrl
=
asWebviewUri
(
this
.
workbenchEnvironmentService
,
this
.
id
,
dirname
(
documentUri
));
if
(
!
isWeb
)
{
coreDependencies
=
`<script src="
${
loader
}
"></script>`
;
const
htmlContent
=
this
.
generateContent
(
8
,
coreDependencies
);
const
htmlContent
=
this
.
generateContent
(
8
,
coreDependencies
,
baseUrl
.
toString
()
);
this
.
initialize
(
htmlContent
);
resolveFunc
!
();
}
else
{
...
...
@@ -186,18 +192,20 @@ export class BackLayerWebView extends Disposable {
${
loaderJs
}
</script>
`
;
const
htmlContent
=
this
.
generateContent
(
8
,
coreDependencies
);
const
htmlContent
=
this
.
generateContent
(
8
,
coreDependencies
,
baseUrl
.
toString
());
this
.
initialize
(
htmlContent
);
resolveFunc
!
();
});
}
}
generateContent
(
outputNodePadding
:
number
,
coreDependencies
:
string
)
{
generateContent
(
outputNodePadding
:
number
,
coreDependencies
:
string
,
baseUrl
:
string
)
{
return
html
`
<html lang="en">
<head>
<meta charset="UTF-8">
<base url="
${
baseUrl
}
/"/>
<style>
#container > div > div {
width: 100%;
...
...
@@ -565,7 +573,9 @@ ${loaderJs}
private
_createInset
(
webviewService
:
IWebviewService
,
content
:
string
)
{
const
rootPath
=
URI
.
file
(
path
.
dirname
(
getPathFromAmdModule
(
require
,
''
)));
this
.
localResourceRootsCache
=
[...
this
.
notebookService
.
getNotebookProviderResourceRoots
(),
rootPath
];
const
workspaceFolders
=
this
.
contextService
.
getWorkspace
().
folders
.
map
(
x
=>
x
.
uri
);
this
.
localResourceRootsCache
=
[...
this
.
notebookService
.
getNotebookProviderResourceRoots
(),
...
workspaceFolders
,
rootPath
];
const
webview
=
webviewService
.
createWebviewElement
(
this
.
id
,
{
enableFindWidget
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录