Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5fc4fe22
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,体验更适合开发者的 AI 搜索 >>
提交
5fc4fe22
编写于
9月 17, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add resolveExternalUri embedder contribution point
上级
86baf839
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
63 addition
and
7 deletion
+63
-7
src/vs/editor/browser/services/openerService.ts
src/vs/editor/browser/services/openerService.ts
+12
-2
src/vs/platform/opener/common/opener.ts
src/vs/platform/opener/common/opener.ts
+14
-4
src/vs/workbench/contrib/url/common/externalUriResolver.ts
src/vs/workbench/contrib/url/common/externalUriResolver.ts
+26
-0
src/vs/workbench/contrib/url/common/url.contribution.ts
src/vs/workbench/contrib/url/common/url.contribution.ts
+6
-1
src/vs/workbench/workbench.web.api.ts
src/vs/workbench/workbench.web.api.ts
+5
-0
未找到文件。
src/vs/editor/browser/services/openerService.ts
浏览文件 @
5fc4fe22
...
...
@@ -13,7 +13,7 @@ import { equalsIgnoreCase } from 'vs/base/common/strings';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
CommandsRegistry
,
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IOpener
,
IOpenerService
,
IValidator
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IOpener
,
IOpenerService
,
IValidator
,
IExternalUriResolver
}
from
'
vs/platform/opener/common/opener
'
;
export
class
OpenerService
extends
Disposable
implements
IOpenerService
{
...
...
@@ -21,6 +21,7 @@ export class OpenerService extends Disposable implements IOpenerService {
private
readonly
_openers
=
new
LinkedList
<
IOpener
>
();
private
readonly
_validators
=
new
LinkedList
<
IValidator
>
();
private
readonly
_resolvers
=
new
LinkedList
<
IExternalUriResolver
>
();
constructor
(
@
ICodeEditorService
private
readonly
_editorService
:
ICodeEditorService
,
...
...
@@ -39,6 +40,11 @@ export class OpenerService extends Disposable implements IOpenerService {
return
{
dispose
:
remove
};
}
registerExternalUriResolver
(
resolver
:
IExternalUriResolver
):
IDisposable
{
const
remove
=
this
.
_resolvers
.
push
(
resolver
);
return
{
dispose
:
remove
};
}
async
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
,
openExternal
?:
boolean
}):
Promise
<
boolean
>
{
// no scheme ?!?
if
(
!
resource
.
scheme
)
{
...
...
@@ -118,7 +124,11 @@ export class OpenerService extends Disposable implements IOpenerService {
}
}
private
_doOpenExternal
(
resource
:
URI
):
Promise
<
boolean
>
{
private
async
_doOpenExternal
(
resource
:
URI
):
Promise
<
boolean
>
{
for
(
const
resolver
of
this
.
_resolvers
.
toArray
())
{
resource
=
await
resolver
.
resolveExternalUri
(
resource
);
}
dom
.
windowOpenNoOpener
(
encodeURI
(
resource
.
toString
(
true
)));
return
Promise
.
resolve
(
true
);
...
...
src/vs/platform/opener/common/opener.ts
浏览文件 @
5fc4fe22
...
...
@@ -5,7 +5,7 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
const
IOpenerService
=
createDecorator
<
IOpenerService
>
(
'
openerService
'
);
...
...
@@ -18,6 +18,10 @@ export interface IValidator {
shouldOpen
(
resource
:
URI
):
Promise
<
boolean
>
;
}
export
interface
IExternalUriResolver
{
resolveExternalUri
(
resource
:
URI
):
Promise
<
URI
>
;
}
export
interface
IOpenerService
{
_serviceBrand
:
undefined
;
...
...
@@ -29,10 +33,15 @@ export interface IOpenerService {
/**
* Register a participant that can validate if the URI resource be opened.
*
v
alidators are run before openers.
*
V
alidators are run before openers.
*/
registerValidator
(
validator
:
IValidator
):
IDisposable
;
/**
* Register a participant that can resolve an external URI resource to be opened.
*/
registerExternalUriResolver
(
resolver
:
IExternalUriResolver
):
IDisposable
;
/**
* Opens a resource, like a webaddress, a document uri, or executes command.
*
...
...
@@ -45,7 +54,8 @@ export interface IOpenerService {
export
const
NullOpenerService
:
IOpenerService
=
Object
.
freeze
({
_serviceBrand
:
undefined
,
registerOpener
()
{
return
{
dispose
()
{
}
};
},
registerValidator
()
{
return
{
dispose
()
{
}
};
},
registerOpener
()
{
return
Disposable
.
None
;
},
registerValidator
()
{
return
Disposable
.
None
;
},
registerExternalUriResolver
()
{
return
Disposable
.
None
;
},
open
()
{
return
Promise
.
resolve
(
false
);
},
});
src/vs/workbench/contrib/url/common/externalUriResolver.ts
0 → 100644
浏览文件 @
5fc4fe22
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
export
class
ExternalUriResolverContribution
extends
Disposable
implements
IWorkbenchContribution
{
constructor
(
@
IOpenerService
_openerService
:
IOpenerService
,
@
IWorkbenchEnvironmentService
_workbenchEnvironmentService
:
IWorkbenchEnvironmentService
,
)
{
super
();
if
(
_workbenchEnvironmentService
.
options
&&
_workbenchEnvironmentService
.
options
.
resolveExternalUri
)
{
this
.
_register
(
_openerService
.
registerExternalUriResolver
({
resolveExternalUri
:
async
(
resource
)
=>
{
return
_workbenchEnvironmentService
.
options
!
.
resolveExternalUri
!
(
resource
);
}
}));
}
}
}
src/vs/workbench/contrib/url/common/url.contribution.ts
浏览文件 @
5fc4fe22
...
...
@@ -14,9 +14,10 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
Extensions
as
ActionExtensions
,
IWorkbenchActionRegistry
}
from
'
vs/workbench/common/actions
'
;
import
{
Extensions
as
WorkbenchExtensions
,
IWorkbenchContributionsRegistry
}
from
'
vs/workbench/common/contributions
'
;
import
{
ExternalUriResolverContribution
}
from
'
vs/workbench/contrib/url/common/externalUriResolver
'
;
import
{
configureTrustedDomainSettingsCommand
}
from
'
vs/workbench/contrib/url/common/trustedDomains
'
;
import
{
OpenerValidatorContributions
}
from
'
vs/workbench/contrib/url/common/trustedDomainsValidator
'
;
import
{
TrustedDomainsFileSystemProvider
}
from
'
vs/workbench/contrib/url/common/trustedDomainsFileSystemProvider
'
;
import
{
OpenerValidatorContributions
}
from
'
vs/workbench/contrib/url/common/trustedDomainsValidator
'
;
export
class
OpenUrlAction
extends
Action
{
static
readonly
ID
=
'
workbench.action.url.openUrl
'
;
...
...
@@ -65,3 +66,7 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
TrustedDomainsFileSystemProvider
,
LifecyclePhase
.
Ready
);
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
ExternalUriResolverContribution
,
LifecyclePhase
.
Ready
);
src/vs/workbench/workbench.web.api.ts
浏览文件 @
5fc4fe22
...
...
@@ -90,6 +90,11 @@ interface IWorkbenchConstructionOptions {
* Experimental: Support for update reporting.
*/
updateProvider
?:
IUpdateProvider
;
/**
* Experimental: Resolves an external uri before it is opened.
*/
readonly
resolveExternalUri
?:
(
uri
:
URI
)
=>
Promise
<
URI
>
;
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录