Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
95f8e3a1
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,发现更多精彩内容 >>
提交
95f8e3a1
编写于
10月 16, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move a few more common events into webview base
上级
e5d36bb1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
44 deletion
+22
-44
src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts
...s/workbench/contrib/webview/browser/baseWebviewElement.ts
+22
-0
src/vs/workbench/contrib/webview/browser/webviewElement.ts
src/vs/workbench/contrib/webview/browser/webviewElement.ts
+0
-23
src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts
...kbench/contrib/webview/electron-browser/webviewElement.ts
+0
-21
未找到文件。
src/vs/workbench/contrib/webview/browser/baseWebviewElement.ts
浏览文件 @
95f8e3a1
...
...
@@ -10,6 +10,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
WebviewExtensionDescription
,
WebviewOptions
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
const
enum
WebviewMessageChannels
{
onmessage
=
'
onmessage
'
,
...
...
@@ -55,6 +56,18 @@ export abstract class BaseWebview<T extends HTMLElement> extends Disposable {
this
.
_register
(
this
.
on
(
'
no-csp-found
'
,
()
=>
{
this
.
handleNoCspFound
();
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didClickLink
,
(
uri
:
string
)
=>
{
this
.
_onDidClickLink
.
fire
(
URI
.
parse
(
uri
));
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
onmessage
,
(
data
:
any
)
=>
{
this
.
_onMessage
.
fire
(
data
);
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didScroll
,
(
scrollYPercentage
:
number
)
=>
{
this
.
_onDidScroll
.
fire
({
scrollYPercentage
:
scrollYPercentage
});
}));
}
dispose
():
void
{
...
...
@@ -69,6 +82,15 @@ export abstract class BaseWebview<T extends HTMLElement> extends Disposable {
private
readonly
_onMissingCsp
=
this
.
_register
(
new
Emitter
<
ExtensionIdentifier
>
());
public
readonly
onMissingCsp
=
this
.
_onMissingCsp
.
event
;
private
readonly
_onDidClickLink
=
this
.
_register
(
new
Emitter
<
URI
>
());
public
readonly
onDidClickLink
=
this
.
_onDidClickLink
.
event
;
private
readonly
_onMessage
=
this
.
_register
(
new
Emitter
<
any
>
());
public
readonly
onMessage
=
this
.
_onMessage
.
event
;
private
readonly
_onDidScroll
=
this
.
_register
(
new
Emitter
<
{
readonly
scrollYPercentage
:
number
;
}
>
());
public
readonly
onDidScroll
=
this
.
_onDidScroll
.
event
;
protected
_send
(
channel
:
string
,
data
?:
any
):
void
{
this
.
_ready
.
then
(()
=>
this
.
postMessage
(
channel
,
data
))
...
...
src/vs/workbench/contrib/webview/browser/webviewElement.ts
浏览文件 @
95f8e3a1
...
...
@@ -62,20 +62,6 @@ export class IFrameWebview extends BaseWebview<HTMLIFrameElement> implements Web
state
:
undefined
};
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
onmessage
,
(
data
:
any
)
=>
{
this
.
_onMessage
.
fire
(
data
);
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didClickLink
,
(
uri
:
string
)
=>
{
this
.
_onDidClickLink
.
fire
(
URI
.
parse
(
uri
));
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didScroll
,
()
=>
{
// if (e.args && typeof e.args[0] === 'number') {
// this._onDidScroll.fire({ scrollYPercentage: e.args[0] });
// }
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
doReload
,
()
=>
{
this
.
reload
();
}));
...
...
@@ -186,18 +172,9 @@ export class IFrameWebview extends BaseWebview<HTMLIFrameElement> implements Web
private
readonly
_onDidFocus
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidFocus
=
this
.
_onDidFocus
.
event
;
private
readonly
_onDidClickLink
=
this
.
_register
(
new
Emitter
<
URI
>
());
public
readonly
onDidClickLink
=
this
.
_onDidClickLink
.
event
;
private
readonly
_onDidScroll
=
this
.
_register
(
new
Emitter
<
{
scrollYPercentage
:
number
}
>
());
public
readonly
onDidScroll
=
this
.
_onDidScroll
.
event
;
private
readonly
_onDidUpdateState
=
this
.
_register
(
new
Emitter
<
string
|
undefined
>
());
public
readonly
onDidUpdateState
=
this
.
_onDidUpdateState
.
event
;
private
readonly
_onMessage
=
this
.
_register
(
new
Emitter
<
any
>
());
public
readonly
onMessage
=
this
.
_onMessage
.
event
;
sendMessage
(
data
:
any
):
void
{
this
.
_send
(
'
message
'
,
data
);
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewElement.ts
浏览文件 @
95f8e3a1
...
...
@@ -295,14 +295,6 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
console
.
error
(
'
embedded page crashed
'
);
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
onmessage
,
(
data
:
any
)
=>
{
this
.
_onMessage
.
fire
(
data
);
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didClickLink
,
(
uri
:
string
)
=>
{
this
.
_onDidClickLink
.
fire
(
URI
.
parse
(
uri
));
}));
this
.
_register
(
this
.
on
(
'
synthetic-mouse-event
'
,
(
rawEvent
:
any
)
=>
{
if
(
!
this
.
element
)
{
return
;
...
...
@@ -329,10 +321,6 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
}
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
didScroll
,
(
scrollYPercentage
:
number
)
=>
{
this
.
_onDidScroll
.
fire
({
scrollYPercentage
:
scrollYPercentage
});
}));
this
.
_register
(
this
.
on
(
WebviewMessageChannels
.
doReload
,
()
=>
{
this
.
reload
();
}));
...
...
@@ -394,18 +382,9 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
parent
.
appendChild
(
this
.
element
);
}
private
readonly
_onDidClickLink
=
this
.
_register
(
new
Emitter
<
URI
>
());
public
readonly
onDidClickLink
=
this
.
_onDidClickLink
.
event
;
private
readonly
_onDidScroll
=
this
.
_register
(
new
Emitter
<
{
scrollYPercentage
:
number
;
}
>
());
public
readonly
onDidScroll
=
this
.
_onDidScroll
.
event
;
private
readonly
_onDidUpdateState
=
this
.
_register
(
new
Emitter
<
string
|
undefined
>
());
public
readonly
onDidUpdateState
=
this
.
_onDidUpdateState
.
event
;
private
readonly
_onMessage
=
this
.
_register
(
new
Emitter
<
any
>
());
public
readonly
onMessage
=
this
.
_onMessage
.
event
;
protected
postMessage
(
channel
:
string
,
data
?:
any
):
void
{
if
(
this
.
element
)
{
this
.
element
.
send
(
channel
,
data
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录