I don't know why I added the src attribute to the select-image tag, but it doesn't appear in the 'canvas' section of GrapesJs #5011
-
I have 2 components
I live in VietNam so English is not perfect. i really need help This is component 1: use grapes.
file ts:
and Component 2: this is file html
file .ts:
even though I inject the src attribute into the select-image tag. but in the code viewer of "view code" of GrapesJs the attribute src is not displayed. I don't know what to do Thank you very much |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 8 replies
-
You have to update the Component model, not the DOM |
Beta Was this translation helpful? Give feedback.
-
I also have renderring angular with GrapesJs ("select-image") |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I don't get what you mean. I guess you want to display the image using the To create the Then you can use |
Beta Was this translation helpful? Give feedback.
-
@ngoc199 |
Beta Was this translation helpful? Give feedback.
-
@ngoc199 "After I asked my mentor for clarification, he expressed that he wanted me to help him figure out how to embed an image link into the 'code-mirror of grapesJs'. Previously, I had assigned the image link to the tag using regular DOM methods, but on 'code-mirror', the link does not appear. I am currently facing difficulties with this task."
|
Beta Was this translation helpful? Give feedback.
-
VietNamese: dạ cảm ơn anh nhiều ạ @ngoc199 .Sau khi em thử làm cách a nhưng vẫn rơi vào bế tắc. để e mô tả lại project ạ, em có 2 component chính để lấy image có tên: grapesComponent và selectImageComponent.
VietNamese:Trong Component selectImagecomponent thì dùng "nz-Zoro design" để tạo sự kiện khi click vào chữ "cập nhật " thì hiện popup Media (Quan trọng là Component này em không import thư viện GrapesJs, ). Nên mọi tác vụ liên quan đến Thư viện grapesJs e chỉ dùng bên GrapeComponent, :(. English:In the selectImageComponent, I used "nz-Zoro design" to create an event when clicking on the word "update" to show the Media popup (importantly, this component doesn't import the GrapesJs library). So, all tasks related to the GrapesJs library, I only use them in the GrapeComponent :(.
VietNamese: Ngoài ra em có dùng CustomElement injection của Angular , khi e dùng </select-image thì nó sẽ tự động hiểu là e đang gọi cả component của selectImageComponent. English:Additionally, I used Angular's CustomElement injection. When I use , it will automatically understand that I am calling the selectImageComponent. In the GrapeComponent, I created a custom BlockManager plugin:
VietNamese: Trong phần content e có dùng customElement để khi e thả Block vào trình canvas thì nó sẽ inject đến selectImageComponent là hiện Popup( "showMediaPopup").. Hiện tại hình ảnh hiển thị như các hình em chụp phía trên nó đều nằm trong component SelectImageComponent chứ nó chưa vào trình canvas ạ( Do khi thả block vào trình canvas nó sẽ hiển thị SelectImageComponent do e inject vào ạ ). Em đang muốn khi thao tác chọn hình ảnh bên component selectImageComponent e có thể lấy được link ảnh đồng thời nó cũng được hiển thị trên "code viewer". English: In the content section, I used a customElement to inject into the selectImageComponent so that when I drag the block into the canvas, it will display the SelectImageComponent (which I injected). Currently, the displayed images, as shown in the pictures I attached above, are all located in the SelectImageComponent component, but they haven't yet entered the canvas (when I drag the block into the canvas, it will display the SelectImageComponent because I injected it). I want to be able to get the image link when selecting an image in the selectImageComponent and also display it in the "code viewer". |
Beta Was this translation helpful? Give feedback.
-
@ngoc199 I am brainstorming many ways. Is there a way to change the default asset manager into my own custom component?. Thank you so much sir |
Beta Was this translation helpful? Give feedback.
-
So the I think GrapesJS does not support reactive components like React, Angular, Vue in the "code viewer" yet. This needs to be confirmed by @artf. As I see in the GrapesJS React Example from #1970, the The reactive component libraries like React, and Angular use JavaScript to render the component. Since there is no JS in the "code viewer", you can see nothing but the I could think of 2 solutions for you:
If you want to use a custom asset manager, follow the official Asset Manager documentation. It has a Vue example. You could look at that and implement your Angular version. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much @ngoc199 . Thanks to you, I have many new ideas. |
Beta Was this translation helpful? Give feedback.
-
@ngoc199 I have successfully accomplished it thanks to your idea. Thank you very much. I consider you the greatest online mentor in my life during these past days.This is the achievement I have made bandicam.2023-04-28.14-40-49-123.mp4 |
Beta Was this translation helpful? Give feedback.
-
DONE. |
Beta Was this translation helpful? Give feedback.
You have to update the Component model, not the DOM