From cfdd666c5f5477b3032db43a89ee75bbae1adffe Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 3 Dec 2008 13:10:18 -0800 Subject: [PATCH] Fixed a Chrome/Safari bug in which ending a link didn't always work. Specifically, in a list of two elements in which each element was a link, clicking right after the first element and then pressing ctrl-L to end the link didn't work as expected. Now it does. --- NEWS | 2 +- static/js/Editor.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 6c2a633..ea7d566 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ 1.5.9: - * + * Fixed a Chrome/Safari bug in which ending a link didn't always work. 1.5.8: November 24, 2008 * Fixed a bug that prevented notes from being automatically saved in certain diff --git a/static/js/Editor.js b/static/js/Editor.js index b2d760d..9ef625d 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -602,7 +602,9 @@ Editor.prototype.end_link = function () { // end of the link if it's not already there if ( link && WEBKIT ) { var selection = this.iframe.contentWindow.getSelection(); - selection.collapse( link, 1 ); + var sentinel = this.document.createTextNode( Editor.title_placeholder_char ); + insertSiblingNodesAfter( link, sentinel ); + selection.collapse( sentinel, 1 ); } } else if ( this.document.selection ) { // browsers such as IE // if some text is already selected, unlink it and bail