mirror of
https://github.com/flarum/framework.git
synced 2025-03-03 21:03:11 +08:00
fix(mentions): cannot use mentionables extender (#3849)
This commit is contained in:
parent
2bc2899a1d
commit
d2a6329689
@ -5,12 +5,9 @@ import TextEditorButton from 'flarum/common/components/TextEditorButton';
|
||||
import KeyboardNavigatable from 'flarum/common/utils/KeyboardNavigatable';
|
||||
|
||||
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
|
||||
import MentionFormats from './mentionables/formats/MentionFormats';
|
||||
import MentionableModels from './mentionables/MentionableModels';
|
||||
|
||||
export default function addComposerAutocomplete() {
|
||||
app.mentionFormats = new MentionFormats();
|
||||
|
||||
const $container = $('<div class="ComposerBody-mentionsDropdownContainer"></div>');
|
||||
const dropdown = new AutocompleteDropdown();
|
||||
|
||||
|
@ -5,7 +5,7 @@ import type MentionFormat from '../mentionables/formats/MentionFormat';
|
||||
|
||||
export default class Mentionables implements IExtender<ForumApplication> {
|
||||
protected formats: (new () => MentionFormat)[] = [];
|
||||
protected mentionables: Record<string, (new () => MentionableModel)[]> = {};
|
||||
protected mentionables: Record<string, (new (...args: any[]) => MentionableModel)[]> = {};
|
||||
|
||||
/**
|
||||
* Register a new mention format.
|
||||
@ -26,7 +26,7 @@ export default class Mentionables implements IExtender<ForumApplication> {
|
||||
* @param mentionable The mentionable instance to register.
|
||||
* Must extend MentionableModel.
|
||||
*/
|
||||
mentionable(symbol: string, mentionable: new () => MentionableModel): this {
|
||||
mentionable(symbol: string, mentionable: new (...args: any[]) => MentionableModel): this {
|
||||
if (!this.mentionables[symbol]) {
|
||||
this.mentionables[symbol] = [];
|
||||
}
|
||||
|
@ -13,11 +13,14 @@ import addComposerAutocomplete from './addComposerAutocomplete';
|
||||
import PostMentionedNotification from './components/PostMentionedNotification';
|
||||
import UserMentionedNotification from './components/UserMentionedNotification';
|
||||
import GroupMentionedNotification from './components/GroupMentionedNotification';
|
||||
import MentionFormats from './mentionables/formats/MentionFormats';
|
||||
import UserPage from 'flarum/forum/components/UserPage';
|
||||
import LinkButton from 'flarum/common/components/LinkButton';
|
||||
import User from 'flarum/common/models/User';
|
||||
import Model from 'flarum/common/Model';
|
||||
|
||||
app.mentionFormats = new MentionFormats();
|
||||
|
||||
export { default as extend } from './extend';
|
||||
|
||||
app.initializers.add('flarum-mentions', function () {
|
||||
|
@ -4,7 +4,7 @@ import TagMention from '../TagMention';
|
||||
|
||||
export default class HashMentionFormat extends MentionFormat {
|
||||
public mentionables: (new (...args: any[]) => MentionableModel)[] = [TagMention];
|
||||
protected extendable: boolean = false;
|
||||
protected extendable: boolean = true;
|
||||
|
||||
public trigger(): string {
|
||||
return '#';
|
||||
|
Loading…
x
Reference in New Issue
Block a user