diff --git a/addons/autolink/autolink.js b/addons/autolink/autolink.js index 4fec3010a..1dc836e4e 100644 --- a/addons/autolink/autolink.js +++ b/addons/autolink/autolink.js @@ -13,18 +13,21 @@ this.extractTargets($('.xe_content')); $(this.targets).each(function(){ - if (!url_regex.test(this.nodeValue)) return true; thisPlugin.cast('AUTOLINK', [this]); }); }, API_AUTOLINK : function(oSender, params) { var textNode = params[0]; var content = textNode.nodeValue; + var dummy = $(''); content = content.replace(//g, '>'); content = content.replace(url_regex, '$1'); - $(textNode).replaceWith(params[0] = $(content)); + $(textNode).before(dummy); + $(textNode).replaceWith(content); + params[0] = dummy.next('a'); + dummy.remove(); }, extractTargets : function(obj) { var thisPlugin = this; @@ -33,7 +36,7 @@ .contents() .each(function(){ if (!$(this).is('a,pre,xml,code,script,style,:input')) { - if (this.nodeType == 3) { // text node + if (this.nodeType == 3 && url_regex.test(this.nodeValue)) { // text node thisPlugin.targets.push(this); } else { thisPlugin.extractTargets(this); diff --git a/addons/autolink/autolink.spec.html b/addons/autolink/autolink.spec.html new file mode 100644 index 000000000..da7908e4e --- /dev/null +++ b/addons/autolink/autolink.spec.html @@ -0,0 +1,95 @@ + + + + +Autolink Addon Unit Test + + + + + + + + + + + + + \ No newline at end of file