How do I programmatically retrieve content from a WYSIHTML5 editor?
Suppose the editor is instantiated as this:
var editor = new wysihtml5.Editor
(
   $(this.el).find('textarea').get(0),
   {
      toolbar:      "toolbar",
      parserRules:  wysihtml5ParserRules
   }
);
i would like to get the editor's content on blur event
editor.on
(
   "blur",
   function()
   {
      //what here?
   }
);
                It's much better to use the API
editor.getValue()
(@dalen mentioned this in the comment above)
Here is how (using jQuery here):
$('iframe').contents().find('.wysihtml5-editor').html();
To find text instead, use text() instead of html().
FYI:
In your application, you won't need the jQueryify bookmarklet, I used it to inject jQuery on that demo page so that I could use it to get the value of editor.
Having said that, there normally should be some built-in method in that editor to get current value you should look at the docs :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With