bevacqua / woofmark

:dog2: Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor
https://bevacqua.github.io/woofmark
MIT License
1.63k stars 64 forks source link

Is there any event triggered on text input? #24

Open konclave opened 8 years ago

konclave commented 8 years ago

The only way I've found to listen to the text input is to add event listener to woofmark.find(textarea).textarea and .editable objects. Is there any other way of doing that?

septagram commented 8 years ago

Also it would be really great to trigger an event upon switching between modes. An example usage would be making the textarea autoexpand, which currently requires not only watching for new input inside the textarea, but also somehow detecting the switch away from the WYSIWYG mode, because that also means the text in the textarea might have changed.

jywarren commented 8 years ago

The library uses crossvent, an event library also by @bevacqua -- so you can create events using crossvent like this: https://github.com/publiclab/PublicLab.Editor/blob/12287656c35630a77c47a547f87e12d70c89a585/src/modules/PublicLab.RichTextModule.js#L135-L149

However, I'm not sure what all the different events are, and it's still element-based, so I think you may still need to watch both elements. But the above example triggers on mode change.