Issue #5019πŸ’¬ AnsweredOpened Mar 31, 2023by julia-alberici0 reactions

Can't set preview mode on editor init when using loadProjectData()

Quick answerby julia-alberici

For the record, this wasn't really a bug, and i could achieve the expected behavior replacing editor.onReady(() => { editor.runCommand("preview"); }); with editor.on('update', () => { editor.runCommand('preview'); });

Read full answer below ↓

Question

GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v111 Reproducible demo link https://codesandbox.io/s/grapesjs-react-components-forked-h3j496?file=/src/index.js Describe the bug How to reproduce the bug?Start a project with grapesjs using ReactjsUse loadProjectData(data) right after editor init Set preview mode through editor.onReady(() => { editor.runCommand("preview"); }); (or any other way actually) What is the expected behavior? Editor should have all preview behaviors (eg. no hover or select style on components) What is the current b...

Answers (2)

julia-albericiβ€’ Mar 31, 2023

For the record, this wasn't really a bug, and i could achieve the expected behavior replacing editor.onReady(() => { editor.runCommand("preview"); }); with editor.on('update', () => { editor.runCommand('preview'); });

GJS Helperβ€’ May 17, 2026

The issue you're encountering where GrapesJS components retain edit mode behaviors (like hover/select styles) despite running the preview command after loadProjectData() is a timing problem related to asynchronous operations. Root Cause When you initialize GrapesJS and immediately call editor.loadP...

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.