Make WordPress Core

Ticket #29838: 29838.patch

File 29838.patch, 5.1 KB (added by rcreators, 9 months ago)

@afercia 's patch updated to run for new wordpress. So can use to check for starting point and direction for next development.

  • src/js/_enqueues/admin/post.js

    diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js
    index 557465bb27..313dab3d27 100644
    a b jQuery( function($) { 
    434434                $previewField.val('');
    435435        });
    436436
    437         // This code is meant to allow tabbing from Title to Post content.
    438         $('#title').on( 'keydown.editor-focus', function( event ) {
    439                 var editor;
    440 
    441                 if ( event.keyCode === 9 && ! event.ctrlKey && ! event.altKey && ! event.shiftKey ) {
    442                         editor = typeof tinymce != 'undefined' && tinymce.get('content');
    443 
    444                         if ( editor && ! editor.isHidden() ) {
    445                                 editor.focus();
    446                         } else if ( $textarea.length ) {
    447                                 $textarea.trigger( 'focus' );
    448                         } else {
    449                                 return;
    450                         }
    451 
    452                         event.preventDefault();
    453                 }
    454         });
    455 
    456437        // Auto save new posts after a title is typed.
    457438        if ( $( '#auto_draft' ).val() ) {
    458439                $( '#title' ).on( 'blur', function() {
  • src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js

    diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js
    index 5aa0bb76f4..4f97c599bf 100644
    a b tinymce.PluginManager.add( 'wordpress', function( editor ) { 
    10741074                        }
    10751075                } );
    10761076
     1077                editor.on( 'keydown', function( event ) {
     1078+                       if ( event.keyCode === 9 && event.shiftKey ) {
     1079+                               var toolbar = editor.theme.panel.find( '.toolbar:not(.menubar)' )[0];
     1080+                               if ( toolbar ) {
     1081+                                       toolbar.focus( true );
     1082+                               }
     1083+                       }
     1084+               });
     1085
    10771086                editor.on( 'nodechange', function( event ) {
    10781087                        var collapsed = editor.selection.isCollapsed();
    10791088
  • src/js/_enqueues/wp/editor/base.js

    diff --git a/src/js/_enqueues/wp/editor/base.js b/src/js/_enqueues/wp/editor/base.js
    index 2465af3227..3e9289398d 100644
    a b window.wp = window.wp || {}; 
    103103
    104104                                editorHeight = parseInt( textarea.style.height, 10 ) || 0;
    105105
    106                                 var keepSelection = false;
    107                                 if ( editor ) {
    108                                         keepSelection = editor.getParam( 'wp_keep_scroll_position' );
    109                                 } else {
    110                                         keepSelection = window.tinyMCEPreInit.mceInit[ id ] &&
    111                                                                         window.tinyMCEPreInit.mceInit[ id ].wp_keep_scroll_position;
    112                                 }
    113 
    114                                 if ( keepSelection ) {
    115                                         // Save the selection.
    116                                         addHTMLBookmarkInTextAreaContent( $textarea );
    117                                 }
     106                                addHTMLBookmarkInTextAreaContent( $textarea );
    118107
    119108                                if ( editor ) {
    120109                                        editor.show();
    window.wp = window.wp || {}; 
    130119                                                }
    131120                                        }
    132121
    133                                         if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
    134                                                 // Restore the selection.
    135                                                 focusHTMLBookmarkInVisualEditor( editor );
    136                                         }
     122                                        // Restore the selection.
     123+                                       focusHTMLBookmarkInVisualEditor( editor );
    137124                                } else {
    138125                                        tinymce.init( window.tinyMCEPreInit.mceInit[ id ] );
    139126                                }
    window.wp = window.wp || {}; 
    168155
    169156                                        var selectionRange = null;
    170157
    171                                         if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
    172                                                 selectionRange = findBookmarkedPosition( editor );
    173                                         }
     158                                        selectionRange = findBookmarkedPosition( editor );
    174159
    175160                                        editor.hide();
    176161
    window.wp = window.wp || {}; 
    520505                 * Focuses the selection markers in Visual mode.
    521506                 *
    522507                 * The method checks for existing selection markers inside the editor DOM (Visual mode)
    523                  * and create a selection between the two nodes using the DOM `createRange` selection API
     508                 * and create a selection between the two nodes using the DOM `createRange` selection API.
    524509                 *
    525510                 * If there is only a single node, select only the single node through TinyMCE's selection API
    526511                 *
    window.wp = window.wp || {}; 
    545530                                }
    546531                        }
    547532
    548                         if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
    549                                 scrollVisualModeToStartElement( editor, startNode );
    550                         }
     533                        scrollVisualModeToStartElement( editor, startNode );
    551534
    552535                        removeSelectionMarker( startNode );
    553536                        removeSelectionMarker( endNode );
  • src/wp-admin/edit-form-advanced.php

    diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php
    index ce68a4097b..5c351bf03c 100644
    a b if ( post_type_supports( $post_type, 'editor' ) ) { 
    621621                array(
    622622                        '_content_editor_dfw' => $_content_editor_dfw,
    623623                        'drag_drop_upload'    => true,
    624                         'tabfocus_elements'   => 'content-html,save-post',
    625624                        'editor_height'       => 300,
    626625                        'tinymce'             => array(
    627626                                'resize'                  => false,
    628627                                'wp_autoresize_on'        => $_wp_editor_expand,
    629628                                'add_unload_trigger'      => false,
    630                                 'wp_keep_scroll_position' => ! $is_IE,
    631629                        ),
    632630                )
    633631        );
  • src/wp-includes/class-wp-editor.php

    diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php
    index 5d7ba224cc..3b20631898 100644
    a b final class _WP_Editors { 
    11131113                        'end_container_on_empty_block' => true,
    11141114                        'wpeditimage_html5_captions'   => true,
    11151115                        'wp_lang_attr'                 => get_bloginfo( 'language' ),
    1116                         'wp_keep_scroll_position'      => false,
    11171116                        'wp_shortcut_labels'           => wp_json_encode( $shortcut_labels ),
    11181117                );
    11191118