question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Pasting multiple paragraphs of text makes block output null

See original GitHub issue

Noticed that if you try pasting a few paragraphs of text into the editor the blocks data output will return null. Adding a space after will update the data, but not great if someone pastes a few paragraphs and saves.

Steps to reproduce:

  1. Go to the editor demo page - https://editorjs.io
  2. Empty the editor fully and paste in the following text:
Lorem ipsum dolor sit amet praesent bibendum est interdum nibh purus. Platea duis pellentesque risus maecenas nisi urna mollis dictumst a tellus. Fringilla iaculis tempor nunc platea porta gravida vel sapien fermentum iaculis. A eu faucibus molestie quam malesuada tristique pulvinar pellentesque. Sollicitudin euismod tincidunt convallis mattis velit elit bibendum ultricies dictum arcu eget urna.

Consequat odio sollicitudin massa vivamus nisl lobortis neque eget diam adipiscing phasellus etiam iaculis. Sed tristique pretium venenatis vulputate pretium purus velit cras fames duis leo porta platea. Dictumst molestie mollis sagittis mollis tristique sagittis in ultrices. Viverra tempus labore dui dapibus malesuada pellentesque pretium aliquet sodales odio consectetur. Labore nulla sapien dui facilisis aliqua libero eiusmod sagittis hac.

Incididunt malesuada purus vivamus dui tempus fusce sodales dapibus turpis bibendum odio viverra libero tincidunt. Quis fusce dolore luctus consectetur luctus nibh suspendisse integer labore convallis. Laoreet dapibus viverra laoreet malesuada tristique leo mollis maecenas fusce porttitor dictum quisque ut. Quis risus imperdiet habitasse pellentesque condimentum mi lobortis lectus sodales quam congue erat ultrices hendrerit. Tincidunt porttitor in eget praesent lobortis sagittis labore tellus tristique ut eiusmod posuere eiusmod.
  1. Look at the data preview below the editor. You can see the “Blocks” value is an empty array.

Expected behavior: It should output the pasted text. Interestingly, sometimes it will work fine, seems to output null more often than not though.

https://user-images.githubusercontent.com/13979799/130320444-aeae9c94-da11-4b66-ba20-2933d16c1223.mov

Screenshots:

Device, Browser, OS: Safari 14.1.2 - Mac 11.5.2

Editor.js version: 2.22.2

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

8reactions
vasiliy-lcommented, Sep 28, 2021

I was able to overcome this issue using the onChange callback by calling the api.saver.save() with a small delay. 🤷‍♂️ https://editorjs.io/configuration#editor-modifications-callback https://editorjs.io/saver#save

This approach also helped me to fix related bug when editor doesn’t delete multiple blocks at once https://github.com/codex-team/editor.js/issues/1699

const handleChange = (api /*, block */) => {
  setTimeout(() => {
    api.saver.save().then(
      (editorData) => console.log(JSON.stringify(editorData))
    );
  }, 200);    
};

const editor = new EditorJS({
  ... // pass configuration props
  onChange: handleChange, 
});
3reactions
unityoxbcommented, Aug 29, 2021

I also found the same problem. After copying the content from other places, if there is no change, the content is empty after submission.

Read more comments on GitHub >

github_iconTop Results From Across the Web

109587 - Pasting lots of text to a textarea is slow - chromium
Issue 163131: Clearing a textarea which contains a large amount of text is extremely slow. Restricting this bug to "Pasting is slow".
Read more >
Why is pasting text into Excel splitting it into multiple cells?
Select a non-empty cell; Do Data -> Text to Columns; Make sure to choose Delimited; Click Next >; Enable the Tab delimiter, disable...
Read more >
Bug Report - text display and copy/paste - Brizy Help Center
I have several text blocks with some of the text pasted in. The size and line spacing on all text is identical. It...
Read more >
Confluence wiki: How to paste multiple paragraphs as a single ...
In Confluence Wiki editor (as of March 2020): Scenario 1: Insert quote from '+' menu. type text in quote. hit return, type more...
Read more >
1273836 - Copy-Paste of simple HTML adds extra new lines ...
Actual results: Extra new lines(empty) are added that are not part of the ... </pre> Copy and Paste In Firefox to text editor:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found