Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] In-Obsidian execution of JavaScript code (special case) #341

Open
cybrox opened this issue Apr 16, 2024 · 1 comment
Open

[FEATURE] In-Obsidian execution of JavaScript code (special case) #341

cybrox opened this issue Apr 16, 2024 · 1 comment
Labels
features request Request for a new feature.

Comments

@cybrox
Copy link

cybrox commented Apr 16, 2024

Firstly, thank you for writing and maintaining this plugin, it gets Obsidian a lot closer to the use-case I need it for!

Is your feature request related to a problem? Please describe.
I have a lot of 2D / 3D vector math and transformation related notes that I would like to add examples to using a library like p5.js. Ideally, I'd want to be able to do something like this:

@html(`
<canvas id="myCanvas"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.2/p5.min.js"></script>
`)

// write any kind of p5 code here

Describe the solution you'd like
This plugin allows me to run JavaScript snippets with the built-in executor that uses my NodeJS path.
For almost all languages, abstracting a generic REPL executor and running that in isolation is a very good idea.
However, JavaScript is a bit of a special case since Obsidian itself is running JavaScript when rendering the note, so in this special case it could be very beneficial to be able to run code directly inside Obsidian instead of going through the whole usual workflow of wrapping it, writing it to a file, executing it and capturing the stdin/stdout.

Describe alternatives you've considered
Not many really, I've considered writing a plugin myself that adds the canvas and just eval()s the code but I am already using this plugin, so I figured this might be an interesting special case?

Let me know if you'd be interested in having support for this special case in this plugin.

@cybrox cybrox added the features request Request for a new feature. label Apr 16, 2024
@twibiral
Copy link
Owner

Hi! Thanks for your issue, I generally think that accessing the runtime of the Obsidian application is a bad idea. Nonetheless, you are not the first to ask for this feature (e.g. #351). If you have an idea how we can implement this as an optional feature, feel free to tell me more or open a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features request Request for a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants