Skip to content
This repository
Browse code

API Clean up the return values for getCurrentLink

Returning a link type "internal" in the situation when no link has been
detected is confusing and makes it hard to know downstream if the link
was detected or not. Switched that to null.

Also added target option to file downloads, as we don't currently have a
mechanism to default this field to "yes" for files.
  • Loading branch information...
commit eef67b6f8761ac947dc473defd46e2c6c4dbc083 1 parent 998b8e0
Mateusz U authored July 10, 2012

Showing 1 changed file with 7 additions and 6 deletions. Show diff stats Hide diff stats

  1. 13  javascript/HtmlEditorField.js
13  javascript/HtmlEditorField.js
@@ -631,8 +631,9 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
631 631
 				}
632 632
 			},
633 633
 		/**
634  
-		 * Return information about the currently selected link, suitable for population of the link
635  
-		 * form.
  634
+		 * Return information about the currently selected link, suitable for population of the link form.
  635
+		 *
  636
+		 * Returns null if no link was currently selected.
636 637
 		 */
637 638
 		getCurrentLink: function() {
638 639
 			var selectedEl = this.getSelection(),
@@ -682,7 +683,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
682 683
 				return {
683 684
 					LinkType: 'file',
684 685
 					file: RegExp.$1,
685  
-					Description: title
  686
+					Description: title,
  687
+					TargetBlank: target ? true : false
686 688
 				};
687 689
 			} else if(href.match(/^#(.*)$/)) {
688 690
 				return {
@@ -707,9 +709,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
707 709
 					TargetBlank: target ? true : false
708 710
 				};
709 711
 			} else {
710  
-				return {
711  
-					LinkType: 'internal'
712  
-				};
  712
+				// No link/invalid link selected.
  713
+				return null;
713 714
 			}
714 715
 		}
715 716
 		});

0 notes on commit eef67b6

Please sign in to comment.
Something went wrong with that request. Please try again.