Issue #5019Opened March 31, 2023by julia-alberici0 reactions

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

Question

GrapesJS version

  • 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?

  1. Start a project with grapesjs using Reactjs
  2. Use loadProjectData(data) right after editor init
  3. 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 behavior? The components become non editable but still have edit mode behaviours (eg. no hover or select style on components)

All the necessary code to reproduce the bug is on the demo link

Code of Conduct

  • I agree to follow this project's Code of Conduct

Answers (1)

julia-albericiMarch 31, 20230 reactions

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'); });

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.