mdx-editor / mdx-editor/editor

[BUG] allowedHeadingLevels not working with markdown shortcuts

Open
#559 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.7k
Forks
307
Avg merge
14h 22m
Merged PRs (30d)
5

Description

If you want to ask for support or request features, sponsor the project and contact me over email.

  • [o] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [o] I have read the documentation and cannot find an answer.

Describe the bug

After setting allowedHeadingLevels [1,2], but ### + spacebar shortcut makes h3 tag. also h4, h5, h6.


export default function InitializedMDXEditor({
  editorRef,
  ...props
}: { editorRef: ForwardedRef<MDXEditorMethods> | null } & MDXEditorProps) {
  return (
    <MDXEditor
      plugins={[
        headingsPlugin({
          allowedHeadingLevels: [1, 2],
        }),
        markdownShortcutPlugin(),
      ]}
      {...props}
      ref={editorRef}
    />
  );
}

Reproduction
Start from https://codesandbox.io/p/sandbox/mdx-editor-base-q8s7zr?file=/src/App.tsx to reproduce the problem so that I can observe the issue on my side and make sure that the fix reliably addresses it.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

I set allowedHeadingLevels = [1,2] but ### or #### or ##### or ###### still working.

Screenshots
If applicable, add screenshots to help explain your problem.

https://github.com/user-attachments/assets/7e5f5c99-789f-4bc4-a682-fe760de621c5

Desktop (please complete the following information):

  • MacOs, tauri

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction in src/App.tsx, using headingsPlugin with allowedHeadingLevels [1,2] and markdownShortcutPlugin. Trace how the markdown heading shortcuts are handled and verify that ### through ###### no longer create headings outside the allowed levels.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.