diff --git a/src/component/base/DraftEditor.react.js b/src/component/base/DraftEditor.react.js index 01553ce672..bb7f537563 100644 --- a/src/component/base/DraftEditor.react.js +++ b/src/component/base/DraftEditor.react.js @@ -286,6 +286,7 @@ class DraftEditor extends React.Component { editorKey={this._editorKey} editorState={this.props.editorState} key={'contents' + this.state.contentsKey} + textDirectionality={this.props.textDirectionality} /> diff --git a/src/component/base/DraftEditorProps.js b/src/component/base/DraftEditorProps.js index 7cf156b651..251e8cab1e 100644 --- a/src/component/base/DraftEditorProps.js +++ b/src/component/base/DraftEditorProps.js @@ -12,6 +12,7 @@ 'use strict'; +import type {BidiDirection} from 'UnicodeBidiDirection'; import type ContentBlock from 'ContentBlock'; import type {DraftBlockRenderMap} from 'DraftBlockRenderMap'; import type {DraftDragType} from 'DraftDragType'; @@ -51,6 +52,10 @@ export type DraftEditorProps = { // regardless of input characters. textAlignment?: DraftTextAlignment, + // Specify whether text directionality should be forced in a direction + // regardless of input characters. + textDirectionality?: BidiDirection, + // For a given `ContentBlock` object, return an object that specifies // a custom block component and/or props. If no object is returned, // the default `TextEditorBlock` is used. diff --git a/src/component/contents/DraftEditorContents.react.js b/src/component/contents/DraftEditorContents.react.js index 65ae81baad..6ead414019 100644 --- a/src/component/contents/DraftEditorContents.react.js +++ b/src/component/contents/DraftEditorContents.react.js @@ -29,6 +29,7 @@ type Props = { blockRendererFn: Function, blockStyleFn: (block: ContentBlock) => string, editorState: EditorState, + textDirectionality?: BidiDirection, }; /** @@ -123,7 +124,10 @@ class DraftEditorContents extends React.Component { customEditable = customRenderer.editable; } - const direction = directionMap.get(key); + const {textDirectionality} = this.props; + const direction = textDirectionality + ? textDirectionality + : directionMap.get(key); const offsetKey = DraftOffsetKey.encode(key, 0, 0); const componentProps = { contentState: content,