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