FormidableLabs / react-live

A flexible playground for live editing React components

Home Page:https://commerce.nearform.com/open-source/react-live/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reset Editor Code

DimaMirana opened this issue · comments

Is there any props or function where you can reset the editor to default code value?

If you want, we did a custom implementation to reset the code here
https://github.com/wonderflow-bv/wanda/blob/main/apps/docs/src/components/live-code/live-code.tsx#L119

We wrapped the component and passed the onRestore callback that reset the original code.

If something like that will be ever implemented I would like to have full customisation on it(placement and style)

commented

hey @DimaMirana -- this is something you should be able to implement with a CustomEditor. Have a look at our Storybook stories for an example.

Unfortunately this isn't something we can add to the default Editor because then we'd be forcing UI patterns on everyone using the lib 😅

I would imagine once dynamically updating the code works again (#271) this would be easy to implement with the code prop and local state.