codemirror
codemirror copied to clipboard
Extending emmet to handle JS comment toggling
Hey, this is Oskar from JSFiddle.
We have emmet enabled by default in JSFiddle, and always had the issue that a HTML comment is toggled within the JavaScript panel. Was looking into extending emmet to handle JS comments but can't figure out a good way to do so.
Any tips would be really appreciated.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi,
currently, Emmet can (with some tweaking) comment with /* ... */, it doesn’t support single-line // ... commenting.
The best way to provide custom commenting logic is to override Emmet shortcut, check current syntax and, in case if it’s JS, use custom commenting logic, otherwise pass keyboard event further (to Emmet), e.g. return Codemirror.Pass object.
Thanks @sergeche. The custom logic you mention, would the correct way be to built it on top of Emmet?If so can you point me to any resource that would help me understand how to add custom logic and trigger it using a shortcut?
You need to simply register a key handler for Cmd-/ shortcut after initializing Emmet plugin (so it can take precedence): http://codemirror.net/doc/manual.html#keymaps