Skip to content

[feature]: Add a language selector to code blocks in the editor #9799

Description

@Liewzheng

Is there an existing issue for this?

  • I have searched the existing issues

Summary

In the Community Edition editor, a code block's language can only be set at creation time via the ```lang input rule. There is no UI to view or change it afterwards:

  • Code blocks inserted via the slash command, the bubble menu, paste, or markdown import are created with language: null, so they get no syntax highlighting.
  • The only way to fix a wrong or missing language is to delete the block and retype the fence from scratch.
  • Read-only surfaces (pages, comments) have no way to tell which language a block was intended to use.

(#9680 references a language dropdown with a search input, but that exists only in the cloud/commercial build — CE master has no language selector at all, only the copy button in code-block-node-view.tsx.)

Proposed behavior

Add a compact language dropdown to the code block node view (top-left, editable mode only):

  • Lists every grammar registered in the extension's lowlight instance, plus a "Plain text" (null) option.
  • Selecting a language writes through to the node's language attribute, so lowlight highlighting updates immediately.
  • An explicitly set but unregistered language stays selectable instead of blanking the picker.

I have a working implementation and would like to raise a PR if the team is interested.

Why should this be worked on?

Syntax highlighting is one of the main reasons to use code blocks, and today a large share of blocks (anything not created by typing the fence manually) silently end up unhighlighted with no recourse. A selector makes the existing lowlight integration actually reachable and matches the UX of the cloud version.

Activity

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

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions