This repository was archived by the owner on May 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,12 @@ getWordCount(editorState: EditorState): number
149
149
findWithRegex (regex: RegExp , contentBlock: ContentBlock, callback : () => void ): void
150
150
```
151
151
152
+ ### mergeBlockData
153
+
154
+ ``` javascript
155
+ mergeBlockData (editorState: EditorState, block: ContentBlock, data: { [id: string]: any }): EditorState
156
+ ```
157
+
152
158
## License
153
159
154
160
MIT © [ juliankrispel] ( https://github.com/juliankrispel )
Original file line number Diff line number Diff line change @@ -279,3 +279,19 @@ export function findWithRegex(
279
279
callback ( start , start + matchArr [ 0 ] . length )
280
280
}
281
281
}
282
+
283
+ export function mergeBlockData (
284
+ editorState : EditorState ,
285
+ block : ContentBlock ,
286
+ data : { [ id : string ] : any }
287
+ ) : EditorState {
288
+ const content = editorState . getCurrentContent ( )
289
+ const updatedBlock = block . mergeIn ( [ 'data' ] , data )
290
+ const blockKey = block . getKey ( )
291
+ const blockMap = content . getBlockMap ( ) . merge ( { [ blockKey ] : updatedBlock } )
292
+ return EditorState . push (
293
+ editorState ,
294
+ content . merge ( { blockMap } ) ,
295
+ 'change-block-data'
296
+ )
297
+ }
You can’t perform that action at this time.
0 commit comments