Skip to content

Commit a17d680

Browse files
committed
added old pluggableList type for compatibility issues
1 parent c45b5c1 commit a17d680

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- In the `<Markdown />` component, `rehypePlugins` and `remarkPlugins` props now use PluggableList from the unified package. This may require changes if you previously used plugins not conforming to the stricter unified typings. Backward compatibility with the old plugin list type will be removed in the next major version.
12+
913
## [24.1.0] - 2025-04-16
1014

1115
### Added

src/cmem/markdown/Markdown.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import remarkTypograf from "@mavrin/remark-typograf";
66
import rehypeRaw from "rehype-raw";
77
import { remarkDefinitionList } from "remark-definition-list";
88
import remarkGfm from "remark-gfm";
9-
import { PluggableList } from "unified";
9+
import type { PluggableList as UnifiedPluggableList } from "unified";
10+
11+
export type OldPluginTuple = boolean | string | object | Array<OldPluginTuple>;
12+
export type OldPluggable = object | Array<OldPluginTuple>;
13+
14+
export type OldPluggableList = Array<OldPluggable>;
15+
16+
type CompatiblePluggableList = UnifiedPluggableList | OldPluggableList;
1017

1118
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
1219
import { HtmlContentBlock, HtmlContentBlockProps, TestableComponent } from "../../index";
@@ -36,7 +43,7 @@ export interface MarkdownProps extends TestableComponent {
3643
* Additional reHype plugins to execute.
3744
* @see https://github.com/remarkjs/react-markdown#architecture
3845
*/
39-
reHypePlugins?: PluggableList;
46+
reHypePlugins?: CompatiblePluggableList;
4047
/**
4148
* Name for browser target where links withing the Markdown content are opened.
4249
* Set to `false` to disable this feature.
@@ -54,9 +61,9 @@ const configDefault = {
5461
@see https://github.com/remarkjs/react-markdown#api
5562
*/
5663
// @see https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins
57-
remarkPlugins: [remarkGfm, remarkTypograf, remarkDefinitionList] as PluggableList,
64+
remarkPlugins: [remarkGfm, remarkTypograf, remarkDefinitionList] as UnifiedPluggableList,
5865
// @see https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins
59-
rehypePlugins: [] as PluggableList,
66+
rehypePlugins: [] as UnifiedPluggableList,
6067
allowedElements: [
6168
// default markdown
6269
"a",

0 commit comments

Comments
 (0)