From de9e3a55e3da492a23255d6bb86757bb892caa68 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 18 Jul 2007 21:29:47 +0000 Subject: [PATCH] Fixing Firefox link creation when in the middle of a line. --- static/js/Editor.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/static/js/Editor.js b/static/js/Editor.js index 58861de..328bb26 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -327,8 +327,16 @@ Editor.prototype.start_link = function () { this.exec_command( "createLink", "/notes/new" ); - container.nodeValue = ""; - selection.collapse( container, 0 ); + var links = getElementsByTagAndClassName( "a", null, parent = this.document ); + for ( var i in links ) { + var link = links[ i ]; + var char_code = link.firstChild.nodeValue.charCodeAt( 0 ); + // look for links titled with a space or nbsp character + if ( link.firstChild.nodeValue.length == 1 && char_code == 0x20 || char_code == 0xa0 ) { + link.firstChild.nodeValue = ""; + selection.collapse( link.firstChild, 0 ); + } + } // otherwise, just create a link with the selected text as the link title } else { this.exec_command( "createLink", "/notes/new" );