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 2 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
44 changes: 44 additions & 0 deletions packages/block-library/src/list/additional-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import {
TextControl,
PanelBody,
ToggleControl,
} from '@wordpress/components';

const AdditionalSettings = ( { setAttributes, ordered, reversed, start } ) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion: perhaps call it OrderedListSettings and move the ordered check?

Copy link
Contributor Author

@mchowning mchowning Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that much better. Thanks for the suggestion!

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> );

export default AdditionalSettings;
3 changes: 3 additions & 0 deletions packages/block-library/src/list/additional-settings.native.js
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;
42 changes: 7 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 AdditionalSettings from './additional-settings';

export default function ListEdit( {
attributes,
Expand Down Expand Up @@ -141,36 +138,11 @@ 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>
}
<AdditionalSettings
setAttributes={ setAttributes }
ordered={ ordered }
reversed={ reversed }
start={ start }
/>
</>;
}