@@ -7,6 +7,7 @@ import CKEditorInspector from "@ckeditor/ckeditor5-inspector"
77import {
88 FullEditorConfig ,
99 MinimalEditorConfig ,
10+ MinimalWithMathEditorConfig ,
1011} from "../../lib/ckeditor/CKEditor"
1112import ResourceLink from "../../lib/ckeditor/plugins/ResourceLink"
1213import { checkNotSubAndSup } from "../../lib/ckeditor/attributeChecks"
@@ -23,6 +24,7 @@ import {
2324 MARKDOWN_CONFIG_KEY ,
2425 RESOURCE_LINK_CONFIG_KEY ,
2526 WEBSITE_NAME ,
27+ MINIMAL_WITH_MATH ,
2628} from "../../lib/ckeditor/plugins/constants"
2729import ResourcePickerDialog from "./ResourcePickerDialog"
2830import useThrowSynchronously from "../../hooks/useAsyncError"
@@ -37,7 +39,7 @@ export interface Props {
3739 name ?: string
3840 onChange ?: ( event : { target : { value : string ; name : string } } ) => void
3941 children ?: React . ReactNode
40- minimal ?: boolean
42+ minimal ?: boolean | typeof MINIMAL_WITH_MATH
4143 embed : string [ ]
4244 link : string [ ]
4345 allowedHtml : string [ ]
@@ -142,48 +144,34 @@ export default function MarkdownEditor(props: Props): JSX.Element {
142144 [ WEBSITE_NAME ] : website . name ,
143145 }
144146
147+ const baseConfig =
148+ minimal === MINIMAL_WITH_MATH
149+ ? MinimalWithMathEditorConfig
150+ : minimal
151+ ? MinimalEditorConfig
152+ : FullEditorConfig
153+
145154 // Create a copy of plugins to avoid mutating the original
146- const plugins = minimal
147- ? [ ...MinimalEditorConfig . plugins ]
148- : [ ...FullEditorConfig . plugins ]
155+ const plugins = [ ...baseConfig . plugins ]
149156 if ( isCustomLinkUIEnabled ) {
150157 plugins . push ( CustomLink )
151158 }
152159
153- if ( minimal ) {
154- return {
155- ...MinimalEditorConfig ,
156- plugins,
157- [ CKEDITOR_RESOURCE_UTILS ] : {
158- renderResource,
159- openResourcePicker,
160- } ,
161- toolbar : {
162- ...MinimalEditorConfig . toolbar ,
163- items : MinimalEditorConfig . toolbar . items . filter ( toolbarItemsFilter ) ,
164- } ,
165- ...resourceLink ,
166- }
167- } else {
168- // this render function is stuck into the editor config
169- // our ResourceEmbed plugin can pull the callback out,
170- // and then use it to render resources within the editor.
171- return {
172- ...FullEditorConfig ,
173- plugins,
174- [ CKEDITOR_RESOURCE_UTILS ] : {
175- renderResource,
176- openResourcePicker,
177- } ,
178- toolbar : {
179- ...FullEditorConfig . toolbar ,
180- items : FullEditorConfig . toolbar . items . filter ( toolbarItemsFilter ) ,
181- } ,
182- [ MARKDOWN_CONFIG_KEY ] : {
183- allowedHtml,
184- } ,
185- ...resourceLink ,
186- }
160+ return {
161+ ...baseConfig ,
162+ plugins,
163+ [ CKEDITOR_RESOURCE_UTILS ] : {
164+ renderResource,
165+ openResourcePicker,
166+ } ,
167+ toolbar : {
168+ ...baseConfig . toolbar ,
169+ items : baseConfig . toolbar . items . filter ( toolbarItemsFilter ) ,
170+ } ,
171+ [ MARKDOWN_CONFIG_KEY ] : {
172+ allowedHtml,
173+ } ,
174+ ...resourceLink ,
187175 }
188176 } , [
189177 minimal ,
0 commit comments