Ticket #29838: 29838.2.diff
File 29838.2.diff, 8.5 KB (added by , 8 months ago) |
---|
-
src/js/_enqueues/admin/post.js
434 434 $previewField.val(''); 435 435 }); 436 436 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 456 437 // Auto save new posts after a title is typed. 457 438 if ( $( '#auto_draft' ).val() ) { 458 439 $( '#title' ).on( 'blur', function() { -
src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js
1074 1074 } 1075 1075 } ); 1076 1076 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 1077 1086 editor.on( 'nodechange', function( event ) { 1078 1087 var collapsed = editor.selection.isCollapsed(); 1079 1088 -
src/js/_enqueues/wp/editor/base.js
28 28 * 29 29 * @return {void} 30 30 */ 31 $$( document ).on( 'click ', function( event ) {31 $$( document ).on( 'click keydown', function( event ) { 32 32 var id, mode, 33 33 target = $$( event.target ); 34 34 … … 35 35 if ( target.hasClass( 'wp-switch-editor' ) ) { 36 36 id = target.attr( 'data-wp-editor-id' ); 37 37 mode = target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html'; 38 switchEditor( id, mode );38 switchEditor( id, mode, event ); 39 39 } 40 40 }); 41 41 } … … 70 70 * 71 71 * @param {string} id The id of the editor you want to change the editor mode for. Default: `content`. 72 72 * @param {string} mode The mode you want to switch to. Default: `toggle`. 73 * @param {Event} event DOM Event triggering the switch. 73 74 * @return {void} 74 75 */ 75 function switchEditor( id, mode ) {76 function switchEditor( id, mode, event ) { 76 77 id = id || 'content'; 77 78 mode = mode || 'toggle'; 78 79 … … 79 80 var editorHeight, toolbarHeight, iframe, 80 81 editor = tinymce.get( id ), 81 82 wrap = $$( '#wp-' + id + '-wrap' ), 83 htmlSwitch = wrap.find( '.switch-tmce' ), 84 tmceSwitch = wrap.find( '.switch-html' ), 82 85 $textarea = $$( '#' + id ), 83 86 textarea = $textarea[0]; 84 87 … … 90 93 } 91 94 } 92 95 96 var isKeyboardActivation = ( event.which === 13 || event.which === 32 ) ? true : false; 93 97 if ( 'tmce' === mode || 'tinymce' === mode ) { 94 98 // If the editor is visible we are already in `tinymce` mode. 95 99 if ( editor && ! editor.isHidden() ) { … … 103 107 104 108 editorHeight = parseInt( textarea.style.height, 10 ) || 0; 105 109 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. 110 if ( ! isKeyboardActivation ) { 116 111 addHTMLBookmarkInTextAreaContent( $textarea ); 117 112 } 118 113 … … 130 125 } 131 126 } 132 127 133 if ( editor.getParam( 'wp_keep_scroll_position' ) ) {134 // Restore the selection.128 // Restore the selection. 129 if ( ! isKeyboardActivation ) { 135 130 focusHTMLBookmarkInVisualEditor( editor ); 136 131 } 137 132 } else { … … 139 134 } 140 135 141 136 wrap.removeClass( 'html-active' ).addClass( 'tmce-active' ); 137 tmceSwitch.attr( 'aria-pressed', false ); 138 htmlSwitch.attr( 'aria-pressed', true ); 142 139 $textarea.attr( 'aria-hidden', true ); 143 140 window.setUserSetting( 'editor', 'tinymce' ); 144 141 … … 168 165 169 166 var selectionRange = null; 170 167 171 if ( editor.getParam( 'wp_keep_scroll_position' ) ) { 172 selectionRange = findBookmarkedPosition( editor ); 173 } 168 selectionRange = findBookmarkedPosition( editor ); 174 169 175 170 editor.hide(); 176 171 … … 184 179 } 185 180 186 181 wrap.removeClass( 'tmce-active' ).addClass( 'html-active' ); 182 tmceSwitch.attr( 'aria-pressed', true ); 183 htmlSwitch.attr( 'aria-pressed', false ); 187 184 $textarea.attr( 'aria-hidden', false ); 188 185 window.setUserSetting( 'editor', 'html' ); 189 186 } … … 520 517 * Focuses the selection markers in Visual mode. 521 518 * 522 519 * 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 520 * and create a selection between the two nodes using the DOM `createRange` selection API. 524 521 * 525 522 * If there is only a single node, select only the single node through TinyMCE's selection API 526 523 * … … 545 542 } 546 543 } 547 544 548 if ( editor.getParam( 'wp_keep_scroll_position' ) ) { 549 scrollVisualModeToStartElement( editor, startNode ); 550 } 545 scrollVisualModeToStartElement( editor, startNode ); 551 546 552 547 removeSelectionMarker( startNode ); 553 548 removeSelectionMarker( endNode ); -
src/wp-admin/edit-form-advanced.php
621 621 array( 622 622 '_content_editor_dfw' => $_content_editor_dfw, 623 623 'drag_drop_upload' => true, 624 'tabfocus_elements' => 'content-html,save-post',625 624 'editor_height' => 300, 626 625 'tinymce' => array( 627 626 'resize' => false, 628 627 'wp_autoresize_on' => $_wp_editor_expand, 629 628 'add_unload_trigger' => false, 630 'wp_keep_scroll_position' => ! $is_IE,631 629 ), 632 630 ) 633 631 ); -
src/wp-includes/class-wp-editor.php
188 188 if ( 'html' !== $default_editor ) { 189 189 $default_editor = 'tinymce'; 190 190 } 191 $tmce_active = ( 'html' === $default_editor ) ? ' aria-pressed="true"' : ''; 192 $html_active = ( 'html' === $default_editor ) ? '' : ' aria-pressed="true"'; 191 193 192 $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' .194 $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce"' . $html_active . ' class="wp-switch-editor switch-tmce"' . 193 195 ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n"; 194 $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' .196 $buttons .= '<button type="button" id="' . $editor_id_attr . '-html"' . $tmce_active . ' class="wp-switch-editor switch-html"' . 195 197 ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n"; 196 198 } else { 197 199 $default_editor = 'tinymce'; … … 1113 1115 'end_container_on_empty_block' => true, 1114 1116 'wpeditimage_html5_captions' => true, 1115 1117 'wp_lang_attr' => get_bloginfo( 'language' ), 1116 'wp_keep_scroll_position' => false,1117 1118 'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ), 1118 1119 ); 1119 1120 -
src/wp-includes/css/editor.css
1140 1140 color: #1d2327; 1141 1141 } 1142 1142 1143 .wp-switch-editor:active,1144 .html-active .switch-html:focus,1145 .tmce-active .switch-tmce:focus {1146 box-shadow: none;1147 }1148 1149 1143 .wp-switch-editor:active { 1150 1144 background-color: #f6f7f7; 1151 1145 box-shadow: none;