Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e1cb0377
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,发现更多精彩内容 >>
提交
e1cb0377
编写于
2月 28, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move previewConfig to own file
上级
dfa6e44b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
112 addition
and
103 deletion
+112
-103
extensions/markdown/src/features/preview.ts
extensions/markdown/src/features/preview.ts
+2
-1
extensions/markdown/src/features/previewConfig.ts
extensions/markdown/src/features/previewConfig.ts
+107
-0
extensions/markdown/src/features/previewContentProvider.ts
extensions/markdown/src/features/previewContentProvider.ts
+1
-101
extensions/markdown/src/features/previewManager.ts
extensions/markdown/src/features/previewManager.ts
+2
-1
未找到文件。
extensions/markdown/src/features/preview.ts
浏览文件 @
e1cb0377
...
...
@@ -7,11 +7,12 @@ import * as vscode from 'vscode';
import
*
as
path
from
'
path
'
;
import
{
Logger
}
from
'
../logger
'
;
import
{
MarkdownContentProvider
,
PreviewConfigManager
}
from
'
./previewContentProvider
'
;
import
{
MarkdownContentProvider
}
from
'
./previewContentProvider
'
;
import
{
disposeAll
}
from
'
../util/dispose
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
getVisibleLine
,
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
PreviewConfigManager
}
from
'
./previewConfig
'
;
const
localize
=
nls
.
loadMessageBundle
();
export
class
MarkdownPreview
{
...
...
extensions/markdown/src/features/previewConfig.ts
0 → 100644
浏览文件 @
e1cb0377
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
export
class
MarkdownPreviewConfig
{
public
static
getConfigForResource
(
resource
:
vscode
.
Uri
)
{
return
new
MarkdownPreviewConfig
(
resource
);
}
public
readonly
scrollBeyondLastLine
:
boolean
;
public
readonly
wordWrap
:
boolean
;
public
readonly
previewFrontMatter
:
string
;
public
readonly
lineBreaks
:
boolean
;
public
readonly
doubleClickToSwitchToEditor
:
boolean
;
public
readonly
scrollEditorWithPreview
:
boolean
;
public
readonly
scrollPreviewWithEditor
:
boolean
;
public
readonly
markEditorSelection
:
boolean
;
public
readonly
lineHeight
:
number
;
public
readonly
fontSize
:
number
;
public
readonly
fontFamily
:
string
|
undefined
;
public
readonly
styles
:
string
[];
private
constructor
(
resource
:
vscode
.
Uri
)
{
const
editorConfig
=
vscode
.
workspace
.
getConfiguration
(
'
editor
'
,
resource
);
const
markdownConfig
=
vscode
.
workspace
.
getConfiguration
(
'
markdown
'
,
resource
);
const
markdownEditorConfig
=
vscode
.
workspace
.
getConfiguration
(
'
[markdown]
'
);
this
.
scrollBeyondLastLine
=
editorConfig
.
get
<
boolean
>
(
'
scrollBeyondLastLine
'
,
false
);
this
.
wordWrap
=
editorConfig
.
get
<
string
>
(
'
wordWrap
'
,
'
off
'
)
!==
'
off
'
;
if
(
markdownEditorConfig
&&
markdownEditorConfig
[
'
editor.wordWrap
'
])
{
this
.
wordWrap
=
markdownEditorConfig
[
'
editor.wordWrap
'
]
!==
'
off
'
;
}
this
.
previewFrontMatter
=
markdownConfig
.
get
<
string
>
(
'
previewFrontMatter
'
,
'
hide
'
);
this
.
scrollPreviewWithEditor
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.scrollPreviewWithEditor
'
,
true
);
this
.
scrollEditorWithPreview
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.scrollEditorWithPreview
'
,
true
);
this
.
lineBreaks
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.breaks
'
,
false
);
this
.
doubleClickToSwitchToEditor
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.doubleClickToSwitchToEditor
'
,
true
);
this
.
markEditorSelection
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.markEditorSelection
'
,
true
);
this
.
fontFamily
=
markdownConfig
.
get
<
string
|
undefined
>
(
'
preview.fontFamily
'
,
undefined
);
this
.
fontSize
=
Math
.
max
(
8
,
+
markdownConfig
.
get
<
number
>
(
'
preview.fontSize
'
,
NaN
));
this
.
lineHeight
=
Math
.
max
(
0.6
,
+
markdownConfig
.
get
<
number
>
(
'
preview.lineHeight
'
,
NaN
));
this
.
styles
=
markdownConfig
.
get
<
string
[]
>
(
'
styles
'
,
[]);
}
public
isEqualTo
(
otherConfig
:
MarkdownPreviewConfig
)
{
for
(
let
key
in
this
)
{
if
(
this
.
hasOwnProperty
(
key
)
&&
key
!==
'
styles
'
)
{
if
(
this
[
key
]
!==
otherConfig
[
key
])
{
return
false
;
}
}
}
// Check styles
if
(
this
.
styles
.
length
!==
otherConfig
.
styles
.
length
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
this
.
styles
.
length
;
++
i
)
{
if
(
this
.
styles
[
i
]
!==
otherConfig
.
styles
[
i
])
{
return
false
;
}
}
return
true
;
}
[
key
:
string
]:
any
;
}
export
class
PreviewConfigManager
{
private
previewConfigurationsForWorkspaces
=
new
Map
<
string
,
MarkdownPreviewConfig
>
();
public
loadAndCacheConfiguration
(
resource
:
vscode
.
Uri
)
{
const
config
=
MarkdownPreviewConfig
.
getConfigForResource
(
resource
);
this
.
previewConfigurationsForWorkspaces
.
set
(
this
.
getKey
(
resource
),
config
);
return
config
;
}
public
shouldUpdateConfiguration
(
resource
:
vscode
.
Uri
):
boolean
{
const
key
=
this
.
getKey
(
resource
);
const
currentConfig
=
this
.
previewConfigurationsForWorkspaces
.
get
(
key
);
const
newConfig
=
MarkdownPreviewConfig
.
getConfigForResource
(
resource
);
return
(
!
currentConfig
||
!
currentConfig
.
isEqualTo
(
newConfig
));
}
private
getKey
(
resource
:
vscode
.
Uri
):
string
{
const
folder
=
vscode
.
workspace
.
getWorkspaceFolder
(
resource
);
if
(
!
folder
)
{
return
''
;
}
return
folder
.
uri
.
toString
();
}
}
extensions/markdown/src/features/previewContentProvider.ts
浏览文件 @
e1cb0377
...
...
@@ -12,6 +12,7 @@ const localize = nls.loadMessageBundle();
import
{
Logger
}
from
'
../logger
'
;
import
{
ContentSecurityPolicyArbiter
,
MarkdownPreviewSecurityLevel
}
from
'
../security
'
;
import
{
PreviewConfigManager
,
MarkdownPreviewConfig
}
from
'
./previewConfig
'
;
/**
* Strings used inside the markdown preview.
...
...
@@ -33,107 +34,6 @@ const previewStrings = {
'
Content Disabled Security Warning
'
)
};
export
class
MarkdownPreviewConfig
{
public
static
getConfigForResource
(
resource
:
vscode
.
Uri
)
{
return
new
MarkdownPreviewConfig
(
resource
);
}
public
readonly
scrollBeyondLastLine
:
boolean
;
public
readonly
wordWrap
:
boolean
;
public
readonly
previewFrontMatter
:
string
;
public
readonly
lineBreaks
:
boolean
;
public
readonly
doubleClickToSwitchToEditor
:
boolean
;
public
readonly
scrollEditorWithPreview
:
boolean
;
public
readonly
scrollPreviewWithEditor
:
boolean
;
public
readonly
markEditorSelection
:
boolean
;
public
readonly
lineHeight
:
number
;
public
readonly
fontSize
:
number
;
public
readonly
fontFamily
:
string
|
undefined
;
public
readonly
styles
:
string
[];
private
constructor
(
resource
:
vscode
.
Uri
)
{
const
editorConfig
=
vscode
.
workspace
.
getConfiguration
(
'
editor
'
,
resource
);
const
markdownConfig
=
vscode
.
workspace
.
getConfiguration
(
'
markdown
'
,
resource
);
const
markdownEditorConfig
=
vscode
.
workspace
.
getConfiguration
(
'
[markdown]
'
);
this
.
scrollBeyondLastLine
=
editorConfig
.
get
<
boolean
>
(
'
scrollBeyondLastLine
'
,
false
);
this
.
wordWrap
=
editorConfig
.
get
<
string
>
(
'
wordWrap
'
,
'
off
'
)
!==
'
off
'
;
if
(
markdownEditorConfig
&&
markdownEditorConfig
[
'
editor.wordWrap
'
])
{
this
.
wordWrap
=
markdownEditorConfig
[
'
editor.wordWrap
'
]
!==
'
off
'
;
}
this
.
previewFrontMatter
=
markdownConfig
.
get
<
string
>
(
'
previewFrontMatter
'
,
'
hide
'
);
this
.
scrollPreviewWithEditor
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.scrollPreviewWithEditor
'
,
true
);
this
.
scrollEditorWithPreview
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.scrollEditorWithPreview
'
,
true
);
this
.
lineBreaks
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.breaks
'
,
false
);
this
.
doubleClickToSwitchToEditor
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.doubleClickToSwitchToEditor
'
,
true
);
this
.
markEditorSelection
=
!!
markdownConfig
.
get
<
boolean
>
(
'
preview.markEditorSelection
'
,
true
);
this
.
fontFamily
=
markdownConfig
.
get
<
string
|
undefined
>
(
'
preview.fontFamily
'
,
undefined
);
this
.
fontSize
=
Math
.
max
(
8
,
+
markdownConfig
.
get
<
number
>
(
'
preview.fontSize
'
,
NaN
));
this
.
lineHeight
=
Math
.
max
(
0.6
,
+
markdownConfig
.
get
<
number
>
(
'
preview.lineHeight
'
,
NaN
));
this
.
styles
=
markdownConfig
.
get
<
string
[]
>
(
'
styles
'
,
[]);
}
public
isEqualTo
(
otherConfig
:
MarkdownPreviewConfig
)
{
for
(
let
key
in
this
)
{
if
(
this
.
hasOwnProperty
(
key
)
&&
key
!==
'
styles
'
)
{
if
(
this
[
key
]
!==
otherConfig
[
key
])
{
return
false
;
}
}
}
// Check styles
if
(
this
.
styles
.
length
!==
otherConfig
.
styles
.
length
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
this
.
styles
.
length
;
++
i
)
{
if
(
this
.
styles
[
i
]
!==
otherConfig
.
styles
[
i
])
{
return
false
;
}
}
return
true
;
}
[
key
:
string
]:
any
;
}
export
class
PreviewConfigManager
{
private
previewConfigurationsForWorkspaces
=
new
Map
<
string
,
MarkdownPreviewConfig
>
();
public
loadAndCacheConfiguration
(
resource
:
vscode
.
Uri
)
{
const
config
=
MarkdownPreviewConfig
.
getConfigForResource
(
resource
);
this
.
previewConfigurationsForWorkspaces
.
set
(
this
.
getKey
(
resource
),
config
);
return
config
;
}
public
shouldUpdateConfiguration
(
resource
:
vscode
.
Uri
):
boolean
{
const
key
=
this
.
getKey
(
resource
);
const
currentConfig
=
this
.
previewConfigurationsForWorkspaces
.
get
(
key
);
const
newConfig
=
MarkdownPreviewConfig
.
getConfigForResource
(
resource
);
return
(
!
currentConfig
||
!
currentConfig
.
isEqualTo
(
newConfig
));
}
private
getKey
(
resource
:
vscode
.
Uri
):
string
{
const
folder
=
vscode
.
workspace
.
getWorkspaceFolder
(
resource
);
if
(
!
folder
)
{
return
''
;
}
return
folder
.
uri
.
toString
();
}
}
export
class
MarkdownContentProvider
{
private
readonly
extraStyles
:
Array
<
vscode
.
Uri
>
=
[];
private
readonly
extraScripts
:
Array
<
vscode
.
Uri
>
=
[];
...
...
extensions/markdown/src/features/previewManager.ts
浏览文件 @
e1cb0377
...
...
@@ -6,11 +6,12 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
Logger
}
from
'
../logger
'
;
import
{
MarkdownContentProvider
,
PreviewConfigManager
}
from
'
./previewContentProvider
'
;
import
{
MarkdownContentProvider
}
from
'
./previewContentProvider
'
;
import
{
MarkdownPreview
,
PreviewSettings
}
from
'
./preview
'
;
import
{
disposeAll
}
from
'
../util/dispose
'
;
import
{
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
isMarkdownFile
}
from
'
../util/file
'
;
import
{
PreviewConfigManager
}
from
'
./previewConfig
'
;
export
class
MarkdownPreviewManager
{
private
static
readonly
markdownPreviewActiveContextKey
=
'
markdownPreviewFocus
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录