Skip to content

fix: remove extra blank lines between list items on clipboard copy#70

Merged
j4rviscmd merged 2 commits intomainfrom
fix/clipboard-tighten
Mar 27, 2026
Merged

fix: remove extra blank lines between list items on clipboard copy#70
j4rviscmd merged 2 commits intomainfrom
fix/clipboard-tighten

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

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-stringify to produce the text/plain clipboard data, which defaults to loose lists (blank lines between items). The Markdown export path already had tightenList() to fix this, but the clipboard copy path did not.

Solution

Added a useClipboardTightenList hook that post-processes the text/plain clipboard 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 logic
  • src/features/editor/ui/Editor.tsx — Register the new hook

Testing

  1. Create a checklist with parent (x1) + children (x2+)
  2. Select all and Ctrl+C
  3. Paste into another text editor
  4. ✅ No extra blank lines between list items
  5. ✅ Blank lines between normal text and lists are preserved

j4rviscmd and others added 2 commits March 27, 2026 17:27
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>
@j4rviscmd j4rviscmd added the bug Something isn't working label Mar 27, 2026
@j4rviscmd j4rviscmd merged commit 3a6713f into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the fix/clipboard-tighten branch March 27, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant