Skip to content

Commit

Permalink
Split image captions
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 11, 2017
1 parent 075fe89 commit 852c84b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions blocks/library/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Placeholder from 'components/placeholder';
* Internal dependencies
*/
import './style.scss';
import { registerBlock, query } from '../../api';
import { registerBlock, createBlock, query } from '../../api';
import Editable from '../../editable';

const { attr, children } = query;
Expand Down Expand Up @@ -74,7 +74,7 @@ registerBlock( 'core/image', {
}
},

edit( { attributes, setAttributes, focus, setFocus } ) {
edit( { attributes, setAttributes, focus, setFocus, insertBlockAfter } ) {
const { url, alt, caption } = attributes;

if ( ! url ) {
Expand Down Expand Up @@ -106,6 +106,12 @@ registerBlock( 'core/image', {
onChange={ ( value ) => setAttributes( { caption: value } ) }
inline
inlineToolbar
onSplit={ ( before, after ) => {
setAttributes( { content: before } );
insertBlockAfter( createBlock( 'core/text', {
content: <p>{ after }</p>
} ) );
} }
/>
) : null }
</figure>
Expand Down

0 comments on commit 852c84b

Please sign in to comment.