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?
- Start a project with grapesjs using Reactjs
- Use
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 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)
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.
Issue #3939
BUG: Disabled drag and drop in preview
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? v95Reproducible demo link https://codesandbo...
Issue #3986
BUG: Cannot read properties of undefined (reading 'uploadFile')
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v96.0.4664.45 Reproducible demo lin...
Issue #3806
BUG: Target :null when adding video
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome new version Reproducible demo link...
Issue #3759
BUG: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? chrome new versionReproducible demo link htt...
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.