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

List block: Add numbering type selection #51186

Merged
merged 8 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
24 changes: 22 additions & 2 deletions packages/block-library/src/list/ordered-list-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import { TextControl, PanelBody, ToggleControl } from '@wordpress/components';
import {
TextControl,
PanelBody,
ToggleControl,
SelectControl,
} from '@wordpress/components';

const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
const OrderedListSettings = ( { setAttributes, reversed, start, type } ) => (
<InspectorControls>
<PanelBody title={ __( 'Ordered list settings' ) }>
<TextControl
Expand All @@ -24,6 +29,21 @@ const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
value={ Number.isInteger( start ) ? start.toString( 10 ) : '' }
step="1"
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Numbering style' ) }
options={ [
{ value: '1', label: __( 'Numbers' ) },
{ value: 'A', label: __( 'Uppercase letters' ) },
{ value: 'a', label: __( 'Lowercase letters' ) },
{ value: 'I', label: __( 'Uppercase roman numerals' ) },
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
{ value: 'i', label: __( 'Lowercase roman numerals' ) },
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
] }
value={ type }
onChange={ ( newValue ) => {
setAttributes( { type: newValue } );
} }
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Reverse list numbering' ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- wp:list {"ordered":true,"type":"A"} -->
<ol type="A">
<!-- wp:list-item -->
<li>Item 1</li>
<!-- /wp:list-item -->
</ol>
<!-- /wp:list -->
21 changes: 21 additions & 0 deletions test/integration/fixtures/blocks/core__list__ol-with-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"name": "core/list",
"isValid": true,
"attributes": {
"ordered": true,
"values": "",
"type": "A"
},
"innerBlocks": [
{
"name": "core/list-item",
"isValid": true,
"attributes": {
"content": "Item 1"
},
"innerBlocks": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"blockName": "core/list",
"attrs": {
"ordered": true,
"type": "A"
},
"innerBlocks": [
{
"blockName": "core/list-item",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<li>Item 1</li>\n\t",
"innerContent": [ "\n\t<li>Item 1</li>\n\t" ]
}
],
"innerHTML": "\n<ol type=\"A\">\n\t\n</ol>\n",
"innerContent": [ "\n<ol type=\"A\">\n\t", null, "\n</ol>\n" ]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:list {"ordered":true,"type":"A"} -->
<ol type="A"><!-- wp:list-item -->
<li>Item 1</li>
<!-- /wp:list-item --></ol>
<!-- /wp:list -->