Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b02ef2ab
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,发现更多精彩内容 >>
提交
b02ef2ab
编写于
4月 23, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extract CellEditorOptions which can update based on the underlying config, #95956
上级
df1a7b0e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
90 addition
and
32 deletion
+90
-32
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+2
-1
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+77
-30
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
...h/contrib/notebook/browser/view/renderers/markdownCell.ts
+11
-1
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
b02ef2ab
...
...
@@ -10,7 +10,7 @@ import { IMouseWheelEvent, StandardMouseEvent } from 'vs/base/browser/mouseEvent
import
{
CancellationToken
,
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
Color
,
RGBA
}
from
'
vs/base/common/color
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
DisposableStore
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
DisposableStore
,
MutableDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
BareFontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
...
...
@@ -271,6 +271,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this
.
list
.
rowsContainer
.
appendChild
(
this
.
webview
.
element
);
this
.
_register
(
this
.
list
);
this
.
_register
(
combinedDisposable
(...
renders
));
// transparent cover
this
.
webviewTransparentCover
=
DOM
.
append
(
this
.
list
.
rowsContainer
,
$
(
'
.webview-cover
'
));
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
b02ef2ab
...
...
@@ -13,7 +13,7 @@ import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import
{
IAction
,
ActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
escape
}
from
'
vs/base/common/strings
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
DisposableStore
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
...
...
@@ -48,6 +48,7 @@ import { domEvent } from 'vs/base/browser/event';
import
{
tokenizeLineToHTML
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
BaseCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
const
$
=
DOM
.
$
;
...
...
@@ -94,46 +95,88 @@ export class CodiconActionViewItem extends ContextAwareMenuEntryActionViewItem {
}
}
export
class
CellEditorOptions
{
private
static
fixedEditorOptions
:
IEditorOptions
=
{
padding
:
{
top
:
EDITOR_TOP_PADDING
,
bottom
:
EDITOR_BOTTOM_PADDING
},
scrollBeyondLastLine
:
false
,
scrollbar
:
{
verticalScrollbarSize
:
14
,
horizontal
:
'
auto
'
,
useShadows
:
true
,
verticalHasArrows
:
false
,
horizontalHasArrows
:
false
,
alwaysConsumeMouseWheel
:
false
},
renderLineHighlightOnlyWhenFocus
:
true
,
overviewRulerLanes
:
0
,
selectOnLineNumbers
:
false
,
lineNumbers
:
'
off
'
,
lineDecorationsWidth
:
0
,
glyphMargin
:
false
,
fixedOverflowWidgets
:
false
,
minimap
:
{
enabled
:
false
},
};
private
_value
:
IEditorOptions
;
private
_disposable
:
IDisposable
;
private
readonly
_onDidChange
=
new
Emitter
<
IEditorOptions
>
();
readonly
onDidChange
:
Event
<
IEditorOptions
>
=
this
.
_onDidChange
.
event
;
constructor
(
configurationService
:
IConfigurationService
,
language
:
string
)
{
this
.
_disposable
=
configurationService
.
onDidChangeConfiguration
(
e
=>
{
if
(
e
.
affectsConfiguration
(
'
editor
'
))
{
this
.
_value
=
computeEditorOptions
();
this
.
_onDidChange
.
fire
(
this
.
value
);
}
});
const
computeEditorOptions
=
()
=>
{
const
editorOptions
=
deepClone
(
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
,
{
overrideIdentifier
:
language
}));
return
{
...
editorOptions
,
...
CellEditorOptions
.
fixedEditorOptions
};
};
this
.
_value
=
computeEditorOptions
();
}
dispose
():
void
{
this
.
_onDidChange
.
dispose
();
this
.
_disposable
.
dispose
();
}
get
value
():
IEditorOptions
{
return
this
.
_value
;
}
}
abstract
class
AbstractCellRenderer
{
protected
editorOptions
:
I
EditorOptions
;
protected
editorOptions
:
Cell
EditorOptions
;
private
actionRunner
=
new
ActionRunner
();
constructor
(
protected
readonly
instantiationService
:
IInstantiationService
,
protected
readonly
notebookEditor
:
INotebookEditor
,
protected
readonly
contextMenuService
:
IContextMenuService
,
private
readonly
configurationService
:
IConfigurationService
,
configurationService
:
IConfigurationService
,
private
readonly
keybindingService
:
IKeybindingService
,
private
readonly
notificationService
:
INotificationService
,
protected
readonly
contextKeyService
:
IContextKeyService
,
language
:
string
,
protected
readonly
dndController
:
CellDragAndDropController
)
{
const
editorOptions
=
deepClone
(
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
,
{
overrideIdentifier
:
language
}));
this
.
editorOptions
=
{
...
editorOptions
,
padding
:
{
top
:
EDITOR_TOP_PADDING
,
bottom
:
EDITOR_BOTTOM_PADDING
},
scrollBeyondLastLine
:
false
,
scrollbar
:
{
verticalScrollbarSize
:
14
,
horizontal
:
'
auto
'
,
useShadows
:
true
,
verticalHasArrows
:
false
,
horizontalHasArrows
:
false
,
alwaysConsumeMouseWheel
:
false
},
renderLineHighlightOnlyWhenFocus
:
true
,
overviewRulerLanes
:
0
,
selectOnLineNumbers
:
false
,
lineNumbers
:
'
off
'
,
lineDecorationsWidth
:
0
,
glyphMargin
:
false
,
fixedOverflowWidgets
:
false
,
minimap
:
{
enabled
:
false
},
};
this
.
editorOptions
=
new
CellEditorOptions
(
configurationService
,
language
);
}
dispose
()
{
this
.
editorOptions
.
dispose
();
}
protected
createBottomCellToolbar
(
container
:
HTMLElement
):
ToolBar
{
...
...
@@ -349,7 +392,9 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
if
(
height
)
{
const
elementDisposables
=
templateData
.
elementDisposables
;
elementDisposables
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
const
markdownCell
=
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
.
value
,
this
.
instantiationService
);
elementDisposables
.
add
(
this
.
editorOptions
.
onDidChange
(
newValue
=>
markdownCell
.
updateEditorOptions
(
newValue
)));
elementDisposables
.
add
(
markdownCell
);
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
markdown
'
);
...
...
@@ -620,13 +665,15 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
const
editorPart
=
DOM
.
append
(
cellContainer
,
$
(
'
.cell-editor-part
'
));
const
editorContainer
=
DOM
.
append
(
editorPart
,
$
(
'
.cell-editor-container
'
));
const
editor
=
this
.
instantiationService
.
createInstance
(
CodeEditorWidget
,
editorContainer
,
{
...
this
.
editorOptions
,
...
this
.
editorOptions
.
value
,
dimension
:
{
width
:
0
,
height
:
0
}
},
{});
disposables
.
add
(
this
.
editorOptions
.
onDidChange
(
newValue
=>
editor
.
updateOptions
(
newValue
)));
const
progressBar
=
new
ProgressBar
(
editorPart
);
progressBar
.
hide
();
disposables
.
add
(
progressBar
);
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
浏览文件 @
b02ef2ab
...
...
@@ -19,7 +19,9 @@ import { CellFoldingState } from 'vs/workbench/contrib/notebook/browser/contrib/
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
export
class
StatefullMarkdownCell
extends
Disposable
{
private
editor
:
CodeEditorWidget
|
null
=
null
;
private
editorOptions
:
IEditorOptions
;
private
markdownContainer
:
HTMLElement
;
private
editingContainer
:
HTMLElement
;
...
...
@@ -37,6 +39,7 @@ export class StatefullMarkdownCell extends Disposable {
this
.
markdownContainer
=
templateData
.
cellContainer
;
this
.
editingContainer
=
templateData
.
editingContainer
;
this
.
editorOptions
=
editorOptions
;
this
.
localDisposables
=
new
DisposableStore
();
this
.
_register
(
this
.
localDisposables
);
...
...
@@ -65,7 +68,7 @@ export class StatefullMarkdownCell extends Disposable {
this
.
editingContainer
.
innerHTML
=
''
;
this
.
editor
=
instantiationService
.
createInstance
(
CodeEditorWidget
,
this
.
editingContainer
,
{
...
editorOptions
,
...
this
.
editorOptions
,
dimension
:
{
width
:
width
,
height
:
totalHeight
...
...
@@ -192,6 +195,13 @@ export class StatefullMarkdownCell extends Disposable {
viewUpdate
();
}
updateEditorOptions
(
newValue
:
IEditorOptions
):
any
{
this
.
editorOptions
=
newValue
;
if
(
this
.
editor
)
{
this
.
editor
.
updateOptions
(
this
.
editorOptions
);
}
}
setFoldingIndicator
()
{
switch
(
this
.
foldingState
)
{
case
CellFoldingState
.
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录