Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ea2132e4
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,发现更多精彩内容 >>
提交
ea2132e4
编写于
2月 28, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleaning up class and method names
上级
e1cb0377
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
24 deletion
+21
-24
extensions/markdown/src/features/preview.ts
extensions/markdown/src/features/preview.ts
+3
-3
extensions/markdown/src/features/previewConfig.ts
extensions/markdown/src/features/previewConfig.ts
+11
-14
extensions/markdown/src/features/previewContentProvider.ts
extensions/markdown/src/features/previewContentProvider.ts
+5
-5
extensions/markdown/src/features/previewManager.ts
extensions/markdown/src/features/previewManager.ts
+2
-2
未找到文件。
extensions/markdown/src/features/preview.ts
浏览文件 @
ea2132e4
...
@@ -12,7 +12,7 @@ import { disposeAll } from '../util/dispose';
...
@@ -12,7 +12,7 @@ import { disposeAll } from '../util/dispose';
import
*
as
nls
from
'
vscode-nls
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
getVisibleLine
,
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
getVisibleLine
,
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
PreviewConfig
Manager
}
from
'
./previewConfig
'
;
import
{
MarkdownPreviewConfiguration
Manager
}
from
'
./previewConfig
'
;
const
localize
=
nls
.
loadMessageBundle
();
const
localize
=
nls
.
loadMessageBundle
();
export
class
MarkdownPreview
{
export
class
MarkdownPreview
{
...
@@ -35,7 +35,7 @@ export class MarkdownPreview {
...
@@ -35,7 +35,7 @@ export class MarkdownPreview {
previewColumn
:
vscode
.
ViewColumn
,
previewColumn
:
vscode
.
ViewColumn
,
public
locked
:
boolean
,
public
locked
:
boolean
,
private
readonly
contentProvider
:
MarkdownContentProvider
,
private
readonly
contentProvider
:
MarkdownContentProvider
,
private
readonly
previewConfigurations
:
PreviewConfig
Manager
,
private
readonly
previewConfigurations
:
MarkdownPreviewConfiguration
Manager
,
private
readonly
logger
:
Logger
,
private
readonly
logger
:
Logger
,
topmostLineMonitor
:
MarkdownFileTopmostLineMonitor
topmostLineMonitor
:
MarkdownFileTopmostLineMonitor
)
{
)
{
...
@@ -156,7 +156,7 @@ export class MarkdownPreview {
...
@@ -156,7 +156,7 @@ export class MarkdownPreview {
}
}
public
updateConfiguration
()
{
public
updateConfiguration
()
{
if
(
this
.
previewConfigurations
.
shouldUpdateConfiguration
(
this
.
_resource
))
{
if
(
this
.
previewConfigurations
.
hasConfigurationChanged
(
this
.
_resource
))
{
this
.
refresh
();
this
.
refresh
();
}
}
}
}
...
...
extensions/markdown/src/features/previewConfig.ts
浏览文件 @
ea2132e4
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
export
class
MarkdownPreviewConfig
{
export
class
MarkdownPreviewConfig
uration
{
public
static
get
Config
ForResource
(
resource
:
vscode
.
Uri
)
{
public
static
getForResource
(
resource
:
vscode
.
Uri
)
{
return
new
MarkdownPreviewConfig
(
resource
);
return
new
MarkdownPreviewConfig
uration
(
resource
);
}
}
public
readonly
scrollBeyondLastLine
:
boolean
;
public
readonly
scrollBeyondLastLine
:
boolean
;
...
@@ -50,7 +50,7 @@ export class MarkdownPreviewConfig {
...
@@ -50,7 +50,7 @@ export class MarkdownPreviewConfig {
this
.
styles
=
markdownConfig
.
get
<
string
[]
>
(
'
styles
'
,
[]);
this
.
styles
=
markdownConfig
.
get
<
string
[]
>
(
'
styles
'
,
[]);
}
}
public
isEqualTo
(
otherConfig
:
MarkdownPreviewConfig
)
{
public
isEqualTo
(
otherConfig
:
MarkdownPreviewConfig
uration
)
{
for
(
let
key
in
this
)
{
for
(
let
key
in
this
)
{
if
(
this
.
hasOwnProperty
(
key
)
&&
key
!==
'
styles
'
)
{
if
(
this
.
hasOwnProperty
(
key
)
&&
key
!==
'
styles
'
)
{
if
(
this
[
key
]
!==
otherConfig
[
key
])
{
if
(
this
[
key
]
!==
otherConfig
[
key
])
{
...
@@ -75,23 +75,23 @@ export class MarkdownPreviewConfig {
...
@@ -75,23 +75,23 @@ export class MarkdownPreviewConfig {
[
key
:
string
]:
any
;
[
key
:
string
]:
any
;
}
}
export
class
PreviewConfig
Manager
{
export
class
MarkdownPreviewConfiguration
Manager
{
private
previewConfigurationsForWorkspaces
=
new
Map
<
string
,
MarkdownPreviewConfig
>
();
private
readonly
previewConfigurationsForWorkspaces
=
new
Map
<
string
,
MarkdownPreviewConfiguration
>
();
public
loadAndCacheConfiguration
(
public
loadAndCacheConfiguration
(
resource
:
vscode
.
Uri
resource
:
vscode
.
Uri
)
{
)
:
MarkdownPreviewConfiguration
{
const
config
=
MarkdownPreviewConfig
.
getConfig
ForResource
(
resource
);
const
config
=
MarkdownPreviewConfig
uration
.
get
ForResource
(
resource
);
this
.
previewConfigurationsForWorkspaces
.
set
(
this
.
getKey
(
resource
),
config
);
this
.
previewConfigurationsForWorkspaces
.
set
(
this
.
getKey
(
resource
),
config
);
return
config
;
return
config
;
}
}
public
shouldUpdateConfiguration
(
public
hasConfigurationChanged
(
resource
:
vscode
.
Uri
resource
:
vscode
.
Uri
):
boolean
{
):
boolean
{
const
key
=
this
.
getKey
(
resource
);
const
key
=
this
.
getKey
(
resource
);
const
currentConfig
=
this
.
previewConfigurationsForWorkspaces
.
get
(
key
);
const
currentConfig
=
this
.
previewConfigurationsForWorkspaces
.
get
(
key
);
const
newConfig
=
MarkdownPreviewConfig
.
getConfig
ForResource
(
resource
);
const
newConfig
=
MarkdownPreviewConfig
uration
.
get
ForResource
(
resource
);
return
(
!
currentConfig
||
!
currentConfig
.
isEqualTo
(
newConfig
));
return
(
!
currentConfig
||
!
currentConfig
.
isEqualTo
(
newConfig
));
}
}
...
@@ -99,9 +99,6 @@ export class PreviewConfigManager {
...
@@ -99,9 +99,6 @@ export class PreviewConfigManager {
resource
:
vscode
.
Uri
resource
:
vscode
.
Uri
):
string
{
):
string
{
const
folder
=
vscode
.
workspace
.
getWorkspaceFolder
(
resource
);
const
folder
=
vscode
.
workspace
.
getWorkspaceFolder
(
resource
);
if
(
!
folder
)
{
return
folder
?
folder
.
uri
.
toString
()
:
''
;
return
''
;
}
return
folder
.
uri
.
toString
();
}
}
}
}
extensions/markdown/src/features/previewContentProvider.ts
浏览文件 @
ea2132e4
...
@@ -12,7 +12,7 @@ const localize = nls.loadMessageBundle();
...
@@ -12,7 +12,7 @@ const localize = nls.loadMessageBundle();
import
{
Logger
}
from
'
../logger
'
;
import
{
Logger
}
from
'
../logger
'
;
import
{
ContentSecurityPolicyArbiter
,
MarkdownPreviewSecurityLevel
}
from
'
../security
'
;
import
{
ContentSecurityPolicyArbiter
,
MarkdownPreviewSecurityLevel
}
from
'
../security
'
;
import
{
PreviewConfigManager
,
MarkdownPreviewConfig
}
from
'
./previewConfig
'
;
import
{
MarkdownPreviewConfigurationManager
,
MarkdownPreviewConfiguration
}
from
'
./previewConfig
'
;
/**
/**
* Strings used inside the markdown preview.
* Strings used inside the markdown preview.
...
@@ -55,7 +55,7 @@ export class MarkdownContentProvider {
...
@@ -55,7 +55,7 @@ export class MarkdownContentProvider {
public
async
provideTextDocumentContent
(
public
async
provideTextDocumentContent
(
markdownDocument
:
vscode
.
TextDocument
,
markdownDocument
:
vscode
.
TextDocument
,
previewConfigurations
:
PreviewConfig
Manager
,
previewConfigurations
:
MarkdownPreviewConfiguration
Manager
,
initialLine
:
number
|
undefined
=
undefined
initialLine
:
number
|
undefined
=
undefined
):
Promise
<
string
>
{
):
Promise
<
string
>
{
const
sourceUri
=
markdownDocument
.
uri
;
const
sourceUri
=
markdownDocument
.
uri
;
...
@@ -134,7 +134,7 @@ export class MarkdownContentProvider {
...
@@ -134,7 +134,7 @@ export class MarkdownContentProvider {
.
toString
();
.
toString
();
}
}
private
computeCustomStyleSheetIncludes
(
resource
:
vscode
.
Uri
,
config
:
MarkdownPreviewConfig
):
string
{
private
computeCustomStyleSheetIncludes
(
resource
:
vscode
.
Uri
,
config
:
MarkdownPreviewConfig
uration
):
string
{
if
(
config
.
styles
&&
Array
.
isArray
(
config
.
styles
))
{
if
(
config
.
styles
&&
Array
.
isArray
(
config
.
styles
))
{
return
config
.
styles
.
map
(
style
=>
{
return
config
.
styles
.
map
(
style
=>
{
return
`<link rel="stylesheet" class="code-user-style" data-source="
${
style
.
replace
(
/"/g
,
'
"
'
)}
" href="
${
this
.
fixHref
(
resource
,
style
)}
" type="text/css" media="screen">`
;
return
`<link rel="stylesheet" class="code-user-style" data-source="
${
style
.
replace
(
/"/g
,
'
"
'
)}
" href="
${
this
.
fixHref
(
resource
,
style
)}
" type="text/css" media="screen">`
;
...
@@ -143,7 +143,7 @@ export class MarkdownContentProvider {
...
@@ -143,7 +143,7 @@ export class MarkdownContentProvider {
return
''
;
return
''
;
}
}
private
getSettingsOverrideStyles
(
nonce
:
string
,
config
:
MarkdownPreviewConfig
):
string
{
private
getSettingsOverrideStyles
(
nonce
:
string
,
config
:
MarkdownPreviewConfig
uration
):
string
{
return
`<style nonce="
${
nonce
}
">
return
`<style nonce="
${
nonce
}
">
body {
body {
${
config
.
fontFamily
?
`font-family:
${
config
.
fontFamily
}
;`
:
''
}
${
config
.
fontFamily
?
`font-family:
${
config
.
fontFamily
}
;`
:
''
}
...
@@ -153,7 +153,7 @@ export class MarkdownContentProvider {
...
@@ -153,7 +153,7 @@ export class MarkdownContentProvider {
</style>`
;
</style>`
;
}
}
private
getStyles
(
resource
:
vscode
.
Uri
,
nonce
:
string
,
config
:
MarkdownPreviewConfig
):
string
{
private
getStyles
(
resource
:
vscode
.
Uri
,
nonce
:
string
,
config
:
MarkdownPreviewConfig
uration
):
string
{
const
baseStyles
=
[
const
baseStyles
=
[
this
.
extensionResourcePath
(
'
markdown.css
'
),
this
.
extensionResourcePath
(
'
markdown.css
'
),
this
.
extensionResourcePath
(
'
tomorrow.css
'
)
this
.
extensionResourcePath
(
'
tomorrow.css
'
)
...
...
extensions/markdown/src/features/previewManager.ts
浏览文件 @
ea2132e4
...
@@ -11,13 +11,13 @@ import { MarkdownPreview, PreviewSettings } from './preview';
...
@@ -11,13 +11,13 @@ import { MarkdownPreview, PreviewSettings } from './preview';
import
{
disposeAll
}
from
'
../util/dispose
'
;
import
{
disposeAll
}
from
'
../util/dispose
'
;
import
{
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
MarkdownFileTopmostLineMonitor
}
from
'
../util/topmostLineMonitor
'
;
import
{
isMarkdownFile
}
from
'
../util/file
'
;
import
{
isMarkdownFile
}
from
'
../util/file
'
;
import
{
PreviewConfig
Manager
}
from
'
./previewConfig
'
;
import
{
MarkdownPreviewConfiguration
Manager
}
from
'
./previewConfig
'
;
export
class
MarkdownPreviewManager
{
export
class
MarkdownPreviewManager
{
private
static
readonly
markdownPreviewActiveContextKey
=
'
markdownPreviewFocus
'
;
private
static
readonly
markdownPreviewActiveContextKey
=
'
markdownPreviewFocus
'
;
private
readonly
topmostLineMonitor
=
new
MarkdownFileTopmostLineMonitor
();
private
readonly
topmostLineMonitor
=
new
MarkdownFileTopmostLineMonitor
();
private
readonly
previewConfigurations
=
new
PreviewConfig
Manager
();
private
readonly
previewConfigurations
=
new
MarkdownPreviewConfiguration
Manager
();
private
readonly
previews
:
MarkdownPreview
[]
=
[];
private
readonly
previews
:
MarkdownPreview
[]
=
[];
private
activePreview
:
MarkdownPreview
|
undefined
=
undefined
;
private
activePreview
:
MarkdownPreview
|
undefined
=
undefined
;
private
readonly
disposables
:
vscode
.
Disposable
[]
=
[];
private
readonly
disposables
:
vscode
.
Disposable
[]
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录