Make inside elements not movable with propagate
You can place another custom component in the middle which propagates those properties and also the draggable or, as the droppable is false on all components you can simply update all inner components on init
Read full answer below ↓Question
Hi, creating a component/block, we want elements inside not to be removed, edited or moved:
not removed and not edited ok but how to make them non movable?
Thanks!
$.get( "/iscrizionePrivacy.plp?a=VGsflaU2d7D0sUcDhl7lCkkX8tE1UW9kBzLcqcUAR_8-yKo74nLUmyXKrfIUst_kUirvlSC_A5sqeHrBsznmUg&locale=it_IT&fromBE=true", function( data ) {
editor.DomComponents.addType('eb-privacy', {
// Make the editor understand when to bind `my-input-type`
// isComponent: el => el.tagName === 'INPUT',
// Model definition
model: {
// Default properties
defaults: {
//tagName: 'input',
//draggable: 'form, form *', // Can be dropped only inside `form` elements
droppable: false, // Can't drop other elements inside
editable: false,
removable: false,
resizable: true,
propagate: ['droppable', 'editable', 'removable'],
components: data
}
}
});
editor.BlockManager.add('test-COMPONENT-PRIVACY', {
label: 'test-COMPONENT-PRIVACY',
content: '<div data-gjs-type="eb-privacy">Test Privacy Component</div>',
});
});Answers (3)
You can place another custom component in the middle which propagates those properties and also the draggable
or, as the droppable is false on all components you can simply update all inner components on init
const doTheThing = items => items.forEach(item => {
item.set({ draggable: false, removable: false, ... })
doTheThing(item.components());
});
editor.DomComponents.addType('eb-privacy', {
...
defaults: { ... },
init() {
doTheThing(this.components());
}
...
Following code prints only "........ doTheThing 3......" Seems init() it's not called:
`$.get( "/iscrizionePrivacy.plp?a=VGsflaU2d7D0sUcDhl7lCkkX8tE1UW9kBzLcqcUAR_8-yKo74nLUmyXKrfIUst_kUirvlSC_A5sqeHrBsznmUg&locale=it_IT&fromBE=true", function( data ) {
const doTheThing = items => items.forEach(item => {
item.set({ draggable: false })
console.log (" ........ doTheThing 2...... ");
doTheThing(item.components());
});
console.log (" ........ doTheThing 3...... ");
editor.DomComponents.addType('eb-privacy', {
// Make the editor understand when to bind `my-input-type`
// isComponent: el => el.tagName === 'INPUT',
// Model definition
model: {
// Default properties
defaults: {
//tagName: 'input',
//draggable: 'form, form *', // Can be dropped only inside `form` elements
droppable: false, // Can't drop other elements inside
editable: false,
removable: false,
resizable: true,
propagate: ['droppable', 'editable', 'removable'],
components: data
},
init() {
console.log (" ........ doTheThing 1...... ");
doTheThing(this.components());
}
}
});
editor.BlockManager.add('test-COMPONENT-PRIVACY', {
label: 'test-COMPONENT-PRIVACY',
content: '<div data-gjs-type="eb-privacy">Test Privacy Component</div>',
});
});`You have to use the component in the canvas
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1748
How to prevent drag items inside the editor
Hello @artf You are doing great job with grapesjs and it's extremely helpful to make our functionality more user friendly. Thanks for creat...
Issue #2129
[Question] how to append a button inside default modal and catch it's click event
I want a form inside a modal (using the default modal ), on click of the submit button make an ajax call. I have created a new component wh...
Issue #3008
Center a Div and resizable borders
1) How to center a div inside a div in the Layer Manager? What button i must use? 2) How to make appear the resizable borders for a block?...
Issue #2076
[QUESTION] How make a new component to allow laravel blade directives?
Hi, thanks for the nice work. I'll like to know if there is a way to use blade directives inside the code. I already add a new functionalit...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
GrapesJS vs Webflow vs Builder.io vs Puck: Which Visual Builder to Choose in 2026
A practitioner's 2026 comparison of GrapesJS, Webflow, Builder.io, and Puck — pricing, AI features, lock-in, and a one-line rule for picking the right one
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.