fix: remove extra blank lines between list items on clipboard copy#70
Merged
fix: remove extra blank lines between list items on clipboard copy#70
Conversation
BlockNote's built-in clipboard handler uses remark-stringify which produces loose lists (blank lines between items). Add useClipboardTightenList hook that post-processes the text/plain clipboard data after BlockNote writes it, removing blank lines only between consecutive list items while preserving paragraph-to-list spacing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When copying content from the editor (Ctrl+C) and pasting into other text editors, nested list items had extra blank lines between them. This was inconsistent with the Markdown export behavior which correctly produced tight lists.
Root Cause
BlockNote's clipboard handler uses
remark-stringifyto produce thetext/plainclipboard data, which defaults to loose lists (blank lines between items). The Markdown export path already hadtightenList()to fix this, but the clipboard copy path did not.Solution
Added a
useClipboardTightenListhook that post-processes thetext/plainclipboard data after BlockNote writes it. The hook uses a conservative algorithm that only removes blank lines where both adjacent lines are list items, preserving intentional spacing between paragraphs and lists.Changes
src/features/editor/hooks/useClipboardTightenList.ts— New hook with clipboard-specific list tightening logicsrc/features/editor/ui/Editor.tsx— Register the new hookTesting