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: static math in package #4385

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
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
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
6 changes: 2 additions & 4 deletions apps/web/src/components/user/event.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 { faBellSlash, faCheck } from '@fortawesome/free-solid-svg-icons'
import { Entity } from '@serlo/authorization'
import Tippy from '@tippyjs/react'
Expand Down Expand Up @@ -39,9 +39,7 @@ interface EventProps {
}

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 Event({
Expand Down
7 changes: 3 additions & 4 deletions apps/web/src/serlo-editor-integration/create-renderers.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { StaticMathProps } from '@editor/package'
import {
InitRenderersArgs,
LinkRenderer,
Expand Down Expand Up @@ -117,10 +118,8 @@ const HighlightStaticRenderer = dynamic<EditorHighlightDocument>(() =>
(mod) => mod.HighlightStaticRenderer
)
)
const StaticMath = dynamic<MathElement>(() =>
import('@editor/plugins/text/static-components/static-math').then(
(mod) => mod.StaticMath
)
const StaticMath = dynamic<StaticMathProps>(() =>
import('@editor/package').then((mod) => mod.StaticMath)
)

export function createRenderers(): InitRenderersArgs {
Expand Down
9 changes: 9 additions & 0 deletions packages/editor/src/package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ export { EditorPluginType } from '@editor/types/editor-plugin-type'

// Exported only so that integrations like serlo-editor-for-edusharing can customize available plugins based on the default plugins
export { defaultPlugins } from './config'

/** StaticMath is a simple component that renders a math formula.
* it's used in the Editor and is exported here in case you want to
* render pretty LaTeX without the whole editor.
* It's relatively big so load it dynamically if you can. */
export {
StaticMath,
type StaticMathProps,
} from '@editor/plugins/text/static-components/static-math'
Loading