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
finalizye lazy rendering api
Oleg Isonen9e1754c5f27e
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 49e6ff5fff..983597113c 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@@ -3,9 +3,16 @@ import type { EditorProps } from "./editor";const EditorLazy = lazy(() => import("./editor"));-const EditorWithSuspense = (props: EditorProps) => {+type EditorPropsWithSuspense = EditorProps & {+ fallback: JSX.Element;+};++const EditorWithSuspense = ({+ fallback,+ ...props+}: EditorPropsWithSuspense) => {return (- <Suspense fallback={props.renderEditable()}>+ <Suspense fallback={fallback}><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 49d2292901..ec8fba195c 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@@ -11,8 +11,13 @@ import { OnChangePlugin } from "./plugins/plugin-on-change";import { config } from "./config";import { useCallback } from "react";+type InstanceRenderProps = {+ ref: (element: HTMLElement | null) => void;+ contentEditable: boolean;+};+export type EditorProps = {- renderEditable: (ref?: (element: HTMLElement | null) => void) => JSX.Element;+ renderInstance: (renderProps: InstanceRenderProps) => JSX.Element;instance: Instance;onChange: (updates: ChildrenUpdates) => void;};@@ -27,9 +32,9 @@ const useSetElement = () => {);};-const Editor = ({ instance, renderEditable, onChange }: EditorProps) => {- const refCallback = useSetElement();- const editable = renderEditable(refCallback);+const Editor = ({ instance, renderInstance, onChange }: EditorProps) => {+ const ref = useSetElement();+ const editable = renderInstance({ ref, contentEditable: true });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 0109ffac62..673c6d8651 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- renderEditable={() => (+ renderInstance={() => (<ContentEditablestyle={{minHeight: 150,diff --git a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsxindex dc74b02a46..426ddce932 100644--- a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx@@ -74,29 +74,32 @@ export const WrapperComponentDev = ({},};- if (editingInstanceId === instance.id) {- return (- <Editor- instance={instance}- renderEditable={(ref) => (- <Component- {...props}- ref={(element: HTMLElement | null) => {- props.ref(element);- ref?.(element);- }}- contentEditable={true}- />- )}- onChange={(updates) => {- onChangeChildren({ instanceId: instance.id, updates });- }}- />- );+ const instanceElement = (+ <Component {...props}>{renderWrapperComponentChildren(children)}</Component>+ );++ if (editingInstanceId !== instance.id) {+ return instanceElement;}return (- <Component {...props}>{renderWrapperComponentChildren(children)}</Component>+ <Editor+ instance={instance}+ fallback={instanceElement}+ renderInstance={({ ref, ...renderProps }) => (+ <Component+ {...props}+ {...renderProps}+ ref={(element: HTMLElement | null) => {+ props.ref(element);+ ref(element);+ }}+ />+ )}+ onChange={(updates) => {+ onChangeChildren({ instanceId: instance.id, updates });+ }}+ />);};