/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
CKEDITOR.plugins.add( 'link',\r
{\r
+ requires : [ 'fakeobjects', 'dialog' ],\r
init : function( editor )\r
{\r
// Add the link and unlink buttons.\r
editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) );\r
editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor' ) );\r
editor.addCommand( 'unlink', new CKEDITOR.unlinkCommand() );\r
+ editor.addCommand( 'removeAnchor', new CKEDITOR.removeAnchorCommand() );\r
editor.ui.addButton( 'Link',\r
{\r
label : editor.lang.link.toolbar,\r
{\r
label : editor.lang.anchor.menu,\r
command : 'anchor',\r
- group : 'anchor'\r
+ group : 'anchor',\r
+ order : 1\r
+ },\r
+\r
+ removeAnchor :\r
+ {\r
+ label : editor.lang.anchor.remove,\r
+ command : 'removeAnchor',\r
+ group : 'anchor',\r
+ order : 5\r
},\r
\r
link :\r
menu = { link : CKEDITOR.TRISTATE_OFF, unlink : CKEDITOR.TRISTATE_OFF };\r
\r
if ( anchor && anchor.hasAttribute( 'name' ) )\r
- menu.anchor = CKEDITOR.TRISTATE_OFF;\r
+ menu.anchor = menu.removeAnchor = CKEDITOR.TRISTATE_OFF;\r
\r
return menu;\r
});\r
}\r
});\r
}\r
- },\r
-\r
- requires : [ 'fakeobjects' ]\r
+ }\r
} );\r
\r
CKEDITOR.plugins.link =\r
startDisabled : true\r
};\r
\r
+CKEDITOR.removeAnchorCommand = function(){};\r
+CKEDITOR.removeAnchorCommand.prototype =\r
+{\r
+ /** @ignore */\r
+ exec : function( editor )\r
+ {\r
+ var sel = editor.getSelection(),\r
+ bms = sel.createBookmarks(),\r
+ anchor;\r
+ if ( sel && ( anchor = sel.getSelectedElement() ) && ( CKEDITOR.plugins.link.fakeAnchor && !anchor.getChildCount() ? CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, anchor ) : anchor.is( 'a' ) ) )\r
+ anchor.remove( 1 );\r
+ else\r
+ {\r
+ if ( ( anchor = CKEDITOR.plugins.link.getSelectedLink( editor ) ) )\r
+ {\r
+ if ( anchor.hasAttribute( 'href' ) )\r
+ {\r
+ anchor.removeAttributes( { name : 1, 'data-cke-saved-name' : 1 } );\r
+ anchor.removeClass( 'cke_anchor' );\r
+ }\r
+ else\r
+ anchor.remove( 1 );\r
+ }\r
+ }\r
+ sel.selectBookmarks( bms );\r
+ }\r
+};\r
+\r
CKEDITOR.tools.extend( CKEDITOR.config,\r
{\r
linkShowAdvancedTab : true,\r