Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7e56fc02
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,发现更多精彩内容 >>
提交
7e56fc02
编写于
3月 19, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Contributions for notebook cell toolbar
上级
f8083181
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
135 addition
and
16 deletion
+135
-16
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+1
-0
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+23
-2
src/vs/workbench/api/common/menusExtensionPoint.ts
src/vs/workbench/api/common/menusExtensionPoint.ts
+6
-0
src/vs/workbench/contrib/notebook/browser/constants.ts
src/vs/workbench/contrib/notebook/browser/constants.ts
+3
-0
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+6
-0
src/vs/workbench/contrib/notebook/browser/view/renderers/cellMenus.ts
...ench/contrib/notebook/browser/view/renderers/cellMenus.ts
+38
-0
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+51
-13
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
...ntrib/notebook/browser/viewModel/notebookCellViewModel.ts
+6
-0
未找到文件。
src/vs/platform/actions/common/actions.ts
浏览文件 @
7e56fc02
...
...
@@ -114,6 +114,7 @@ export class MenuId {
static
readonly
CommentThreadActions
=
new
MenuId
(
'
CommentThreadActions
'
);
static
readonly
CommentTitle
=
new
MenuId
(
'
CommentTitle
'
);
static
readonly
CommentActions
=
new
MenuId
(
'
CommentActions
'
);
static
readonly
NotebookCellTitle
=
new
MenuId
(
'
NotebookCellTitle
'
);
static
readonly
BulkEditTitle
=
new
MenuId
(
'
BulkEditTitle
'
);
static
readonly
BulkEditContext
=
new
MenuId
(
'
BulkEditContext
'
);
static
readonly
TimelineItemContext
=
new
MenuId
(
'
TimelineItemContext
'
);
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
7e56fc02
...
...
@@ -131,7 +131,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const
extHostWindow
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWindow
,
new
ExtHostWindow
(
rpcProtocol
));
const
extHostProgress
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostProgress
,
new
ExtHostProgress
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadProgress
)));
const
extHostLabelService
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHosLabelService
,
new
ExtHostLabelService
(
rpcProtocol
));
const
extHostNotebook
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostNotebook
,
new
ExtHostNotebookController
(
rpcProtocol
,
extHostDocumentsAndEditors
));
const
extHostNotebook
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostNotebook
,
new
ExtHostNotebookController
(
rpcProtocol
,
extHost
Commands
,
extHost
DocumentsAndEditors
));
const
extHostTheming
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostTheming
,
new
ExtHostTheming
(
rpcProtocol
));
const
extHostAuthentication
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostAuthentication
,
new
ExtHostAuthentication
(
rpcProtocol
));
const
extHostTimeline
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostTimeline
,
new
ExtHostTimeline
(
rpcProtocol
,
extHostCommands
));
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
7e56fc02
...
...
@@ -14,6 +14,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
INotebookDisplayOrder
,
ITransformedDisplayOutputDto
,
IOrderedMimeType
,
IStreamOutput
,
IErrorOutput
,
mimeTypeSupportedByCore
,
IOutput
,
sortMimeTypes
,
diff
,
CellUri
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ISplice
}
from
'
vs/base/common/sequence
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
export
class
ExtHostCell
implements
vscode
.
NotebookCell
{
...
...
@@ -415,7 +416,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
private
static
_handlePool
:
number
=
0
;
private
readonly
_proxy
:
MainThreadNotebookShape
;
private
readonly
_notebookProviders
=
new
Map
<
string
,
{
readonly
provider
:
vscode
.
NotebookProvider
,
readonly
extension
:
IExtensionDescription
}
>
();
private
readonly
_notebookProviders
=
new
Map
<
string
,
{
readonly
provider
:
vscode
.
NotebookProvider
,
readonly
extension
:
IExtensionDescription
;
}
>
();
private
readonly
_documents
=
new
Map
<
string
,
ExtHostNotebookDocument
>
();
private
readonly
_editors
=
new
Map
<
string
,
ExtHostNotebookEditor
>
();
private
readonly
_notebookOutputRenderers
=
new
Map
<
number
,
ExtHostNotebookOutputRenderer
>
();
...
...
@@ -431,8 +432,28 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
return
this
.
_activeNotebookDocument
;
}
constructor
(
mainContext
:
IMainContext
,
private
_documentsAndEditors
:
ExtHostDocumentsAndEditors
)
{
constructor
(
mainContext
:
IMainContext
,
commands
:
ExtHostCommands
,
private
_documentsAndEditors
:
ExtHostDocumentsAndEditors
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadNotebook
);
commands
.
registerArgumentProcessor
({
processArgument
:
arg
=>
{
if
(
arg
&&
arg
.
$mid
===
12
)
{
const
documentHandle
=
arg
.
notebookEditor
?.
notebookHandle
;
const
cellHandle
=
arg
.
cell
.
handle
;
for
(
let
value
of
this
.
_editors
)
{
if
(
value
[
1
].
document
.
handle
===
documentHandle
)
{
const
cell
=
value
[
1
].
document
.
getCell
(
cellHandle
);
if
(
cell
)
{
return
cell
;
}
}
}
return
arg
;
}
}
});
}
registerNotebookOutputRenderer
(
...
...
src/vs/workbench/api/common/menusExtensionPoint.ts
浏览文件 @
7e56fc02
...
...
@@ -51,6 +51,7 @@ namespace schema {
case
'
comments/commentThread/context
'
:
return
MenuId
.
CommentThreadActions
;
case
'
comments/comment/title
'
:
return
MenuId
.
CommentTitle
;
case
'
comments/comment/context
'
:
return
MenuId
.
CommentActions
;
case
'
notebook/cell/title
'
:
return
MenuId
.
NotebookCellTitle
;
case
'
extension/context
'
:
return
MenuId
.
ExtensionContext
;
case
'
timeline/title
'
:
return
MenuId
.
TimelineTitle
;
case
'
timeline/item/context
'
:
return
MenuId
.
TimelineItemContext
;
...
...
@@ -212,6 +213,11 @@ namespace schema {
type
:
'
array
'
,
items
:
menuItem
},
'
notebook/cell/title
'
:
{
description
:
localize
(
'
notebook.cell.title
'
,
"
The contributed notebook cell title menu
"
),
type
:
'
array
'
,
items
:
menuItem
},
'
extension/context
'
:
{
description
:
localize
(
'
menus.extensionContext
'
,
"
The extension context menu
"
),
type
:
'
array
'
,
...
...
src/vs/workbench/contrib/notebook/browser/constants.ts
浏览文件 @
7e56fc02
...
...
@@ -24,3 +24,6 @@ export const CELL_MARGIN = 32;
export
const
EDITOR_TOP_PADDING
=
8
;
export
const
EDITOR_BOTTOM_PADDING
=
8
;
export
const
EDITOR_TOOLBAR_HEIGHT
=
22
;
// Context Keys
export
const
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
=
'
notebookCellType
'
;
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
7e56fc02
...
...
@@ -698,6 +698,12 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
//#endregion
toJSON
():
any
{
return
{
notebookHandle
:
this
.
viewModel
?.
handle
};
}
}
const
embeddedEditorBackground
=
'
walkThrough.embeddedEditorBackground
'
;
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellMenus.ts
0 → 100644
浏览文件 @
7e56fc02
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IMenuService
,
MenuId
,
IMenu
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
createAndFillInContextMenuActions
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
export
class
CellMenus
implements
IDisposable
{
constructor
(
@
IMenuService
private
readonly
menuService
:
IMenuService
,
@
IContextMenuService
private
readonly
contextMenuService
:
IContextMenuService
)
{
}
getCellTitleActions
(
contextKeyService
:
IContextKeyService
):
IMenu
{
return
this
.
getMenu
(
MenuId
.
NotebookCellTitle
,
contextKeyService
);
}
private
getMenu
(
menuId
:
MenuId
,
contextKeyService
:
IContextKeyService
):
IMenu
{
const
menu
=
this
.
menuService
.
createMenu
(
menuId
,
contextKeyService
);
const
primary
:
IAction
[]
=
[];
const
secondary
:
IAction
[]
=
[];
const
result
=
{
primary
,
secondary
};
createAndFillInContextMenuActions
(
menu
,
{
shouldForwardArgs
:
true
},
result
,
this
.
contextMenuService
,
g
=>
/^inline/
.
test
(
g
));
return
menu
;
}
dispose
():
void
{
}
}
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
7e56fc02
...
...
@@ -28,7 +28,9 @@ import { ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser
import
{
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
EDITOR_BOTTOM_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
,
EDITOR_BOTTOM_PADDING
,
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellMenus
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellMenus
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
class
NotebookCellListDelegate
implements
IListVirtualDelegate
<
ICellViewModel
>
{
private
_lineHeight
:
number
;
...
...
@@ -68,6 +70,7 @@ abstract class AbstractCellRenderer {
private
readonly
configurationService
:
IConfigurationService
,
private
readonly
keybindingService
:
IKeybindingService
,
private
readonly
notificationService
:
INotificationService
,
protected
readonly
contextKeyService
:
IContextKeyService
,
language
:
string
,
)
{
const
editorOptions
=
deepClone
(
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
,
{
overrideIdentifier
:
language
}));
...
...
@@ -108,6 +111,11 @@ abstract class AbstractCellRenderer {
return
toolbar
;
}
protected
createMenu
():
CellMenus
{
const
menu
=
this
.
instantiationService
.
createInstance
(
CellMenus
);
return
menu
;
}
showContextMenu
(
listIndex
:
number
|
undefined
,
element
:
CellViewModel
,
x
:
number
,
y
:
number
)
{
const
actions
:
IAction
[]
=
[
this
.
instantiationService
.
createInstance
(
InsertCodeCellAboveAction
),
...
...
@@ -150,8 +158,9 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
instantiationService
,
notehookEditor
,
contextMenuService
,
configurationService
,
keybindingService
,
notificationService
,
'
markdown
'
);
super
(
instantiationService
,
notehookEditor
,
contextMenuService
,
configurationService
,
keybindingService
,
notificationService
,
contextKeyService
,
'
markdown
'
);
}
get
templateId
()
{
...
...
@@ -165,14 +174,6 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
const
disposables
=
new
DisposableStore
();
const
toolbar
=
this
.
createToolbar
(
container
);
toolbar
.
setActions
([
this
.
instantiationService
.
createInstance
(
MoveCellUpAction
),
this
.
instantiationService
.
createInstance
(
MoveCellDownAction
),
this
.
instantiationService
.
createInstance
(
InsertCodeCellBelowAction
),
this
.
instantiationService
.
createInstance
(
EditCellAction
),
this
.
instantiationService
.
createInstance
(
SaveCellAction
),
this
.
instantiationService
.
createInstance
(
DeleteCellAction
)
])();
disposables
.
add
(
toolbar
);
container
.
appendChild
(
codeInnerContent
);
...
...
@@ -230,11 +231,30 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
}));
elementDisposable
!
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
markdown
'
);
const
menu
=
this
.
createMenu
().
getCellTitleActions
(
this
.
contextKeyService
);
const
actions
:
IAction
[]
=
[];
for
(
let
[,
actions
]
of
menu
.
getActions
({
shouldForwardArgs
:
true
}))
{
actions
.
push
(...
actions
);
}
templateData
.
toolbar
!
.
setActions
([
...
actions
,
this
.
instantiationService
.
createInstance
(
MoveCellUpAction
),
this
.
instantiationService
.
createInstance
(
MoveCellDownAction
),
this
.
instantiationService
.
createInstance
(
InsertCodeCellBelowAction
),
this
.
instantiationService
.
createInstance
(
EditCellAction
),
this
.
instantiationService
.
createInstance
(
SaveCellAction
),
this
.
instantiationService
.
createInstance
(
DeleteCellAction
)
])();
}
templateData
.
toolbar
!
.
context
=
<
INotebookCellActionContext
>
{
cell
:
element
,
notebookEditor
:
this
.
notebookEditor
notebookEditor
:
this
.
notebookEditor
,
$mid
:
12
};
}
...
...
@@ -269,8 +289,9 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
instantiationService
,
notebookEditor
,
contextMenuService
,
configurationService
,
keybindingService
,
notificationService
,
'
python
'
);
super
(
instantiationService
,
notebookEditor
,
contextMenuService
,
configurationService
,
keybindingService
,
notificationService
,
contextKeyService
,
'
python
'
);
}
get
templateId
()
{
...
...
@@ -364,9 +385,26 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
templateData
.
focusIndicator
!
.
style
.
height
=
`
${
element
.
getIndicatorHeight
()}
px`
;
}));
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
code
'
);
const
menu
=
this
.
createMenu
().
getCellTitleActions
(
contextKeyService
);
const
actions
:
IAction
[]
=
[];
for
(
let
[,
items
]
of
menu
.
getActions
({
shouldForwardArgs
:
true
}))
{
actions
.
push
(...
items
);
}
templateData
.
toolbar
!
.
setActions
([
...
actions
,
this
.
instantiationService
.
createInstance
(
MoveCellUpAction
),
this
.
instantiationService
.
createInstance
(
MoveCellDownAction
),
this
.
instantiationService
.
createInstance
(
InsertCodeCellBelowAction
),
this
.
instantiationService
.
createInstance
(
DeleteCellAction
)
])();
templateData
.
toolbar
!
.
context
=
<
INotebookCellActionContext
>
{
cell
:
element
,
notebookEditor
:
this
.
notebookEditor
notebookEditor
:
this
.
notebookEditor
,
$mid
:
12
};
}
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
浏览文件 @
7e56fc02
...
...
@@ -519,4 +519,10 @@ export class CellViewModel extends Disposable implements ICellViewModel {
this
.
_outputsTop
=
new
PrefixSumComputer
(
values
);
}
}
toJSON
():
any
{
return
{
handle
:
this
.
handle
};
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录