diff options
| author | hukl <contact@smyck.org> | 2009-02-17 21:54:39 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-17 21:54:39 +0100 |
| commit | f61b5b0597e0c25f084ee67d402f12a43a7a9947 (patch) | |
| tree | 3b4c3f9f38637f1a7ecf703ece4fd3bc4c6e2934 /public/javascripts/tiny_mce/plugins/bbcode | |
| parent | 3d3b786cc43266f6292f5edd25733dbb9bd6ed06 (diff) | |
added tinymce editor for body area of pages
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/bbcode')
| -rwxr-xr-x | public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js | 1 | ||||
| -rwxr-xr-x | public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js | 117 |
2 files changed, 118 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js b/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js new file mode 100755 index 0000000..88f7ea6 --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js | |||
| @@ -0,0 +1 @@ | |||
| (function(){tinymce.create('tinymce.plugins.BBCodePlugin',{init:function(ed,url){var t=this,dialect=ed.getParam('bbcode_dialect','punbb').toLowerCase();ed.onBeforeSetContent.add(function(ed,o){o.content=t['_'+dialect+'_bbcode2html'](o.content);});ed.onPostProcess.add(function(ed,o){if(o.set)o.content=t['_'+dialect+'_bbcode2html'](o.content);if(o.get)o.content=t['_'+dialect+'_html2bbcode'](o.content);});},getInfo:function(){return{longname:'BBCode Plugin',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_punbb_html2bbcode:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str);};rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");rep(/<font>(.*?)<\/font>/gi,"$1");rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");rep(/<\/(strong|b)>/gi,"[/b]");rep(/<(strong|b)>/gi,"[b]");rep(/<\/(em|i)>/gi,"[/i]");rep(/<(em|i)>/gi,"[i]");rep(/<\/u>/gi,"[/u]");rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");rep(/<u>/gi,"[u]");rep(/<blockquote[^>]*>/gi,"[quote]");rep(/<\/blockquote>/gi,"[/quote]");rep(/<br \/>/gi,"\n");rep(/<br\/>/gi,"\n");rep(/<br>/gi,"\n");rep(/<p>/gi,"");rep(/<\/p>/gi,"\n");rep(/ /gi," ");rep(/"/gi,"\"");rep(/</gi,"<");rep(/>/gi,">");rep(/&/gi,"&");return s;},_punbb_bbcode2html:function(s){s=tinymce.trim(s);function rep(re,str){s=s.replace(re,str);};rep(/\n/gi,"<br />");rep(/\[b\]/gi,"<strong>");rep(/\[\/b\]/gi,"</strong>");rep(/\[i\]/gi,"<em>");rep(/\[\/i\]/gi,"</em>");rep(/\[u\]/gi,"<u>");rep(/\[\/u\]/gi,"</u>");rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span> ");rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span> ");return s;}});tinymce.PluginManager.add('bbcode',tinymce.plugins.BBCodePlugin);})(); \ No newline at end of file | |||
diff --git a/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js new file mode 100755 index 0000000..1d7493e --- /dev/null +++ b/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | /** | ||
| 2 | * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ | ||
| 3 | * | ||
| 4 | * @author Moxiecode | ||
| 5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. | ||
| 6 | */ | ||
| 7 | |||
| 8 | (function() { | ||
| 9 | tinymce.create('tinymce.plugins.BBCodePlugin', { | ||
| 10 | init : function(ed, url) { | ||
| 11 | var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase(); | ||
| 12 | |||
| 13 | ed.onBeforeSetContent.add(function(ed, o) { | ||
| 14 | o.content = t['_' + dialect + '_bbcode2html'](o.content); | ||
| 15 | }); | ||
| 16 | |||
| 17 | ed.onPostProcess.add(function(ed, o) { | ||
| 18 | if (o.set) | ||
| 19 | o.content = t['_' + dialect + '_bbcode2html'](o.content); | ||
| 20 | |||
| 21 | if (o.get) | ||
| 22 | o.content = t['_' + dialect + '_html2bbcode'](o.content); | ||
| 23 | }); | ||
| 24 | }, | ||
| 25 | |||
| 26 | getInfo : function() { | ||
| 27 | return { | ||
| 28 | longname : 'BBCode Plugin', | ||
| 29 | author : 'Moxiecode Systems AB', | ||
| 30 | authorurl : 'http://tinymce.moxiecode.com', | ||
| 31 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode', | ||
| 32 | version : tinymce.majorVersion + "." + tinymce.minorVersion | ||
| 33 | }; | ||
| 34 | }, | ||
| 35 | |||
| 36 | // Private methods | ||
| 37 | |||
| 38 | // HTML -> BBCode in PunBB dialect | ||
| 39 | _punbb_html2bbcode : function(s) { | ||
| 40 | s = tinymce.trim(s); | ||
| 41 | |||
| 42 | function rep(re, str) { | ||
| 43 | s = s.replace(re, str); | ||
| 44 | }; | ||
| 45 | |||
| 46 | // example: <strong> to [b] | ||
| 47 | rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"); | ||
| 48 | rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"); | ||
| 49 | rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"); | ||
| 50 | rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"); | ||
| 51 | rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"); | ||
| 52 | rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"); | ||
| 53 | rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"); | ||
| 54 | rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"); | ||
| 55 | rep(/<font>(.*?)<\/font>/gi,"$1"); | ||
| 56 | rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"); | ||
| 57 | rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"); | ||
| 58 | rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"); | ||
| 59 | rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"); | ||
| 60 | rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"); | ||
| 61 | rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"); | ||
| 62 | rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"); | ||
| 63 | rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"); | ||
| 64 | rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"); | ||
| 65 | rep(/<\/(strong|b)>/gi,"[/b]"); | ||
| 66 | rep(/<(strong|b)>/gi,"[b]"); | ||
| 67 | rep(/<\/(em|i)>/gi,"[/i]"); | ||
| 68 | rep(/<(em|i)>/gi,"[i]"); | ||
| 69 | rep(/<\/u>/gi,"[/u]"); | ||
| 70 | rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"); | ||
| 71 | rep(/<u>/gi,"[u]"); | ||
| 72 | rep(/<blockquote[^>]*>/gi,"[quote]"); | ||
| 73 | rep(/<\/blockquote>/gi,"[/quote]"); | ||
| 74 | rep(/<br \/>/gi,"\n"); | ||
| 75 | rep(/<br\/>/gi,"\n"); | ||
| 76 | rep(/<br>/gi,"\n"); | ||
| 77 | rep(/<p>/gi,""); | ||
| 78 | rep(/<\/p>/gi,"\n"); | ||
| 79 | rep(/ /gi," "); | ||
| 80 | rep(/"/gi,"\""); | ||
| 81 | rep(/</gi,"<"); | ||
| 82 | rep(/>/gi,">"); | ||
| 83 | rep(/&/gi,"&"); | ||
| 84 | |||
| 85 | return s; | ||
| 86 | }, | ||
| 87 | |||
| 88 | // BBCode -> HTML from PunBB dialect | ||
| 89 | _punbb_bbcode2html : function(s) { | ||
| 90 | s = tinymce.trim(s); | ||
| 91 | |||
| 92 | function rep(re, str) { | ||
| 93 | s = s.replace(re, str); | ||
| 94 | }; | ||
| 95 | |||
| 96 | // example: [b] to <strong> | ||
| 97 | rep(/\n/gi,"<br />"); | ||
| 98 | rep(/\[b\]/gi,"<strong>"); | ||
| 99 | rep(/\[\/b\]/gi,"</strong>"); | ||
| 100 | rep(/\[i\]/gi,"<em>"); | ||
| 101 | rep(/\[\/i\]/gi,"</em>"); | ||
| 102 | rep(/\[u\]/gi,"<u>"); | ||
| 103 | rep(/\[\/u\]/gi,"</u>"); | ||
| 104 | rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>"); | ||
| 105 | rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>"); | ||
| 106 | rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />"); | ||
| 107 | rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>"); | ||
| 108 | rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span> "); | ||
| 109 | rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span> "); | ||
| 110 | |||
| 111 | return s; | ||
| 112 | } | ||
| 113 | }); | ||
| 114 | |||
| 115 | // Register plugin | ||
| 116 | tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); | ||
| 117 | })(); \ No newline at end of file | ||
