-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page manager #3411
Merged
Merged
Page manager #3411
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi guys, this PR introduces the new Pages module in GrapesJS but besides that, it also includes a lot of improvements and refactoring inside the editor which was necessary to make this module work properly. In order to use this module, you will probably need to update the way you initialize and store your project but the good news is that you should be able to continue to use the old way without a big difference.
The new module is focused only on API and no UI was introduced but you can easily make your own as you can see from this demo https://codepen.io/artf/pen/XWpJQoY
Initialization
In order to use the module, you have to change the way the editor is initialized.
Before
Current possible ways of initialization
After
Changes in the Storage structure
Currently, the Storage module is creating this kind of structure for your editor project (the JSON you're storing/loading)
With the Pages module, things are slightly different
As you can see, with Pages module enabled, you'll get now only
styles
andpages
as the representation of your project. Styles are kept global across all the pages (this lets you reuse styles across all the pages) and thepages
key contains the array of pages, where each page is:Possible breaking changes
Before the introduction of the Page module, GrapesJS was creating the main Wrapper component (the one containing your components) right at the initialization step (before loading plugins) this could allow plugins calling methods like
editor.getComponents()
oreditor.getHtml()
even before the load of project dataNow with the Pages module, this step was refactored and the creation of wrappers is actually happening once the data are loaded. Indeed, this actually allows you to extend the Wrapper component, something that wasn't possible at all. So, with this new approach, if in your plugin you have to access components, you have to do it once the editor is loaded.