Skip to content

Commit

Permalink
Fix block embed attributor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jul 6, 2023
1 parent b65abc1 commit 0614441
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/fuzz/editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] },
],
Expand Down
20 changes: 19 additions & 1 deletion test/unit/core/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, `<p></p>`);
editor.insertContents(
0,
Expand All @@ -944,6 +944,24 @@ describe('Editor', function () {
]);
});

it('inserts formatted block embeds (attributor)', function () {
const editor = this.initialize(Editor, `<p></p>`);
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, `<p><strong>ab</strong></p>`);
editor.insertContents(1, new Delta().insert({ image: '#' }));
Expand Down

0 comments on commit 0614441

Please sign in to comment.