Skip to content

MentionItem

MentionItem configures mention behavior inside the editor, such as @user, #topic or custom business entities. Pass mentionItemAttr to PowerEditor to define candidates, filtering, selection callbacks and click callbacks.

Props

PropTypeRequiredDefaultDescription
valuestringNo-Current input value.
placeholderstringNoWrite something...Placeholder text.
mentionListarray | functionNo[]Candidate list, or a function that returns candidates.
filterFuncfunctionNo-Custom candidate filter.
chooseItemCallbackfunctionNo-Called after a candidate is selected.
mentionClickCallbackfunctionNo-Called when an inserted mention is clicked.
headerForegroundstring | functionNorgba(0, 120, 212, 1)Popper header foreground color.
showPopperbooleanNofalseWhether to show the candidate popper.
theme'light' | 'dark'NolightTheme.

Configure PowerEditor

mentionList, filterFunc, chooseItemCallback, mentionClickCallback and headerForeground are usually passed through mentionItemAttr when PowerEditor is initialized.

vue
<template>
    <power-editor :mention-item-attr="mentionItemAttr" />
</template>

<script>
export default {
    data() {
        return {
            mentionItemAttr: {
                mentionList: (value) => [
                    { label: 'Alice', value: 'alice' },
                    { label: 'Bob', value: 'bob' }
                ],
                filterFunc: (listItem, value) => {
                    return listItem.label.toLowerCase().includes(value.toLowerCase());
                },
                chooseItemCallback: (chooseItem, value) => {
                    console.log('chooseItemCallback', chooseItem, value);
                },
                mentionClickCallback: (chooseItem, value) => {
                    console.log('mentionClickCallback', chooseItem, value);
                },
                headerForeground: () => {
                    return '#958DF1';
                }
            }
        };
    }
};
</script>

Callback Notes

Keep filterFunc lightweight and focused on filtering. For remote search, handle data loading in mentionList or cache candidates before filtering.

Use chooseItemCallback to record selection behavior or enrich business data. Use mentionClickCallback for detail cards, navigation or entity inspection.

MIT Licensed