From 912ffccdf6e8f884f6af2babae32ca47ee6463f2 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 12 Oct 2014 18:13:20 +0000 Subject: [PATCH] TinyMCE: fix the 'wpgallery' plugin to use a placeholder for galleries when either the 'wpview' plugin or wp.mce is not loaded. Fixes #28756 Built from https://develop.svn.wordpress.org/trunk@29883 git-svn-id: http://core.svn.wordpress.org/trunk@29639 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/wpgallery/plugin.js | 20 +----------------- .../tinymce/plugins/wpgallery/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 134684 -> 134688 bytes 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wpgallery/plugin.js b/wp-includes/js/tinymce/plugins/wpgallery/plugin.js index 7f82e3575f..41dcfe5789 100644 --- a/wp-includes/js/tinymce/plugins/wpgallery/plugin.js +++ b/wp-includes/js/tinymce/plugins/wpgallery/plugin.js @@ -61,25 +61,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { editor.addCommand( 'WP_Gallery', function() { editMedia( editor.selection.getNode() ); }); -/* - editor.on( 'init', function( e ) { - // _createButtons() - // iOS6 doesn't show the buttons properly on click, show them on 'touchstart' - if ( 'ontouchstart' in window ) { - editor.dom.events.bind( editor.getBody(), 'touchstart', function( e ) { - var target = e.target; - - if ( target.nodeName == 'IMG' && editor.dom.hasClass( target, 'wp-gallery' ) ) { - editor.selection.select( target ); - editor.dom.events.cancel( e ); - editor.plugins.wordpress._hideButtons(); - editor.plugins.wordpress._showButtons( target, 'wp_gallerybtns' ); - } - }); - } - }); -*/ editor.on( 'mouseup', function( event ) { var dom = editor.dom, node = event.target; @@ -117,7 +99,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { editor.on( 'BeforeSetContent', function( event ) { // 'wpview' handles the gallery shortcode when present - if ( ! editor.plugins.wpview ) { + if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) { event.content = replaceGalleryShortcodes( event.content ); } }); diff --git a/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js b/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js index dc6288ac2a..1231ac6cc1 100644 --- a/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js @@ -1 +1 @@ -tinymce.PluginManager.add("wpgallery",function(a){function b(a){return a.replace(/\[gallery([^\]]*)\]/g,function(a){return c("wp-gallery",a)})}function c(a,b){return b=window.encodeURIComponent(b),''}function d(a){function b(a,b){return b=new RegExp(b+'="([^"]+)"').exec(a),b?window.decodeURIComponent(b[1]):""}return a.replace(/(?:]+)?>)*(]+>)(?:<\/p>)*/g,function(a,c){var d=b(c,"data-wp-media");return d?"

"+d+"

":a})}function e(b){var c,d,e;"IMG"===b.nodeName&&"undefined"!=typeof wp&&wp.media&&(e=window.decodeURIComponent(a.dom.getAttrib(b,"data-wp-media")),a.dom.hasClass(b,"wp-gallery")&&wp.media.gallery&&(c=wp.media.gallery,d=c.edit(e),d.state("gallery-edit").on("update",function(e){var f=c.shortcode(e).string();a.dom.setAttrib(b,"data-wp-media",window.encodeURIComponent(f)),d.detach()})))}a.addCommand("WP_Gallery",function(){e(a.selection.getNode())}),a.on("mouseup",function(b){function c(){d.removeClass(d.select("img.wp-media-selected"),"wp-media-selected")}var d=a.dom,f=b.target;"IMG"===f.nodeName&&d.getAttrib(f,"data-wp-media")?2!==b.button&&(d.hasClass(f,"wp-media-selected")?e(f):(c(),d.addClass(f,"wp-media-selected"))):c()}),a.on("ResolveName",function(b){var c=a.dom,d=b.target;"IMG"===d.nodeName&&c.getAttrib(d,"data-wp-media")&&c.hasClass(d,"wp-gallery")&&(b.name="gallery")}),a.on("BeforeSetContent",function(c){a.plugins.wpview||(c.content=b(c.content))}),a.on("PostProcess",function(a){a.get&&(a.content=d(a.content))})}); \ No newline at end of file +tinymce.PluginManager.add("wpgallery",function(a){function b(a){return a.replace(/\[gallery([^\]]*)\]/g,function(a){return c("wp-gallery",a)})}function c(a,b){return b=window.encodeURIComponent(b),''}function d(a){function b(a,b){return b=new RegExp(b+'="([^"]+)"').exec(a),b?window.decodeURIComponent(b[1]):""}return a.replace(/(?:]+)?>)*(]+>)(?:<\/p>)*/g,function(a,c){var d=b(c,"data-wp-media");return d?"

"+d+"

":a})}function e(b){var c,d,e;"IMG"===b.nodeName&&"undefined"!=typeof wp&&wp.media&&(e=window.decodeURIComponent(a.dom.getAttrib(b,"data-wp-media")),a.dom.hasClass(b,"wp-gallery")&&wp.media.gallery&&(c=wp.media.gallery,d=c.edit(e),d.state("gallery-edit").on("update",function(e){var f=c.shortcode(e).string();a.dom.setAttrib(b,"data-wp-media",window.encodeURIComponent(f)),d.detach()})))}a.addCommand("WP_Gallery",function(){e(a.selection.getNode())}),a.on("mouseup",function(b){function c(){d.removeClass(d.select("img.wp-media-selected"),"wp-media-selected")}var d=a.dom,f=b.target;"IMG"===f.nodeName&&d.getAttrib(f,"data-wp-media")?2!==b.button&&(d.hasClass(f,"wp-media-selected")?e(f):(c(),d.addClass(f,"wp-media-selected"))):c()}),a.on("ResolveName",function(b){var c=a.dom,d=b.target;"IMG"===d.nodeName&&c.getAttrib(d,"data-wp-media")&&c.hasClass(d,"wp-gallery")&&(b.name="gallery")}),a.on("BeforeSetContent",function(c){a.plugins.wpview&&"undefined"!=typeof wp&&wp.mce||(c.content=b(c.content))}),a.on("PostProcess",function(a){a.get&&(a.content=d(a.content))})}); \ No newline at end of file diff --git a/wp-includes/js/tinymce/wp-tinymce.js.gz b/wp-includes/js/tinymce/wp-tinymce.js.gz index 4b595fa81726dbdc87792979a86deaa1082df7b9..0f7d749d2eb96dadf1efe4671d3b10afed56bb64 100644 GIT binary patch delta 2187 zcmV;62z2+HoCu(t2!MnEv;tuSfB)|7m!ow*R}8TF|6xgf3iW^ZfCvZZnQ)&|i-Kvk z#x;mEow|wF%*oM#a9QSPC3b;G7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