X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Flink%2Fplugin.js;h=c7f7adb77e3f3d6164749bd8644bfc2d13f3ca9b;hb=refs%2Ftags%2Fv3.3.2;hp=3681b8e72844757282a7af295e3d3b797914c814;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/link/plugin.js b/_source/plugins/link/plugin.js index 3681b8e..c7f7adb 100644 --- a/_source/plugins/link/plugin.js +++ b/_source/plugins/link/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -37,8 +37,8 @@ CKEDITOR.plugins.add( 'link', 'background-position: center center;' + 'background-repeat: no-repeat;' + 'border: 1px solid #a9a9a9;' + - 'width: 18px;' + - 'height: 18px;' + + 'width: 18px !important;' + + 'height: 18px !important;' + '}\n' + 'a.cke_anchor' + '{' + @@ -65,6 +65,16 @@ CKEDITOR.plugins.add( 'link', command.setState( CKEDITOR.TRISTATE_DISABLED ); } ); + editor.on( 'doubleclick', function( evt ) + { + var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element; + + if ( element.is( 'a' ) ) + evt.data.dialog = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) ) ? 'anchor' : 'link'; + else if ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' ) + evt.data.dialog = 'anchor'; + }); + // If the "menu" plugin is loaded, register the menu items. if ( editor.addMenuItems ) { @@ -107,7 +117,7 @@ CKEDITOR.plugins.add( 'link', if ( !isAnchor ) { - if ( !( element = element.getAscendant( 'a', true ) ) ) + if ( !( element = CKEDITOR.plugins.link.getSelectedLink( editor ) ) ) return null; isAnchor = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) ); @@ -147,6 +157,35 @@ CKEDITOR.plugins.add( 'link', requires : [ 'fakeobjects' ] } ); +CKEDITOR.plugins.link = +{ + /** + * Get the surrounding link element of current selection. + * @param editor + * @example CKEDITOR.plugins.link.getSelectedLink( editor ); + * @since 3.2.1 + * The following selection will all return the link element. + *
+	 *  li^nk
+	 *  [link]
+	 *  text[link]
+	 *  li[nk]
+	 *  [li]nk]
+	 *  [li]nk
+	 * 
+ */ + getSelectedLink : function( editor ) + { + var range; + try { range = editor.getSelection().getRanges()[ 0 ]; } + catch( e ) { return null; } + + range.shrink( CKEDITOR.SHRINK_TEXT ); + var root = range.getCommonAncestor(); + return root.getAscendant( 'a', true ); + } +}; + CKEDITOR.unlinkCommand = function(){}; CKEDITOR.unlinkCommand.prototype = { @@ -178,7 +217,9 @@ CKEDITOR.unlinkCommand.prototype = selection.selectRanges( ranges ); editor.document.$.execCommand( 'unlink', false, null ); selection.selectBookmarks( bookmarks ); - } + }, + + startDisabled : true }; CKEDITOR.tools.extend( CKEDITOR.config,