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

feat: add runnable monaco editor (#219) #1273

Merged
merged 46 commits into from
Mar 7, 2024
Merged

Conversation

KermanX
Copy link
Member

@KermanX KermanX commented Feb 5, 2024

Overview

resolves #219

This PR introduces the "runnable" Monaco editor:

Grammar:

```ts {monaco-run}
console.log('Hello' as string, [1, 'text', new Error('message'), () => {}])
```

Example:
image

Screen.Recording.2024-03-07.at.23.11.59.mov

Options

  • autorun: boolean | 'once'
    Default: true
    Run the code automatically after input
  • outputHeight: string | undefined
    Default: undefined
  • highlightOutput: boolean
  • runnerOptions: Record<string, unknown>
    Will be passed to the runner as-is.

Notes

  • Use setup/runners.ts to provide custom runners. You can highlight code and call other runners in your runner.
  • Code will not run in the presenter preview or in the overview.
  • Code will always be autorun in print mode.
  • Using new Function() to run the code.
  • Cannot use import statements in the code. Should use dynamic import instead.

Todos

  • Print mode
  • Not sure whether "monaco-runnable" is the best name? ({monaco-run}?)
  • Any better way to import code, and how to import local code?

@KermanX KermanX marked this pull request as ready for review March 3, 2024 14:08
@KermanX KermanX marked this pull request as draft March 3, 2024 14:45
@KermanX KermanX marked this pull request as ready for review March 3, 2024 14:54
packages/client/internals/MonacoOutput.vue Outdated Show resolved Hide resolved
packages/client/internals/MonacoOutput.vue Outdated Show resolved Hide resolved
packages/client/internals/MonacoOutput.vue Outdated Show resolved Hide resolved
packages/client/internals/MonacoOutput.vue Outdated Show resolved Hide resolved
packages/types/src/runner.ts Outdated Show resolved Hide resolved
Copy link

netlify bot commented Mar 7, 2024

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit cf4c5aa
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/65ea3e0c176bc2000886bf76
😎 Deploy Preview https://deploy-preview-1273--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@antfu
Copy link
Member

antfu commented Mar 7, 2024

Looks very nice! I like it!

We could have some docs for it, and maybe add one new demo to experiments with the runner step? (otherwise, we have no tests for it)

@antfu antfu mentioned this pull request Mar 7, 2024
9 tasks
@antfu antfu merged commit 8549e30 into slidevjs:main Mar 7, 2024
21 checks passed
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

Successfully merging this pull request may close these issues.

notebook cell element
2 participants