draft-js-modifiers
Version:
Modular state modifiers for Draft.js
20 lines (15 loc) • 573 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _draftJs = require('draft-js');
var modifyBlockByKey = function modifyBlockByKey(editorState, blockKey, blockData) {
var content = editorState.getCurrentContent();
var blockMap = content.getBlockMap().map(function (b) {
return b.key === blockKey ? b.merge(blockData) : b;
});
var newContent = content.merge({ blockMap: blockMap });
return _draftJs.EditorState.push(editorState, newContent, 'split-block' // TODO: will this do ?
);
};
exports.default = modifyBlockByKey;