Skip to content

Instantly share code, notes, and snippets.

@scottsappen
Created July 1, 2013 15:20
Show Gist options
  • Save scottsappen/5901768 to your computer and use it in GitHub Desktop.
Save scottsappen/5901768 to your computer and use it in GitHub Desktop.
great WYSIWYG editors out there for your web pages http://www.tinymce.com/
<script src="../Scripts/tinymce/jscripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>
<textarea id="textarea_text" rows="20" cols="20" runat="server" class="tinymce" />
tinyMCE.init({
mode: "specific_textareas",
editor_selector: "tinymce",
encoding: "xml",
height: "600",
width: "100%",
theme: "advanced",
plugins: "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
theme_advanced_buttons1: "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
theme_advanced_buttons2: "cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,|,insertdate,inserttime",
theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,advhr",
theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,pagebreak,|,print,|,ltr,rtl,|,fullscreen,preview",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,
setup: function (ed) {
ed.onSaveContent.add(function (i, o) {
o.content = o.content.replace(/&#39/g, "&apos");
});
}
});
And finally, notice the
encoding: xml
initialization code in the constructor. Take care of the encoding piece should you wish. I’d recommend this vs. disabling any kind of validation to help protect yourself a little bit more from XSS attacks or things of that nature. If you do, you need to decode it to display it properly.
pseudo code:
textarea_text.Value = HttpUtility.HtmlDecode(theEncodedTextFromDBOrWherever)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment