easyblockshq / easyblocks

The open-source visual builder framework.
https://easyblocks.io
GNU Affero General Public License v3.0
241 stars 33 forks source link

feat(editor) include query parameters as editor params #60

Open maarten2424 opened 3 weeks ago

maarten2424 commented 3 weeks ago

Description

Currently, the following query parameters are only mutable on the URL.

The editor page takes a few important query parameters:

readOnly <boolean> = true - if set to true, 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 to true 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 with rootComponent.

locale <string> - a locale id. The locale must exist in Config.locales.

This MR enables the parameters to be set as parameters on the editor itself, making them mutable and react when changed. This way changes to any of these parameters won't result in a refresh of the editor, and making it more usable in dynamic hosted environments.

vercel[bot] commented 3 weeks ago

@maarten2424 is attempting to deploy a commit to the Shopstory Team on Vercel.

A member of the Team first needs to authorize it.

r00dY commented 1 day ago

@maarten2424 So the assumption is that you can re-render the editor based on input params, right? It makes sense, although I'm not sure it will work right now with the changes in the PR. There are some useEffect with [] dep array or memo in the initial render phase of the editor. Unless those are addressed I don't think it's gonna work. How was it tested?