Issue #3192Opened December 18, 2020by niveth090 reactions

How to make components not editable in preview mode?

Question

Code SnippetTEXT
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 (1)

artfDecember 30, 20200 reactions

Fix your function in this way

whenRunPreview(ed, type) {
  ed.getWrapper().findType(type).forEach(cmp => cmp.set({ editable: false }))
}

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.