-
-
Notifications
You must be signed in to change notification settings - Fork 555
Remove blank line under a 'none' content block will remove 'none' block together #605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is the solution here to check if the block is paragraph, has no content, and focus is start of block (should be impossible to meet these criteria and not meet this one). If that matches, then delete the block rather than merging it? |
Yeah that sounds right - we should already have quite some backspace handling logic here for that, but seems like this case isn't accounted for |
@matthewlipski I'm not sure any of the code blocks there handle that cases this. At least when I looked into it, I came to that conclusion. I wrote some custom keydown handlers (on if (e.key === "Backspace") {
const selection = blockNoteEditor.getSelection()
const position = blockNoteEditor.getTextCursorPosition()
if (selection === undefined && position && position.block.type === "paragraph") {
const block = position.block
const blockPos = getBlockInfoFromPos(
blockNoteEditor._tiptapEditor.state.doc,
blockNoteEditor._tiptapEditor.state.selection.anchor
)
const isTopBlock = blockPos.depth === 2
const isEmptyBlock = block.content.length === 0 && block.children.length === 0
const isEmptyContentWithChildren = block.content.length === 0 && block.children.length > 0
if (isTopBlock && isEmptyBlock) {
e.stopPropagation()
e.preventDefault()
blockNoteEditor.removeBlocks([block])
if (position.prevBlock) {
blockNoteEditor.setTextCursorPosition(position.prevBlock, "end")
}
} else if (isTopBlock && position.prevBlock && isEmptyContentWithChildren && Array.isArray(position.prevBlock.children)) {
e.stopPropagation()
e.preventDefault()
blockNoteEditor.updateBlock(position.prevBlock, { children: position.prevBlock.children.concat(block.children) })
blockNoteEditor.removeBlocks([block])
if (position.prevBlock) {
blockNoteEditor.setTextCursorPosition(position.prevBlock, "end")
}
}
}
} |
Hmm have you tried modifying the code from |
Hi @matthewlipski, I've created a pull request to resolve this issue. Could you please review it at your convenience? Thank you! |
Describe the bug

When I need to remove a blank line under a 'none' type content, it never works, remove the 'none' content together.
I think remove a blank line is reasonable action.
I tried, all
content: "none",
will cause this bug.To Reproduce
Misc
The text was updated successfully, but these errors were encountered: