Skip to content

Commit

Permalink
Fix embed inherits formats unexpectedly
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jun 1, 2023
1 parent 663e9bd commit 9e513a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Editor {
) {
isImplicitNewlineAppended = true;
}
const [leaf] = this.scroll.leaf(index);
const formats = merge({}, bubbleFormats(leaf));
attributes = AttributeMap.diff(formats, attributes) || {};
} else if (index > 0) {
// @ts-expect-error
const [leaf, offset] = this.scroll.descendant(LeafBlot, index - 1);
Expand Down
10 changes: 10 additions & 0 deletions test/unit/core/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ describe('Quill', function () {
Emitter.sources.API,
);
});

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>',
);
});
});

describe('events', function () {
Expand Down

0 comments on commit 9e513a2

Please sign in to comment.