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 editor options and wrapping component prop #45

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

ivan-auror
Copy link
Contributor

👋 I'm considering using this plugin in a design system storybook and there were two missing features I thought I'd implement and ask for feedback.

The first feature is for the <Playground> to accept an optional editorOptions prop of type Monaco.editor.IEditorOptions so that the editor's options can be defined at init time rather than after the fact via the modifyEditor function prop. The minimap (on by default) is not useful for snippets that require little or no scrolling so it would be useful to be able to turn that off, and the current way of dealing with this feels suboptimal:

modifyEditor={(monaco, editor) => {
    editor.updateOptions({ minimap: { enabled: false } });
}} 

The second feature is to pass in a wrapping component that wraps the rendered code so that it can be distinguished from the rest of the page. For instance, if the component rendered by the snippet has the same background color as the rest of the page but has some other visually defining feature (e.g. a border radius) then it is indistinguishable from the rest of the page unless a wrapping element is added, but I don't want that to be a part of the code sample.

CleanShot 2024-06-17 at 15 44 46@2x

I'm happy to split these into separate PRs if that helps.

Getting correct syntax highlighting on JSX is another item on the wishlist, but that seems like it's much harder than it should be 😅

Copy link
Owner

@JeremyRH JeremyRH left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! Looks great, just have a few comments.

src/index.tsx Outdated Show resolved Hide resolved
src/index.tsx Outdated Show resolved Hide resolved
src/index.tsx Outdated Show resolved Hide resolved
src/Editor/Editor.tsx Outdated Show resolved Hide resolved
@JeremyRH
Copy link
Owner

I agree, correct syntax highlighting for JSX is a lot harder than it should be and I didn't feel it was worth the effort.

@ivan-auror
Copy link
Contributor Author

Thanks for the feedback! I've implemented all changes.

@JeremyRH JeremyRH merged commit 58dc909 into JeremyRH:main Jul 1, 2024
1 check passed
@JeremyRH
Copy link
Owner

JeremyRH commented Jul 1, 2024

Release your changes in 3.1.0. Thank you!

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.

2 participants