Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox 在点击按钮上传图片时,光标会偏移致使图片位置错乱 #1136

Open
xp0inter opened this issue Dec 17, 2021 · 10 comments
Assignees

Comments

@xp0inter
Copy link

xp0inter commented Dec 17, 2021

编辑模式

  • wysiwyg 所见即所得模式

描述问题

光标位置会偏移造成图片位置错乱
比如下图所示,光标在文章地下,但是点击按钮上传图片,图片会跑到文章开头
firefoxBUG

下图是会跑到已输入的内容(文字123)的前面去
firefoxBUG2

期待的结果

修正光标位置,上传图片的位置在光标所处位置

截屏或录像

版本信息

  • 版本: 3.8.8
  • 操作系统:windows 10
  • 浏览器:Firefox 95.0.1 (64 位)

其他信息

@snowchenlei
Copy link

这个问题我也有,每次图片都插到最开头去了。我还以为设置有问题呢。而且图片回车也有问题,一大片空白还删不掉。
firefox的兼容性比较差
edge是正常的。

@tenglongwentian
Copy link

这个问题我这边也发现了,最初以为是document.execCommand("insertHTML", false, succFileText)执行结果为false,查询mdn文档发现该指令已被废弃,但是后来发现是因为失去焦点光标造成的,啥时候解决了,求告知。

@tenglongwentian
Copy link

@Vanessa219

@Vanessa219
Copy link
Owner

最近比较忙,兼容性问题可能要等一等,如果着急的可以先 PR。

@tenglongwentian
Copy link

@Vanessa219 期待官方更好的修复。这边目前的策略是针对Firefox浏览器进行覆盖的方式进行处理,但是这种方式仅适用于在结尾处插入图片的情况。that.contentEditor.setValue(that.contentEditor.getValue() + succFileText)

@tenglongwentian
Copy link

@Vanessa219 尝试了另一种光标定位,很不理想。

@tenglongwentian
Copy link

@Vanessa219 that.contentEditor.focus()编辑器这个焦点Google中与Firefox中结果不一致,top存在差异。

@Vanessa219
Copy link
Owner

兼容性问题是比较麻烦的。

@tenglongwentian
Copy link

@Vanessa219 给点思路,怎么处理手动更新focus焦点,尝试了range,但是完全不对。

@Vanessa219
Copy link
Owner

  const selection = window.getSelection();
    selection.removeAllRanges();
    selection.addRange(range);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants