Migrate `onToolbarCreate` to the DiscourseAPI
This commit is contained in:
parent
7b8e313dac
commit
f6aa1ac37a
|
@ -176,8 +176,13 @@ class Toolbar {
|
|||
}
|
||||
}
|
||||
|
||||
export function onToolbarCreate(func) {
|
||||
export function addToolbarCallback(func) {
|
||||
_createCallbacks.push(func);
|
||||
}
|
||||
|
||||
export function onToolbarCreate(func) {
|
||||
console.warn('`onToolbarCreate` is deprecated, use the plugin api instead.');
|
||||
addToolbarCallback(func);
|
||||
};
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { onToolbarCreate } from 'discourse/components/d-editor';
|
||||
import { withPluginApi } from 'discourse/lib/plugin-api';
|
||||
|
||||
export default {
|
||||
name: 'enable-emoji',
|
||||
|
@ -7,7 +7,8 @@ export default {
|
|||
const siteSettings = container.lookup('site-settings:main');
|
||||
|
||||
if (siteSettings.enable_emoji) {
|
||||
onToolbarCreate(toolbar => {
|
||||
withPluginApi('0.1', api => {
|
||||
api.onToolbarCreate(toolbar => {
|
||||
toolbar.addButton({
|
||||
id: 'emoji',
|
||||
group: 'extras',
|
||||
|
@ -16,6 +17,7 @@ export default {
|
|||
title: 'composer.emoji'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// enable plugin emojis
|
||||
Discourse.Emoji.applyCustomEmojis();
|
||||
|
|
|
@ -3,6 +3,7 @@ import ComposerEditor from 'discourse/components/composer-editor';
|
|||
import { addPosterIcon } from 'discourse/widgets/poster-name';
|
||||
import { addButton } from 'discourse/widgets/post-menu';
|
||||
import { includeAttributes } from 'discourse/lib/transform-post';
|
||||
import { addToolbarCallback } from 'discourse/components/d-editor';
|
||||
|
||||
let _decorateId = 0;
|
||||
function decorate(klass, evt, cb) {
|
||||
|
@ -86,6 +87,10 @@ class PluginApi {
|
|||
addButton(name, callback);
|
||||
}
|
||||
|
||||
onToolbarCreate(callback) {
|
||||
addToolbarCallback(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let _pluginv01;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import componentTest from 'helpers/component-test';
|
||||
import { onToolbarCreate } from 'discourse/components/d-editor';
|
||||
import { withPluginApi } from 'discourse/lib/plugin-api';
|
||||
|
||||
moduleForComponent('d-editor', {integration: true});
|
||||
|
||||
|
@ -540,7 +540,8 @@ componentTest('emoji', {
|
|||
template: '{{d-editor value=value}}',
|
||||
setup() {
|
||||
// Test adding a custom button
|
||||
onToolbarCreate(toolbar => {
|
||||
withPluginApi('0.1', api => {
|
||||
api.onToolbarCreate(toolbar => {
|
||||
toolbar.addButton({
|
||||
id: 'emoji',
|
||||
group: 'extras',
|
||||
|
@ -548,6 +549,7 @@ componentTest('emoji', {
|
|||
action: 'emoji'
|
||||
});
|
||||
});
|
||||
});
|
||||
this.set('value', 'hello world.');
|
||||
},
|
||||
test(assert) {
|
||||
|
|
Loading…
Reference in New Issue