Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Extensions can't register CodeMirror onKeyEvent handlers #1113

Closed
davidderaedt opened this issue Jun 22, 2012 · 6 comments
Closed

Extensions can't register CodeMirror onKeyEvent handlers #1113

davidderaedt opened this issue Jun 22, 2012 · 6 comments
Assignees

Comments

@davidderaedt
Copy link

Some extensions may need to listen to all CodeMirror onKeyEvent events directly, to override the default behavior currently described in the Editor._installEditorListeners() method.

For instance, this would would allow the creation of extensions which would implement support for zen-coding for CodeMirror2, which is currently only possible by modifying Brackets Editor class itself.

Note: Since the CodeMirror event mapping implementation may become more generic in the future, this could be achieved by exposing this mapping mechanism.

@ghost ghost assigned peterflynn and pthiess Jun 22, 2012
@sergeche
Copy link

The next version of Zen Coding plugin won’t use onKeyEvent listener. I’ve talked with @marijnh about better keybindings implementation, and he said that the better solution is to extend CodeMirror.defaults.extraKeys object with proper keyboard shortcuts.

Although, there might be issues with Tab key (ZC overrides this key to expand abbreviations), but I need more investigation on this.

@davidderaedt
Copy link
Author

Thanks for the heads up !

@pthiess
Copy link
Contributor

pthiess commented Jun 28, 2012

Hi David,

Thanks a lot for your feedback - Reviewed and removed unrelated story links. This issue is covered by Trello Card #572. I'm closing the issue here. Please remember to vote on the Trello card.

@pthiess
Copy link
Contributor

pthiess commented Jun 28, 2012

closing

@pthiess pthiess closed this as completed Jun 28, 2012
@sergeche
Copy link

Just uploaded new Zen Coding for CodeMirror2 plugin: https://github.com/sergeche/zen-coding/blob/v0.7.1/plugins/codemirror2/editor.js

It does’t use onKeyEvent listener anymore, it just extends CodeMirror.defaults.extraKeys object with new actions and uses CM’s internal key handler mechanism.

The integration of ZC plugin is also much simpler now: you just need to include zencoding.js file into your page.

@davidderaedt
Copy link
Author

Thanks a lot for the update Serge, it looks like a really nice improvement.

However, brackets does not extend those defaults: it overwrites them when creating a editor instance.

This seems to me like a separate issue, so I'll open a new one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants