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

Hide alignment controls and video toggles #2295

Merged
merged 3 commits into from
May 14, 2019
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
8 changes: 8 additions & 0 deletions assets/css/amp-stories.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ amp-story-grid-layer amp-img > img {
.is-style-white.wp-block-quote {
background-image: url("../images/quote-white.svg");
}

/**
* See https://github.com/ampproject/amp-wp/issues/2283
*/
.edit-post-layout[data-block-name="core/video"] .edit-post-settings-sidebar__panel-block .block-editor-block-inspector__card + div > .components-panel__body:first-child .components-toggle-control:nth-child(2),
.edit-post-layout[data-block-name="core/video"] .edit-post-settings-sidebar__panel-block .block-editor-block-inspector__card + div > .components-panel__body:first-child .components-toggle-control:nth-child(6) {
display: none;
}
8 changes: 4 additions & 4 deletions assets/src/stories-editor/blocks/amp-story-page/edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ div[data-type="amp/amp-story-page"] .wp-block-image {
* Hackily hide the alignment options from the image block since they are irrelevant for an image block in a story.
* In the future the underlying alignment buttons should be removed entirely. See <https://github.com/ampproject/amp-wp/issues/2115>.
*/
.editor-block-list__block[data-type="core/image"] > div.editor-block-list__block-edit.block-editor-block-list__block-edit > div.editor-block-contextual-toolbar.block-editor-block-contextual-toolbar > div.editor-block-toolbar.block-editor-block-toolbar > div:nth-child(2),
.editor-block-list__block[data-type="core/pullquote"] > div.editor-block-list__block-edit.block-editor-block-list__block-edit > div.editor-block-contextual-toolbar.block-editor-block-contextual-toolbar > div.editor-block-toolbar.block-editor-block-toolbar > div:nth-child(2),
.editor-block-list__block[data-type="core/embed"] > div.editor-block-list__block-edit.block-editor-block-list__block-edit > div.editor-block-contextual-toolbar.block-editor-block-contextual-toolbar > div.editor-block-toolbar.block-editor-block-toolbar > div:nth-child(2),
.editor-block-list__block[data-type="core/video"] > div.editor-block-list__block-edit.block-editor-block-list__block-edit > div.editor-block-contextual-toolbar.block-editor-block-contextual-toolbar > div.editor-block-toolbar.block-editor-block-toolbar > div:nth-child(2) {
.edit-post-layout[data-block-name="core/image"] .edit-post-header-toolbar__block-toolbar .block-editor-block-toolbar > .components-toolbar,
.edit-post-layout[data-block-name="core/pullquote"] .edit-post-header-toolbar__block-toolbar .block-editor-block-toolbar > .components-toolbar,
.edit-post-layout[data-block-name="core/embed"] .edit-post-header-toolbar__block-toolbar .block-editor-block-toolbar > .components-toolbar,
.edit-post-layout[data-block-name="core/video"] .edit-post-header-toolbar__block-toolbar .block-editor-block-toolbar > .components-toolbar {
display: none;
}

Expand Down
25 changes: 17 additions & 8 deletions assets/src/stories-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { ALLOWED_BLOCKS } from './constants';
import store from './store';

const {
getSelectedBlockClientId,
getSelectedBlock,
getBlocksByClientId,
getClientIdsWithDescendants,
getBlockRootClientId,
Expand Down Expand Up @@ -147,25 +147,34 @@ let allBlocksWithChildren = getClientIdsWithDescendants();

let editorMode = getEditorMode();

let selectedBlock;

subscribe( async () => {
maybeInitializeAnimations();

const defaultBlockName = getDefaultBlockName();
const selectedBlockClientId = getSelectedBlockClientId();
const newSelectedBlock = getSelectedBlock();

// Switch default block depending on context
if ( selectedBlockClientId ) {
const selectedBlock = getBlock( selectedBlockClientId );

if ( 'amp/amp-story-page' === selectedBlock.name && 'amp/amp-story-page' !== defaultBlockName ) {
if ( newSelectedBlock ) {
if ( 'amp/amp-story-page' === newSelectedBlock.name && 'amp/amp-story-page' !== defaultBlockName ) {
setDefaultBlockName( 'amp/amp-story-page' );
} else if ( 'amp/amp-story-page' !== selectedBlock.name && 'amp/amp-story-text' !== defaultBlockName ) {
} else if ( 'amp/amp-story-page' !== newSelectedBlock.name && 'amp/amp-story-text' !== defaultBlockName ) {
setDefaultBlockName( 'amp/amp-story-text' );
}
} else if ( ! selectedBlockClientId && 'amp/amp-story-page' !== defaultBlockName ) {
} else if ( 'amp/amp-story-page' !== defaultBlockName ) {
setDefaultBlockName( 'amp/amp-story-page' );
}

if ( selectedBlock !== newSelectedBlock ) {
const editPostLayout = document.querySelector( '.edit-post-layout' );
if ( editPostLayout ) {
editPostLayout.setAttribute( 'data-block-name', newSelectedBlock ? newSelectedBlock.name : '' );
}
}

selectedBlock = newSelectedBlock;

const newBlockOrder = getBlockOrder();
const newlyAddedPages = newBlockOrder.find( ( block ) => ! blockOrder.includes( block ) );
const deletedPages = blockOrder.filter( ( block ) => ! newBlockOrder.includes( block ) );
Expand Down