@@ -29,7 +29,9 @@ import {
2929 TREE_NODE_SEGMENT_GROW_CLASS ,
3030 TREE_NODE_TAIL_CLASS ,
3131 TreeModelImpl ,
32- TreeViewWelcomeWidget
32+ TreeViewWelcomeWidget ,
33+ TOOLTIP_ID ,
34+ tooltipSingleton
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,9 @@ 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' ;
49+ import { Message } from '@theia/core/shared/@phosphor/messaging' ;
4550
4651export const TREE_NODE_HYPERLINK = 'theia-TreeNodeHyperlink' ;
4752export const VIEW_ITEM_CONTEXT_MENU : MenuPath = [ 'view-item-context-menu' ] ;
@@ -274,13 +279,32 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
274279 classes . push ( TREE_NODE_SEGMENT_GROW_CLASS ) ;
275280 }
276281 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- } ) ;
282+
283+ let attrs : { } = {
284+ ...this . decorateCaption ( node , { } ) ,
285+ className,
286+ id : node . id
287+ } ;
288+
289+ if ( node . tooltip && isMarkdownString ( node . tooltip ) ) {
290+ // Render markdown in custom tooltip
291+ const tooltip = markdownit ( ) . render ( node . tooltip . value ) ;
292+
293+ attrs = {
294+ ...attrs ,
295+ 'data-tip' : tooltip ,
296+ 'data-for' : TOOLTIP_ID
297+ } ;
298+ } else {
299+ const title = node . tooltip ||
300+ ( node . resourceUri && this . labelProvider . getLongName ( new CoreURI ( node . resourceUri ) ) )
301+ || this . toNodeName ( node ) ;
302+
303+ attrs = {
304+ ...attrs ,
305+ title
306+ } ;
307+ }
284308
285309 const children : React . ReactNode [ ] = [ ] ;
286310 const caption = this . toNodeName ( node ) ;
@@ -457,4 +481,9 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
457481 shouldShowWelcomeView ( ) : boolean {
458482 return ( this . model . proxy === undefined || this . model . isTreeEmpty ) && this . message === undefined ;
459483 }
484+
485+ protected onUpdateRequest ( msg : Message ) : void {
486+ super . onUpdateRequest ( msg ) ;
487+ tooltipSingleton . update ( ) ;
488+ }
460489}
0 commit comments