TinyMCE wpView:
- Cast off commands targeted to a view except undo, redo, RemoveFormat and mceToggleFormat (bold, italic, etc.). - Disable the link and unlink buttons when a view is selected. Props avryl, see #28595 Built from https://develop.svn.wordpress.org/trunk@29183 git-svn-id: http://core.svn.wordpress.org/trunk@28967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5f54195855
commit
c6afe2dd3e
|
@ -15,9 +15,10 @@ tinymce.PluginManager.add( 'wplink', function( editor ) {
|
|||
editor.addShortcut( 'ctrl+k', '', 'WP_Link' );
|
||||
|
||||
function setState( button, node ) {
|
||||
var parent = editor.dom.getParent( node, 'a' );
|
||||
var parent = editor.dom.getParent( node, 'a' ),
|
||||
getView = editor.plugins.wpview ? editor.plugins.wpview.getView : function() { return false; };
|
||||
|
||||
button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) );
|
||||
button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) || getView( node ) );
|
||||
button.active( parent && parent.href );
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
tinymce.PluginManager.add("wplink",function(a){function b(b,c){var d=a.dom.getParent(c,"a");b.disabled(a.selection.isCollapsed()&&!d||d&&!d.href),b.active(d&&d.href)}var c;a.addCommand("WP_Link",function(){c&&c.disabled()||"undefined"==typeof window.wpLink||window.wpLink.open(a.id)}),a.addShortcut("alt+shift+a","","WP_Link"),a.addShortcut("ctrl+k","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Alt+Shift+A",cmd:"WP_Link",onPostRender:function(){c=this,a.on("nodechange",function(a){b(c,a.element)})}}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",onPostRender:function(){var c=this;a.on("nodechange",function(a){b(c,a.element)})}}),a.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Alt+Shift+A",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0})});
|
||||
tinymce.PluginManager.add("wplink",function(a){function b(b,c){var d=a.dom.getParent(c,"a"),e=a.plugins.wpview?a.plugins.wpview.getView:function(){return!1};b.disabled(a.selection.isCollapsed()&&!d||d&&!d.href||e(c)),b.active(d&&d.href)}var c;a.addCommand("WP_Link",function(){c&&c.disabled()||"undefined"==typeof window.wpLink||window.wpLink.open(a.id)}),a.addShortcut("alt+shift+a","","WP_Link"),a.addShortcut("ctrl+k","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Alt+Shift+A",cmd:"WP_Link",onPostRender:function(){c=this,a.on("nodechange",function(a){b(c,a.element)})}}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",onPostRender:function(){var c=this;a.on("nodechange",function(a){b(c,a.element)})}}),a.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Alt+Shift+A",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0})});
|
|
@ -1,4 +1,5 @@
|
|||
/* global tinymce */
|
||||
|
||||
/**
|
||||
* WordPress View plugin.
|
||||
*/
|
||||
|
@ -21,7 +22,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
*/
|
||||
function getParent( node, className ) {
|
||||
while ( node && node.parentNode ) {
|
||||
if ( node.className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1 ) {
|
||||
if ( node.className && ( ' ' + node.className + ' ' ).indexOf( ' ' + className + ' ' ) !== -1 ) {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -563,7 +564,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
editor.dom.removeClass( editor.getBody(), 'has-focus' );
|
||||
} );
|
||||
|
||||
editor.on( 'nodechange', function( event ) {
|
||||
editor.on( 'NodeChange', function( event ) {
|
||||
var dom = editor.dom,
|
||||
views = editor.dom.select( '.wpview-wrap' ),
|
||||
className = event.element.className,
|
||||
|
@ -617,7 +618,20 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
}
|
||||
});
|
||||
|
||||
editor.on( 'resolvename', function( event ) {
|
||||
editor.on( 'BeforeExecCommand', function( event ) {
|
||||
var cmd = event.command,
|
||||
view;
|
||||
|
||||
if ( cmd === 'undo' || cmd === 'redo' || cmd === 'RemoveFormat' || cmd === 'mceToggleFormat' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( view = getView( editor.selection.getNode() ) ) {
|
||||
handleEnter( view );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
if ( editor.dom.hasClass( event.target, 'wpview-wrap' ) ) {
|
||||
event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'wpview';
|
||||
event.stopPropagation();
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.0-beta1-20140715';
|
||||
$wp_version = '4.0-beta1-20140716';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue