From d87a4823532d3cfafe303e5f37e530bb8eff1437 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 30 May 2014 02:37:52 +0000 Subject: [PATCH] TinyMCE in iOS: - Fix placing the caret at the bottom of longer posts when the keyboard is open. - Disable resizing on switching editors and on show/hide the kitchen sink row. See #28242 git-svn-id: https://develop.svn.wordpress.org/trunk@28626 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/editor.js | 21 +++++++++++-------- .../js/tinymce/plugins/wordpress/plugin.js | 17 ++++++++++++--- .../js/tinymce/skins/wordpress/wp-content.css | 10 +++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index e718716355..c0d3ba0454 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -60,7 +60,8 @@ window.switchEditors = { if ( ed ) { ed.show(); - if ( editorHeight ) { + // No point resizing the iframe in iOS + if ( ! tinymce.Env.iOS && editorHeight ) { toolbarHeight = getToolbarHeight(); editorHeight = editorHeight - toolbarHeight + 14; @@ -84,16 +85,18 @@ window.switchEditors = { } if ( ed ) { - iframe = DOM.get( id + '_ifr' ); - editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; + if ( ! tinymce.Env.iOS ) { + iframe = DOM.get( id + '_ifr' ); + editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; - if ( editorHeight ) { - toolbarHeight = getToolbarHeight(); - editorHeight = editorHeight + toolbarHeight - 14; + if ( editorHeight ) { + toolbarHeight = getToolbarHeight(); + editorHeight = editorHeight + toolbarHeight - 14; - // height cannot be under 50 or over 5000 - if ( editorHeight > 50 && editorHeight < 5000 ) { - txtarea_el.style.height = editorHeight + 'px'; + // height cannot be under 50 or over 5000 + if ( editorHeight > 50 && editorHeight < 5000 ) { + txtarea_el.style.height = editorHeight + 'px'; + } } } diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index b14d6f42a0..62c786783b 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -37,9 +37,12 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - if ( pixels && ! initial ) { - iframe = editor.getContentAreaContainer().firstChild; - DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels ); // Resize iframe + if ( pixels && ! initial ) { + // Resize iframe, not needed in iOS + if ( ! tinymce.Env.iOS ) { + iframe = editor.getContentAreaContainer().firstChild; + DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels ); + } if ( state === 'hide' ) { setUserSetting('hidetb', '0'); @@ -277,6 +280,10 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { doc = editor.getDoc(), dom = editor.dom; + if ( tinymce.Env.iOS ) { + dom.addClass( doc.documentElement, 'ios' ); + } + if ( editor.getParam( 'directionality' ) === 'rtl' ) { bodyClass.push('rtl'); dom.setAttrib( doc.documentElement, 'dir', 'rtl' ); @@ -358,6 +365,10 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { editor.on( 'preInit', function() { // Don't replace with and with and don't remove them when empty editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' ); + + if ( tinymce.Env.iOS ) { + editor.settings.height = 300; + } }); // Add custom shortcuts 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 56bee77d6e..4ada8310d0 100644 --- a/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css +++ b/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css @@ -1,4 +1,14 @@ /* Additional default styles for the editor */ + +html.ios { + height: 100%; +} + +.ios body#tinymce { + height: 200%; + max-width: none; +} + body { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; font-size: 13px;