Repository navigation
Description
Describe the bug
I am using this very simple custom block:
export const Title = createReactBlockSpec(
{
type: 'title',
propSchema: {
type: {
default: 'type-a',
values: ['type-a', 'type-b'],
},
},
content: 'inline',
hardBreakShortcut: 'none',
},
{
render: (props) => {
return (
<div className="title-block" data-title-type={props.block.props.type}>
<div className="inline-content" ref={props.contentRef}/>
</div>
);
},
},
);The CSS is something like this:
.title-block {
text-align: center;
} When the block is added, the cursor is blinking on the left edge of the added block div (hardly visible in the image).
As soon as I start typing the cursor moves to the center (as per text-align: center) and everything looks OK.
If I inspect the DOM however, the following is created:
<div class="title-block" data-title-type="title">
dfvvdfvdf
<div class="bn-inline-content inline-content"></div>
</div>The text is not added to the .inline-content element that holds the contentRef but before that node. Also the document content is not updated and the block has an empty content property. And therefore the UI also considers the block empty replacing it when you try to add a block with the + button on said custom block.
It works however, if I do not start typing immediately after adding the block:
- add custom block
- click anywhere into another block (if there's no other block than this does not work)
- click back into the newly added custom block
- start typing
- DOM looks good.
To Reproduce
- add custom block
- start typing after the block has been added
The issue is reproducible here: https://stackblitz.com/edit/github-scugpd2y?file=App.tsx
Misc
- Node version: v24.4.0
- Package manager: npm 10.9.1
- Browser: Google Chrome
- React: 18.3.1
Activity
MetaMmodern commentedon Jul 26, 2025
I actually have the same thing, but in my case cursor appears right after my custom block. @sgehrig Have you found a solution so far?
sgehrig commentedon Jul 26, 2025
@MetaMmodern Not yet. To be honest, at this point I was simply hoping for a fix.
MetaMmodern commentedon Jul 27, 2025
I've tried digging more and found this issue: #1802
So decided to try that same approach and digged more into TipTap.
I mixed in React stuff through addNodeView and could reproduce it in my app.
The funny part is that this versions works without bugs:
but this doesn't:
It renders cursor underneath the block:
chatgpt has been telling that this is somehow related to how React handles refs, not attaching them right away before render. I guess NodeViewContent is using a ref internally.
But I don't understand why it works in tipTap and BlockNote examples but doesn't work inside my app...
I'm not even sure I can reproduce this in sandbox and I'm tired:(
MetaMmodern commentedon Jul 27, 2025
I checked BlockNote source code as well, it uses the exact same approach of ReactNodeViewRenderer. So, that means it's something breaking on that TipTap level.
MetaMmodern commentedon Jul 27, 2025
@nperez0111 can you please look into this and let us know if this is even something we could fix ourselves? The wild part is that official examples work, while our attempts fail with this cursor bug.
sgehrig commentedon Jul 27, 2025
One thing to note: we're using React 18 (and that's what my reproducer uses as well) but most official examples use React 19 if I'm not mistaken.
MetaMmodern commentedon Jul 27, 2025
I use react 19.1
So probably not the cause
P.S. although, our issues are slightly different, so maybe maybe
Can you bump it to 19 in your stackblitz?
sgehrig commentedon Jul 28, 2025
The problem is that we need React 18 because the application is not yet ready for 19. That's why I explicitly tried to mimic the real environment.
sgehrig commentedon Aug 25, 2025
@nperez0111 Much appreciated! Thanks a lot.
fix(react): set data-node-view-content on styled inline contentRef ta…
fix(react): set data-node-view-content on styled inline contentRef ta…