Skip to content

Commit

Permalink
Lighter block DOM: List (#20498)
Browse files Browse the repository at this point in the history
* Lighter block DOM: List

* Fix space key
  • Loading branch information
ellatrix committed Mar 4, 2020
1 parent 2446adb commit e69f2ab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const BlockComponent = forwardRef(
}
);

const elements = [ 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ];
const elements = [ 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul' ];

const ExtendedBlockComponent = elements.reduce( ( acc, element ) => {
acc[ element ] = forwardRef( ( props, ref ) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
RichText,
BlockControls,
RichTextShortcut,
__experimentalBlock as Block,
} from '@wordpress/block-editor';
import { ToolbarGroup } from '@wordpress/components';
import {
Expand Down Expand Up @@ -146,7 +147,8 @@ export default function ListEdit( {
<RichText
identifier="values"
multiline="li"
tagName={ tagName }
__unstableMultilineRootTag={ tagName }
tagName={ Block[ tagName ] }
onChange={ ( nextValues ) =>
setAttributes( { values: nextValues } )
}
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const settings = {
supports: {
className: false,
__unstablePasteTextInline: true,
lightBlockWrapper: true,
},
example: {
attributes: {
Expand Down
7 changes: 5 additions & 2 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,10 @@ class RichText extends Component {
*/
handleSpace( event ) {
const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event;
const { tagName, __unstableMultilineTag: multilineTag } = this.props;
const {
__unstableMultilineRootTag: multilineRootTag,
__unstableMultilineTag: multilineTag,
} = this.props;

if (
// Only override when no modifiers are pressed.
Expand Down Expand Up @@ -797,7 +800,7 @@ class RichText extends Component {
return;
}

this.onChange( indentListItems( value, { type: tagName } ) );
this.onChange( indentListItems( value, { type: multilineRootTag } ) );
event.preventDefault();
}

Expand Down

0 comments on commit e69f2ab

Please sign in to comment.