Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created June 1, 2011 18:06
Show Gist options
  • Save mkuklis/1002898 to your computer and use it in GitHub Desktop.
Save mkuklis/1002898 to your computer and use it in GitHub Desktop.
TINYeditor
var editor = new TINY.editor.edit('editor', {
id: "editor",
width: 400,
height:200,
cssclass:'te',
controlclass:'tecontrol',
rowclass:'teheader',
dividerclass:'tedivider',
controls:['bold','italic','link','unlink','image','orderedlist','unorderedlist','undo','redo'],
footer:false,
fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
xhtml:true,
cssfile:'/stylesheets/tinyeditor/tinyeditor.css',
bodyid:'editor',
footerclass:'tefooter',
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
resize:{cssclass:'resize'}
});
// bind on key up
$(editor.i.contentWindow.document).keyup(function(e) {
$('#textarea').val($(this).find("#editor").html()));
});
// bind to paste event
$(editor.i.contentWindow.document).bind('paste', function(e) {
setTimeout(function() {
$('#textarea').val($(editor).find("#editor").html());
}, 100);
});
// bind when buttons are used
$(".tecontrol").bind("click", function() {
var html = $(editor.i.contentWindow.document.body)[0].innerHTML;
$('#textarea').val(html);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment