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

Commit 72f5e14

Browse files
committed
add indentation feature for the example of checkableList, and remove
mergeEntityData func
1 parent 1895bd8 commit 72f5e14

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
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

packages/utils/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ getLineCount(editorState: EditorState): number
143143
getWordCount(editorState: EditorState): number
144144
```
145145

146-
### mergeEntityData
147-
148-
```javascript
149-
mergeEntityData(editorState: EditorState, entityKey: string, data: Object): EditorState
150-
```
151-
152146
## License
153147

154148
MIT © [juliankrispel](https://github.com/juliankrispel)

packages/utils/src/index.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,3 @@ export function getWordCount(editorState: EditorState): number {
266266
const wordArray = cleanString.match(/\S+/g) // matches words according to whitespace
267267
return wordArray ? wordArray.length : 0
268268
}
269-
270-
export function mergeEntityData(
271-
editorState: EditorState,
272-
entityKey: string,
273-
data: Object
274-
): EditorState {
275-
const newContentState = editorState
276-
.getCurrentContent()
277-
.mergeEntityData(entityKey, data)
278-
279-
return EditorState.push(editorState, newContentState, 'apply-entity')
280-
}

0 commit comments

Comments
 (0)