Adding new components to existing ones
See original GitHub issueHello,
I would like to ask if there’s any existing support or API for adding new components to an existing component list (e. g. after fetching or generating them dynamically). I’m talking about something like this:
editor.addComponent({
parent: 'parent_id',
component: '<p>New child component</p>'
})
I’ve studied the documentation and the closest I got is the addComponents()
function. Unfortunately, this function specifies no target where the new component should be placed.
I’m asking this because my intention is to use GrapesJS in a real-time collaborative way and sending the whole HTML representation back and forth after every user action is just too slow.
Best regards, Michal
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Create and insert component instances - Figma Help Center
Select the Assets tab in the left sidebar, or use the shortcut: Mac: ⌥ Option 2; Windows: Alt + 2 · Find the...
Read more >How to Add Components to an Existing Build
To add components you first fetch the missing component(s). The way to fetch the new component is to add the missing component(s) on...
Read more >Fusion 360 Help | Create new components | Autodesk
Click the X to clear the selection. In the Browser, click to select the new parent component. From Bodies: Check the box to...
Read more >Adding new components to existing design - PCB Design
Basically, just add few new resistors - copy nearest one and paste as much times as I need. Make needed connections, and use...
Read more >Add new elements in Master Component – Adobe XD Feedback
Requirement Reason: This way we wouldn't need to ungroup the component to add the new element every time. The requirement usually occurs in ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your replies, I think my question has been answered and there’s not much else to add. I’m closing this now, however the
find()
method would be a welcome addition to this awesome framework.Unfortunately I am not aware of a simple way to get a specific component object without recursively iterating through them to find the one you want, but that sounds like a great idea!
You might be able to do something like this to get all components and then filter for the one that you want (this code is not fully tested, but hopefully can get you started in the right direction if you’re stuck):
getAllComponents().filter(function(component) { return component.cid == "someID"; } )[0]