Skip to content

Conversation

@ysds
Copy link
Contributor

@ysds ysds commented Jan 14, 2026

Summary

Fixes #2156

Disable the language selector dropdown in code blocks when editable={false} is set on the BlockNoteView.

Rationale

As reported in #2156, when the editor is set to read-only mode (editable={false}), the code block language selector dropdown remains interactive, allowing users to change the language. This is inconsistent with the expected behavior where all editing functionality should be disabled in read-only mode.

Changes

  • Check editor.isEditable before registering the change event listener on the language selector
  • Set select.disabled = true when the editor is in read-only mode
  • Only register the event listener and cleanup function when the editor is editable

Impact

  • No impact on existing functionality when editable={true} (default behavior)
  • When editable={false}, the language selector will be visually disabled and non-interactive
  • Dynamic changes to editable are properly handled due to Tiptap's setEditable() triggering a re-render of block components

Testing

  • Manually tested with editable={false} set on BlockNoteView - language selector is disabled
  • Manually tested dynamic toggling of editable - selector state updates correctly when toggling between editable and read-only modes

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

When `editable={false}` is set on the BlockNoteView, the language selector
dropdown in code blocks was still interactive. This fix checks
`editor.isEditable` and disables the select element when the editor is
in read-only mode.

Fixes TypeCellOS#2156
@vercel
Copy link

vercel bot commented Jan 14, 2026

@ysds is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2351

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2351

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2351

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2351

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2351

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2351

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2351

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2351

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2351

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2351

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2351

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2351

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2351

commit: f218c3b

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code block language can be changed even when editable is false

1 participant