Issue #924💬 AnsweredOpened March 4, 2018by jadebayo0 reactions

Calling 'preview' command not working correctly

快速解答by artf

Yeah, you should make use of this

Read full answer below ↓

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)

artfMarch 6, 2018

Yeah, you should make use of this

editor.on('load', () => editor.runCommand('preview'))
lock[bot]September 18, 2019

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.

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.