Skip to content

🐛 fix(auto-complete): stabilize IME input and simplify preview lifecycle - #207

Open
ilimei wants to merge 3 commits into
masterfrom
fix/auto-complete-ime
Open

ilimei wants to merge 3 commits into
masterfrom
fix/auto-complete-ime

Conversation

@ilimei

@ilimei ilimei commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

🔀 变更说明 | Description of Change

自动补全预览原先通过正式 Markdown 插入流程修改正文,并由多个监听器清理节点和恢复选区,容易干扰中文输入法的组词与上屏过程。本次重写补全生命周期,针对组词卡顿、拼音残留及预览清理问题收紧文档更新边界。

  • 使用单一更新监听器和明确的状态流程管理请求、预览、取消与接受;请求返回时核对光标和正文上下文,丢弃过期结果。

  • 将多段预览放在一个不可编辑的行内容器中,保留灰字、换行和撑开正文的 UI,取消时不拆分原正文段落。

  • 预览插入前先提交待处理的用户更新,再使用独立的预览事务,避免 PREVIEW_TAG 随合批更新跳过用户输入的失效判断。

  • 原生组词开始时用 display: none 隐藏预览;等待上屏事件及 Lexical 更新完成后清理,不恢复旧选区。

  • 保留现有 API,覆盖 Tab 接受、撤销、失焦取消与卸载重挂载清理。

  • 简化 Playground 示例:移除顶部固定工具栏,并局部覆盖编辑区域的全局焦点边框;已在浏览器中验证聚焦效果。

📝 补充信息 | Additional Information

验证:

  • 18 个相关测试通过,包含 DOM 预编辑 a → 啊、两种请求返回/用户输入合批顺序、连续取消后的文本归一化、Safari 延迟 insertFromComposition、预览生命周期及 Markdown 插入回归。
  • 类型检查、ESLint、构建、循环依赖检查通过。
  • Chrome + macOS + 搜狗输入法初步人工测试反馈正常;Windows 微软拼音及 macOS Safari 原生人工测试待验证。

自动化 DOM 事件测试不等同于所有原生输入法实现的兼容性验收。

实现边界:多段预览使用瞬态行内包装器承载块 DOM,不将其 innerHTML 作为可移植 HTML;接受时重新解析 Markdown。旧 PlaceholderBlock 节点和主题选项为反序列化兼容保留。

Simplify completion scheduling and cancellation into a single lifecycle. Keep multiline previews in a non-editable inline container, hide them during composition, and remove them only after native input has settled.

Validate request context before showing suggestions and preserve normal acceptance, undo, blur, and detach behavior. Add native preedit replacement and preview lifecycle regressions.
@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lobe-editor Ready Ready Preview Sep 5, 2026 10:32am UTC

Request Review

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

👍 @ilimei


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@lobehub/editor@207

commit: dd00118

Flush pending user updates before discrete preview insertion so the preview tag cannot mask input invalidation. Cover both response/input orderings, repeated text normalization, and delayed Safari composition commits.

Document transient HTML layout and legacy block-node compatibility.

This branch was successfully deployed

1 active deployment
Preview — dd00118a Deployed Sep 5, 2026 by vercel[bot]
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.

1 participant