From de9d0a39124486c9e7431296df913221cb483510 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 21 Feb 2020 11:35:24 -0500 Subject: [PATCH] Fix pasting plain text with newlines (#3472) Fixes https://github.com/ianstormtaylor/slate/issues/1681 --- packages/slate-react/src/plugin/with-react.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/slate-react/src/plugin/with-react.ts b/packages/slate-react/src/plugin/with-react.ts index 1441aa64b..d42cf4b77 100644 --- a/packages/slate-react/src/plugin/with-react.ts +++ b/packages/slate-react/src/plugin/with-react.ts @@ -69,12 +69,12 @@ export const withReact = (editor: T) => { const text = data.getData('text/plain') if (text) { - const lines = text.split('\n') + const lines = text.split(/\r\n|\r|\n/) let split = false for (const line of lines) { if (split) { - Transforms.splitNodes(e) + Transforms.splitNodes(e, { always: true }) } Transforms.insertText(e, line)