[Bug]: calling 'preview' command not working correctly
Question
This is a piece of code that i am an using:
this.editor = grapesjs.init(this.config)
const commandManager = this.editor.Commands
commandManager.get('preview').run(this.editor)
I want the editor to go into preview mode immediately upon loading. It does go into preview mode but the offsets are still displaying. Hovering over components still highlights. Is there some piece that needs to load before the command works properly. When clicking on the preview button manually it works fine but calling the command from code doesn't. Is there some event i can attach to to make sure that the editor has fully loaded before calling the command?
Answers (2)
Yeah, you should make use of this
editor.on('load', () => editor.runCommand('preview'))
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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1487
Load from Database
I've got an issue with loading the lory-slider from my mysql db. When i load it back in, the functionality is gone, i cant slide left or ri...
Issue #503
command event that is triggered when we click "Hide Preview"
Hi, editor.on('run:preview', () => { console.log('preview ON') }) This is working fine. Now I need the command event that is triggered when...
Issue #690
Preview Command bug: exit the preview mode will run the sw-visibility command, when the sw-visibility stopped before go to preview mode.
Hi @artf , The case is "switch-visibility" command stopped, then click the preview button or trigger preview command, it will go to preview...
Issue #1183
Grapesjs Plugins not loading second time in React SPA
Hello, I'm trying to add a grapesjs editor to my React SPA. I'm initializing editor this way: config variable has the following configurati...
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.