From de0cf1caa69e342cad7530eab9ea5d0d73ad6a7e Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 9 Mar 2018 18:49:57 -0500 Subject: [PATCH] Writing Flow: Redirect click below editor to last text field --- edit-post/components/visual-editor/index.js | 13 ++-- edit-post/components/visual-editor/style.scss | 14 ++++ .../default-block-appender/index.js | 14 +++- .../test/__snapshots__/index.js.snap | 3 + editor/components/writing-flow/index.js | 72 ++++++++++++++++--- editor/components/writing-flow/style.scss | 10 +++ test/e2e/integration/002-adding-blocks.js | 12 ++-- 7 files changed, 111 insertions(+), 27 deletions(-) create mode 100644 editor/components/writing-flow/style.scss diff --git a/edit-post/components/visual-editor/index.js b/edit-post/components/visual-editor/index.js index cdf593a640b01..15b1658deffd7 100644 --- a/edit-post/components/visual-editor/index.js +++ b/edit-post/components/visual-editor/index.js @@ -8,7 +8,6 @@ import { WritingFlow, ObserveTyping, EditorGlobalKeyboardShortcuts, - BlockSelectionClearer, MultiSelectScrollIntoView, } from '@wordpress/editor'; import { Fragment, compose } from '@wordpress/element'; @@ -23,12 +22,12 @@ import BlockInspectorButton from './block-inspector-button'; function VisualEditor( { hasFixedToolbar, isLargeViewport } ) { return ( - +
- - + + ) } /> - - - + + +
); } diff --git a/edit-post/components/visual-editor/style.scss b/edit-post/components/visual-editor/style.scss index 667a5cd0e1fc3..4b0a49c132e1f 100644 --- a/edit-post/components/visual-editor/style.scss +++ b/edit-post/components/visual-editor/style.scss @@ -24,6 +24,14 @@ } } +.edit-post-visual-editor .editor-writing-flow__click-redirect { + // Collapse to minimum height of 50px, to fully occupy editor bottom pad. + height: 50px; + width: $visual-editor-max-width; + // Offset for: Visual editor padding, block (default appender) margin. + margin: #{ -1 * $block-spacing } auto -50px; +} + .edit-post-visual-editor .editor-block-list__block { margin-left: auto; margin-right: auto; @@ -89,6 +97,12 @@ margin-right: auto; position: relative; + &[data-root-uid=""] .editor-default-block-appender__content:hover { + // Outline on root-level default block appender is redundant with the + // WritingFlow click redirector. + outline: 1px solid transparent; + } + @include break-small() { padding: 0 $block-mover-padding-visible; // don't subtract 1px border because it's a border not an outline diff --git a/editor/components/default-block-appender/index.js b/editor/components/default-block-appender/index.js index c53b1049f6911..f42b5e246f37b 100644 --- a/editor/components/default-block-appender/index.js +++ b/editor/components/default-block-appender/index.js @@ -22,7 +22,15 @@ import { getBlock, getBlockCount } from '../../store/selectors'; import InserterWithShortcuts from '../inserter-with-shortcuts'; import Inserter from '../inserter'; -export function DefaultBlockAppender( { isLocked, isVisible, onAppend, showPrompt, placeholder, layout, rootUID } ) { +export function DefaultBlockAppender( { + isLocked, + isVisible, + onAppend, + showPrompt, + placeholder, + layout, + rootUID, +} ) { if ( isLocked || ! isVisible ) { return null; } @@ -30,7 +38,9 @@ export function DefaultBlockAppender( { isLocked, isVisible, onAppend, showPromp const value = placeholder || __( 'Write your story' ); return ( -
+
- { children } -
+ +
+ { children } +
+
+ ); /* eslint-disable jsx-a11y/no-static-element-interactions */ } diff --git a/editor/components/writing-flow/style.scss b/editor/components/writing-flow/style.scss new file mode 100644 index 0000000000000..06a7d77c1a69c --- /dev/null +++ b/editor/components/writing-flow/style.scss @@ -0,0 +1,10 @@ +.editor-writing-flow { + height: 100%; + display: flex; + flex-direction: column; +} + +.editor-writing-flow__click-redirect { + flex-basis: 100%; + cursor: text; +} diff --git a/test/e2e/integration/002-adding-blocks.js b/test/e2e/integration/002-adding-blocks.js index f69c667e4027d..3520d72eefdba 100644 --- a/test/e2e/integration/002-adding-blocks.js +++ b/test/e2e/integration/002-adding-blocks.js @@ -4,19 +4,15 @@ describe( 'Adding blocks', () => { } ); it( 'Should insert content using the placeholder and the regular inserter', () => { - const lastBlockSelector = '.editor-block-list__block-edit:last'; + // Default block appender is provisional + cy.get( '.editor-default-block-appender' ).click(); + cy.get( '.editor-post-title__input' ).click(); + cy.get( '[data-type="core/paragraph"]' ).should( 'have.length', 0 ); // Using the placeholder cy.get( '.editor-default-block-appender' ).click(); cy.focused().type( 'Paragraph block' ); - // Default block appender is provisional - cy.get( lastBlockSelector ).then( ( firstBlock ) => { - cy.get( '.editor-default-block-appender' ).click(); - cy.get( '.editor-post-title__input' ).click(); - cy.get( lastBlockSelector ).should( 'have.text', firstBlock.text() ); - } ); - // Using the slash command // TODO: Test omitted because Cypress doesn't update the selection // object properly, so the slash inserter is not showing up.