This example shows how to save and restore selection with API.
<!-- buttons -->
<button onclick="saveSelection(event)">save</button>
<button onclick="restoreSelection(event)">restore</button>
<!-- element -->
<textarea id="entry">...</textarea>
<!-- call -->
<script>
let app = Redactor('#entry');
function saveSelection(e) {
e.preventDefault();
e.stopPropagation();
app.editor.save();
}
function restoreSelection(e) {
e.preventDefault();
e.stopPropagation();
app.editor.restore();
}
</script>