draft-js icon indicating copy to clipboard operation
draft-js copied to clipboard

Error when `formatPastedText` returns html with no text content

Open tu4mo opened this issue 3 years ago • 3 comments

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

https://codesandbox.io/s/spring-framework-zp7hq?file=/src/App.js

  1. Copy "a" and paste it in the editor.
  2. formatPastedText removes "a" from html.
  3. insertFragmentIntoContentState.js:189 Uncaught TypeError: Cannot read property 'getLength' of undefined at https://github.com/facebook/draft-js/blob/10ca1ad44843e970c4314f85a8f37d26f842ebf9/src/model/transaction/insertFragmentIntoContentState.js#L257

What is the expected behavior?

No error.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

macOS v11.3.1 Chrome v90.0.4430.93 Draft v0.11.7

tu4mo avatar May 10 '21 13:05 tu4mo

Hi @tu4mo ) I can not reproduce this bug in chrome from local project wich was created with create-react-app , it seems it is the bug with codesandbox

Quintis1212 avatar May 23 '21 09:05 Quintis1212

Hi @Quintis1212, thanks for taking the time to look in to this. Perhaps "crash" was a wrong word to describe the issue. I rephrased it. The error happens locally as well.

tu4mo avatar May 23 '21 12:05 tu4mo

@tu4mo If you paste text in editor copied from https://www.lipsum.com/, it throws the same error. However, if you paste only text or only HTML this formatPastedText works fine on my local system.

2022-02-10_19-47

Zeshan-Sh avatar Feb 10 '22 14:02 Zeshan-Sh