Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1052cb5f
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,体验更适合开发者的 AI 搜索 >>
提交
1052cb5f
编写于
10月 07, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes Microsoft/monaco-editor#175: bring back context menu functionality for `editor.addAction`
上级
90aa6e0f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
7 deletion
+59
-7
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+26
-1
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+14
-0
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
+5
-6
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+14
-0
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
1052cb5f
...
...
@@ -10,7 +10,7 @@ import {Disposable, IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IContextKey
,
IContextKeyServiceTarget
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ContextKeyExpr
,
IContextKey
,
IContextKeyServiceTarget
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CommonEditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
DefaultConfig
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
...
...
@@ -27,6 +27,8 @@ import {SplitLinesCollection} from 'vs/editor/common/viewModel/splitLinesCollect
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
hash
}
from
'
vs/base/common/hash
'
;
import
{
EditorModeContext
}
from
'
vs/editor/common/modes/editorModeContext
'
;
import
{
MenuId
,
MenuRegistry
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
...
...
@@ -511,7 +513,30 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
)
{
throw
new
Error
(
'
Invalid action descriptor, `id`, `label` and `run` are required properties!
'
);
}
// Generate a unique id to allow the same descriptor.id across multiple editor instances
let
uniqueId
=
this
.
getId
()
+
'
:
'
+
descriptor
.
id
;
let
action
=
new
DynamicEditorAction
(
descriptor
,
this
);
// Register the command
CommandsRegistry
.
registerCommand
(
uniqueId
,
()
=>
action
.
run
());
if
(
descriptor
.
contextMenuGroupId
)
{
let
menuItem
:
IMenuItem
=
{
command
:
{
id
:
uniqueId
,
title
:
descriptor
.
label
},
when
:
ContextKeyExpr
.
equals
(
'
editorId
'
,
this
.
getId
()),
group
:
descriptor
.
contextMenuGroupId
,
order
:
descriptor
.
contextMenuOrder
||
0
};
// Register the menu item
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorContext
,
menuItem
);
}
this
.
_actions
[
action
.
id
]
=
action
;
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
1052cb5f
...
...
@@ -3421,6 +3421,20 @@ export interface IActionDescriptor {
* An array of keybindings for the action.
*/
keybindings
?:
number
[];
/**
* Control if the action should show up in the context menu and where.
* The context menu of the editor has these default:
* navigation - The navigation group comes first in all cases.
* 1_modification - This group comes next and contains commands that modify your code.
* 9_cutcopypaste - The last default group with the basic editing commands.
* You can also create your own group.
* Defaults to null (don't show in context menu).
*/
contextMenuGroupId
?:
string
;
/**
* Control the order in the context menu group.
*/
contextMenuOrder
?:
number
;
/**
* The keybinding rule.
*/
...
...
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
浏览文件 @
1052cb5f
...
...
@@ -16,7 +16,7 @@ import {ActionItem, Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import
{
IContextMenuService
,
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IMenuService
,
IMenu
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMenuService
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ICommonCodeEditor
,
IEditorContribution
,
MouseTargetType
,
EditorContextKeys
,
IScrollEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
editorAction
,
ServicesAccessor
,
EditorAction
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -39,7 +39,6 @@ export class ContextMenuController implements IEditorContribution {
private
_toDispose
:
IDisposable
[]
=
[];
private
_contextMenuIsBeingShownCount
:
number
=
0
;
private
_editor
:
ICodeEditor
;
private
_contextMenu
:
IMenu
;
constructor
(
editor
:
ICodeEditor
,
...
...
@@ -51,9 +50,6 @@ export class ContextMenuController implements IEditorContribution {
)
{
this
.
_editor
=
editor
;
this
.
_contextMenu
=
this
.
_menuService
.
createMenu
(
MenuId
.
EditorContext
,
this
.
_contextKeyService
);
this
.
_toDispose
.
push
(
this
.
_contextMenu
);
this
.
_toDispose
.
push
(
this
.
_editor
.
onContextMenu
((
e
:
IEditorMouseEvent
)
=>
this
.
_onContextMenu
(
e
)));
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidScrollChange
((
e
:
IScrollEvent
)
=>
{
if
(
this
.
_contextMenuIsBeingShownCount
>
0
)
{
...
...
@@ -129,7 +125,10 @@ export class ContextMenuController implements IEditorContribution {
private
_getMenuActions
():
IAction
[]
{
const
result
:
IAction
[]
=
[];
const
groups
=
this
.
_contextMenu
.
getActions
();
let
contextMenu
=
this
.
_menuService
.
createMenu
(
MenuId
.
EditorContext
,
this
.
_contextKeyService
);
const
groups
=
contextMenu
.
getActions
();
contextMenu
.
dispose
();
for
(
let
group
of
groups
)
{
const
[,
actions
]
=
group
;
...
...
src/vs/monaco.d.ts
浏览文件 @
1052cb5f
...
...
@@ -2776,6 +2776,20 @@ declare module monaco.editor {
* An array of keybindings for the action.
*/
keybindings
?:
number
[];
/**
* Control if the action should show up in the context menu and where.
* The context menu of the editor has these default:
* navigation - The navigation group comes first in all cases.
* 1_modification - This group comes next and contains commands that modify your code.
* 9_cutcopypaste - The last default group with the basic editing commands.
* You can also create your own group.
* Defaults to null (don't show in context menu).
*/
contextMenuGroupId
?:
string
;
/**
* Control the order in the context menu group.
*/
contextMenuOrder
?:
number
;
/**
* The keybinding rule.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录