API for adding buttons to the new composer

This commit is contained in:
Robin Ward
2015-11-02 16:05:40 -05:00
parent 290708ca53
commit 5cd6308850
4 changed files with 160 additions and 73 deletions

View File

@ -1,4 +1,5 @@
import componentTest from 'helpers/component-test';
import { onToolbarCreate } from 'discourse/components/d-editor';
moduleForComponent('d-editor', {integration: true});
@ -441,21 +442,34 @@ testCase(`rule with a selection`, function(assert, textarea) {
});
});
testCase(`emoji`, function(assert) {
assert.equal($('.emoji-modal').length, 0);
componentTest('emoji', {
template: '{{d-editor value=value}}',
setup() {
// Test adding a custom button
onToolbarCreate(toolbar => {
toolbar.addButton({
id: 'emoji',
group: 'extras',
icon: 'smile-o',
action: 'emoji'
});
});
this.set('value', 'hello world.');
},
test(assert) {
assert.equal($('.emoji-modal').length, 0);
click('button.emoji');
andThen(() => {
assert.equal($('.emoji-modal').length, 1);
});
click('button.emoji');
andThen(() => {
assert.equal($('.emoji-modal').length, 1);
});
click('a[data-group-id=0]');
click('a[title=grinning]');
click('a[data-group-id=0]');
click('a[title=grinning]');
andThen(() => {
assert.ok($('.emoji-modal').length === 0);
assert.equal(this.get('value'), 'hello world.:grinning:');
});
andThen(() => {
assert.ok($('.emoji-modal').length === 0);
assert.equal(this.get('value'), 'hello world.:grinning:');
});
}
});