Last active
May 5, 2017 12:15
-
-
Save jonathanborges/a8abcef877d876d8d85508dc05d812b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>TinyMCE Upload Base64Image</title> | |
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script> | |
<script> | |
tinymce.init({ | |
selector: 'textarea', | |
height: 500, | |
toolbar: 'mybutton', | |
menubar: false, | |
setup: function (editor) { | |
editor.addButton('mybutton', { | |
text: 'Inserir Imagem', | |
icon: false, | |
onclick: function () { | |
var el = document.createElement('input'); | |
el.setAttribute('type', 'file'); | |
el.style.display = 'none'; | |
document.body.appendChild(el); | |
el.addEventListener('change', function(event) { | |
var reader = new FileReader(); | |
reader.readAsDataURL(event.target.files[0]); | |
reader.onload = function () { | |
editor.insertContent('<img src="'+reader.result+'">'); | |
}; | |
}); | |
el.click(); | |
} | |
}); | |
}, | |
content_css: [] | |
}); | |
</script> | |
</head> | |
<body> | |
<textarea cols="30" rows="30"></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment