Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions edit-post/components/text-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
}

// Always show outlines in code editor
.editor-post-title div,
.editor-post-text-editor {
.editor-post-title div {
border: 1px solid $light-gray-500;
}

Expand Down
37 changes: 27 additions & 10 deletions editor/components/post-text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import Textarea from 'react-autosize-textarea';
/**
* WordPress dependencies
*/
import { Component, compose } from '@wordpress/element';
import { parse } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/utils';
import { Component, compose, Fragment } from '@wordpress/element';
import { parse, withEditorSettings } from '@wordpress/blocks';
import { withSelect, withDispatch } from '@wordpress/data';
import { withInstanceId } from '@wordpress/components';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,15 +61,25 @@ class PostTextEditor extends Component {
}

render() {
const { value, placeholder, instanceId } = this.props;
const decodedPlaceholder = decodeEntities( placeholder );

return (
<Textarea
autoComplete="off"
value={ this.state.value || this.props.value }
onFocus={ this.startEditing }
onChange={ this.edit }
onBlur={ this.stopEditing }
className="editor-post-text-editor"
/>
<Fragment>
<label htmlFor={ `post-content-${ instanceId }` } className="screen-reader-text">
{ decodedPlaceholder || __( 'Write your story' ) }
</label>
<Textarea
autoComplete="off"
value={ this.state.value || value }
onFocus={ this.startEditing }
onChange={ this.edit }
onBlur={ this.stopEditing }
className="editor-post-text-editor"
id={ `post-content-${ instanceId }` }
placeholder={ decodedPlaceholder || __( 'Write your story' ) }
/>
</Fragment>
);
}
}
Expand All @@ -87,4 +100,8 @@ export default compose( [
},
};
} ),
withEditorSettings( ( settings ) => ( {
placeholder: settings.bodyPlaceholder,
} ) ),
withInstanceId,
] )( PostTextEditor );
10 changes: 7 additions & 3 deletions editor/components/post-text-editor/style.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
.editor-post-text-editor {
border: 1px solid $light-gray-500;
display: block;
margin: 0;
margin: 0 0 2em;
width: 100%;
border: none;
outline: none;
box-shadow: none;
resize: none;
overflow: hidden;
font-family: $editor-html-font;
font-size: $text-editor-font-size;
line-height: 150%;

&:hover,
&:focus {
border: 1px solid $light-gray-500;
box-shadow: none;
// Emulate the effect used on the post title.
outline: 1px solid $light-gray-500;
outline-offset: -2px;
}
}

Expand Down