]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wpview/plugin.js
WordPress 3.9.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpview / plugin.js
index f357fffc80608a9a51bd2b65401ce077e24ed533..4e224b0683da03c61da8cdf7d86ecf29678b2ba2 100644 (file)
@@ -332,17 +332,24 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
                tinymce.each( dom.select( 'div[data-wpview-text]', event.node ), function( node ) {
                        // Empty the wrap node
                        if ( 'textContent' in node ) {
-                               node.textContent = '';
+                               node.textContent = '\u00a0';
                        } else {
-                               node.innerText = '';
+                               node.innerText = '\u00a0';
                        }
-
-                       // This makes all views into block tags (as we use <div>).
-                       // Can use 'PostProcess' and a regex instead.
-                       dom.replace( dom.create( 'p', null, window.decodeURIComponent( dom.getAttrib( node, 'data-wpview-text' ) ) ), node );
                });
     });
 
+    editor.on( 'PostProcess', function( event ) {
+               if ( event.content ) {
+                       event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g, function( match, shortcode ) {
+                               if ( shortcode ) {
+                                       return '<p>' + window.decodeURIComponent( shortcode ) + '</p>';
+                               }
+                               return ''; // If error, remove the view wrapper
+                       });
+               }
+       });
+
        editor.on( 'keydown', function( event ) {
                var keyCode = event.keyCode,
                        body = editor.getBody(),