微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Cypress Automation 的 CKEditor5 中设置光标位置或选择特定内容?

如何解决如何在 Cypress Automation 的 CKEditor5 中设置光标位置或选择特定内容?

我正在寻找一种在 Cypress Automation 的 ckeditor5 中设置光标位置(或设置选择)的方法。从这个位置开始输入或删除一些内容。但我找不到如何做到这一点的方法。 我尝试使用 ckeditor5 对象如下:

cy.window()
  .its('editor')
  .then(editor => {
    editor.model.change(writer => {
      const position = writer.createPositionFromPath(
        editor.model.document.getRoot(),[0,2,27]);
      const position1 = writer.createPositionFromPath(
        editor.model.document.getRoot(),27]);
      const range = writer.createrange(position1,position);
      writer.setSelection(range);
    });
});
CKEDITOR.Editor.create( document.querySelector( '#editor' ) )
  .then( editor => {
    window.editor = editor;
  })

但它不起作用。

也许有人知道如何做到这一点?使用 cypress 或 ckeditor5 对象...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。