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

Commit

Permalink
3/n Splitting PR #1828: updates to the Rich Text Editor example (#1828)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mitermayer authored and facebook-github-bot committed Aug 6, 2018
1 parent a399e43 commit e98e91e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/draft-0-10-0/playground/src/DraftJsRichEditorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import React, {Component} from 'react';

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

import gkx from 'draft-js/lib/gkx';
import NestedRichTextEditorUtil from 'draft-js/lib/NestedRichTextEditorUtil';

import './DraftJsRichEditorExample.css';

const RichTextUtils = gkx('draft_tree_data_support')
? NestedRichTextEditorUtil
: RichUtils;

class DraftJsRichEditorExample extends Component {
constructor(props) {
super(props);
Expand All @@ -23,7 +30,7 @@ class DraftJsRichEditorExample extends Component {
}

_handleKeyCommand(command, editorState) {
const newState = RichUtils.handleKeyCommand(editorState, command);
const newState = RichTextUtils.handleKeyCommand(editorState, command);
if (newState) {
this.onChange(newState);
return true;
Expand All @@ -33,7 +40,7 @@ class DraftJsRichEditorExample extends Component {

_mapKeyToEditorCommand(e) {
if (e.keyCode === 9 /* TAB */) {
const newEditorState = RichUtils.onTab(
const newEditorState = RichTextUtils.onTab(
e,
this.props.editorState,
4 /* maxDepth */,
Expand All @@ -47,12 +54,14 @@ class DraftJsRichEditorExample extends Component {
}

_toggleBlockType(blockType) {
this.onChange(RichUtils.toggleBlockType(this.props.editorState, blockType));
this.onChange(
RichTextUtils.toggleBlockType(this.props.editorState, blockType),
);
}

_toggleInlineStyle(inlineStyle) {
this.onChange(
RichUtils.toggleInlineStyle(this.props.editorState, inlineStyle),
RichTextUtils.toggleInlineStyle(this.props.editorState, inlineStyle),
);
}

Expand Down

0 comments on commit e98e91e

Please sign in to comment.