prettier-browser-extension
prettier-browser-extension copied to clipboard
Additional ways to format
These are some ideas based on what I think is useful though I'm not sure we'd want all of them:
- Keyboard shortcut (prettier-js-extension uses
Ctrl + Shift + F) - Button action (clicking on the extension icon in Chrome's extension toolbar)
- Context menu
- Automatic formatting (could work like the VSCode extension and allow auto formatting on any supported file, possible with a debounce/throttle if we hit performance bottlenecks)
Note: These could make #20 easier to implement as we wouldn't have to worry about placing a button in an unknown UI, which could break stuff or look ugly.
The only one I have reservations about is the automatic formatting. Otherwise, I like this idea a lot! I also think it would be nice to add a feature where, if text is selected, it will only format that text.
The only one I have reservations about is the automatic formatting.
Out of curiosity, what don't you like about it? How would you feel about adding it with a toggle that's off by default?
I also think it would be nice to add a feature where, if text is selected, it will only format that text.
As far as I'm aware Prettier requires formatted text to be valid as an entire file, so this would mean that only some selections could be formatted properly. Personally I think it's easier to only allow formatting entire inputs, since it's closer to Prettier's built in functionality. Otherwise we would have to explain to the user why selections are invalid and implement extra error handling.
Out of curiosity, what don't you like about it? How would you feel about adding it with a toggle that's off by default?
Having a toggle sounds good! I don't think it's a good idea to modify text as users are typing, since characters can move and make it really unwieldy.
As far as I'm aware Prettier requires formatted text to be valid as an entire file, so this would mean that only some selections could be formatted properly. Personally I think it's easier to only allow formatting entire inputs, since it's closer to Prettier's built in functionality. Otherwise we would have to explain to the user why selections are invalid and implement extra error handling.
That's right. What I like about this functionality is that blocks of code that aren't in markdown can be formatted. That being said, I don't think this should be a high priority feature.