From d86e45805f68dc9f87ee8f8fe1016175705f9378 Mon Sep 17 00:00:00 2001 From: Maarten Vleugels Date: Mon, 17 Jun 2024 16:37:03 +0100 Subject: [PATCH] feat(editor) include query parameters as editor params --- packages/editor/src/EasyblocksEditor.tsx | 5 +++++ packages/editor/src/EasyblocksEditorProps.ts | 5 +++++ packages/editor/src/EasyblocksParent.tsx | 19 ++++++++++++++----- packages/editor/src/Editor.tsx | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/editor/src/EasyblocksEditor.tsx b/packages/editor/src/EasyblocksEditor.tsx index be269fa8..0d4b1b25 100644 --- a/packages/editor/src/EasyblocksEditor.tsx +++ b/packages/editor/src/EasyblocksEditor.tsx @@ -62,6 +62,11 @@ export function EasyblocksEditor(props: EasyblocksEditorProps) { onExternalDataChange={props.onExternalDataChange ?? (() => ({}))} widgets={props.widgets} components={props.components} + readOnly={props.readOnly} + locale={props.locale} + documentId={props.documentId} + rootTemplate={props.rootTemplate} + rootComponent={props.rootComponent} /> )} diff --git a/packages/editor/src/EasyblocksEditorProps.ts b/packages/editor/src/EasyblocksEditorProps.ts index 00c69611..0916f55c 100644 --- a/packages/editor/src/EasyblocksEditorProps.ts +++ b/packages/editor/src/EasyblocksEditorProps.ts @@ -25,4 +25,9 @@ export type EasyblocksEditorProps = { >; __debug?: boolean; + rootTemplate?: string; + rootComponent?: string; + locale?: string; + documentId?: string; + readOnly?: boolean; }; diff --git a/packages/editor/src/EasyblocksParent.tsx b/packages/editor/src/EasyblocksParent.tsx index 033e3cdd..c22e525b 100644 --- a/packages/editor/src/EasyblocksParent.tsx +++ b/packages/editor/src/EasyblocksParent.tsx @@ -31,6 +31,11 @@ type EasyblocksParentProps = { | ComponentType> >; components?: Record>; + locale?: string; + documentId?: string; + rootComponent?: string; + rootTemplate?: string; + readOnly?: boolean; }; const shouldForwardProp: ShouldForwardProp<"web"> = (propName, target) => { @@ -70,11 +75,15 @@ export function EasyblocksParent(props: EasyblocksParentProps) { /> { if (!props.document) { if (props.rootTemplateId) { + console.log(props.rootTemplateId); if (props.rootComponentId) { throw new Error( "You can't pass both 'rootContainer' and 'rootTemplate' parameters to the editor" @@ -648,7 +649,7 @@ const EditorContent = ({ const sidebarNodeRef = useRef(null); const [editableData, form] = useForm({ - id: "easyblocks-editor", + id: `easyblocks-editor-${initialEntry._id}`, label: "Edit entry", fields: [], initialValues: initialEntry,