Skip to content

Commit

Permalink
List block: Add numbering type selection (#51186)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Stine <alex.stine@yourtechadvisors.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 16, 2023
1 parent 8f9ab38 commit d481efb
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 -->

1 comment on commit d481efb

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in d481efb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5285823154
📝 Reported issues:

Please sign in to comment.