fix(toolbar): multi-line toggleBlockquote support matching list toggle pattern#119
Open
alph-cmky wants to merge 1 commit into
Open
fix(toolbar): multi-line toggleBlockquote support matching list toggle pattern#119alph-cmky wants to merge 1 commit into
alph-cmky wants to merge 1 commit into
Conversation
…e pattern Previously toggleBlockquote only operated on the cursor's single line, while toggleOrderedList and toggleUnorderedList already supported multi-line selections via getLinesInRange + applyLines helpers. This change makes toggleBlockquote use the same multi-line path: - All selected lines have "> " → remove from all - Mixed or none have "> " → add to all (stripping existing prefix first) - Single line and collapsed cursor behaviour preserved Removed the now-unused toggleLinePrefix helper. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
redreamality
approved these changes
Jul 3, 2026
redreamality
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed PR #119.
This is a focused and well-scoped fix for toggleBlockquote multi-line behavior, aligning it with the existing ordered/unordered list toggle implementation style.
Validation performed in an isolated checkout:
pnpm exec tsc --noEmit -p packages/plugin-toolbar/tsconfig.json
pnpm --filter @floatboat/nexus-plugin-toolbar test -- plugin-toolbar --reporter=verbose
pnpm --filter @floatboat/nexus-plugin-toolbar test -- --runInBand
pnpm exec tsc --noEmit -p packages/core/tsconfig.json
These checks passed.
Review notes:
- CLA is passing.
- The implementation reuses the existing
getLinesInRange/applyLinespattern used by list toggles instead of introducing a separate path. - The PR preserves single-line behavior while adding multi-line support.
- Mixed selected lines are normalized instead of producing nested
> > textprefixes. - The change keeps the replacement as a single transaction via
replaceRange, which is important for atomic undo behavior. - Test coverage is strong for the size of the change: single-line compatibility, multi-line add/remove, mixed selections, reversed selection, line-boundary behavior, round-trip stability, and undo atomicity.
Conclusion: approved from code-review perspective.
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 / 摘要
Make
toggleBlockquotesupport multi-line selections, matching the existing behaviour oftoggleOrderedListandtoggleUnorderedList.Motivation / 背景与动机
toggleOrderedListandtoggleUnorderedListboth support multi-line selections via thegetLinesInRange+applyLineshelpers informatting.ts. However,toggleBlockquotewas implemented as a single-line-only wrapper around the now-removedtoggleLinePrefixhelper, breaking consistency across the formatting API.Changes / 变更内容
packages/plugin-toolbar:src/formatting.ts: RewrotetoggleBlockquoteto usegetLinesInRange+applyLines, matching the list toggle pattern. In mixed-state mode, strips existing>before adding a new prefix (avoids> > text). Removed the now-unusedtoggleLinePrefixhelper.test/plugin-toolbar.test.ts: Added 16 test cases across 4 describe blocks — single-line backward compat, multi-line selection (6 cases including reversed/re-mixed/boundary), round-trip stability, and atomic undo (7 cases mirroring the existing list toggle test suite).Testing / 测试
pnpm testpasses — 531 tests (515 existing + 16 new)pnpm typecheckpasses — zero errorsCompliance / 合规自检
Checklist / 自检清单
live-preview-table.ts