Skip to content

Conversation

@matthewlipski
Copy link
Collaborator

Summary

When using BlockNoteViewEditor and setting renderEditor={false} in BlockNoteViewComponent, you currently have to pass the same editable prop to both, or it causes issues.

Because it doesn't make sense to need to pass the same editable prop to 2 different components in the first place, this PR removes the prop from BlockNoteViewEditor. Instead, the editable value is passed in through the BlockNoteContext to ensure it's the same between the components.

Rationale

There is currently an issue with the comments sidebar example caused by this mismatch in editable states, as the prop is passed to BlockNoteViewComponent but not BlockNoteViewEditor.

This makes the editor not focusable while the user selected has only comment priviledges and editable is false. That, in turn, prevents the editor from being focusable, meaning the formatting toolbar can't be shown, and so the user can't add comments.

Changes

See above

Impact

Testing

Technically a breaking change since BlockNoteViewEditor no longer supports the editable prop? Shouldn't really matter though.

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

@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
blocknote Ready Ready Preview Jan 15, 2026 0:48am
blocknote-website Ready Ready Preview Jan 15, 2026 0:48am

@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@2357

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 526cc34

ctx.editorProps.editable !== editor.isEditable
) {
editor.isEditable = props.editable;
editor.isEditable = ctx.editorProps.editable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is needed, don't we already do this on line 145? Can we find edge-cases why we also need to set this here on mount / why we added it originally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, it's redundant to have this logic in both components. Seems like the reason this was done is that the effect on line 145 would only fire after the context value was updated, so editor.isEditable may not have the correct value when mount is run.

I ended up removing the effect on line 145 and simplifying the code in mount instead, to not deal with this weird hook priority thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah realized I commented on the same sort of behavior #2357 (comment) . I think we should be using only the effect & not the mount handler. If we need to have this render before layout (as some things will look different in editable vs. not mode), then use a useLayoutEffect since it will be done before paint. Though, I could see this triggering a re-render of the editor blocks that are defined as react nodes, so ideally it'd be set on editor creation & the layout effect is purely for reactivity

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, even with useLayoutEffect, mount is still called before the effect, so things still don't work. Also, I don't think we could set it on editor creation since editable can only be set on the view, not passed to the editor itself. Maybe worth discussing on call.

editor.isEditable = props.editable;
}
// Set editable state of the actual editor.
editor.isEditable = ctx.editorProps.editable !== false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that editable is not "reactive", i.e. you change that context value & it won't switch the editor between editable & not editable modes?

We should check this behavior in an example. Since I think people may have things like:

function Component(){
const [isEditable, setEditable] = useState(true);

return <><button onClick={()=>setEditable(a=>!a)}>Toggle</button><Editor editable={isEditable} /></>
}

And, expect it to react to the button.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the existing example where this issue was coming up - all good, editor is re-mounted with the toggled editable state and everything works as expected. ctx.editorProps.editable is in the dependency array of mount, so I think this makes sense.

Copy link
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always appreciate something that simplifies things. Just want to check the one thing first

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.

4 participants