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

applyDelta deletes wrong text with insert + delete #3620

Closed
luin opened this issue Aug 3, 2022 · 0 comments · Fixed by #3777
Closed

applyDelta deletes wrong text with insert + delete #3620

luin opened this issue Aug 3, 2022 · 0 comments · Fixed by #3777

Comments

@luin
Copy link
Member

luin commented Aug 3, 2022

In applyDelta, if a block embed is inserted to the middle of a line, the implicitly added \n cause the deletion happens at a wrong position.

Steps for Reproduction

The following test case fails:

    it('deletes text and appends block embed', function() {
      const editor = this.initialize(Editor, `<p><br></p><p>abc</p>`);
      editor.applyDelta(
        new Delta()
          .retain(2)
          .insert({ video: '#' })
          .delete(2),
      );
      expect(this.container).toEqualHTML(
        '<p><br></p><p>a</p><iframe class="ql-video" frameborder="0" allowfullscreen="true" src="#"></iframe><p><br></p>',
      );
    });

Expected behavior:

The result is <p><br></p><p>a</p><iframe class="ql-video" frameborder="0" allowfullscreen="true" src="#"></iframe><p><br></p>.

Actual behavior:

The result is <p><br></p><p>a</p><p>c</p>

Platforms:

Chrome v103.

Version:

2.0.0-dev.4

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 a pull request may close this issue.

1 participant