-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Display a table in diagnostic window of Monaco Editor #2856
Comments
@chengtie You can achieve this with raw HTML and specifying table, th, td {
border: 1px solid black;
} monaco.languages.register({ id: 'mySpecialLanguage' });
monaco.languages.registerHoverProvider('mySpecialLanguage', {
provideHover: function (model) {
return {
range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
contents: [
{
value: "<table><tr><td>abc</td><td>123</td></tr><tr><td>abc</td><td>123</td></tr></table>",
supportHtml: true
},
]
}
}
});
monaco.editor.create(document.getElementById("container"), {
value: '\n\nHover over this text',
language: 'mySpecialLanguage'
}); |
@rcjsuen Thank you, that works great! Additionally, i guess it is impossible to use table solutions like https://github.com/handsontable/handsontable here? |
You can use a template string for that (the line breaks are important for the table rendering). CSS (augmented from post above): .monaco .hover-content table, th, td {
border: 1px solid black;
} Hover element: contents: [
{ value: '**SOURCE**' },
{ value: `
| a | b | c | d | e |
|---|---|---|---|---|
| f | g | h | i | j |`
}
] |
@spahnke it works, thank you! Again, i guess it is impossible to use table solutions like https://github.com/handsontable/handsontable here? |
@chengtie It is not possible to render a special table widget inside the hover via the hover provider. |
Context
Description
(* I don't know if it is an existing feature or not *)
In this sample of Monaco Editor, when we hover on the
Hover over this text
, we could see markdown result in the diagnostic window. The contents of the window are provided by the code:I'm wondering if it is possible to draw a table in the diagnostic window.
I tried to add
{ value: '| a | b | c | d | e | |---|---|---|---|---| | 1 | 2 | 3 | 4 | 5 |'}
, it did not work.Could anyone help?
The text was updated successfully, but these errors were encountered: