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
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7123ed7
editor package with vite
elbotho Nov 28, 2023
2a2fcf5
write tailwind styles to dist
elbotho Nov 29, 2023
0df1774
export styles
elbotho Nov 29, 2023
7eeb136
only support esm
elbotho Nov 29, 2023
3d048fc
manually write type export
elbotho Nov 29, 2023
87f4f40
only use manually exported types, fix css export
elbotho Nov 29, 2023
8b79c41
rename to editor
elbotho Nov 29, 2023
d869b46
chore: Add missing cache for linux
kulla Nov 30, 2023
c331e85
chore: Change `build-editor` to `build:editor`
kulla Nov 30, 2023
62e39ab
chore: Add .yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.6.0-16c9f1d…
kulla Dec 4, 2023
f3800ba
feat: Add necessary exports for RLP
kulla Dec 4, 2023
657c32c
change script name
elbotho Dec 6, 2023
cddf121
Merge pull request #3146 from serlo/patches-kulla
elbotho Dec 6, 2023
8ae6fc0
refactor: Remove hello world string
kulla Dec 12, 2023
34b5d1e
feat(editor): export FaIcon
kulla Dec 12, 2023
fe44690
feat(editor): Export PluginToolbar and PluginDefaultTools
kulla Dec 12, 2023
220b324
feat: Export EditorInput, PreviewOverlay
kulla Dec 12, 2023
567ccf9
feat(editor): Change API of SerloEditor
kulla Dec 12, 2023
8e452d3
feat(editor): Proper forwarding of the children
kulla Dec 12, 2023
52e9a4d
feat(editor): Export createRenderers
kulla Dec 12, 2023
f99d647
refactor(editor): Delete unecessary renderers
kulla Dec 13, 2023
cd12e9b
refactor: Delete unused exports
kulla Dec 13, 2023
69c99f9
refactor: Explicit exports of editor.ts
kulla Dec 13, 2023
d5dcbc0
refactor(editor): Remove unused export
kulla Dec 13, 2023
60e658f
chore: Use npm-run-all for build
kulla Dec 13, 2023
30da363
chore(tailwind): Fix building of styles
kulla Dec 13, 2023
d6351f6
chore(prettier): Add json config for prettier
kulla Dec 4, 2023
fa4781e
chore(editor-build): Load SVG as react components
kulla Dec 13, 2023
8810d4c
feat(editor-npm): Export createBasicPlugins()
kulla Dec 13, 2023
6c3f4aa
refactor(editor-npm): Remove unused exports
kulla Dec 13, 2023
5678340
refactor(editor-npm): Remove unused exports
kulla Dec 13, 2023
5f8a348
Update package.json for export
kulla Dec 14, 2023
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
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 added .yarn/cache/fsevents-patch-21ad2b1333-8.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.
23 changes: 20 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
{
"name": "@serlo/frontend",
"name": "@serlo/editor",
"version": "0.0.1",
"private": true,
"bugs": {
"url": "https://github.com/serlo/frontend/issues"
},
"type": "module",
"repository": "serlo/frontend",
"license": "Apache-2.0",
"author": "Serlo Education e.V.",
"module": "./dist/editor.js",
"types": "./dist/src/serlo-editor/package/index.d.ts",
"exports": {
".": {
"import": "./dist/editor.js"
},
"./dist/editor-tailwind.css": {
"import": "./dist/editor-tailwind.css",
"require": "./dist/editor-tailwind.css"
}
},
"files": [
"dist"
],
"scripts": {
"_eslint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
"_prettier": "prettier .",
"analyze": "cross-env ANALYZE=true yarn build",
"build": "npm-run-all build:prisma build:next",
"build:next": "next build",
"build:prisma": "yarn prisma generate",
"build-editor": "tsc && vite build && tailwindcss -o dist/editor-tailwind.css --minify",
elbotho marked this conversation as resolved.
Show resolved Hide resolved
"check:all": "scripts/check-all.sh",
"check:api": "node ./scripts/check-api-version.mjs",
"check:tailwind": "node ./scripts/check-tailwind.js",
Expand Down Expand Up @@ -48,6 +62,7 @@
"@reduxjs/toolkit": "^1.9.7",
"@serlo/authorization": "^0.57.3",
"@tippyjs/react": "^4.2.6",
"@vitejs/plugin-react": "^4.2.0",
"algebra.js": "^0.2.6",
"array-move": "^4.0.0",
"autoprefixer": "^10.4.16",
Expand Down Expand Up @@ -160,7 +175,9 @@
"tailwindcss": "^3.3.3",
"tailwindcss-animate": "^1.0.7",
"ts-unused-exports": "^10.0.1",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
40 changes: 40 additions & 0 deletions src/serlo-editor/package/editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'

import { EditorPluginType } from '../types/editor-plugin-type'
import { InstanceDataProvider } from '@/contexts/instance-context'
import { LoggedInDataProvider } from '@/contexts/logged-in-data-context'
import type { InstanceData, LoggedInData } from '@/data-types'
import { Editor, type EditorProps } from '@/serlo-editor/core'

export interface SerloEditorProps {
instanceData: InstanceData
loggedInData: LoggedInData
initialState?: EditorProps['initialState']
}
const emptyState = {
plugin: EditorPluginType.Rows,
state: [
{
plugin: EditorPluginType.Text,
state: [],
},
],
}

/** For exporting the editor */
export function SerloEditor({
instanceData,
loggedInData,
initialState,
}: SerloEditorProps) {
return (
<InstanceDataProvider value={instanceData}>
<LoggedInDataProvider value={loggedInData}>
hello editor
<div className="serlo-editor-hacks mb-24 max-w-[816px] px-2">
<Editor initialState={initialState ?? emptyState} />
</div>
</LoggedInDataProvider>
</InstanceDataProvider>
)
}
68 changes: 68 additions & 0 deletions src/serlo-editor/package/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import IconBox from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-box.svg'
import IconEquation from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-equation.svg'
import IconGeogebra from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-geogebra.svg'
import IconHighlight from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-highlight.svg'
import IconMultimedia from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-multimedia.svg'
import IconSpoiler from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-spoiler.svg'
import IconTable from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-table.svg'
import IconText from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-text.svg'
import IconVideo from '@/serlo-editor/editor-ui/assets/plugin-icons/icon-video.svg'

export * from './editor'

export { editorPlugins } from '@/serlo-editor/plugin/helpers/editor-plugins'
export { editorRenderers } from '@/serlo-editor/plugin/helpers/editor-renderer'

export { EditorPluginType } from '@/serlo-editor/types/editor-plugin-type'
export * from '@/serlo-editor/types/editor-plugins'
export * from '@/serlo-editor/types/plugin-type-guards'
export type { PluginsWithData } from '@/serlo-editor/plugin/helpers/editor-plugins'

// default strings
export {
instanceData as instanceDataDe,
loggedInData as loggedInDataDe,
} from '@/data/de'
export {
instanceData as instanceDataEn,
loggedInData as loggedInDataEn,
} from '@/data/en'

// renderers
export { BoxStaticRenderer } from '@/serlo-editor/plugins/box/static'
export { GeogebraStaticRenderer } from '@/serlo-editor/plugins/geogebra/static'
export { ImageStaticRenderer } from '@/serlo-editor/plugins/image/static'
export { MultimediaStaticRenderer } from '@/serlo-editor/plugins/multimedia/static'
export { RowsStaticRenderer } from '@/serlo-editor/plugins/rows/static'
export { SerloTableStaticRenderer } from '@/serlo-editor/plugins/serlo-table/static'
export { SpoilerStaticRenderer } from '@/serlo-editor/plugins/spoiler/static'
export type { MathElement } from '@/serlo-editor/plugins/text'
export { TextStaticRenderer } from '@/serlo-editor/plugins/text/static'
export { VideoStaticRenderer } from '@/serlo-editor/plugins/video/static'
export { StaticMath } from '@/serlo-editor/plugins/text/static-components/static-math'

// plugins
export { createBoxPlugin } from '@/serlo-editor/plugins/box'
export { equationsPlugin } from '@/serlo-editor/plugins/equations'
export { geoGebraPlugin } from '@/serlo-editor/plugins/geogebra'
export { createHighlightPlugin } from '@/serlo-editor/plugins/highlight'
export { createMultimediaPlugin } from '@/serlo-editor/plugins/multimedia'
export { createRowsPlugin } from '@/serlo-editor/plugins/rows'
export { createSerloTablePlugin } from '@/serlo-editor/plugins/serlo-table'
export { createSpoilerPlugin } from '@/serlo-editor/plugins/spoiler'
export { createTextPlugin } from '@/serlo-editor/plugins/text'
export { unsupportedPlugin } from '@/serlo-editor/plugins/unsupported'
export { videoPlugin } from '@/serlo-editor/plugins/video'

// icons
export {
IconBox,
IconEquation,
IconGeogebra,
IconHighlight,
IconMultimedia,
IconSpoiler,
IconTable,
IconText,
IconVideo,
}
34 changes: 34 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
// https://vitejs.dev/guide/build.html#library-mode

/* we use vite only for building the serlo editor package */

// eslint-disable-next-line import/no-default-export
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/serlo-editor/package/index.ts'),
name: 'editor',
fileName: 'editor',
formats: ['es'],
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
plugins: [react(), dts()],
})
Loading
Loading