11import React from "react" ;
22import ReactMarkdown from "react-markdown" ;
3+ /**
4+ * Recreate the old type to provide support until next major
5+ */
6+ import { PluggableList as PluggableListDeprecated } from "react-markdown-deprecated/lib/react-markdown" ;
37import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" ;
48// @ts -ignore: No declaration file for module (TODO: should be @ts-expect-error but GUI elements is used inside project with `noImplicitAny=false`)
59import remarkTypograf from "@mavrin/remark-typograf" ;
610import rehypeExternalLinks from "rehype-external-links" ;
711import rehypeRaw from "rehype-raw" ;
812import { remarkDefinitionList } from "remark-definition-list" ;
913import remarkGfm from "remark-gfm" ;
10- import type { PluggableList as UnifiedPluggableList } from "unified" ;
11-
12- export type OldPluginTuple = boolean | string | object | Array < OldPluginTuple > ;
13- export type OldPluggable = object | Array < OldPluginTuple > ;
14-
15- export type OldPluggableList = Array < OldPluggable > ;
16-
17- type CompatiblePluggableList = UnifiedPluggableList | OldPluggableList ;
14+ import { PluggableList as PluggableListUnified } from "unified" ;
1815
1916import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
2017import { HtmlContentBlock , HtmlContentBlockProps , TestableComponent } from "../../index" ;
18+ type PluggableList = PluggableListUnified | PluggableListDeprecated ;
2119
2220export interface MarkdownProps extends TestableComponent {
2321 children : string ;
@@ -45,7 +43,7 @@ export interface MarkdownProps extends TestableComponent {
4543 * @see https://github.com/remarkjs/react-markdown#architecture
4644 * @deprecated (v25) this property won't support `PluggableList` from "react-markdown/lib/react-markdown" with the next major version, only the one from `unified` will be supported then.
4745 */
48- reHypePlugins ?: CompatiblePluggableList ;
46+ reHypePlugins ?: PluggableList ;
4947 /**
5048 * Name for browser target where links withing the Markdown content are opened.
5149 * Set to `false` to disable this feature.
@@ -63,9 +61,9 @@ const configDefault = {
6361 @see https://github.com/remarkjs/react-markdown#api
6462 */
6563 // @see https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins
66- remarkPlugins : [ remarkGfm , remarkTypograf , remarkDefinitionList ] as UnifiedPluggableList ,
64+ remarkPlugins : [ remarkGfm , remarkTypograf , remarkDefinitionList ] as PluggableListUnified ,
6765 // @see https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins
68- rehypePlugins : [ ] as UnifiedPluggableList ,
66+ rehypePlugins : [ ] as PluggableListUnified ,
6967 allowedElements : [
7068 // default markdown
7169 "a" ,
@@ -175,8 +173,8 @@ export const Markdown = ({
175173 } ;
176174
177175 if ( reHypePlugins ) {
178- reHypePlugins . forEach (
179- ( plugin ) => ( reactMarkdownProperties . rehypePlugins = [ ... reactMarkdownProperties . rehypePlugins , plugin ] )
176+ reactMarkdownProperties . rehypePlugins = reactMarkdownProperties . rehypePlugins . concat (
177+ reHypePlugins as PluggableListUnified
180178 ) ;
181179 }
182180
0 commit comments