Skip to content

Commit

Permalink
Add underline button to mobile version.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioEstevao committed Sep 19, 2019
1 parent 264b178 commit 1ed9583
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Toolbar, Slot } from '@wordpress/components';
const FormatToolbar = () => {
return (
<Toolbar>
{ [ 'bold', 'italic', 'link' ].map( ( format ) =>
{ [ 'bold', 'italic', 'link', 'underline' ].map( ( format ) =>
<Slot name={ `RichText.ToolbarControls.${ format }` } key={ format } />
) }
<Slot name="RichText.ToolbarControls" />
Expand Down
2 changes: 2 additions & 0 deletions packages/format-library/src/default-formats.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { bold } from './bold';
import { italic } from './italic';
import { link } from './link';
import { strikethrough } from './strikethrough';
import { underline } from './underline';

export default [
bold,
italic,
link,
underline,
strikethrough,
];
14 changes: 12 additions & 2 deletions packages/format-library/src/underline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
import { __ } from '@wordpress/i18n';
import { toggleFormat } from '@wordpress/rich-text';
import { RichTextShortcut, __unstableRichTextInputEvent } from '@wordpress/block-editor';
import { RichTextToolbarButton, RichTextShortcut, __unstableRichTextInputEvent } from '@wordpress/block-editor';

const name = 'core/underline';
const title = __( 'Underline' );

export const underline = {
name,
Expand All @@ -15,7 +16,7 @@ export const underline = {
attributes: {
style: 'style',
},
edit( { value, onChange } ) {
edit( { isActive, value, onChange } ) {
const onToggle = () => {
onChange(
toggleFormat( value, {
Expand All @@ -33,6 +34,15 @@ export const underline = {
character="u"
onUse={ onToggle }
/>
<RichTextToolbarButton
name="underline"
icon="editor-underline"
title={ title }
onClick={ onToggle }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="u"
/>
<__unstableRichTextInputEvent
inputType="formatUnderline"
onInput={ onToggle }
Expand Down

0 comments on commit 1ed9583

Please sign in to comment.