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: introduce an ImageContent component in editor #328

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eric-burel
Copy link
Contributor

This PR introduces an ImageContent component for the editor, for binary images.

Design choices:

  • only binary images are supported, with format you typically expect on the web
  • svg is still treated as text (you might want a tutorial about programming with SVG)
  • other binary image format are not supported (which I think is ok for most use cases)

Problems left:

  • somehow the editor displays code from another file alongside the image
  • not sure if shoving images in the first demo lesson is good for testing

image

Closes #309

Copy link

stackblitz bot commented Sep 11, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment on lines +22 to +24
export function ImageContent({ src }: { src: string }) {
return <img src={src} />;
}
Copy link
Member

Choose a reason for hiding this comment

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

Problems left:
somehow the editor displays code from another file alongside the image

The existing <BinaryContent /> does too, but it uses position: absolute; inset: 0 to cover the text area. We could do same here:

Suggested change
export function ImageContent({ src }: { src: string }) {
return <img src={src} />;
}
export function ImageContent({ src }: { src: string }) {
return (
<div className="flex items-center justify-center absolute inset-0 z-10 bg-tk-elements-app-backgroundColor">
<img src={src} />
</div>
);
}

This isn't actually good approach as the text content of previous file is still present in DOM. It's part of tab and read order so users can actually navigate to this invisible element. But as this bug is already present in TutorialKit we can ignore it on this PR. 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a leftover of a time where we were trying to cache the EditorView from CodeMirror which I don't think is necessary. We should change the logic so that the CodeMirrorEditor is not rendered in that case.

@eric-burel eric-burel changed the title introduce an ImageContent component in editor feat: introduce an ImageContent component in editor Sep 20, 2024
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.

Display images
3 participants