mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-26 00:27:28 +02:00
Fix pasting plain text with newlines (#3472)
Fixes https://github.com/ianstormtaylor/slate/issues/1681
This commit is contained in:
@@ -69,12 +69,12 @@ export const withReact = <T extends Editor>(editor: T) => {
|
|||||||
const text = data.getData('text/plain')
|
const text = data.getData('text/plain')
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
const lines = text.split('\n')
|
const lines = text.split(/\r\n|\r|\n/)
|
||||||
let split = false
|
let split = false
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (split) {
|
if (split) {
|
||||||
Transforms.splitNodes(e)
|
Transforms.splitNodes(e, { always: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
Transforms.insertText(e, line)
|
Transforms.insertText(e, line)
|
||||||
|
Reference in New Issue
Block a user