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
149149mergeEntityData (editorState: EditorState, entityKey: string, data: Object ): EditorState
150150```
151151
152+ ### mergeBlockData
153+
154+ ``` javascript
155+ mergeBlockData (editorState: EditorState, block: ContentBlock, data: { [id: string]: any }): EditorState
156+ ```
157+
152158## License
153159
154160MIT © [ juliankrispel] ( https://github.com/juliankrispel )
Original file line number Diff line number Diff line change @@ -278,3 +278,19 @@ export function mergeEntityData(
278278
279279 return EditorState . push ( editorState , newContentState , 'apply-entity' )
280280}
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