Skip to content

Commit d63df3b

Browse files
committed
Use same conditional logic for handlePastedText and handleBeforeInput
1 parent 8bb2520 commit d63df3b

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/__test__/plugin-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ describe('draft-js-markdown-shortcuts-plugin', () => {
341341
});
342342
[
343343
'replaceText',
344-
'insertEmptyBlock',
345344
'handleBlockType',
346345
'handleImage',
347346
'handleLink',

src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import createLinkDecorator from './decorators/link';
1919
import createImageDecorator from './decorators/image';
2020
import { replaceText } from './utils';
2121

22-
const INLINE_STYLE_CHARACTERS = [' ', '*', '_', '~', '`'];
23-
2422
function checkCharacterForState(editorState, character) {
2523
let newEditorState = handleBlockType(editorState, character);
2624
if (editorState === newEditorState) {
@@ -147,7 +145,7 @@ const createMarkdownShortcutsPlugin = (config = {}) => {
147145
let newEditorState = editorState;
148146
let buffer = [];
149147
for (let i = 0; i < text.length; i++) { // eslint-disable-line no-plusplus
150-
if (INLINE_STYLE_CHARACTERS.indexOf(text[i]) >= 0) {
148+
if (text[i].match(/[^A-z0-9_*~`]/)) {
151149
newEditorState = replaceText(newEditorState, buffer.join('') + text[i]);
152150
newEditorState = checkCharacterForState(newEditorState, text[i]);
153151
buffer = [];

0 commit comments

Comments
 (0)