diff --git a/editor/components/block-list/block-drop-zone.js b/editor/components/block-drop-zone/index.js similarity index 100% rename from editor/components/block-list/block-drop-zone.js rename to editor/components/block-drop-zone/index.js diff --git a/editor/components/block-list/block.js b/editor/components/block-list/block.js index 7b1f31cbcdcf8..6f3722841f60c 100644 --- a/editor/components/block-list/block.js +++ b/editor/components/block-list/block.js @@ -17,11 +17,11 @@ import { __, sprintf } from '@wordpress/i18n'; * Internal dependencies */ import BlockMover from '../block-mover'; +import BlockDropZone from '../block-drop-zone'; import BlockSettingsMenu from '../block-settings-menu'; import InvalidBlockWarning from './invalid-block-warning'; import BlockCrashWarning from './block-crash-warning'; import BlockCrashBoundary from './block-crash-boundary'; -import BlockDropZone from './block-drop-zone'; import BlockHtml from './block-html'; import BlockContextualToolbar from './block-contextual-toolbar'; import BlockMultiControls from './multi-controls'; diff --git a/editor/components/block-list/index.js b/editor/components/block-list/index.js index 96cd00dd499f1..029be5b570c7f 100644 --- a/editor/components/block-list/index.js +++ b/editor/components/block-list/index.js @@ -8,7 +8,6 @@ import { invert, isEqual, mapValues, - noop, sortBy, throttle, } from 'lodash'; @@ -18,9 +17,8 @@ import 'element-closest'; /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import { serialize, getDefaultBlockName, createBlock } from '@wordpress/blocks'; +import { serialize } from '@wordpress/blocks'; /** * Internal dependencies @@ -28,7 +26,6 @@ import { serialize, getDefaultBlockName, createBlock } from '@wordpress/blocks'; import './style.scss'; import BlockListBlock from './block'; import BlockListSiblingInserter from './sibling-inserter'; -import BlockDropZone from './block-drop-zone'; import { getBlockUids, getMultiSelectedBlocksStartUid, @@ -37,7 +34,7 @@ import { getMultiSelectedBlockUids, getSelectedBlock, } from '../../selectors'; -import { insertBlock, startMultiSelect, stopMultiSelect, multiSelect, selectBlock } from '../../actions'; +import { startMultiSelect, stopMultiSelect, multiSelect, selectBlock } from '../../actions'; class BlockList extends Component { constructor( props ) { @@ -49,7 +46,6 @@ class BlockList extends Component { this.onCopy = this.onCopy.bind( this ); this.onCut = this.onCut.bind( this ); this.setBlockRef = this.setBlockRef.bind( this ); - this.appendDefaultBlock = this.appendDefaultBlock.bind( this ); this.setLastClientY = this.setLastClientY.bind( this ); this.onPointerMove = throttle( this.onPointerMove.bind( this ), 100 ); // Browser does not fire `*move` event when the pointer position changes @@ -200,11 +196,6 @@ class BlockList extends Component { } } - appendDefaultBlock() { - const newBlock = createBlock( getDefaultBlockName() ); - this.props.onInsertBlock( newBlock ); - } - render() { const { blocks, showContextualToolbar } = this.props; @@ -225,19 +216,6 @@ class BlockList extends Component { uid={ uid } />, ] ) } - { ! blocks.length && -
- - -
- } ); } @@ -253,9 +231,6 @@ export default connect( selectedBlock: getSelectedBlock( state ), } ), ( dispatch ) => ( { - onInsertBlock( block ) { - dispatch( insertBlock( block ) ); - }, onStartMultiSelect() { dispatch( startMultiSelect() ); }, diff --git a/editor/components/block-list/style.scss b/editor/components/block-list/style.scss index b896388aad6b6..385d524679312 100644 --- a/editor/components/block-list/style.scss +++ b/editor/components/block-list/style.scss @@ -323,47 +323,6 @@ } } -.editor-block-list__placeholder { - max-width: $visual-editor-max-width + ( 2 * $block-mover-padding-visible ); - padding: 0; - clear: left; - margin: 0 auto; - position: relative; - - @include break-small() { - padding: 0 ( $block-padding + $block-mover-padding-visible ); - } - - input[type=text] { - height: $text-editor-font-size * 4; // same height as an empty paragraph - margin: 0px 0px 4px 0px; - outline: 1px solid transparent; - border: none; - background: none; - box-shadow: none; - display: block; - transition: 0.2s outline; - text-align: left; - width: 100%; - color: $dark-gray-300; - font-size: $editor-font-size; - line-height: $editor-line-height; - cursor: text; - max-width: none; // fixes a bleed issue from the admin - - &:hover { - outline: 1px solid $light-gray-500; - } - - padding: ( $block-padding - 2px ) $block-padding; - - @include break-small() { - margin-left: -$block-padding; - margin-right: -$block-padding; - } - } -} - .editor-block-list__block .blocks-visual-editor__block-html-textarea { display: block; margin: 0; diff --git a/editor/components/default-block-appender/index.js b/editor/components/default-block-appender/index.js new file mode 100644 index 0000000000000..504a0a4eb59e3 --- /dev/null +++ b/editor/components/default-block-appender/index.js @@ -0,0 +1,71 @@ +/** + * External dependencies + */ +import { connect } from 'react-redux'; +import classnames from 'classnames'; +import 'element-closest'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { Component } from '@wordpress/element'; +import { getDefaultBlockName, createBlock } from '@wordpress/blocks'; + +/** + * Internal dependencies + */ +import './style.scss'; +import BlockDropZone from '../block-drop-zone'; +import { insertBlock } from '../../actions'; +import { getBlockCount } from '../../selectors'; + +class DefaultBlockAppender extends Component { + constructor( props ) { + super( props ); + this.appendDefaultBlock = this.appendDefaultBlock.bind( this ); + } + + appendDefaultBlock() { + const newBlock = createBlock( getDefaultBlockName() ); + this.props.onInsertBlock( newBlock ); + } + + render() { + const { count } = this.props; + + const className = classnames( 'editor-default-block-appender', { + 'is-visible-placeholder': count === 0, + } ); + + return ( +
+ + { count === 0 && + + } + { count !== 0 && +
+ ); + } +} + +export default connect( + ( state ) => ( { + count: getBlockCount( state ), + } ), + { onInsertBlock: insertBlock } +)( DefaultBlockAppender ); diff --git a/editor/components/default-block-appender/style.scss b/editor/components/default-block-appender/style.scss new file mode 100644 index 0000000000000..cbc0d2ec3f4cf --- /dev/null +++ b/editor/components/default-block-appender/style.scss @@ -0,0 +1,32 @@ +$empty-paragraph-height: $text-editor-font-size * 4; + +.editor-default-block-appender { + &.is-visible-placeholder .editor-default-block-appender__content { + height: $empty-paragraph-height; + color: $dark-gray-300; + outline: 1px solid transparent; + transition: 0.2s outline; + + &:hover { + outline: 1px solid $light-gray-500; + } + } +} + +.editor-default-block-appender__content, +input[type=text].editor-default-block-appender__content { + border: none; + background: none; + box-shadow: none; + display: block; + width: 100%; + height: $empty-paragraph-height * 1.5; + font-size: $editor-font-size; + line-height: $editor-line-height; + cursor: text; + max-width: none; // fixes a bleed issue from the admin + + &:focus { + outline: 1px solid $light-gray-500; + } +} diff --git a/editor/components/index.js b/editor/components/index.js index 0a10d67048c65..f0ce47164e71b 100644 --- a/editor/components/index.js +++ b/editor/components/index.js @@ -40,6 +40,7 @@ export { default as BlockList } from './block-list'; export { default as BlockMover } from './block-mover'; export { default as BlockSettingsMenu } from './block-settings-menu'; export { default as BlockToolbar } from './block-toolbar'; +export { default as DefaultBlockAppender } from './default-block-appender'; export { default as ErrorBoundary } from './error-boundary'; export { default as Inserter } from './inserter'; export { default as Warning } from './warning'; diff --git a/editor/edit-post/modes/visual-editor/index.js b/editor/edit-post/modes/visual-editor/index.js index 3b22d6c734618..250d5f94033ce 100644 --- a/editor/edit-post/modes/visual-editor/index.js +++ b/editor/edit-post/modes/visual-editor/index.js @@ -14,8 +14,7 @@ import { KeyboardShortcuts } from '@wordpress/components'; * Internal dependencies */ import './style.scss'; -import VisualEditorInserter from './inserter'; -import { BlockList, PostTitle, WritingFlow } from '../../../components'; +import { BlockList, PostTitle, WritingFlow, DefaultBlockAppender } from '../../../components'; import { getBlockUids, getMultiSelectedBlockUids, isFeatureActive } from '../../../selectors'; import { clearSelectedBlock, multiSelect, redo, undo, removeBlocks } from '../../../actions'; @@ -98,7 +97,7 @@ class VisualEditor extends Component { showContextualToolbar={ ! this.props.hasFixedToolbar } /> - + ); /* eslint-enable jsx-a11y/no-static-element-interactions */ diff --git a/editor/edit-post/modes/visual-editor/inserter.js b/editor/edit-post/modes/visual-editor/inserter.js deleted file mode 100644 index ad2ae85eeacb2..0000000000000 --- a/editor/edit-post/modes/visual-editor/inserter.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * External dependencies - */ -import { connect } from 'react-redux'; -import classnames from 'classnames'; - -/** - * WordPress dependencies - */ -import { __, sprintf } from '@wordpress/i18n'; -import { IconButton } from '@wordpress/components'; -import { Component } from '@wordpress/element'; -import { createBlock, BlockIcon } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import { Inserter } from '../../../components'; -import { insertBlock } from '../../../actions'; -import { getMostFrequentlyUsedBlocks, getBlockCount } from '../../../selectors'; - -export class VisualEditorInserter extends Component { - constructor() { - super( ...arguments ); - - this.showControls = this.toggleControls.bind( this, true ); - this.hideControls = this.toggleControls.bind( this, false ); - - this.state = { - isShowingControls: false, - }; - } - - toggleControls( isShowingControls ) { - this.setState( { isShowingControls } ); - } - - insertBlock( name ) { - const { onInsertBlock } = this.props; - onInsertBlock( createBlock( name ) ); - } - - render() { - const { blockCount } = this.props; - const { isShowingControls } = this.state; - const { mostFrequentlyUsedBlocks } = this.props; - const classes = classnames( 'editor-visual-editor__inserter', { - 'is-showing-controls': isShowingControls, - } ); - - return ( -
- - { mostFrequentlyUsedBlocks && mostFrequentlyUsedBlocks.map( ( block ) => ( - this.insertBlock( block.name ) } - label={ sprintf( __( 'Insert %s' ), block.title ) } - icon={ ( - - - - ) } - > - { block.title } - - ) ) } -
- ); - } -} - -export default connect( - ( state ) => { - return { - mostFrequentlyUsedBlocks: getMostFrequentlyUsedBlocks( state ), - blockCount: getBlockCount( state ), - }; - }, - { onInsertBlock: insertBlock }, -)( VisualEditorInserter ); diff --git a/editor/edit-post/modes/visual-editor/style.scss b/editor/edit-post/modes/visual-editor/style.scss index 324c7a01b29b3..1c8dcb8939f6a 100644 --- a/editor/edit-post/modes/visual-editor/style.scss +++ b/editor/edit-post/modes/visual-editor/style.scss @@ -66,45 +66,6 @@ } } -.editor-visual-editor__inserter { - display: flex; - align-items: baseline; - max-width: $visual-editor-max-width + ( 2 * $block-mover-padding-visible ); - margin: 0 auto; - clear: both; - - padding: $block-padding; - padding-left: $block-padding - 8px; // Offset by left button's own padding - @include break-small { - padding: $block-padding ( $block-padding + $block-mover-padding-visible ); - padding-left: $block-padding + $block-mover-padding-visible - 8px; - } - - > .editor-inserter__block { - flex-direction: row; - opacity: 0; - transition: opacity 150ms; - margin: 0 10px; - width: auto; - font-family: $default-font; - font-size: $default-font-size; - box-shadow: none; - padding: 6px; - align-items: center; - } - - &:hover > .editor-inserter__block, - &.is-showing-controls > .editor-inserter__block { - opacity: 1; - } -} - -.editor-visual-editor__inserter-block-icon { - display: inline-block; - margin-right: 8px; - height: 20px; -} - .editor-visual-editor .editor-post-title { margin-left: auto; margin-right: auto; @@ -124,3 +85,18 @@ } } } + +.editor-visual-editor .editor-default-block-appender { + max-width: $visual-editor-max-width + ( 2 * $block-mover-padding-visible ); + clear: left; + margin: 0 auto; + position: relative; + + @include break-small() { + padding: 0 $block-mover-padding-visible; + + .editor-default-block-appender__content { + padding: 0 $block-padding; + } + } +} diff --git a/editor/edit-post/modes/visual-editor/test/inserter.js b/editor/edit-post/modes/visual-editor/test/inserter.js deleted file mode 100644 index a4b6c7f3a7c85..0000000000000 --- a/editor/edit-post/modes/visual-editor/test/inserter.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * External dependencies - */ -import { shallow } from 'enzyme'; - -/** - * WordPress dependencies - */ -import { getBlockType } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import { VisualEditorInserter } from '../inserter'; - -describe( 'VisualEditorInserter', () => { - it( 'should show controls when receiving focus', () => { - const wrapper = shallow( ); - - wrapper.simulate( 'focus' ); - - expect( wrapper.state( 'isShowingControls' ) ).toBe( true ); - } ); - - it( 'should hide controls when losing focus', () => { - const wrapper = shallow( ); - - wrapper.simulate( 'focus' ); - wrapper.simulate( 'blur' ); - - expect( wrapper.state( 'isShowingControls' ) ).toBe( false ); - } ); - - it( 'should insert frequently used blocks', () => { - const onInsertBlock = jest.fn(); - const mostFrequentlyUsedBlocks = [ getBlockType( 'core/paragraph' ), getBlockType( 'core/image' ) ]; - const wrapper = shallow( - - ); - wrapper.state.preferences = { - blockUsage: { - 'core/paragraph': 42, - 'core/image': 34, - }, - }; - - wrapper - .findWhere( ( node ) => node.prop( 'children' ) === 'Paragraph' ) - .simulate( 'click' ); - - expect( onInsertBlock ).toHaveBeenCalled(); - expect( onInsertBlock.mock.calls[ 0 ][ 0 ].name ).toBe( 'core/paragraph' ); - } ); -} ); diff --git a/editor/reducer.js b/editor/reducer.js index 145dbcdc969de..91befd1e9e575 100644 --- a/editor/reducer.js +++ b/editor/reducer.js @@ -10,11 +10,9 @@ import { get, reduce, keyBy, - keys, first, last, omit, - pick, without, mapValues, findIndex, @@ -492,24 +490,18 @@ export function preferences( state = PREFERENCES_DEFAULTS, action ) { mode: action.mode, }; case 'INSERT_BLOCKS': - // record the block usage and put the block in the recently used blocks - let blockUsage = state.blockUsage; + // put the block in the recently used blocks let recentlyUsedBlocks = [ ...state.recentlyUsedBlocks ]; action.blocks.forEach( ( block ) => { - const uses = ( blockUsage[ block.name ] || 0 ) + 1; - blockUsage = omit( blockUsage, block.name ); - blockUsage[ block.name ] = uses; recentlyUsedBlocks = [ block.name, ...without( recentlyUsedBlocks, block.name ) ].slice( 0, MAX_RECENT_BLOCKS ); } ); return { ...state, - blockUsage, recentlyUsedBlocks, }; case 'SETUP_EDITOR': const isBlockDefined = name => getBlockType( name ) !== undefined; const filterInvalidBlocksFromList = list => list.filter( isBlockDefined ); - const filterInvalidBlocksFromObject = obj => pick( obj, keys( obj ).filter( isBlockDefined ) ); const commonBlocks = getBlockTypes() .filter( ( blockType ) => 'common' === blockType.category ) .map( ( blockType ) => blockType.name ); @@ -520,7 +512,6 @@ export function preferences( state = PREFERENCES_DEFAULTS, action ) { recentlyUsedBlocks: filterInvalidBlocksFromList( [ ...state.recentlyUsedBlocks ] ) .concat( difference( commonBlocks, state.recentlyUsedBlocks ) ) .slice( 0, MAX_RECENT_BLOCKS ), - blockUsage: filterInvalidBlocksFromObject( state.blockUsage ), }; case 'TOGGLE_FEATURE': return { diff --git a/editor/selectors.js b/editor/selectors.js index a3e231995f062..2b09a395f384d 100644 --- a/editor/selectors.js +++ b/editor/selectors.js @@ -8,8 +8,6 @@ import { has, last, reduce, - keys, - without, compact, } from 'lodash'; import createSelector from 'rememo'; @@ -21,11 +19,6 @@ import { serialize, getBlockType } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; -/*** - * Module constants - */ -const MAX_FREQUENT_BLOCKS = 3; - /** * Returns the current editing mode. * @@ -1009,27 +1002,6 @@ export function getRecentlyUsedBlocks( state ) { return compact( state.preferences.recentlyUsedBlocks.map( blockType => getBlockType( blockType ) ) ); } -/** - * Resolves the block usage stats into a list of the most frequently used blocks. - * Memoized so we're not generating block lists every time we render the list - * in the inserter. - * - * @param {Object} state Global application state - * @return {Array} List of block type settings - */ -export const getMostFrequentlyUsedBlocks = createSelector( - ( state ) => { - const { blockUsage } = state.preferences; - const orderedByUsage = keys( blockUsage ).sort( ( a, b ) => blockUsage[ b ] - blockUsage[ a ] ); - // add in paragraph and image blocks if they're not already in the usage data - return compact( - [ ...orderedByUsage, ...without( [ 'core/paragraph', 'core/image' ], ...orderedByUsage ) ] - .map( blockType => getBlockType( blockType ) ) - ).slice( 0, MAX_FREQUENT_BLOCKS ); - }, - ( state ) => state.preferences.blockUsage -); - /** * Returns whether the given feature is enabled or not * diff --git a/editor/store-defaults.js b/editor/store-defaults.js index 22e5b390398eb..d58d559c89a3d 100644 --- a/editor/store-defaults.js +++ b/editor/store-defaults.js @@ -8,7 +8,6 @@ export const PREFERENCES_DEFAULTS = { isSidebarOpened: ! viewPort.isExtraSmall(), panels: { 'post-status': true }, recentlyUsedBlocks: [], - blockUsage: {}, features: { fixedToolbar: true, }, diff --git a/editor/test/reducer.js b/editor/test/reducer.js index 0c7317b851051..ec8a54a41bf84 100644 --- a/editor/test/reducer.js +++ b/editor/test/reducer.js @@ -890,7 +890,6 @@ describe( 'state', () => { const state = preferences( undefined, {} ); expect( state ).toEqual( { - blockUsage: {}, recentlyUsedBlocks: [], mode: 'visual', isSidebarOpened: true, @@ -935,7 +934,7 @@ describe( 'state', () => { } ); it( 'should record recently used blocks', () => { - const state = preferences( deepFreeze( { recentlyUsedBlocks: [], blockUsage: {} } ), { + const state = preferences( deepFreeze( { recentlyUsedBlocks: [] } ), { type: 'INSERT_BLOCKS', blocks: [ { uid: 'bacon', @@ -945,7 +944,7 @@ describe( 'state', () => { expect( state.recentlyUsedBlocks[ 0 ] ).toEqual( 'core-embed/twitter' ); - const twoRecentBlocks = preferences( deepFreeze( { recentlyUsedBlocks: [], blockUsage: {} } ), { + const twoRecentBlocks = preferences( deepFreeze( { recentlyUsedBlocks: [] } ), { type: 'INSERT_BLOCKS', blocks: [ { uid: 'eggs', @@ -960,24 +959,6 @@ describe( 'state', () => { expect( twoRecentBlocks.recentlyUsedBlocks[ 1 ] ).toEqual( 'core-embed/twitter' ); } ); - it( 'should record block usage', () => { - const state = preferences( deepFreeze( { recentlyUsedBlocks: [], blockUsage: {} } ), { - type: 'INSERT_BLOCKS', - blocks: [ { - uid: 'eggs', - name: 'core-embed/twitter', - }, { - uid: 'bacon', - name: 'core-embed/youtube', - }, { - uid: 'milk', - name: 'core-embed/youtube', - } ], - } ); - - expect( state.blockUsage ).toEqual( { 'core-embed/youtube': 2, 'core-embed/twitter': 1 } ); - } ); - it( 'should populate recentlyUsedBlocks, filling up with common blocks, on editor setup', () => { const state = preferences( deepFreeze( { recentlyUsedBlocks: [ 'core-embed/twitter', 'core-embed/youtube' ] } ), { type: 'SETUP_EDITOR', @@ -999,13 +980,6 @@ describe( 'state', () => { expect( state.recentlyUsedBlocks[ 0 ] ).toEqual( 'core-embed/youtube' ); } ); - it( 'should remove unregistered blocks from persisted block usage stats', () => { - const state = preferences( deepFreeze( { recentlyUsedBlocks: [], blockUsage: { 'core/i-do-not-exist': 42, 'core-embed/youtube': 88 } } ), { - type: 'SETUP_EDITOR', - } ); - expect( state.blockUsage ).toEqual( { 'core-embed/youtube': 88 } ); - } ); - it( 'should toggle a feature flag', () => { const state = preferences( deepFreeze( { features: { chicken: true } } ), { type: 'TOGGLE_FEATURE', diff --git a/editor/test/selectors.js b/editor/test/selectors.js index 787a22cfb552e..70737b6e95c4e 100644 --- a/editor/test/selectors.js +++ b/editor/test/selectors.js @@ -68,7 +68,6 @@ import { didPostSaveRequestFail, getSuggestedPostFormat, getNotices, - getMostFrequentlyUsedBlocks, getRecentlyUsedBlocks, getMetaBoxes, getDirtyMetaBoxes, @@ -2041,35 +2040,6 @@ describe( 'selectors', () => { } ); } ); - describe( 'getMostFrequentlyUsedBlocks', () => { - it( 'should have paragraph and image to bring frequently used blocks up to three blocks', () => { - const noUsage = { preferences: { blockUsage: {} } }; - const someUsage = { preferences: { blockUsage: { 'core/paragraph': 1 } } }; - - expect( getMostFrequentlyUsedBlocks( noUsage ).map( ( block ) => block.name ) ) - .toEqual( [ 'core/paragraph', 'core/image' ] ); - - expect( getMostFrequentlyUsedBlocks( someUsage ).map( ( block ) => block.name ) ) - .toEqual( [ 'core/paragraph', 'core/image' ] ); - } ); - it( 'should return the top 3 most recently used blocks', () => { - const state = { - preferences: { - blockUsage: { - 'core/deleted-block': 20, - 'core/paragraph': 4, - 'core/image': 11, - 'core/quote': 2, - 'core/gallery': 1, - }, - }, - }; - - expect( getMostFrequentlyUsedBlocks( state ).map( ( block ) => block.name ) ) - .toEqual( [ 'core/image', 'core/paragraph', 'core/quote' ] ); - } ); - } ); - describe( 'getRecentlyUsedBlocks', () => { it( 'should return the most recently used blocks', () => { const state = { diff --git a/test/e2e/integration/001-hello-gutenberg.js b/test/e2e/integration/001-hello-gutenberg.js index ab8aaf59c8c46..fed6862bcb1dd 100644 --- a/test/e2e/integration/001-hello-gutenberg.js +++ b/test/e2e/integration/001-hello-gutenberg.js @@ -7,6 +7,5 @@ describe( 'Hello Gutenberg', () => { // Assertions cy.url().should( 'include', 'post-new.php' ); cy.get( '[placeholder="Add title"]' ).should( 'exist' ); - cy.get( '[value="Write your story"]' ).should( 'exist' ); } ); } ); diff --git a/test/e2e/integration/002-adding-blocks.js b/test/e2e/integration/002-adding-blocks.js index 5f5c8c48c07b9..b052ff513d213 100644 --- a/test/e2e/integration/002-adding-blocks.js +++ b/test/e2e/integration/002-adding-blocks.js @@ -7,20 +7,16 @@ describe( 'Adding blocks', () => { const lastBlockSelector = '.editor-block-list__block-edit:last [contenteditable="true"]:first'; // Using the placeholder - cy.get( '[value="Write your story"]' ).click(); - cy.get( lastBlockSelector ).type( 'First Paragraph' ); - - // Using the quick inserter - cy.get( '.editor-visual-editor__inserter [aria-label="Insert Paragraph"]' ).click(); - cy.get( lastBlockSelector ).type( 'Second Paragraph' ); + cy.get( '.editor-default-block-appender' ).click(); + cy.get( lastBlockSelector ).type( 'Paragraph block' ); // Using the slash command - cy.get( '.editor-visual-editor__inserter [aria-label="Insert Paragraph"]' ).click(); + cy.get( '.editor-default-block-appender' ).click(); cy.get( lastBlockSelector ).type( '/quote{enter}' ); cy.get( lastBlockSelector ).type( 'Quote block' ); // Using the regular inserter - cy.get( '.editor-visual-editor__inserter [aria-label="Insert block"]' ).click(); + cy.get( '.editor-header [aria-label="Insert block"]' ).click(); cy.get( '[placeholder="Search for a block"]' ).type( 'code' ); cy.get( '.editor-inserter__block' ).contains( 'Code' ).click(); cy.get( '[placeholder="Write codeā€¦"]' ).type( 'Code block' ); @@ -31,8 +27,7 @@ describe( 'Adding blocks', () => { // Assertions cy.get( '.editor-post-text-editor' ) - .should( 'contain', 'First Paragraph' ) - .should( 'contain', 'Second Paragraph' ) + .should( 'contain', 'Paragraph block' ) .should( 'contain', 'Quote block' ) .should( 'contain', 'Code block' ); } ); diff --git a/test/e2e/integration/003-multi-block-selection.js b/test/e2e/integration/003-multi-block-selection.js index 6437bc510f732..f6b85776de0af 100644 --- a/test/e2e/integration/003-multi-block-selection.js +++ b/test/e2e/integration/003-multi-block-selection.js @@ -10,12 +10,9 @@ describe( 'Multi-block selection', () => { const multiSelectedCssClass = 'is-multi-selected'; // Creating test blocks - // Using the placeholder - cy.get( '[value="Write your story"]' ).click(); + cy.get( '.editor-default-block-appender' ).click(); cy.get( lastBlockSelector ).type( 'First Paragraph' ); - - // Using the quick inserter - cy.get( '.editor-visual-editor__inserter [aria-label="Insert Paragraph"]' ).click(); + cy.get( '.editor-default-block-appender' ).click(); cy.get( lastBlockSelector ).type( 'Second Paragraph' ); // Default: No selection