diff --git a/core/editor.ts b/core/editor.ts index 0b7e8c4aee..5b4b6a9a49 100644 --- a/core/editor.ts +++ b/core/editor.ts @@ -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); diff --git a/test/unit/core/editor.js b/test/unit/core/editor.js index 162865c63a..542c896063 100644 --- a/test/unit/core/editor.js +++ b/test/unit/core/editor.js @@ -517,6 +517,16 @@ describe('Editor', function () { ); }); + it('insert inline embed to the middle of formatted content', function () { + const editor = this.initialize(Editor, '
0123
'); + editor.applyDelta( + new Delta().retain(2).insert({ image: '/assets/favicon.png' }), + ); + expect(this.container).toEqualHTML( + '0123