From 156df528519e7e928d6e0119b89ef51b8adc0664 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 1 Jun 2015 17:37:14 +0000 Subject: [PATCH] Editor: - Remove the old DFW. - Add back-compat stub for wp-fullscreen.js. - Keep wp_ajax_wp_fullscreen_save_post() for now. See #30949. git-svn-id: https://develop.svn.wordpress.org/trunk@32677 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/admin-ajax.php | 5 +- src/wp-admin/css/edit.css | 24 - src/wp-admin/css/ie.css | 13 - src/wp-admin/css/l10n.css | 7 - src/wp-admin/includes/ajax-actions.php | 1 + src/wp-admin/js/wp-fullscreen-stub.js | 39 + src/wp-admin/js/wp-fullscreen.js | 704 ------------------ src/wp-includes/class-wp-editor.php | 125 +--- src/wp-includes/css/editor.css | 509 +------------ src/wp-includes/css/media-views.css | 14 - .../js/media/views/uploader/editor.js | 6 +- src/wp-includes/js/quicktags.js | 17 - .../js/tinymce/plugins/wpfullscreen/plugin.js | 76 -- .../js/tinymce/skins/wordpress/wp-content.css | 11 - src/wp-includes/script-loader.php | 5 +- 15 files changed, 61 insertions(+), 1495 deletions(-) create mode 100644 src/wp-admin/js/wp-fullscreen-stub.js delete mode 100644 src/wp-admin/js/wp-fullscreen.js delete mode 100644 src/wp-includes/js/tinymce/plugins/wpfullscreen/plugin.js diff --git a/src/wp-admin/admin-ajax.php b/src/wp-admin/admin-ajax.php index 752da778f0..7b2d5d6af1 100644 --- a/src/wp-admin/admin-ajax.php +++ b/src/wp-admin/admin-ajax.php @@ -56,7 +56,7 @@ $core_actions_post = array( 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax', 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink', 'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order', - 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', + 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', @@ -65,6 +65,9 @@ $core_actions_post = array( 'press-this-add-category', ); +// Deprecated +$core_actions_post[] = 'wp-fullscreen-save-post'; + // Register core Ajax calls. if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) ) add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 ); diff --git a/src/wp-admin/css/edit.css b/src/wp-admin/css/edit.css index 55b4184a57..054c5f2e62 100644 --- a/src/wp-admin/css/edit.css +++ b/src/wp-admin/css/edit.css @@ -70,12 +70,6 @@ padding: 11px 10px; } -#wp-fullscreen-save .fs-saved { - color: #999; - float: right; - margin-top: 4px; -} - #poststuff .inside-submitbox, #side-sortables .inside-submitbox { margin: 0 3px; @@ -390,24 +384,6 @@ td.plugin-title p { border: 1px solid transparent; } -.wp-fullscreen-wrap #content-textarea-clone { - display: none; -} - -/* editor-expand.js override */ -.wp-fullscreen-wrap { - padding-top: 0 !important; -} - -.wp-fullscreen-wrap .wp-editor-area { - margin-top: 0 !important; -} - -.wp-fullscreen-wrap .mce-edit-area { - padding-top: 0 !important; -} -/* end editor-expand.js override */ - .wp-editor-expand #wp-content-editor-tools { z-index: 1000; border-bottom: 1px solid #e5e5e5; diff --git a/src/wp-admin/css/ie.css b/src/wp-admin/css/ie.css index 6dfbc956b4..864bed5d81 100644 --- a/src/wp-admin/css/ie.css +++ b/src/wp-admin/css/ie.css @@ -50,19 +50,6 @@ width: 35%; } -.wp-fullscreen-title { - width: 97%; -} - -#wp_mce_fullscreen_ifr { - background-color: #f9f9f9; -} - -#wp-fullscreen-tagline { - color: #82878c; - font-size: 14px; -} - #adminmenuback { left: 0; background-image: none; diff --git a/src/wp-admin/css/l10n.css b/src/wp-admin/css/l10n.css index 75c8d745ae..ea8dc199fb 100644 --- a/src/wp-admin/css/l10n.css +++ b/src/wp-admin/css/l10n.css @@ -54,13 +54,6 @@ body.locale-he-il .press-this a.wp-switch-editor { /* zn_CH: Enlarge font size, set font-size: normal */ .locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; } -/* Zn_CH: Distraction-free writing. - * More beautiful font for "Just write." - * Larger text for HTML/Visual mode. - */ -.locale-zh-cn #wp-fullscreen-tagline { font-family: KaiTi, "楷体", sans-serif; } -.locale-zh-cn #wp-fullscreen-modes a { font-size: 12px; } - /* zh_CN: Enlarge font-size. */ .locale-zh-cn #sort-buttons { font-size: 1em !important; } diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index a672733cdf..56d58c8515 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -2102,6 +2102,7 @@ function wp_ajax_time_format() { * Ajax handler for saving posts from the fullscreen editor. * * @since 3.1.0 + * @deprecated 4.3.0 */ function wp_ajax_wp_fullscreen_save_post() { $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; diff --git a/src/wp-admin/js/wp-fullscreen-stub.js b/src/wp-admin/js/wp-fullscreen-stub.js new file mode 100644 index 0000000000..c31c7eec99 --- /dev/null +++ b/src/wp-admin/js/wp-fullscreen-stub.js @@ -0,0 +1,39 @@ +/** + * Distraction-Free Writing (wp-fullscreen) backwards compatibility stub. + * Todo: remove at the end of 2016. + * + * Original was deprecated in 4.1, removed in 4.3. + */ +( function() { + var noop = function(){}; + + window.wp = window.wp || {}; + window.wp.editor = window.wp.editor || {}; + window.wp.editor.fullscreen = { + bind_resize: noop, + dfwWidth: noop, + off: noop, + on: noop, + refreshButtons: noop, + resizeTextarea: noop, + save: noop, + switchmode: noop, + toggleUI: noop, + + settings: {}, + pubsub: { + publish: noop, + subscribe: noop, + unsubscribe: noop, + topics: {} + }, + fade: { + In: noop, + Out: noop + }, + ui: { + fade: noop, + init: noop + } + }; +}()); diff --git a/src/wp-admin/js/wp-fullscreen.js b/src/wp-admin/js/wp-fullscreen.js deleted file mode 100644 index cb8c8e0156..0000000000 --- a/src/wp-admin/js/wp-fullscreen.js +++ /dev/null @@ -1,704 +0,0 @@ -/* global deleteUserSetting, setUserSetting, switchEditors, tinymce, tinyMCEPreInit */ -/** - * Distraction-Free Writing - * (wp-fullscreen) - * - * Access the API globally using the window.wp.editor.fullscreen variable. - */ -( function( $, window ) { - var api, ps, s, toggleUI, uiTimer, PubSub, - uiScrollTop = 0, - transitionend = 'transitionend webkitTransitionEnd', - $body = $( document.body ), - $document = $( document ); - - /** - * PubSub - * - * A lightweight publish/subscribe implementation. - * - * @access private - */ - PubSub = function() { - this.topics = {}; - - this.subscribe = function( topic, callback ) { - if ( ! this.topics[ topic ] ) - this.topics[ topic ] = []; - - this.topics[ topic ].push( callback ); - return callback; - }; - - this.unsubscribe = function( topic, callback ) { - var i, l, - topics = this.topics[ topic ]; - - if ( ! topics ) - return callback || []; - - // Clear matching callbacks - if ( callback ) { - for ( i = 0, l = topics.length; i < l; i++ ) { - if ( callback == topics[i] ) - topics.splice( i, 1 ); - } - return callback; - - // Clear all callbacks - } else { - this.topics[ topic ] = []; - return topics; - } - }; - - this.publish = function( topic, args ) { - var i, l, broken, - topics = this.topics[ topic ]; - - if ( ! topics ) - return; - - args = args || []; - - for ( i = 0, l = topics.length; i < l; i++ ) { - broken = ( topics[i].apply( null, args ) === false || broken ); - } - return ! broken; - }; - }; - - // Initialize the fullscreen/api object - api = {}; - - // Create the PubSub (publish/subscribe) interface. - ps = api.pubsub = new PubSub(); - - s = api.settings = { // Settings - visible: false, - mode: 'tinymce', - id: '', - title_id: '', - timer: 0, - toolbar_shown: false - }; - - function _hideUI() { - $body.removeClass('wp-dfw-show-ui'); - } - - /** - * toggleUI - * - * Toggle the CSS class to show/hide the toolbar, borders and statusbar. - */ - toggleUI = api.toggleUI = function( show ) { - clearTimeout( uiTimer ); - - if ( ! $body.hasClass('wp-dfw-show-ui') || show === 'show' ) { - $body.addClass('wp-dfw-show-ui'); - } else if ( show !== 'autohide' ) { - $body.removeClass('wp-dfw-show-ui'); - } - - if ( show === 'autohide' ) { - uiTimer = setTimeout( _hideUI, 2000 ); - } - }; - - function resetCssPosition( add ) { - s.$dfwWrap.parents().each( function( i, parent ) { - var cssPosition, $parent = $(parent); - - if ( add ) { - if ( parent.style.position ) { - $parent.data( 'wp-dfw-css-position', parent.style.position ); - } - - $parent.css( 'position', 'static' ); - } else { - cssPosition = $parent.data( 'wp-dfw-css-position' ); - cssPosition = cssPosition || ''; - $parent.css( 'position', cssPosition ); - } - - if ( parent.nodeName === 'BODY' ) { - return false; - } - }); - } - - /** - * on() - * - * Turns fullscreen on. - * - * @param string mode Optional. Switch to the given mode before opening. - */ - api.on = function() { - var id, $dfwWrap, titleId; - - if ( s.visible ) { - return; - } - - if ( ! s.$fullscreenFader ) { - api.ui.init(); - } - - // Settings can be added or changed by defining "wp_fullscreen_settings" JS object. - if ( typeof window.wp_fullscreen_settings === 'object' ) - $.extend( s, window.wp_fullscreen_settings ); - - id = s.id || window.wpActiveEditor; - - if ( ! id ) { - if ( s.hasTinymce ) { - id = tinymce.activeEditor.id; - } else { - return; - } - } - - s.id = id; - $dfwWrap = s.$dfwWrap = $( '#wp-' + id + '-wrap' ); - - if ( ! $dfwWrap.length ) { - return; - } - - s.$dfwTextarea = $( '#' + id ); - s.$editorContainer = $dfwWrap.find( '.wp-editor-container' ); - uiScrollTop = $document.scrollTop(); - - if ( s.hasTinymce ) { - s.editor = tinymce.get( id ); - } - - if ( s.editor && ! s.editor.isHidden() ) { - s.origHeight = $( '#' + id + '_ifr' ).height(); - s.mode = 'tinymce'; - } else { - s.origHeight = s.$dfwTextarea.height(); - s.mode = 'html'; - } - - // Try to find title field - if ( typeof window.adminpage !== 'undefined' && - ( window.adminpage === 'post-php' || window.adminpage === 'post-new-php' ) ) { - - titleId = 'title'; - } else { - titleId = id + '-title'; - } - - s.$dfwTitle = $( '#' + titleId ); - - if ( ! s.$dfwTitle.length ) { - s.$dfwTitle = null; - } - - api.ui.fade( 'show', 'showing', 'shown' ); - }; - - /** - * off() - * - * Turns fullscreen off. - */ - api.off = function() { - if ( ! s.visible ) - return; - - api.ui.fade( 'hide', 'hiding', 'hidden' ); - }; - - /** - * switchmode() - * - * @return string - The current mode. - * - * @param string to - The fullscreen mode to switch to. - * @event switchMode - * @eventparam string to - The new mode. - * @eventparam string from - The old mode. - */ - api.switchmode = function( to ) { - var from = s.mode; - - if ( ! to || ! s.visible || ! s.hasTinymce || typeof switchEditors === 'undefined' ) { - return from; - } - - // Don't switch if the mode is the same. - if ( from == to ) - return from; - - if ( to === 'tinymce' && ! s.editor ) { - s.editor = tinymce.get( s.id ); - - if ( ! s.editor && typeof tinyMCEPreInit !== 'undefined' && - tinyMCEPreInit.mceInit && tinyMCEPreInit.mceInit[ s.id ] ) { - - // If the TinyMCE instance hasn't been created, set the "wp_fulscreen" flag on creating it - tinyMCEPreInit.mceInit[ s.id ].wp_fullscreen = true; - } - } - - s.mode = to; - switchEditors.go( s.id, to ); - api.refreshButtons( true ); - - if ( to === 'html' ) { - setTimeout( api.resizeTextarea, 200 ); - } - - return to; - }; - - /** - * General - */ - - api.save = function() { - var $hidden = $('#hiddenaction'), - oldVal = $hidden.val(), - $spinner = $('#wp-fullscreen-save .spinner'), - $saveMessage = $('#wp-fullscreen-save .wp-fullscreen-saved-message'), - $errorMessage = $('#wp-fullscreen-save .wp-fullscreen-error-message'); - - $spinner.addClass( 'is-active' ); - $errorMessage.hide(); - $saveMessage.hide(); - $hidden.val('wp-fullscreen-save-post'); - - if ( s.editor && ! s.editor.isHidden() ) { - s.editor.save(); - } - - $.ajax({ - url: window.ajaxurl, - type: 'post', - data: $('form#post').serialize(), - dataType: 'json' - }).done( function( response ) { - $spinner.removeClass( 'is-active' ); - - if ( response && response.success ) { - $saveMessage.show(); - - setTimeout( function() { - $saveMessage.fadeOut(300); - }, 3000 ); - - if ( response.data && response.data.last_edited ) { - $('#wp-fullscreen-save input').attr( 'title', response.data.last_edited ); - } - } else { - $errorMessage.show(); - } - }).fail( function() { - $spinner.removeClass( 'is-active' ); - $errorMessage.show(); - }); - - $hidden.val( oldVal ); - }; - - api.dfwWidth = function( pixels, total ) { - var width; - - if ( pixels && pixels.toString().indexOf('%') !== -1 ) { - s.$editorContainer.css( 'width', pixels ); - s.$statusbar.css( 'width', pixels ); - - if ( s.$dfwTitle ) { - s.$dfwTitle.css( 'width', pixels ); - } - return; - } - - if ( ! pixels ) { - // Reset to theme width - width = $('#wp-fullscreen-body').data('theme-width') || 800; - s.$editorContainer.width( width ); - s.$statusbar.width( width ); - - if ( s.$dfwTitle ) { - s.$dfwTitle.width( width - 16 ); - } - - deleteUserSetting('dfw_width'); - return; - } - - if ( total ) { - width = pixels; - } else { - width = s.$editorContainer.width(); - width += pixels; - } - - if ( width < 200 || width > 1200 ) { - // sanity check - return; - } - - s.$editorContainer.width( width ); - s.$statusbar.width( width ); - - if ( s.$dfwTitle ) { - s.$dfwTitle.width( width - 16 ); - } - - setUserSetting( 'dfw_width', width ); - }; - - // This event occurs before the overlay blocks the UI. - ps.subscribe( 'show', function() { - var title = $('#last-edit').text(); - - if ( title ) { - $('#wp-fullscreen-save input').attr( 'title', title ); - } - }); - - // This event occurs while the overlay blocks the UI. - ps.subscribe( 'showing', function() { - $body.addClass( 'wp-fullscreen-active' ); - s.$dfwWrap.addClass( 'wp-fullscreen-wrap' ); - - if ( s.$dfwTitle ) { - s.$dfwTitle.after( '' ); - s.$dfwWrap.prepend( s.$dfwTitle.addClass('wp-fullscreen-title') ); - } - - api.refreshButtons(); - resetCssPosition( true ); - $('#wpadminbar').hide(); - - // Show the UI for 2 sec. when opening - toggleUI('autohide'); - - api.bind_resize(); - - if ( s.editor ) { - s.editor.execCommand( 'wpFullScreenOn' ); - } - - if ( 'ontouchstart' in window ) { - api.dfwWidth( '90%' ); - } else { - api.dfwWidth( $( '#wp-fullscreen-body' ).data('dfw-width') || 800, true ); - } - - // scroll to top so the user is not disoriented - scrollTo(0, 0); - }); - - // This event occurs after the overlay unblocks the UI - ps.subscribe( 'shown', function() { - s.visible = true; - - if ( s.editor && ! s.editor.isHidden() ) { - s.editor.execCommand( 'wpAutoResize' ); - } else { - api.resizeTextarea( 'force' ); - } - }); - - ps.subscribe( 'hide', function() { // This event occurs before the overlay blocks DFW. - $document.unbind( '.fullscreen' ); - s.$dfwTextarea.unbind('.wp-dfw-resize'); - }); - - ps.subscribe( 'hiding', function() { // This event occurs while the overlay blocks the DFW UI. - $body.removeClass( 'wp-fullscreen-active' ); - - if ( s.$dfwTitle ) { - $( '#wp-fullscreen-title-placeholder' ).before( s.$dfwTitle.removeClass('wp-fullscreen-title').css( 'width', '' ) ).remove(); - } - - s.$dfwWrap.removeClass( 'wp-fullscreen-wrap' ); - s.$editorContainer.css( 'width', '' ); - s.$dfwTextarea.add( '#' + s.id + '_ifr' ).height( s.origHeight ); - - if ( s.editor ) { - s.editor.execCommand( 'wpFullScreenOff' ); - } - - resetCssPosition( false ); - - window.scrollTo( 0, uiScrollTop ); - $('#wpadminbar').show(); - }); - - // This event occurs after DFW is removed. - ps.subscribe( 'hidden', function() { - s.visible = false; - }); - - api.refreshButtons = function( fade ) { - if ( s.mode === 'html' ) { - $('#wp-fullscreen-mode-bar').removeClass('wp-tmce-mode').addClass('wp-html-mode') - .find('a').removeClass( 'active' ).filter('.wp-fullscreen-mode-html').addClass( 'active' ); - - if ( fade ) { - $('#wp-fullscreen-button-bar').fadeOut( 150, function(){ - $(this).addClass('wp-html-mode').fadeIn( 150 ); - }); - } else { - $('#wp-fullscreen-button-bar').addClass('wp-html-mode'); - } - } else if ( s.mode === 'tinymce' ) { - $('#wp-fullscreen-mode-bar').removeClass('wp-html-mode').addClass('wp-tmce-mode') - .find('a').removeClass( 'active' ).filter('.wp-fullscreen-mode-tinymce').addClass( 'active' ); - - if ( fade ) { - $('#wp-fullscreen-button-bar').fadeOut( 150, function(){ - $(this).removeClass('wp-html-mode').fadeIn( 150 ); - }); - } else { - $('#wp-fullscreen-button-bar').removeClass('wp-html-mode'); - } - } - }; - - /** - * UI Elements - * - * Used for transitioning between states. - */ - api.ui = { - init: function() { - var toolbar; - - s.toolbar = toolbar = $('#fullscreen-topbar'); - s.$fullscreenFader = $('#fullscreen-fader'); - s.$statusbar = $('#wp-fullscreen-status'); - s.hasTinymce = typeof tinymce !== 'undefined'; - - if ( ! s.hasTinymce ) - $('#wp-fullscreen-mode-bar').hide(); - - $document.keyup( function(e) { - var c = e.keyCode || e.charCode, modKey; - - if ( ! s.visible ) { - return; - } - - if ( navigator.platform && navigator.platform.indexOf('Mac') !== -1 ) { - modKey = e.ctrlKey; // Ctrl key for Mac - } else { - modKey = e.altKey; // Alt key for Win & Linux - } - - if ( modKey && ( 61 === c || 107 === c || 187 === c ) ) { // + - api.dfwWidth( 25 ); - e.preventDefault(); - } - - if ( modKey && ( 45 === c || 109 === c || 189 === c ) ) { // - - api.dfwWidth( -25 ); - e.preventDefault(); - } - - if ( modKey && 48 === c ) { // 0 - api.dfwWidth( 0 ); - e.preventDefault(); - } - }); - - $( window ).on( 'keydown.wp-fullscreen', function( event ) { - // Turn fullscreen off when Esc is pressed. - if ( 27 === event.keyCode && s.visible ) { - api.off(); - event.stopImmediatePropagation(); - } - }); - - if ( 'ontouchstart' in window ) { - $body.addClass('wp-dfw-touch'); - } - - toolbar.on( 'mouseenter', function() { - toggleUI('show'); - }).on( 'mouseleave', function() { - toggleUI('autohide'); - }); - - // Bind buttons - $('#wp-fullscreen-buttons').on( 'click.wp-fullscreen', 'button', function( event ) { - var command = event.currentTarget.id ? event.currentTarget.id.substr(6) : null; - - if ( s.editor && 'tinymce' === s.mode ) { - switch( command ) { - case 'bold': - s.editor.execCommand('Bold'); - break; - case 'italic': - s.editor.execCommand('Italic'); - break; - case 'bullist': - s.editor.execCommand('InsertUnorderedList'); - break; - case 'numlist': - s.editor.execCommand('InsertOrderedList'); - break; - case 'link': - s.editor.execCommand('WP_Link'); - break; - case 'unlink': - s.editor.execCommand('unlink'); - break; - case 'help': - s.editor.execCommand('WP_Help'); - break; - case 'blockquote': - s.editor.execCommand('mceBlockQuote'); - break; - } - } else if ( command === 'link' && window.wpLink ) { - window.wpLink.open(); - } - - if ( command === 'wp-media-library' && typeof wp !== 'undefined' && wp.media && wp.media.editor ) { - wp.media.editor.open( s.id ); - } - }); - }, - - fade: function( before, during, after ) { - if ( ! s.$fullscreenFader ) { - api.ui.init(); - } - - // If any callback bound to before returns false, bail. - if ( before && ! ps.publish( before ) ) { - return; - } - - api.fade.In( s.$fullscreenFader, 200, function() { - if ( during ) { - ps.publish( during ); - } - - api.fade.Out( s.$fullscreenFader, 200, function() { - if ( after ) { - ps.publish( after ); - } - }); - }); - } - }; - - api.fade = { - // Sensitivity to allow browsers to render the blank element before animating. - sensitivity: 100, - - In: function( element, speed, callback, stop ) { - - callback = callback || $.noop; - speed = speed || 400; - stop = stop || false; - - if ( api.fade.transitions ) { - if ( element.is(':visible') ) { - element.addClass( 'fade-trigger' ); - return element; - } - - element.show(); - element.first().one( transitionend, function() { - callback(); - }); - - setTimeout( function() { element.addClass( 'fade-trigger' ); }, this.sensitivity ); - } else { - if ( stop ) { - element.stop(); - } - - element.css( 'opacity', 1 ); - element.first().fadeIn( speed, callback ); - - if ( element.length > 1 ) { - element.not(':first').fadeIn( speed ); - } - } - - return element; - }, - - Out: function( element, speed, callback, stop ) { - - callback = callback || $.noop; - speed = speed || 400; - stop = stop || false; - - if ( ! element.is(':visible') ) { - return element; - } - - if ( api.fade.transitions ) { - element.first().one( transitionend, function() { - if ( element.hasClass('fade-trigger') ) { - return; - } - - element.hide(); - callback(); - }); - setTimeout( function() { element.removeClass( 'fade-trigger' ); }, this.sensitivity ); - } else { - if ( stop ) { - element.stop(); - } - - element.first().fadeOut( speed, callback ); - - if ( element.length > 1 ) { - element.not(':first').fadeOut( speed ); - } - } - - return element; - }, - - // Check if the browser supports CSS 3.0 transitions - transitions: ( function() { - var style = document.documentElement.style; - - return ( typeof style.WebkitTransition === 'string' || - typeof style.MozTransition === 'string' || - typeof style.OTransition === 'string' || - typeof style.transition === 'string' ); - })() - }; - - /** - * Resize API - * - * Automatically updates textarea height. - */ - api.bind_resize = function() { - s.$dfwTextarea.on( 'keydown.wp-dfw-resize click.wp-dfw-resize paste.wp-dfw-resize', function() { - api.resizeTextarea(); - }); - }; - - api.resizeTextarea = function() { - var node = s.$dfwTextarea[0]; - - if ( node.scrollHeight > node.clientHeight ) { - node.style.height = node.scrollHeight + 50 + 'px'; - } - }; - - // Export - window.wp = window.wp || {}; - window.wp.editor = window.wp.editor || {}; - window.wp.editor.fullscreen = api; - -})( jQuery, window ); diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index a22991a176..7bccc2f0f1 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -25,6 +25,7 @@ final class _WP_Editors { private static $has_medialib = false; private static $editor_buttons_css = true; private static $drag_drop_upload = false; + private static $old_dfw_compat = false; private function __construct() {} @@ -53,8 +54,7 @@ final class _WP_Editors { * @type string $editor_class Extra classes to add to the editor textarea elemen. Default empty. * @type bool $teeny Whether to output the minimal editor config. Examples include * Press This and the Comment editor. Default false. - * @type bool $dfw Whether to replace the default fullscreen with "Distraction Free - * Writing". DFW requires specific DOM elements and css). Default false. + * @type bool $dfw Deprecated in 4.1. Since 4.3 used only to enqueue wp-fullscreen-stub.js for backwards compatibility. * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to * TinyMCE using an array. Default true. * @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to @@ -111,6 +111,10 @@ final class _WP_Editors { if ( self::$this_quicktags ) self::$has_quicktags = true; + if ( $set['dfw'] ) { + self::$old_dfw_compat = true; + } + if ( empty( $set['editor_height'] ) ) return $set; @@ -283,9 +287,6 @@ final class _WP_Editors { if ( empty($qtInit['buttons']) ) $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; - if ( $set['dfw'] ) - $qtInit['buttons'] .= ',fullscreen'; - if ( $set['_content_editor_dfw'] ) { $qtInit['buttons'] .= ',dfw'; } @@ -469,9 +470,6 @@ final class _WP_Editors { } } - if ( $set['dfw'] ) - $plugins[] = 'wpfullscreen'; - self::$plugins = $plugins; self::$ext_plugins = $ext_plugins; @@ -637,18 +635,6 @@ final class _WP_Editors { unset($set['tinymce']['body_class']); } - if ( $set['dfw'] ) { - // replace the first 'fullscreen' with 'wp_fullscreen' - if ( ($key = array_search('fullscreen', $mce_buttons)) !== false ) - $mce_buttons[$key] = 'wp_fullscreen'; - elseif ( ($key = array_search('fullscreen', $mce_buttons_2)) !== false ) - $mce_buttons_2[$key] = 'wp_fullscreen'; - elseif ( ($key = array_search('fullscreen', $mce_buttons_3)) !== false ) - $mce_buttons_3[$key] = 'wp_fullscreen'; - elseif ( ($key = array_search('fullscreen', $mce_buttons_4)) !== false ) - $mce_buttons_4[$key] = 'wp_fullscreen'; - } - $mceInit = array ( 'selector' => "#$editor_id", 'resize' => 'vertical', @@ -753,8 +739,9 @@ final class _WP_Editors { wp_enqueue_script('wplink'); } - if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) ) - wp_enqueue_script('wp-fullscreen'); + if ( self::$old_dfw_compat ) { + wp_enqueue_script('wp-fullscreen-stub'); + } if ( self::$has_medialib ) { add_thickbox(); @@ -1252,9 +1239,6 @@ final class _WP_Editors { if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) self::wp_link_dialog(); - if ( in_array( 'wpfullscreen', self::$plugins, true ) || in_array( 'fullscreen', self::$qt_buttons, true ) ) - self::wp_fullscreen_html(); - /** * Fires after any core TinyMCE editor instances are created. * @@ -1271,96 +1255,7 @@ final class _WP_Editors { * @global int $content_width */ public static function wp_fullscreen_html() { - global $content_width; - $post = get_post(); - - $width = isset( $content_width ) && 800 > $content_width ? $content_width : 800; - $width = $width + 22; // compensate for the padding and border - $dfw_width = get_user_setting( 'dfw_width', $width ); - $save = $post && $post->post_status == 'publish' ? __('Update') : __('Save'); - - ?> -
-
-
-
-
- -
-
- - -
-
- -
- array( 'title' => __('Bold (Ctrl + B)'), 'both' => false ), - 'italic' => array( 'title' => __('Italic (Ctrl + I)'), 'both' => false ), - 'bullist' => array( 'title' => __('Unordered list (Alt + Shift + U)'), 'both' => false ), - 'numlist' => array( 'title' => __('Ordered list (Alt + Shift + O)'), 'both' => false ), - 'blockquote' => array( 'title' => __('Blockquote (Alt + Shift + Q)'), 'both' => false ), - 'wp-media-library' => array( 'title' => __('Media library (Alt + Shift + M)'), 'both' => true ), - 'link' => array( 'title' => __('Insert/edit link (Alt + Shift + A)'), 'both' => true ), - 'unlink' => array( 'title' => __('Unlink (Alt + Shift + S)'), 'both' => false ), - 'help' => array( 'title' => __('Help (Alt + Shift + H)'), 'both' => false ), - ); - - /** - * Filter the list of TinyMCE buttons for the fullscreen - * 'Distraction-Free Writing' editor. - * - * @since 3.2.0 - * - * @param array $buttons An array of TinyMCE buttons for the DFW editor. - */ - $buttons = apply_filters( 'wp_fullscreen_buttons', $buttons ); - - foreach ( $buttons as $button => $args ) { - if ( 'separator' == $args ) { - continue; - } - - $onclick = ! empty( $args['onclick'] ) ? ' onclick="' . $args['onclick'] . '"' : ''; - $title = esc_attr( $args['title'] ); - ?> - -
- -
- - -
- -
- - post_status == 'publish' ) _e('Updated.'); else _e('Saved.'); ?> - - -
- -
-
-
-
-
-
0' ); ?>
-
-
-
-
- -
-
- div { - float: left; -} - -#wp-fullscreen-mode-bar { - padding: 3px 14px 0 0; -} - -#wp-fullscreen-buttons .hidden { - display: none; -} - -#wp-fullscreen-buttons .disabled { - opacity: 0.5; -} - -#wp-fullscreen-buttons .mce-btn button { - margin: 0; - outline: 0 none; - border: 0 none; - white-space: nowrap; - width: auto; - background: none; - color: #32373c; - cursor: pointer; - font-size: 18px; - line-height: 20px; - overflow: visible; - text-align: center; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -.wp-html-mode #wp-fullscreen-buttons div { - display: none; -} - -.wp-html-mode #wp-fullscreen-buttons div.wp-fullscreen-both { - display: block; -} - -#wp-fullscreen-save img { - vertical-align: middle; -} - -#wp-fullscreen-save span { - display: none; - margin: 5px 6px 0; - float: left; -} - -/* =Thickbox Adjustments --------------------------------------------------------------- */ -.wp-fullscreen-active #TB_overlay { - z-index: 100050; -} - -.wp-fullscreen-active #TB_window { - z-index: 100051; -} - -/* Colors */ -.fullscreen-overlay { - background: #fff; -} - -/* =CSS 3 transitions --------------------------------------------------------------- */ - -.wp-fullscreen-active #fullscreen-topbar { - -webkit-transition-duration: 0.8s; - transition-duration: 0.8s; - opacity: 0; - filter: alpha(opacity=0); -} - -.wp-fullscreen-active #wp-fullscreen-statusbar { - height: 0; -} - -.wp-fullscreen-active.wp-dfw-show-ui #fullscreen-topbar { - -webkit-transition-duration: 0.4s; - transition-duration: 0.4s; - opacity: 1; - filter: alpha(opacity=100); -} - -.wp-fullscreen-active.wp-dfw-show-ui #wp-fullscreen-statusbar { - height: 29px; - background: #f8f8f8; - border-top: 1px solid #eee; -} - -.wp-fullscreen-active .wp-fullscreen-title, -.wp-fullscreen-active .wp-editor-container { - -webkit-transition-duration: 0.8s; - transition-duration: 0.8s; - border-color: transparent; -} - -.wp-fullscreen-active.wp-dfw-show-ui .wp-fullscreen-title, -.wp-fullscreen-active.wp-dfw-show-ui .wp-editor-container { - -webkit-transition-duration: 0.4s; - transition-duration: 0.4s; - border-color: #ccc; -} - -.fade-1000, -.fade-600, -.fade-400, -.fade-300 { - opacity: 0; - -webkit-transition-property: opacity; - transition-property: opacity; -} - -.fade-1000 { - -webkit-transition-duration: 1s; - transition-duration: 1s; -} - -.fade-600 { - -webkit-transition-duration: 0.6s; - transition-duration: 0.6s; -} - -.fade-400 { - -webkit-transition-duration: 0.4s; - transition-duration: 0.4s; -} - -.fade-300 { - -webkit-transition-duration: 0.3s; - transition-duration: 0.3s; -} - -.fade-trigger { - opacity: 1; -} - -/* DFW on touch screen devices */ -.wp-dfw-touch #fullscreen-topbar { - position: absolute; - opacity: 1; -} - -.wp-dfw-touch .wp-fullscreen-wrap .wp-editor-container, -.wp-dfw-touch .wp-fullscreen-title { - max-width: 700px; -} - -.wp-fullscreen-active.wp-dfw-touch .wp-fullscreen-title, -.wp-fullscreen-active.wp-dfw-touch .wp-editor-container { - border-color: #ccc; -} - -.wp-dfw-touch #wp-fullscreen-statusbar { - height: 30px; -} - -@media screen and ( max-width: 782px ) { - #wp-fullscreen-close, - #wp-fullscreen-central-toolbar, - #wp-fullscreen-mode-bar, - #wp-fullscreen-button-bar, - #wp-fullscreen-save { - display: inline-block; - } - - #fullscreen-topbar { - height: 85px; - } - - #wp-fullscreen-central-toolbar { - width: auto !important; - min-width: 0; - } - - #wp-fullscreen-close { - line-height: 30px; - vertical-align: top; - padding: 0 12px; - } - - #wp-fullscreen-button-bar { - position: absolute; - top: 45px; - left: 0; - } - - .wp-fullscreen-wrap { - top: 95px; - } - - #wp-fullscreen-save { - position: absolute; - right: 10px; - } -} - -@media screen and ( max-width: 480px ) { - #wp_fs_help { - display: none; - } - - .wp-fullscreen-wrap .wp-editor-container, - .wp-fullscreen-title { - width: 480px !important; - } - - body.wp-fullscreen-active { - width: 480px; - overflow: auto; - } - - #fullscreen-topbar, - .wp-fullscreen-wrap { - width: 480px; - } - - #fullscreen-topbar { - position: absolute; - } - - #wp-fullscreen-status { - width: auto !important; - max-width: 100%; - padding: 0 10px; - } -} - /* =Localization -------------------------------------------------------------- */ .rtl .wp-switch-editor, @@ -2136,8 +1632,7 @@ html:lang(he-il) .rtl .quicktags-toolbar input { @media print, (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) { - .wp-media-buttons .add_media span.wp-media-buttons-icon, - #wp-fullscreen-buttons #wp_fs_image span.mce_image { + .wp-media-buttons .add_media span.wp-media-buttons-icon { background: none; } } diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css index 6e04e57b0f..7fd028a7ee 100644 --- a/src/wp-includes/css/media-views.css +++ b/src/wp-includes/css/media-views.css @@ -2042,7 +2042,6 @@ } /* Drag & drop on the editor upload */ -#wp-fullscreen-body .uploader-editor, .wp-editor-wrap .uploader-editor { background: rgba( 150, 150, 150, 0.9 ); position: absolute; @@ -2055,17 +2054,6 @@ text-align: center; } -#wp-fullscreen-body .uploader-editor { - background: rgba( 0, 86, 132, 0.9 ); - position: fixed; - z-index: 100050; /* above the editor toolbar */ -} - -.wp-editor-wrap.wp-fullscreen-wrap .uploader-editor { - opacity: 0; -} - -#wp-fullscreen-body .uploader-editor-content, .wp-editor-wrap .uploader-editor-content { border: 1px dashed #fff; position: absolute; @@ -2075,7 +2063,6 @@ bottom: 10px; } -#wp-fullscreen-body .uploader-editor .uploader-editor-title, .wp-editor-wrap .uploader-editor .uploader-editor-title { position: absolute; top: 50%; @@ -2097,7 +2084,6 @@ background: rgba( 0, 86, 132, 0.9 ); } -#wp-fullscreen-body .uploader-editor .uploader-editor-title, .wp-editor-wrap .uploader-editor.droppable .uploader-editor-title { display: block; } diff --git a/src/wp-includes/js/media/views/uploader/editor.js b/src/wp-includes/js/media/views/uploader/editor.js index a638d95650..6fc2e388c2 100644 --- a/src/wp-includes/js/media/views/uploader/editor.js +++ b/src/wp-includes/js/media/views/uploader/editor.js @@ -1,8 +1,8 @@ /*globals wp, _, jQuery */ /** - * Creates a dropzone on WP editor instances (elements with .wp-editor-wrap - * or #wp-fullscreen-body) and relays drag'n'dropped files to a media workflow. + * Creates a dropzone on WP editor instances (elements with .wp-editor-wrap) + * and relays drag'n'dropped files to a media workflow. * * wp.media.view.EditorUploader * @@ -109,7 +109,7 @@ EditorUploader = View.extend({ } View.prototype.render.apply( this, arguments ); - $( '.wp-editor-wrap, #wp-fullscreen-body' ).each( _.bind( this.attach, this ) ); + $( '.wp-editor-wrap' ).each( _.bind( this.attach, this ) ); return this; }, diff --git a/src/wp-includes/js/quicktags.js b/src/wp-includes/js/quicktags.js index 9b2f8c8d66..1799a5e288 100644 --- a/src/wp-includes/js/quicktags.js +++ b/src/wp-includes/js/quicktags.js @@ -283,11 +283,6 @@ function edButton(id, display, tagStart, tagEnd, access) { } } - if ( use && use.indexOf(',fullscreen,') !== -1 ) { - theButtons.fullscreen = new qt.FullscreenButton(); - html += theButtons.fullscreen.html(name + '_'); - } - if ( use && use.indexOf(',dfw,') !== -1 ) { theButtons.dfw = new qt.DFWButton(); html += theButtons.dfw.html( name + '_' ); @@ -623,18 +618,6 @@ function edButton(id, display, tagStart, tagEnd, access) { } }; - qt.FullscreenButton = function() { - qt.Button.call(this, 'fullscreen', quicktagsL10n.fullscreen, 'f', quicktagsL10n.toggleFullscreen); - }; - qt.FullscreenButton.prototype = new qt.Button(); - qt.FullscreenButton.prototype.callback = function(e, c) { - if ( ! c.id || typeof wp === 'undefined' || ! wp.editor || ! wp.editor.fullscreen ) { - return; - } - - wp.editor.fullscreen.on(); - }; - qt.DFWButton = function() { qt.Button.call( this, 'dfw', '', 'f', quicktagsL10n.dfw ); }; diff --git a/src/wp-includes/js/tinymce/plugins/wpfullscreen/plugin.js b/src/wp-includes/js/tinymce/plugins/wpfullscreen/plugin.js deleted file mode 100644 index b06bcb9f27..0000000000 --- a/src/wp-includes/js/tinymce/plugins/wpfullscreen/plugin.js +++ /dev/null @@ -1,76 +0,0 @@ -/* global tinymce */ -/** - * WP Fullscreen (Distraction-Free Writing) TinyMCE plugin - */ -tinymce.PluginManager.add( 'wpfullscreen', function( editor ) { - var settings = editor.settings; - - function fullscreenOn() { - settings.wp_fullscreen = true; - editor.dom.addClass( editor.getDoc().documentElement, 'wp-fullscreen' ); - // Start auto-resizing - editor.execCommand( 'wpAutoResizeOn' ); - } - - function fullscreenOff() { - settings.wp_fullscreen = false; - editor.dom.removeClass( editor.getDoc().documentElement, 'wp-fullscreen' ); - // Stop auto-resizing - editor.execCommand( 'wpAutoResizeOff' ); - } - - // For use from outside the editor. - editor.addCommand( 'wpFullScreenOn', fullscreenOn ); - editor.addCommand( 'wpFullScreenOff', fullscreenOff ); - - function getExtAPI() { - return ( typeof wp !== 'undefined' && wp.editor && wp.editor.fullscreen ); - } - - // Toggle DFW mode. For use from inside the editor. - function toggleFullscreen() { - var fullscreen = getExtAPI(); - - if ( fullscreen ) { - if ( editor.getParam('wp_fullscreen') ) { - fullscreen.off(); - } else { - fullscreen.on(); - } - } - } - - editor.addCommand( 'wpFullScreen', toggleFullscreen ); - - editor.on( 'keydown', function( event ) { - var fullscreen; - - // Turn fullscreen off when Esc is pressed. - if ( event.keyCode === 27 && ( fullscreen = getExtAPI() ) && fullscreen.settings.visible ) { - fullscreen.off(); - } - }); - - editor.on( 'init', function() { - // Set the editor when initializing from whitin DFW - if ( editor.getParam('wp_fullscreen') ) { - fullscreenOn(); - } - }); - - // Register buttons - editor.addButton( 'wp_fullscreen', { - tooltip: 'Distraction-free writing mode', - shortcut: 'Alt+Shift+W', - onclick: toggleFullscreen, - classes: 'wp-fullscreen btn widget' // This overwrites all classes on the container! - }); - - editor.addMenuItem( 'wp_fullscreen', { - text: 'Distraction-free writing mode', - icon: 'wp_fullscreen', - shortcut: 'Alt+Shift+W', - context: 'view', - onclick: toggleFullscreen - }); -}); diff --git a/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css b/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css index dd7b5c48db..0a0a759966 100644 --- a/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css +++ b/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css @@ -71,17 +71,6 @@ img.emoji { box-shadow: none !important; } -/* DFW mode */ -html.wp-fullscreen, -html.wp-fullscreen body#tinymce { - width: auto; - max-width: none; - min-height: 0; - overflow: hidden; - color: #333; - background: transparent; -} - .aligncenter, dl.aligncenter, .html5-captions .wp-caption.aligncenter { diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 6cd361b5d3..5ed1db751f 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -94,8 +94,6 @@ function wp_default_scripts( &$scripts ) { 'enterURL' => __( 'Enter the URL' ), 'enterImageURL' => __( 'Enter the URL of the image' ), 'enterImageDescription' => __( 'Enter a description of the image' ), - 'fullscreen' => __( 'fullscreen' ), - 'toggleFullscreen' => esc_attr__( 'Toggle fullscreen mode' ), 'textdirection' => esc_attr__( 'text direction' ), 'toggleTextdirection' => esc_attr__( 'Toggle Editor Text Direction' ), 'dfw' => esc_attr__( 'Distraction-free writing mode' ) @@ -105,7 +103,8 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 ); - $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 ); + // Back-compat for old DFW. To-do: remove at the end of 2016. + $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 ); $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(