Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: static elements iframe rendering #715

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

loweisz
Copy link
Contributor

@loweisz loweisz commented Aug 8, 2024

Purpose

Approach

Copy link

vercel bot commented Aug 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
experience-builder-test-app ✅ Ready (Inspect) Visit Preview Aug 8, 2024 8:48pm

// window.removeEventListener('message', onMessage);
}
}

Copy link
Contributor Author

@loweisz loweisz Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[1] Introducing a new event sent from the web app, that will set a flag similar to the editor mode to set it in read-only mode.
We will also set the mode to editor mode, so that we enable the iframe communication and don't fetch staff over the network

@@ -38,6 +38,7 @@ export const ExperienceRoot = ({
experience={experienceObject as Experience<EntityStore> | undefined}
visualEditorMode={visualEditorMode}
initialLocale={locale}
isReadOnlyMode={isReadOnlyMode}
/>
Copy link
Contributor Author

@loweisz loweisz Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[2] For read-only we still render the VisualEditorRoot, but we set it into read-only

experience={experience}
isReadOnlyMode={isReadOnlyMode}
visualEditorMode={visualEditorMode}
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[3] Pass it on to the Visual editor

if (isReadOnlyMode) {
return <ReadOnlyRenderer />;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[4] Introducing a new Renderer that will handle elements diffently to the normal editor renderer

@@ -0,0 +1,32 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[5] This renderer will render the blocks directly, as we don't need the editor things like the dropzone and hover stuff.

@@ -0,0 +1,116 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[6] Mostly copy-pasted code from the useEditorSubscriber, excluding all the events that we are not interested in, like the drag and drop stuff, hover or select events.

this will mostly just listen to the component tree update events and will update the tree in here

...modifiedProps,
style: { ...sizeStyles, ...style },
// forces the container elements to render without the dropzone
editorMode: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[7] Creating the element that will be rendered for this node. We set it here directly to editor mode as this would prevent elements like the container to not render the dropzone

@@ -0,0 +1,53 @@
import React, { useMemo, useRef } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[8] Mostly the same as the blocks for the delivery mode just getting the information differently as we are already in the editor mode land.

This might be abstracted and be shared with the delivery mode components ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant