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

A minimal runeditable code embed #17

Closed
adamziel opened this issue Sep 22, 2022 · 6 comments
Closed

A minimal runeditable code embed #17

adamziel opened this issue Sep 22, 2022 · 6 comments

Comments

@adamziel
Copy link
Collaborator

Let's make it easy to embed runedditable code examples in the technical documentation.

A minimal implementation already exists at https://adamziel.github.io/embed.html#IkhleSB0aGVyZSEi

CleanShot 2022-09-22 at 13 16 34@2x

One problem with it is the code editor – it has much less affordances than the one on StackBlitz. I mean code completion, files explorer, linter integration etc.

Let's build a minimal "full widget" app for embedding editable code snippets.

@adamziel adamziel changed the title A minimal runeditable code embed [Browser] A minimal runeditable code embed Oct 14, 2022
@eliot-akira
Copy link
Collaborator

eliot-akira commented Oct 20, 2022

StackBlitz uses Monaco Editor, the same core library as Visual Studio Code.

It integrates with language server protocol (LSP) to provide advanced editor features like code completion and linting. I've heard some people mention that Monaco can be heavy in terms of file size.


An alternative is CodeMirror (sponsored by Automattic, by the way). It has a community-developed extension, LSP integration for CodeMirror.

It's used by Replit, another "online IDE as a service". They previously used Monaco, and wrote an in-depth article comparing the pros and cons: Betting on CodeMirror. A relevant excerpt:

Ultimately, our reasons for moving off of Monaco came down to:

  • Lack of mobile support
  • A clunky API and subpar documentation
  • Difficulty in customizing the core editor components and functionality
  • Massive bundle size which led to degraded performance across the app

CodeMirror, in contrast to Monaco:

  • Works well on mobile
  • Has a modern, extensible API with excellent documentation
  • Is easy to customize, style, and reconfigure
  • Is very lightweight and performant

@adamziel
Copy link
Collaborator Author

Such a good research, thank you @eliot-akira! Monaco Editor is the same one used in that quick demo in the description, but mobile support is a huge advantage of CodeMirror. I'm thinking about leveraging StackBlitz and not doing a code editor for the first implementation of this, but for a second round CodeMirror looks very promising.

CodeMirror (sponsored by Automattic, by the way).

TIL!

@adamziel adamziel changed the title [Browser] A minimal runeditable code embed A minimal runeditable code embed Oct 22, 2022
@StevenDufresne
Copy link
Contributor

I think Sandpack also uses CodeMirror.

@adamziel
Copy link
Collaborator Author

adamziel commented Dec 14, 2022

For posterity:

A code editing experiment (source code in this repo!): https://wasm.wordpress.net/wordpress.html?login=1&url=/wp-admin/post-new.php&ide=1
A wporg theme with a playground Gutenberg block: https://github.com/WordPress/wporg-wasm

@adamziel
Copy link
Collaborator Author

Related PR: #168

@adamziel
Copy link
Collaborator Author

adamziel commented Jun 2, 2023

The Interactive Code Block merged in #168 effectively solves this issue. It's yet to be documented and released in the plugin directory but let's track that separately in the playground-tools repo:

@adamziel adamziel closed this as completed Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants