Nando Vieira
Nando Vieira

Reputation: 974

Add link to autocompletion's documentation

Is there a way of having a clickable link on autocompletion's documentation? I tried adding raw HTML and it's being escaped for security reasons (and that's a good thing).

Cheers!

Autocompletion's documentation escapes HTML

Upvotes: 1

Views: 662

Answers (1)

Métoule
Métoule

Reputation: 14472

Yes, it's possible: the doc states that completionitem.documentation can either be a string, or a IMarkdownString.

So to add a link, just use the markdown syntax instead of pure HTML. For example:

monaco.languages.registerCompletionItemProvider('json', {
    provideCompletionItems: function(model, position) {
        return [{
            label: '"nullif(expression)"',
            kind: monaco.languages.CompletionItemKind.Function,
            documentation: { 
                value: "The NULLIF function... [see Google](https://www.google.com)" 
            },
            insertText: '"nullif(expression)"'
        }];
    }
});

Upvotes: 3

Related Questions