Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7ceb3af6
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,发现更多精彩内容 >>
提交
7ceb3af6
编写于
7月 22, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
isolate DropdownMenuActionViewItem
上级
89f2de67
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
123 addition
and
109 deletion
+123
-109
src/vs/base/browser/ui/dropdown/dropdown.ts
src/vs/base/browser/ui/dropdown/dropdown.ts
+3
-105
src/vs/base/browser/ui/dropdown/dropdownActionViewItem.ts
src/vs/base/browser/ui/dropdown/dropdownActionViewItem.ts
+115
-0
src/vs/base/browser/ui/toolbar/toolbar.ts
src/vs/base/browser/ui/toolbar/toolbar.ts
+2
-1
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
...kbench/browser/parts/notifications/notificationsViewer.ts
+1
-1
src/vs/workbench/contrib/comments/browser/commentNode.ts
src/vs/workbench/contrib/comments/browser/commentNode.ts
+1
-1
src/vs/workbench/contrib/markers/browser/markersViewActions.ts
...s/workbench/contrib/markers/browser/markersViewActions.ts
+1
-1
未找到文件。
src/vs/base/browser/ui/dropdown/dropdown.ts
浏览文件 @
7ceb3af6
...
...
@@ -5,16 +5,15 @@
import
'
vs/css!./dropdown
'
;
import
{
Gesture
,
EventType
as
GestureEventType
}
from
'
vs/base/browser/touch
'
;
import
{
ActionRunner
,
IAction
,
IActionRunner
,
IActionViewItemProvider
}
from
'
vs/base/common/actions
'
;
import
{
ActionRunner
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextViewProvider
,
IAnchor
,
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
IMenuOptions
}
from
'
vs/base/browser/ui/menu/menu
'
;
import
{
ResolvedKeybinding
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EventHelper
,
EventType
,
removeClass
,
addClass
,
append
,
$
,
addDisposableListener
,
addClasses
,
DOMEvent
}
from
'
vs/base/browser/dom
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EventHelper
,
EventType
,
removeClass
,
addClass
,
append
,
$
,
addDisposableListener
,
DOMEvent
}
from
'
vs/base/browser/dom
'
;
import
{
IContextMenuDelegate
}
from
'
vs/base/browser/contextmenu
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
BaseActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionViewItems
'
;
export
interface
ILabelRenderer
{
(
container
:
HTMLElement
):
IDisposable
|
null
;
...
...
@@ -283,104 +282,3 @@ export class DropdownMenu extends BaseDropdown {
removeClass
(
this
.
element
,
'
active
'
);
}
}
export
class
DropdownMenuActionViewItem
extends
BaseActionViewItem
{
private
menuActionsOrProvider
:
ReadonlyArray
<
IAction
>
|
IActionProvider
;
private
dropdownMenu
:
DropdownMenu
|
undefined
;
private
contextMenuProvider
:
IContextMenuProvider
;
private
actionViewItemProvider
?:
IActionViewItemProvider
;
private
keybindings
?:
(
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
;
private
clazz
:
string
|
undefined
;
private
anchorAlignmentProvider
:
(()
=>
AnchorAlignment
)
|
undefined
;
private
menuAsChild
?:
boolean
;
private
_onDidChangeVisibility
=
this
.
_register
(
new
Emitter
<
boolean
>
());
readonly
onDidChangeVisibility
=
this
.
_onDidChangeVisibility
.
event
;
constructor
(
action
:
IAction
,
menuActions
:
ReadonlyArray
<
IAction
>
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
);
constructor
(
action
:
IAction
,
actionProvider
:
IActionProvider
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
);
constructor
(
action
:
IAction
,
menuActionsOrProvider
:
ReadonlyArray
<
IAction
>
|
IActionProvider
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
)
{
super
(
null
,
action
);
this
.
menuActionsOrProvider
=
menuActionsOrProvider
;
this
.
contextMenuProvider
=
contextMenuProvider
;
this
.
actionViewItemProvider
=
actionViewItemProvider
;
this
.
actionRunner
=
actionRunner
;
this
.
keybindings
=
keybindings
;
this
.
clazz
=
clazz
;
this
.
anchorAlignmentProvider
=
anchorAlignmentProvider
;
this
.
menuAsChild
=
menuAsChild
;
}
render
(
container
:
HTMLElement
):
void
{
const
labelRenderer
:
ILabelRenderer
=
(
el
:
HTMLElement
):
IDisposable
|
null
=>
{
this
.
element
=
append
(
el
,
$
(
'
a.action-label.codicon
'
));
// todo@aeschli: remove codicon, should come through `this.clazz`
if
(
this
.
clazz
)
{
addClasses
(
this
.
element
,
this
.
clazz
);
}
this
.
element
.
tabIndex
=
0
;
this
.
element
.
setAttribute
(
'
role
'
,
'
button
'
);
this
.
element
.
setAttribute
(
'
aria-haspopup
'
,
'
true
'
);
this
.
element
.
setAttribute
(
'
aria-expanded
'
,
'
false
'
);
this
.
element
.
title
=
this
.
_action
.
label
||
''
;
return
null
;
};
const
options
:
IDropdownMenuOptions
=
{
contextMenuProvider
:
this
.
contextMenuProvider
,
labelRenderer
:
labelRenderer
,
menuAsChild
:
this
.
menuAsChild
};
// Render the DropdownMenu around a simple action to toggle it
if
(
Array
.
isArray
(
this
.
menuActionsOrProvider
))
{
options
.
actions
=
this
.
menuActionsOrProvider
;
}
else
{
options
.
actionProvider
=
this
.
menuActionsOrProvider
as
IActionProvider
;
}
this
.
dropdownMenu
=
this
.
_register
(
new
DropdownMenu
(
container
,
options
));
this
.
_register
(
this
.
dropdownMenu
.
onDidChangeVisibility
(
visible
=>
{
this
.
element
?.
setAttribute
(
'
aria-expanded
'
,
`
${
visible
}
`
);
this
.
_onDidChangeVisibility
.
fire
(
visible
);
}));
this
.
dropdownMenu
.
menuOptions
=
{
actionViewItemProvider
:
this
.
actionViewItemProvider
,
actionRunner
:
this
.
actionRunner
,
getKeyBinding
:
this
.
keybindings
,
context
:
this
.
_context
};
if
(
this
.
anchorAlignmentProvider
)
{
const
that
=
this
;
this
.
dropdownMenu
.
menuOptions
=
{
...
this
.
dropdownMenu
.
menuOptions
,
get
anchorAlignment
():
AnchorAlignment
{
return
that
.
anchorAlignmentProvider
!
();
}
};
}
}
setActionContext
(
newContext
:
unknown
):
void
{
super
.
setActionContext
(
newContext
);
if
(
this
.
dropdownMenu
)
{
if
(
this
.
dropdownMenu
.
menuOptions
)
{
this
.
dropdownMenu
.
menuOptions
.
context
=
newContext
;
}
else
{
this
.
dropdownMenu
.
menuOptions
=
{
context
:
newContext
};
}
}
}
show
():
void
{
if
(
this
.
dropdownMenu
)
{
this
.
dropdownMenu
.
show
();
}
}
}
src/vs/base/browser/ui/dropdown/dropdownActionViewItem.ts
0 → 100644
浏览文件 @
7ceb3af6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
'
vs/css!./dropdown
'
;
import
{
IAction
,
IActionRunner
,
IActionViewItemProvider
}
from
'
vs/base/common/actions
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
ResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
append
,
$
,
addClasses
}
from
'
vs/base/browser/dom
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
BaseActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionViewItems
'
;
import
{
IActionProvider
,
DropdownMenu
,
IContextMenuProvider
,
IDropdownMenuOptions
,
ILabelRenderer
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
export
class
DropdownMenuActionViewItem
extends
BaseActionViewItem
{
private
menuActionsOrProvider
:
ReadonlyArray
<
IAction
>
|
IActionProvider
;
private
dropdownMenu
:
DropdownMenu
|
undefined
;
private
contextMenuProvider
:
IContextMenuProvider
;
private
actionViewItemProvider
?:
IActionViewItemProvider
;
private
keybindings
?:
(
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
;
private
clazz
:
string
|
undefined
;
private
anchorAlignmentProvider
:
(()
=>
AnchorAlignment
)
|
undefined
;
private
menuAsChild
?:
boolean
;
private
_onDidChangeVisibility
=
this
.
_register
(
new
Emitter
<
boolean
>
());
readonly
onDidChangeVisibility
=
this
.
_onDidChangeVisibility
.
event
;
constructor
(
action
:
IAction
,
menuActions
:
ReadonlyArray
<
IAction
>
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
);
constructor
(
action
:
IAction
,
actionProvider
:
IActionProvider
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
);
constructor
(
action
:
IAction
,
menuActionsOrProvider
:
ReadonlyArray
<
IAction
>
|
IActionProvider
,
contextMenuProvider
:
IContextMenuProvider
,
actionViewItemProvider
:
IActionViewItemProvider
|
undefined
,
actionRunner
:
IActionRunner
,
keybindings
:
((
action
:
IAction
)
=>
ResolvedKeybinding
|
undefined
)
|
undefined
,
clazz
:
string
|
undefined
,
anchorAlignmentProvider
?:
()
=>
AnchorAlignment
,
menuAsChild
?:
boolean
)
{
super
(
null
,
action
);
this
.
menuActionsOrProvider
=
menuActionsOrProvider
;
this
.
contextMenuProvider
=
contextMenuProvider
;
this
.
actionViewItemProvider
=
actionViewItemProvider
;
this
.
actionRunner
=
actionRunner
;
this
.
keybindings
=
keybindings
;
this
.
clazz
=
clazz
;
this
.
anchorAlignmentProvider
=
anchorAlignmentProvider
;
this
.
menuAsChild
=
menuAsChild
;
}
render
(
container
:
HTMLElement
):
void
{
const
labelRenderer
:
ILabelRenderer
=
(
el
:
HTMLElement
):
IDisposable
|
null
=>
{
this
.
element
=
append
(
el
,
$
(
'
a.action-label.codicon
'
));
// todo@aeschli: remove codicon, should come through `this.clazz`
if
(
this
.
clazz
)
{
addClasses
(
this
.
element
,
this
.
clazz
);
}
this
.
element
.
tabIndex
=
0
;
this
.
element
.
setAttribute
(
'
role
'
,
'
button
'
);
this
.
element
.
setAttribute
(
'
aria-haspopup
'
,
'
true
'
);
this
.
element
.
setAttribute
(
'
aria-expanded
'
,
'
false
'
);
this
.
element
.
title
=
this
.
_action
.
label
||
''
;
return
null
;
};
const
options
:
IDropdownMenuOptions
=
{
contextMenuProvider
:
this
.
contextMenuProvider
,
labelRenderer
:
labelRenderer
,
menuAsChild
:
this
.
menuAsChild
};
// Render the DropdownMenu around a simple action to toggle it
if
(
Array
.
isArray
(
this
.
menuActionsOrProvider
))
{
options
.
actions
=
this
.
menuActionsOrProvider
;
}
else
{
options
.
actionProvider
=
this
.
menuActionsOrProvider
as
IActionProvider
;
}
this
.
dropdownMenu
=
this
.
_register
(
new
DropdownMenu
(
container
,
options
));
this
.
_register
(
this
.
dropdownMenu
.
onDidChangeVisibility
(
visible
=>
{
this
.
element
?.
setAttribute
(
'
aria-expanded
'
,
`
${
visible
}
`
);
this
.
_onDidChangeVisibility
.
fire
(
visible
);
}));
this
.
dropdownMenu
.
menuOptions
=
{
actionViewItemProvider
:
this
.
actionViewItemProvider
,
actionRunner
:
this
.
actionRunner
,
getKeyBinding
:
this
.
keybindings
,
context
:
this
.
_context
};
if
(
this
.
anchorAlignmentProvider
)
{
const
that
=
this
;
this
.
dropdownMenu
.
menuOptions
=
{
...
this
.
dropdownMenu
.
menuOptions
,
get
anchorAlignment
():
AnchorAlignment
{
return
that
.
anchorAlignmentProvider
!
();
}
};
}
}
setActionContext
(
newContext
:
unknown
):
void
{
super
.
setActionContext
(
newContext
);
if
(
this
.
dropdownMenu
)
{
if
(
this
.
dropdownMenu
.
menuOptions
)
{
this
.
dropdownMenu
.
menuOptions
.
context
=
newContext
;
}
else
{
this
.
dropdownMenu
.
menuOptions
=
{
context
:
newContext
};
}
}
}
show
():
void
{
if
(
this
.
dropdownMenu
)
{
this
.
dropdownMenu
.
show
();
}
}
}
src/vs/base/browser/ui/toolbar/toolbar.ts
浏览文件 @
7ceb3af6
...
...
@@ -7,13 +7,14 @@ import 'vs/css!./toolbar';
import
*
as
nls
from
'
vs/nls
'
;
import
{
Action
,
IActionRunner
,
IAction
,
IActionViewItemProvider
}
from
'
vs/base/common/actions
'
;
import
{
ActionBar
,
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IContextMenuProvider
,
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
import
{
IContextMenuProvider
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
import
{
ResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Disposable
,
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
import
{
Codicon
,
registerIcon
}
from
'
vs/base/common/codicons
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdownActionViewItem
'
;
export
const
CONTEXT
=
'
context.toolbar
'
;
...
...
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
浏览文件 @
7ceb3af6
...
...
@@ -16,7 +16,6 @@ import { IAction, IActionRunner } from 'vs/base/common/actions';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
dispose
,
DisposableStore
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
import
{
INotificationViewItem
,
NotificationViewItem
,
NotificationViewItemContentChangeKind
,
INotificationMessage
,
ChoiceAction
}
from
'
vs/workbench/common/notifications
'
;
import
{
ClearNotificationAction
,
ExpandNotificationAction
,
CollapseNotificationAction
,
ConfigureNotificationAction
}
from
'
vs/workbench/browser/parts/notifications/notificationsActions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
...
...
@@ -24,6 +23,7 @@ import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import
{
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
isNonEmptyArray
}
from
'
vs/base/common/arrays
'
;
import
{
Codicon
}
from
'
vs/base/common/codicons
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdownActionViewItem
'
;
export
class
NotificationsListDelegate
implements
IListVirtualDelegate
<
INotificationViewItem
>
{
...
...
src/vs/workbench/contrib/comments/browser/commentNode.ts
浏览文件 @
7ceb3af6
...
...
@@ -23,7 +23,6 @@ import { Emitter, Event } from 'vs/base/common/event';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
import
{
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
ToggleReactionsAction
,
ReactionAction
,
ReactionActionViewItem
}
from
'
./reactionsAction
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -35,6 +34,7 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c
import
{
CommentFormActions
}
from
'
vs/workbench/contrib/comments/browser/commentFormActions
'
;
import
{
MOUSE_CURSOR_TEXT_CSS_CLASS_NAME
}
from
'
vs/base/browser/ui/mouseCursor/mouseCursor
'
;
import
{
ActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionViewItems
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdownActionViewItem
'
;
export
class
CommentNode
extends
Disposable
{
private
_domNode
:
HTMLElement
;
...
...
src/vs/workbench/contrib/markers/browser/markersViewActions.ts
浏览文件 @
7ceb3af6
...
...
@@ -23,11 +23,11 @@ import { ContextScopedHistoryInputBox } from 'vs/platform/browser/contextScopedH
import
{
Marker
}
from
'
vs/workbench/contrib/markers/browser/markersModel
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdown
'
;
import
{
AnchorAlignment
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
Codicon
}
from
'
vs/base/common/codicons
'
;
import
{
BaseActionViewItem
,
ActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionViewItems
'
;
import
{
DropdownMenuActionViewItem
}
from
'
vs/base/browser/ui/dropdown/dropdownActionViewItem
'
;
export
class
ShowProblemsPanelAction
extends
Action
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录