Skip to content

feat(history): configurable undo depth + test(toolbar): coverage + refactor(core): shared helpers + docs#162

Open
yanjiaru1 wants to merge 5 commits into
floatboatai:mainfrom
yanjiaru1:feat/nexus-editor-improvements
Open

feat(history): configurable undo depth + test(toolbar): coverage + refactor(core): shared helpers + docs#162
yanjiaru1 wants to merge 5 commits into
floatboatai:mainfrom
yanjiaru1:feat/nexus-editor-improvements

Conversation

@yanjiaru1

Copy link
Copy Markdown

What

  1. 给 plugin-history 增加 minDepth 和 newGroupDelay 配置项
  2. 给 plugin-toolbar 补充 toggleBlockquote、insertCodeBlock、insertImage、insertHorizontalRule 的测试覆盖
  3. 把 React/Vue 重复的 controlled-document 工具函数提取到 core
  4. 给 EventEmitter 增加 once() 方法
  5. 更新 README 文档,记录 createHistoryPlugin 配置项

Why

  1. plugin-history 当前硬编码调用 CM6 history(),没有任何配置项。Roadmap P1 标记了 "Undo/redo grouping" 为 planned,本 PR 是实现它的第一步。
  2. toolbar 的测试文件覆盖了 bold、italic、link、heading、list 等功能,但 blockquote、code block、image、hr 四个函数完全没有测试。
  3. React 和 Vue 的 controlled-document.ts 有三个完全一样的函数,提取到 core 可以避免维护时改一漏一。
  4. EventEmitter 是核心类,on/off/emit/clear 都有了,但缺少 once() 这个通用 API。
  5. 改了公共接口但没更新文档,不符合项目规范。

How

history

  • 新增 HistoryPluginOptions 接口(minDepth, newGroupDelay)
  • createHistoryPlugin 接受可选 options 参数并转发给 CM6 history()
  • 向后兼容:不传参数时行为不变
  • 新增 2 个测试验证配置生效

toolbar

  • toggleBlockquote 新增 3 个测试
  • insertCodeBlock 新增 2 个测试
  • insertImage 新增 2 个测试
  • insertHorizontalRule 新增 1 个测试

core (refactor)

  • 新建 packages/core/src/controlled-document.ts,包含三个共享函数
  • React 和 Vue 包改为从 core 导入再导出,保持向后兼容

core (feat)

  • EventEmitter 新增 once() 方法,触发一次后自动移除监听

docs

  • README.md 和 README.zh.md 新增 createHistoryPlugin 配置项文档

AI Disclosure

本 PR 使用 AI 辅助工具(Claude)进行代码生成和审查。

Checklist

  • Conventional Commits title
  • CLA signed
  • Tests added, pnpm test passes
  • pnpm build succeeds
  • No new dependencies added
  • Public API changes update README

@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.
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