@@ -3,11 +3,11 @@ import {htmlEscape} from 'escape-goat';
33
44type TributeItem = Record < string , any > ;
55
6- function makeCollections ( mentions : boolean , emoji : boolean ) {
7- const collections = [ ] ;
6+ export async function attachTribute ( element : HTMLElement ) {
7+ const { default : Tribute } = await import ( /* webpackChunkName: "tribute" */ 'tributejs' ) ;
88
9- if ( emoji ) {
10- collections . push ( {
9+ const collections = [
10+ { // emojis
1111 trigger : ':' ,
1212 requireLeadingSpace : true ,
1313 values : ( query : string , cb : ( matches : Array < string > ) => void ) => {
@@ -28,11 +28,7 @@ function makeCollections(mentions: boolean, emoji: boolean) {
2828 menuItemTemplate : ( item : TributeItem ) => {
2929 return `<div class="tribute-item">${ emojiHTML ( item . original ) } <span>${ htmlEscape ( item . original ) } </span></div>` ;
3030 } ,
31- } ) ;
32- }
33-
34- if ( mentions ) {
35- collections . push ( {
31+ } , { // mentions
3632 values : window . config . mentionValues ?? [ ] ,
3733 requireLeadingSpace : true ,
3834 menuItemTemplate : ( item : TributeItem ) => {
@@ -44,15 +40,9 @@ function makeCollections(mentions: boolean, emoji: boolean) {
4440 </div>
4541 ` ;
4642 } ,
47- } ) ;
48- }
43+ } ,
44+ ] ;
4945
50- return collections ;
51- }
52-
53- export async function attachTribute ( element : HTMLElement , mentions : boolean , emoji : boolean ) {
54- const { default : Tribute } = await import ( /* webpackChunkName: "tribute" */ 'tributejs' ) ;
55- const collections = makeCollections ( mentions , emoji ) ;
5646 // @ts -expect-error TS2351: This expression is not constructable (strange, why)
5747 const tribute = new Tribute ( { collection : collections , noMatchTemplate : '' } ) ;
5848 tribute . attach ( element ) ;
0 commit comments