diff --git a/docs/en-US/component/mention.md b/docs/en-US/component/mention.md index 1212bfd8a8..5bf57ac386 100644 --- a/docs/en-US/component/mention.md +++ b/docs/en-US/component/mention.md @@ -105,11 +105,12 @@ and please go to the original component to view the documentation. ### Events -| Name | Description | Type | -| --------------------------------- | ----------------------------------- | ------------------------------------------------------------ | -| search | trigger when prefix hit | ^[Function]`(pattern: string, prefix: string) => void` | -| select | trigger when user select the option | ^[Function]`(option: MentionOption, prefix: string) => void` | -| [input events](./input.md#events) | — | — | +| Name | Description | Type | +| --------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | +| search | trigger when prefix hit | ^[Function]`(pattern: string, prefix: string) => void` | +| select | trigger when user select the option | ^[Function]`(option: MentionOption, prefix: string) => void` | +| whole-remove ^(2.10.4) | trigger when a whole mention is removed and `whole` is `true` or `check-is-whole` is `true` | ^[Function]`(pattern: string, prefix: string) => void` | +| [input events](./input.md#events) | — | — | ### Slots diff --git a/packages/components/mention/src/mention.ts b/packages/components/mention/src/mention.ts index c0f3e73e0f..0a213524f6 100644 --- a/packages/components/mention/src/mention.ts +++ b/packages/components/mention/src/mention.ts @@ -108,6 +108,8 @@ export const mentionProps = buildProps({ export const mentionEmits = { [UPDATE_MODEL_EVENT]: (value: string) => isString(value), + 'whole-remove': (pattern: string, prefix: string) => + isString(pattern) && isString(prefix), input: (value: string) => isString(value), search: (pattern: string, prefix: string) => isString(pattern) && isString(prefix), diff --git a/packages/components/mention/src/mention.vue b/packages/components/mention/src/mention.vue index 894a700aee..b742ce18e7 100644 --- a/packages/components/mention/src/mention.vue +++ b/packages/components/mention/src/mention.vue @@ -178,6 +178,7 @@ const handleInputKeyDown = (event: KeyboardEvent | Event) => { inputValue.slice(0, prefixIndex) + inputValue.slice(splitIndex + 1) emit(UPDATE_MODEL_EVENT, newValue) emit(INPUT_EVENT, newValue) + emit('whole-remove', pattern, prefix) const newSelectionEnd = prefixIndex nextTick(() => {