Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7e74dc8e
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,发现更多精彩内容 >>
提交
7e74dc8e
编写于
2月 14, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handler -> notebookEditor
上级
55d34d79
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
46 addition
and
46 deletion
+46
-46
src/vs/workbench/contrib/notebook/browser/output/transforms/errorTransform.ts
...trib/notebook/browser/output/transforms/errorTransform.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/output/transforms/richTransform.ts
...ntrib/notebook/browser/output/transforms/richTransform.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/output/transforms/streamTransform.ts
...rib/notebook/browser/output/transforms/streamTransform.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/renderers/backLayerWebView.ts
...ch/contrib/notebook/browser/renderers/backLayerWebView.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts
...kbench/contrib/notebook/browser/renderers/cellRenderer.ts
+14
-14
src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts
.../workbench/contrib/notebook/browser/renderers/codeCell.ts
+14
-14
src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts
...kbench/contrib/notebook/browser/renderers/markdownCell.ts
+9
-9
未找到文件。
src/vs/workbench/contrib/notebook/browser/output/transforms/errorTransform.ts
浏览文件 @
7e74dc8e
...
...
@@ -13,7 +13,7 @@ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookB
class
ErrorTransform
implements
IOutputTransformContribution
{
constructor
(
public
handle
r
:
INotebookEditor
,
public
edito
r
:
INotebookEditor
,
@
IThemeService
private
readonly
themeService
:
IThemeService
)
{
}
...
...
src/vs/workbench/contrib/notebook/browser/output/transforms/richTransform.ts
浏览文件 @
7e74dc8e
...
...
@@ -20,7 +20,7 @@ class RichRenderer implements IOutputTransformContribution {
private
_mdRenderer
:
marked
.
Renderer
=
new
marked
.
Renderer
({
gfm
:
true
});;
constructor
(
public
handle
r
:
INotebookEditor
,
public
notebookEdito
r
:
INotebookEditor
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IModelService
private
readonly
modelService
:
IModelService
,
@
IModeService
private
readonly
modeService
:
IModeService
...
...
@@ -50,8 +50,8 @@ class RichRenderer implements IOutputTransformContribution {
const
textModel
=
this
.
modelService
.
createModel
(
str
,
mode
,
resource
,
false
);
editor
.
setModel
(
textModel
);
let
width
=
this
.
handle
r
.
getListDimension
()
!
.
width
;
let
fontInfo
=
this
.
handle
r
.
getFontInfo
();
let
width
=
this
.
notebookEdito
r
.
getListDimension
()
!
.
width
;
let
fontInfo
=
this
.
notebookEdito
r
.
getFontInfo
();
let
height
=
Math
.
min
(
textModel
.
getLineCount
(),
16
)
*
(
fontInfo
?.
lineHeight
||
18
);
editor
.
layout
({
...
...
src/vs/workbench/contrib/notebook/browser/output/transforms/streamTransform.ts
浏览文件 @
7e74dc8e
...
...
@@ -9,7 +9,7 @@ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookB
class
StreamRenderer
implements
IOutputTransformContribution
{
constructor
(
handle
r
:
INotebookEditor
edito
r
:
INotebookEditor
)
{
}
...
...
src/vs/workbench/contrib/notebook/browser/renderers/backLayerWebView.ts
浏览文件 @
7e74dc8e
...
...
@@ -75,7 +75,7 @@ export class BackLayerWebView extends Disposable {
outputMapping
:
Map
<
string
,
boolean
>
=
new
Map
();
preloadsCache
:
Map
<
string
,
boolean
>
=
new
Map
();
constructor
(
public
webviewService
:
IWebviewService
,
public
notebookService
:
INotebookService
,
public
notebook
Handle
r
:
INotebookEditor
,
public
environmentSerice
:
IEnvironmentService
)
{
constructor
(
public
webviewService
:
IWebviewService
,
public
notebookService
:
INotebookService
,
public
notebook
Edito
r
:
INotebookEditor
,
public
environmentSerice
:
IEnvironmentService
)
{
super
();
this
.
element
=
document
.
createElement
(
'
div
'
);
...
...
@@ -242,7 +242,7 @@ export class BackLayerWebView extends Disposable {
this
.
webview
.
mountTo
(
this
.
element
);
this
.
_register
(
this
.
webview
.
onDidWheel
(
e
=>
{
this
.
notebook
Handle
r
.
triggerScroll
(
e
);
this
.
notebook
Edito
r
.
triggerScroll
(
e
);
}));
this
.
_register
(
this
.
webview
.
onMessage
((
data
:
IMessage
)
=>
{
...
...
@@ -252,10 +252,10 @@ export class BackLayerWebView extends Disposable {
let
outputHeight
=
height
===
0
?
0
:
height
+
16
;
if
(
cell
)
{
const
lineNum
=
cell
.
lineCount
;
const
lineHeight
=
this
.
notebook
Handle
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
lineHeight
=
this
.
notebook
Edito
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
totalHeight
=
lineNum
*
lineHeight
;
cell
.
dynamicHeight
=
totalHeight
+
32
/* code cell padding */
+
outputHeight
;
this
.
notebook
Handle
r
.
layoutNotebookCell
(
cell
,
totalHeight
+
32
/* code cell padding */
+
outputHeight
);
this
.
notebook
Edito
r
.
layoutNotebookCell
(
cell
,
totalHeight
+
32
/* code cell padding */
+
outputHeight
);
}
}
else
if
(
data
.
type
===
'
scroll-ack
'
)
{
// const date = new Date();
...
...
src/vs/workbench/contrib/notebook/browser/renderers/cellRenderer.ts
浏览文件 @
7e74dc8e
...
...
@@ -55,7 +55,7 @@ class AbstractCellRenderer {
protected
editorOptions
:
IEditorOptions
;
constructor
(
protected
handle
r
:
INotebookEditor
,
protected
notebookEdito
r
:
INotebookEditor
,
private
contextMenuService
:
IContextMenuService
,
private
configurationService
:
IConfigurationService
,
language
:
string
...
...
@@ -87,7 +87,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
await
this
.
handle
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
code
'
,
'
above
'
);
await
this
.
notebookEdito
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
code
'
,
'
above
'
);
}
);
actions
.
push
(
insertAbove
);
...
...
@@ -98,7 +98,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
await
this
.
handle
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
code
'
,
'
below
'
);
await
this
.
notebookEdito
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
code
'
,
'
below
'
);
}
);
actions
.
push
(
insertBelow
);
...
...
@@ -109,7 +109,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
await
this
.
handle
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
markdown
'
,
'
above
'
);
await
this
.
notebookEdito
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
markdown
'
,
'
above
'
);
}
);
actions
.
push
(
insertMarkdownAbove
);
...
...
@@ -120,7 +120,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
await
this
.
handle
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
markdown
'
,
'
below
'
);
await
this
.
notebookEdito
r
.
insertEmptyNotebookCell
(
listIndex
,
element
,
'
markdown
'
,
'
below
'
);
}
);
actions
.
push
(
insertMarkdownBelow
);
...
...
@@ -132,7 +132,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
this
.
handle
r
.
editNotebookCell
(
listIndex
,
element
);
this
.
notebookEdito
r
.
editNotebookCell
(
listIndex
,
element
);
}
);
...
...
@@ -144,7 +144,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
this
.
handle
r
.
saveNotebookCell
(
listIndex
,
element
);
this
.
notebookEdito
r
.
saveNotebookCell
(
listIndex
,
element
);
}
);
...
...
@@ -157,7 +157,7 @@ class AbstractCellRenderer {
undefined
,
true
,
async
()
=>
{
this
.
handle
r
.
deleteNotebookCell
(
listIndex
,
element
);
this
.
notebookEdito
r
.
deleteNotebookCell
(
listIndex
,
element
);
}
);
...
...
@@ -183,12 +183,12 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
private
disposables
:
Map
<
CellViewModel
,
DisposableStore
>
=
new
Map
();
constructor
(
handle
r
:
INotebookEditor
,
notehookEdito
r
:
INotebookEditor
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
)
{
super
(
handle
r
,
contextMenuService
,
configurationService
,
'
markdown
'
);
super
(
notehookEdito
r
,
contextMenuService
,
configurationService
,
'
markdown
'
);
}
get
templateId
()
{
...
...
@@ -244,7 +244,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
this
.
showContextMenu
(
listIndex
,
element
,
e
.
posx
,
top
+
height
);
}));
elementDisposable
!
.
add
(
new
StatefullMarkdownCell
(
this
.
handle
r
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
elementDisposable
!
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEdito
r
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
}
}
...
...
@@ -265,12 +265,12 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
private
disposables
:
Map
<
CellViewModel
,
DisposableStore
>
=
new
Map
();
constructor
(
protected
handle
r
:
INotebookEditor
,
protected
notebookEdito
r
:
INotebookEditor
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
)
{
super
(
handle
r
,
contextMenuService
,
configurationService
,
'
python
'
);
super
(
notebookEdito
r
,
contextMenuService
,
configurationService
,
'
python
'
);
}
get
templateId
()
{
...
...
@@ -329,7 +329,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
this
.
showContextMenu
(
listIndex
,
element
,
e
.
posx
,
top
+
height
);
}));
elementDisposable
?.
add
(
new
CodeCell
(
this
.
handle
r
,
element
,
templateData
,
height
));
elementDisposable
?.
add
(
new
CodeCell
(
this
.
notebookEdito
r
,
element
,
templateData
,
height
));
}
disposeTemplate
(
templateData
:
CellRenderTemplate
):
void
{
...
...
src/vs/workbench/contrib/notebook/browser/renderers/codeCell.ts
浏览文件 @
7e74dc8e
...
...
@@ -11,7 +11,7 @@ import { CellRenderTemplate, INotebookEditor } from 'vs/workbench/contrib/notebo
export
class
CodeCell
extends
Disposable
{
constructor
(
handle
r
:
INotebookEditor
,
notebookEdito
r
:
INotebookEditor
,
viewCell
:
CellViewModel
,
templateData
:
CellRenderTemplate
,
height
:
number
|
undefined
...
...
@@ -19,7 +19,7 @@ export class CodeCell extends Disposable {
super
();
let
width
;
const
listDimension
=
handle
r
.
getListDimension
();
const
listDimension
=
notebookEdito
r
.
getListDimension
();
if
(
listDimension
)
{
width
=
listDimension
.
width
-
CELL_MARGIN
*
2
;
}
else
{
...
...
@@ -27,7 +27,7 @@ export class CodeCell extends Disposable {
}
const
lineNum
=
viewCell
.
lineCount
;
const
lineHeight
=
handle
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
lineHeight
=
notebookEdito
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
totalHeight
=
lineNum
*
lineHeight
;
const
model
=
viewCell
.
getTextModel
();
templateData
.
editor
?.
setModel
(
model
);
...
...
@@ -80,9 +80,9 @@ export class CodeCell extends Disposable {
if
(
viewCell
.
outputs
.
length
)
{
let
outputHeight
=
templateData
.
outputContainer
!
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
32
+
outputHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
32
+
outputHeight
);
}
else
{
handle
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
16
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
16
);
}
}
}
...
...
@@ -93,20 +93,20 @@ export class CodeCell extends Disposable {
let
hasDynamicHeight
=
true
;
for
(
let
i
=
0
;
i
<
viewCell
.
outputs
.
length
;
i
++
)
{
let
outputItemDiv
=
document
.
createElement
(
'
div
'
);
let
result
=
handle
r
.
getOutputRenderer
().
render
(
viewCell
.
outputs
[
i
],
outputItemDiv
);
let
result
=
notebookEdito
r
.
getOutputRenderer
().
render
(
viewCell
.
outputs
[
i
],
outputItemDiv
);
templateData
.
outputContainer
?.
appendChild
(
outputItemDiv
);
if
(
result
)
{
hasDynamicHeight
=
hasDynamicHeight
||
result
?.
hasDynamicHeight
;
if
(
result
.
shadowContent
)
{
hasDynamicHeight
=
false
;
handle
r
.
createInset
(
viewCell
,
i
,
result
.
shadowContent
,
totalHeight
+
8
);
notebookEdito
r
.
createInset
(
viewCell
,
i
,
result
.
shadowContent
,
totalHeight
+
8
);
}
}
}
if
(
height
!==
undefined
&&
hasDynamicHeight
)
{
let
clientHeight
=
templateData
.
outputContainer
!
.
clientHeight
;
let
listDimension
=
handle
r
.
getListDimension
();
let
listDimension
=
notebookEdito
r
.
getListDimension
();
let
dimension
=
listDimension
?
{
width
:
listDimension
.
width
-
CELL_MARGIN
*
2
,
height
:
clientHeight
...
...
@@ -116,7 +116,7 @@ export class CodeCell extends Disposable {
let
height
=
elementSizeObserver
.
getHeight
();
if
(
clientHeight
!==
height
)
{
viewCell
.
dynamicHeight
=
totalHeight
+
32
+
height
;
handle
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
height
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
height
);
}
elementSizeObserver
.
dispose
();
...
...
@@ -124,7 +124,7 @@ export class CodeCell extends Disposable {
});
elementSizeObserver
.
startObserving
();
viewCell
.
dynamicHeight
=
totalHeight
+
32
+
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
clientHeight
);
this
.
_register
(
elementSizeObserver
);
}
...
...
@@ -135,20 +135,20 @@ export class CodeCell extends Disposable {
let
hasDynamicHeight
=
true
;
for
(
let
i
=
0
;
i
<
viewCell
.
outputs
.
length
;
i
++
)
{
let
outputItemDiv
=
document
.
createElement
(
'
div
'
);
let
result
=
handle
r
.
getOutputRenderer
().
render
(
viewCell
.
outputs
[
i
],
outputItemDiv
);
let
result
=
notebookEdito
r
.
getOutputRenderer
().
render
(
viewCell
.
outputs
[
i
],
outputItemDiv
);
templateData
.
outputContainer
?.
appendChild
(
outputItemDiv
);
if
(
result
)
{
hasDynamicHeight
=
hasDynamicHeight
||
result
?.
hasDynamicHeight
;
if
(
result
.
shadowContent
)
{
hasDynamicHeight
=
false
;
handle
r
.
createInset
(
viewCell
,
i
,
result
.
shadowContent
,
totalHeight
+
8
);
notebookEdito
r
.
createInset
(
viewCell
,
i
,
result
.
shadowContent
,
totalHeight
+
8
);
}
}
}
if
(
height
!==
undefined
&&
hasDynamicHeight
)
{
let
clientHeight
=
templateData
.
outputContainer
!
.
clientHeight
;
let
listDimension
=
handle
r
.
getListDimension
();
let
listDimension
=
notebookEdito
r
.
getListDimension
();
let
dimension
=
listDimension
?
{
width
:
listDimension
.
width
-
CELL_MARGIN
*
2
,
height
:
clientHeight
...
...
@@ -158,7 +158,7 @@ export class CodeCell extends Disposable {
let
height
=
elementSizeObserver
.
getHeight
();
if
(
clientHeight
!==
height
)
{
viewCell
.
dynamicHeight
=
totalHeight
+
32
+
height
;
handle
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
height
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
height
);
}
elementSizeObserver
.
dispose
();
...
...
src/vs/workbench/contrib/notebook/browser/renderers/markdownCell.ts
浏览文件 @
7e74dc8e
...
...
@@ -20,7 +20,7 @@ export class StatefullMarkdownCell extends Disposable {
private
localDisposables
:
DisposableStore
;
constructor
(
handle
r
:
INotebookEditor
,
notebookEdito
r
:
INotebookEditor
,
viewCell
:
CellViewModel
,
templateData
:
CellRenderTemplate
,
editorOptions
:
IEditorOptions
,
...
...
@@ -37,7 +37,7 @@ export class StatefullMarkdownCell extends Disposable {
if
(
viewCell
.
isEditing
)
{
// switch to editing mode
let
width
;
const
listDimension
=
handle
r
.
getListDimension
();
const
listDimension
=
notebookEdito
r
.
getListDimension
();
if
(
listDimension
)
{
width
=
listDimension
.
width
-
CELL_MARGIN
*
2
;
}
else
{
...
...
@@ -45,7 +45,7 @@ export class StatefullMarkdownCell extends Disposable {
}
const
lineNum
=
viewCell
.
lineCount
;
const
lineHeight
=
handle
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
lineHeight
=
notebookEdito
r
.
getFontInfo
()?.
lineHeight
??
18
;
const
totalHeight
=
Math
.
max
(
lineNum
,
1
)
*
lineHeight
;
if
(
this
.
editor
)
{
...
...
@@ -84,7 +84,7 @@ export class StatefullMarkdownCell extends Disposable {
this
.
cellContainer
.
appendChild
(
renderedHTML
);
}
handle
r
.
layoutNotebookCell
(
viewCell
,
realContentHeight
+
32
+
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
realContentHeight
+
32
+
clientHeight
);
}));
this
.
localDisposables
.
add
(
this
.
editor
.
onDidContentSizeChange
(
e
=>
{
...
...
@@ -98,7 +98,7 @@ export class StatefullMarkdownCell extends Disposable {
}
);
const
clientHeight
=
this
.
cellContainer
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
32
+
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
e
.
contentHeight
+
32
+
clientHeight
);
}
}));
...
...
@@ -126,20 +126,20 @@ export class StatefullMarkdownCell extends Disposable {
this
.
cellContainer
.
appendChild
(
renderedHTML
);
this
.
localDisposables
.
add
(
markdownRenderer
.
onDidUpdateRender
(()
=>
{
const
clientHeight
=
this
.
cellContainer
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
}));
}
}
const
clientHeight
=
this
.
cellContainer
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
totalHeight
+
32
+
clientHeight
);
this
.
editor
.
focus
();
}
else
{
if
(
this
.
editor
)
{
// switch from editing mode
this
.
editingContainer
!
.
style
.
display
=
'
none
'
;
const
clientHeight
=
this
.
cellContainer
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
}
else
{
// first time, readonly mode
this
.
editingContainer
!
.
style
.
display
=
'
none
'
;
...
...
@@ -153,7 +153,7 @@ export class StatefullMarkdownCell extends Disposable {
this
.
localDisposables
.
add
(
markdownRenderer
.
onDidUpdateRender
(()
=>
{
const
clientHeight
=
this
.
cellContainer
.
clientHeight
;
handle
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
notebookEdito
r
.
layoutNotebookCell
(
viewCell
,
clientHeight
);
}));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录