From 27c26ec5c28e622c0efe6a2829432010a8da56c1 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 16 Feb 2009 16:54:17 -0800 Subject: [PATCH] Now, if you copy a link from another web page and paste it into a note, Luminotes properly recognizes it as an external link. --- NEWS | 2 ++ static/js/Editor.js | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index d8999d5..c0b0c82 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ URL. * You can now copy the Luminotes Desktop URL and paste it into another web browser without getting an error message. + * Now, if you copy a link from another web page and paste it into a note, + Luminotes properly recognizes it as an external link. * Fixed a bug in which clicking "compare versions" during a conflict didn't actually display the changes between the two versions. diff --git a/static/js/Editor.js b/static/js/Editor.js index d1172de..8b7d01e 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -1034,18 +1034,8 @@ Editor.prototype.mouse_released = function ( event ) { } if ( !link.href ) return false; - // links with targets are considered to be external links pointing outside of this wiki - if ( link.target ) { - // if this is a read-only editor and the link target is "_top", go to the link's URL directly - if ( !self.edit_enabled && link.target == "_top" ) { - window.location = link.href; - return true; - } - - // launch the external link ourselves, assuming that its target is "_new" - window.open( link.href ); - return true; - } + var query = parse_query( link ); + var id = query.note_id; // special case for links to uploaded files if ( !link.target && /\/files\//.test( link.href ) ) { @@ -1055,10 +1045,23 @@ Editor.prototype.mouse_released = function ( event ) { return true; } + // links with targets are considered to be external links pointing outside of this wiki + if ( link.target || id == undefined ) { + // if this is a read-only editor and the link target is "_top", go to the link's URL directly + if ( !self.edit_enabled && ( link.target == "_top" || !link.target ) ) { + window.location = link.href; + return true; + } + + // launch the external link ourselves, assuming that its target is "_new" + window.open( link.href ); + if ( !link.target ) + link.target = "_top"; + return true; + } + // load the note corresponding to the clicked link - var query = parse_query( link ); var title = link_title( link, query ); - var id = query.note_id; signal( self, "load_editor", title, id, null, null, link, self.holder ); return true; }