Skip to content

Commit

Permalink
enforce blocks not being formatted with inline
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Sep 28, 2016
1 parent f92f1ed commit 8a71905
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/blot/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class BlockBlot extends FormatBlot {
}

format(name: string, value: any) {
if (name === this.statics.blotName && !value) {
if (Registry.query(name, Registry.Scope.BLOCK) == null) {
return;
} else if (name === this.statics.blotName && !value) {
this.replaceWith(BlockBlot.blotName);
} else {
super.format(name, value);
Expand Down
10 changes: 10 additions & 0 deletions test/unit/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@ describe('Block', function() {
expect(container.children.length).toBe(3);
expect(container.children.head.next.statics.blotName).toBe('video');
});

it('ignore inline', function() {
let container = Registry.create('scroll');
let block = Registry.create('header', 1);
container.appendChild(block);
block.format('bold', true);
expect(container.domNode.innerHTML).toBe('<h1></h1>');
expect(container.children.head.statics.blotName).toBe('header');
expect(container.children.head.formats()).toEqual({ header: 'h1' });
});
});
});

0 comments on commit 8a71905

Please sign in to comment.