-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Text: add drop cap support #1189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c51f524
f09458e
49ac22d
2b98530
30dbbb1
d8a83c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ 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'; | ||
| import Toggle from 'components/form-toggle'; | ||
|
|
||
| const { children } = query; | ||
|
|
||
|
|
@@ -31,8 +33,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 && ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible alternative to creating single combined focus && ...[
<BlockControls key="controls">
<AlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
/>
</BlockControls>,
<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>
],
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something we'll need to pick a model and apply consistently, because people will start using as examples. I personally don't like the arrays much and prefer a single element tree.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fairness, it's already an array 😄 |
||
| <BlockControls key="controls"> | ||
|
|
@@ -44,6 +46,11 @@ registerBlockType( 'core/text', { | |
| /> | ||
| </BlockControls> | ||
| ), | ||
| focus && ( | ||
| <InspectorControls> | ||
| <Toggle checked={ !! dropCap } onChange={ toggleDropCap } /> | ||
|
||
| </InspectorControls> | ||
| ), | ||
| <Editable | ||
| key="editable" | ||
| value={ content } | ||
|
|
@@ -62,6 +69,7 @@ registerBlockType( 'core/text', { | |
| } } | ||
| onMerge={ mergeBlocks } | ||
| style={ { textAlign: align } } | ||
| className={ `drop-cap-${ dropCap }` } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a modifier class on Editable? className={ classnames( { 'has-drop-cap': dropCap } ) }.blocks-editable.has-drop-cap .blocks-editable__tinymce:not( :focus ) {Or better yet, a prop on the component if it's Editable's own styles responsible for creating the effect?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, plan is to turn it into |
||
| />, | ||
| ]; | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs in "WordPress dependencies"