BUG: Text disappears if pasted for a second time in text block
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome 99
Reproducible demo link
https://grapesjs.com/demo.html
Describe the bug
How to reproduce the bug?
- Open https://grapesjs.com/demo.html and delete all sample sections
- Place one "Text section"
- Open a text editor and type 3 lines of text. Something like this:
Line 1
Line 2
Line 3
- Copy the 3 lines from the text editor
- Go back to GrapesJS demo page and double click the text section just before the word
consecterur(other word would work too) - Press
CTRL+Vto paste the text - Click outside to commit the changes
- Hover your mouse over the
Line 2and notice it is its ownTextelement - Double click on
Line 2just before the2 - Press
CTRL+Vto paste the same 2 lines text - Click outside to commit the changes
What is the expected behavior? The text that was pasted the second time should be kept where it was pasted
What is the current behavior? The text that was pasted the second time disappears
If is necessary to execute some code in order to reproduce the bug, paste it here below:
// your code here
Screenshots of the steps:
- Go to https://grapesjs.com/demo.html and delete all sample sections. Put one "Text section":

- Open text editor, type 3 lines and copy them. Double click on the text in the text section and move the caret just before the word
consecterurand press CTRL+V to paste the 3 lines and click outside to commit the changes:
- Double click on the second line and press CTRL+V again:

- Now click outside to commit the second paste - the last pasted lines disappear:

Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (3)
@artf The problem is relevant to the latest version. (v0.19.4)
The bug occurs if you copy and paste a nested component while editing text. A regular paste (cmd + v) copies all html, including id, and after removing focus, html with identical id is deleted.
I can confirm that this problem occurs only with Grapesjs 0.18.3 - I downgraded to 0.18.2 and the problem does not occur. Older versions are OK too.
I can confirm that this problem occurs only with Grapesjs 0.18.3 - I downgraded to 0.18.2 and the problem does not occur. Older versions are OK too.
in version 0.18.2, nested components were not created inside the text.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5729
BUG: editing/replacing the text inside of a link
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link https:/...
Issue #4239
BUG: in component first mode, sync works only the first time on UI feedback
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v100 Reproducible demo link https:/...
Issue #5378
BUG: Uncaught TypeError: Cannot read properties of undefined (reading 'Canvas') while dragging a component in Layer Manager Panel
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v116.0.5845.97 Reproducible demo li...
Issue #4732
BUG: Tabs behaviour after HTML import
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 107 (MacOS) Reproducible demo link...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.