Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9a74df8b
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,发现更多精彩内容 >>
提交
9a74df8b
编写于
2月 05, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Converting remaining webview commands to use Action2
For #89348
上级
8847219d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
42 deletion
+49
-42
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
+3
-10
src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts
.../contrib/webview/electron-browser/webview.contribution.ts
+7
-7
src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts
...bench/contrib/webview/electron-browser/webviewCommands.ts
+39
-25
未找到文件。
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
浏览文件 @
9a74df8b
...
...
@@ -22,7 +22,6 @@ export class ShowWebViewEditorFindWidgetAction extends Action2 {
super
({
id
:
ShowWebViewEditorFindWidgetAction
.
ID
,
title
:
ShowWebViewEditorFindWidgetAction
.
LABEL
,
precondition
:
contextKeyExpr
,
keybinding
:
{
when
:
contextKeyExpr
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
,
...
...
@@ -41,13 +40,11 @@ export class HideWebViewEditorFindCommand extends Action2 {
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.hideFind
'
,
"
Stop find
"
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
const
precondition
=
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
);
super
({
id
:
HideWebViewEditorFindCommand
.
ID
,
title
:
HideWebViewEditorFindCommand
.
LABEL
,
precondition
:
precondition
,
keybinding
:
{
when
:
precondition
,
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
)
,
primary
:
KeyCode
.
Escape
,
weight
:
KeybindingWeight
.
EditorContrib
}
...
...
@@ -64,13 +61,11 @@ export class WebViewEditorFindNextCommand extends Action2 {
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.findNext
'
,
'
Find next
'
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
const
precondition
=
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
);
super
({
id
:
WebViewEditorFindNextCommand
.
ID
,
title
:
WebViewEditorFindNextCommand
.
LABEL
,
precondition
:
precondition
,
keybinding
:
{
when
:
precondition
,
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
)
,
primary
:
KeyCode
.
Enter
,
weight
:
KeybindingWeight
.
EditorContrib
}
...
...
@@ -87,13 +82,11 @@ export class WebViewEditorFindPreviousCommand extends Action2 {
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.findPrevious
'
,
'
Find previous
'
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
const
precondition
=
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
);
super
({
id
:
WebViewEditorFindPreviousCommand
.
ID
,
title
:
WebViewEditorFindPreviousCommand
.
LABEL
,
precondition
:
precondition
,
keybinding
:
{
when
:
precondition
,
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
)
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
Enter
,
weight
:
KeybindingWeight
.
EditorContrib
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts
浏览文件 @
9a74df8b
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncActionDescriptor
,
registerAction2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -26,15 +26,15 @@ actionRegistry.registerWorkbenchAction(
function
registerWebViewCommands
(
editorId
:
string
):
void
{
const
contextKeyExpr
=
ContextKeyExpr
.
and
(
ContextKeyExpr
.
equals
(
'
activeEditor
'
,
editorId
),
ContextKeyExpr
.
not
(
'
editorFocus
'
)
/* https://github.com/Microsoft/vscode/issues/58668 */
)
!
;
new
webviewCommands
.
SelectAllWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
registerAction2
(
class
extends
webviewCommands
.
SelectAllWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
// These commands are only needed on MacOS where we have to disable the menu bar commands
if
(
isMacintosh
)
{
new
webviewCommands
.
CopyWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
new
webviewCommands
.
PasteWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
new
webviewCommands
.
CutWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
new
webviewCommands
.
UndoWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
new
webviewCommands
.
RedoWebviewEditorCommand
(
contextKeyExpr
).
register
(
);
registerAction2
(
class
extends
webviewCommands
.
CopyWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
registerAction2
(
class
extends
webviewCommands
.
PasteWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
registerAction2
(
class
extends
webviewCommands
.
CutWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
registerAction2
(
class
extends
webviewCommands
.
UndoWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
registerAction2
(
class
extends
webviewCommands
.
RedoWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
}
);
}
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts
浏览文件 @
9a74df8b
...
...
@@ -6,8 +6,9 @@
import
{
WebviewTag
}
from
'
electron
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
Command
,
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
Action2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
InputFocusedContextKey
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -37,109 +38,122 @@ export class OpenWebviewDeveloperToolsAction extends Action {
}
}
export
class
SelectAllWebviewEditorCommand
extends
Command
{
export
class
SelectAllWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.selectAll
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.selectAll
'
,
'
Select all
'
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
const
precondition
=
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
));
super
({
id
:
SelectAllWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
kbOpts
:
{
title
:
SelectAllWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
precondition
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_A
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
selectAll
());
}
}
export
class
CopyWebviewEditorCommand
extends
Command
{
export
class
CopyWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.copy
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.copy
'
,
"
Copy2
"
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
super
({
id
:
CopyWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
kbOpts
:
{
title
:
CopyWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_C
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
_args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
copy
());
}
}
export
class
PasteWebviewEditorCommand
extends
Command
{
export
class
PasteWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.paste
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.paste
'
,
'
Paste
'
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
super
({
id
:
PasteWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
kbOpts
:
{
title
:
PasteWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_V
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
_args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
paste
());
}
}
export
class
CutWebviewEditorCommand
extends
Command
{
export
class
CutWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.cut
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.cut
'
,
'
Cut
'
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
super
({
id
:
CutWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
kbOpts
:
{
title
:
CutWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
)),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_X
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
_args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
cut
());
}
}
export
class
UndoWebviewEditorCommand
extends
Command
{
export
class
UndoWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.undo
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.undo
'
,
"
Undo
"
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
super
({
id
:
UndoWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
),
ContextKeyExpr
.
not
(
webviewHasOwnEditFunctionsContextKey
)),
kbOpts
:
{
title
:
UndoWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
),
ContextKeyExpr
.
not
(
webviewHasOwnEditFunctionsContextKey
)),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_Z
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
undo
());
}
}
export
class
RedoWebviewEditorCommand
extends
Command
{
export
class
RedoWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.redo
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.redo
'
,
"
Redo
"
);
constructor
(
contextKeyExpr
:
ContextKeyExpr
)
{
super
({
id
:
RedoWebviewEditorCommand
.
ID
,
precondition
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
),
ContextKeyExpr
.
not
(
webviewHasOwnEditFunctionsContextKey
)),
kbOpts
:
{
title
:
RedoWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
contextKeyExpr
,
ContextKeyExpr
.
not
(
InputFocusedContextKey
),
ContextKeyExpr
.
not
(
webviewHasOwnEditFunctionsContextKey
)),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_Y
,
secondary
:
[
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_Z
],
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_Z
},
...
...
@@ -148,7 +162,7 @@ export class RedoWebviewEditorCommand extends Command {
});
}
public
run
Command
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
public
run
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
redo
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录