/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
'background-position: center center;' +\r
'background-repeat: no-repeat;' +\r
'border: 1px solid #a9a9a9;' +\r
- 'width: 18px;' +\r
- 'height: 18px;' +\r
+ 'width: 18px !important;' +\r
+ 'height: 18px !important;' +\r
'}\n' +\r
'a.cke_anchor' +\r
'{' +\r
* for this in Firefox. So we must detect the state by element paths.\r
*/\r
var command = editor.getCommand( 'unlink' ),\r
- element = evt.data.path.lastElement.getAscendant( 'a', true );\r
+ element = evt.data.path.lastElement && evt.data.path.lastElement.getAscendant( 'a', true );\r
if ( element && element.getName() == 'a' && element.getAttribute( 'href' ) )\r
command.setState( CKEDITOR.TRISTATE_OFF );\r
else\r
command.setState( CKEDITOR.TRISTATE_DISABLED );\r
} );\r
\r
+ editor.on( 'doubleclick', function( evt )\r
+ {\r
+ var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element;\r
+\r
+ if ( element.is( 'a' ) )\r
+ evt.data.dialog = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) ) ? 'anchor' : 'link';\r
+ else if ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' )\r
+ evt.data.dialog = 'anchor';\r
+ });\r
+\r
// If the "menu" plugin is loaded, register the menu items.\r
if ( editor.addMenuItems )\r
{\r
{\r
editor.contextMenu.addListener( function( element, selection )\r
{\r
- if ( !element )\r
+ if ( !element || element.isReadOnly() )\r
return null;\r
\r
var isAnchor = ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' );\r
\r
if ( !isAnchor )\r
{\r
- if ( !( element = element.getAscendant( 'a', true ) ) )\r
+ if ( !( element = CKEDITOR.plugins.link.getSelectedLink( editor ) ) )\r
return null;\r
\r
isAnchor = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) );\r
requires : [ 'fakeobjects' ]\r
} );\r
\r
+CKEDITOR.plugins.link =\r
+{\r
+ /**\r
+ * Get the surrounding link element of current selection.\r
+ * @param editor\r
+ * @example CKEDITOR.plugins.link.getSelectedLink( editor );\r
+ * @since 3.2.1\r
+ * The following selection will all return the link element.\r
+ * <pre>\r
+ * <a href="#">li^nk</a>\r
+ * <a href="#">[link]</a>\r
+ * text[<a href="#">link]</a>\r
+ * <a href="#">li[nk</a>]\r
+ * [<b><a href="#">li]nk</a></b>]\r
+ * [<a href="#"><b>li]nk</b></a>\r
+ * </pre>\r
+ */\r
+ getSelectedLink : function( editor )\r
+ {\r
+ try\r
+ {\r
+ var selection = editor.getSelection();\r
+ if ( selection.getType() == CKEDITOR.SELECTION_ELEMENT )\r
+ {\r
+ var selectedElement = selection.getSelectedElement();\r
+ if ( selectedElement.is( 'a' ) )\r
+ return selectedElement;\r
+ }\r
+\r
+ var range = selection.getRanges( true )[ 0 ];\r
+ range.shrink( CKEDITOR.SHRINK_TEXT );\r
+ var root = range.getCommonAncestor();\r
+ return root.getAscendant( 'a', true );\r
+ }\r
+ catch( e ) { return null; }\r
+ }\r
+};\r
+\r
CKEDITOR.unlinkCommand = function(){};\r
CKEDITOR.unlinkCommand.prototype =\r
{\r
selection.selectRanges( ranges );\r
editor.document.$.execCommand( 'unlink', false, null );\r
selection.selectBookmarks( bookmarks );\r
- }\r
+ },\r
+\r
+ startDisabled : true\r
};\r
\r
CKEDITOR.tools.extend( CKEDITOR.config,\r