-/**\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
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
/* Macgirvin Aug-2010 changed from punbb to dfrn dialect */
-(function() {\r
- tinymce.create('tinymce.plugins.BBCodePlugin', {\r
- init : function(ed, url) {\r
+(function() {
+ tinymce.create('tinymce.plugins.BBCodePlugin', {
+ init : function(ed, url) {
var t = this, dialect = ed.getParam('bbcode_dialect', 'dfrn').toLowerCase();
-\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
+
+ 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
+ };
+ },
+
+ // Private methods
+
// HTML -> BBCode in DFRN dialect
_dfrn_html2bbcode : function(s) {
- s = tinymce.trim(s);\r
-\r
- function rep(re, str) {\r
- s = s.replace(re, str);\r
- };\r
-\r
+ s = tinymce.trim(s);
+
+ function rep(re, str) {
+
+
+ s = s.replace(re,str);
+
+ //modify code to keep stuff intact within [code][/code] blocks
+ //Waitman Gobble NO WARRANTY
+
+ /* This doesn't seem to work well with
+ [code]line1
+ line2[/code]
+ commenting out for now
+ */
+
+/*
+ var o = new Array();
+ var x = s.split("[code]");
+ var i = 0;
+
+ var si = "";
+ si = x.shift();
+ si = si.replace(re,str);
+ o.push(si);
+
+ for (i = 0; i < x.length; i++) {
+ var no = new Array();
+ var j = x.shift();
+ var g = j.split("[/code]");
+ no.push(g.shift());
+ si = g.shift();
+ si = si.replace(re,str);
+ no.push(si);
+ o.push(no.join("[/code]"));
+ }
+
+ s = o.join("[code]");
+*/
+ };
+
function get(re) {
return s.match(re);
var codes = get(/<code>(.*?)<\/code>/gi);
rep(/<code>(.*?)<\/code>/gi,"[$!$!CODEBLOCK!$!$]");
- // example: <strong> to [b]\r
+ // example: <strong> to [b]
rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");
- rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");\r
- rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");\r
+ rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
+ rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
- rep(/<font>(.*?)<\/font>/gi,"$1");\r
+ rep(/<font>(.*?)<\/font>/gi,"$1");
// Use [^>]* instead of .* to prevent a match against two separate <img> tags
rep(/<img[^>]*?width=\"([^>]*?)\"[^>]*?height=\"([^>]*?)\"[^>]*?src=\"([^>]*?)\"[^>]*?\/>/gi,"[img=$1x$2]$3[/img]");
rep(/<li>(.*?)<\/li>/gi,'[li]$1[/li]');
//rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
- 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(/<\/(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(/<hr \/>/gi,"[hr]");
rep(/<br (.*?)\/>/gi,"\n");
- rep(/<br \/>/gi,"\n");\r
- rep(/<br>/gi,"\n");\r
- rep(/<p>/gi,"");\r
- rep(/<\/p>/gi,"\n");\r
- rep(/ |\u00a0/gi," ");\r
- rep(/"/gi,"\"");\r
- rep(/</gi,"<");\r
- rep(/>/gi,">");\r
- rep(/&/gi,"&");\r
-\r
+ rep(/<br\/>/gi,"\n");
+ rep(/<br>/gi,"\n");
+ rep(/<p>/gi,"");
+ rep(/<\/p>/gi,"\n");
+ rep(/ |\u00a0/gi," ");
+ rep(/"/gi,"\"");
+ rep(/</gi,"<");
+ rep(/>/gi,">");
+ rep(/&/gi,"&");
+
// Hack to fix an annoying bug of TinyMCE where block formats don't
// work when forced_root_block = ''. So set forced_root_block = 'div'
// and then strip out the divs manually
}
}
- return s; \r
- },\r
-\r
+ return s;
+ },
+
// BBCode -> HTML from DFRN dialect
_dfrn_bbcode2html : function(s) {
- s = tinymce.trim(s);\r
-\r
- function rep(re, str) {\r
- s = s.replace(re, str);\r
- };\r
-\r
+ s = tinymce.trim(s);
+
+
+ function rep(re, str) {
+
+
+ /*//modify code to keep stuff intact within [code][/code] blocks
+ //Waitman Gobble NO WARRANTY
+
+
+ var o = new Array();
+ var x = s.split("[code]");
+ var i = 0;
+
+ var si = "";
+ si = x.shift();
+ si = si.replace(re,str);
+ o.push(si);
+
+ for (i = 0; i < x.length; i++) {
+ var no = new Array();
+ var j = x.shift();
+ var g = j.split("[/code]");
+ no.push(g.shift());
+ si = g.shift();
+ si = si.replace(re,str);
+ no.push(si);
+ o.push(no.join("[/code]"));
+ }
+
+ s = o.join("[code]");*/
+
+ s = s.replace(re, str);
+
+ };
+
function get(re) {
var codes = get(/\[code\](.*?)\[\/code\]/gi);
rep(/\[code\](.*?)\[\/code\]/gi,"[$!$!CODEBLOCK!$!$]");
- // 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
+ // example: [b] to <strong>
+ 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(/\[hr\]/gi,"<hr />");
rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");
- rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");\r
- rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
+ rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
+ rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
- rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");\r
-\r
+ rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
+
rep(/\[list\](.*?)\[\/list\]/gi, '<ul class="listbullet" style="list-style-type: circle;">$1</ul>');
rep(/\[list=\](.*?)\[\/list\]/gi, '<ul class="listnone" style="list-style-type: none;">$1</ul>');
rep(/\[list=1\](.*?)\[\/list\]/gi, '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>');
}
}
- return s; \r
- }\r
- });\r
-\r
- // Register plugin\r
- tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);\r
-})();
\ No newline at end of file
+ return s;
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
+})();