silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.03k stars 140 forks source link

Feature Request: Simplify Space Script Development by Loading a separate .js file #823

Closed simone-viozzi closed 2 months ago

simone-viozzi commented 3 months ago

I suggest enabling users to develop space scripts in external .js files before loading them into SilverBullet.

This approach simplifies the development process, improves version control, and facilitates outside testing.

Additionally, this feature could allow developers to create a JavaScript library of pure functions, test it externally, and then integrate it with SilverBullet by wrapping these functions in SilverBullet-specific calls.

zefhemel commented 3 months ago

Yes, that shouldn't be hard to add, but this makes the line between space script and plugs (https://silverbullet.md/Plugs) even more blurry. Effectively plugs do what you describe (although doing things like defining custom functions are a bit tricky to do from a plug at the moment, that can be fixed though).

simone-viozzi commented 3 months ago

Yes, I like the idea of using a Plug for external JavaScript.

I haven't looked into plugs, but I understand I cannot use the space script silverbullet.registerFunction etc..?

simone-viozzi commented 2 months ago

In the end, I solved my use case by creating a plug: https://github.com/simone-viozzi/silverbullet-meeting-notes

Fell free to add it to the list of plugs if you want, but it's very specific for my use case.