How to insert image (or update a component) from modal #5278
-
Hi I am currently opening a modal using
The first causes GrapeJS to loose modifications as soon as the canvas is interacted with, the second only adds a component at the end of the canvas, not at the pointer. A more obvious way would be to use Can anyone relate to this issue, what should I be doing? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Found this #3200 (comment) I think it could help some others fwiw. |
Beta Was this translation helpful? Give feedback.
-
Here is a codepen: https://codepen.io/Craig-Fairhurst/pen/KKrYWYp When you add a Stock Photo (I'm using company logo here) and then later move that Stock Photo, it causes the changes made by vanilla JavaScript to be lost. I want to essentially do what happens in the Codepen, with GrapesJS using components instead of manually updating the JavaScript via vanilla code. See below for that code.
You can see, it works, but as soon as the image is dragged around, the image The problem is, when you access I feel there is scope for this by passing parameters(?) which I will look at next. |
Beta Was this translation helpful? Give feedback.
-
Hi I’m thinking something as simple as |
Beta Was this translation helpful? Give feedback.
-
OK, so you get access to the component when creating the data type via the init method, simply storing the
And then when closing the modal, you can access via this: |
Beta Was this translation helpful? Give feedback.
OK, so you get access to the component when creating the data type via the init method, simply storing the
this
reference when in the view's init function for use later worked for me.And then when closing the modal, you can access via this:
canvasElement.mode…