Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit f9526de

Browse files
authored
Merge pull request #18 from withspectrum/change-block-type
Fix changing the current block type
2 parents 460a2d8 + d1c12d2 commit f9526de

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "draft-js-markdown-plugin",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description":
55
"A DraftJS plugin for supporting Markdown syntax shortcuts, fork of draft-js-markdown-shortcuts-plugin",
66
"main": "lib/index.js",

src/modifiers/changeCurrentBlockType.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ const changeCurrentBlockType = (
1212
const blockMap = currentContent.getBlockMap();
1313
const block = blockMap.get(key);
1414
const data = block.getData().merge(blockMetadata);
15-
const newBlock = block.merge({ type, data, text: text || "" });
16-
const newSelection = selection.merge({
17-
anchorOffset: 0,
18-
focusOffset: 0,
19-
});
15+
const newBlock = block.merge({ type, data, text: text });
2016
const newContentState = currentContent.merge({
2117
blockMap: blockMap.set(key, newBlock),
22-
selectionAfter: newSelection,
18+
selectionAfter: selection,
2319
});
2420
return EditorState.push(editorState, newContentState, "change-block-type");
2521
};

0 commit comments

Comments
 (0)