Repository navigation
输入翻译在 contenteditable 替换后能撤销:普通 contenteditable 走原生撤销栈,受控编辑器走它自己的撤销栈,夹具与端到端都用真实按键验证(#657) - #699
Merged
Merged
Conversation
…夹具与端到端都用真实按键验证(#657) Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
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.
问题
替换后 Ctrl / Cmd+Z 能把原文撤回来,是输入翻译的硬要求:扩展往用户自己写的文字上动手,原文只存在于用户的记忆里。多行文本框已经由 TC-E2E-115 钉住,contenteditable 还没有验证;受控编辑器的撤销栈由编辑器自己管,浏览器的原生撤销栈里根本没有它的改动,要单独验证。
根因
#656 之前 contenteditable 不写回,谈不上撤销。#656 的写回路径决定了撤销能不能成立:
execCommand('insertText'),进原生撤销栈beforeinput,在编辑器的模型里是一步如果写回拆成先删后插,或者绕过编辑器改 DOM,撤销就会停在空框或者撤不回来。
修复
rich-input.html的受控编辑器加上自己的撤销栈(仿 slate-history):验证
ControlOrMeta+z一步回到原文,ControlOrMeta+Shift+z回到译文pnpm test114 个文件 1407 条全绿;pnpm typecheck通过;pnpm build通过;pnpm test:e2e:core88 过、2 跳过Closes #657