Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: When inserting text when component not synced, the text is overwritten from the existing model #5650

Closed
2 tasks done
Wayne-Mather opened this issue Jan 29, 2024 · 1 comment

Comments

@Wayne-Mather
Copy link
Contributor

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Edge 121.0.2277.83, Firefox 122

Reproducible demo link

https://jsfiddle.net/50mga1t7/1/

Describe the bug

How to reproduce the bug?

  1. Create a toolbar action to insert some text
  2. Edit a text node and insert some text
  3. Click the toolbar command to insert some new component/text
  4. The textnode will reset to the model details before the edit's took place

What is the expected behavior?
The textnode should show the current text as being edited and the new inserted text

What is the current behavior?
The new text is inserted using the text from the model rather than the current view

Code of Conduct

  • I agree to follow this project's Code of Conduct
Wayne-Mather pushed a commit to Wayne-Mather/grapesjs that referenced this issue Jan 29, 2024
Wayne-Mather pushed a commit to Wayne-Mather/grapesjs that referenced this issue Jan 31, 2024
@artf
Copy link
Member

artf commented Feb 10, 2024

This is not a bug, merging the current DOM with components requires a bit more effort.
There is already a similar API you can use or re-implement with your own needs (using component definition instead of HTML string)

@artf artf closed this as completed Feb 10, 2024
Wayne-Mather pushed a commit to Wayne-Mather/grapesjs that referenced this issue Feb 13, 2024
artf pushed a commit that referenced this issue Feb 19, 2024
* #5650 - Fix inserting component using text from the view rather than the model

* #5650 - Updated code to be better based on PR feedback

* #5650 - Made the content replacement controlled by property on the options object

---------

Co-authored-by: Wayne Mather <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants