{"id":280,"date":"2011-10-30T18:05:53","date_gmt":"2011-10-30T22:05:53","guid":{"rendered":"https:\/\/havalite.com\/?p=280"},"modified":"2022-12-01T18:21:20","modified_gmt":"2022-12-01T23:21:20","slug":"cleditor-wysiwyg-editor","status":"publish","type":"post","link":"https:\/\/havalite.com\/?p=280","title":{"rendered":"CLEditor &#8211; WYSIWYG HTML Editor"},"content":{"rendered":"<p>CLEditor is one of the best jQuery WYSIWYG open source editors in the internet. It has most features for small projects and can also be easily developed to add more features to it. The implementation on a web site is very easy, that&#8217;s why i choosed it to be a plugin for Havalite CMS and in other projects of mine. The only thing i needed is to allow users to add a list of their own defined CSS Styles, maybe some which are not used in CLEditor such as(direction:RTL, display:Block, list-style, own fonts etc..). And for this purpose i made the plugin &#8220;myStyles&#8221; which can be added to CLEditor<\/p>\n<h2>Usage:<\/h2>\n<p>First we need the jQuery framework as usual by any jQuery project:<\/p>\n<pre class=\"js\">&lt;script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4.2\/jquery.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>After that we implement the CLEditor. (If you still don&#8217;t have it, you can <a href=\"http:\/\/premiumsoftware.net\/cleditor\/\">download from here<\/a>)<\/p>\n<pre class=\"js\">&lt;script type=\"text\/javascript\" src=\"jquery.cleditor.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>Now we add<tt style=\"color: #5084a0;\"> jquery.cleditor.mystyles.js<\/tt> to get a new button on the editor for our own styles. Don&#8217;t forget to put the the icon <strong>mystyles.png<\/strong> in the images folder!<\/p>\n<pre class=\"js\">&lt;script type=\"text\/javascript\" src=\"jquery.cleditor.mystyles.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>And here is the part for implementing CLEditor with some features such as width and height:<\/p>\n<pre class=\"js\">&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function() {\r\n    $.cleditor.defaultOptions.width = 500;  \/\/ OR '100%'\r\n    $.cleditor.defaultOptions.height = 300;\r\n    $(\"textarea\").cleditor();\r\n});\r\n&lt;\/script&gt;<\/pre>\n<p>Now CLEditor is ready and can be seen on your site. If you want to use it only for a specified textarea, change the last line by adding the id or class of the textarea:<tt style=\"color: #5084a0;\"> $(\"#myTextArea\").cleditor(); <\/tt><\/p>\n<p>Under mystyles button you&#8217;ll find only 4 defined styles. To change or add more, open the file <tt style=\"color: #5084a0;\">jquery.cleditor.mystyles.js<\/tt>, there you&#8217;ll see the <tt style=\"color: #5084a0;\"><strong>var mylist<\/strong><\/tt>. Just add the name of your style and the styles you want as follow:<\/p>\n<pre class=\"js\">var mslist = {\r\n    \"Marker Yellow\" : \"color:red; background-color:#FFFF00;\",\r\n    \"Marker Green\" : \"color:#000; background-color:#00FF00;\",\r\n    \"divider\" : \"\",\r\n    \"Language RTL\" : \"direction:rtl; display:block;\",\r\n    \"Language LTR\" : \"direction:ltr;\"\r\n};\r\n<\/pre>\n<p>Thats it<\/p>\n<p><a href=\"https:\/\/havalite.com\/experiment\/cleditor\/\">See Demo<\/a><\/p>\n<p><span class=\"download\">Download:<\/span> <a href=\"https:\/\/havalite.com\/experiment\/cleditor\/jquery.cleditor.mystyles.js\">jquery.cleditor.mystyles.js<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CLEditor is one of the best jQuery WYSIWYG open source editors in the internet. It has most features for small projects and can also be easily developed to add more features to it. The implementation on a web site is very easy, that&#8217;s why i choosed it to be a plugin for Havalite CMS and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-jquery-plugins"],"_links":{"self":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280"}],"version-history":[{"count":7,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":307,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions\/307"}],"wp:attachment":[{"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}