Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
add indentation feature for the example of checkableList, and remove
Browse files Browse the repository at this point in the history
mergeEntityData func
  • Loading branch information
freedomlang committed Apr 16, 2019
1 parent 0f15c04 commit f5279e3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/checkable-list-example/src/CheckableList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CheckableListItemBlock,
CHECKABLE_LIST_ITEM,
blockRenderMap,
CheckableListItemUtils,
} from 'draft-js-checkable-list-item'

class CheckableList extends Component<PluginProps> {
Expand Down Expand Up @@ -50,6 +51,27 @@ class CheckableList extends Component<PluginProps> {
setEditorState(newEditorState)
}

handleTab = (event: SyntheticKeyboardEvent): ?boolean => {
if (this.adjustBlockDepth(event)) {
return true
}
const { editorState, setEditorState } = this.props
const newEditorState = RichUtils.onTab(event, editorState, 4)
if (newEditorState !== editorState) {
setEditorState(newEditorState)
}
}

adjustBlockDepth(event: SyntheticKeyboardEvent): boolean {
const { editorState, setEditorState } = this.props
const newEditorState = CheckableListItemUtils.onTab(event, editorState, 4)
if (newEditorState !== editorState) {
setEditorState(newEditorState)
return true
}
return false
}

componentDidMount() {
const { registerPlugin } = this.props

Expand All @@ -71,6 +93,7 @@ class CheckableList extends Component<PluginProps> {
return CHECKABLE_LIST_ITEM
}
},
// handleTab: this.handleTab
})
}

Expand Down

0 comments on commit f5279e3

Please sign in to comment.