grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Disable editing in Preview Mode.

Open yashvirsoftobiz opened this issue 8 years ago • 5 comments

@artf How can we disable editing in the preview mode and re-enable it when preview mode off. I want to remove editor and hide toolbar in the preview mode so that user can only view the changes and can not edit it also all the editable option should be come when user stop the preview mode.

yashvirsoftobiz avatar Jul 27 '18 07:07 yashvirsoftobiz

You can use: editor.stopCommand('sw-visibility'); editor.runCommand('sw-visibility');

jvillena avatar Jul 27 '18 13:07 jvillena

@jvillena I have used this code but it is not working.

editor.on('run:preview', () => { editor.stopCommand('sw-visibility'); });

editor.on('stop:preview', () => editor.runCommand('sw-visibility'); });

yashvirsoftobiz avatar Jul 27 '18 13:07 yashvirsoftobiz

Hi Artur ( @artf ),

I need to add save and publish button so is there any plugin available or do i need to hardcoded. Can you please help me.

ghost avatar Jul 27 '18 14:07 ghost

editor.on('run:preview', () => {
	// Execute a callback on all inner components starting from the root
	editor.DomComponents.getWrapper().onAll(comp => 
		comp.is('text') && comp.set({ editable: false })
	);
});
// Same for the `stop:preview` but set editable to true

artf avatar Jul 27 '18 20:07 artf

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Mar 10 '20 20:03 lock[bot]