mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 21:11:55 +08:00
45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
import app from 'flarum/app';
|
|
import SettingsPage from 'flarum/components/settings-page';
|
|
import { extend } from 'flarum/extension-utils';
|
|
import icon from 'flarum/helpers/icon';
|
|
|
|
import postMentionPreviews from 'flarum-mentions/post-mention-previews';
|
|
import mentionedByList from 'flarum-mentions/mentioned-by-list';
|
|
import postReplyAction from 'flarum-mentions/post-reply-action';
|
|
import composerAutocomplete from 'flarum-mentions/composer-autocomplete';
|
|
import PostMentionedNotification from 'flarum-mentions/components/post-mentioned-notification';
|
|
import UserMentionedNotification from 'flarum-mentions/components/user-mentioned-notification';
|
|
|
|
app.initializers.add('mentions', function() {
|
|
// For every mention of a post inside a post's content, set up a hover handler
|
|
// that shows a preview of the mentioned post.
|
|
postMentionPreviews();
|
|
|
|
// In the footer of each post, show information about who has replied (i.e.
|
|
// who the post has been mentioned by).
|
|
mentionedByList();
|
|
|
|
// Add a 'reply' control to the footer of each post. When clicked, it will
|
|
// open up the composer and add a post mention to its contents.
|
|
postReplyAction();
|
|
|
|
// After typing '@' in the composer, show a dropdown suggesting a bunch of
|
|
// posts or users that the user could mention.
|
|
composerAutocomplete();
|
|
|
|
app.notificationComponentRegistry['postMentioned'] = PostMentionedNotification;
|
|
app.notificationComponentRegistry['userMentioned'] = UserMentionedNotification;
|
|
|
|
// Add notification preferences.
|
|
extend(SettingsPage.prototype, 'notificationTypes', function(items) {
|
|
items.add('postMentioned', {
|
|
name: 'postMentioned',
|
|
label: [icon('reply'), ' Someone replies to my post']
|
|
});
|
|
items.add('userMentioned', {
|
|
name: 'userMentioned',
|
|
label: [icon('at'), ' Someone mentions me in a post']
|
|
});
|
|
});
|
|
});
|