Using Textbox.io - Get Active Editor

by textboxio

HTML

<script src="https://s3.amazonaws.com/static.ephox.com/jsfiddle/textboxio/textboxio.js"></script>
<div class="editableDiv">
    <p>First div content.</p>
</div>
<div class="editableDiv">
    <p>Second div content.</p>
</div>

<button id="getActiveContent">Get Active Editor Contents</button>

CSS

.editableDiv {
    margin:10px 0;
    height:200px;
}

JavaScript

// Create a Textbox.io Editor for the matched element(s)
textboxio.replaceAll('.editableDiv');

document.getElementById('getActiveContent').onclick = function() {
    // Get the active editor
    var editor = textboxio.getActiveEditor();
    
    // Retrieve the contents of the active editor
    var content = editor.content.get();
    alert(content);
};