Changeset 41646
- Timestamp:
- 09/29/2017 07:11:08 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/js/editor.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor.js
r41645 r41646 120 120 focusHTMLBookmarkInVisualEditor( editor ); 121 121 } else { 122 /** 123 * TinyMCE is still not loaded. In order to restore the selection 124 * when the editor loads, a `on('init')` event is added, that will 125 * do the restoration. 126 * 127 * To achieve that, the initialization config is cloned and extended 128 * to include the `setup` method, which makes it possible to add the 129 * `on('init')` event. 130 * 131 * Cloning is used to prevent modification of the original init config, 132 * which may cause unwanted side effects. 133 */ 134 var tinyMCEConfig = $.extend( 135 {}, 136 window.tinyMCEPreInit.mceInit[ id ], 137 { 138 setup: function( editor ) { 139 editor.on( 'init', function( event ) { 140 focusHTMLBookmarkInVisualEditor( event.target ); 141 }); 142 } 143 } 144 ); 145 146 tinymce.init( tinyMCEConfig ); 122 tinymce.init( window.tinyMCEPreInit.mceInit[ id ] ); 147 123 } 148 124 … … 727 703 editor.$( startNode ).before( startElement[0] ); 728 704 editor.$( startNode ).after( endElement[0] ); 729 } 730 else { 705 } else { 731 706 boundaryRange.collapse( false ); 732 707 boundaryRange.insertNode( endElement[0] ); … … 838 813 textArea.setSelectionRange( start, end ); 839 814 } 815 816 // Restore the selection when the editor is initialized. Needed when the Text editor is the default. 817 $( document ).on( 'tinymce-editor-init.keep-scroll-position', function( event, editor ) { 818 if ( editor.$( '.mce_SELRES_start' ).length ) { 819 focusHTMLBookmarkInVisualEditor( editor ); 820 } 821 } ); 840 822 841 823 /**
Note: See TracChangeset
for help on using the changeset viewer.