From 0ccb8295010ed157626cb0765a3db2ace6c78c40 Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Thu, 21 Mar 2024 15:40:33 +0100 Subject: [PATCH 1/8] feat(editor): WIP plugins config object --- .../create-basic-plugins.tsx | 18 ++++++++------- .../src/plugin/helpers/editor-plugins.tsx | 22 +++++++++++++++++++ .../editor/src/store/documents/selectors.ts | 9 ++++++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/packages/editor/src/editor-integration/create-basic-plugins.tsx b/packages/editor/src/editor-integration/create-basic-plugins.tsx index fac70087cb..f507622ac0 100644 --- a/packages/editor/src/editor-integration/create-basic-plugins.tsx +++ b/packages/editor/src/editor-integration/create-basic-plugins.tsx @@ -31,6 +31,15 @@ import { EditorPluginType } from '@editor/types/editor-plugin-type' import { SupportedLanguage } from '@editor/types/language-data' import { TemplatePluginType } from '@editor/types/template-plugin-type' +export interface CreateBasicPluginsConfig { + language?: SupportedLanguage + allowedChildPlugins?: string[] + exerciseVisibleInSuggestion: boolean + enableTextAreaExercise?: boolean + allowImageInTableCells: boolean + multimediaConfig?: MultimediaConfig +} + export function createBasicPlugins({ language = 'de', enableTextAreaExercise = false, @@ -38,14 +47,7 @@ export function createBasicPlugins({ allowedChildPlugins, allowImageInTableCells, multimediaConfig, -}: { - language?: SupportedLanguage - allowedChildPlugins?: string[] - exerciseVisibleInSuggestion: boolean - enableTextAreaExercise?: boolean - allowImageInTableCells: boolean - multimediaConfig?: MultimediaConfig -}) { +}: CreateBasicPluginsConfig) { const editorStrings = editorData[language].loggedInData.strings.editor return [ diff --git a/packages/editor/src/plugin/helpers/editor-plugins.tsx b/packages/editor/src/plugin/helpers/editor-plugins.tsx index efbee87095..813c3816fe 100644 --- a/packages/editor/src/plugin/helpers/editor-plugins.tsx +++ b/packages/editor/src/plugin/helpers/editor-plugins.tsx @@ -1,3 +1,8 @@ +import { + createBasicPlugins, + type CreateBasicPluginsConfig, +} from '@editor/editor-integration/create-basic-plugins' + import { EditorPlugin } from '../internal-plugin' export interface PluginWithData { @@ -9,6 +14,11 @@ export interface PluginWithData { export type PluginsWithData = PluginWithData[] +export interface CreatePluginsConfig { + basicPlugins: CreateBasicPluginsConfig + customPlugins: PluginsWithData +} + export const editorPlugins = (function () { let allPlugins: PluginsWithData | null = null @@ -21,6 +31,18 @@ export const editorPlugins = (function () { Object.freeze(allPlugins) } + function initTemp(config: CreatePluginsConfig) { + if (allPlugins) return // only initialize once + + allPlugins = [ + ...createBasicPlugins(config.basicPlugins), + ...config.customPlugins, + ] + + // Ensure the highest integrity level that JS provides + Object.freeze(allPlugins) + } + function getAllWithData() { if (!allPlugins) throw new Error('init editor plugins first') diff --git a/packages/editor/src/store/documents/selectors.ts b/packages/editor/src/store/documents/selectors.ts index 0d97da6b3b..dc551db14d 100644 --- a/packages/editor/src/store/documents/selectors.ts +++ b/packages/editor/src/store/documents/selectors.ts @@ -30,6 +30,15 @@ export const selectDocument = createSelector( } ) +export const selectDocumentWithPlugin = createSelector( + [selectSelf, (_state, id: string | null) => id], + (documents, id) => { + const document = id ? documents[id] : null + const plugin = editorPlugins.getByType(document?.plugin || '') + return { document, plugin } + } +) + export const selectDocumentPluginType = createSelector( [selectSelf, (_state, id: string) => id], (documents, id) => documents[id].plugin as EditorPluginType From d4f911f20b52947ff717c1df20143a164242de94 Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Wed, 27 Mar 2024 11:30:47 +0100 Subject: [PATCH 2/8] feat(editor): plugins init moved to editor package --- packages/editor/src/package/editor.tsx | 26 +++++++++++++++---- packages/editor/src/package/index.ts | 2 -- .../src/plugin/helpers/editor-plugins.tsx | 17 +----------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index 5a11ab5408..02cf43e582 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -1,4 +1,12 @@ import { Editor, type EditorProps } from '@editor/core' +import { + type CreateBasicPluginsConfig, + createBasicPlugins, +} from '@editor/editor-integration/create-basic-plugins' +import { + type PluginsWithData, + editorPlugins, +} from '@editor/plugin/helpers/editor-plugins' import { SupportedLanguage } from '@editor/types/language-data' import React from 'react' @@ -10,10 +18,13 @@ import { LoggedInDataProvider } from '@/contexts/logged-in-data-context' import '@/assets-webkit/styles/serlo-tailwind.css' export interface SerloEditorProps { - language?: SupportedLanguage - initialState?: EditorProps['initialState'] children: EditorProps['children'] + initialState?: EditorProps['initialState'] + basicPluginsConfig: CreateBasicPluginsConfig + customPlugins: PluginsWithData + language?: SupportedLanguage } + const emptyState = { plugin: EditorPluginType.Rows, state: [ @@ -26,17 +37,22 @@ const emptyState = { /** For exporting the editor */ export function SerloEditor({ - language = 'de', + children, initialState, - ...props + basicPluginsConfig, + customPlugins, + language = 'de', }: SerloEditorProps) { const { instanceData, loggedInData } = editorData[language] + const basicPlugins = createBasicPlugins(basicPluginsConfig) + editorPlugins.init([...basicPlugins, ...customPlugins]) + return (
- + {children}
diff --git a/packages/editor/src/package/index.ts b/packages/editor/src/package/index.ts index 8a9b6b1dcf..7e0effdeb6 100644 --- a/packages/editor/src/package/index.ts +++ b/packages/editor/src/package/index.ts @@ -3,7 +3,6 @@ export { SerloRenderer, type SerloRendererProps } from './serlo-renderer' export { type BaseEditor } from '@editor/core' -export { editorPlugins } from '@editor/plugin/helpers/editor-plugins' export { editorRenderers } from '@editor/plugin/helpers/editor-renderer' export { EditorPluginType } from '@editor/types/editor-plugin-type' @@ -23,4 +22,3 @@ export { EditorInput, PreviewOverlay } from '@editor/editor-ui' export { PluginToolbar } from '@editor/editor-ui/plugin-toolbar' export { PluginDefaultTools } from '@editor/editor-ui/plugin-toolbar/plugin-tool-menu/plugin-default-tools' export { createRenderers } from '@editor/editor-integration/create-renderers' -export { createBasicPlugins } from '@editor/editor-integration/create-basic-plugins' diff --git a/packages/editor/src/plugin/helpers/editor-plugins.tsx b/packages/editor/src/plugin/helpers/editor-plugins.tsx index 813c3816fe..8a85cfddd0 100644 --- a/packages/editor/src/plugin/helpers/editor-plugins.tsx +++ b/packages/editor/src/plugin/helpers/editor-plugins.tsx @@ -1,7 +1,4 @@ -import { - createBasicPlugins, - type CreateBasicPluginsConfig, -} from '@editor/editor-integration/create-basic-plugins' +import type { CreateBasicPluginsConfig } from '@editor/editor-integration/create-basic-plugins' import { EditorPlugin } from '../internal-plugin' @@ -31,18 +28,6 @@ export const editorPlugins = (function () { Object.freeze(allPlugins) } - function initTemp(config: CreatePluginsConfig) { - if (allPlugins) return // only initialize once - - allPlugins = [ - ...createBasicPlugins(config.basicPlugins), - ...config.customPlugins, - ] - - // Ensure the highest integrity level that JS provides - Object.freeze(allPlugins) - } - function getAllWithData() { if (!allPlugins) throw new Error('init editor plugins first') From dfd8e5f40973fe6c2c046626e4821e09a8d97f6a Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Wed, 27 Mar 2024 12:02:36 +0100 Subject: [PATCH 3/8] chore(editor): remove leftovers --- packages/editor/src/plugin/helpers/editor-plugins.tsx | 7 ------- packages/editor/src/store/documents/selectors.ts | 9 --------- 2 files changed, 16 deletions(-) diff --git a/packages/editor/src/plugin/helpers/editor-plugins.tsx b/packages/editor/src/plugin/helpers/editor-plugins.tsx index 8a85cfddd0..efbee87095 100644 --- a/packages/editor/src/plugin/helpers/editor-plugins.tsx +++ b/packages/editor/src/plugin/helpers/editor-plugins.tsx @@ -1,5 +1,3 @@ -import type { CreateBasicPluginsConfig } from '@editor/editor-integration/create-basic-plugins' - import { EditorPlugin } from '../internal-plugin' export interface PluginWithData { @@ -11,11 +9,6 @@ export interface PluginWithData { export type PluginsWithData = PluginWithData[] -export interface CreatePluginsConfig { - basicPlugins: CreateBasicPluginsConfig - customPlugins: PluginsWithData -} - export const editorPlugins = (function () { let allPlugins: PluginsWithData | null = null diff --git a/packages/editor/src/store/documents/selectors.ts b/packages/editor/src/store/documents/selectors.ts index dc551db14d..0d97da6b3b 100644 --- a/packages/editor/src/store/documents/selectors.ts +++ b/packages/editor/src/store/documents/selectors.ts @@ -30,15 +30,6 @@ export const selectDocument = createSelector( } ) -export const selectDocumentWithPlugin = createSelector( - [selectSelf, (_state, id: string | null) => id], - (documents, id) => { - const document = id ? documents[id] : null - const plugin = editorPlugins.getByType(document?.plugin || '') - return { document, plugin } - } -) - export const selectDocumentPluginType = createSelector( [selectSelf, (_state, id: string) => id], (documents, id) => documents[id].plugin as EditorPluginType From 61074b32847b84ecf3840a4dc933eec042d0fd04 Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Wed, 27 Mar 2024 15:03:46 +0100 Subject: [PATCH 4/8] feat(editor): renderers init moved to editor package --- .../editor-integration/create-renderers.tsx | 8 ++++++-- packages/editor/src/package/editor.tsx | 19 ++++++++++++++++++- packages/editor/src/package/index.ts | 5 +---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/editor-integration/create-renderers.tsx b/packages/editor/src/editor-integration/create-renderers.tsx index 9003fc10fb..71384a806a 100644 --- a/packages/editor/src/editor-integration/create-renderers.tsx +++ b/packages/editor/src/editor-integration/create-renderers.tsx @@ -1,6 +1,7 @@ -import { +import type { InitRenderersArgs, LinkRenderer, + PluginStaticRenderer, } from '@editor/plugin/helpers/editor-renderer' import { AnchorStaticRenderer } from '@editor/plugins/anchor/static' import { ArticleStaticRenderer } from '@editor/plugins/article/static' @@ -32,7 +33,9 @@ import { ComponentProps } from 'react' import { Lazy } from '@/components/content/lazy' import { Link } from '@/components/content/link' -export function createRenderers(): InitRenderersArgs { +export function createRenderers( + customPluginRenderers: PluginStaticRenderer[] +): InitRenderersArgs { return { pluginRenderers: [ // plugins @@ -106,6 +109,7 @@ export function createRenderers(): InitRenderersArgs { type: TemplatePluginType.GenericContent, renderer: GenericContentTypeStaticRenderer, }, + ...customPluginRenderers, ], mathRenderer: (element: MathElement) => element.inline ? ( diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index 02cf43e582..f9886ec006 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -3,15 +3,20 @@ import { type CreateBasicPluginsConfig, createBasicPlugins, } from '@editor/editor-integration/create-basic-plugins' +import { createRenderers } from '@editor/editor-integration/create-renderers' import { type PluginsWithData, editorPlugins, } from '@editor/plugin/helpers/editor-plugins' +import { + type InitRenderersArgs, + editorRenderers, +} from '@editor/plugin/helpers/editor-renderer' +import { EditorPluginType } from '@editor/types/editor-plugin-type' import { SupportedLanguage } from '@editor/types/language-data' import React from 'react' import { editorData } from './editor-data' -import { EditorPluginType } from '../types/editor-plugin-type' import { InstanceDataProvider } from '@/contexts/instance-context' import { LoggedInDataProvider } from '@/contexts/logged-in-data-context' @@ -21,7 +26,14 @@ export interface SerloEditorProps { children: EditorProps['children'] initialState?: EditorProps['initialState'] basicPluginsConfig: CreateBasicPluginsConfig + // Custom plugins are an Edusharing specific feature, and will not be supported in the future customPlugins: PluginsWithData + // Custom renderers are an Edusharing specific feature, and will not be supported in the future + customRenderers: Partial< + Pick + > + // Custom plugins renderers are an Edusharing specific feature, and will not be supported in the future + customPluginsRenderers: InitRenderersArgs['pluginRenderers'] language?: SupportedLanguage } @@ -41,6 +53,8 @@ export function SerloEditor({ initialState, basicPluginsConfig, customPlugins, + customRenderers, + customPluginsRenderers, language = 'de', }: SerloEditorProps) { const { instanceData, loggedInData } = editorData[language] @@ -48,6 +62,9 @@ export function SerloEditor({ const basicPlugins = createBasicPlugins(basicPluginsConfig) editorPlugins.init([...basicPlugins, ...customPlugins]) + const basicRenderers = createRenderers(customPluginsRenderers) + editorRenderers.init({ ...basicRenderers, ...customRenderers }) + return ( diff --git a/packages/editor/src/package/index.ts b/packages/editor/src/package/index.ts index 7e0effdeb6..7ea668b010 100644 --- a/packages/editor/src/package/index.ts +++ b/packages/editor/src/package/index.ts @@ -1,9 +1,7 @@ export { SerloEditor, type SerloEditorProps } from './editor' export { SerloRenderer, type SerloRendererProps } from './serlo-renderer' -export { type BaseEditor } from '@editor/core' - -export { editorRenderers } from '@editor/plugin/helpers/editor-renderer' +export type { BaseEditor } from '@editor/core' export { EditorPluginType } from '@editor/types/editor-plugin-type' @@ -21,4 +19,3 @@ export { FaIcon } from '@/components/fa-icon' export { EditorInput, PreviewOverlay } from '@editor/editor-ui' export { PluginToolbar } from '@editor/editor-ui/plugin-toolbar' export { PluginDefaultTools } from '@editor/editor-ui/plugin-toolbar/plugin-tool-menu/plugin-default-tools' -export { createRenderers } from '@editor/editor-integration/create-renderers' From 22db328601265bfc5344a5e42188330741f0852f Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Thu, 28 Mar 2024 11:52:52 +0100 Subject: [PATCH 5/8] feat(editor): merge plugins config into one object --- .../editor-integration/create-renderers.tsx | 2 +- packages/editor/src/package/editor.tsx | 39 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/packages/editor/src/editor-integration/create-renderers.tsx b/packages/editor/src/editor-integration/create-renderers.tsx index 71384a806a..80b8ffc04b 100644 --- a/packages/editor/src/editor-integration/create-renderers.tsx +++ b/packages/editor/src/editor-integration/create-renderers.tsx @@ -34,7 +34,7 @@ import { Lazy } from '@/components/content/lazy' import { Link } from '@/components/content/link' export function createRenderers( - customPluginRenderers: PluginStaticRenderer[] + customPluginRenderers: PluginStaticRenderer[] = [] ): InitRenderersArgs { return { pluginRenderers: [ diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index f9886ec006..6f49367826 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -5,12 +5,13 @@ import { } from '@editor/editor-integration/create-basic-plugins' import { createRenderers } from '@editor/editor-integration/create-renderers' import { - type PluginsWithData, editorPlugins, + type PluginWithData, } from '@editor/plugin/helpers/editor-plugins' import { - type InitRenderersArgs, editorRenderers, + type PluginStaticRenderer, + type InitRenderersArgs, } from '@editor/plugin/helpers/editor-renderer' import { EditorPluginType } from '@editor/types/editor-plugin-type' import { SupportedLanguage } from '@editor/types/language-data' @@ -22,18 +23,18 @@ import { LoggedInDataProvider } from '@/contexts/logged-in-data-context' import '@/assets-webkit/styles/serlo-tailwind.css' +// Custom plugins and renderers are an Edusharing specific feature, +// and will not be supported in the future +interface PluginsConfig { + basicPluginsConfig: CreateBasicPluginsConfig + customPlugins?: Array + customRenderers?: Partial +} + export interface SerloEditorProps { children: EditorProps['children'] + pluginsConfig: PluginsConfig initialState?: EditorProps['initialState'] - basicPluginsConfig: CreateBasicPluginsConfig - // Custom plugins are an Edusharing specific feature, and will not be supported in the future - customPlugins: PluginsWithData - // Custom renderers are an Edusharing specific feature, and will not be supported in the future - customRenderers: Partial< - Pick - > - // Custom plugins renderers are an Edusharing specific feature, and will not be supported in the future - customPluginsRenderers: InitRenderersArgs['pluginRenderers'] language?: SupportedLanguage } @@ -48,21 +49,15 @@ const emptyState = { } /** For exporting the editor */ -export function SerloEditor({ - children, - initialState, - basicPluginsConfig, - customPlugins, - customRenderers, - customPluginsRenderers, - language = 'de', -}: SerloEditorProps) { +export function SerloEditor(props: SerloEditorProps) { + const { children, pluginsConfig, initialState, language = 'de' } = props + const { basicPluginsConfig, customPlugins, customRenderers } = pluginsConfig const { instanceData, loggedInData } = editorData[language] const basicPlugins = createBasicPlugins(basicPluginsConfig) - editorPlugins.init([...basicPlugins, ...customPlugins]) + editorPlugins.init([...basicPlugins, ...(customPlugins || [])]) - const basicRenderers = createRenderers(customPluginsRenderers) + const basicRenderers = createRenderers(customPlugins) editorRenderers.init({ ...basicRenderers, ...customRenderers }) return ( From a069b82f201c124dcaaae313f674efe6e860dd6c Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Thu, 28 Mar 2024 12:13:33 +0100 Subject: [PATCH 6/8] feat(editor): init renderers from inside the editor --- packages/editor/src/package/editor.tsx | 2 +- packages/editor/src/package/serlo-renderer.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index 6f49367826..719776cb51 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -25,7 +25,7 @@ import '@/assets-webkit/styles/serlo-tailwind.css' // Custom plugins and renderers are an Edusharing specific feature, // and will not be supported in the future -interface PluginsConfig { +export interface PluginsConfig { basicPluginsConfig: CreateBasicPluginsConfig customPlugins?: Array customRenderers?: Partial diff --git a/packages/editor/src/package/serlo-renderer.tsx b/packages/editor/src/package/serlo-renderer.tsx index 1da3f3a5fd..81c71d4013 100644 --- a/packages/editor/src/package/serlo-renderer.tsx +++ b/packages/editor/src/package/serlo-renderer.tsx @@ -1,22 +1,31 @@ +import { createRenderers } from '@editor/editor-integration/create-renderers' +import { editorRenderers } from '@editor/plugin/helpers/editor-renderer' import { StaticRenderer } from '@editor/static-renderer/static-renderer' import type { AnyEditorDocument } from '@editor/types/editor-plugins' import type { SupportedLanguage } from '@editor/types/language-data' +import type { PluginsConfig } from './editor' import { editorData } from './editor-data' import { InstanceDataProvider } from '@/contexts/instance-context' import { LoggedInDataProvider } from '@/contexts/logged-in-data-context' export interface SerloRendererProps { + pluginsConfig: PluginsConfig language?: SupportedLanguage document?: AnyEditorDocument | AnyEditorDocument[] } export function SerloRenderer({ + pluginsConfig, language = 'de', ...props }: SerloRendererProps) { + const { customPlugins, customRenderers } = pluginsConfig const { instanceData, loggedInData } = editorData[language] + const basicRenderers = createRenderers(customPlugins) + editorRenderers.init({ ...basicRenderers, ...customRenderers }) + return ( From c6ceaf45728d0125a809196502c10b3afc9475a2 Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Wed, 3 Apr 2024 10:25:56 +0200 Subject: [PATCH 7/8] style(editor): move customPlugins default value definition --- .../editor/src/editor-integration/create-renderers.tsx | 2 +- packages/editor/src/package/editor.tsx | 8 ++++++-- packages/editor/src/package/serlo-renderer.tsx | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/editor-integration/create-renderers.tsx b/packages/editor/src/editor-integration/create-renderers.tsx index 80b8ffc04b..71384a806a 100644 --- a/packages/editor/src/editor-integration/create-renderers.tsx +++ b/packages/editor/src/editor-integration/create-renderers.tsx @@ -34,7 +34,7 @@ import { Lazy } from '@/components/content/lazy' import { Link } from '@/components/content/link' export function createRenderers( - customPluginRenderers: PluginStaticRenderer[] = [] + customPluginRenderers: PluginStaticRenderer[] ): InitRenderersArgs { return { pluginRenderers: [ diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index 719776cb51..f02d30b998 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -51,11 +51,15 @@ const emptyState = { /** For exporting the editor */ export function SerloEditor(props: SerloEditorProps) { const { children, pluginsConfig, initialState, language = 'de' } = props - const { basicPluginsConfig, customPlugins, customRenderers } = pluginsConfig + const { + basicPluginsConfig, + customRenderers, + customPlugins = [], + } = pluginsConfig const { instanceData, loggedInData } = editorData[language] const basicPlugins = createBasicPlugins(basicPluginsConfig) - editorPlugins.init([...basicPlugins, ...(customPlugins || [])]) + editorPlugins.init([...basicPlugins, ...customPlugins]) const basicRenderers = createRenderers(customPlugins) editorRenderers.init({ ...basicRenderers, ...customRenderers }) diff --git a/packages/editor/src/package/serlo-renderer.tsx b/packages/editor/src/package/serlo-renderer.tsx index 81c71d4013..e6cbee2f71 100644 --- a/packages/editor/src/package/serlo-renderer.tsx +++ b/packages/editor/src/package/serlo-renderer.tsx @@ -20,7 +20,7 @@ export function SerloRenderer({ language = 'de', ...props }: SerloRendererProps) { - const { customPlugins, customRenderers } = pluginsConfig + const { customRenderers, customPlugins = [] } = pluginsConfig const { instanceData, loggedInData } = editorData[language] const basicRenderers = createRenderers(customPlugins) From efdf1e28749b9881aebd6808e70e1c8ae232a0c5 Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Wed, 3 Apr 2024 15:44:23 +0200 Subject: [PATCH 8/8] feat(editor): remove deprecated customRenderers config prop --- .../src/editor-integration/create-renderers.tsx | 12 ++++++++++-- packages/editor/src/package/editor.tsx | 10 ++-------- packages/editor/src/package/serlo-renderer.tsx | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/editor/src/editor-integration/create-renderers.tsx b/packages/editor/src/editor-integration/create-renderers.tsx index 71384a806a..307a65e6d5 100644 --- a/packages/editor/src/editor-integration/create-renderers.tsx +++ b/packages/editor/src/editor-integration/create-renderers.tsx @@ -31,7 +31,6 @@ import { TemplatePluginType } from '@editor/types/template-plugin-type' import { ComponentProps } from 'react' import { Lazy } from '@/components/content/lazy' -import { Link } from '@/components/content/link' export function createRenderers( customPluginRenderers: PluginStaticRenderer[] @@ -120,7 +119,16 @@ export function createRenderers( ), linkRenderer: ({ href, children }: ComponentProps) => { - return {children} + return ( + + {children} + + ) }, } } diff --git a/packages/editor/src/package/editor.tsx b/packages/editor/src/package/editor.tsx index f02d30b998..97d3f58649 100644 --- a/packages/editor/src/package/editor.tsx +++ b/packages/editor/src/package/editor.tsx @@ -11,7 +11,6 @@ import { import { editorRenderers, type PluginStaticRenderer, - type InitRenderersArgs, } from '@editor/plugin/helpers/editor-renderer' import { EditorPluginType } from '@editor/types/editor-plugin-type' import { SupportedLanguage } from '@editor/types/language-data' @@ -28,7 +27,6 @@ import '@/assets-webkit/styles/serlo-tailwind.css' export interface PluginsConfig { basicPluginsConfig: CreateBasicPluginsConfig customPlugins?: Array - customRenderers?: Partial } export interface SerloEditorProps { @@ -51,18 +49,14 @@ const emptyState = { /** For exporting the editor */ export function SerloEditor(props: SerloEditorProps) { const { children, pluginsConfig, initialState, language = 'de' } = props - const { - basicPluginsConfig, - customRenderers, - customPlugins = [], - } = pluginsConfig + const { basicPluginsConfig, customPlugins = [] } = pluginsConfig const { instanceData, loggedInData } = editorData[language] const basicPlugins = createBasicPlugins(basicPluginsConfig) editorPlugins.init([...basicPlugins, ...customPlugins]) const basicRenderers = createRenderers(customPlugins) - editorRenderers.init({ ...basicRenderers, ...customRenderers }) + editorRenderers.init(basicRenderers) return ( diff --git a/packages/editor/src/package/serlo-renderer.tsx b/packages/editor/src/package/serlo-renderer.tsx index e6cbee2f71..f4582d8348 100644 --- a/packages/editor/src/package/serlo-renderer.tsx +++ b/packages/editor/src/package/serlo-renderer.tsx @@ -20,11 +20,11 @@ export function SerloRenderer({ language = 'de', ...props }: SerloRendererProps) { - const { customRenderers, customPlugins = [] } = pluginsConfig + const { customPlugins = [] } = pluginsConfig const { instanceData, loggedInData } = editorData[language] const basicRenderers = createRenderers(customPlugins) - editorRenderers.init({ ...basicRenderers, ...customRenderers }) + editorRenderers.init(basicRenderers) return (