Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6852fbc0
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,发现更多精彩内容 >>
提交
6852fbc0
编写于
3月 25, 2020
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Notebook cell layout tweaks
上级
f308a0a5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
27 deletion
+37
-27
src/vs/workbench/contrib/notebook/browser/constants.ts
src/vs/workbench/contrib/notebook/browser/constants.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/notebook.css
src/vs/workbench/contrib/notebook/browser/notebook.css
+11
-6
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+6
-4
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+16
-13
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
...h/contrib/notebook/browser/viewModel/codeCellViewModel.ts
+2
-2
未找到文件。
src/vs/workbench/contrib/notebook/browser/constants.ts
浏览文件 @
6852fbc0
...
...
@@ -20,11 +20,11 @@ export const COPY_CELL_DOWN_COMMAND_ID = 'workbench.notebook.cell.copyDown';
export
const
EXECUTE_CELL_COMMAND_ID
=
'
workbench.notebook.cell.execute
'
;
// Cell sizing related
export
const
CELL_MARGIN
=
32
;
export
const
CELL_MARGIN
=
20
;
export
const
CELL_RUN_GUTTER
=
32
;
// TODO should be dynamic based on execution order width, and runnable enablement
export
const
EDITOR_TOP_PADDING
=
8
;
export
const
EDITOR_BOTTOM_PADDING
=
8
;
export
const
EDITOR_TOOLBAR_HEIGHT
=
22
;
export
const
RUN_BUTTON_WIDTH
=
30
;
// Cell context keys
export
const
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
=
'
notebookCellType
'
;
// code, markdown
...
...
src/vs/workbench/contrib/notebook/browser/notebook.css
浏览文件 @
6852fbc0
...
...
@@ -132,28 +132,33 @@
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
.cell
.run-button-container
{
width
:
30px
;
position
:
relative
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
.cell
.run-button-container
.monaco-toolbar
{
margin-top
:
8
px
;
margin-top
:
5
px
;
visibility
:
hidden
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
:hover
.cell
.run-button-container
.monaco-toolbar
,
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row.focused
.cell
.run-button-container
.monaco-toolbar
{
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
.cell
.run-button-container
.monaco-toolbar
.codicon-play
{
margin-right
:
8px
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
:hover
.cell.runnable
.run-button-container
.monaco-toolbar
,
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row.focused
.cell.runnable
.run-button-container
.monaco-toolbar
{
visibility
:
visible
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
.cell
.run-button-container
.execution-count-label
{
position
:
absolute
;
top
:
8
px
;
top
:
2
px
;
font-size
:
12px
;
visibility
:
visible
;
white-space
:
pre
;
width
:
100%
;
text-align
:
center
;
padding-right
:
2px
;
box-sizing
:
border-box
;
}
.monaco-workbench
.part.editor
>
.content
.notebook-editor
.monaco-list-row
:hover
.cell
.run-button-container
.execution-count-label
,
...
...
@@ -187,7 +192,7 @@
width
:
6px
;
border-left-width
:
2px
;
border-left-style
:
solid
;
left
:
2
8
px
;
left
:
2
0
px
;
top
:
22px
;
bottom
:
8px
;
visibility
:
hidden
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
6852fbc0
...
...
@@ -40,7 +40,7 @@ import { NotebookViewModel, INotebookEditorViewState, IModelDecorationsChangeAcc
import
{
IEditorGroupView
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
CELL_MARGIN
,
RUN_BUTTON_WIDTH
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CELL_MARGIN
,
CELL_RUN_GUTTER
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
Color
,
RGBA
}
from
'
vs/base/common/color
'
;
import
{
NotebookEventDispatcher
,
NotebookLayoutChangedEvent
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
...
...
@@ -794,8 +794,10 @@ registerThemingParticipant((theme, collector) => {
}
// Cell Margin
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .monaco-list-row > div.cell {
padding
: 8px
${
CELL_MARGIN
}
px 8px
${
CELL_MARGIN
}
px; }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .output { margin: 8px
${
CELL_MARGIN
}
px 8px
${
CELL_MARGIN
+
RUN_BUTTON_WIDTH
}
px }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .monaco-list-row > div.cell {
margin
: 8px
${
CELL_MARGIN
}
px 8px
${
CELL_MARGIN
}
px; }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .output { margin: 8px
${
CELL_MARGIN
}
px 8px
${
CELL_MARGIN
+
CELL_RUN_GUTTER
}
px }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .cell .cell-editor-container { width: calc(100% -
${
RUN_BUTTON_WIDTH
}
px); }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .cell .cell-editor-container { width: calc(100% -
${
CELL_RUN_GUTTER
}
px); }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .monaco-list-row > div.cell.markdown { padding-left:
${
CELL_RUN_GUTTER
}
px; }`
);
collector
.
addRule
(
`.monaco-workbench .part.editor > .content .notebook-editor .cell .run-button-container { width:
${
CELL_RUN_GUTTER
}
px; }`
);
});
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
6852fbc0
...
...
@@ -6,6 +6,7 @@
import
{
getZoomLevel
}
from
'
vs/base/browser/browser
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
{
IListRenderer
,
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
ProgressBar
}
from
'
vs/base/browser/ui/progressbar/progressbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -16,15 +17,16 @@ import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
BareFontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
import
{
ContextAwareMenuEntryActionViewItem
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
MenuItemAction
,
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMenu
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellRenderTemplate
,
CellRunState
,
ICellViewModel
,
INotebookEditor
,
CellEditState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY
,
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
ExecuteCellAction
,
INotebookCellActionContext
}
from
'
vs/workbench/contrib/notebook/browser/contrib/notebookActions
'
;
import
{
CellEditState
,
CellRenderTemplate
,
CellRunState
,
ICellViewModel
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellMenus
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellMenus
'
;
import
{
CodeCell
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/codeCell
'
;
import
{
StatefullMarkdownCell
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/markdownCell
'
;
...
...
@@ -32,8 +34,6 @@ import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewMod
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
CellKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookCellActionContext
,
ExecuteCellAction
}
from
'
vs/workbench/contrib/notebook/browser/contrib/notebookActions
'
;
import
{
ProgressBar
}
from
'
vs/base/browser/ui/progressbar/progressbar
'
;
const
$
=
DOM
.
$
;
...
...
@@ -361,19 +361,22 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
templateData
.
executionOrderLabel
!
.
innerText
=
executionOrdeerLabel
;
}
if
(
templateData
.
executionOrderLabel
)
{
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
code
'
);
const
cellEditableKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
!!
(
element
.
metadata
?.
editable
));
const
updateForMetadata
=
()
=>
{
const
metadata
=
element
.
getEvaluatedMetadata
(
this
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
metadata
);
DOM
.
toggleClass
(
templateData
.
cellContainer
,
'
runnable
'
,
!!
metadata
.
runnable
);
renderExecutionOrder
();
}
cellEditableKey
.
set
(
!!
metadata
.
editable
);
};
updateForMetadata
();
elementDisposable
.
add
(
element
.
onDidChangeMetadata
(()
=>
{
renderExecutionOrder
();
cellEditableKey
.
set
(
!!
element
.
metadata
?.
editable
);
updateForMetadata
();
}));
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
code
'
);
const
cellEditableKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
!!
(
element
.
metadata
?.
editable
));
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
);
const
toolbarContext
=
<
INotebookCellActionContext
>
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
浏览文件 @
6852fbc0
...
...
@@ -8,7 +8,7 @@ import * as UUID from 'vs/base/common/uuid';
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
CELL_MARGIN
,
RUN_BUTTON_WIDTH
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
CELL_MARGIN
,
CELL_RUN_GUTTER
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
ICellViewModel
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
ICell
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellViewModel
}
from
'
./baseCellViewModel
'
;
...
...
@@ -109,7 +109,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
?
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
16
+
outputTotalHeight
:
EDITOR_TOOLBAR_HEIGHT
+
this
.
editorHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
+
outputTotalHeight
;
const
indicatorHeight
=
totalHeight
-
EDITOR_TOOLBAR_HEIGHT
-
16
;
const
editorWidth
=
state
.
outerWidth
!==
undefined
?
state
.
outerWidth
-
CELL_MARGIN
*
2
-
RUN_BUTTON_WIDTH
:
0
;
const
editorWidth
=
state
.
outerWidth
!==
undefined
?
state
.
outerWidth
-
CELL_MARGIN
*
2
-
CELL_RUN_GUTTER
:
0
;
this
.
_layoutInfo
=
{
fontInfo
:
state
.
font
||
null
,
editorHeight
:
this
.
_editorHeight
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录