Skip to content

Commit

Permalink
Ensure that the editor triggers an update when clicking "heading"
Browse files Browse the repository at this point in the history
fixes #58
  • Loading branch information
bantic committed Aug 11, 2015
1 parent 250a976 commit 5344ca2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/js/commands/format-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FormatBlockCommand extends TextFormatCommand {

editor.rerender();
editor.selectSections(activeSections);
this.editor.didUpdate();
}

unexec() {
Expand All @@ -41,6 +42,7 @@ class FormatBlockCommand extends TextFormatCommand {

editor.rerender();
editor.selectSections(activeSections);
this.editor.didUpdate();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/commands/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export default class ImageCommand extends Command {
sections.forEach(section => section.renderNode.scheduleForRemoval());

this.editor.rerender();
this.editor.trigger('update');
this.editor.didUpdate();
}
}
18 changes: 18 additions & 0 deletions tests/acceptance/editor-commands-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ test('highlight text, click "heading" button turns text into h2 header', (assert
});
});

test('click heading button triggers update', (assert) => {
const done = assert.async();
const triggered = [];
const triggerFn = editor.trigger;
editor.trigger = (name, ...args) => {
triggered.push(name);
triggerFn.call(editor, name, ...args);
};

setTimeout(() => {
Helpers.toolbar.clickButton(assert, 'heading');
assert.ok(triggered.indexOf('update') !== -1,
'update was triggered');

done();
});
});

test('highlighting heading text activates toolbar button', (assert) => {
const done = assert.async();

Expand Down

0 comments on commit 5344ca2

Please sign in to comment.