stackblitz / tutorialkit

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

feat(runtime): add `terminal.input` for writing to stdin #350

Closed AriPerkkio closed 1 month ago

AriPerkkio commented 1 month ago
import tutorialStore from 'tutorialkit:store';

export default function Example() {
  async function onClick() {
    const terminal = tutorialStore.terminalConfig.value!.panels[0];
    terminal.input('npm run test\n');
  }

  return (
    <button
      onClick={onClick}
      className="px-4 py-1 my-3 cursor-pointer border-1 border-tk-border-primary rounded-md bg-tk-elements-primaryButton-backgroundColor text-tk-elements-primaryButton-textColor"
    >
      Run tests
    </button>
  );
}
stackblitz[bot] commented 1 month ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.