UNPKG

draft-js-modifiers

Version:
26 lines (18 loc) 830 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _draftJs = require('draft-js'); var _modifyBlockForContentState = require('draft-js/lib/modifyBlockForContentState'); var _modifyBlockForContentState2 = _interopRequireDefault(_modifyBlockForContentState); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var modifyBlock = function modifyBlock(editorState, blockData) { var content = editorState.getCurrentContent(); var selection = editorState.getSelection(); var newContent = (0, _modifyBlockForContentState2.default)(content, selection, function (block) { return block.merge(blockData); }); return _draftJs.EditorState.push(editorState, newContent, 'split-block' // TODO: will this do ? ); }; exports.default = modifyBlock;