diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index 44d1473a99..183f2bc68d 100755 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -44,61 +44,79 @@ _dfrn_html2bbcode : function(s) { 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]"); - - }; - - - - - /* oembed */ - function _h2b_cb(match) { - function s_h2b(data) { - match = data; + 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]"); + + }; + + + + + /* oembed */ + function _h2b_cb(match) { + /* + function s_h2b(data) { + match = data; } $.ajax({ - type:"POST", + type:"POST", url: 'oembed/h2b', - data: {text: match}, - async: false, - success: s_h2b, - dataType: 'html' - }); - return match; - } + data: {text: match}, + async: false, + success: s_h2b, + dataType: 'html' + }); + */ + + var f, g, tof = [], tor = []; + var find_spanc = /]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:]*>(.*?)<\/span *>)*.*?)<\/span *>/ig; + while (f = find_spanc.exec(match)) { + var find_a = /]* rel=[\"']oembed[\"'][^>]*)>.*?<\/a *>/ig; + if (g = find_a.exec(f[1])) { + var find_href = /href=[\"']([^\"']*)[\"']/ig; + var m2 = find_href.exec(g[1]); + if (m2[1]) { + tof.push(f[0]); + tor.push("[EMBED]" + m2[1] + "[/EMBED]"); + } + } + } + for (var i = 0; i < tof.length; i++) match = match.replace(tof[i], tor[i]); + + return match; + } if (s.indexOf('class="oembed')>=0){ //alert("request oembed html2bbcode"); s = _h2b_cb(s); } - - /* /oembed */ - + + /* /oembed */ + // example: to [b] rep(/(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]"); @@ -111,16 +129,16 @@ rep(//gi,"[img=$3x$2]$1[/img]"); rep(//gi,"[img=$2x$3]$1[/img]"); rep(//gi,"[img]$1[/img]"); - - rep(/