stackblitz / tutorialkit

TutorialKit by StackBlitz - Create interactive tutorials powered by the WebContainer API
https://tutorialkit.dev
MIT License
504 stars 48 forks source link

Accessing File Tree with Source Codes as a JSON #341

Closed rainmakersumit closed 2 months ago

rainmakersumit commented 2 months ago

Is your feature request related to a problem?

I need the full code base including the user changes so that we can evaluate the code and get back to him with a report.

Describe the solution you'd like.

If I get the entire file tree and user code changes as JSON then It would be easier to evaluate.

Describe alternatives you've considered.

Not Applicable.

Additional context

No response

AriPerkkio commented 2 months ago

There are couple of options:

  1. Use the "Open In StackBlitz" button on top of the TutorialKit, and use those to "store" user's results. So basically when you click this ⚡ button, you get link to stackblitz.com with the current state of the editor. It includes all lesson and template files, including the modifications that user did.
  1. Create your own custom component that calls TutorialKit's public APIs to get current state of the file system + editor. This is the same data as in option #1, but here you can process the JSON anyway you want. Here is example where we simply print the JSON on the page:

https://stackblitz.com/~/edit/tutorialkit-store-snapshot?file=src/components/SnapshotButton.tsx&file=src/content/tutorial/1-basics/1-introduction/1-welcome/content.mdx

import tutorialStore from 'tutorialkit:store';

// Save current state of the file system
const snapshot = tutorialStore.takeSnapshot();

image

Does this help?

rainmakersumit commented 2 months ago

Solved, I have another question image

Can I hide this button ? Without CSS ? Basically I was looking for full control over the system I need to add Custom Button Over there, is it possible ?

AriPerkkio commented 2 months ago

Can I hide this button ? Without CSS ?

At the moment we don't support hiding the Solve/Reset -button. Feel free to open feature request for this.

Solved

Great, let's close this issue then.