Changeset 26876 for trunk/src/wp-admin/js/editor.js
- Timestamp:
- 12/28/2013 11:52:04 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor.js
r26224 r26876 14 14 // mode can be 'html', 'tmce', or 'toggle'; 'html' is used for the 'Text' editor tab. 15 15 go: function( id, mode ) { 16 var t = this, ed, wrap_id, txtarea_el, 17 dom = tinymce.DOM;16 var t = this, ed, wrap_id, txtarea_el, editorHeight, toolbarHeight, 17 DOM = tinymce.DOM; //DOMUtils outside the editor iframe 18 18 19 19 id = id || 'content'; … … 22 22 ed = tinymce.get( id ); 23 23 wrap_id = 'wp-' + id + '-wrap'; 24 txtarea_el = dom.get( id );24 txtarea_el = DOM.get( id ); 25 25 26 26 if ( 'toggle' === mode ) { … … 32 32 } 33 33 34 function getToolbarHeight() { 35 var height; 36 37 try { 38 height = DOM.getSize( DOM.select( '.mce-toolbar-grp', ed.getContainer() )[0] ); 39 } catch(e){} 40 41 if ( height && height.h && height.h > 10 && height.h < 100 ) { 42 return height.h; 43 } 44 45 return 0; 46 } 47 34 48 if ( 'tmce' === mode || 'tinymce' === mode ) { 35 49 if ( ed && ! ed.isHidden() ) { … … 41 55 } 42 56 57 editorHeight = txtarea_el ? parseInt( txtarea_el.style.height, 10 ) : 0; 58 43 59 if ( tinyMCEPreInit.mceInit[ id ] && tinyMCEPreInit.mceInit[ id ].wpautop ) { 44 60 txtarea_el.value = t.wpautop( txtarea_el.value ); … … 47 63 if ( ed ) { 48 64 ed.show(); 65 66 if ( editorHeight && ( toolbarHeight = getToolbarHeight() ) ) { 67 editorHeight = editorHeight - toolbarHeight + 11; 68 69 // height cannot be under 50 or over 5000 70 if ( editorHeight > 50 && editorHeight < 5000 ) { 71 ed.theme.resizeTo( null, editorHeight ); 72 } 73 } 49 74 } else { 50 ed = new tinymce.Editor( id, tinyMCEPreInit.mceInit[ id ] ); 51 ed.render(); 52 } 53 54 dom.removeClass( wrap_id, 'html-active' ); 55 dom.addClass( wrap_id, 'tmce-active' ); 75 tinymce.init( tinyMCEPreInit.mceInit[id] ); 76 77 // ed = tinymce.createEditor( id, tinyMCEPreInit.mceInit[id] ); 78 // ed.render(); 79 } 80 81 DOM.removeClass( wrap_id, 'html-active' ); 82 DOM.addClass( wrap_id, 'tmce-active' ); 56 83 setUserSetting( 'editor', 'tinymce' ); 57 84 … … 63 90 64 91 if ( ed ) { 92 editorHeight = DOM.get( id + '_ifr' ); 93 editorHeight = editorHeight ? parseInt( editorHeight.style.height, 10 ) : 0; 94 95 if ( editorHeight && ( toolbarHeight = getToolbarHeight() ) ) { 96 editorHeight = editorHeight + toolbarHeight - 11; 97 98 // height cannot be under 50 or over 5000 99 if ( editorHeight > 50 && editorHeight < 5000 ) { 100 txtarea_el.style.height = editorHeight + 'px'; 101 } 102 } 103 65 104 ed.hide(); 66 105 } else { … … 70 109 } 71 110 72 dom.setStyles( txtarea_el, {'display': '', 'visibility': ''} );73 } 74 75 dom.removeClass( wrap_id, 'tmce-active' );76 dom.addClass( wrap_id, 'html-active' );111 DOM.setStyles( txtarea_el, {'display': '', 'visibility': ''} ); 112 } 113 114 DOM.removeClass( wrap_id, 'tmce-active' ); 115 DOM.addClass( wrap_id, 'html-active' ); 77 116 setUserSetting( 'editor', 'html' ); 78 117 } … … 89 128 preserve_linebreaks = true; 90 129 content = content.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) { 91 a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-temp-lb>' ); 92 return a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-temp-lb>' ); 130 a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' ); 131 a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' ); 132 return a.replace( /\r?\n/g, '<wp-line-break>' ); 93 133 }); 94 134 } … … 150 190 // put back the line breaks in pre|script 151 191 if ( preserve_linebreaks ) { 152 content = content.replace( /<wp- temp-lb>/g, '\n' );192 content = content.replace( /<wp-line-break>/g, '\n' ); 153 193 } 154 194 … … 182 222 preserve_linebreaks = true; 183 223 pee = pee.replace( /<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) { 184 return a.replace( /(\r\n|\n)/g, '<wp- temp-lb>' );224 return a.replace( /(\r\n|\n)/g, '<wp-line-break>' ); 185 225 }); 186 226 } … … 231 271 // put back the line breaks in pre|script 232 272 if ( preserve_linebreaks ) { 233 pee = pee.replace( /<wp- temp-lb>/g, '\n' );273 pee = pee.replace( /<wp-line-break>/g, '\n' ); 234 274 } 235 275
Note: See TracChangeset
for help on using the changeset viewer.