You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code in the active file of an editor would be formatted by Prettier, either 1. on type, or 2. on save. I have this currently configured in my CodeSandbox User settings, and it works perfectly.
Do you have any examples of how you would like to see us implement it?
I've tried adding prettier as a dev dependency, and providing a settings.json file in the root, but with no success :(.
Also I had to come up with a workaround for "saving" a file in the editor, as there isn't a builtin function for that. Not sure if this is where my issue stems from 🤷🏾♂️:
useEffect(()=>{consthandleKeyDown=(event: KeyboardEvent)=>{// Check if the key combination is pressedif((event.ctrlKey||event.metaKey)&&event.key==='s'){// Prevent default behavior (saving the page)event.preventDefault();// Execute your function to update the current filesandpack.updateCurrentFile(sandpack.files[sandpack.activeFile].code,true);}};// Add event listenerdocument.addEventListener('keydown',handleKeyDown);// Remove event listener when component unmountsreturn()=>{document.removeEventListener('keydown',handleKeyDown);};},[sandpack.files]);
The text was updated successfully, but these errors were encountered:
Thanks for the quick reply @danilowoz . I checked the sandbox out, but it seemed to work only when I set my User settings to enable prettier. I don't know how to do these settings with sandpack.
Tell us how you think we can improve Sandpack
Packages affected
What is this feature?
Prettier code formatting.
How would your idea work?
Code in the active file of an editor would be formatted by Prettier, either 1. on type, or 2. on save. I have this currently configured in my CodeSandbox User settings, and it works perfectly.
Do you have any examples of how you would like to see us implement it?
I've tried adding
prettier
as a dev dependency, and providing asettings.json
file in the root, but with no success :(.Also I had to come up with a workaround for "saving" a file in the editor, as there isn't a builtin function for that. Not sure if this is where my issue stems from 🤷🏾♂️:
The text was updated successfully, but these errors were encountered: