Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0614806c
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,发现更多精彩内容 >>
提交
0614806c
编写于
8月 24, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move out util-methods to make MarkedString API ready, #29076
上级
018d5a2b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
28 deletion
+33
-28
src/vs/base/common/htmlContent.ts
src/vs/base/common/htmlContent.ts
+28
-23
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+3
-3
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
+2
-2
未找到文件。
src/vs/base/common/htmlContent.ts
浏览文件 @
0614806c
...
...
@@ -15,26 +15,6 @@ export interface IMarkdownString {
export
class
MarkdownString
implements
IMarkdownString
{
static
isEmpty
(
oneOrMany
:
IMarkdownString
|
IMarkdownString
[]):
boolean
{
if
(
MarkdownString
.
isMarkdownString
(
oneOrMany
))
{
return
!
oneOrMany
.
value
;
}
else
if
(
Array
.
isArray
(
oneOrMany
))
{
return
oneOrMany
.
every
(
MarkdownString
.
isEmpty
);
}
else
{
return
false
;
}
}
static
isMarkdownString
(
thing
:
any
):
thing
is
IMarkdownString
{
if
(
thing
instanceof
MarkdownString
)
{
return
true
;
}
else
if
(
typeof
thing
===
'
object
'
)
{
return
typeof
(
<
IMarkdownString
>
thing
).
value
===
'
string
'
&&
(
typeof
(
<
IMarkdownString
>
thing
).
trusted
===
'
boolean
'
||
(
<
IMarkdownString
>
thing
).
trusted
===
void
0
);
}
return
false
;
}
value
:
string
;
trusted
?:
true
;
...
...
@@ -42,13 +22,18 @@ export class MarkdownString implements IMarkdownString {
this
.
value
=
value
;
}
appendText
(
value
:
string
):
this
{
appendText
(
value
:
string
):
MarkdownString
{
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
this
.
value
+=
value
.
replace
(
/
[\\
`*_{}[
\]
()#+
\-
.!
]
/g
,
'
\\
$&
'
);
return
this
;
}
appendCodeblock
(
langId
:
string
,
code
:
string
):
this
{
appendMarkdown
(
value
:
string
):
MarkdownString
{
this
.
value
+=
value
;
return
this
;
}
appendCodeblock
(
langId
:
string
,
code
:
string
):
MarkdownString
{
this
.
value
+=
'
\n
```
'
;
this
.
value
+=
langId
;
this
.
value
+=
'
\n
'
;
...
...
@@ -58,6 +43,26 @@ export class MarkdownString implements IMarkdownString {
}
}
export
function
isEmptyMarkdownString
(
oneOrMany
:
IMarkdownString
|
IMarkdownString
[]):
boolean
{
if
(
isMarkdownString
(
oneOrMany
))
{
return
!
oneOrMany
.
value
;
}
else
if
(
Array
.
isArray
(
oneOrMany
))
{
return
oneOrMany
.
every
(
isEmptyMarkdownString
);
}
else
{
return
true
;
}
}
export
function
isMarkdownString
(
thing
:
any
):
thing
is
IMarkdownString
{
if
(
thing
instanceof
MarkdownString
)
{
return
true
;
}
else
if
(
typeof
thing
===
'
object
'
)
{
return
typeof
(
<
IMarkdownString
>
thing
).
value
===
'
string
'
&&
(
typeof
(
<
IMarkdownString
>
thing
).
trusted
===
'
boolean
'
||
(
<
IMarkdownString
>
thing
).
trusted
===
void
0
);
}
return
false
;
}
export
function
markedStringsEquals
(
a
:
IMarkdownString
|
IMarkdownString
[],
b
:
IMarkdownString
|
IMarkdownString
[]):
boolean
{
if
(
!
a
&&
!
b
)
{
return
true
;
...
...
@@ -65,7 +70,7 @@ export function markedStringsEquals(a: IMarkdownString | IMarkdownString[], b: I
return
false
;
}
else
if
(
Array
.
isArray
(
a
)
&&
Array
.
isArray
(
b
))
{
return
equals
(
a
,
b
,
markdownStringEqual
);
}
else
if
(
MarkdownString
.
isMarkdownString
(
a
)
&&
MarkdownString
.
isMarkdownString
(
b
))
{
}
else
if
(
isMarkdownString
(
a
)
&&
isMarkdownString
(
b
))
{
return
markdownStringEqual
(
a
,
b
);
}
else
{
return
false
;
...
...
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
0614806c
...
...
@@ -20,7 +20,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import
{
getHover
}
from
'
../common/hover
'
;
import
{
HoverOperation
,
IHoverComputer
}
from
'
./hoverOperation
'
;
import
{
ContentHoverWidget
}
from
'
./hoverWidgets
'
;
import
{
IMarkdownString
,
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
IMarkdownString
,
MarkdownString
,
isEmptyMarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModelWithDecorations
'
;
import
{
ColorPickerModel
}
from
'
vs/editor/contrib/colorPicker/browser/colorPickerModel
'
;
import
{
ColorPickerWidget
}
from
'
vs/editor/contrib/colorPicker/browser/colorPickerWidget
'
;
...
...
@@ -103,7 +103,7 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
const
{
color
,
formatters
}
=
colorRange
;
return
new
ColorHover
(
d
.
range
,
color
,
formatters
);
}
else
{
if
(
MarkdownString
.
isEmpty
(
d
.
options
.
hoverMessage
))
{
if
(
isEmptyMarkdownString
(
d
.
options
.
hoverMessage
))
{
return
null
;
}
...
...
@@ -310,7 +310,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
if
(
!
(
msg
instanceof
ColorHover
))
{
msg
.
contents
.
filter
(
contents
=>
!
MarkdownString
.
isEmpty
(
contents
))
.
filter
(
contents
=>
!
isEmptyMarkdownString
(
contents
))
.
forEach
(
contents
=>
{
const
renderedContents
=
renderMarkdown
(
contents
,
{
actionCallback
:
(
content
)
=>
{
...
...
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
浏览文件 @
0614806c
...
...
@@ -15,7 +15,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
tokenizeToString
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
IMarkdownString
,
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
IMarkdownString
,
isEmpty
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
export
interface
IHoverMessage
{
value
:
IMarkdownString
;
...
...
@@ -61,7 +61,7 @@ class MarginComputer implements IHoverComputer<IHoverMessage[]> {
let
hoverMessage
=
d
.
options
.
glyphMarginHoverMessage
;
if
(
!
MarkdownString
.
isEmpty
(
hoverMessage
))
{
if
(
!
isEmptyMarkdownString
(
hoverMessage
))
{
continue
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录