tiff / wysihtml5

Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.
http://xing.github.com/wysihtml5/
MIT License
6.5k stars 1k forks source link

key up event #540

Open negatratoron opened 8 years ago

negatratoron commented 8 years ago

Looking at the events here

https://github.com/xing/wysihtml5/wiki/Events

There's a change event, but it doesn't fire each time the user enters a character. There's also a newword:composer event, but there's nothing like a keyup event as far as I can tell.

Anyone else think a keyup event should be added?

Guam commented 8 years ago

I think this would be a good feature to trigger an auto-complete search.

Velora commented 8 years ago

I think someone mentioned here awhile back a way this could be accomplished by using editor.composer.doc to attach event listeners. I'm using this solution:

  var editor = new wysihtml5.Editor("editor");

    editor.on("load", function() {
        var $doc = $(editor.composer.doc);
        $doc.keyup(function(){
           // Your code here
        });
    });
mark222 commented 8 years ago

I would like the "change" event to work as one would expect. Currently it only fires when the editor loses focus... I can set a blur event for that, so this is not helpful. I would expect a change event to fire on anything that causes the state of the editor to change - a character typed, text pasted or cut, a style change, etc. Anything that would cause getValue() to return something different.

Then it becomes simple to write auto-save functions, auto-complete, and anything that requires immediate response to content changes. Key up/down is not sufficient for lots of cases that cause content to change without a physical keystroke.