question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Listening to events from all CodeMirror instances

See original GitHub issue

CodeMirror very usefully provides CodeMirror.defaults to set global defaults. I think it would be useful if there was likewise some way to specify default event handlers, or event handlers on a global bus.

If you want to write a beforeChange handler that works on all CodeMirror editors on your website, right now you have to carefully make sure you attach the handler to each instance as it is created.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vincentwoocommented, Jul 14, 2016

CodeMirror.defineInitHook(func: function) If your extension just needs to run some code whenever a CodeMirror instance is initialized, use > CodeMirror.defineInitHook. Give it a function as its only argument, and from then on, that > function will be called (with the instance as argument) whenever a new CodeMirror instance is initialized.

god, nevermind, why am I so bad at this

0reactions
tonytlwucommented, Apr 13, 2018

I’ve created a PR so that CodeMirror.fromTextArea doesn’t override user’s options.finishInit configuration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Listening to events from all CodeMirror instances · Issue #4114
Register an event handler for the given event type (a string) on the editor instance. There is also a CodeMirror.on(object, type, func) version ......
Read more >
CodeMirror 6: Proper way to listen for changes
I need to sync the document contents with some other state, and I noticed that while I can listen for input events on...
Read more >
Event listener - CodeMirror
I have a widget which draws a caret. This caret can react to mouse events to draw a hover for instance, and prints...
Read more >
User Manual - CodeMirror
Overview. CodeMirror is a code-editor component that can be embedded in Web pages. The code library provides only the editor component, no accompanying ......
Read more >
CodeMirror 5 User Manual
Various CodeMirror -related objects emit events, which allow client code to react to various situations. ... An editor instance fires the following events....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found