mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-15 17:18:53 +02:00
6f1668c43d
- Restore the "link" button state to disabled by default and enabled when text or image is selected. - Remove the (recently added) default `link` plugin, not needed for `wpLink`. See #27309 Built from https://develop.svn.wordpress.org/trunk@27447 git-svn-id: http://core.svn.wordpress.org/trunk@27293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
/* global tinymce */
|
|
tinymce.PluginManager.add( 'wplink', function( editor ) {
|
|
// Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' );
|
|
editor.addCommand( 'WP_Link', function() {
|
|
if ( typeof window.wpLink !== 'undefined' ) {
|
|
window.wpLink.open( editor.id );
|
|
}
|
|
});
|
|
|
|
editor.addButton( 'link', {
|
|
icon: 'link',
|
|
tooltip: 'Insert/edit link',
|
|
shortcut: 'Alt+Shift+A',
|
|
cmd: 'WP_Link',
|
|
|
|
onPostRender: function() {
|
|
var ctrl = this;
|
|
|
|
editor.on( 'nodechange', function( event ) {
|
|
var node = event.element;
|
|
|
|
ctrl.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
|
|
ctrl.active( node.nodeName === 'A' && ! node.name );
|
|
});
|
|
}
|
|
});
|
|
|
|
editor.addButton( 'unlink', {
|
|
icon: 'unlink',
|
|
tooltip: 'Remove link',
|
|
cmd: 'unlink',
|
|
stateSelector: 'a[href]'
|
|
});
|
|
|
|
editor.addMenuItem( 'link', {
|
|
icon: 'link',
|
|
text: 'Insert link',
|
|
shortcut: 'Alt+Shift+A',
|
|
cmd: 'WP_Link',
|
|
stateSelector: 'a[href]',
|
|
context: 'insert',
|
|
prependToContext: true
|
|
});
|
|
});
|