how to move components
Question
Hello dear:
I want move a component to first/end in the wrapper programmatically, i think something like editor.getWrapper().add(editor.selectedComponent(), {at: 0});, but this's adding a new clone from selectedComponent,
maybe with trigger "sorter:drag:end" at position??
can you help me?
sorry for my poor english :')
Answers (1)
Probably it makes sense to add a new component.move(desComponent, opts) method to cover such a case, but for now you can achieve it in this way:
const selected = editor.getSelected();
selected.remove({ temporary: true }); // temporary option will avoid removing component related styles
editor.getWrapper().append(selected, { at: 0 });
Related Questions and Answers
Continue research with similar issue discussions.
Issue #510
Add new class programatically
Hello Artf, I want to edit the styles of components (mostly imported html) without modifying all components with the same class. I tried to...
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Issue #3328
How can I update the nodeValue (text value) of components by inputs forms
Hello. Grapesjs is a great tool. Thanks for it. I want to update the text value of a component by inputs, how can I do that?? if a user fil...
Issue #1982
[QUESTIONS] addcomponent after the selected component
how do I make it possible to add new components after the component I selected, at this time I use editor.DomComponents.addComponent (block...
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.