How to make components not editable in preview mode?
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 (1)
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.
Issue #2055
[QUESTION]: How to remove the components correctly?
I want to remove the components programmatically, the following is my code snippet. After the components have been removed, then undo the d...
Issue #4273
How to trigger the 'Import Template (modal)' on page load
Hello, Please i'm in need of the logic on how to the import template modal on initialization of the page... I'm using the newsletter preset...
Issue #3366
Extending preview command
I am trying to extend the preview command. I expected the code below to run the normal preview command along with console output, but only...
Issue #2961
BUG: Components in custom modal isn't editable
Hello, I'm trying to add custom modal block to my project and I want to change content of this modal also with drag&drop. Here's code of my...
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.