What is the best way of allowing downloads from a notebook to a local file in Observable 2?
The examples in this page work in the old Observable interface, but not the new one. This would appear to be a break in backward compatibility.
Loading and Saving Test / Jo Wood | Observable (download works with old.observablehq)
https://observablehq.com/d/d1df7c47c844b824 (same download does not work with observablehq)
Hm it works for me in New, both the <a> and the DOM.download example:
I tested and works with Windows Chrome Browser. However, there’s an issue with Windows FireFox:
Content-Security-Policy: The page’s settings blocked the loading of a resource (frame-src) at blob:https://jwolondon.static.observableusercontent.com/b26f18dd-e51c-47d6-9dc6-9dc2681ce4ed because it violates the following directive: “frame-src ‘self’ https://*.static.observableusercontent.com”
Update: I implemented a FireFox specific workaround at https://observablehq.com/d/24ef26431599fa87
See: GitHub - arberosmani/workaround-csp-frame-src-blocked-on-firefox · GitHub for details.
Good report! Turns out we first added blob: and data: to our frame-src CSP in 2018. I didn’t know why it was there so I removed it, but I’ve added them back to New Observable now. This should fix these downloads (for browsers where it wasn’t working already).
Note that if you use the Export menu (enter Tinker mode if you aren’t already, then focus the text1 cell, then click the download icon in the toolbar), you can use Export text to download this file, too (and it didn’t need the expanded CSP, or custom UI in the notebook).
I want to make cell selection work in read-only mode… and the export menu too… I just need to figure out where it can live without being too obtrusive.