Skip to content

Commit

Permalink
RichText: warn when using inline container
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Feb 18, 2019
1 parent 5dc9ac4 commit a5d3151
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { RemoveBrowserShortcuts } from './remove-browser-shortcuts';
* Browser dependencies
*/

const { getSelection } = window;
const { getSelection, getComputedStyle } = window;

export class RichText extends Component {
constructor( { value, onReplace, multiline } ) {
Expand Down Expand Up @@ -136,7 +136,17 @@ export class RichText extends Component {
}

setRef( node ) {
this.editableRef = node;
if ( node ) {
const computedStyle = getComputedStyle( node );

if ( computedStyle.display === 'inline' ) {
window.console.warn( 'RichText cannot be used with an inline container. Please use a different tagName.' );
}

this.editableRef = node;
} else {
delete this.editableRef;
}
}

setFocusedElement() {
Expand Down

0 comments on commit a5d3151

Please sign in to comment.