JSFiddle - React, Tailwind, and code Playground

by jasonmerino

HTML

<script src="http://redactorjs.com/js/redactor/redactor.js"></script>
<link rel="stylesheet" href="http://redactorjs.com/js/redactor/css/redactor.min.css">
<!DOCTYPE html>
<html>
    <head>
        <title>Redactor</title>
        <meta charset="utf-8">
    </head>
    <body>
        <textarea id="redactor_content" name="content" style="height: 560px;">I never did quite grasp him, though he endeavored to explain it to me upon numerous occasions. I suggested telepathy, but he said no, that it was not telepathy since they could only communicate when in each others' presence, nor could they talk with the Sagoths or the other inhabitants of Pellucidar by the same method they used to converse with one another.</textarea>
    </body>
</html>

JavaScript

function getRedactorSelection(obj, event, key)
{
    var doc = obj.getDoc().get(0);
    if (doc.getSelection)
    {
        return alert(doc.getSelection());
    }
    else if (doc.selection)
    {
        return alert(doc.selection.createRange());
    }
};
$(document).ready(

function() {
    $('#redactor_content').redactor({
        buttonsAdd: ['|', 'button1'],
        buttonsCustom: {
            button1: {
                title: 'Button',
                callback: getRedactorSelection
            }
        }
    });
});