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

[RNMobile] update mobile to not use ListEdit #17070

Merged
merged 3 commits into from
Aug 20, 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
12 changes: 2 additions & 10 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ import Autocomplete from '../autocomplete';
import BlockFormatControls from '../block-format-controls';
import FormatToolbar from './format-toolbar';
import { withBlockEditContext } from '../block-edit/context';
import { ListEdit } from './list-edit';

const wrapperClasses = 'editor-rich-text block-editor-rich-text';
const classes = 'editor-rich-text__editable block-editor-rich-text__editable';

function RichTextWraper( {
children,
tagName,
value: originalValue,
onChange: originalOnChange,
selectionStart,
selectionEnd,
onSelectionChange,
multiline,
onTagNameChange,
inlineToolbar,
wrapperClassName,
className,
Expand Down Expand Up @@ -86,14 +85,7 @@ function RichTextWraper( {
>
{ ( { isSelected, value, onChange } ) =>
<View>
{ isSelected && multiline === 'li' && (
<ListEdit
onTagNameChange={ onTagNameChange }
tagName={ tagName }
value={ value }
onChange={ onChange }
/>
) }
{ children && children( { value, onChange } ) }
{ isSelected && ! inlineToolbar && (
<BlockFormatControls>
<FormatToolbar />
Expand Down
43 changes: 8 additions & 35 deletions packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import {
RichText,
BlockControls,
RichTextShortcut,
InspectorControls,
} from '@wordpress/block-editor';
import {
Toolbar,
TextControl,
PanelBody,
ToggleControl,
} from '@wordpress/components';
import {
__unstableIndentListItems as indentListItems,
Expand All @@ -27,6 +23,7 @@ import {
* Internal dependencies
*/
import { name } from './';
import OrderedListSettings from './ordered-list-settings';

export default function ListEdit( {
attributes,
Expand Down Expand Up @@ -141,36 +138,12 @@ export default function ListEdit( {
>
{ controls }
</RichText>
{ ordered &&
<InspectorControls>
<PanelBody title={ __( 'Ordered List Settings' ) }>
<TextControl
label={ __( 'Start Value' ) }
type="number"
onChange={ ( value ) => {
const int = parseInt( value, 10 );

setAttributes( {
// It should be possible to unset the value,
// e.g. with an empty string.
start: isNaN( int ) ? undefined : int,
} );
} }
value={ Number.isInteger( start ) ? start.toString( 10 ) : '' }
step="1"
/>
<ToggleControl
label={ __( 'Reverse List Numbering' ) }
checked={ reversed || false }
onChange={ ( value ) => {
setAttributes( {
// Unset the attribute if not reversed.
reversed: value || undefined,
} );
} }
/>
</PanelBody>
</InspectorControls>
}
{ ordered && (
<OrderedListSettings
setAttributes={ setAttributes }
ordered={ ordered }
reversed={ reversed }
start={ start }
/> ) }
</>;
}
43 changes: 43 additions & 0 deletions packages/block-library/src/list/ordered-list-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import {
TextControl,
PanelBody,
ToggleControl,
} from '@wordpress/components';

const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
<InspectorControls>
<PanelBody title={ __( 'Ordered List Settings' ) }>
<TextControl
label={ __( 'Start Value' ) }
type="number"
onChange={ ( value ) => {
const int = parseInt( value, 10 );

setAttributes( {
// It should be possible to unset the value,
// e.g. with an empty string.
start: isNaN( int ) ? undefined : int,
} );
} }
value={ Number.isInteger( start ) ? start.toString( 10 ) : '' }
step="1"
/>
<ToggleControl
label={ __( 'Reverse List Numbering' ) }
checked={ reversed || false }
onChange={ ( value ) => {
setAttributes( {
// Unset the attribute if not reversed.
reversed: value || undefined,
} );
} }
/>
</PanelBody>
</InspectorControls> );

export default OrderedListSettings;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Mobile has no additional list settings at this time, so render nothing
const AdditionalSettings = () => null;
export default AdditionalSettings;