Skip to content

Commit 76d62e7

Browse files
committed
Add "inline" prop to Editable component
1 parent 1cb599d commit 76d62e7

File tree

9 files changed

+41
-23
lines changed

9 files changed

+41
-23
lines changed

blocks/components/editable/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,16 @@ export default class Editable extends wp.element.Component {
320320
}
321321

322322
render() {
323-
const { tagName, style, value, focus, className, showAlignments = false, formattingControls } = this.props;
323+
const {
324+
tagName,
325+
style,
326+
value,
327+
focus,
328+
className,
329+
showAlignments = false,
330+
inline,
331+
formattingControls
332+
} = this.props;
324333
const classes = classnames( 'blocks-editable', className );
325334

326335
// Generating a key that includes `tagName` ensures that if the tag
@@ -335,6 +344,9 @@ export default class Editable extends wp.element.Component {
335344
style={ style }
336345
className={ classes }
337346
defaultValue={ value }
347+
settings={ {
348+
forced_root_block: inline ? false : 'p'
349+
} }
338350
key={ key } />
339351
);
340352

blocks/components/editable/style.scss

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ figcaption.blocks-editable {
2626
margin-top: 0.5em;
2727
color: $dark-gray-100;
2828
text-align: center;
29-
30-
p {
31-
font-size: $default-font-size;
32-
}
29+
font-size: $default-font-size;
3330
}
3431

3532

blocks/components/editable/tinymce.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default class TinyMCE extends wp.element.Component {
2121
}
2222

2323
initialize() {
24+
const { settings, focus } = this.props;
25+
2426
tinymce.init( {
2527
target: this.editorNode,
2628
theme: false,
@@ -35,10 +37,11 @@ export default class TinyMCE extends wp.element.Component {
3537
},
3638
formats: {
3739
strikethrough: { inline: 'del' }
38-
}
40+
},
41+
...settings
3942
} );
4043

41-
if ( this.props.focus ) {
44+
if ( focus ) {
4245
this.editorNode.focus();
4346
}
4447
}

blocks/library/button/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ registerBlock( 'core/button', {
7474
value={ text }
7575
onFocus={ setFocus }
7676
onChange={ ( value ) => setAttributes( { text: value } ) }
77+
inline
7778
/>
7879
{ focus &&
7980
<form

blocks/library/embed/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ registerBlock( 'core/embed', {
5555
value={ caption }
5656
focus={ focus }
5757
onFocus={ setFocus }
58-
onChange={ ( value ) => setAttributes( { caption: value } ) } />
58+
onChange={ ( value ) => setAttributes( { caption: value } ) }
59+
inline
60+
/>
5961
) : null }
6062
</figure>
6163
);

blocks/library/heading/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ registerBlock( 'core/heading', {
104104
onFocus={ setFocus }
105105
onChange={ ( value ) => setAttributes( { content: value } ) }
106106
onMerge={ mergeWithPrevious }
107+
inline
107108
/>
108109
);
109110
},

blocks/library/image/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ registerBlock( 'core/image', {
101101
value={ caption }
102102
focus={ focus }
103103
onFocus={ setFocus }
104-
onChange={ ( value ) => setAttributes( { caption: value } ) } />
104+
onChange={ ( value ) => setAttributes( { caption: value } ) }
105+
inline
106+
/>
105107
) : null }
106108
</figure>
107109
);

blocks/library/quote/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ registerBlock( 'core/quote', {
121121
showAlignments
122122
/>
123123
{ ( citation || !! focus ) && (
124-
<footer>
125-
<Editable
126-
value={ citation }
127-
onChange={
128-
( nextCitation ) => setAttributes( {
129-
citation: nextCitation
130-
} )
131-
}
132-
focus={ focusedEditable === 'citation' ? focus : null }
133-
onFocus={ () => setFocus( { editable: 'citation' } ) }
134-
/>
135-
</footer>
124+
<Editable
125+
tagName="footer"
126+
value={ citation }
127+
onChange={
128+
( nextCitation ) => setAttributes( {
129+
citation: nextCitation
130+
} )
131+
}
132+
focus={ focusedEditable === 'citation' ? focus : null }
133+
onFocus={ () => setFocus( { editable: 'citation' } ) }
134+
inline
135+
/>
136136
) }
137137
</blockquote>
138138
);

post-content.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ window._wpGutenbergPost = {
7474
'<!-- /wp:core/text -->',
7575

7676
'<!-- wp:core/quote style="1" -->',
77-
'<blockquote class="blocks-quote-style-1"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer><p>Matt Mullenweg, 2017</p></footer></blockquote>',
77+
'<blockquote class="blocks-quote-style-1"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><footer>Matt Mullenweg, 2017</footer></blockquote>',
7878
'<!-- /wp:core/quote -->',
7979

8080
'<!-- wp:core/text -->',
@@ -86,7 +86,7 @@ window._wpGutenbergPost = {
8686
'<!-- /wp:core/text -->',
8787

8888
'<!-- wp:core/quote style="2" -->',
89-
'<blockquote class="blocks-quote-style-2"><p>There is no greater agony than bearing an untold story inside you.</p><footer><p>Maya Angelou</p></footer></blockquote>',
89+
'<blockquote class="blocks-quote-style-2"><p>There is no greater agony than bearing an untold story inside you.</p><footer>Maya Angelou</footer></blockquote>',
9090
'<!-- /wp:core/quote -->',
9191

9292
'<!-- wp:core/separator -->',

0 commit comments

Comments
 (0)