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
149149findWithRegex (regex: RegExp , contentBlock: ContentBlock, callback : () => void ): void
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 @@ -279,3 +279,19 @@ export function findWithRegex(
279279 callback ( start , start + matchArr [ 0 ] . length )
280280 }
281281}
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