Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2c34226f
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,发现更多精彩内容 >>
提交
2c34226f
编写于
1月 13, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Notebook Provider for both ipynb and test.ipynb
上级
6616034c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
93 addition
and
3 deletion
+93
-3
extensions/notebook-test/package.json
extensions/notebook-test/package.json
+10
-0
extensions/notebook-test/src/extension.ts
extensions/notebook-test/src/extension.ts
+2
-1
extensions/notebook-test/src/notebookProvider.ts
extensions/notebook-test/src/notebookProvider.ts
+54
-2
src/vs/workbench/contrib/notebook/browser/contentWidget.ts
src/vs/workbench/contrib/notebook/browser/contentWidget.ts
+7
-0
src/vs/workbench/contrib/notebook/browser/extensionPoint.ts
src/vs/workbench/contrib/notebook/browser/extensionPoint.ts
+4
-0
src/vs/workbench/contrib/notebook/browser/notebook.css
src/vs/workbench/contrib/notebook/browser/notebook.css
+2
-0
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+6
-0
src/vs/workbench/contrib/notebook/common/notebookProvider.ts
src/vs/workbench/contrib/notebook/common/notebookProvider.ts
+8
-0
未找到文件。
extensions/notebook-test/package.json
浏览文件 @
2c34226f
...
...
@@ -26,6 +26,16 @@
{
"viewType"
:
"jupyter"
,
"displayName"
:
"Jupyter"
,
"selector"
:
[
{
"filenamePattern"
:
"*.ipynb"
,
"excludeFileNamePattern"
:
"*.test.ipynb"
}
]
},
{
"viewType"
:
"jupyterTest"
,
"displayName"
:
"Jupyter Test"
,
"selector"
:
[
{
"filenamePattern"
:
"*.test.ipynb"
...
...
extensions/notebook-test/src/extension.ts
浏览文件 @
2c34226f
...
...
@@ -9,6 +9,7 @@ import { NotebookProvider } from './notebookProvider';
export
function
activate
(
context
:
vscode
.
ExtensionContext
)
{
console
.
log
(
context
.
extensionPath
);
context
.
subscriptions
.
push
(
vscode
.
window
.
registerNotebookProvider
(
'
jupyter
'
,
new
NotebookProvider
(
context
.
extensionPath
)));
context
.
subscriptions
.
push
(
vscode
.
window
.
registerNotebookProvider
(
'
jupyter
'
,
new
NotebookProvider
(
context
.
extensionPath
,
true
)));
context
.
subscriptions
.
push
(
vscode
.
window
.
registerNotebookProvider
(
'
jupyterTest
'
,
new
NotebookProvider
(
context
.
extensionPath
,
false
)));
}
extensions/notebook-test/src/notebookProvider.ts
浏览文件 @
2c34226f
...
...
@@ -40,6 +40,10 @@ export class Cell implements vscode.ICell {
outputsFullFilled
()
{
return
this
.
_outputs
&&
this
.
outputs
.
length
===
this
.
_outputs
.
length
;
}
clearOutputs
()
{
this
.
outputs
=
[];
}
}
export
class
JupyterNotebook
implements
vscode
.
INotebook
{
...
...
@@ -56,17 +60,26 @@ export class NotebookProvider implements vscode.NotebookProvider {
onDidChangeNotebook
:
vscode
.
Event
<
{
resource
:
vscode
.
Uri
;
notebook
:
vscode
.
INotebook
;
}
>
=
this
.
_onDidChangeNotebook
.
event
;
private
_notebooks
:
Map
<
string
,
JupyterNotebook
>
=
new
Map
();
constructor
(
private
_extensionPath
:
string
)
{
constructor
(
private
_extensionPath
:
string
,
private
fillOutputs
:
boolean
)
{
}
async
resolveNotebook
(
resource
:
vscode
.
Uri
):
Promise
<
vscode
.
INotebook
|
undefined
>
{
if
(
this
.
_notebooks
.
has
(
resource
.
fsPath
))
{
return
this
.
_notebooks
.
get
(
resource
.
fsPath
);
let
notebook
=
this
.
_notebooks
.
get
(
resource
.
fsPath
);
if
(
!
this
.
fillOutputs
)
{
notebook
?.
cells
.
forEach
(
cell
=>
{
cell
.
clearOutputs
();
});
}
return
notebook
;
}
let
content
=
await
vscode
.
workspace
.
fs
.
readFile
(
resource
);
try
{
let
notebookJSON
=
JSON
.
parse
(
content
.
toString
());
let
notebook
=
new
JupyterNotebook
(
notebookJSON
.
metadata
,
notebookJSON
.
cells
.
map
((
rawCell
:
any
)
=>
{
...
...
@@ -78,6 +91,45 @@ export class NotebookProvider implements vscode.NotebookProvider {
})
);
if
(
this
.
fillOutputs
)
{
let
preloadScript
=
false
;
notebook
!
.
cells
.
forEach
(
cell
=>
{
if
(
cell
.
outputsFullFilled
())
{
return
;
}
if
(
!
preloadScript
)
{
let
containHTML
=
cell
.
containHTML
();
if
(
containHTML
)
{
preloadScript
=
true
;
const
scriptPathOnDisk
=
vscode
.
Uri
.
file
(
path
.
join
(
this
.
_extensionPath
,
'
dist
'
,
'
ipywidgets.js
'
)
);
let
scriptUri
=
scriptPathOnDisk
.
with
({
scheme
:
'
vscode-resource
'
});
cell
.
insertDependencies
(
{
'
output_type
'
:
'
display_data
'
,
'
data
'
:
{
'
text/html
'
:
[
`<script src="
${
scriptUri
}
"></script>\n`
,
]
}
}
);
cell
.
fillInOutputs
();
}
else
{
cell
.
fillInOutputs
();
}
}
else
{
cell
.
fillInOutputs
();
}
});
}
this
.
_notebooks
.
set
(
resource
.
fsPath
,
notebook
);
return
Promise
.
resolve
(
notebook
);
...
...
src/vs/workbench/contrib/notebook/browser/contentWidget.ts
浏览文件 @
2c34226f
...
...
@@ -76,6 +76,13 @@ export class BackLayerWebView extends Disposable {
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
#container > div {
width: 100%;
padding: 9px;
background-color: var(--vscode-list-inactiveSelectionBackground);
}
</style>
</head>
<body style="overflow: hidden;">
<div id='container' class="widgetarea" style="position: absolute;width:100%;"></div>
...
...
src/vs/workbench/contrib/notebook/browser/extensionPoint.ts
浏览文件 @
2c34226f
...
...
@@ -52,6 +52,10 @@ const notebookContribution: IJSONSchema = {
type
:
'
string
'
,
description
:
nls
.
localize
(
'
contributes.notebook.selector.filenamePattern
'
,
'
Glob that the notebook is enabled for.
'
),
},
excludeFileNamePattern
:
{
type
:
'
string
'
,
description
:
nls
.
localize
(
'
contributes.notebook.selector.excludeFileNamePattern
'
,
'
Glob that the notebook is disabled for.
'
)
}
}
}
}
...
...
src/vs/workbench/contrib/notebook/browser/notebook.css
浏览文件 @
2c34226f
...
...
@@ -45,6 +45,8 @@
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.output
{
margin-left
:
24px
;
margin-right
:
24px
;
padding-left
:
8px
;
padding-right
:
8px
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.output
p
{
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
2c34226f
...
...
@@ -416,4 +416,10 @@ registerThemingParticipant((theme, collector) => {
if
(
quoteBorder
)
{
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor blockquote { border-color:
${
quoteBorder
}
; }`
);
}
const
inactiveListItem
=
theme
.
getColor
(
'
list.inactiveSelectionBackground
'
);
if
(
inactiveListItem
)
{
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .output { background-color:
${
inactiveListItem
}
; }`
);
}
});
src/vs/workbench/contrib/notebook/common/notebookProvider.ts
浏览文件 @
2c34226f
...
...
@@ -9,6 +9,7 @@ import { basename } from 'vs/base/common/resources';
export
interface
NotebookSelector
{
readonly
filenamePattern
?:
string
;
readonly
excludeFileNamePattern
?:
string
;
}
export
class
NotebookProviderInfo
{
...
...
@@ -34,6 +35,13 @@ export class NotebookProviderInfo {
static
selectorMatches
(
selector
:
NotebookSelector
,
resource
:
URI
):
boolean
{
if
(
selector
.
filenamePattern
)
{
if
(
glob
.
match
(
selector
.
filenamePattern
.
toLowerCase
(),
basename
(
resource
).
toLowerCase
()))
{
if
(
selector
.
excludeFileNamePattern
)
{
if
(
glob
.
match
(
selector
.
excludeFileNamePattern
.
toLowerCase
(),
basename
(
resource
).
toLowerCase
()))
{
// should exclude
return
false
;
}
}
return
true
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录