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

tmp: editor package with vite #3136

Closed
wants to merge 32 commits into from
Closed

Conversation

elbotho
Copy link
Member

@elbotho elbotho commented Nov 28, 2023

this is the first step: export editor as react component

what works:

  • editor and tools to customize can be imported and used in other react repo
  • tailwind css styles are exported and can be imported from package
  • important types are included

what does not work / is not included here:

  • assets (icons, katex font)
  • using workspaces
  • limit dependencies

example usage from other repo

import {
  RowsStaticRenderer,
  TextStaticRenderer,
  editorPlugins,
  editorRenderers,
  instanceDataDe,
  loggedInDataDe,
  SerloEditor,
  EditorPluginType,
  createTextPlugin,
  createRowsPlugin,
  MathElement,
  StaticMath,
} from '@serlo/editor'
import {
  InstanceData,
  LoggedInData,
} from '@serlo/editor/dist/src/data-types'
import { LinkRenderer } from '@serlo/editor/dist/src/serlo-editor/plugin/helpers/editor-renderer'
import { ComponentProps } from 'react'

export default function Demo() {
  editorPlugins.init([
    {
      type: EditorPluginType.Text,
      plugin: createTextPlugin({}),
      visibleInSuggestions: true,
      icon: <>text</>,
    },
    { type: EditorPluginType.Rows, plugin: createRowsPlugin() },
  ])

  editorRenderers.init({
    pluginRenderers: [
      { type: EditorPluginType.Rows, renderer: RowsStaticRenderer },
      { type: EditorPluginType.Text, renderer: TextStaticRenderer },
    ],
    mathRenderer: (element: MathElement) => <StaticMath {...element} />,
    linkRenderer: ({ href, children }: ComponentProps<LinkRenderer>) => {
      return <a href={href}>{children}</a>
    },
  })

  return (
    <SerloEditor
      instanceData={instanceDataDe as InstanceData}
      loggedInData={loggedInDataDe as LoggedInData}
    />
  )
}

Copy link

vercel bot commented Nov 28, 2023

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

Name Status Preview Updated (UTC)
frontend ✅ Ready (Inspect) Visit Preview Dec 14, 2023 11:10am

Copy link
Contributor

github-actions bot commented Nov 28, 2023

📦 Next.js Bundle Analysis for @serlo/editor

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 102.92 KB (-1 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/___exercise_folder_dashboard/[id] 46.24 KB (🟡 +9 B) 149.16 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

package.json Outdated Show resolved Hide resolved
@elbotho
Copy link
Member Author

elbotho commented Dec 8, 2023

closing this because it should slowly but surely move into #3183

@kulla
Copy link
Member

kulla commented Dec 12, 2023

closing this because it should slowly but surely move into #3183

Keep it open for now, I am trying some things -> I will close it... 😄

@kulla
Copy link
Member

kulla commented Dec 12, 2023

ToDos to fix TS errors

  • 1 src/frontend/editor.tsx:41
  • 2 src/frontend/plugins/create-renderers.tsx:6
  • 2 src/frontend/plugins/edusharing-asset/editor.tsx:4
  • 10 src/frontend/plugins/serlo-injection/editor.tsx:5
  • 1 src/frontend/plugins/serlo-injection/index.ts:5
  • 1 src/frontend/plugins/serlo-injection/static.tsx:9
  • "Error: could not find react-redux context value; please ensure the component is wrapped in a "

@kulla
Copy link
Member

kulla commented Dec 15, 2023

Work will be continued in #3220

@kulla kulla closed this Dec 15, 2023
@kulla kulla deleted the try-exporting-package-vite branch December 15, 2023 09:42
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.

2 participants