Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8fd47cd5
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,发现更多精彩内容 >>
提交
8fd47cd5
编写于
2月 13, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable select all in iframe based webviews
上级
20fae66e
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
66 addition
and
39 deletion
+66
-39
src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts
...s/workbench/contrib/webview/browser/baseWebviewElement.ts
+6
-0
src/vs/workbench/contrib/webview/browser/dynamicWebviewEditorOverlay.ts
...ch/contrib/webview/browser/dynamicWebviewEditorOverlay.ts
+1
-0
src/vs/workbench/contrib/webview/browser/pre/main.js
src/vs/workbench/contrib/webview/browser/pre/main.js
+21
-14
src/vs/workbench/contrib/webview/browser/webview.contribution.ts
...workbench/contrib/webview/browser/webview.contribution.ts
+6
-1
src/vs/workbench/contrib/webview/browser/webview.ts
src/vs/workbench/contrib/webview/browser/webview.ts
+2
-0
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
+24
-0
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
+6
-0
src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts
.../contrib/webview/electron-browser/webview.contribution.ts
+0
-2
src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts
...bench/contrib/webview/electron-browser/webviewCommands.ts
+0
-22
未找到文件。
src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts
浏览文件 @
8fd47cd5
...
@@ -286,4 +286,10 @@ export abstract class BaseWebview<T extends HTMLElement> extends Disposable {
...
@@ -286,4 +286,10 @@ export abstract class BaseWebview<T extends HTMLElement> extends Disposable {
this
.
element
.
style
.
pointerEvents
=
''
;
this
.
element
.
style
.
pointerEvents
=
''
;
}
}
}
}
public
selectAll
()
{
if
(
this
.
element
)
{
this
.
_send
(
'
execCommand
'
,
'
selectAll
'
);
}
}
}
}
src/vs/workbench/contrib/webview/browser/dynamicWebviewEditorOverlay.ts
浏览文件 @
8fd47cd5
...
@@ -187,6 +187,7 @@ export class DynamicWebviewEditorOverlay extends Disposable implements WebviewEd
...
@@ -187,6 +187,7 @@ export class DynamicWebviewEditorOverlay extends Disposable implements WebviewEd
showFind
():
void
{
this
.
withWebview
(
webview
=>
webview
.
showFind
());
}
showFind
():
void
{
this
.
withWebview
(
webview
=>
webview
.
showFind
());
}
hideFind
():
void
{
this
.
withWebview
(
webview
=>
webview
.
hideFind
());
}
hideFind
():
void
{
this
.
withWebview
(
webview
=>
webview
.
hideFind
());
}
runFindAction
(
previous
:
boolean
):
void
{
this
.
withWebview
(
webview
=>
webview
.
runFindAction
(
previous
));
}
runFindAction
(
previous
:
boolean
):
void
{
this
.
withWebview
(
webview
=>
webview
.
runFindAction
(
previous
));
}
selectAll
():
void
{
this
.
withWebview
(
webview
=>
webview
.
selectAll
());
}
public
getInnerWebview
()
{
public
getInnerWebview
()
{
return
this
.
_webview
.
value
;
return
this
.
_webview
.
value
;
...
...
src/vs/workbench/contrib/webview/browser/pre/main.js
浏览文件 @
8fd47cd5
...
@@ -545,6 +545,13 @@
...
@@ -545,6 +545,13 @@
initData
.
initialScrollProgress
=
progress
;
initData
.
initialScrollProgress
=
progress
;
});
});
host
.
onMessage
(
'
execCommand
'
,
(
_event
,
data
)
=>
{
const
target
=
getActiveFrame
();
if
(
!
target
)
{
return
;
}
target
.
contentDocument
.
execCommand
(
data
);
});
trackFocus
({
trackFocus
({
onFocus
:
()
=>
host
.
postMessage
(
'
did-focus
'
),
onFocus
:
()
=>
host
.
postMessage
(
'
did-focus
'
),
...
...
src/vs/workbench/contrib/webview/browser/webview.contribution.ts
浏览文件 @
8fd47cd5
...
@@ -14,7 +14,7 @@ import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/wor
...
@@ -14,7 +14,7 @@ import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/wor
import
{
Extensions
as
EditorInputExtensions
,
IEditorInputFactoryRegistry
}
from
'
vs/workbench/common/editor
'
;
import
{
Extensions
as
EditorInputExtensions
,
IEditorInputFactoryRegistry
}
from
'
vs/workbench/common/editor
'
;
import
{
webviewDeveloperCategory
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
webviewDeveloperCategory
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
WebviewEditorInputFactory
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInputFactory
'
;
import
{
WebviewEditorInputFactory
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInputFactory
'
;
import
{
HideWebViewEditorFindCommand
,
ReloadWebviewAction
,
ShowWebViewEditorFindWidgetAction
,
WebViewEditorFindNextCommand
,
WebViewEditorFindPreviousCommand
}
from
'
../browser/webviewCommands
'
;
import
{
HideWebViewEditorFindCommand
,
ReloadWebviewAction
,
ShowWebViewEditorFindWidgetAction
,
WebViewEditorFindNextCommand
,
WebViewEditorFindPreviousCommand
,
SelectAllWebviewEditorCommand
}
from
'
../browser/webviewCommands
'
;
import
{
WebviewEditor
}
from
'
./webviewEditor
'
;
import
{
WebviewEditor
}
from
'
./webviewEditor
'
;
import
{
WebviewInput
}
from
'
./webviewEditorInput
'
;
import
{
WebviewInput
}
from
'
./webviewEditorInput
'
;
import
{
IWebviewWorkbenchService
,
WebviewEditorService
}
from
'
./webviewWorkbenchService
'
;
import
{
IWebviewWorkbenchService
,
WebviewEditorService
}
from
'
./webviewWorkbenchService
'
;
...
@@ -50,6 +50,11 @@ registerAction2(class extends WebViewEditorFindPreviousCommand {
...
@@ -50,6 +50,11 @@ registerAction2(class extends WebViewEditorFindPreviousCommand {
constructor
()
{
super
(
webviewActiveContextKeyExpr
);
}
constructor
()
{
super
(
webviewActiveContextKeyExpr
);
}
});
});
registerAction2
(
class
extends
SelectAllWebviewEditorCommand
{
constructor
()
{
super
(
webviewActiveContextKeyExpr
);
}
});
const
actionRegistry
=
Registry
.
as
<
IWorkbenchActionRegistry
>
(
ActionExtensions
.
WorkbenchActions
);
const
actionRegistry
=
Registry
.
as
<
IWorkbenchActionRegistry
>
(
ActionExtensions
.
WorkbenchActions
);
actionRegistry
.
registerWorkbenchAction
(
actionRegistry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
create
(
ReloadWebviewAction
,
ReloadWebviewAction
.
ID
,
ReloadWebviewAction
.
LABEL
),
SyncActionDescriptor
.
create
(
ReloadWebviewAction
,
ReloadWebviewAction
.
ID
,
ReloadWebviewAction
.
LABEL
),
...
...
src/vs/workbench/contrib/webview/browser/webview.ts
浏览文件 @
8fd47cd5
...
@@ -93,6 +93,8 @@ export interface Webview extends IDisposable {
...
@@ -93,6 +93,8 @@ export interface Webview extends IDisposable {
hideFind
():
void
;
hideFind
():
void
;
runFindAction
(
previous
:
boolean
):
void
;
runFindAction
(
previous
:
boolean
):
void
;
selectAll
():
void
;
windowDidDragStart
():
void
;
windowDidDragStart
():
void
;
windowDidDragEnd
():
void
;
windowDidDragEnd
():
void
;
}
}
...
...
src/vs/workbench/contrib/webview/browser/webviewCommands.ts
浏览文件 @
8fd47cd5
...
@@ -13,6 +13,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
...
@@ -13,6 +13,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import
{
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED
,
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
WebviewEditor
}
from
'
vs/workbench/contrib/webview/browser/webviewEditor
'
;
import
{
WebviewEditor
}
from
'
vs/workbench/contrib/webview/browser/webviewEditor
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
InputFocusedContextKey
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
export
class
ShowWebViewEditorFindWidgetAction
extends
Action2
{
export
class
ShowWebViewEditorFindWidgetAction
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.showFind
'
;
public
static
readonly
ID
=
'
editor.action.webvieweditor.showFind
'
;
...
@@ -97,6 +98,29 @@ export class WebViewEditorFindPreviousCommand extends Action2 {
...
@@ -97,6 +98,29 @@ export class WebViewEditorFindPreviousCommand extends Action2 {
getActiveWebviewEditor
(
accessor
)?.
find
(
true
);
getActiveWebviewEditor
(
accessor
)?.
find
(
true
);
}
}
}
}
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
,
title
:
SelectAllWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
precondition
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_A
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
getActiveWebviewEditor
(
accessor
)?.
selectAll
();
}
}
export
class
ReloadWebviewAction
extends
Action
{
export
class
ReloadWebviewAction
extends
Action
{
static
readonly
ID
=
'
workbench.action.webview.reloadWebviewAction
'
;
static
readonly
ID
=
'
workbench.action.webview.reloadWebviewAction
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
refreshWebviewLabel
'
,
"
Reload Webviews
"
);
static
readonly
LABEL
=
nls
.
localize
(
'
refreshWebviewLabel
'
,
"
Reload Webviews
"
);
...
...
src/vs/workbench/contrib/webview/browser/webviewEditor.ts
浏览文件 @
8fd47cd5
...
@@ -88,6 +88,12 @@ export class WebviewEditor extends BaseEditor {
...
@@ -88,6 +88,12 @@ export class WebviewEditor extends BaseEditor {
});
});
}
}
public
selectAll
()
{
this
.
withWebview
(
webview
=>
{
webview
.
selectAll
();
});
}
public
reload
()
{
public
reload
()
{
this
.
withWebview
(
webview
=>
webview
.
reload
());
this
.
withWebview
(
webview
=>
webview
.
reload
());
}
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts
浏览文件 @
8fd47cd5
...
@@ -26,8 +26,6 @@ actionRegistry.registerWorkbenchAction(
...
@@ -26,8 +26,6 @@ actionRegistry.registerWorkbenchAction(
function
registerWebViewCommands
(
editorId
:
string
):
void
{
function
registerWebViewCommands
(
editorId
:
string
):
void
{
const
contextKeyExpr
=
ContextKeyExpr
.
and
(
ContextKeyExpr
.
equals
(
'
activeEditor
'
,
editorId
),
ContextKeyExpr
.
not
(
'
editorFocus
'
)
/* https://github.com/Microsoft/vscode/issues/58668 */
)
!
;
const
contextKeyExpr
=
ContextKeyExpr
.
and
(
ContextKeyExpr
.
equals
(
'
activeEditor
'
,
editorId
),
ContextKeyExpr
.
not
(
'
editorFocus
'
)
/* https://github.com/Microsoft/vscode/issues/58668 */
)
!
;
registerAction2
(
class
extends
webviewCommands
.
SelectAllWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
});
// These commands are only needed on MacOS where we have to disable the menu bar commands
// These commands are only needed on MacOS where we have to disable the menu bar commands
if
(
isMacintosh
)
{
if
(
isMacintosh
)
{
registerAction2
(
class
extends
webviewCommands
.
CopyWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
});
registerAction2
(
class
extends
webviewCommands
.
CopyWebviewEditorCommand
{
constructor
()
{
super
(
contextKeyExpr
);
}
});
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts
浏览文件 @
8fd47cd5
...
@@ -38,28 +38,6 @@ export class OpenWebviewDeveloperToolsAction extends Action {
...
@@ -38,28 +38,6 @@ export class OpenWebviewDeveloperToolsAction extends Action {
}
}
}
}
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
,
title
:
SelectAllWebviewEditorCommand
.
LABEL
,
keybinding
:
{
when
:
precondition
,
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_A
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
public
run
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
withActiveWebviewBasedWebview
(
accessor
,
webview
=>
webview
.
selectAll
());
}
}
export
class
CopyWebviewEditorCommand
extends
Action2
{
export
class
CopyWebviewEditorCommand
extends
Action2
{
public
static
readonly
ID
=
'
editor.action.webvieweditor.copy
'
;
public
static
readonly
ID
=
'
editor.action.webvieweditor.copy
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.copy
'
,
"
Copy2
"
);
public
static
readonly
LABEL
=
nls
.
localize
(
'
editor.action.webvieweditor.copy
'
,
"
Copy2
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录