I'm trying to get contents of Jodit editor into a variable.
I have tried looking through their documentation but nowhere can I find how to do it. I've had a look at their methods documentation but information provided there doesn't connect any dots.
    <textarea id="editor"></textarea>
    <br>
    <button class="btn btn-primary ml-3" id="save">Save</button>
    <script>
        var editor = new Jodit('#editor', {
        });
        $('#save').on('click', function(e) {
             var text = editor.someMethodThatGetsContents(); 
             alert(text); 
        });
    </script>
I think I should get a html string.
   var editor = new Jodit('#editor');
   var editor_val = editor.value;
   console.log(editor_val);
Try this way, maybe this going to help you.
from the docs:
function handleContent(newValue) {
...
const x =  newValue.srcElement.innerHTML;
...
}
<JoditEditor
...
onBlur={handleContent}
...
/>
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