Ticket #29841: 29841.patch
File 29841.patch, 4.5 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/mce-view.js
17 17 mediaWindows = [], 18 18 windowIdx = 0, 19 19 waitInterval = 50, 20 viewOptions = ['encodedText']; 20 viewOptions = ['encodedText'], 21 oEmbedProviders = []; 21 22 22 23 // Create the `wp.mce` object if necessary. 23 24 wp.mce = wp.mce || {}; 24 25 26 // Convert PHP regex to JS regex. 27 _.each( window._wpMCEViewL10n.oEmbedProviders, function( provider, pattern ) { 28 var match = /^([^a-z0-9\\ ])?(.*)\1([a-z]*)$/.exec( pattern ); 29 30 if ( ! match ) { 31 return; 32 } 33 34 pattern = match[1] ? match[2].replace( new RegExp( '\\\\' + match[1], 'g' ), match[1] ) : match[2]; 35 pattern = pattern.replace( /\//g, '\\/' ); 36 pattern = new RegExp( pattern, 'i' ); 37 38 oEmbedProviders.push( pattern ); 39 } ); 40 25 41 /** 26 42 * wp.mce.View 27 43 * … … 111 127 setContent: function( html, option ) { 112 128 this.getNodes( function ( editor, node, content ) { 113 129 var el = ( option === 'wrap' || option === 'replace' ) ? node : content, 114 insert = html; 130 insert = html, 131 view = editor.plugins.wpview.getView( editor.selection.getNode() ), 132 p; 115 133 116 134 if ( _.isString( insert ) ) { 117 135 insert = editor.dom.createFragment( insert ); 118 136 } 119 137 120 138 if ( option === 'replace' ) { 121 editor.dom.replace( insert, el ); 139 p = editor.dom.create( 'p', null, insert ); 140 141 editor.dom.replace( p, el ); 142 143 if ( view ) { 144 editor.selection.select( p, true ); 145 editor.selection.collapse(); 146 } 122 147 } else { 123 148 el.innerHTML = ''; 124 149 el.appendChild( insert ); 150 151 if ( view ) { 152 editor.plugins.wpview.setViewCursor( false, view ); 153 } 125 154 } 126 155 } ); 127 156 }, … … 700 729 701 730 this.setError( this.error.message, 'admin-media' ); 702 731 } else { 703 this.setContent( '<p>' + this.original + '</p>', 'replace' );732 this.setContent( this.original, 'replace' ); 704 733 } 705 734 } else if ( this.error.statusText ) { 706 735 this.setError( this.error.statusText, 'admin-media' ); 707 736 } else if ( this.original ) { 708 this.setContent( '<p>' + this.original + '</p>', 'replace' );737 this.setContent( this.original, 'replace' ); 709 738 } 710 739 }, 711 740 … … 875 904 return; 876 905 } 877 906 878 return { 879 index: match.index, 880 content: match[0], 881 options: { 882 url: match[1] 883 } 884 }; 907 if ( _.some( oEmbedProviders, function( re ) { 908 return re.exec( match[1] ); 909 } ) ) { 910 return { 911 index: match.index, 912 content: match[0], 913 options: { 914 url: match[1] 915 } 916 }; 917 } 885 918 } 886 919 } ) ); 887 920 -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
162 162 toolbar = editor.$( viewNode ).find( '.toolbar' ), 163 163 editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0], 164 164 editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0; 165 165 166 166 if ( toolbar.length && editor.iframeElement ) { 167 167 // 48 = 43 for the toolbar + 5 buffer 168 168 delta = viewNode.getBoundingClientRect().top + editor.iframeElement.getBoundingClientRect().top - editorToolbarBottom - 48; … … 718 718 return { 719 719 getViewText: getViewText, 720 720 setViewText: setViewText, 721 getView: getView 721 getView: getView, 722 setViewCursor: setViewCursor 722 723 }; 723 724 }); -
src/wp-includes/script-loader.php
418 418 $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); 419 419 $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 ); 420 420 421 require_once ABSPATH . WPINC . '/class-oembed.php'; 422 423 did_action( 'init' ) && $scripts->localize( 'mce-view', '_wpMCEViewL10n', array( 424 'oEmbedProviders' => _wp_oembed_get_object()->providers 425 ) ); 426 421 427 if ( is_admin() ) { 422 428 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1 ); 423 429 did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array(