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

fix(frontend): use EditorImage on subject landing pages #4247

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StaticStringsProvider } from '@editor/i18n/static-strings-provider'
import { staticStrings as staticStringsDe } from '@editor/i18n/strings/de/static'
import { staticStrings as staticStringsEn } from '@editor/i18n/strings/en/static'
import { SerloOnlyFeaturesContext } from '@editor/utils/serlo-extra-context'
import type { AuthorizationPayload } from '@serlo/authorization'
import Head from 'next/head'
import { Router, useRouter } from 'next/router'
Expand Down Expand Up @@ -125,37 +126,39 @@ export function FrontendClientBase({
</Head>
) : null}
<AuthProvider unauthenticatedAuthorizationPayload={authorization}>
<StaticStringsProvider
value={
instanceData.lang === 'de'
? mergeDeepRight(staticStringsEn, staticStringsDe)
: staticStringsEn
}
>
<LoggedInDataProvider value={loggedInData}>
<UuidsProvider value={serloEntityData ?? null}>
<Toaster />
<ConditionalWrap
condition={!noHeaderFooter}
wrapper={(kids) => <HeaderFooter>{kids}</HeaderFooter>}
>
<SerloOnlyFeaturesContext.Provider value={{ isSerlo: true }}>
<StaticStringsProvider
value={
instanceData.lang === 'de'
? mergeDeepRight(staticStringsEn, staticStringsDe)
: staticStringsEn
}
>
<LoggedInDataProvider value={loggedInData}>
<UuidsProvider value={serloEntityData ?? null}>
<Toaster />
<ConditionalWrap
condition={!noContainers}
wrapper={(kids) => (
<div className="relative">
<MaxWidthDiv showNav={showNav}>
<main id="content">{kids}</main>
</MaxWidthDiv>
</div>
)}
condition={!noHeaderFooter}
wrapper={(kids) => <HeaderFooter>{kids}</HeaderFooter>}
>
{children}
<ConditionalWrap
condition={!noContainers}
wrapper={(kids) => (
<div className="relative">
<MaxWidthDiv showNav={showNav}>
<main id="content">{kids}</main>
</MaxWidthDiv>
</div>
)}
>
{children}
</ConditionalWrap>
<MaintenanceBanner />
</ConditionalWrap>
<MaintenanceBanner />
</ConditionalWrap>
</UuidsProvider>
</LoggedInDataProvider>
</StaticStringsProvider>
</UuidsProvider>
</LoggedInDataProvider>
</StaticStringsProvider>
</SerloOnlyFeaturesContext.Provider>
</AuthProvider>
</InstanceDataProvider>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { editorRenderers } from '@editor/plugin/helpers/editor-renderer'
import { EditorImage } from '@editor/plugins/image/components/editor-image'
import { isImageDocument } from '@editor/types/plugin-type-guards'
import { faListUl } from '@fortawesome/free-solid-svg-icons'
import Image from 'next/image'
Expand Down Expand Up @@ -146,8 +147,7 @@ export function SubjectLandingTopicOverview({
alt={`Illustration: ${term.title}`}
/>
) : (
// eslint-disable-next-line @next/next/no-img-element
<img src={src} className="h-12 w-12 object-cover" />
<EditorImage src={src} className="h-12 w-12 object-cover" />
)
) : null}
</div>
Expand Down
9 changes: 3 additions & 6 deletions apps/web/src/serlo-editor-integration/editor-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { StaticRenderer } from '@editor/static-renderer/static-renderer'
import { AnyEditorDocument } from '@editor/types/editor-plugins'
import { SerloOnlyFeaturesContext } from '@editor/utils/serlo-extra-context'

export function EditorRenderer({
document,
}: {
document: unknown
}): JSX.Element {
return (
<SerloOnlyFeaturesContext.Provider value={{ isSerlo: true }}>
<div className="serlo-content-with-spacing-fixes">
<StaticRenderer document={document as AnyEditorDocument} />
</div>
</SerloOnlyFeaturesContext.Provider>
<div className="serlo-content-with-spacing-fixes">
<StaticRenderer document={document as AnyEditorDocument} />
</div>
)
}