|
11 | 11 | npm install --save @djsp/utils |
12 | 12 | ``` |
13 | 13 |
|
14 | | -## Usage |
| 14 | +## Static Methods |
15 | 15 |
|
16 | | -```jsx |
17 | | -import React, { Component } from 'react' |
| 16 | +### replaceWithAtomicBlock |
18 | 17 |
|
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 |
20 | 123 |
|
21 | | -class Example extends Component { |
22 | | - render () { |
23 | | - return ( |
24 | | - <MyComponent /> |
25 | | - ) |
26 | | - } |
27 | | -} |
| 124 | +```javascript |
| 125 | +insertNewLine(editorState: EditorState): EditorState |
28 | 126 | ``` |
29 | 127 |
|
30 | 128 | ## License |
|
0 commit comments