TinyMCE, inline link:

- Fix applying the changes when pressing the Enter key in Firefox. No longer inserts new paragraph in the editor.
- Fix empty check when getting text from the dialog.
- Always focus the URL field when opening the dialog.
- Add back the keydown events in the modal.

See #33301.
Built from https://develop.svn.wordpress.org/trunk@36743


git-svn-id: http://core.svn.wordpress.org/trunk@36710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-02-27 00:52:26 +00:00
parent f3afec6974
commit 1f4b40b9c3
6 changed files with 51 additions and 13 deletions

View File

@ -68,7 +68,13 @@
return tinymce.trim( this.getEl().firstChild.value );
},
getLinkText: function() {
return tinymce.trim( this.getEl().firstChild.nextSibling.value );
var text = this.getEl().firstChild.nextSibling.value;
if ( ! tinymce.trim( text ) ) {
return '';
}
return text.replace( /[\r\n\t ]+/g, ' ' );
},
reset: function() {
var urlInput = this.getEl().firstChild;
@ -144,12 +150,15 @@
], true );
editToolbar.on( 'show', function() {
var inputNode = editToolbar.find( 'toolbar' )[0];
if ( inputNode && ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
window.setTimeout( function() {
inputNode.focus( true );
});
var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0];
if ( element ) {
element.focus();
element.select();
}
} );
}
} );
@ -172,6 +181,8 @@
return;
}
editToolbar.tempHide = false;
if ( link ) {
editor.dom.setAttribs( link, { 'data-wplink-edit': true } );
} else {
@ -181,6 +192,8 @@
if ( tinymce.Env.ie ) {
editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
}
editor.nodeChanged();
}
} );
@ -227,12 +240,12 @@
inputInstance.reset();
removePlaceholders();
editor.focus();
if ( tinymce.isIE ) {
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
editor.windowManager.wplinkBookmark = null;
}
editToolbar.tempHide = false;
}
} );
@ -384,6 +397,7 @@
tinymce.$( input ).on( 'keydown', function( event ) {
if ( event.keyCode === 13 ) {
editor.execCommand( 'wp_link_apply' );
event.preventDefault();
}
} );
}

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,8 @@ var wpLink;
wpLink.setAutocomplete();
}
inputs.submit.click( function( event ) {
inputs.dialog.on( 'keydown', wpLink.keydown );
inputs.submit.on( 'click', function( event ) {
event.preventDefault();
wpLink.update();
});
@ -210,7 +211,7 @@ var wpLink;
// IE will show a flashing cursor over the dialog.
window.setTimeout( function() {
inputs.url.focus()[0].select();
}, 100 );
} );
}
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
@ -431,6 +432,29 @@ var wpLink;
editor.nodeChanged();
},
keydown: function( event ) {
var id;
// Escape key.
if ( 27 === event.keyCode ) {
wpLink.close();
event.stopImmediatePropagation();
// Tab key.
} else if ( 9 === event.keyCode ) {
id = event.target.id;
// wp-link-submit must always be the last focusable element in the dialog.
// following focusable elements will be skipped on keyboard navigation.
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
inputs.close.focus();
event.preventDefault();
} else if ( id === 'wp-link-close' && event.shiftKey ) {
inputs.submit.focus();
event.preventDefault();
}
}
},
setDefaultValues: function() {
var selection,
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta1-36742';
$wp_version = '4.5-beta1-36743';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.