Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
make rendering instances work again
Oleg Isonen254637eba56e
diff --git a/apps/designer/app/canvas/features/wrapper-component/text-editor/config.ts b/apps/designer/app/canvas/features/wrapper-component/text-editor/config.tsindex 5e50a7a73a..d1c1b9adaf 100644--- a/apps/designer/app/canvas/features/wrapper-component/text-editor/config.ts+++ b/apps/designer/app/canvas/features/wrapper-component/text-editor/config.ts@@ -1,7 +1,7 @@import { InstanceNode } from "./nodes/node-instance";export const config = {- namespace: "ComponentTextEditor",+ namespace: "WsTextEditor",onError(error: Error) {throw error;},diff --git a/apps/designer/app/canvas/features/wrapper-component/text-editor/editor-lazy.tsx b/apps/designer/app/canvas/features/wrapper-component/text-editor/editor-lazy.tsxindex 0e99b87e13..a208f8248e 100644--- a/apps/designer/app/canvas/features/wrapper-component/text-editor/editor-lazy.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/text-editor/editor-lazy.tsx@@ -5,7 +5,7 @@ const EditorLazy = lazy(() => import("./editor"));const EditorWithSuspense = (props: EditorProps) => {return (- <Suspense fallback={props.editable}>+ <Suspense fallback={props.renderEditable()}><EditorLazy {...props} /></Suspense>);diff --git a/apps/designer/app/canvas/features/wrapper-component/text-editor/editor.tsx b/apps/designer/app/canvas/features/wrapper-component/text-editor/editor.tsxindex 76b7ce6788..875c03e1ed 100644--- a/apps/designer/app/canvas/features/wrapper-component/text-editor/editor.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/text-editor/editor.tsx@@ -9,28 +9,29 @@ import { InstancePlugin } from "./plugins/plugin-instance";import { ToolbarConnectorPlugin } from "./plugins/plugin-toolbar-connector";import { OnChangePlugin } from "./plugins/plugin-on-change";import { config } from "./config";-import { useEffect } from "react";+import { useCallback, useEffect } from "react";import { useSelectedElement } from "~/canvas/shared/nano-states";import { getInstanceIdFromElement } from "~/shared/dom-utils";export type EditorProps = {- editable: JSX.Element;+ renderEditable: (ref?: (element: HTMLElement | null) => void) => JSX.Element;instance: Instance;onChange: (updates: ChildrenUpdates) => void;};const useSetElement = (instance: Instance) => {const [editor] = useLexicalComposerContext();- const [element] = useSelectedElement();- useEffect(() => {- if (element && getInstanceIdFromElement(element) === instance.id) {+ return useCallback(+ (element) => {editor.setRootElement(element);- }- }, [element, editor, instance]);+ },+ [editor]+ );};-const Editor = ({ instance, editable, onChange }: EditorProps) => {- useSetElement(instance);+const Editor = ({ instance, renderEditable, onChange }: EditorProps) => {+ const refCallback = useSetElement(instance);+ const editable = renderEditable(refCallback);return (<><RichTextPlugin contentEditable={editable} placeholder="" />diff --git a/apps/designer/app/canvas/features/wrapper-component/text-editor/example-text-editor.tsx b/apps/designer/app/canvas/features/wrapper-component/text-editor/example-text-editor.tsxindex 0e4fe8e079..0109ffac62 100644--- a/apps/designer/app/canvas/features/wrapper-component/text-editor/example-text-editor.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/text-editor/example-text-editor.tsx@@ -100,7 +100,7 @@ export const ExampleTextEditor = ({ onChange }: ExampleTextEditorProps) => {}}><Editor- editable={+ renderEditable={() => (<ContentEditablestyle={{minHeight: 150,@@ -114,7 +114,7 @@ export const ExampleTextEditor = ({ onChange }: ExampleTextEditorProps) => {background: "#eee",}}/>- }+ )}instance={{component: "Paragraph",diff --git a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsxindex 75b573d53f..dc74b02a46 100644--- a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx@@ -78,7 +78,16 @@ export const WrapperComponentDev = ({return (<Editorinstance={instance}- editable={<Component {...props} contentEditable={true} />}+ renderEditable={(ref) => (+ <Component+ {...props}+ ref={(element: HTMLElement | null) => {+ props.ref(element);+ ref?.(element);+ }}+ contentEditable={true}+ />+ )}onChange={(updates) => {onChangeChildren({ instanceId: instance.id, updates });}}