Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit e98e91e

Browse files
mitermayerfacebook-github-bot
authored andcommitted
3/n Splitting PR #1828: updates to the Rich Text Editor example (#1828)
Summary: Splitting up this PR and updating it as I do. This piece was an update to the Rich Text Editor example. This is directly taken from mitermayer 's fork, props to him Pull Request resolved: #1828 Reviewed By: mitermayer Differential Revision: D9181983 Pulled By: mitermayer fbshipit-source-id: aa2b66cb87123f96c3cd9cde19eb0fa86ff47c51
1 parent a399e43 commit e98e91e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

examples/draft-0-10-0/playground/src/DraftJsRichEditorExample.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ import React, {Component} from 'react';
99

1010
import {Editor, RichUtils, getDefaultKeyBinding} from 'draft-js';
1111

12+
import gkx from 'draft-js/lib/gkx';
13+
import NestedRichTextEditorUtil from 'draft-js/lib/NestedRichTextEditorUtil';
14+
1215
import './DraftJsRichEditorExample.css';
1316

17+
const RichTextUtils = gkx('draft_tree_data_support')
18+
? NestedRichTextEditorUtil
19+
: RichUtils;
20+
1421
class DraftJsRichEditorExample extends Component {
1522
constructor(props) {
1623
super(props);
@@ -23,7 +30,7 @@ class DraftJsRichEditorExample extends Component {
2330
}
2431

2532
_handleKeyCommand(command, editorState) {
26-
const newState = RichUtils.handleKeyCommand(editorState, command);
33+
const newState = RichTextUtils.handleKeyCommand(editorState, command);
2734
if (newState) {
2835
this.onChange(newState);
2936
return true;
@@ -33,7 +40,7 @@ class DraftJsRichEditorExample extends Component {
3340

3441
_mapKeyToEditorCommand(e) {
3542
if (e.keyCode === 9 /* TAB */) {
36-
const newEditorState = RichUtils.onTab(
43+
const newEditorState = RichTextUtils.onTab(
3744
e,
3845
this.props.editorState,
3946
4 /* maxDepth */,
@@ -47,12 +54,14 @@ class DraftJsRichEditorExample extends Component {
4754
}
4855

4956
_toggleBlockType(blockType) {
50-
this.onChange(RichUtils.toggleBlockType(this.props.editorState, blockType));
57+
this.onChange(
58+
RichTextUtils.toggleBlockType(this.props.editorState, blockType),
59+
);
5160
}
5261

5362
_toggleInlineStyle(inlineStyle) {
5463
this.onChange(
55-
RichUtils.toggleInlineStyle(this.props.editorState, inlineStyle),
64+
RichTextUtils.toggleInlineStyle(this.props.editorState, inlineStyle),
5665
);
5766
}
5867

0 commit comments

Comments
 (0)