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

How to change code from JS #191

Open
voidowl-rl opened this issue Oct 3, 2023 · 1 comment
Open

How to change code from JS #191

voidowl-rl opened this issue Oct 3, 2023 · 1 comment

Comments

@voidowl-rl
Copy link

I use KotlinPlayground in a small project to show students code and allow them to edit it (without the hassle to deal with any special code editors). It works great so far - thanks for this great tool.

However, I want to change the code in an existing KotlinPlayground instance (received by using getInstance) programmatically from JavaScript. I tried instance.update({code: "..."}) and to reinitialize the playground but none of the approaches worked. Is there an (easy) way to do this?

@zoobestik
Copy link
Contributor

zoobestik commented Oct 13, 2023

I thought, this just one workaround, currently:

instance.view.codemirror.setValue(code);

But, i can not recommend it to use. Cause it's private part API and, possibly, it will change in the near future.
The plan is add instance.setCode(code); like a public method.

@nikpachoo, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants