Skip to content

Unable to programmatically select a single inline element #2864

Description

@judithroth

What’s broken?

At OpenProject, we're building an extension to have custom work package links for the BlockNote editor.
However, currently the behaviour when clicking on such an inline link is broken:

  1. The user expects after clicking on the element that when Ctrl-C and Ctrl-V are pressed, the work package link is copied
  2. The user expects after clicking on the element and pressing "del" or "backspace" that the element is removed from the document

It would be easy to solve both expectations, if we could select a single inline block. However, this is not possible at the moment via BlockNote, because it's not possible to select a single inline content.

Furthermore, when we force selection via ProseMirror, BlockNote opens a formatting toolbar. This toolbar does not make sense in our case, since you can't e.g. change font boldness or italics on our custom inline work package link.

What did you expect to happen?

What we need is:

  1. Be able to select a single inline element via editor.setSelection
  2. Be able to pass in if we want the formatting toolbar to open or not, e.g. showFormattingToolbar: true|false

Steps to reproduce

  1. Write your own extension with inline elements
  2. Try editor.setSelection on a single inline element

BlockNote version

0.51.3

Environment

No response

Additional context

Image

We would like to solve this in a clean way 🙂 At the moment we're exploring the following options:

  • Set selection via ProseMirror (solves our requirements but opens formatting toolbar)
  • Attach our own handlers which intercept copy-paste, keypress etc. when the inline element was clicked (and remove the handlers when the focus is removed)

If you see other good ways to solve our problem, we're happy about suggestions!

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-triageIssue has not yet been reviewed or classified by maintainers.
    on Jun 22, 2026
  2. removed
    needs-triageIssue has not yet been reviewed or classified by maintainers.
    on Jul 20, 2026
  3. YousefED commented on Jul 20, 2026

    @YousefED
    Collaborator

    Thanks Judith, we'll look into this

  4. matthewlipski commented on Jul 20, 2026

    @matthewlipski
    Collaborator

    Hi @judithroth, unfortunately the ProseMirror API is the only way to set selections at a more granular level than blocks. Having this functionality within the BlockNote API is on our roadmap, and we started investigating a possible implementation in #2044, but I'm afraid I don't have a concrete timeline for when that's going to be available at the moment.

    The way we handle the issue you're running into (i.e. setting a ProseMirror selection opening the formatting toolbar automatically) internally though is by dismissing it immediately after setting the selection. For example, when inserting an image block via the slash menu, the selection is set to wrap the inserted block which causes the formatting toolbar to open, but we immediately dismiss it. You can find the code for that here.

  5. YousefED commented on Jul 20, 2026

    @YousefED
    Collaborator

    The way we handle the issue you're running into (i.e. setting a ProseMirror selection opening the formatting toolbar automatically) internally though is by dismissing it immediately after setting the selection. For example, when inserting an image block via the slash menu, the selection is set to wrap the inserted block which causes the formatting toolbar to open, but we immediately dismiss it. You can find the code for that here.

    @matthewlipski could we add support for a meta on the transaction to prevent the formatting toolbar to be opened at all? Or is this not possible? The dismiss works but is slightly hacky

  6. added theissue type on Aug 11, 2026
  7. added
    bug:P2High: Core functionality significantly impacted.
    on Aug 11, 2026
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

    bug:P2High: Core functionality significantly impacted.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions