Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ffe09d36
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,发现更多精彩内容 >>
提交
ffe09d36
编写于
2月 05, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null work for webview
上级
7842634a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
28 deletion
+40
-28
src/vs/workbench/parts/html/electron-browser/html.contribution.ts
...orkbench/parts/html/electron-browser/html.contribution.ts
+2
-2
src/vs/workbench/parts/html/electron-browser/htmlPreviewPart.ts
.../workbench/parts/html/electron-browser/htmlPreviewPart.ts
+8
-9
src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts
...workbench/parts/webview/electron-browser/webviewEditor.ts
+11
-9
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
...ench/parts/webview/electron-browser/webviewEditorInput.ts
+6
-3
src/vs/workbench/parts/webview/electron-browser/webviewElement.ts
...orkbench/parts/webview/electron-browser/webviewElement.ts
+2
-2
src/vs/workbench/parts/webview/electron-browser/webviewFindWidget.ts
...bench/parts/webview/electron-browser/webviewFindWidget.ts
+11
-3
未找到文件。
src/vs/workbench/parts/html/electron-browser/html.contribution.ts
浏览文件 @
ffe09d36
...
...
@@ -23,7 +23,7 @@ function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI
return
accessor
.
get
(
IEditorService
).
visibleControls
.
filter
(
c
=>
c
instanceof
HtmlPreviewPart
&&
c
.
model
)
.
map
(
e
=>
e
as
HtmlPreviewPart
)
.
filter
(
e
=>
e
.
model
.
uri
.
scheme
===
uri
.
scheme
&&
e
.
model
.
uri
.
toString
()
===
uri
.
toString
());
.
filter
(
e
=>
e
.
model
!
.
uri
.
scheme
===
uri
.
scheme
&&
e
.
model
!
.
uri
.
toString
()
===
uri
.
toString
());
}
// --- Register Editor
...
...
@@ -45,7 +45,7 @@ CommandsRegistry.registerCommand('_workbench.previewHtml', function (
const
uri
=
resource
instanceof
URI
?
resource
:
URI
.
parse
(
resource
);
label
=
label
||
uri
.
fsPath
;
let
input
:
HtmlInput
;
let
input
:
HtmlInput
|
undefined
;
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
...
...
src/vs/workbench/parts/html/electron-browser/htmlPreviewPart.ts
浏览文件 @
ffe09d36
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
localize
}
from
'
vs/nls
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
Disposable
,
IDisposable
,
dispose
,
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
EditorOptions
,
EditorInput
,
IEditorMemento
}
from
'
vs/workbench/common/editor
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -38,8 +37,8 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
private
_webviewDisposables
:
IDisposable
[];
private
_modelRef
:
IReference
<
ITextEditorModel
>
;
public
get
model
()
:
ITextModel
{
return
this
.
_modelRef
&&
this
.
_modelRef
.
object
.
textEditorModel
;
}
private
_modelRef
?
:
IReference
<
ITextEditorModel
>
;
public
get
model
()
{
return
this
.
_modelRef
?
this
.
_modelRef
.
object
.
textEditorModel
:
undefined
;
}
private
_modelChangeSubscription
=
Disposable
.
None
;
private
_themeChangeSubscription
=
Disposable
.
None
;
...
...
@@ -138,14 +137,14 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
this
.
_themeChangeSubscription
=
this
.
themeService
.
onThemeChange
(
this
.
onThemeChange
.
bind
(
this
));
if
(
this
.
_hasValidModel
())
{
this
.
_modelChangeSubscription
=
this
.
model
.
onDidChangeContent
(()
=>
this
.
webview
.
contents
=
this
.
model
.
getLinesContent
().
join
(
'
\n
'
));
this
.
webview
.
contents
=
this
.
model
.
getLinesContent
().
join
(
'
\n
'
);
this
.
_modelChangeSubscription
=
this
.
model
!
.
onDidChangeContent
(()
=>
this
.
webview
.
contents
=
this
.
model
!
.
getLinesContent
().
join
(
'
\n
'
));
this
.
webview
.
contents
=
this
.
model
!
.
getLinesContent
().
join
(
'
\n
'
);
}
}
}
private
_hasValidModel
():
boolean
{
return
this
.
_modelRef
&&
this
.
model
&&
!
this
.
model
.
isDisposed
(
);
return
!!
(
this
.
_modelRef
&&
this
.
model
&&
!
this
.
model
.
isDisposed
()
);
}
public
layout
(
dimension
:
Dimension
):
void
{
...
...
@@ -248,10 +247,10 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
}
private
saveHTMLPreviewViewState
(
input
:
HtmlInput
,
editorViewState
:
HtmlPreviewEditorViewState
):
void
{
this
.
editorMemento
.
saveEditorState
(
this
.
group
,
input
,
editorViewState
);
this
.
editorMemento
.
saveEditorState
(
this
.
group
!
,
input
,
editorViewState
);
}
private
loadHTMLPreviewViewState
(
input
:
HtmlInput
):
HtmlPreviewEditorViewState
{
return
this
.
editorMemento
.
loadEditorState
(
this
.
group
,
input
);
private
loadHTMLPreviewViewState
(
input
:
HtmlInput
):
HtmlPreviewEditorViewState
|
undefined
{
return
this
.
editorMemento
.
loadEditorState
(
this
.
group
!
,
input
);
}
}
src/vs/workbench/parts/webview/electron-browser/webviewEditor.ts
浏览文件 @
ffe09d36
...
...
@@ -28,7 +28,7 @@ export class WebviewEditor extends BaseWebviewEditor {
public
static
readonly
ID
=
'
WebviewEditor
'
;
private
_editorFrame
:
HTMLElement
;
private
_content
:
HTMLElement
;
private
_content
?
:
HTMLElement
;
private
_webviewContent
:
HTMLElement
|
undefined
;
private
_webviewFocusTrackerDisposables
:
IDisposable
[]
=
[];
...
...
@@ -171,8 +171,9 @@ export class WebviewEditor extends BaseWebviewEditor {
if
(
token
.
isCancellationRequested
)
{
return
;
}
input
.
updateGroup
(
this
.
group
.
id
);
if
(
this
.
group
)
{
input
.
updateGroup
(
this
.
group
.
id
);
}
this
.
updateWebview
(
input
);
});
}
...
...
@@ -187,7 +188,7 @@ export class WebviewEditor extends BaseWebviewEditor {
useSameOriginForRoot
:
false
,
localResourceRoots
:
input
.
options
.
localResourceRoots
||
this
.
getDefaultLocalResourceRoots
(),
extensionLocation
:
input
.
extensionLocation
},
input
.
options
.
retainContextWhenHidden
);
},
!!
input
.
options
.
retainContextWhenHidden
);
if
(
this
.
_webviewContent
)
{
this
.
_webviewContent
.
style
.
visibility
=
'
visible
'
;
...
...
@@ -198,8 +199,9 @@ export class WebviewEditor extends BaseWebviewEditor {
private
getDefaultLocalResourceRoots
():
URI
[]
{
const
rootPaths
=
this
.
_contextService
.
getWorkspace
().
folders
.
map
(
x
=>
x
.
uri
);
if
((
this
.
input
as
WebviewEditorInput
).
extensionLocation
)
{
rootPaths
.
push
((
this
.
input
as
WebviewEditorInput
).
extensionLocation
);
const
extensionLocation
=
(
this
.
input
as
WebviewEditorInput
).
extensionLocation
;
if
(
extensionLocation
)
{
rootPaths
.
push
(
extensionLocation
);
}
return
rootPaths
;
}
...
...
@@ -235,7 +237,7 @@ export class WebviewEditor extends BaseWebviewEditor {
this
.
_webview
.
state
=
input
.
webviewState
;
this
.
_content
.
setAttribute
(
'
aria-flowto
'
,
this
.
_webviewContent
.
id
);
this
.
_content
!
.
setAttribute
(
'
aria-flowto
'
,
this
.
_webviewContent
.
id
);
this
.
doUpdateContainer
();
}
...
...
@@ -254,11 +256,11 @@ export class WebviewEditor extends BaseWebviewEditor {
this
.
_webviewFocusTrackerDisposables
=
dispose
(
this
.
_webviewFocusTrackerDisposables
);
// Track focus in webview content
const
webviewContentFocusTracker
=
DOM
.
trackFocus
(
this
.
_webviewContent
);
const
webviewContentFocusTracker
=
DOM
.
trackFocus
(
this
.
_webviewContent
!
);
this
.
_webviewFocusTrackerDisposables
.
push
(
webviewContentFocusTracker
);
this
.
_webviewFocusTrackerDisposables
.
push
(
webviewContentFocusTracker
.
onDidFocus
(()
=>
this
.
_onDidFocusWebview
.
fire
()));
// Track focus in webview element
this
.
_webviewFocusTrackerDisposables
.
push
(
this
.
_webview
.
onDidFocus
(()
=>
this
.
_onDidFocusWebview
.
fire
()));
this
.
_webviewFocusTrackerDisposables
.
push
(
this
.
_webview
!
.
onDidFocus
(()
=>
this
.
_onDidFocusWebview
.
fire
()));
}
}
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
浏览文件 @
ffe09d36
...
...
@@ -56,7 +56,7 @@ export class WebviewEditorInput extends EditorInput {
private
_html
:
string
=
''
;
private
_currentWebviewHtml
:
string
=
''
;
public
_events
:
WebviewEvents
|
undefined
;
private
_container
:
HTMLElement
;
private
_container
?
:
HTMLElement
;
private
_webview
:
WebviewElement
|
undefined
;
private
_webviewOwner
:
any
;
private
_webviewDisposables
:
IDisposable
[]
=
[];
...
...
@@ -139,7 +139,7 @@ export class WebviewEditorInput extends EditorInput {
return
this
.
getName
();
}
public
getDescription
()
:
string
{
public
getDescription
()
{
return
null
;
}
...
...
@@ -240,10 +240,13 @@ export class WebviewEditorInput extends EditorInput {
return
this
.
_webview
;
}
public
set
webview
(
value
:
WebviewElement
)
{
public
set
webview
(
value
:
WebviewElement
|
undefined
)
{
this
.
_webviewDisposables
=
dispose
(
this
.
_webviewDisposables
);
this
.
_webview
=
value
;
if
(
!
this
.
_webview
)
{
return
;
}
this
.
_webview
.
onDidClickLink
(
link
=>
{
if
(
this
.
_events
&&
this
.
_events
.
onDidClickLink
)
{
...
...
src/vs/workbench/parts/webview/electron-browser/webviewElement.ts
浏览文件 @
ffe09d36
...
...
@@ -44,7 +44,7 @@ interface IKeydownEvent {
class
WebviewProtocolProvider
extends
Disposable
{
constructor
(
webview
:
Electron
.
WebviewTag
,
private
readonly
_extensionLocation
:
URI
,
private
readonly
_extensionLocation
:
URI
|
undefined
,
private
readonly
_getLocalResourceRoots
:
()
=>
ReadonlyArray
<
URI
>
,
private
readonly
_environmentService
:
IEnvironmentService
,
private
readonly
_fileService
:
IFileService
,
...
...
@@ -356,7 +356,7 @@ export class WebviewElement extends Disposable {
}
public
mountTo
(
parent
:
HTMLElement
)
{
parent
.
appendChild
(
this
.
_webviewFindWidget
.
getDomNode
());
parent
.
appendChild
(
this
.
_webviewFindWidget
.
getDomNode
()
!
);
parent
.
appendChild
(
this
.
_webview
);
}
...
...
src/vs/workbench/parts/webview/electron-browser/webviewFindWidget.ts
浏览文件 @
ffe09d36
...
...
@@ -11,7 +11,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export
class
WebviewFindWidget
extends
SimpleFindWidget
{
constructor
(
private
_webview
:
WebviewElement
,
private
_webview
:
WebviewElement
|
undefined
,
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
...
...
@@ -24,6 +24,9 @@ export class WebviewFindWidget extends SimpleFindWidget {
}
public
find
(
previous
:
boolean
)
{
if
(
!
this
.
_webview
)
{
return
;
}
const
val
=
this
.
inputValue
;
if
(
val
)
{
this
.
_webview
.
find
(
val
,
{
findNext
:
true
,
forward
:
!
previous
});
...
...
@@ -32,11 +35,16 @@ export class WebviewFindWidget extends SimpleFindWidget {
public
hide
()
{
super
.
hide
();
this
.
_webview
.
stopFind
(
true
);
this
.
_webview
.
focus
();
if
(
this
.
_webview
)
{
this
.
_webview
.
stopFind
(
true
);
this
.
_webview
.
focus
();
}
}
public
onInputChanged
()
{
if
(
!
this
.
_webview
)
{
return
;
}
const
val
=
this
.
inputValue
;
if
(
val
)
{
this
.
_webview
.
startFind
(
val
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录