Skip to content

fix(toolbar): multi-line toggleBlockquote support matching list toggle pattern#119

Open
alph-cmky wants to merge 1 commit into
floatboatai:mainfrom
alph-cmky:fix/toolbar-blockquote-multiline
Open

fix(toolbar): multi-line toggleBlockquote support matching list toggle pattern#119
alph-cmky wants to merge 1 commit into
floatboatai:mainfrom
alph-cmky:fix/toolbar-blockquote-multiline

Conversation

@alph-cmky

Copy link
Copy Markdown

Summary / 摘要

Make toggleBlockquote support multi-line selections, matching the existing behaviour of toggleOrderedList and toggleUnorderedList.

Motivation / 背景与动机

toggleOrderedList and toggleUnorderedList both support multi-line selections via the getLinesInRange + applyLines helpers in formatting.ts. However, toggleBlockquote was implemented as a single-line-only wrapper around the now-removed toggleLinePrefix helper, breaking consistency across the formatting API.

  • Roadmap (docs/ROADMAP.md): Aligns with P1 toolbar completeness goal

Changes / 变更内容

  • packages/plugin-toolbar:
    • src/formatting.ts: Rewrote toggleBlockquote to use getLinesInRange + applyLines, matching the list toggle pattern. In mixed-state mode, strips existing > before adding a new prefix (avoids > > text). Removed the now-unused toggleLinePrefix helper.
    • 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 test passes — 531 tests (515 existing + 16 new)
  • pnpm typecheck passes — zero errors
  • New vitest cases cover:
    • Single-line add/remove (backward compat guard)
    • Multi-line add/remove/mixed/reversed/boundary/end-of-doc
    • Round-trip stability (toggle on → off restores original)
    • Atomic undo Cases 1–7 (including the load-bearing Case 4 — proves single history entry)
  • Manual UI check in electron-demo

Compliance / 合规自检

  • CLA signed — first-time contributor
  • AI disclosure: AI assistance used for test case generation and code review. Implementation logic designed and verified by human.
  • New dependencies: none
  • No build artifacts committed
  • No secrets committed

Checklist / 自检清单

  • Title follows Conventional Commits
  • No public API changes
  • Not touching live-preview-table.ts
  • No breaking changes
  • Change aligns with project scope (GOVERNANCE.md §4)

…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>
@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@redreamality redreamality left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / applyLines pattern 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 > > text prefixes.
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants