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

refactor: use editor package in frontend (WIP) #4380

Draft
wants to merge 94 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
7b7937f
refactor: use editor package in frontend (WIP)
hejtful Dec 30, 2024
9a22f05
refactor(editor): export TemplatePluginType in package
hejtful Jan 3, 2025
8f453d0
fix: enable SaveButton
hejtful Jan 3, 2025
5146b4a
refactor: remove BoxRenderer import from ExamsInfoBox
hejtful Jan 8, 2025
f9b0124
refactor: update EditorPluginType import path in revision-preview-box…
hejtful Jan 8, 2025
d63e3bf
refactor: remove renderers init from Revision comp
hejtful Jan 8, 2025
b8b7e96
refactor: remove renderers init from Entity comp
hejtful Jan 8, 2025
f97649f
refactor: update EditorPluginType import path in Entity comp
hejtful Jan 8, 2025
000fd3e
fix: enable Course
hejtful Jan 8, 2025
c7d96e4
refactor: remove CourseHeader import from Entity comp
hejtful Jan 8, 2025
dcfce72
refactor: remove Editor imports from subject landing
hejtful Jan 9, 2025
2351f0f
refactor: export SerloOnlyFeaturesContext as part of Editor package
hejtful Jan 9, 2025
8180607
refactor: export plugin type guards as part of Editor package
hejtful Jan 9, 2025
287b27e
refactor(web): move strings for uuid-url-input to frontend
elbotho Jan 9, 2025
6c750b2
refactor: export static-is-empty as part of Editor package
hejtful Jan 9, 2025
f153c36
refactor(editor): export StaticMath in package
elbotho Jan 9, 2025
d255e57
refactor(web): import StaticMath from package
elbotho Jan 9, 2025
d16e86b
refactor: export plugin state types as part of Editor package
hejtful Jan 9, 2025
199c459
refactor(web): duplicate EditorTooltip in frontend as SimpleTooltip f…
elbotho Jan 9, 2025
b66146d
Merge pull request #4384 from serlo/refactor/split-strings-uuid-tool
hejtful Jan 9, 2025
035ffbe
merge with parent branch
hejtful Jan 9, 2025
35e0fd4
Merge pull request #4385 from serlo/refactor/export-static-math
hejtful Jan 9, 2025
1ceb88a
Merge pull request #4386 from serlo/refactor/frontend-tooltip
hejtful Jan 9, 2025
870b8ef
refactor(tests): migrate to vitest, move all tests to editor
elbotho Jan 10, 2025
d939141
Merge pull request #4388 from serlo/refactor/migrate-to-vitest
hejtful Jan 10, 2025
f5fa037
refactor: remove Next router from Course
hejtful Jan 10, 2025
a0d27f4
fix: dependency cycle
hejtful Jan 10, 2025
5bec2f8
refactor: show empty course notice in Entity
hejtful Jan 13, 2025
f7933aa
Merge pull request #4391 from serlo/refactor/remove-next-router-from-…
hejtful Jan 13, 2025
125061b
fix: add injection static renderer
hejtful Jan 13, 2025
4157974
fix: button styles
hejtful Jan 13, 2025
0887cbc
refactor: remove editor static strings from frontend client base
hejtful Jan 13, 2025
ea010db
refactor: remove box renderer from privacy
hejtful Jan 13, 2025
1fd2bc7
refactor: remove createRenderers from license detail
hejtful Jan 13, 2025
9871a8c
refactor: remove direct Editor imports from Editor presentation
hejtful Jan 13, 2025
5a5d240
refactor: replace EditorRenderer with SerloRenderer in profile page
hejtful Jan 13, 2025
6dc5ff0
fix: domainOrigin server in storage-format
hejtful Jan 13, 2025
b3224a8
refactor: replace EditorRenderer with SerloRenderer in topic page
hejtful Jan 13, 2025
e0696ea
refactor: unused export in static-extract-text
hejtful Jan 13, 2025
aa1d2d1
refactor: remove EditStringsProvider from taxonomy move copy
hejtful Jan 13, 2025
a5841a3
refactor: add User template plugin
hejtful Jan 13, 2025
ef93c1d
refactor: remove SpoilerRenderer from profile settings
hejtful Jan 13, 2025
e1bb369
refactor: hide notices for editor presentation
hejtful Jan 14, 2025
52d28b1
Merge pull request #4393 from serlo/refactor/remove-direct-editor-imp…
hejtful Jan 14, 2025
0e98f73
refactor: move get-course-id-from-path to web
hejtful Jan 14, 2025
82a19cf
refactor: move document helpers to web
hejtful Jan 14, 2025
35e52a2
refactor: package import in request-page
hejtful Jan 14, 2025
3ad0389
refactor: package import in get-translated-type
hejtful Jan 14, 2025
b9ba69e
refactor: move more SaveButton strings to web
hejtful Jan 14, 2025
fb518a4
refactor: remove editor imports from ___editor_preview
hejtful Jan 15, 2025
52fe0b2
refactor: import TemplatePluginType from package
hejtful Jan 15, 2025
3566b5c
refactor: remove editor imports from ___bot_or_not
hejtful Jan 15, 2025
54a81a6
refactor: remove create-plugin and create-renderers from web
hejtful Jan 15, 2025
ca7cbe2
refactor: duplicate SerloAddButton in web
hejtful Jan 15, 2025
b7daf44
refactor: remove editor import from new AddButton component
hejtful Jan 15, 2025
557df19
refactor: export extractStringFromTextDocument from package
hejtful Jan 15, 2025
fc40442
refactor(editor): add Page and PageLayout
hejtful Jan 15, 2025
42558ee
refactor: add Page and PageLayout to serlo-editor
hejtful Jan 15, 2025
2d923ee
refactor: replace PagePartnersRenderer with static image in Donations…
hejtful Jan 15, 2025
bfaa802
refactor: replace PagePartnersRenderer with static image in landing-d…
hejtful Jan 15, 2025
cf50566
refactor: replace PagePartnersRenderer with static image in data-wall…
hejtful Jan 15, 2025
aedab09
refactor(editor): remove page-partners
hejtful Jan 15, 2025
e5eb64c
refactor(editor): remove mentions of page-partners
hejtful Jan 15, 2025
d2de337
refactor: export types used in convert-editor-response-to-state from …
hejtful Jan 15, 2025
7b52f07
merge staging
hejtful Jan 15, 2025
41c2309
refactor: move external revision strings to web
hejtful Jan 15, 2025
453db8a
refactor: decouple saving components from Editor codebase
hejtful Jan 15, 2025
f50c93c
refactor: decouple article-add-modal from Editor codebase
hejtful Jan 15, 2025
b636b94
fix: enable interactive video and taxonomy
hejtful Jan 16, 2025
b912afb
fix: bildungsraum-share error message
hejtful Jan 16, 2025
dc58f08
refactor: duplicate injection static renderer in web
hejtful Jan 16, 2025
8499ac0
refactor: export dispatchReplaceRootDocument from package
hejtful Jan 16, 2025
a0cf7a8
merge staging
hejtful Jan 17, 2025
d35be51
refactor: mark dispatchReplaceRootDocument as deprecated and serlo-only
hejtful Jan 17, 2025
f1225e2
Merge pull request #4410 from serlo/refactor/export-dispatch-replace-…
hejtful Jan 17, 2025
d391e38
refactor: simply use SerloRenderer to render injection
hejtful Jan 17, 2025
dc8cb80
refactor: Editor package exports for ___experiments page
hejtful Jan 17, 2025
b759c09
Merge pull request #4413 from serlo/refactor/package-exports-for-expe…
hejtful Jan 17, 2025
d53db47
Merge pull request #4409 from serlo/refactor/duplicate-injection-stat…
hejtful Jan 17, 2025
6e85975
try rollup-plugin-tree-shakeable
elbotho Jan 17, 2025
9588c29
add side effects
elbotho Jan 17, 2025
1b7e013
remove rollup-plugin-tree-shakeable
elbotho Jan 17, 2025
6edbf19
fix(editor-package): add sideEffects none to allow tree shaking
elbotho Jan 17, 2025
359d152
feat(editor-package): try loading renderers dynamically
elbotho Jan 17, 2025
343ef39
refactor: enable Serlo-specific plugins (and renderers) in Editor
hejtful Jan 17, 2025
e265d32
feat(editor-package): load more renderers dynamically
elbotho Jan 17, 2025
f0bcd11
feat(editor-package): try with suspense
elbotho Jan 17, 2025
46e5f74
Merge pull request #4415 from serlo/fix/editor-package-tree-shaking
hejtful Jan 17, 2025
ce5e45a
Merge pull request #4416 from serlo/refactor/dynamic-import-renderers
hejtful Jan 17, 2025
fe1ced7
Merge branch 'refactor/use-editor-package-in-frontend' into refactor/…
hejtful Jan 17, 2025
fb461d2
refactor: dynamically import serlo static renderers
hejtful Jan 17, 2025
f3acfe0
Merge pull request #4417 from serlo/refactor/enable-serlo-specific-pl…
hejtful Jan 17, 2025
ea1208f
refactor: add TextExercise and TextExerciseGroup
hejtful Jan 17, 2025
24fcf22
docs(editor): update Editor README to reflect current package exports
hejtful Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 1 addition & 11 deletions .github/workflows/web_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ jobs:
- run: yarn
- run: yarn lint:tsc

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn
- run: yarn test

editor-test:
runs-on: ubuntu-latest
steps:
Expand All @@ -52,4 +42,4 @@ jobs:
with:
node-version: 20
- run: yarn
- run: yarn editor:test
- run: yarn test
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/abab-npm-2.0.6-2662fba7f0-6ffc1af4ff.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/co-npm-4.6.0-03f2d1feb6-5210d92230.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ejs-npm-3.1.10-4e8cf4bdc1-ce90637e9c.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/exit-npm-0.1.2-ef3761a67d-abc407f07a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/psl-npm-1.9.0-a546edad1a-20c4277f64.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/tmpl-npm-1.0.5-d399ba37e2-cd922d9b85.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/tr46-npm-3.0.0-e1ae1ea7c9-44c3cc6767.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Creates a build of the frontend, shows summary of build artefacts and creates in
yarn test
```

Runs jest tests.
Runs editor unit tests (vitest).

```
yarn codegen
Expand Down
17 changes: 0 additions & 17 deletions apps/web/jest.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions apps/web/jest.setup.ts

This file was deleted.

5 changes: 1 addition & 4 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"lint:prettier": "yarn _prettier --check",
"lint:tsc": "tsc --noEmit",
"show-unused-exports": "ts-unused-exports tsconfig.json --excludePathsFromReport=src/pages/ --excludePathsFromReport=src/fetcher/graphql-types/operations.ts --allowUnusedTypes",
"start": "next start",
"test": "jest"
"start": "next start"
},
"resolutions": {
"@serlo/katex-styles": "1.0.1"
Expand Down Expand Up @@ -100,7 +99,6 @@
"@tailwindcss/typography": "^0.5.15",
"@types/canvas-confetti": "^1.6.4",
"@types/iframe-resizer": "^3.5.13",
"@types/jest": "^29.5.14",
"@types/js-cookie": "^3.0.6",
"@types/json-diff": "^1.0.3",
"@types/katex": "^0.16.7",
Expand All @@ -123,7 +121,6 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"graphql-tag": "2.12.6",
"jest": "^29.7.0",
"micromark": "^4.0.1",
"npm-run-all": "^4.1.5",
"postcss-flexbugs-fixes": "^5.0.2",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/web/public/_assets/img/wallet/partners.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EditorPluginType } from '@editor/types/editor-plugin-type'
import { EditorPluginType } from '@editor/package'
import { type ReactNode } from 'react'

import { DisplayModes } from './display-modes'
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/components/author/revision/revision.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { editorRenderers } from '@editor/plugin/helpers/editor-renderer'
import { useState, useEffect } from 'react'

import { DisplayModes } from './display-modes'
Expand All @@ -12,7 +11,6 @@ import { UserTools } from '@/components/user-tools/user-tools'
import { useInstanceData } from '@/contexts/instance-context'
import { type RevisionData } from '@/data-types'
import { removeHash } from '@/helper/remove-hash'
import { createRenderers } from '@/serlo-editor-integration/create-renderers'

export interface RevisionProps {
data: RevisionData
Expand All @@ -26,7 +24,6 @@ export function Revision({ data }: RevisionProps) {
const [displayMode, setDisplayMode] = useState<DisplayModes>(
DisplayModes.This
)
editorRenderers.init(createRenderers())

// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(() => {
Expand Down
30 changes: 18 additions & 12 deletions apps/web/src/components/author/uuid-url-input.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEditStrings } from '@editor/i18n/edit-strings-provider'
import { gql } from 'graphql-request'
import { useState } from 'react'

import { FaIcon } from '../fa-icon'
import { useGraphqlSwr } from '@/api/use-graphql-swr'
import { useInstanceData } from '@/contexts/instance-context'
import { useLoggedInData } from '@/contexts/logged-in-data-context'
import { UuidType, UuidWithRevType } from '@/data-types'
import {
TaxonomyTermType,
Expand Down Expand Up @@ -38,13 +38,16 @@ export function UuidUrlInput({
const { data, error } = useSimpleUuidFetch(maybeUuid)

const { strings } = useInstanceData()
const modalStrings = useEditStrings().templatePlugins.article.addModal
const loggedInData = useLoggedInData()

if (!loggedInData) return null
const uuidToolStrings = loggedInData.strings.uuidUrlInput

return (
<div className="my-4 border-t-2 pt-5">
<input
className="serlo-input-font-reset w-72 rounded-xl bg-editor-primary-200 p-2 font-bold placeholder-almost-black outline-none placeholder:font-normal focus:bg-editor-primary"
placeholder={modalStrings.placeholder}
placeholder={uuidToolStrings.placeholder}
onChange={(event) => {
if (event.target.value.length === 0) {
setMaybeUuid(null)
Expand All @@ -69,16 +72,16 @@ export function UuidUrlInput({

function renderFeedback() {
if (maybeUuid === null) return null
if (maybeUuid === false) return modalStrings.invalidInput
if (maybeUuid === false) return uuidToolStrings.invalidInput
if (error) {
// eslint-disable-next-line no-console
console.error(error)
return modalStrings.fetchError
return uuidToolStrings.fetchError
}
if (!data) return modalStrings.loading
if (!data) return uuidToolStrings.loading

const { uuid } = data
if (!uuid) return modalStrings.notFound
if (!uuid) return uuidToolStrings.notFound

const { __typename: typename, id } = uuid

Expand All @@ -90,18 +93,21 @@ export function UuidUrlInput({
Object.hasOwn(uuid, 'type') && uuid.type ? uuid.type : undefined

if (!supportedEntityTypes.includes(typename as UuidWithRevType))
return modalStrings.unsupportedType.replace('%type%', typename)
return uuidToolStrings.unsupportedType.replace('%type%', typename)

if (taxonomyType && !supportedTaxonomyTypes.includes(taxonomyType))
return modalStrings.unsupportedType.replace('%type%', taxonomyType ?? '')
return uuidToolStrings.unsupportedType.replace(
'%type%',
taxonomyType ?? ''
)

if (unsupportedIds && unsupportedIds.includes(id))
return modalStrings.unsupportedId
return uuidToolStrings.unsupportedId

if (!id) return modalStrings.notFound
if (!id) return uuidToolStrings.notFound

if (!typename.includes(UuidType.Exercise) && !title)
return modalStrings.notFound
return uuidToolStrings.notFound

return (
<>
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/components/comments/comment.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StaticMathProps } from '@editor/plugins/text/static-components/static-math'
import type { StaticMathProps } from '@editor/package'
import dynamic from 'next/dynamic'
import { useEffect, useRef, useState } from 'react'

Expand All @@ -23,9 +23,7 @@ interface CommentProps {
}

const StaticMath = dynamic<StaticMathProps>(() =>
import('@editor/plugins/text/static-components/static-math').then(
(mod) => mod.StaticMath
)
import('@editor/package').then((mod) => mod.StaticMath)
)

export function Comment({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EditorTooltip } from '@editor/editor-ui/editor-tooltip'
import { faCreativeCommons } from '@fortawesome/free-brands-svg-icons'
import { faSlash } from '@fortawesome/free-solid-svg-icons'

import { Link } from '../link'
import { FaIcon } from '@/components/fa-icon'
import { SimpleTooltip } from '@/components/simple-tooltip'
import { useInstanceData } from '@/contexts/instance-context'
import { getLicense } from '@/data/licenses/licenses-helpers'
import { cn } from '@/helper/cn'
Expand Down Expand Up @@ -63,16 +63,16 @@ export function ExerciseLicenseNotice({
return (
<>
<Link
className={cn(`
serlo-button-learner-transparent serlo-tooltip-trigger w-[33px] text-[18px] text-base font-normal hover:no-underline
`)}
className={cn(
`serlo-button-learner-transparent serlo-tooltip-trigger w-[33px] text-[18px] text-base font-normal hover:no-underline`
)}
href={licenseHref}
noExternalIcon
>
<>
<EditorTooltip
<SimpleTooltip
text={tooltipTitle}
hotkeys={tooltipExplanation}
subtext={tooltipExplanation}
className="right-0 top-10"
/>
<span className="relative -ml-[1px] inline-block h-5 w-5 align-sub text-xl">
Expand Down
41 changes: 30 additions & 11 deletions apps/web/src/components/entity/entity.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { editorRenderers } from '@editor/plugin/helpers/editor-renderer'
import { isEmptyArticle } from '@editor/plugins/article/utils/static-is-empty'
import { CourseHeader } from '@editor/plugins/course/renderer/course-header'
import { EditorPluginType } from '@editor/types/editor-plugin-type'
import { isArticleDocument } from '@editor/types/plugin-type-guards'
import {
EditorPluginType,
isArticleDocument,
isCourseDocument,
isEmptyArticle,
} from '@editor/package'
import {
faExclamationCircle,
faGraduationCap,
faTools,
faTrash,
} from '@fortawesome/free-solid-svg-icons'
Expand All @@ -24,7 +26,6 @@ import { getIconByTypename } from '@/helper/icon-by-entity-type'
import { isProduction } from '@/helper/is-production'
import { replacePlaceholders } from '@/helper/replace-placeholders'
import { getHistoryUrl } from '@/helper/urls/get-history-url'
import { createRenderers } from '@/serlo-editor-integration/create-renderers'
import { EditorRenderer } from '@/serlo-editor-integration/editor-renderer'

export interface EntityProps {
Expand All @@ -38,14 +39,12 @@ const LenabiCourseFeedback = dynamic(() =>
)

export function Entity({ data }: EntityProps) {
editorRenderers.init(createRenderers())

const isLenabiUserJourneyCoursePage = !isProduction && data.id === 307521

const { strings } = useInstanceData()
return wrapWithSchema(
<>
{renderNotices()}
{renderNotices(data.content)}
{renderStyledH1()}
{renderUserTools({ aboveContent: true })}
<div className="min-h-[25vh]" key={data.id}>
Expand All @@ -61,7 +60,14 @@ export function Entity({ data }: EntityProps) {
function renderStyledH1() {
if (!data.title) return null
if (data.typename === UuidType.Course)
return <CourseHeader title={<>{data.title}</>} />
return (
<>
<p className="serlo-p mb-0 mt-10 text-[1rem] font-bold">
<FaIcon icon={faGraduationCap} /> {strings.entities.course}
</p>
<div className="mx-side my-0 text-2xl font-bold">{data.title}</div>
</>
)

return (
<h1 className="serlo-h1 mt-12" itemProp="name">
Expand Down Expand Up @@ -139,7 +145,7 @@ export function Entity({ data }: EntityProps) {
)
}

function renderNotices() {
function renderNotices(document: EntityData['content']) {
if (data.trashed)
return (
<InfoPanel icon={faTrash} doNotIndex>
Expand Down Expand Up @@ -175,5 +181,18 @@ export function Entity({ data }: EntityProps) {
</InfoPanel>
)
}

const isCourse =
document &&
!Array.isArray(document) &&
document.plugin === EditorPluginType.Course &&
isCourseDocument(document)
if (isCourse && !document.state.pages.length) {
return (
<InfoPanel icon={faExclamationCircle} type="warning" doNotIndex>
{strings.content.courseNoPagesWarning}
</InfoPanel>
)
}
}
}
6 changes: 2 additions & 4 deletions apps/web/src/components/equations-app/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StaticMathProps } from '@editor/plugins/text/static-components/static-math'
import type { StaticMathProps } from '@editor/package'
import { faCheck, faPlay } from '@fortawesome/free-solid-svg-icons'
import dynamic from 'next/dynamic'

Expand All @@ -12,9 +12,7 @@ interface OverviewProps {
}

const StaticMath = dynamic<StaticMathProps>(() =>
import('@editor/plugins/text/static-components/static-math').then(
(mod) => mod.StaticMath
)
import('@editor/package').then((mod) => mod.StaticMath)
)

export function Overview({ selectLevel, solved }: OverviewProps) {
Expand Down
Loading
Loading