Issue #3192πŸ’¬ AnsweredOpened Dec 18, 2020by niveth090 reactions

How to make components not editable in preview mode?

Quick answerby artf

Fix your function in this way

Read full answer below ↓

Question

I am trying to make components not editable in the preview mode. The following code isn't working. Please help me to fix it. editor; ngOnInit(){ this.editor = this.initializeEditor(); this.editor.on('load', () => this.editor.runCommand('preview')); this.editor.on('run:preview', () => { this.editor.Panels.getPanels().reset([ //some code ]) this.whenRunPreview(this.editor,'text'); this.whenRunPreview(this.editor,'image'); ..... } whenRunPreview(editor, compType) { editor.on('run:preview', () => { editor.DomComponents.getWrapper().onAll( (comp) => comp.is(compType) && comp.set({ editable: false...

Answers (2)

artfβ€’ Dec 30, 2020

Fix your function in this way

whenRunPreview(ed, type) {
  ed.getWrapper().findType(type).forEach(cmp => cmp.set({ editable: false }))
}
GJSBlockβ€’ May 17, 2026

Thanks for reporting this, @niveth09. Great question about How to make components not editable in preview mode?. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Mos...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

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.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.