Skip to content

Commit 212579d

Browse files
authored
Merge pull request #4505 from udecode/md/heading
Fix custom headings node type
2 parents 38838ad + 2a7d7cd commit 212579d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.changeset/wise-doors-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@platejs/markdown': patch
3+
---
4+
5+
Fix custom headings node type.

apps/www/src/app/dev/c.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Button } from "@/components/ui/button";
1111
import { BaseEditorKit } from "@/registry/components/editor/editor-base-kit";
1212
import { ListKit } from "@/registry/components/editor/plugins/list-classic-kit";
1313
import { MarkdownKit } from "@/registry/components/editor/plugins/markdown-kit";
14-
import { listValue } from "@/registry/examples/values/list-classic-value";
14+
import { basicBlocksValue } from "@/registry/examples/values/basic-blocks-value";
1515
import { Editor, EditorContainer } from "@/registry/ui/editor";
1616

1717

@@ -63,11 +63,11 @@ const withCustomPlugins = (plugins: any[]): any[] => {
6363
let index = 0
6464

6565
const value = normalizeNodeId([
66-
// ...withCustomType(basicBlocksValue),
66+
...withCustomType(basicBlocksValue),
6767
// ...withCustomType(basicMarksValue),
6868
// ...withCustomType(tableValue),
6969
// ...withCustomType(codeBlockValue),
70-
...withCustomType(listValue),
70+
// ...withCustomType(listValue),
7171
// ...listValue,
7272
], {
7373
idCreator() {

packages/markdown/src/lib/rules/defaultRules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ export const defaultRules: MdRules = {
310310
};
311311
},
312312
serialize: (node, options) => {
313+
const key = getPluginKey(options.editor!, node.type);
313314
const depthMap = {
314315
h1: 1,
315316
h2: 2,
@@ -324,7 +325,7 @@ export const defaultRules: MdRules = {
324325
node.children,
325326
options
326327
) as MdHeading['children'],
327-
depth: depthMap[node.type as keyof typeof depthMap] as any,
328+
depth: depthMap[key as keyof typeof depthMap] as any,
328329
type: 'heading',
329330
};
330331
},

0 commit comments

Comments
 (0)