Skip to content

Commit e5e316f

Browse files
committed
feat(editor) include query parameters as editor params
1 parent 35d985c commit e5e316f

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

packages/editor/src/EasyblocksEditor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export function EasyblocksEditor(props: EasyblocksEditorProps) {
6262
onExternalDataChange={props.onExternalDataChange ?? (() => ({}))}
6363
widgets={props.widgets}
6464
components={props.components}
65+
readOnly={props.readOnly}
66+
locale={props.locale}
67+
documentId={props.documentId}
68+
rootTemplate={props.rootTemplate}
69+
rootComponent={props.rootComponent}
6570
/>
6671
)}
6772

packages/editor/src/EasyblocksEditorProps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ export type EasyblocksEditorProps = {
2525
>;
2626

2727
__debug?: boolean;
28+
rootTemplate?: string;
29+
rootComponent?: string;
30+
locale?: string;
31+
documentId?: string;
32+
readOnly?: boolean;
2833
};

packages/editor/src/EasyblocksParent.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type EasyblocksParentProps = {
3131
| ComponentType<InlineTypeWidgetComponentProps<any>>
3232
>;
3333
components?: Record<string, ComponentType<any>>;
34+
locale?: string;
35+
documentId?: string;
36+
rootComponent?: string;
37+
rootTemplate?: string;
38+
readOnly?: boolean;
3439
};
3540

3641
const shouldForwardProp: ShouldForwardProp<"web"> = (propName, target) => {
@@ -70,11 +75,15 @@ export function EasyblocksParent(props: EasyblocksParentProps) {
7075
/>
7176
<Editor
7277
config={props.config}
73-
locale={editorSearchParams.locale ?? undefined}
74-
readOnly={editorSearchParams.readOnly ?? true}
75-
documentId={editorSearchParams.documentId}
76-
rootComponentId={editorSearchParams.rootComponentId ?? null}
77-
rootTemplateId={editorSearchParams.rootTemplateId}
78+
locale={props.locale || editorSearchParams.locale || undefined}
79+
readOnly={props.readOnly ?? editorSearchParams.readOnly ?? true}
80+
documentId={props.documentId ?? editorSearchParams.documentId}
81+
rootComponentId={
82+
props.rootComponent ?? editorSearchParams.rootComponentId ?? null
83+
}
84+
rootTemplateId={
85+
props.rootTemplate ?? editorSearchParams.rootTemplateId
86+
}
7887
externalData={props.externalData}
7988
onExternalDataChange={props.onExternalDataChange}
8089
widgets={{

packages/editor/src/Editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ const EditorContent = ({
648648
const sidebarNodeRef = useRef<HTMLDivElement | null>(null);
649649

650650
const [editableData, form] = useForm({
651-
id: "easyblocks-editor",
651+
id: `easyblocks-editor-${initialEntry._id}`,
652652
label: "Edit entry",
653653
fields: [],
654654
initialValues: initialEntry,

0 commit comments

Comments
 (0)