Skip to content

Commit

Permalink
Merge pull request #1189 from WordPress/add/drop-cap-support
Browse files Browse the repository at this point in the history
Text: add drop cap support
  • Loading branch information
mtias authored Jun 15, 2017
2 parents 5069c7d + d8a83c0 commit c521550
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
13 changes: 13 additions & 0 deletions blocks/editable/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
}
}

.drop-cap-true .blocks-editable__tinymce:not( :focus ) {
&:first-letter {
float: left;
font-size: 4.1em;
line-height: 0.7;
font-family: serif;
font-weight: bold;
margin: .07em .23em 0 0;
text-transform: uppercase;
font-style: normal;
}
}

.block-editable__inline-toolbar {
display: flex;
justify-content: center;
Expand Down
22 changes: 19 additions & 3 deletions blocks/library/text/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/**
* WordPress dependencies
*/
import { __ } from 'i18n';
import { Children, cloneElement } from 'element';
import Toggle from 'components/form-toggle';

/**
* Internal dependencies
Expand All @@ -10,11 +12,12 @@ import { registerBlockType, createBlock, query, setDefaultBlock } from '../../ap
import AlignmentToolbar from '../../alignment-toolbar';
import BlockControls from '../../block-controls';
import Editable from '../../editable';
import InspectorControls from '../../inspector-controls';

const { children } = query;

registerBlockType( 'core/text', {
title: wp.i18n.__( 'Text' ),
title: __( 'Text' ),

icon: 'text',

Expand All @@ -31,8 +34,8 @@ registerBlockType( 'core/text', {
},

edit( { attributes, setAttributes, insertBlockAfter, focus, setFocus, mergeBlocks } ) {
const { align, content } = attributes;

const { align, content, dropCap } = attributes;
const toggleDropCap = () => setAttributes( { dropCap: ! dropCap } );
return [
focus && (
<BlockControls key="controls">
Expand All @@ -44,6 +47,18 @@ registerBlockType( 'core/text', {
/>
</BlockControls>
),
focus && (
<InspectorControls key="inspector">
<div className="blocks-text__drop-cap" style={ { display: 'flex', justifyContent: 'space-between' } }>
<label htmlFor="blocks-text__drop-cap">{ __( 'Drop Cap' ) }</label>
<Toggle
checked={ !! dropCap }
onChange={ toggleDropCap }
id="blocks-text__drop-cap-toggle"
/>
</div>
</InspectorControls>
),
<Editable
key="editable"
value={ content }
Expand All @@ -62,6 +77,7 @@ registerBlockType( 'core/text', {
} }
onMerge={ mergeBlocks }
style={ { textAlign: align } }
className={ `drop-cap-${ dropCap }` }
/>,
];
},
Expand Down

0 comments on commit c521550

Please sign in to comment.