diff --git a/blots/scroll.ts b/blots/scroll.ts index 89efb3a783..d3583b1802 100644 --- a/blots/scroll.ts +++ b/blots/scroll.ts @@ -200,10 +200,10 @@ class Scroll extends ScrollBlot { renderBlock.key, renderBlock.value, ) as EmbedBlot; + this.insertBefore(blockEmbed, refBlot || undefined); Object.keys(renderBlock.attributes).forEach(name => { blockEmbed.format(name, renderBlock.attributes[name]); }); - this.insertBefore(blockEmbed, refBlot || undefined); } }); } diff --git a/test/fuzz/editor.test.ts b/test/fuzz/editor.test.ts index 08a707ccd5..4b239238a3 100644 --- a/test/fuzz/editor.test.ts +++ b/test/fuzz/editor.test.ts @@ -36,6 +36,7 @@ const attributeDefs: { { name: 'height', values: ['100', '200', '300'] }, ], blockEmbed: [ + { name: 'align', values: ['center', 'right'] }, { name: 'width', values: ['100', '200', '300'] }, { name: 'height', values: ['100', '200', '300'] }, ], diff --git a/test/unit/core/editor.js b/test/unit/core/editor.js index fd6318e75c..c82a004335 100644 --- a/test/unit/core/editor.js +++ b/test/unit/core/editor.js @@ -926,7 +926,7 @@ describe('Editor', function () { }); }); - it('inserts formatted block embeds', function () { + it('inserts formatted block embeds (styles)', function () { const editor = this.initialize(Editor, `

`); editor.insertContents( 0, @@ -944,6 +944,24 @@ describe('Editor', function () { ]); }); + it('inserts formatted block embeds (attributor)', function () { + const editor = this.initialize(Editor, `

`); + editor.insertContents( + 0, + new Delta() + .insert('a\n') + .insert({ video: '#' }, { align: 'center' }) + .insert({ video: '#' }, { align: 'center' }) + .insert('\nd'), + ); + expect(editor.getDelta().ops).toEqual([ + { insert: 'a\n' }, + { insert: { video: '#' }, attributes: { align: 'center' } }, + { insert: { video: '#' }, attributes: { align: 'center' } }, + { insert: '\nd\n' }, + ]); + }); + it('inserts inline embeds to bold text', function () { const editor = this.initialize(Editor, `

ab

`); editor.insertContents(1, new Delta().insert({ image: '#' }));