X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Flink%2Fplugin.js;h=4442432bdf2a51dc7f6e558570ebe3aad36f6d52;hp=083256cea2ad0e8253cb9a37e13fdb85059e3dd8;hb=f0610347140239143439a511ee2bd48cb784f470;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/plugins/link/plugin.js b/_source/plugins/link/plugin.js index 083256c..4442432 100644 --- a/_source/plugins/link/plugin.js +++ b/_source/plugins/link/plugin.js @@ -11,6 +11,7 @@ CKEDITOR.plugins.add( 'link', editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) ); editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor' ) ); editor.addCommand( 'unlink', new CKEDITOR.unlinkCommand() ); + editor.addCommand( 'removeAnchor', new CKEDITOR.removeAnchorCommand() ); editor.ui.addButton( 'Link', { label : editor.lang.link.toolbar, @@ -108,7 +109,16 @@ CKEDITOR.plugins.add( 'link', { label : editor.lang.anchor.menu, command : 'anchor', - group : 'anchor' + group : 'anchor', + order : 1 + }, + + removeAnchor : + { + label : editor.lang.anchor.remove, + command : 'removeAnchor', + group : 'anchor', + order : 5 }, link : @@ -148,7 +158,7 @@ CKEDITOR.plugins.add( 'link', menu = { link : CKEDITOR.TRISTATE_OFF, unlink : CKEDITOR.TRISTATE_OFF }; if ( anchor && anchor.hasAttribute( 'name' ) ) - menu.anchor = CKEDITOR.TRISTATE_OFF; + menu.anchor = menu.removeAnchor = CKEDITOR.TRISTATE_OFF; return menu; }); @@ -329,6 +339,34 @@ CKEDITOR.unlinkCommand.prototype = startDisabled : true }; +CKEDITOR.removeAnchorCommand = function(){}; +CKEDITOR.removeAnchorCommand.prototype = +{ + /** @ignore */ + exec : function( editor ) + { + var sel = editor.getSelection(), + bms = sel.createBookmarks(), + anchor; + if ( sel && ( anchor = sel.getSelectedElement() ) && ( CKEDITOR.plugins.link.fakeAnchor && !anchor.getChildCount() ? CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, anchor ) : anchor.is( 'a' ) ) ) + anchor.remove( 1 ); + else + { + if ( ( anchor = CKEDITOR.plugins.link.getSelectedLink( editor ) ) ) + { + if ( anchor.hasAttribute( 'href' ) ) + { + anchor.removeAttributes( { name : 1, 'data-cke-saved-name' : 1 } ); + anchor.removeClass( 'cke_anchor' ); + } + else + anchor.remove( 1 ); + } + } + sel.selectBookmarks( bms ); + } +}; + CKEDITOR.tools.extend( CKEDITOR.config, { linkShowAdvancedTab : true,