Open jmcphers opened 1 year ago
the console would have to become its own webview.
Remarkably we've learned recently that this is not true! The console could keep on rendering with React and we could stick a webview behind it to render unsafe content. That's how VS Code's notebooks work.
To reproduce, run this Python code (originally from #970):
The result is a widget that looks clickable but doesn't do anything when clicked.
The reason this happens is that the HTML returned from the kernel (as a
text/html
result) contains JavaScript to make the widget interactive. However, we intentionally strip script content from kernel results because we load it right into the root DOM, and it's unsafe to load arbitrary content there.This is also a problem for Plotly, etc. Read a longer discussion of the issue here: https://github.com/posit-dev/positron/issues/928.
To address this, we need a way to safely load HTML output -- including output containing scripts -- from kernels into Positron. Some considerations:
Related: https://github.com/posit-dev/positron/issues/444 tracks the work to emit R HTML widgets. These, too, can bear scripted content and will likely be emitted as
text/html
results when that issue has been addressed.