quill icon indicating copy to clipboard operation
quill copied to clipboard

Inserted inline embed inherits formats with applyDelta

Open luin opened this issue 3 years ago • 0 comments
trafficstars

When call updateContents() to insert an embed into the middle of a line, the inserted embed inherits the formats of the target position. If the insertion is a text, it won't inherit any formats.

Steps for Reproduction

The following test case fails:

    it('updateContents() insert text to the middle of formatted content', function() {
      const delta = new Delta()
        .retain(5)
        .insert({ image: '/assets/favicon.png' });
      this.quill.updateContents(delta);
      expect(this.quill.root).toEqualHTML(
        '<p>0123<em>4</em><img src="/assets/favicon.png"><em>5</em>67</p>',
      );
    });

Expected behavior:

<p>0123<em>4</em><img src="/assets/favicon.png"><em>5</em>67</p>

Actual behavior:

<p>0123<em>4<img src="/assets/favicon.png">5</em>67</p>

Platforms:

Chrome v103.

Version:

2.0.0-dev.4

luin avatar Aug 06 '22 00:08 luin