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
mergeEntityData (editorState: EditorState, entityKey: string, data: Object ): EditorState
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 @@ -278,3 +278,19 @@ export function mergeEntityData(
278
278
279
279
return EditorState . push ( editorState , newContentState , 'apply-entity' )
280
280
}
281
+
282
+ export function mergeBlockData (
283
+ editorState : EditorState ,
284
+ block : ContentBlock ,
285
+ data : { [ id : string ] : any }
286
+ ) : EditorState {
287
+ const content = editorState . getCurrentContent ( )
288
+ const updatedBlock = block . mergeIn ( [ 'data' ] , data )
289
+ const blockKey = block . getKey ( )
290
+ const blockMap = content . getBlockMap ( ) . merge ( { [ blockKey ] : updatedBlock } )
291
+ return EditorState . push (
292
+ editorState ,
293
+ content . merge ( { blockMap } ) ,
294
+ 'change-block-data'
295
+ )
296
+ }
You can’t perform that action at this time.
0 commit comments