CoreFiles by mySites.guru
plugin.js62 lines, 1,538 bytes, from wordpress-3.9.39.zip
Raw History Compare with 3.9.37
md5
c72fe4f61b17d1730183c6c5d3086faa
sha1
e7d7dc0c90015f74fc90c25e3ca36455c8cc4879
sha256
53a29bed83500d9f2c000192fe990748b2ea60fe937fa71d8546c5795401d4ef
/* global tinymce */
tinymce.PluginManager.add( 'wplink', function( editor ) {
	var linkButton;
	
	// Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' );
	editor.addCommand( 'WP_Link', function() {
		if ( ( ! linkButton || ! linkButton.disabled() ) && typeof window.wpLink !== 'undefined' ) {
			window.wpLink.open( editor.id );
		}
	});

	// WP default shortcut
	editor.addShortcut( 'alt+shift+a', '', 'WP_Link' );
	// The "de-facto standard" shortcut, see #27305
	editor.addShortcut( 'ctrl+k', '', 'WP_Link' );

	function setState( button, node ) {
		var parent = editor.dom.getParent( node, 'a' );

		button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) );
		button.active( parent && parent.href );
	}

	editor.addButton( 'link', {
		icon: 'link',
		tooltip: 'Insert/edit link',
		shortcut: 'Alt+Shift+A',
		cmd: 'WP_Link',

		onPostRender: function() {
			linkButton = this;

			editor.on( 'nodechange', function( event ) {
				setState( linkButton, event.element );
			});
		}
	});

	editor.addButton( 'unlink', {
		icon: 'unlink',
		tooltip: 'Remove link',
		cmd: 'unlink',

		onPostRender: function() {
			var unlinkButton = this;

			editor.on( 'nodechange', function( event ) {
				setState( unlinkButton, event.element );
			});
		}
	});

	editor.addMenuItem( 'link', {
		icon: 'link',
		text: 'Insert link',
		shortcut: 'Alt+Shift+A',
		cmd: 'WP_Link',
		stateSelector: 'a[href]',
		context: 'insert',
		prependToContext: true
	});
});

The same content is in 41 releases, WordPress 3.9.1-RC1 to 4.0-beta1. See them all, or every version of this file.