Skip to content

Typing ``` then Enter throws "Language is not supported" and corrupts cursor/deletion #3005

Closed

Description

@liicos

What’s broken?

Typing ``` (with no language name) and pressing Enter creates a code block whose language is an empty string. The highlighter then throws Uncaught Error: Language is not supported. After that, the cursor position is wrong, and Backspace/Delete no longer behave correctly in that block.

What did you expect to happen?

Typing ``` and pressing Enter should create a normal code block with the default language (e.g. text), without throwing. The cursor should land inside the block, and Backspace/Delete should work as usual.

Steps to reproduce

  1. Open any BlockNote editor with @blocknote/code-block enabled (the official code-block example is enough).
  2. In an empty paragraph, type ``` (three backticks, no language name).
  3. Press Enter.

Result: the console throws Uncaught Error: Language is not supported. After that, the cursor is in the wrong place, and Backspace/Delete in that block are also wrong.

```js then Enter does not reproduce this.

BlockNote version

v0.54.0

Environment

No response

Additional context

No response

Contribution

  • I'd be interested in contributing a fix for this issue

Sponsor

  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

Activity

  1. added
    needs-triage
    on Aug 25, 2026
  2. adarshsm commented on Aug 29, 2026

    @adarshsm
    Contributor

    Taking this one.

    Root cause is in the code-block input rule (CodeKeyboardShortcutsExtension.ts):

    find: /^```(.*?)\s$/,
    replace: ({ match }) => {
      const languageName = match[1].trim();
      const attributes = {
        language: getLanguageId(options, languageName) ?? languageName,
      };

    With no language suffix, match[1] is empty, getLanguageId returns undefined, and the raw empty string is used as the language. createLanguageSelect then throws because "" isn't in supportedLanguages — hence the double space in Language is not supported. — and the block is left in a broken state, which is what breaks the cursor and Backspace/Delete afterwards.

    Fix is to fall back to the configured defaultLanguage ("text") when no language is given. Note there are two existing tests asserting the empty-language behaviour, so those encode the bug and will be updated. PR shortly.

  3. AntoLC commented on Sep 3, 2026

    @AntoLC

    Hi !
    In our case, we used an alias js, it should be supported:

    * @example
    * {
    * javascript: {
    * name: "JavaScript",
    * aliases: ["js"],
    * },
    * typescript: {
    * name: "TypeScript",
    * aliases: ["ts"],
    * },
    * }
    */

    But it throws an error, the alias does not seem checked.

    if (!(selectedLanguage in supportedLanguages)) {
    throw new Error(`Language ${selectedLanguage} is not supported.`);
    }

    In this case, using a fallback language could maybe provide a smoother user experience than throwing an error, wdyt ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions