Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Mobile] - Unsupported block - UI improvements (#62240)
* Mobile - Unsupported block editor - Update editor style overrides

* Mobile - Unsupported block - Update UI to show Tap to edit for unsupported blocks, simplifying the flow to open the Unsupported block editor

* Fix unsupported block condition

* Update snapshot

* Fix condition for the help icon
  • Loading branch information
Gerardo Pacheco committed Jun 6, 2024
commit 1ce59db6373daa0a77e6d9d1b1c32d27a7dda262
50 changes: 39 additions & 11 deletions packages/block-library/src/missing/edit.native.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/**
* External dependencies
*/
import {
View,
Text,
TouchableWithoutFeedback,
TouchableOpacity,
} from 'react-native';
import { View, Text, TouchableOpacity } from 'react-native';

/**
* WordPress dependencies
Expand All @@ -25,6 +20,7 @@ import {
store as blockEditorStore,
} from '@wordpress/block-editor';
import { store as noticesStore } from '@wordpress/notices';
import { requestUnsupportedBlockFallback } from '@wordpress/react-native-bridge';

/**
* Internal dependencies
Expand All @@ -48,11 +44,38 @@ export class UnsupportedBlockEdit extends Component {
}

toggleSheet() {
const { attributes, block, clientId } = this.props;
const { originalName } = attributes;
const title = this.getTitle();
const blockContent = serialize( block ? [ block ] : [] );

if ( this.canEditUnsupportedBlock() ) {
requestUnsupportedBlockFallback(
blockContent,
clientId,
originalName,
title
);
return;
}

this.setState( {
showHelp: ! this.state.showHelp,
} );
}

canEditUnsupportedBlock() {
const {
canEnableUnsupportedBlockEditor,
isUnsupportedBlockEditorSupported,
} = this.props;

return (
! canEnableUnsupportedBlockEditor &&
isUnsupportedBlockEditorSupported
);
}

closeSheet() {
this.setState( {
showHelp: false,
Expand Down Expand Up @@ -186,7 +209,11 @@ export class UnsupportedBlockEdit extends Component {
);

const subtitle = (
<Text style={ subTitleStyle }>{ __( 'Unsupported' ) }</Text>
<Text style={ subTitleStyle }>
{ this.canEditUnsupportedBlock()
? __( 'Tap to edit' )
: __( 'Unsupported' ) }
</Text>
);

const icon = blockType
Expand All @@ -198,8 +225,8 @@ export class UnsupportedBlockEdit extends Component {
);
const iconClassName = 'unsupported-icon' + '-' + preferredColorScheme;
return (
<TouchableWithoutFeedback
disabled={ ! this.props.isSelected }
<TouchableOpacity
activeOpacity={ 0.5 }
accessibilityLabel={ __( 'Help button' ) }
accessibilityRole="button"
accessibilityHint={ __( 'Tap here to show help' ) }
Expand All @@ -211,7 +238,8 @@ export class UnsupportedBlockEdit extends Component {
styles.unsupportedBlockDark
) }
>
{ this.renderHelpIcon() }
{ ! this.canEditUnsupportedBlock() &&
this.renderHelpIcon() }
<View style={ styles.unsupportedBlockHeader }>
<Icon
className={ iconClassName }
Expand All @@ -223,7 +251,7 @@ export class UnsupportedBlockEdit extends Component {
{ subtitle }
{ this.renderSheet( title, originalName ) }
</View>
</TouchableWithoutFeedback>
</TouchableOpacity>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ exports[`Missing block renders without crashing 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": true,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
collapsable={false}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
Expand All @@ -23,72 +32,79 @@ exports[`Missing block renders without crashing 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"opacity": 1,
}
}
>
<View
accessibilityHint="Tap here to show help"
accessibilityLabel="Help button"
accessibilityRole="button"
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
<View>
<View
accessibilityHint="Tap here to show help"
accessibilityLabel="Help button"
accessibilityRole="button"
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
}
accessible={true}
collapsable={false}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"opacity": 1,
accessible={true}
collapsable={false}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"opacity": 1,
}
}
}
>
<Svg
height={24}
label="Help icon"
style={{}}
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
>
Path
</Svg>
</View>
<View>
<Svg
fill="white"
height={24}
style={{}}
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
>
Path
</Svg>
<Svg
height={24}
label="Help icon"
style={{}}
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
>
Path
</Svg>
</View>
<View>
<Svg
fill="white"
height={24}
style={{}}
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
>
Path
</Svg>
<Text>
missing/block/title
</Text>
</View>
<Text>
missing/block/title
Unsupported
</Text>
</View>
<Text>
Unsupported
</Text>
</View>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
display: none;
}

/* Remove header toolbar */
.editor-header__toolbar {
display: none;
}

/* Hide all children of editor-header__settings */
.editor-header__settings > * {
display: none;
}

/* Show only the interface-pinned-items container */
.editor-header__settings > .interface-pinned-items {
display: block;
}

.components-button.editor-post-publish-panel__toggle.is-primary{
display: none;
}

/* Remove default block appender at the end of the post */
.block-list-appender {
.block-list-appender, .block-list-appender__toggle,
.block-editor-inserter, .components-autocomplete__popover {
display: none;
}

Expand All @@ -18,6 +38,11 @@
display: none;
}

/* Remove block inserter popover */
.block-editor-block-popover {
display: none;
}

/* Right align post header children as we will only display one child */
.edit-post-header {
justify-content: flex-end;
Expand Down