From 761e503b84e23aac3285f7ecdeaf0e7f901b17c8 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Mon, 25 Nov 2019 11:42:54 +0000 Subject: [PATCH 1/4] Add list props to rich text in native. --- .../block-editor/src/components/rich-text/index.js | 2 ++ .../src/list/ordered-list-settings.native.js | 3 --- packages/rich-text/src/component/index.native.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) delete mode 100644 packages/block-library/src/list/ordered-list-settings.native.js diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js index e433c89eafd24f..7b4af55b49c5c8 100644 --- a/packages/block-editor/src/components/rich-text/index.js +++ b/packages/block-editor/src/components/rich-text/index.js @@ -398,6 +398,8 @@ class RichTextWrapper extends Component { __unstableDidAutomaticChange={ didAutomaticChange } __unstableUndo={ undo } style={ style } + start={ start } + reversed={ reversed } > { ( { isSelected, value, onChange, Editable } ) => <> diff --git a/packages/block-library/src/list/ordered-list-settings.native.js b/packages/block-library/src/list/ordered-list-settings.native.js deleted file mode 100644 index 43bab31a4330eb..00000000000000 --- a/packages/block-library/src/list/ordered-list-settings.native.js +++ /dev/null @@ -1,3 +0,0 @@ -// Mobile has no additional list settings at this time, so render nothing -const AdditionalSettings = () => null; -export default AdditionalSettings; diff --git a/packages/rich-text/src/component/index.native.js b/packages/rich-text/src/component/index.native.js index 0af666459641e5..5f12377f700fe8 100644 --- a/packages/rich-text/src/component/index.native.js +++ b/packages/rich-text/src/component/index.native.js @@ -600,7 +600,16 @@ export class RichText extends Component { } if ( tagName ) { - value = `<${ tagName }>${ value }`; + let extraAttributes = ``; + if ( tagName === `ol` ) { + if ( this.props.reversed ) { + extraAttributes += ` reversed`; + } + if ( this.props.start ) { + extraAttributes += ` start=${ this.props.start }`; + } + } + value = `<${ tagName } ${ extraAttributes }>${ value }`; } return value; } From 23e472872d0cb05554db78cad014da688e1deb6a Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 27 Nov 2019 13:41:35 +0000 Subject: [PATCH 2/4] Make sure we remove root tags with extra attributes too --- packages/rich-text/src/component/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/index.native.js b/packages/rich-text/src/component/index.native.js index 5f12377f700fe8..41b2391f7f9aad 100644 --- a/packages/rich-text/src/component/index.native.js +++ b/packages/rich-text/src/component/index.native.js @@ -218,7 +218,7 @@ export class RichText extends Component { } removeRootTag( tag, html ) { - const openingTagRegexp = RegExp( '^<' + tag + '>', 'gim' ); + const openingTagRegexp = RegExp( '^<' + tag + '[^>]*>', 'gim' ); const closingTagRegexp = RegExp( '$', 'gim' ); return html.replace( openingTagRegexp, '' ).replace( closingTagRegexp, '' ); } From 2fc6d6d45f440fd451b7e5cc36a73cb6203bf470 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 27 Nov 2019 14:26:52 +0000 Subject: [PATCH 3/4] Adapt the keyboard of the control depending of the type of the control. --- .../src/mobile/bottom-sheet/cell.native.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/components/src/mobile/bottom-sheet/cell.native.js b/packages/components/src/mobile/bottom-sheet/cell.native.js index a0da5b6bb3d12a..f8ab0b445be771 100644 --- a/packages/components/src/mobile/bottom-sheet/cell.native.js +++ b/packages/components/src/mobile/bottom-sheet/cell.native.js @@ -57,6 +57,18 @@ class BottomSheetCell extends Component { this.setState( { isScreenReaderEnabled } ); } + typeToKeyboardType( type, step ) { + let keyboardType = `default`; + if ( type === `number` ) { + if ( step && Math.abs( step ) < 1 ) { + keyboardType = `decimal-pad`; + } else { + keyboardType = `number-pad`; + } + } + return keyboardType; + } + render() { const { accessible, @@ -80,6 +92,8 @@ class BottomSheetCell extends Component { style = {}, getStylesFromColorScheme, customActionButton, + type, + step, ...valueProps } = this.props; @@ -156,6 +170,7 @@ class BottomSheetCell extends Component { pointerEvents={ this.state.isEditingValue ? 'auto' : 'none' } onFocus={ startEditing } onBlur={ finishEditing } + keyboardType={ this.typeToKeyboardType( type, step ) } { ...valueProps } /> ) : ( From bff7d165982da86fb938c151e0c08abd8a31af3c Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 27 Nov 2019 14:29:45 +0000 Subject: [PATCH 4/4] Make sure component refresh when props start/reversed change. --- packages/rich-text/src/component/index.native.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/index.native.js b/packages/rich-text/src/component/index.native.js index 41b2391f7f9aad..723149b3ccf0f2 100644 --- a/packages/rich-text/src/component/index.native.js +++ b/packages/rich-text/src/component/index.native.js @@ -491,7 +491,9 @@ export class RichText extends Component { } shouldComponentUpdate( nextProps ) { - if ( nextProps.tagName !== this.props.tagName ) { + if ( nextProps.tagName !== this.props.tagName || + nextProps.reversed !== this.props.reversed || + nextProps.start !== this.props.start ) { this.lastEventCount = undefined; this.value = undefined; return true;