Skip to content

Commit

Permalink
List block: Add numbering type selection (WordPress#51186)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Stine <[email protected]>
Co-authored-by: Ramon <[email protected]>
  • Loading branch information
3 people authored and sethrubenstein committed Jul 13, 2023
1 parent d50ea6d commit 51abe94
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
22 changes: 20 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,19 @@ 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' ) },
{ value: 'i', label: __( 'Lowercase Roman numerals' ) },
] }
value={ type }
onChange={ ( newValue ) => setAttributes( { type: newValue } ) }
/>
<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 -->

0 comments on commit 51abe94

Please sign in to comment.