diff --git a/README.md b/README.md index f54bcee..76b0691 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ In this editor we use a pure, deterministic function to convert document state t * `autoFocus`: Setting this to true will automatically focus input into the editor when the component is mounted * `placeholder`: A string to use as placeholder text for the `RichTextEditor`. * `readOnly`: A boolean that determines if the `RichTextEditor` should render static html. - * `enableSoftNewLineByDefault`: Set this to `true` if you wish to use soft line breaks when only pressing the return key. By default, if you press the return/enter key it will create a new text block. If you don't set this value to `true`, the user may use one of several [designated keys](https://github.com/facebook/draft-js/blob/cf9be24e8b14419143f1f01aabc68ed1be2f95e4/src/component/utils/isSoftNewlineEvent.js#L16) while pressing the return key to create a soft new line. + * `disableSoftNewLine`: Set this to `true` if you wish to always to a new text block when pressing the return key. Otherwise, the user may use one of several [designated keys](https://github.com/facebook/draft-js/blob/cf9be24e8b14419143f1f01aabc68ed1be2f95e4/src/component/utils/isSoftNewlineEvent.js#L16) while pressing the return key to create a soft new line. ### EditorValue Class In Draft.js `EditorState` contains not only the document contents but the entire state of the editor including cursor position and selection. This is helpful for many reasons including undo/redo. To make things easier for you, we have wrapped the state of the editor in an `EditorValue` instance with helpful methods to convert to/from a HTML or Markdown. An instance of this class should be passed to `RichTextEditor` in the `value` prop. diff --git a/src/RichTextEditor.js b/src/RichTextEditor.js index 8af9d6a..b096ed1 100644 --- a/src/RichTextEditor.js +++ b/src/RichTextEditor.js @@ -66,6 +66,7 @@ type Props = { editorStyle?: Object; toolbarStyle?: Object; onBlur?: (event: Object) => void; + disableSoftNewLine?: boolean; }; export default class RichTextEditor extends Component { @@ -197,6 +198,9 @@ export default class RichTextEditor extends Component { // `shift + return` should insert a soft newline. _handleReturnSoftNewline(event: Object): boolean { + if (this.props.disableSoftNewLine) { + return false; + } let editorState = this.props.value.getEditorState(); if (isSoftNewlineEvent(event)) { let selection = editorState.getSelection();