Skip to content

当一段文本存在换行时,上、下快捷键的光标移动位置行为出现异常 #185

@laden666666

Description

@laden666666

Description
快捷键 上、下 行为异常,正常的 上、 下 行为是移动到上、下一行同 x 方向的位置,但是 editable 的上、下快捷键错乱

Recording
Image

Sandbox
playground 可以复现

Steps
To reproduce the behavior:

  1. 输入一大段文字,让其折行(最少4行)
  2. 将光标选择第三行中间部分
  3. 点击键盘”上“,光标移动到第一行左边,而不是第二行中间。
  4. 点击键盘”下“,光标移动到第四行左边,而不是第四行中间。

Expectation

  1. 希望 上 是移动到上一行,而不是第一行
  2. 希望上和下都能移动到对应的 x 方向的文本上,而不是行首

Environment

  • Editable Version: 最新版的playground
  • Operating System: Macos,Window 都复现了
  • Browser: chrome
  • TypeScript Version: 最新版的playground

Context
我看了源码,问题出现在 findPreviousLinePoint、findNextLinePoint:

  • 居左问题是 isSameLine 判断错误,导致均使用 9999 做 x 查询
  • 上会到第一行是 findPreviousLinePoint 中循环顺序错了
    如果需要,我可以尝试提供 PR 修复

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions