Skip to content

fix(toolbar): make blockquote toggle range-aware and atomic#140

Open
he666-ux wants to merge 1 commit into
floatboatai:mainfrom
he666-ux:fix/toolbar-blockquote-range-clean
Open

fix(toolbar): make blockquote toggle range-aware and atomic#140
he666-ux wants to merge 1 commit into
floatboatai:mainfrom
he666-ux:fix/toolbar-blockquote-range-clean

Conversation

@he666-ux

@he666-ux he666-ux commented Jul 8, 2026

Copy link
Copy Markdown

Summary / 摘要

Make toggleBlockquote() range-aware and atomic so blockquote toggling behaves consistently with existing list toggles.

toggleBlockquote() 支持范围选区和原子更新,使 blockquote 的切换行为与现有列表切换保持一致。

Motivation / 背景与动机

toggleBlockquote() previously only operated on the active line and updated the document/selection separately. That made its behavior inconsistent with toggleOrderedList() and toggleUnorderedList(), which already support multi-line ranges and atomic undo.

之前的 toggleBlockquote() 只处理当前行,并且分开更新文档和选区,这与已经支持多行选区和原子撤销的 toggleOrderedList() / toggleUnorderedList() 不一致。

What Changed / 改动内容

  • make toggleBlockquote() apply to every covered line in the current selection

  • remove > from all selected lines when they are already quoted

  • preserve the existing single-line behavior for collapsed selections

  • support reversed selections and range boundaries consistently with other block-level toggles

  • switch the implementation to a single atomic range replacement so one undo restores both the document and the selection

  • toggleBlockquote() 对当前选区覆盖的所有行生效

  • 当所有选中行都已带 > 时,统一移除前缀

  • 保留折叠光标场景下的单行行为

  • 让反向选区和边界行为与其他块级 toggle 保持一致

  • 改为单次原子范围替换,保证一次 undo 同时恢复文档和选区

Tests / 测试

  • pnpm test packages/plugin-toolbar/test/plugin-toolbar.test.ts
  • pnpm test
  • pnpm --filter @floatboat/nexus-plugin-toolbar build

Added coverage for:

  • single-line blockquote toggle
  • multi-line range toggle
  • mixed-state, reversed-selection, and boundary behavior
  • atomic undo / redo regression cases

新增覆盖包括:

  • 单行 blockquote 切换
  • 多行范围切换
  • 混合状态、反向选区、边界场景
  • 原子 undo / redo 回归用例

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


heshengqi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants