GordonSmith / vscode-ojs

VS Code extension for ObservableHQ notebooks
https://marketplace.visualstudio.com/items?itemName=GordonSmith.observable-js
MIT License
58 stars 5 forks source link

Auto-import default Inputs, d3, vl and Plot libraries for the new OJS notebooks that use them #22

Closed RandomFractals closed 3 years ago

RandomFractals commented 3 years ago

Hi Gordon,

First of all, congrats on crossing 1K installs in VS marketplace.

I wanted to request this auto-import feature for the new OJS notebooks. @mbostock & ObservbableHQ team recently simplified how the above mentioned libraries are used on Observable site.

In order to import them into OJS vscode extension we'd need to add them too when .ojs and .omd files are created and code cells reference them.

I think we can just scan notebook cells code on import and add them at the end of the imported notebook OJS/OMD code.

See Mike's recommended libraries notebook for the latest versions to use:

https://observablehq.com/@observablehq/recommended-libraries

and this example I created recently: https://github.com/RandomFractals/Chicago-transportation-notebooks/blob/main/notebooks/observable/chicago-traffic-tracker.ojs

I had to add them manually in my OJS Imports section, but I think that process can be automated with your OJS notebook importing and loading tool.

GordonSmith commented 3 years ago

Added support for the new Notebook paradigm and tested by importing https://observablehq.com/@observablehq/recommended-libraries into an OJS and OMD.

RandomFractals commented 3 years ago

oh, so the obsrvablehq libs and yours already do that? and we don't have to scan code cells or inject those default imports?

Anyhoo, thanks for the quick patch!

GordonSmith commented 3 years ago

Yea it pretty much just works when I bumped my versions - I did need to add support for the notebook cell types...