feat(components): [mention] add whole-remove event (#21050)

* feat(components): [mention] 添加mention-remove事件,当props.whole为真且移除提及项时触发

* feat(components): [mention] 添加whole-remove事件,当props.whole为真且移除提及项时触发

* feat(components): [mention]添加 whole-remove事件,并更新了文档说明

* feat(components): [mention]添加 whole-remove事件,并更新了文档说明

* feat(components): [mention]添加 whole-remove事件,并更新了文档说明

* feat(components): [mention]添加 whole-remove事件,并更新了文档说明

* Update docs/en-US/component/mention.md

---------

Co-authored-by: btea <2356281422@qq.com>
This commit is contained in:
56jun
2025-07-10 16:40:18 +08:00
committed by GitHub
parent 173c1cbfd7
commit e4d3ce2970
3 changed files with 9 additions and 5 deletions

View File

@@ -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

View File

@@ -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),

View File

@@ -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(() => {