+++ /dev/null
-/**\r
- * editor_plugin_src.js\r
- *\r
- * Copyright 2009, Moxiecode Systems AB\r
- * Released under LGPL License.\r
- *\r
- * License: http://tinymce.moxiecode.com/license\r
- * Contributing: http://tinymce.moxiecode.com/contributing\r
- */\r
-\r
-(function() {\r
- tinymce.create('tinymce.plugins.BBCodePlugin', {\r
- init : function(ed, url) {\r
- var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();\r
-\r
- ed.onBeforeSetContent.add(function(ed, o) {\r
- o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
- });\r
-\r
- ed.onPostProcess.add(function(ed, o) {\r
- if (o.set)\r
- o.content = t['_' + dialect + '_bbcode2html'](o.content);\r
-\r
- if (o.get)\r
- o.content = t['_' + dialect + '_html2bbcode'](o.content);\r
- });\r
- },\r
-\r
- getInfo : function() {\r
- return {\r
- longname : 'BBCode Plugin',\r
- author : 'Moxiecode Systems AB',\r
- authorurl : 'http://tinymce.moxiecode.com',\r
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',\r
- version : tinymce.majorVersion + "." + tinymce.minorVersion\r
- };\r
- },\r
-\r
- // Private methods\r
-\r
- // HTML -> BBCode in PunBB dialect\r
- _punbb_html2bbcode : function(s) {\r
- s = tinymce.trim(s);\r
-\r
- function rep(re, str) {\r
- s = s.replace(re, str);\r
- };\r
-\r
- // example: <strong> to [b]\r
- rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");\r
- rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");\r
- rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");\r
- rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");\r
- rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");\r
- rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");\r
- rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");\r
- rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");\r
- rep(/<font>(.*?)<\/font>/gi,"$1");\r
- rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");\r
- rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");\r
- rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");\r
- rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");\r
- rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");\r
- rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");\r
- rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");\r
- rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");\r
- rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");\r
- rep(/<\/(strong|b)>/gi,"[/b]");\r
- rep(/<(strong|b)>/gi,"[b]");\r
- rep(/<\/(em|i)>/gi,"[/i]");\r
- rep(/<(em|i)>/gi,"[i]");\r
- rep(/<\/u>/gi,"[/u]");\r
- rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");\r
- rep(/<u>/gi,"[u]");\r
- rep(/<blockquote[^>]*>/gi,"[quote]");\r
- rep(/<\/blockquote>/gi,"[/quote]");\r
- rep(/<br \/>/gi,"\n");\r
- rep(/<br\/>/gi,"\n");\r
- rep(/<br>/gi,"\n");\r
- rep(/<p>/gi,"");\r
- rep(/<\/p>/gi,"\n");\r
- rep(/ /gi," ");\r
- rep(/"/gi,"\"");\r
- rep(/</gi,"<");\r
- rep(/>/gi,">");\r
- rep(/&/gi,"&");\r
-\r
- return s; \r
- },\r
-\r
- // BBCode -> HTML from PunBB dialect\r
- _punbb_bbcode2html : function(s) {\r
- s = tinymce.trim(s);\r
-\r
- function rep(re, str) {\r
- s = s.replace(re, str);\r
- };\r
-\r
- // example: [b] to <strong>\r
- rep(/\n/gi,"<br />");\r
- rep(/\[b\]/gi,"<strong>");\r
- rep(/\[\/b\]/gi,"</strong>");\r
- rep(/\[i\]/gi,"<em>");\r
- rep(/\[\/i\]/gi,"</em>");\r
- rep(/\[u\]/gi,"<u>");\r
- rep(/\[\/u\]/gi,"</u>");\r
- rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");\r
- rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
- rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");\r
- rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");\r
- rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span> ");\r
- rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span> ");\r
-\r
- return s; \r
- }\r
- });\r
-\r
- // Register plugin\r
- tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);\r
-})();
\ No newline at end of file