@@ -29,7 +29,9 @@ import {
2929 TREE_NODE_SEGMENT_GROW_CLASS ,
3030 TREE_NODE_TAIL_CLASS ,
3131 TreeModelImpl ,
32- TreeViewWelcomeWidget
32+ TreeViewWelcomeWidget ,
33+ TooltipService ,
34+ TooltipAttributes
3335} from '@theia/core/lib/browser' ;
3436import { TreeViewItem , TreeViewItemCollapsibleState } from '../../../common/plugin-api-rpc' ;
3537import { MenuPath , MenuModelRegistry , ActionMenuNode } from '@theia/core/lib/common/menu' ;
@@ -42,6 +44,8 @@ import { MessageService } from '@theia/core/lib/common/message-service';
4244import { View } from '../../../common/plugin-protocol' ;
4345import CoreURI from '@theia/core/lib/common/uri' ;
4446import { ContextKeyService } from '@theia/core/lib/browser/context-key-service' ;
47+ import * as markdownit from 'markdown-it' ;
48+ import { isMarkdownString } from '../../../plugin/markdown-string' ;
4549
4650export const TREE_NODE_HYPERLINK = 'theia-TreeNodeHyperlink' ;
4751export const VIEW_ITEM_CONTEXT_MENU : MenuPath = [ 'view-item-context-menu' ] ;
@@ -245,6 +249,9 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
245249 @inject ( ContextKeyService )
246250 protected readonly contextKeyService : ContextKeyService ;
247251
252+ @inject ( TooltipService )
253+ protected readonly tooltipService : TooltipService ;
254+
248255 protected readonly onDidChangeVisibilityEmitter = new Emitter < boolean > ( ) ;
249256 readonly onDidChangeVisibility = this . onDidChangeVisibilityEmitter . event ;
250257
@@ -274,13 +281,32 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
274281 classes . push ( TREE_NODE_SEGMENT_GROW_CLASS ) ;
275282 }
276283 const className = classes . join ( ' ' ) ;
277- const title = node . tooltip ||
278- ( node . resourceUri && this . labelProvider . getLongName ( new CoreURI ( node . resourceUri ) ) )
279- || this . toNodeName ( node ) ;
280- const attrs = this . decorateCaption ( node , {
281- className, id : node . id ,
282- title
283- } ) ;
284+
285+ let attrs : React . HTMLAttributes < HTMLElement > & Partial < TooltipAttributes > = {
286+ ...this . decorateCaption ( node , { } ) ,
287+ className,
288+ id : node . id
289+ } ;
290+
291+ if ( node . tooltip && isMarkdownString ( node . tooltip ) ) {
292+ // Render markdown in custom tooltip
293+ const tooltip = markdownit ( ) . render ( node . tooltip . value ) ;
294+
295+ attrs = {
296+ ...attrs ,
297+ 'data-tip' : tooltip ,
298+ 'data-for' : this . tooltipService . tooltipId
299+ } ;
300+ } else {
301+ const title = node . tooltip ||
302+ ( node . resourceUri && this . labelProvider . getLongName ( new CoreURI ( node . resourceUri ) ) )
303+ || this . toNodeName ( node ) ;
304+
305+ attrs = {
306+ ...attrs ,
307+ title
308+ } ;
309+ }
284310
285311 const children : React . ReactNode [ ] = [ ] ;
286312 const caption = this . toNodeName ( node ) ;
@@ -444,7 +470,9 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
444470 }
445471
446472 protected render ( ) : React . ReactNode {
447- return React . createElement ( 'div' , this . createContainerAttributes ( ) , this . renderSearchInfo ( ) , this . renderTree ( this . model ) ) ;
473+ const node = React . createElement ( 'div' , this . createContainerAttributes ( ) , this . renderSearchInfo ( ) , this . renderTree ( this . model ) ) ;
474+ this . tooltipService . update ( ) ;
475+ return node ;
448476 }
449477
450478 protected renderSearchInfo ( ) : React . ReactNode {
0 commit comments