Skip to content

Commit 9539c14

Browse files
committed
docs
1 parent a6c6bdd commit 9539c14

File tree

8 files changed

+12
-39
lines changed

8 files changed

+12
-39
lines changed

.changeset/funny-fishes-design.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@
22
'@udecode/plate-markdown': minor
33
---
44

5-
When serializing an incomplete MDX file, we encounter an error. To address this, the solution is to remove the remark mdx plugin causing the issue.
5+
- Added fallback handling for unsupported MDX tags to gracefully preserve content
66

7-
To make the remarkMdx plugin discoverable, we’ve introduced `tagRemarkPlugin`.
8-
9-
```tsx
10-
remarkPlugins: [
11-
remarkMath,
12-
remarkGfm,
13-
tagRemarkPlugin(remarkMdx, REMARK_MDX_TAG),
14-
remarkMention,
15-
],
16-
```
17-
18-
After that we can use the following code with `withoutMdx` option to solve this issue.
19-
20-
```tsx
21-
try {
22-
const nodes = editor.getApi(MarkdownPlugin).markdown.deserialize(text);
23-
return nodes;
24-
} catch (error) {
25-
const nodes = editor.getApi(MarkdownPlugin).markdown.deserialize(text, {
26-
withoutMdx: true,
27-
});
28-
return nodes;
29-
}
30-
```
31-
32-
The previous approach relied on using name for filtering, but this proved to be unreliable—name can be minified during the build process, making it inconsistent.
7+
- Now remarkMdx is exported directly from the `@udecode/plate-markdown` package instead of importing from `remark-mdx`

apps/www/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
"remark-emoji": "5.0.1",
159159
"remark-gfm": "^4.0.0",
160160
"remark-math": "^6.0.0",
161-
"remark-mdx": "^3.1.0",
162161
"sass": "1.83.4",
163162
"shadcx": "workspace:^",
164163
"sonner": "1.7.4",

apps/www/src/registry/default/components/editor/plugins/markdown-plugin.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@
22

33
import {
44
MarkdownPlugin,
5-
REMARK_MDX_TAG,
5+
remarkMdx,
66
remarkMention,
7-
tagRemarkPlugin,
87
} from '@udecode/plate-markdown';
98
import { SuggestionPlugin } from '@udecode/plate-suggestion/react';
109
import remarkGfm from 'remark-gfm';
1110
import remarkMath from 'remark-math';
12-
import remarkMdx from 'remark-mdx';
1311

1412
export const markdownPlugin = MarkdownPlugin.configure({
1513
options: {
1614
disallowedNodes: [SuggestionPlugin.key],
17-
remarkPlugins: [
18-
remarkMath,
19-
remarkGfm,
20-
tagRemarkPlugin(remarkMdx, REMARK_MDX_TAG),
21-
remarkMention,
22-
],
15+
remarkPlugins: [remarkMath, remarkGfm, remarkMdx, remarkMention],
2316
},
2417
});

apps/www/src/registry/registry-components.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ const plugins: Registry['items'] = [
265265
'@udecode/plate-markdown',
266266
'remark-gfm',
267267
'remark-math',
268-
'remark-mdx',
269268
],
270269
files: [
271270
{

packages/markdown/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"marked": "^15.0.6",
5151
"mdast-util-math": "3.0.0",
5252
"mdast-util-mdx": "3.0.0",
53+
"remark-mdx": "^3.1.0",
5354
"remark-parse": "^11.0.0",
5455
"remark-stringify": "^11.0.0",
5556
"unified": "^11.0.5",

packages/markdown/src/lib/plugins/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
* @file Automatically generated by barrelsby.
33
*/
44

5+
export * from './remarkMdx';
56
export * from './remarkMention';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import baseRemarkMdx from 'remark-mdx';
2+
3+
import { REMARK_MDX_TAG , tagRemarkPlugin } from '../utils';
4+
5+
export const remarkMdx = tagRemarkPlugin(baseRemarkMdx, REMARK_MDX_TAG) as typeof baseRemarkMdx;

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6849,6 +6849,7 @@ __metadata:
68496849
marked: "npm:^15.0.6"
68506850
mdast-util-math: "npm:3.0.0"
68516851
mdast-util-mdx: "npm:3.0.0"
6852+
remark-mdx: "npm:^3.1.0"
68526853
remark-parse: "npm:^11.0.0"
68536854
remark-stringify: "npm:^11.0.0"
68546855
unified: "npm:^11.0.5"
@@ -22163,7 +22164,6 @@ __metadata:
2216322164
remark-emoji: "npm:5.0.1"
2216422165
remark-gfm: "npm:^4.0.0"
2216522166
remark-math: "npm:^6.0.0"
22166-
remark-mdx: "npm:^3.1.0"
2216722167
rimraf: "npm:6.0.1"
2216822168
sass: "npm:1.83.4"
2216922169
shadcx: "workspace:^"

0 commit comments

Comments
 (0)