Editor page
In order to use Easyblocks your project must have a dedicated page that contains the Easyblocks Editor, called the editor page.
Creating the editor page is simple:
The config
property takes an Easyblocks configuration object described in a Configuration guide. The components
property takes the instances of your No-Code Components (described in No-Code Components section).
Please keep in mind that the editor page shouldn't render any extra headers, footers, popups etc. It must be blank canvas with EasyblocksEditor
being a single component rendered.
In order to embed the Easyblocks editor in your product, you should use an <iframe>
element that points to your editor page. However, in order to play around, you can simply open the editor page directly.
Query parameters
The editor page takes a few important query parameters:
readOnly <boolean> = true
- if set totrue
, no permanent modifications will be done to existing documents or templates. Very good way to play around, debug components, documents, etc. When you open the editor page directly it's by default set totrue
in order to prevent unexpected modifications.document <string>
- the id of the document you want to open. Leaving it undefined means you're creating a new document.rootComponent <string>
- the id of the root component. Mandatory when creating a new document (document
param is not set).rootTemplate <string>
- the id of the template to copy when creating a new document. Can't be specified together withrootComponent
.locale <string>
- a locale id. The locale must exist inConfig.locales
.
Examples:
https://youdomain.com/easyblocks-editor?rootComponent=RootSectionsStack
- open new document with a root componentRootSectionsStack
.readOnly
is not set (defaults totrue
) so the document is just temporary, will never be saved to backend. It's the best way to start playing around with the editor.https://youdomain.com/easyblocks-editor?document=abcd123
- open a document with idabcd123
in read-only mode, a good way to debug the document while being sure it won't get modified in the backend.https://youdomain.com/easyblocks-editor?document=abcd123&readOnly=false&locale=de
- edit the documentabcd123
, all the changes will be saved to the backend. The editor is opened inde
locale (German).
Events
The editor page sends postMessage events to the parent window.
To listen to any of these events, you can create a callback ref to <iframe>
and add event listener to message
event in useEffect
hook:
Below is the list of events that editor can publish:
@easyblocks/closed
@easyblocks/closed
Published when editor should be closed because user has clicked the close button in the top bar. The format:
@easyblocks/content-saved
@easyblocks/content-saved
Published each time the editor is performing the save of current content. It can be done by autosave mechanism or when closing the editor and the data the current data hasn't been saved yet. The format:
Last updated