Based on Davi Ferreira's pure JS Medium Editor