Editor: run autosave when pressing Ctrl or Command + S in the Text editor, same as the Visual editor.

Fixes #31655.
Built from https://develop.svn.wordpress.org/trunk@32680


git-svn-id: http://core.svn.wordpress.org/trunk@32650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-06-01 19:02:25 +00:00
parent 1c0419071f
commit 02f5020d52
3 changed files with 21 additions and 10 deletions

View File

@ -204,7 +204,7 @@ jQuery(document).ready( function($) {
var stamp, visibility, $submitButtons, updateVisibility, updateText,
sticky = '',
last = 0,
co = $('#content'),
$textarea = $('#content'),
$document = $(document),
$editSlugWrap = $('#edit-slug-box'),
postId = $('#post_ID').val() || 0,
@ -212,7 +212,8 @@ jQuery(document).ready( function($) {
releaseLock = true,
$postVisibilitySelect = $('#post-visibility-select'),
$timestampdiv = $('#timestampdiv'),
$postStatusSelect = $('#post-status-select');
$postStatusSelect = $('#post-status-select'),
isMac = window.navigator.platform ? window.navigator.platform.indexOf( 'Mac' ) !== -1 : false;
postboxes.add_postbox_toggles(pagenow);
@ -313,11 +314,10 @@ jQuery(document).ready( function($) {
// This code is meant to allow tabbing from Title to Post content.
$('#title').on( 'keydown.editor-focus', function( event ) {
var editor, $textarea;
var editor;
if ( event.keyCode === 9 && ! event.ctrlKey && ! event.altKey && ! event.shiftKey ) {
editor = typeof tinymce != 'undefined' && tinymce.get('content');
$textarea = $('#content');
if ( editor && ! editor.isHidden() ) {
editor.focus();
@ -790,16 +790,16 @@ jQuery(document).ready( function($) {
// word count
if ( typeof(wpWordCount) != 'undefined' ) {
$document.triggerHandler('wpcountwords', [ co.val() ]);
$document.triggerHandler('wpcountwords', [ $textarea.val() ]);
co.keyup( function(e) {
$textarea.keyup( function(e) {
var k = e.keyCode || e.charCode;
if ( k == last )
return true;
if ( 13 == k || 8 == last || 46 == last )
$document.triggerHandler('wpcountwords', [ co.val() ]);
$document.triggerHandler('wpcountwords', [ $textarea.val() ]);
last = k;
return true;
@ -835,7 +835,6 @@ jQuery(document).ready( function($) {
// Resize the visual and text editors
( function() {
var editor, offset, mce,
$textarea = $('textarea#content'),
$handle = $('#post-status-info'),
$postdivrich = $('#postdivrich');
@ -923,4 +922,16 @@ jQuery(document).ready( function($) {
}
});
}
// Save on pressing Ctrl/Command + S in the Text editor
$textarea.on( 'keydown.wp-autosave', function( event ) {
if ( event.which === 83 ) {
if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) {
return;
}
wp.autosave && wp.autosave.server.triggerSave();
event.preventDefault();
}
});
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32679';
$wp_version = '4.3-alpha-32680';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.