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

Commit f5279e3

Browse files
committed
add indentation feature for the example of checkableList, and remove
mergeEntityData func
1 parent 0f15c04 commit f5279e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/checkable-list-example/src/CheckableList.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
CheckableListItemBlock,
1616
CHECKABLE_LIST_ITEM,
1717
blockRenderMap,
18+
CheckableListItemUtils,
1819
} from 'draft-js-checkable-list-item'
1920

2021
class CheckableList extends Component<PluginProps> {
@@ -50,6 +51,27 @@ class CheckableList extends Component<PluginProps> {
5051
setEditorState(newEditorState)
5152
}
5253

54+
handleTab = (event: SyntheticKeyboardEvent): ?boolean => {
55+
if (this.adjustBlockDepth(event)) {
56+
return true
57+
}
58+
const { editorState, setEditorState } = this.props
59+
const newEditorState = RichUtils.onTab(event, editorState, 4)
60+
if (newEditorState !== editorState) {
61+
setEditorState(newEditorState)
62+
}
63+
}
64+
65+
adjustBlockDepth(event: SyntheticKeyboardEvent): boolean {
66+
const { editorState, setEditorState } = this.props
67+
const newEditorState = CheckableListItemUtils.onTab(event, editorState, 4)
68+
if (newEditorState !== editorState) {
69+
setEditorState(newEditorState)
70+
return true
71+
}
72+
return false
73+
}
74+
5375
componentDidMount() {
5476
const { registerPlugin } = this.props
5577

@@ -71,6 +93,7 @@ class CheckableList extends Component<PluginProps> {
7193
return CHECKABLE_LIST_ITEM
7294
}
7395
},
96+
// handleTab: this.handleTab
7497
})
7598
}
7699

0 commit comments

Comments
 (0)