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

Commit 61e835b

Browse files
author
Axel Wahlen
committed
Add handling of whitespaces after the inline style change
1 parent 2df3609 commit 61e835b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/modifiers/changeCurrentInlineStyle.js

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ const changeCurrentInlineStyle = (editorState, matchArr, style) => {
5555
style
5656
);
5757

58+
// check if last match is a whitespace char to re-add it
59+
if (/^\s$/.test(matchArr[matchArr.length - 1])) {
60+
newContentState = Modifier.insertText(newContentState, afterSelection, " ");
61+
62+
afterSelection = newContentState.getSelectionAfter();
63+
}
64+
5865
const newEditorState = EditorState.push(
5966
editorState,
6067
newContentState,

0 commit comments

Comments
 (0)