Skip to content

Commit 1e5263a

Browse files
cameronvoellhypest
authored andcommitted
RNMobile Add size options to mobile image block (#17245)
* [RNMobile] Native mobile release v1.11.0 (#17181) * [RNMobile] Fix crash when adding separator * Build: remove global install of latest npm since we want to use the paired node/npm version (#17134) * Build: remove global install of latest npm since we want to use the paired node/npm version * Also update travis to remove --latest-npm flag * [RNMobile] Try dark mode (iOS) (#17067) * Adding dark mode component implemented on list and list block * Adding DarkMode handling to RichText, ToolBar and SafeArea * Mobile: Using DarkMode as HOC * iOS DarkMode: Modified colors on block list and block container * iOS DarkMode: Improved Header Toolbar colors * iOS DarkMode: Removing background from buttons * iOS DarkMode warning and unsupported * iOS DarkMode: MediaPlaceholder * iOS DarkMode: BottomSheets * iOS DarkMode: Inserter * iOS DarkMode: DefaultBlockAppender * iOS DarkMode: PostTite * Update hardcoded colors with variables * iOS DarkMode: Fix bottom-sheet cell value color * iOS DarkMode: More - PageBreak - Add Block Here * iOS DarkMode: Better text color * iOS Darkmode: Code block * iOS DarkMode: HTML View * iOS DarkMode: Improve colors on SafeArea * Fix toolbar not avoiding keyboard regression * Fix native unit tests * Fix gutenberg-mobile unit tests * Adding RNDarkMode mocks * RNMobile: Fix crash when viewing HTML on iOS * [RNMobile] Remove toolbar from html view * [RNMobile] Fix MaxListenersExceededWarning caused by dark-mode event emitter (#17186) * Fix MaxListenersExceededWarning caused by dark-mode event emitter * Checking for setMaxListeners trying to avoid CI error * Adding remove listener to DarkMode HOC * DarkMode: Binding this.onModeChanged to `this` * DarkMode: Adding conditional needed to pass UI Tests on CI * Fix focus title on new posts regression (#17180) * BottomSheet: Setting DashIcon color directly when theme is default (light) (#17193) * Activate Travis CI on rnmobile/master branch (#17229) * Added ability to update image size options (sizeSlug) through a new InspectorControl Cell that leads to a Picker. * Added a style for Size Inspector Controls cell to align it will other cells that have icons. * Add native support for the MediaText block (#16305) * First working version of the MediaText component for native mobile * Fix adding a block to an innerblock list * Disable mediaText on production * MediaText native: improve editor visuals * Move BlockToolbar from BlockList to Layout * Remove BlockEditorProvider from BlockList and add native version of EditorProvider to Editor. Plus support InsertionPoint and BlockListAppender * Update BlockMover for native to hide if locked or if it's the only block * Make the vertical align button work, add more styling options for toolbar buttons * Make sure registerCoreBlocks does not break in production * Copy docblock comment from the web version for registerCoreBlocks * Fix focusing on the media placeholder * Only support adding image for now * Update usage of MediaPlaceholder in MediaContainer * Enable autoScroll for just the out most block list * Fix JS Unit tests * Roll back to IconButton refactor and fix tests * Fix BlockVerticalAlignmentToolbar buttons style on mobile * Fix thing for web and ensure ariaPressed is always passed down * Use AriaPressed directly to style SVG on mobile * Update snapshots * Swtiched to react-native Modal onDismiss property for signaling Picker is ready to show * Added a prop for catching modal dismissal on Android. (onDismiss is iOS only and onModalHide works on Android but breaks on iOS) * Added icon for Inspector Controls size option. Removed style we no longer need. * Added title to size option iOS ActionSheet and left alignstyle to size options BottomSheet * MediaUpload and MediaPlaceholder unify props (#17145) * Unify media placeholder and upload props within media-text (#17268) * [RNMobile] Fix dismiss keyboard button for the post title (#17260) * Set unused functions to undefined instead of false in BottomSheet Modal props * Recover border colors (#17269) * [RNMobile] Insure tapping at end of post inserts at end Previously, tapping at the end of the post would insert a block immediately after the currently selected block. In addition, this commit is cleaning out a few unusued props in the block-list file. * Support group block on mobile (#17251) * First working version of the MediaText component for native mobile * Fix adding a block to an innerblock list * Disable mediaText on production * MediaText native: improve editor visuals * Move BlockToolbar from BlockList to Layout * Remove BlockEditorProvider from BlockList and add native version of EditorProvider to Editor. Plus support InsertionPoint and BlockListAppender * Update BlockMover for native to hide if locked or if it's the only block * Make the vertical align button work, add more styling options for toolbar buttons * Make sure registerCoreBlocks does not break in production * Copy docblock comment from the web version for registerCoreBlocks * Fix focusing on the media placeholder * Only support adding image for now * Update usage of MediaPlaceholder in MediaContainer * Enable autoScroll for just the out most block list * Fix JS Unit tests * Roll back to IconButton refactor and fix tests * Fix BlockVerticalAlignmentToolbar buttons style on mobile * Fix thing for web and ensure ariaPressed is always passed down * Use AriaPressed directly to style SVG on mobile * Update snapshots * Support group block on mobile * Extend shouldShowInsertionPoint condition to be false when group is selected * Code refactor * Update package-lock * Removing old style reference. * Moved Picker for image size options into new ImageSizePicker component. Cleaned up sizeOptionLabels. * Updated total left margin on Android Image size options to be 24 px instead of 28 px * Image Size options hidden behind __DEV__ flag * Remove redundant bg color within button appender (#17325) * [RNMobile] DarkMode improvements (#17309) * Remove the need to import `useStyle` and pass the theme prop on every instance that `withStyle` is used * Implement dark-mode refactor on all components * Fix broken native tests * Fix default block appender background color on DarkMode * DarkMode: Make `useStyle` a class function * Cleaned up default true properties and replaced code with lodash map. * Updated to use BottomSheetPickerCell. Eliminated code, but size options now open over top inspector controls menu. * Added leftalign to PickerCell. * [RNMobile] Add autosave to mobile apps (#17329) * [RNMobile] Fix crash when adding separator * Build: remove global install of latest npm since we want to use the paired node/npm version (#17134) * Build: remove global install of latest npm since we want to use the paired node/npm version * Also update travis to remove --latest-npm flag * [RNMobile] Try dark mode (iOS) (#17067) * Adding dark mode component implemented on list and list block * Adding DarkMode handling to RichText, ToolBar and SafeArea * Mobile: Using DarkMode as HOC * iOS DarkMode: Modified colors on block list and block container * iOS DarkMode: Improved Header Toolbar colors * iOS DarkMode: Removing background from buttons * iOS DarkMode warning and unsupported * iOS DarkMode: MediaPlaceholder * iOS DarkMode: BottomSheets * iOS DarkMode: Inserter * iOS DarkMode: DefaultBlockAppender * iOS DarkMode: PostTite * Update hardcoded colors with variables * iOS DarkMode: Fix bottom-sheet cell value color * iOS DarkMode: More - PageBreak - Add Block Here * iOS DarkMode: Better text color * iOS Darkmode: Code block * iOS DarkMode: HTML View * iOS DarkMode: Improve colors on SafeArea * Fix toolbar not avoiding keyboard regression * Fix native unit tests * Fix gutenberg-mobile unit tests * Adding RNDarkMode mocks * RNMobile: Fix crash when viewing HTML on iOS * [RNMobile] Remove toolbar from html view * [RNMobile] Fix MaxListenersExceededWarning caused by dark-mode event emitter (#17186) * Fix MaxListenersExceededWarning caused by dark-mode event emitter * Checking for setMaxListeners trying to avoid CI error * Adding remove listener to DarkMode HOC * DarkMode: Binding this.onModeChanged to `this` * DarkMode: Adding conditional needed to pass UI Tests on CI * Fix focus title on new posts regression (#17180) * BottomSheet: Setting DashIcon color directly when theme is default (light) (#17193) * Add a preliminary version of the AutosaveMonitor for mobile that calls the "bridge" and asks the native side to save the content * Add autosave mock function for tests * Fix merge conflicts * Fix lint * Re-add autosave on mobile that was removed erroneously during import-merge from rnmobile/master * Remove native variant of AutosaveMonitor and introduces changes at editor store level * Default to false for `isEditedPostAutosaveable` on mobile. There was a typo in the returing value on the previous commit. * Make sure to consider edits to the Title when checking if auto-save is needed * Fix lint * Add isAppender functionality on mobile (#17195) * Add isAppender functionality on mobile * refactor isAppender conditions * Replace dropZoneUIOnly in favour of showMediaSelectionUI * deprecate dropZoneUIOnly and add disableMediaSelection prop * Update test * Refactor tests and change prop name * Remove redundant empty lines * Refactor conditions inside MediaPlaceholder * Update block-editor CHANGELOG * Update packages/block-editor/CHANGELOG.md Co-Authored-By: Grzegorz (Greg) Ziółkowski <grzegorz@gziolo.pl> * Autosave monitor - Make the mobile editor ping the native at each keystroke, since the deboucing logic is already well defined in the apps. (#17548) * [RNMobile] Refactor Dark Mode HOC (#17552) * [RNMobile] Refactor the Dark Mode HOC to fix naming antipatterns * Fix lint errors * Add .native.js suffix to usePreferredColorScheme * Update usage of theme props renamed to preferredColorScheme * Update usage of theme props renamed to preferredColorScheme * Add missing heading levels to the UI (H4, H5, H6) (#17533) * Fix lint issue (#17598) * Fix list filter on paste for RN mobile. (#17550) * Fix method for RN mobile. * Use array.From instead of slice. * Remove comment and use Array.from directly * Convert from NodeList spreadable to Array.from * Fix lint errors. * Fix documentation examples to use Array.from * Add empty line. * [RNMobile] Move MediaUploadPorgress to its own component folder (#17392) * Move MediaUploadPorgress to its own component folder (native) * MediaUploadProgress - Fix import to code standards * MediaUploadProgress readme * Mobile - MediaUploadProgress README update * Rnmobile/fix link editing on start (#17631) * Don't try to clear links if text is clean. * Commented LinkUI removal test when no URL. * Don't try to remove link if we are at start of link and no actual selection is * Re-implementing #17802, affected by merge. Fixed extra space and unused code. * Fixing lint error, trailing space.
1 parent 9068189 commit 1e5263a

File tree

9 files changed

+55
-9
lines changed

9 files changed

+55
-9
lines changed

packages/block-editor/src/components/media-placeholder/styles.native.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
background-color: $background-dark-secondary;
2020
}
2121

22-
.emptyStateContainerDark {
23-
background-color: $background-dark-secondary;
24-
}
25-
2622
.emptyStateTitle {
2723
text-align: center;
2824
margin-top: 8;

packages/block-editor/src/components/media-upload/index.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class MediaUpload extends React.Component {
106106

107107
const getMediaOptions = () => (
108108
<Picker
109-
hideCancelButton={ true }
109+
hideCancelButton
110110
ref={ ( instance ) => this.picker = instance }
111111
options={ mediaOptions }
112112
onChange={ this.onPickerChange }

packages/block-library/src/image/edit.native.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import {
99
requestImageFailedRetryDialog,
1010
requestImageUploadCancelDialog,
1111
} from 'react-native-gutenberg-bridge';
12-
import { isEmpty } from 'lodash';
12+
import { isEmpty, map } from 'lodash';
1313

1414
/**
1515
* WordPress dependencies
1616
*/
1717
import {
1818
TextControl,
1919
ToggleControl,
20+
SelectControl,
2021
Icon,
2122
Toolbar,
2223
ToolbarButton,
@@ -50,6 +51,19 @@ import {
5051
LINK_DESTINATION_NONE,
5152
} from './constants';
5253

54+
const IMAGE_SIZE_THUMBNAIL = 'thumbnail';
55+
const IMAGE_SIZE_MEDIUM = 'medium';
56+
const IMAGE_SIZE_LARGE = 'large';
57+
const IMAGE_SIZE_FULL_SIZE = 'full';
58+
const DEFAULT_SIZE_SLUG = IMAGE_SIZE_LARGE;
59+
const sizeOptionLabels = {
60+
[ IMAGE_SIZE_THUMBNAIL ]: __( 'Thumbnail' ),
61+
[ IMAGE_SIZE_MEDIUM ]: __( 'Medium' ),
62+
[ IMAGE_SIZE_LARGE ]: __( 'Large' ),
63+
[ IMAGE_SIZE_FULL_SIZE ]: __( 'Full Size' ),
64+
};
65+
const sizeOptions = map( sizeOptionLabels, ( label, option ) => ( { value: option, label } ) );
66+
5367
// Default Image ratio 4:3
5468
const IMAGE_ASPECT_RATIO = 4 / 3;
5569

@@ -70,6 +84,7 @@ export class ImageEdit extends React.Component {
7084
this.updateImageURL = this.updateImageURL.bind( this );
7185
this.onSetLinkDestination = this.onSetLinkDestination.bind( this );
7286
this.onSetNewTab = this.onSetNewTab.bind( this );
87+
this.onSetSizeSlug = this.onSetSizeSlug.bind( this );
7388
this.onImagePressed = this.onImagePressed.bind( this );
7489
this.onClearSettings = this.onClearSettings.bind( this );
7590
this.onFocusCaption = this.onFocusCaption.bind( this );
@@ -179,12 +194,19 @@ export class ImageEdit extends React.Component {
179194
this.props.setAttributes( updatedLinkTarget );
180195
}
181196

197+
onSetSizeSlug( sizeSlug ) {
198+
this.props.setAttributes( {
199+
sizeSlug,
200+
} );
201+
}
202+
182203
onClearSettings() {
183204
this.props.setAttributes( {
184205
alt: '',
185206
linkDestination: LINK_DESTINATION_NONE,
186207
href: undefined,
187208
linkTarget: undefined,
209+
sizeSlug: DEFAULT_SIZE_SLUG,
188210
rel: undefined,
189211
} );
190212
}
@@ -216,7 +238,7 @@ export class ImageEdit extends React.Component {
216238

217239
render() {
218240
const { attributes, isSelected } = this.props;
219-
const { url, height, width, alt, href, id, linkTarget } = attributes;
241+
const { url, height, width, alt, href, id, linkTarget, sizeSlug } = attributes;
220242

221243
const getToolbarEditButton = ( open ) => (
222244
<BlockControls>
@@ -249,6 +271,16 @@ export class ImageEdit extends React.Component {
249271
checked={ linkTarget === '_blank' }
250272
onChange={ this.onSetNewTab }
251273
/>
274+
{ // eslint-disable-next-line no-undef
275+
__DEV__ &&
276+
<SelectControl
277+
hideCancelButton
278+
icon={ 'editor-expand' }
279+
label={ __( 'Size' ) }
280+
value={ sizeOptionLabels[ sizeSlug || DEFAULT_SIZE_SLUG ] }
281+
onChangeValue={ ( newValue ) => this.onSetSizeSlug( newValue ) }
282+
options={ sizeOptions }
283+
/> }
252284
<TextControl
253285
icon={ 'editor-textcolor' }
254286
label={ __( 'Alt Text' ) }

packages/components/src/mobile/bottom-sheet/cell.native.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class BottomSheetCell extends Component {
4242
value,
4343
valuePlaceholder = '',
4444
icon,
45+
leftAlign,
4546
labelStyle = {},
4647
valueStyle = {},
4748
onChangeValue,
@@ -57,7 +58,10 @@ class BottomSheetCell extends Component {
5758
const isValueEditable = editable && onChangeValue !== undefined;
5859
const cellLabelStyle = getStylesFromColorScheme( styles.cellLabel, styles.cellTextDark );
5960
const cellLabelCenteredStyle = getStylesFromColorScheme( styles.cellLabelCentered, styles.cellTextDark );
60-
const defaultLabelStyle = showValue || icon !== undefined ? cellLabelStyle : cellLabelCenteredStyle;
61+
const cellLabelLeftAlignNoIconStyle = getStylesFromColorScheme( styles.cellLabelLeftAlignNoIcon, styles.cellTextDark );
62+
const defaultMissingIconAndValue = leftAlign ? cellLabelLeftAlignNoIconStyle : cellLabelCenteredStyle;
63+
const defaultLabelStyle = showValue || icon !== undefined ? cellLabelStyle : defaultMissingIconAndValue;
64+
6165
const drawSeparator = ( separatorType && separatorType !== 'none' ) || separatorStyle === undefined;
6266

6367
const onCellPress = () => {

packages/components/src/mobile/bottom-sheet/index.native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class BottomSheet extends Component {
136136
onBackdropPress={ this.props.onClose }
137137
onBackButtonPress={ this.props.onClose }
138138
onSwipe={ this.props.onClose }
139+
onDismiss={ Platform.OS === 'ios' ? this.props.onDismiss : undefined }
140+
onModalHide={ Platform.OS === 'android' ? this.props.onDismiss : undefined }
139141
swipeDirection="down"
140142
onMoveShouldSetResponder={ panResponder.panHandlers.onMoveShouldSetResponder }
141143
onMoveShouldSetResponderCapture={ panResponder.panHandlers.onMoveShouldSetResponderCapture }

packages/components/src/mobile/bottom-sheet/picker-cell.native.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Picker from '../picker';
77
export default function BottomSheetPickerCell( props ) {
88
const {
99
options,
10+
hideCancelButton,
1011
onChangeValue,
1112
...cellProps
1213
} = props;
@@ -24,6 +25,8 @@ export default function BottomSheetPickerCell( props ) {
2425
return (
2526
<Cell onPress={ onCellPress } editable={ false } { ...cellProps } >
2627
<Picker
28+
leftAlign
29+
hideCancelButton={ hideCancelButton }
2730
ref={ ( instance ) => picker = instance }
2831
options={ options }
2932
onChange={ onChange }

packages/components/src/mobile/bottom-sheet/styles.native.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
text-align: center;
121121
}
122122

123+
.cellLabelLeftAlignNoIcon {
124+
font-size: 17px;
125+
color: #2e4453;
126+
flex: 1;
127+
margin-left: 12px;
128+
}
129+
123130
.cellValue {
124131
font-size: 17px;
125132
color: #2e4453;

packages/components/src/mobile/picker/index.android.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class Picker extends Component {
5252
<BottomSheet.Cell
5353
icon={ option.icon }
5454
key={ index }
55+
leftAlign={ this.props.leftAlign }
5556
label={ option.label }
5657
separatorType={ 'none' }
5758
onPress={ () => this.onCellPress( option.value ) }

packages/components/src/mobile/picker/index.ios.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import { Component } from '@wordpress/element';
1111

1212
class Picker extends Component {
1313
presentPicker() {
14-
const { options, onChange } = this.props;
14+
const { options, onChange, title } = this.props;
1515
const labels = options.map( ( { label } ) => label );
1616
const fullOptions = [ __( 'Cancel' ) ].concat( labels );
1717

1818
ActionSheetIOS.showActionSheetWithOptions(
1919
{
20+
title,
2021
options: fullOptions,
2122
cancelButtonIndex: 0,
2223
},

0 commit comments

Comments
 (0)