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

Mobile Release v1.75.0 #40630

Merged
merged 20 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7473046
Release script: Update react-native-editor version to 1.74.0
Apr 14, 2022
6f89f35
Release script: Update with changes from 'npm run core preios'
Apr 14, 2022
f04c036
Update CHANGELOG
Apr 14, 2022
8787a69
Release script: Update react-native-editor version to 1.75.0
Apr 26, 2022
5651a1e
Commit changes from "npm run core preios"
Apr 26, 2022
cc03315
[RNMobile] Prevent unnecessary re-renders of RichText component due t…
fluiddot Apr 26, 2022
18483c0
Mobile - RichText - Set a default value for selectionStart / selectio…
Apr 26, 2022
68bf03d
Embed block: Fix inline preview cut-off when editing URL (#35326)
fluiddot Apr 19, 2022
b97f8d5
[RNMobile] Upgrade to AztecAndroid 1.5.7 (#40099)
mchowning Apr 15, 2022
7746f8c
Add constants file to Spacer block (#40446)
fluiddot Apr 20, 2022
1d6e193
Use CSS to transform text into title case (#40550)
Apr 25, 2022
fcb9abf
Mobile - Notice list - Updates the code with the following: (#40415)
Apr 20, 2022
4a11173
Mobile - Layout - Set a background color for the toolbar (#40266)
Apr 18, 2022
79c5553
[RNMobile] - Update tests with paragraph blocks to work on both envir…
jostnes Apr 27, 2022
ca3e18f
Mobile - HTML View - Add a top margin to avoid the tooltip overlappin…
Apr 27, 2022
4d91a1a
[RNMobile] Add featured image settings to the Latest Posts block (#39…
Apr 27, 2022
f7626e5
Update CHANGELOG with user-facing changes
Apr 28, 2022
72a45b9
Merge commit '04d733dd911874bc6aea5a01a437d0c136fa2137' into rnmobile…
mchowning Apr 28, 2022
a462c7e
Merge remote-tracking branch 'origin/trunk' into rnmobile/release_1.75.0
mchowning Apr 28, 2022
8aa2c93
Merge remote-tracking branch 'origin/trunk' into rnmobile/release_1.75.0
mchowning Apr 28, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import {
alignNone,
positionCenter,
positionLeft,
positionRight,
stretchFullWidth,
stretchWide,
} from '@wordpress/icons';

export const BLOCK_ALIGNMENTS_CONTROLS = {
none: {
icon: alignNone,
title: _x( 'None', 'Alignment option' ),
},
left: {
icon: positionLeft,
title: __( 'Align left' ),
},
center: {
icon: positionCenter,
title: __( 'Align center' ),
},
right: {
icon: positionRight,
title: __( 'Align right' ),
},
wide: {
icon: stretchWide,
title: __( 'Wide width' ),
},
full: {
icon: stretchFullWidth,
title: __( 'Full width' ),
},
};

export const DEFAULT_CONTROL = 'none';

export const POPOVER_PROPS = {
isAlternate: true,
};
178 changes: 69 additions & 109 deletions packages/block-editor/src/components/block-alignment-control/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,23 @@ import classNames from 'classnames';
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import {
ToolbarDropdownMenu,
ToolbarGroup,
MenuGroup,
MenuItem,
} from '@wordpress/components';
import {
alignNone,
positionCenter,
positionLeft,
positionRight,
stretchFullWidth,
stretchWide,
} from '@wordpress/icons';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
*/
import useAvailableAlignments from './use-available-alignments';

const BLOCK_ALIGNMENTS_CONTROLS = {
none: {
icon: alignNone,
title: _x( 'None', 'Alignment option' ),
},
left: {
icon: positionLeft,
title: __( 'Align left' ),
},
center: {
icon: positionCenter,
title: __( 'Align center' ),
},
right: {
icon: positionRight,
title: __( 'Align right' ),
},
wide: {
icon: stretchWide,
title: __( 'Wide width' ),
},
full: {
icon: stretchFullWidth,
title: __( 'Full width' ),
},
};

const DEFAULT_CONTROL = 'none';

const POPOVER_PROPS = {
isAlternate: true,
};
import {
BLOCK_ALIGNMENTS_CONTROLS,
DEFAULT_CONTROL,
POPOVER_PROPS,
} from './constants';

function BlockAlignmentUI( {
value,
Expand Down Expand Up @@ -92,72 +55,69 @@ function BlockAlignmentUI( {
label: __( 'Align' ),
toggleProps: { describedBy: __( 'Change alignment' ) },
};
const extraProps =
isToolbar || Platform.isNative
? {
isCollapsed: isToolbar ? isCollapsed : undefined,
controls: enabledControls.map(
( { name: controlName } ) => {
return {
...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
isActive:
value === controlName ||
( ! value && controlName === 'none' ),
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: () => onChangeAlignment( controlName ),
};
}
),
}
: {
children: ( { onClose } ) => {
return (
<>
<MenuGroup className="block-editor-block-alignment-control__menu-group">
{ enabledControls.map(
( { name: controlName, info } ) => {
const {
icon,
title,
} = BLOCK_ALIGNMENTS_CONTROLS[
controlName
];
// If no value is provided, mark as selected the `none` option.
const isSelected =
controlName === value ||
( ! value &&
controlName === 'none' );
return (
<MenuItem
key={ controlName }
icon={ icon }
iconPosition="left"
className={ classNames(
'components-dropdown-menu__menu-item',
{
'is-active': isSelected,
}
) }
isSelected={ isSelected }
onClick={ () => {
onChangeAlignment(
controlName
);
onClose();
} }
role="menuitemradio"
info={ info }
>
{ title }
</MenuItem>
);
}
) }
</MenuGroup>
</>
);
},
};
const extraProps = isToolbar
? {
isCollapsed,
controls: enabledControls.map( ( { name: controlName } ) => {
return {
...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
isActive:
value === controlName ||
( ! value && controlName === 'none' ),
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: () => onChangeAlignment( controlName ),
};
} ),
}
: {
children: ( { onClose } ) => {
return (
<>
<MenuGroup className="block-editor-block-alignment-control__menu-group">
{ enabledControls.map(
( { name: controlName, info } ) => {
const {
icon,
title,
} = BLOCK_ALIGNMENTS_CONTROLS[
controlName
];
// If no value is provided, mark as selected the `none` option.
const isSelected =
controlName === value ||
( ! value &&
controlName === 'none' );
return (
<MenuItem
key={ controlName }
icon={ icon }
iconPosition="left"
className={ classNames(
'components-dropdown-menu__menu-item',
{
'is-active': isSelected,
}
) }
isSelected={ isSelected }
onClick={ () => {
onChangeAlignment(
controlName
);
onClose();
} }
role="menuitemradio"
info={ info }
>
{ title }
</MenuItem>
);
}
) }
</MenuGroup>
</>
);
},
};

return <UIComponent { ...commonProps } { ...extraProps } />;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
ToolbarDropdownMenu,
ToolbarGroup,
BottomSheetSelectControl,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import useAvailableAlignments from './use-available-alignments';
import {
BLOCK_ALIGNMENTS_CONTROLS,
DEFAULT_CONTROL,
POPOVER_PROPS,
} from './constants';

function BlockAlignmentUI( {
value,
onChange,
controls,
isToolbar,
isCollapsed = true,
isBottomSheetControl = false,
} ) {
const enabledControls = useAvailableAlignments( controls );
const hasEnabledControls = !! enabledControls.length;

if ( ! hasEnabledControls ) {
return null;
}

function onChangeAlignment( align ) {
onChange( [ value, 'none' ].includes( align ) ? undefined : align );
}

const activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[ value ];
const defaultAlignmentControl =
BLOCK_ALIGNMENTS_CONTROLS[ DEFAULT_CONTROL ];

const toolbarUIComponent = isToolbar ? ToolbarGroup : ToolbarDropdownMenu;
const UIComponent = isBottomSheetControl
? BottomSheetSelectControl
: toolbarUIComponent;

const commonProps = {
label: __( 'Align' ),
};
const extraProps = isBottomSheetControl
? {
options: enabledControls.map( ( { name: controlName } ) => {
const control = BLOCK_ALIGNMENTS_CONTROLS[ controlName ];
return {
value: controlName,
label: control.title,
icon: control.icon,
};
} ),
value: activeAlignmentControl ? value : 'none',
onChange: ( align ) => onChangeAlignment( align ),
}
: {
icon: activeAlignmentControl
? activeAlignmentControl.icon
: defaultAlignmentControl.icon,
isCollapsed: isToolbar ? isCollapsed : undefined,
controls: enabledControls.map( ( { name: controlName } ) => {
return {
...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
isActive:
value === controlName ||
( ! value && controlName === 'none' ),
onClick: () => onChangeAlignment( controlName ),
};
} ),
popoverProps: POPOVER_PROPS,
toggleProps: { describedBy: __( 'Change alignment' ) },
};

return <UIComponent { ...commonProps } { ...extraProps } />;
}

export default BlockAlignmentUI;
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const defaultRenderToggle = ( {
};
const expandedModeViewText = (
<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>
{ __( 'Add Blocks' ) }
{ __( 'Add blocks' ) }
</Text>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
color: $white;
font-weight: 500;
align-self: center;
text-transform: capitalize;
}

.inserter-menu__list-wrapper {
Expand Down
Loading