Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
207fece6
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
207fece6
编写于
10月 25, 2021
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Remove Jupyter specific loader special case (#126939)"
This reverts commit
efe0678e
. Fixes #132557
上级
b498b7d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
11 deletion
+76
-11
src/vs/workbench/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
...h/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
...orkbench/contrib/notebook/browser/notebookEditorWidget.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+73
-8
未找到文件。
src/vs/workbench/contrib/notebook/browser/diff/notebookTextDiffEditor.ts
浏览文件 @
207fece6
...
...
@@ -382,7 +382,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
this
.
_modifiedWebview
=
this
.
instantiationService
.
createInstance
(
BackLayerWebView
,
this
,
id
,
resource
,
this
.
_notebookOptions
.
computeDiffWebviewOptions
(),
undefined
)
as
BackLayerWebView
<
IDiffCellInfo
>
;
// attach the webview container to the DOM tree first
this
.
_list
.
rowsContainer
.
insertAdjacentElement
(
'
afterbegin
'
,
this
.
_modifiedWebview
.
element
);
this
.
_modifiedWebview
.
createWebview
();
await
this
.
_modifiedWebview
.
createWebview
();
this
.
_modifiedWebview
.
element
.
style
.
width
=
`calc(50% - 16px)`
;
this
.
_modifiedWebview
.
element
.
style
.
left
=
`calc(50%)`
;
}
...
...
@@ -395,7 +395,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
this
.
_originalWebview
=
this
.
instantiationService
.
createInstance
(
BackLayerWebView
,
this
,
id
,
resource
,
this
.
_notebookOptions
.
computeDiffWebviewOptions
(),
undefined
)
as
BackLayerWebView
<
IDiffCellInfo
>
;
// attach the webview container to the DOM tree first
this
.
_list
.
rowsContainer
.
insertAdjacentElement
(
'
afterbegin
'
,
this
.
_originalWebview
.
element
);
this
.
_originalWebview
.
createWebview
();
await
this
.
_originalWebview
.
createWebview
();
this
.
_originalWebview
.
element
.
style
.
width
=
`calc(50% - 16px)`
;
this
.
_originalWebview
.
element
.
style
.
left
=
`16px`
;
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
浏览文件 @
207fece6
...
...
@@ -1233,7 +1233,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
throw
new
Error
(
'
Notebook output webview object is not created successfully.
'
);
}
this
.
_webview
.
createWebview
();
await
this
.
_webview
.
createWebview
();
if
(
!
this
.
_webview
.
webview
)
{
throw
new
Error
(
'
Notebook output webview element was not created successfully.
'
);
}
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
207fece6
...
...
@@ -10,8 +10,8 @@ import { VSBuffer } from 'vs/base/common/buffer';
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
getExtensionForMimeType
}
from
'
vs/base/common/mime
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
FileAccess
,
Schemas
}
from
'
vs/base/common/network
'
;
import
{
isMacintosh
,
isWeb
}
from
'
vs/base/common/platform
'
;
import
{
dirname
,
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
UUID
from
'
vs/base/common/uuid
'
;
...
...
@@ -96,6 +96,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Disposable {
private
readonly
_onMessage
=
this
.
_register
(
new
Emitter
<
INotebookWebviewMessage
>
());
private
readonly
_preloadsCache
=
new
Set
<
string
>
();
public
readonly
onMessage
:
Event
<
INotebookWebviewMessage
>
=
this
.
_onMessage
.
event
;
private
_initalized
?:
Promise
<
void
>
;
private
_disposed
=
false
;
private
_currentKernel
?:
INotebookKernel
;
...
...
@@ -215,7 +216,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Disposable {
};
}
private
generateContent
(
baseUrl
:
string
)
{
private
generateContent
(
coreDependencies
:
string
,
baseUrl
:
string
)
{
const
renderersData
=
this
.
getRendererData
();
const
preloadScript
=
preloadsScriptStr
(
this
.
options
,
...
...
@@ -356,8 +357,13 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Disposable {
</style>
</head>
<body style="overflow: hidden;">
<script>
self.require = {};
</script>
${
coreDependencies
}
<div id='container' class="widgetarea" style="position: absolute;width:100%;top: 0px"></div>
<script type="module">
${
preloadScript
}
</script>
<div id="container" class="widgetarea" style="position: absolute; width:100%; top: 0px"></div>
<script type="module" nonce="
${
this
.
nonce
}
">
${
preloadScript
}
</script>
</body>
</html>`
;
}
...
...
@@ -402,11 +408,70 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Disposable {
return
!!
this
.
webview
;
}
createWebview
():
void
{
async
createWebview
():
Promise
<
void
>
{
const
baseUrl
=
this
.
asWebviewUri
(
dirname
(
this
.
documentUri
),
undefined
);
const
htmlContent
=
this
.
generateContent
(
baseUrl
.
toString
());
this
.
_initialize
(
htmlContent
);
return
;
// Python notebooks assume that requirejs is a global.
// For all other notebooks, they need to provide their own loader.
if
(
!
this
.
documentUri
.
path
.
toLowerCase
().
endsWith
(
'
.ipynb
'
))
{
const
htmlContent
=
this
.
generateContent
(
''
,
baseUrl
.
toString
());
this
.
_initialize
(
htmlContent
);
return
;
}
let
coreDependencies
=
''
;
let
resolveFunc
:
()
=>
void
;
this
.
_initalized
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
resolveFunc
=
resolve
;
});
if
(
!
isWeb
)
{
const
loaderUri
=
FileAccess
.
asFileUri
(
'
vs/loader.js
'
,
require
);
const
loader
=
this
.
asWebviewUri
(
loaderUri
,
undefined
);
coreDependencies
=
`<script src="
${
loader
}
"></script><script>
var requirejs = (function() {
return require;
}());
</script>`
;
const
htmlContent
=
this
.
generateContent
(
coreDependencies
,
baseUrl
.
toString
());
this
.
_initialize
(
htmlContent
);
resolveFunc
!
();
}
else
{
const
loaderUri
=
FileAccess
.
asBrowserUri
(
'
vs/loader.js
'
,
require
);
fetch
(
loaderUri
.
toString
(
true
)).
then
(
async
response
=>
{
if
(
response
.
status
!==
200
)
{
throw
new
Error
(
response
.
statusText
);
}
const
loaderJs
=
await
response
.
text
();
coreDependencies
=
`
<script>
${
loaderJs
}
</script>
<script>
var requirejs = (function() {
return require;
}());
</script>
`
;
const
htmlContent
=
this
.
generateContent
(
coreDependencies
,
baseUrl
.
toString
());
this
.
_initialize
(
htmlContent
);
resolveFunc
!
();
},
error
=>
{
// the fetch request is rejected
const
htmlContent
=
this
.
generateContent
(
coreDependencies
,
baseUrl
.
toString
());
this
.
_initialize
(
htmlContent
);
resolveFunc
!
();
});
}
await
this
.
_initalized
;
}
private
_initialize
(
content
:
string
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录