Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 841427 - Allow 'Launch' link context item
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Feb 19, 2013
1 parent 0a808ee commit 9900cba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions media/ckeditor/plugins/mdn-link/plugin.js
Expand Up @@ -25,6 +25,7 @@ CKEDITOR.plugins.add( 'mdn-link',
editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor' ) );
editor.addCommand( 'unlink', new CKEDITOR.unlinkCommand() );
editor.addCommand( 'removeAnchor', new CKEDITOR.removeAnchorCommand() );
editor.addCommand( 'launch', new CKEDITOR.launchCommand() );
editor.ui.addButton( 'Link',
{
label : editor.lang.link.toolbar,
Expand Down Expand Up @@ -147,6 +148,14 @@ CKEDITOR.plugins.add( 'mdn-link',
command : 'unlink',
group : 'link',
order : 5
},

launch :
{
label: gettext('Launch'),
command: 'launch',
group: 'link',
order: 6
}
});
}
Expand All @@ -160,18 +169,22 @@ CKEDITOR.plugins.add( 'mdn-link',
return null;

var anchor = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, element );

if ( !anchor && !( anchor = CKEDITOR.plugins.link.getSelectedLink( editor ) ) )
return null;

var menu = {};

if ( anchor.getAttribute( 'href' ) && anchor.getChildCount() )
menu = { link : CKEDITOR.TRISTATE_OFF, unlink : CKEDITOR.TRISTATE_OFF };
menu = {
link : CKEDITOR.TRISTATE_OFF,
unlink : CKEDITOR.TRISTATE_OFF
};

if ( anchor && anchor.hasAttribute( 'name' ) )
menu.anchor = menu.removeAnchor = CKEDITOR.TRISTATE_OFF;

menu.launch = CKEDITOR.TRISTATE_ON;

return menu;
});
}
Expand Down Expand Up @@ -315,6 +328,16 @@ CKEDITOR.plugins.link =
}
};

CKEDITOR.launchCommand = function() {};
CKEDITOR.launchCommand.prototype = {
exec: function(editor) {
var link = CKEDITOR.plugins.link.getSelectedLink(editor)
if(link && link.$) {
window.open(link.$.href);
}
}
};

CKEDITOR.unlinkCommand = function(){};
CKEDITOR.unlinkCommand.prototype =
{
Expand Down
2 changes: 1 addition & 1 deletion media/ckeditor/skins/kuma/editor.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9900cba

Please sign in to comment.