1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-26 16:44:22 +02:00

fix copying text with leading/trailing white space, fixes #1153 (#1157)

* fix copying text with leading/trailing white space, fixes #1153

* remove extra removeChild
This commit is contained in:
Ian Storm Taylor
2017-09-21 11:55:22 -07:00
committed by GitHub
parent 3aa5f41cff
commit 375573f9ee

View File

@@ -204,6 +204,11 @@ function Plugin(options = {}) {
// node, wrap it in a `<span>` so we have something to set an attribute on. // node, wrap it in a `<span>` so we have something to set an attribute on.
if (attach.nodeType == 3) { if (attach.nodeType == 3) {
const span = window.document.createElement('span') const span = window.document.createElement('span')
// COMPAT: In Chrome and Safari, if we don't add the `white-space` style
// then leading and trailing spaces will be ignored. (2017/09/21)
span.style.whiteSpace = 'pre'
span.appendChild(attach) span.appendChild(attach)
contents.appendChild(span) contents.appendChild(span)
attach = span attach = span