Adds codicons to hovers (#85580)
* Closes #85579 - adds codicons to hovers * Uses `icon://vscode.codicons/icon-name` url structure
This commit is contained in:
parent
f26928514a
commit
255766f07c
2 changed files with 18 additions and 1 deletions
|
@ -15,12 +15,15 @@ import { cloneAndChange } from 'vs/base/common/objects';
|
|||
import { escape } from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { renderCodicons } from 'vs/base/browser/ui/codiconLabel/codiconLabel';
|
||||
|
||||
export interface MarkdownRenderOptions extends FormattedTextRenderOptions {
|
||||
codeBlockRenderer?: (modeId: string, value: string) => Promise<string>;
|
||||
codeBlockRenderCallback?: () => void;
|
||||
}
|
||||
|
||||
const codiconsRegex = /^icon:\/\/vscode\.codicons\/(.*)$/;
|
||||
|
||||
/**
|
||||
* Create html nodes for the given content element.
|
||||
*/
|
||||
|
@ -72,6 +75,13 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
|
|||
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.image = (href: string, title: string, text: string) => {
|
||||
if (href) {
|
||||
const match = codiconsRegex.exec(href);
|
||||
if (match !== null) {
|
||||
return renderCodicons(`$(${match[1]})`);
|
||||
}
|
||||
}
|
||||
|
||||
let dimensions: string[] = [];
|
||||
let attributes: string[] = [];
|
||||
if (href) {
|
||||
|
@ -185,7 +195,8 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
|
|||
'a': ['href', 'name', 'target', 'data-href'],
|
||||
'iframe': ['allowfullscreen', 'frameborder', 'src'],
|
||||
'img': ['src', 'title', 'alt', 'width', 'height'],
|
||||
'div': ['class', 'data-code']
|
||||
'div': ['class', 'data-code'],
|
||||
'span': ['class']
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -104,3 +104,9 @@
|
|||
.monaco-editor-hover .hover-row.status-bar .actions .action-container .action .icon {
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.monaco-editor-hover .markdown-hover .hover-contents .codicon {
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue