提交 3ab2688b 编写于 作者: J Johannes Rieken

trusted -> isTrusted, #29076

上级 27c07934
......@@ -5,7 +5,6 @@
'use strict';
import { localize } from 'vs/nls';
import * as DOM from 'vs/base/browser/dom';
import { defaultGenerator } from 'vs/base/common/idGenerator';
import { escape } from 'vs/base/common/strings';
......@@ -102,12 +101,13 @@ export function renderMarkdown(markdown: IMarkdownString, options: RenderOptions
}
title = removeMarkdownEscapes(title);
href = removeMarkdownEscapes(href);
if (!href || href.match(/^data:|javascript:/i)) {
if (
!href
|| href.match(/^data:|javascript:/i)
|| (href.match(/^command:/i) && !markdown.isTrusted)
) {
// drop the link
return text;
} else if (href.match(/^command:/i)) {
return markdown.trusted
? `<a href="#" data-href="${href}" title="${localize('hover.command', "Click to execute command")}">${text}&nbsp;<span class="octicon octicon-terminal"></span></a>`
: text;
} else {
return `<a href="#" data-href="${href}" title="${title || text}">${text}</a>`;
......
......@@ -10,13 +10,13 @@ import { marked } from 'vs/base/common/marked/marked';
export interface IMarkdownString {
value: string;
trusted?: true;
isTrusted?: boolean;
}
export class MarkdownString implements IMarkdownString {
value: string;
trusted?: true;
isTrusted?: boolean;
constructor(value: string = '') {
this.value = value;
......@@ -58,7 +58,7 @@ export function isMarkdownString(thing: any): thing is IMarkdownString {
return true;
} else if (typeof thing === 'object') {
return typeof (<IMarkdownString>thing).value === 'string'
&& (typeof (<IMarkdownString>thing).trusted === 'boolean' || (<IMarkdownString>thing).trusted === void 0);
&& (typeof (<IMarkdownString>thing).isTrusted === 'boolean' || (<IMarkdownString>thing).isTrusted === void 0);
}
return false;
}
......@@ -83,7 +83,7 @@ function markdownStringEqual(a: IMarkdownString, b: IMarkdownString): boolean {
} else if (!a || !b) {
return false;
} else {
return a.value === b.value && a.trusted === b.trusted;
return a.value === b.value && a.isTrusted === b.isTrusted;
}
}
......
......@@ -355,7 +355,7 @@ declare module monaco {
}
export interface IMarkdownString {
value: string;
trusted?: true;
isTrusted?: boolean;
}
export interface IKeyboardEvent {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册