Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f3caf387
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,发现更多精彩内容 >>
提交
f3caf387
编写于
7月 25, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Also serialize and restore webview icons
上级
8899e43f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
43 deletion
+54
-43
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
+1
-39
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
...ench/parts/webview/electron-browser/webviewEditorInput.ts
+45
-1
src/vs/workbench/parts/webview/electron-browser/webviewEditorInputFactory.ts
...rts/webview/electron-browser/webviewEditorInputFactory.ts
+5
-2
src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts
...ch/parts/webview/electron-browser/webviewEditorService.ts
+3
-1
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
浏览文件 @
f3caf387
...
...
@@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
map
from
'
vs/base/common/map
'
;
import
URI
,
{
UriComponents
}
from
'
vs/base/common/uri
'
;
...
...
@@ -30,39 +29,6 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
private
static
revivalPool
=
0
;
private
static
_styleElement
?:
HTMLStyleElement
;
private
static
_icons
=
new
Map
<
number
,
{
light
:
URI
,
dark
:
URI
}
>
();
private
static
updateStyleElement
(
webview
:
WebviewEditorInput
,
iconPath
:
{
light
:
URI
,
dark
:
URI
}
|
undefined
)
{
const
id
=
webview
.
getId
();
if
(
!
this
.
_styleElement
)
{
this
.
_styleElement
=
dom
.
createStyleSheet
();
this
.
_styleElement
.
className
=
'
webview-icons
'
;
}
if
(
!
iconPath
)
{
this
.
_icons
.
delete
(
id
);
}
else
{
this
.
_icons
.
set
(
id
,
iconPath
);
}
const
cssRules
:
string
[]
=
[];
this
.
_icons
.
forEach
((
value
,
key
)
=>
{
const
webviewSelector
=
`.show-file-icons .webview-
${
key
}
-name-file-icon::before`
;
if
(
URI
.
isUri
(
value
))
{
cssRules
.
push
(
`
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
toString
()}
); }`
);
}
else
{
cssRules
.
push
(
`
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
light
.
toString
()}
); }`
);
cssRules
.
push
(
`.vs-dark
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
dark
.
toString
()}
); }`
);
}
});
this
.
_styleElement
.
innerHTML
=
cssRules
.
join
(
'
\n
'
);
}
private
_toDispose
:
IDisposable
[]
=
[];
private
readonly
_proxy
:
ExtHostWebviewsShape
;
...
...
@@ -132,7 +98,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
public
$setIconPath
(
handle
:
WebviewPanelHandle
,
value
:
{
light
:
UriComponents
,
dark
:
UriComponents
}
|
undefined
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
MainThreadWebviews
.
updateStyleElement
(
webview
,
reviveWebviewIcon
(
value
)
);
webview
.
iconPath
=
reviveWebviewIcon
(
value
);
}
public
$setHtml
(
handle
:
WebviewPanelHandle
,
value
:
string
):
void
{
...
...
@@ -225,10 +191,6 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
onMessage
:
message
=>
this
.
_proxy
.
$onMessage
(
handle
,
message
),
onDispose
:
()
=>
{
const
cleanUp
=
()
=>
{
const
webview
=
this
.
_webviews
.
get
(
handle
);
if
(
webview
)
{
MainThreadWebviews
.
updateStyleElement
(
webview
,
undefined
);
}
this
.
_webviews
.
delete
(
handle
);
};
this
.
_proxy
.
$onDidDisposeWebviewPanel
(
handle
).
then
(
...
...
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
浏览文件 @
f3caf387
...
...
@@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -14,12 +14,47 @@ import * as vscode from 'vscode';
import
{
WebviewEvents
,
WebviewInputOptions
,
WebviewReviver
}
from
'
./webviewEditorService
'
;
import
{
WebviewElement
}
from
'
./webviewElement
'
;
export
class
WebviewEditorInput
extends
EditorInput
{
private
static
handlePool
=
0
;
private
static
_styleElement
?:
HTMLStyleElement
;
private
static
_icons
=
new
Map
<
number
,
{
light
:
URI
,
dark
:
URI
}
>
();
private
static
updateStyleElement
(
id
:
number
,
iconPath
:
{
light
:
URI
,
dark
:
URI
}
|
undefined
)
{
if
(
!
this
.
_styleElement
)
{
this
.
_styleElement
=
dom
.
createStyleSheet
();
this
.
_styleElement
.
className
=
'
webview-icons
'
;
}
if
(
!
iconPath
)
{
this
.
_icons
.
delete
(
id
);
}
else
{
this
.
_icons
.
set
(
id
,
iconPath
);
}
const
cssRules
:
string
[]
=
[];
this
.
_icons
.
forEach
((
value
,
key
)
=>
{
const
webviewSelector
=
`.show-file-icons .webview-
${
key
}
-name-file-icon::before`
;
if
(
URI
.
isUri
(
value
))
{
cssRules
.
push
(
`
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
toString
()}
); }`
);
}
else
{
cssRules
.
push
(
`
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
light
.
toString
()}
); }`
);
cssRules
.
push
(
`.vs-dark
${
webviewSelector
}
{ content: ""; background-image: url(
${
value
.
dark
.
toString
()}
); }`
);
}
});
this
.
_styleElement
.
innerHTML
=
cssRules
.
join
(
'
\n
'
);
}
public
static
readonly
typeId
=
'
workbench.editors.webviewInput
'
;
private
_name
:
string
;
private
_iconPath
?:
{
light
:
URI
,
dark
:
URI
};
private
_options
:
WebviewInputOptions
;
private
_html
:
string
=
''
;
private
_currentWebviewHtml
:
string
=
''
;
...
...
@@ -109,6 +144,15 @@ export class WebviewEditorInput extends EditorInput {
this
.
_onDidChangeLabel
.
fire
();
}
public
get
iconPath
()
{
return
this
.
_iconPath
;
}
public
set
iconPath
(
value
:
{
light
:
URI
,
dark
:
URI
}
|
undefined
)
{
this
.
_iconPath
=
value
;
WebviewEditorInput
.
updateStyleElement
(
this
.
_id
,
value
);
}
public
matches
(
other
:
IEditorInput
):
boolean
{
return
other
&&
other
===
this
;
}
...
...
src/vs/workbench/parts/webview/electron-browser/webviewEditorInputFactory.ts
浏览文件 @
f3caf387
...
...
@@ -15,6 +15,7 @@ interface SerializedWebview {
readonly
options
:
WebviewInputOptions
;
readonly
extensionLocation
:
string
;
readonly
state
:
any
;
readonly
iconPath
:
{
light
:
string
,
dark
:
string
}
|
undefined
;
}
export
class
WebviewEditorInputFactory
implements
IEditorInputFactory
{
...
...
@@ -43,7 +44,8 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
title
:
input
.
getName
(),
options
:
input
.
options
,
extensionLocation
:
input
.
extensionLocation
.
toString
(),
state
:
input
.
state
state
:
input
.
state
,
iconPath
:
input
.
iconPath
?
{
light
:
input
.
iconPath
.
light
.
toString
(),
dark
:
input
.
iconPath
.
dark
.
toString
(),
}
:
undefined
,
};
return
JSON
.
stringify
(
data
);
}
...
...
@@ -54,6 +56,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
):
WebviewEditorInput
{
const
data
:
SerializedWebview
=
JSON
.
parse
(
serializedEditorInput
);
const
extensionLocation
=
URI
.
parse
(
data
.
extensionLocation
);
return
this
.
_webviewService
.
reviveWebview
(
data
.
viewType
,
data
.
title
,
data
.
state
,
data
.
options
,
extensionLocation
);
const
iconPath
=
data
.
iconPath
?
{
light
:
URI
.
parse
(
data
.
iconPath
.
light
),
dark
:
URI
.
parse
(
data
.
iconPath
.
dark
)
}
:
undefined
;
return
this
.
_webviewService
.
reviveWebview
(
data
.
viewType
,
data
.
title
,
iconPath
,
data
.
state
,
data
.
options
,
extensionLocation
);
}
}
src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts
浏览文件 @
f3caf387
...
...
@@ -36,6 +36,7 @@ export interface IWebviewEditorService {
reviveWebview
(
viewType
:
string
,
title
:
string
,
iconPath
:
{
light
:
URI
,
dark
:
URI
}
|
undefined
,
state
:
any
,
options
:
WebviewInputOptions
,
extensionLocation
:
URI
...
...
@@ -126,6 +127,7 @@ export class WebviewEditorService implements IWebviewEditorService {
reviveWebview
(
viewType
:
string
,
title
:
string
,
iconPath
:
{
light
:
URI
,
dark
:
URI
}
|
undefined
,
state
:
any
,
options
:
WebviewInputOptions
,
extensionLocation
:
URI
...
...
@@ -148,7 +150,7 @@ export class WebviewEditorService implements IWebviewEditorService {
});
}
});
webviewInput
.
iconPath
=
iconPath
;
return
webviewInput
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录