Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing Flow: Trailing placeholder attempt 3 #4539

Merged
merged 18 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions edit-post/assets/stylesheets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ $text-editor-max-width: 760px;
$visual-editor-max-width: 636px;
$block-controls-height: 36px;
$icon-button-size: 36px;
$icon-button-size-small: 24px;
$inserter-tabs-height: 36px;
$block-toolbar-height: 37px;
$sidebar-width: 280px;

// Blocks
$block-padding: 14px;
$block-mover-margin: 18px;
$block-mover-padding-hidden: 10px;
$block-mover-padding-visible: 32px;
$block-spacing: 4px;
// old $block-mover-padding-visible: 32px;
$block-mover-padding-visible: $icon-button-size-small + $icon-button-size-small;


// Buttons & UI Widgets
$button-style__radius-roundrect: 4px;
Expand Down
1 change: 0 additions & 1 deletion edit-post/assets/stylesheets/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ $z-layers: (
'.editor-block-list__block {core/image aligned left or right}': 20,
'.freeform-toolbar': 10,
'.editor-warning': 1,
'.editor-block-list__sibling-inserter': 1,
'.components-form-toggle__input': 1,
'.editor-format-list__menu': 1,
'.editor-inserter__tabs': 1,
Expand Down
2 changes: 0 additions & 2 deletions edit-post/components/modes/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
DefaultBlockAppender,
EditorGlobalKeyboardShortcuts,
BlockSelectionClearer,
InserterWithShortcuts,
} from '@wordpress/editor';
import { Fragment } from '@wordpress/element';

Expand Down Expand Up @@ -41,7 +40,6 @@ function VisualEditor( props ) {
/>
<DefaultBlockAppender />
</WritingFlow>
<InserterWithShortcuts />
</BlockSelectionClearer>
);
}
Expand Down
17 changes: 2 additions & 15 deletions edit-post/components/modes/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@
}
}

.edit-post-visual-editor .editor-inserter-with-shortcuts {
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;
}
}

.edit-post-visual-editor .editor-post-title {
margin-left: auto;
margin-right: auto;
Expand All @@ -72,7 +59,7 @@
}

@include break-small() {
padding: 5px ( $block-mover-padding-visible );
padding: 5px #{ $block-mover-padding-visible - 1px }; // subtract 1px border, because this is an outline

.editor-post-permalink {
left: $block-mover-padding-visible;
Expand All @@ -89,7 +76,7 @@
position: relative;

@include break-small() {
padding: 0 $block-mover-padding-visible;
padding: 0 $block-mover-padding-visible; // don't subtract 1px border because it's a border not an outline

.editor-default-block-appender__content {
padding: 0 $block-padding;
Expand Down
2 changes: 2 additions & 0 deletions editor/components/block-list/block-mobile-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import BlockMover from '../block-mover';
import BlockRemoveButton from '../block-settings-menu/block-remove-button';
import BlockSettingsMenu from '../block-settings-menu';
import VisualEditorInserter from '../inserter';

function BlockMobileToolbar( { uid, renderBlockMenu } ) {
return (
<div className="editor-block-list__block-mobile-toolbar">
<VisualEditorInserter />
<BlockMover uids={ [ uid ] } />
<BlockRemoveButton uids={ [ uid ] } small />
<BlockSettingsMenu uids={ [ uid ] } renderBlockMenu={ renderBlockMenu } />
Expand Down
14 changes: 12 additions & 2 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { __, sprintf } from '@wordpress/i18n';
* Internal dependencies
*/
import BlockMover from '../block-mover';
import VisualEditorInserter from '../inserter';
import BlockDropZone from '../block-drop-zone';
import BlockSettingsMenu from '../block-settings-menu';
import InvalidBlockWarning from './invalid-block-warning';
Expand All @@ -33,7 +34,7 @@ import BlockHtml from './block-html';
import BlockContextualToolbar from './block-contextual-toolbar';
import BlockMultiControls from './multi-controls';
import BlockMobileToolbar from './block-mobile-toolbar';
import BlockListSiblingInserter from './sibling-inserter';
import BlockInsertionPoint from './insertion-point';
import {
clearSelectedBlock,
editPost,
Expand Down Expand Up @@ -111,6 +112,7 @@ export class BlockListBlock extends Component {
this.insertBlocksAfter = this.insertBlocksAfter.bind( this );
this.onTouchStart = this.onTouchStart.bind( this );
this.onClick = this.onClick.bind( this );
this.selectOnOpen = this.selectOnOpen.bind( this );

this.previousOffset = null;
this.hadTouchStart = false;
Expand Down Expand Up @@ -388,6 +390,12 @@ export class BlockListBlock extends Component {
this.setState( { error } );
}

selectOnOpen( open ) {
if ( open && ! this.props.isSelected ) {
this.props.onSelect();
}
}

render() {
const { block, order, mode, showContextualToolbar, isLocked, renderBlockMenu } = this.props;
const { name: blockName, isValid } = block;
Expand Down Expand Up @@ -432,6 +440,7 @@ export class BlockListBlock extends Component {
{ ...wrapperProps }
>
<BlockDropZone index={ order } />
{ ( showUI || isHovered ) && <VisualEditorInserter onToggle={ this.selectOnOpen } /> }
{ ( showUI || isHovered ) && <BlockMover uids={ [ block.uid ] } /> }
{ ( showUI || isHovered ) && <BlockSettingsMenu uids={ [ block.uid ] } renderBlockMenu={ renderBlockMenu } /> }
{ showUI && isValid && showContextualToolbar && <BlockContextualToolbar /> }
Expand Down Expand Up @@ -479,7 +488,7 @@ export class BlockListBlock extends Component {
{ showUI && <BlockMobileToolbar uid={ block.uid } renderBlockMenu={ renderBlockMenu } /> }
</div>
{ !! error && <BlockCrashWarning /> }
<BlockListSiblingInserter uid={ block.uid } />
<BlockInsertionPoint uid={ block.uid } />
</div>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */
Expand Down Expand Up @@ -560,6 +569,7 @@ const mapDispatchToProps = ( dispatch, ownProps ) => ( {
onMetaChange( meta ) {
dispatch( editPost( { meta } ) );
},

toggleSelection( selectionEnabled ) {
dispatch( toggleSelection( selectionEnabled ) );
},
Expand Down
4 changes: 2 additions & 2 deletions editor/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { serialize } from '@wordpress/blocks';
*/
import './style.scss';
import BlockListBlock from './block';
import BlockListSiblingInserter from './sibling-inserter';
import BlockInsertionPoint from './insertion-point';
import BlockSelectionClearer from '../block-selection-clearer';
import {
getBlockUids,
Expand Down Expand Up @@ -250,7 +250,7 @@ class BlockList extends Component {

return (
<BlockSelectionClearer>
{ !! blocks.length && <BlockListSiblingInserter /> }
{ !! blocks.length && <BlockInsertionPoint /> }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this insertion point ever be shown?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is supposed to be shown when you open the inserter in an empty post but I just tried and it's not showing up. Might be an issue somewhere else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I guess it's the inversed condition and also some styling issues.

On a second thought, might be it's not needed when the post is empty.

{ map( blocks, ( uid ) => (
<BlockListBlock
key={ 'block-' + uid }
Expand Down
35 changes: 35 additions & 0 deletions editor/components/block-list/insertion-point.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* External dependencies
*/
import { connect } from 'react-redux';

/**
* Internal dependencies
*/
import {
getBlockUids,
getBlockInsertionPoint,
isBlockInsertionPointVisible,
} from '../../store/selectors';

function BlockInsertionPoint( { showInsertionPoint } ) {
if ( ! showInsertionPoint ) {
return null;
}

return <div className="editor-block-list__insertion-point" />;
}

export default connect(
( state, { uid } ) => {
const blockIndex = uid ? getBlockUids( state ).indexOf( uid ) : -1;
const insertIndex = blockIndex > -1 ? blockIndex + 1 : 0;

return {
showInsertionPoint: (
isBlockInsertionPointVisible( state ) &&
getBlockInsertionPoint( state ) === insertIndex
),
};
},
)( BlockInsertionPoint );
95 changes: 0 additions & 95 deletions editor/components/block-list/sibling-inserter.js

This file was deleted.

Loading