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

Commit 88da2b0

Browse files
Merge pull request #28 from draft-js-plugins/docs/utils
Update docs for utils
2 parents 58e7b19 + 40d71b8 commit 88da2b0

File tree

4 files changed

+2039
-2074
lines changed

4 files changed

+2039
-2074
lines changed

packages/utils/README.md

Lines changed: 109 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,118 @@
1111
npm install --save @djsp/utils
1212
```
1313

14-
## Usage
14+
## Static Methods
1515

16-
```jsx
17-
import React, { Component } from 'react'
16+
### replaceWithAtomicBlock
1817

19-
import MyComponent from '@djsp/utils'
18+
```javascript
19+
replaceWithAtomicBlock(
20+
editorState: EditorState,
21+
entityType: string,
22+
data: Object
23+
): EditorState
24+
```
25+
26+
### insertEntityBlock
27+
28+
```javascript
29+
insertEntityBlock(
30+
editorState: EditorState,
31+
entityType: string,
32+
data: Object
33+
): EditorState
34+
```
35+
36+
### createEntityDecorator
37+
38+
```javascript
39+
createEntityDecorator(
40+
entityName: string,
41+
component: Function,
42+
props?: Object
43+
): DraftDecorator
44+
```
45+
46+
### insertTextWithEntity
47+
48+
```javascript
49+
insertTextWithEntity(
50+
contentState: ContentState,
51+
selection: SelectionState,
52+
entityType: string,
53+
text: string,
54+
mutability?: 'IMMUTABLE' | 'MUTABLE' | 'SEGMENTED',
55+
entityData?: Object
56+
): ContentState
57+
```
58+
59+
### createLinkAtSelection
60+
61+
```javascript
62+
createLinkAtSelection(
63+
editorState: EditorState,
64+
url: string
65+
): EditorState
66+
```
67+
68+
### removeLinkAtSelection
69+
70+
```javascript
71+
removeLinkAtSelection(editorState: EditorState): EditorState
72+
```
73+
74+
### collapseToEnd
75+
76+
```javascript
77+
collapseToEnd(editorState: EditorState): EditorState
78+
```
79+
80+
### getCurrentEntityKey
81+
82+
```javascript
83+
getCurrentEntityKey(editorState: EditorState): ?string
84+
```
85+
86+
### createEntityStrategy
87+
88+
```javascript
89+
createEntityStrategy(entityType: string): (
90+
contentBlock: ContentBlock,
91+
callback: (start: number, end: number) => void,
92+
contentState: ContentState
93+
) => void
94+
```
95+
96+
### getCurrentEntity
97+
98+
```javascript
99+
getCurrentEntity(
100+
editorState: EditorState
101+
): ?DraftEntityInstance
102+
```
103+
104+
### getBlockEntityKey
105+
106+
```javascript
107+
getBlockEntityKey(
108+
contentState: ContentState,
109+
key: string
110+
): ?string
111+
```
112+
113+
### hasEntity
114+
115+
```javascript
116+
hasEntity(
117+
editorState: EditorState,
118+
entityType: string
119+
): boolean
120+
```
121+
122+
### insertNewLine
20123

21-
class Example extends Component {
22-
render () {
23-
return (
24-
<MyComponent />
25-
)
26-
}
27-
}
124+
```javascript
125+
insertNewLine(editorState: EditorState): EditorState
28126
```
29127

30128
## License

0 commit comments

Comments
 (0)