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(codeeditor): support to extensions #286

Merged
merged 9 commits into from Jan 11, 2022
Merged

feat(codeeditor): support to extensions #286

merged 9 commits into from Jan 11, 2022

Conversation

danilowoz
Copy link
Member

@danilowoz danilowoz commented Jan 4, 2022

Introduces the ability to load Codemirror extensions in the CodeEditor component, in two ways:

  • By SandpackCodeEditor props:
<SandpackProvider template="react">
  <SandpackThemeProvider>
    <SandpackCodeEditor
      extensions={[autocompletion()]}
      extensionsKeymap={[completionKeymap]}
    />
  </SandpackThemeProvider>
</SandpackProvider>
  • By Sandpack props:
<Sandpack
  options={{
    codeEditor: {
      extensions: [autocompletion()],
      extensionsKeymap: [completionKeymap],
    },
  }}
  template="react"
/>

Closes #280

@danilowoz danilowoz self-assigned this Jan 4, 2022
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 4, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b4cfdf3:

Sandbox Source
Sandpack Blog Example 1 Configuration

@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 4, 2022 12:11 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 4, 2022 12:11 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 4, 2022 12:11 Inactive
@danilowoz danilowoz mentioned this pull request Jan 4, 2022
2 tasks
@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 4, 2022 12:20 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 4, 2022 12:20 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 4, 2022 12:20 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 4, 2022 13:45 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 4, 2022 13:45 Inactive
Copy link

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for adding this so quickly 😄

A couple nits around capitalization of CodeMirror but seems like it's good to go

bb8 thumbs up

cypress/integration/CodeMirror.spec.js Outdated Show resolved Hide resolved
* Property to register Codemirror extension keymap.
*/
extensionsKeymap?: Array<readonly KeyBinding[]>;
id?: string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓What's the id for? Should we add a comment explaining what it's for? I'm assuming it maps to the id of the CodeEditor so maybe that's obvious.

Copy link
Member Author

@danilowoz danilowoz Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is a temp bug fix that I'll approach in another PR soon. It's related to a random id generated in every render, which leads to unmatch values in tests cases. Here's more detail #143

sandpack-react/src/types.ts Outdated Show resolved Hide resolved
sandpack-react/src/types.ts Outdated Show resolved Hide resolved
sandpack-react/src/types.ts Outdated Show resolved Hide resolved
website/docs/docs/advanced-usage/components.md Outdated Show resolved Hide resolved
@@ -153,6 +153,31 @@ If you played with the `Sandpack` preset, you should be familiar already with th
</SandpackLayout>
</SandpackProvider>

### Extensions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I was hoping you'd add docs too 🙌

@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 5, 2022 09:39 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 5, 2022 09:39 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 5, 2022 09:39 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 5, 2022 09:59 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 5, 2022 09:59 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 5, 2022 09:59 Inactive
Co-authored-by: Sanne <sanne@codesandbox.io>
@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 5, 2022 11:19 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 5, 2022 11:19 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 5, 2022 11:19 Inactive
@jsjoeio
Copy link

jsjoeio commented Jan 10, 2022

Any ideas on when this will be merged?

@vercel vercel bot temporarily deployed to Preview – sandpack-theme January 11, 2022 10:45 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-landing January 11, 2022 10:45 Inactive
@vercel vercel bot temporarily deployed to Preview – sandpack-docs January 11, 2022 10:45 Inactive
@danilowoz danilowoz merged commit 47e73a9 into main Jan 11, 2022
@danilowoz danilowoz deleted the feat/cm-extensions branch January 11, 2022 10:57
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.

Feature request: vim keybindings
3 participants