JSFiddle - React, Tailwind, and code Playground

by jakie8

HTML

<textarea id="demo"></textarea>

CSS

#demo{
    margin:20px;
    min-height:250px;
    width:300px;
    font-family:monospace;
    padding:10px;
    font-size:13px;
}

JavaScript

var Behave = Behave || function (userOpts) {

    'use strict';

    // Fast repeat, uses the `Exponentiation by squaring` algorithm.
    if (typeof String.prototype.repeat !== 'function') {
        String.prototype.repeat = function(times) {
            if (times < 1){
                return '';
            }
            if (times % 2){
                return this.repeat(times - 1) + this;
            }
            var half = this.repeat(times / 2);
            return half + half;
        };
    }

    if (typeof Array.prototype.filter !== 'function') {
        Array.prototype.filter = function(func /*, thisp */) {
            if (this === null) {
                throw new TypeError();
            }

            var t = Object(this),
                len = t.length >>> 0;
            if (typeof func != "function"){
                throw new TypeError();
            }
            var res = [],
                thisp = arguments[1];
            for (var i = 0; i < len; i++) {
                if (i in t) {
                    var val = t[i];
                    if (func.call(thisp, val, i, t)) {
                        res.push(val);
                    }
                }
            }
            return res;
        };
    }

    var defaults = {
        textarea: null,
        replaceTab: true,
        softTabs: true,
        tabSize: 4,
        autoOpen: true,
        overwrite: true,
        autoStrip: true,
        autoIndent: true,
        fence: false
    },
    tab,
    charSettings = {

        keyMap: [
            { open: "\"", close: "\"", canBreak: false },
            { open: "'", close: "'", canBreak: false },
            { open: "(", close: ")", canBreak: false },
            { open: "[", close: "]", canBreak: true },
            { open: "{", close: "}", canBreak: true }
        ]

    },
    utils = {
        cursor: {
            get: function doGetCaretPosition() {
                var caretPos = 0;

                if (typeof...