Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
776f9f74
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,发现更多精彩内容 >>
提交
776f9f74
编写于
1月 14, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - drop support for URL preview
上级
b98f99c5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
88 deletion
+16
-88
src/vs/workbench/browser/parts/editor/iframeEditor.ts
src/vs/workbench/browser/parts/editor/iframeEditor.ts
+11
-68
src/vs/workbench/common/editor/iframeEditorModel.ts
src/vs/workbench/common/editor/iframeEditorModel.ts
+3
-19
src/vs/workbench/parts/markdown/common/markdownEditorModel.ts
...vs/workbench/parts/markdown/common/markdownEditorModel.ts
+2
-1
未找到文件。
src/vs/workbench/browser/parts/editor/iframeEditor.ts
浏览文件 @
776f9f74
...
...
@@ -22,12 +22,11 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
/**
* An implementation of editor for
embedding a URL into
an IFrame by leveraging the IFrameEditorInput.
* An implementation of editor for
showing HTML content in
an IFrame by leveraging the IFrameEditorInput.
*/
export
class
IFrameEditor
extends
BaseEditor
{
public
static
ID
=
'
workbench.editors.iFrameEditor
'
;
public
static
allowScriptExecutionSettingsKey
=
'
workbench.editor.allowIframeScriptExecution
'
;
private
static
RESOURCE_PROPERTY
=
'
resource
'
;
...
...
@@ -96,44 +95,19 @@ export class IFrameEditor extends BaseEditor {
return
null
;
}
let
allowScriptExecution
=
this
.
storageService
.
getBoolean
(
IFrameEditor
.
allowScriptExecutionSettingsKey
,
StorageScope
.
WORKSPACE
,
false
);
// Set IFrame contents directly
// Set IFrame contents
let
iframeModel
=
<
IFrameEditorModel
>
resolvedModel
;
if
(
iframeModel
.
hasContents
())
{
let
isUpdate
=
!
isNewInput
&&
!!
this
.
iframeBuilder
.
getProperty
(
IFrameEditor
.
RESOURCE_PROPERTY
);
let
contents
=
iframeModel
.
getContents
();
// Sanitize Script from content if script execution is not allowed
if
(
!
allowScriptExecution
)
{
contents
.
body
=
DOM
.
removeScriptTags
(
contents
.
body
);
}
// Crazy hack to get keybindings to bubble out of the iframe to us
contents
.
body
=
contents
.
body
+
this
.
enableKeybindings
();
// Set Contents
try
{
this
.
setFrameContents
(
iframeModel
.
resource
,
isUpdate
?
contents
.
body
:
[
contents
.
head
,
contents
.
body
,
contents
.
tail
].
join
(
'
\n
'
),
isUpdate
/* body only */
);
}
catch
(
error
)
{
setTimeout
(()
=>
this
.
reload
(
true
/* clear */
),
1000
);
// retry in case of an error which indicates the iframe (only) might be on a different URL
}
}
// Set IFrame source location
else
{
let
isUpdate
=
!
isNewInput
&&
!!
this
.
iframeBuilder
.
getProperty
(
IFrameEditor
.
RESOURCE_PROPERTY
);
let
contents
=
iframeModel
.
getContents
();
// Sandboxing (can only be applied when using a real source location)
if
(
allowScriptExecution
)
{
this
.
iframeBuilder
.
removeAttribute
(
'
sandbox
'
);
}
else
{
this
.
iframeBuilder
.
attr
({
'
sandbox
'
:
'
allow-same-origin
'
// protect us from attacks (see http://www.w3schools.com/tags/att_iframe_sandbox.asp)
});
}
// Crazy hack to get keybindings to bubble out of the iframe to us
contents
.
body
=
contents
.
body
+
this
.
enableKeybindings
();
// Set URL
this
.
iframeBuilder
.
src
(
iframeModel
.
getUrl
()
+
'
?etag=
'
+
new
Date
().
getTime
());
// make sure to bypass browser caches by appending current time
// Set Contents
try
{
this
.
setFrameContents
(
iframeModel
.
resource
,
isUpdate
?
contents
.
body
:
[
contents
.
head
,
contents
.
body
,
contents
.
tail
].
join
(
'
\n
'
),
isUpdate
/* body only */
);
}
catch
(
error
)
{
setTimeout
(()
=>
this
.
reload
(
true
/* clear */
),
1000
);
// retry in case of an error which indicates the iframe (only) might be on a different URL
}
});
}
...
...
@@ -278,35 +252,4 @@ export class IFrameEditor extends BaseEditor {
super
.
dispose
();
}
}
export
class
ToggleJavaScriptInIFrameEditorInputAction
extends
EditorInputAction
{
constructor
(
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IStorageService
private
storageService
:
IStorageService
)
{
super
(
'
workbench.files.action.toggleJSInIFrameEditor
'
,
nls
.
localize
(
'
enableJavaScript
'
,
"
Enable JavaScript
"
));
}
public
get
label
():
string
{
let
allowScriptExecution
=
this
.
storageService
.
getBoolean
(
IFrameEditor
.
allowScriptExecutionSettingsKey
,
StorageScope
.
WORKSPACE
,
false
);
if
(
allowScriptExecution
)
{
return
nls
.
localize
(
'
disableJavaScript
'
,
"
Disable JavaScript
"
);
}
return
nls
.
localize
(
'
enableJavaScript
'
,
"
Enable JavaScript
"
);
}
public
run
(
event
?:
any
):
Promise
{
// Apply globally
this
.
storageService
.
swap
(
IFrameEditor
.
allowScriptExecutionSettingsKey
,
true
,
false
,
StorageScope
.
WORKSPACE
,
false
);
let
options
=
new
EditorOptions
();
options
.
forceOpen
=
true
;
// force open since we open the same input again
return
this
.
editorService
.
openEditor
(
this
.
input
,
options
,
this
.
position
);
}
}
\ No newline at end of file
src/vs/workbench/common/editor/iframeEditorModel.ts
浏览文件 @
776f9f74
...
...
@@ -15,9 +15,9 @@ export interface IFrameContents {
/**
* An editor model that represents the resolved state for an iframe editor input. After the model has been
* resolved it knows which
URL or content to pass to the iframe editor. If a URL is being used, this will
*
be set as the iframe's URL. Otherwise the contents will be set directly into the iframe. In that cas
e
*
the contents have to ensure that e.g. a base URL is set so that relative links or images can be
resolved.
* resolved it knows which
content to pass to the iframe editor. The contents will be set directly into the
*
iframe. The contents have to ensure that e.g. a base URL is set so that relative links or images can b
e
* resolved.
*/
export
class
IFrameEditorModel
extends
EditorModel
{
private
_resource
:
URI
;
...
...
@@ -37,18 +37,6 @@ export class IFrameEditorModel extends EditorModel {
return
this
.
_resource
;
}
public
setUrl
(
url
:
string
):
void
{
this
.
url
=
url
;
}
public
getUrl
():
string
{
return
this
.
url
;
}
public
hasUrl
():
boolean
{
return
!!
this
.
url
;
}
public
setContents
(
head
:
string
,
body
:
string
,
tail
:
string
):
void
{
this
.
head
=
head
;
this
.
body
=
body
;
...
...
@@ -62,8 +50,4 @@ export class IFrameEditorModel extends EditorModel {
tail
:
this
.
tail
};
}
public
hasContents
():
boolean
{
return
!!
this
.
head
||
!!
this
.
body
||
!!
this
.
tail
;
}
}
\ No newline at end of file
src/vs/workbench/parts/markdown/common/markdownEditorModel.ts
浏览文件 @
776f9f74
...
...
@@ -30,7 +30,8 @@ interface IMarkdownWorkerOutput extends IEmitOutput {
*/
export
class
MarkdownEditorModel
extends
IFrameEditorModel
{
constructor
(
resource
:
URI
,
constructor
(
resource
:
URI
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IStorageService
private
storageService
:
IStorageService
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录