Bug: Embed Code menu item is incorrect for viewof cells

Making a separate thread for this post since it hasn’t yet been addressed:

For example, clicking “Embed code” in the menu on this cell yields:

<div id="observablehq-615a6148"></div>
<script type="module">
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import define from "https://api.observablehq.com/@observablehq/a-brief-introduction-to-viewof.js?v=3";
const inspect = Inspector.into("#observablehq-615a6148");
(new Runtime).module(define, name => (name === "color") && inspect());
</script>

But I think it should be this, instead:

<div id="observablehq-615a6148"></div>
<script type="module">
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import define from "https://api.observablehq.com/@observablehq/a-brief-introduction-to-viewof.js?v=3";
const inspect = Inspector.into("#observablehq-615a6148");
(new Runtime).module(define, name => (name === "viewof color") && inspect());
</script>
1 Like

Thanks for the report! We’ve rolled out a fix and embeds now properly specify viewof when appropriate.

1 Like