Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<div id="app">
<at :members="members" name-key="name" v-model="html">
<!-- custom: same as default slot -->
<!-- <template slot="item" scope="s">
<!-- <template slot="item" slot-scope="s">
<span v-text="s.item"></span>
</template> -->

<!-- custom: with avatars -->
<template slot="item" scope="s">
<template slot="item" slot-scope="s">
<img :src="s.item.avatar">
<span v-text="s.item.name"></span>
</template>
Expand All @@ -18,7 +18,7 @@

<at-ta :members="members" name-key="name" v-model="text">
<!-- custom: with avatars -->
<template slot="item" scope="s">
<template slot="item" slot-scope="s">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed to use slot-scope as a Vue upgrade, 👍
but I've been afraid it would break users that were still using older versions of Vue.

So I'd like to make such changes later in a major bump 😄

<img :src="s.item.avatar">
<span v-text="s.item.name"></span>
</template>
Expand Down
9 changes: 7 additions & 2 deletions src/At.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export default {
scrollRef: {
type: String,
default: ''
}
},
processItem: {
type: Function,
default: (list, cur, suffix) => {
return itemName(list[cur]) + suffix
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afriad the itemName here would be "not defined" 😨

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn’t be undefind. I was able to use it. Maybe add a check first?

Copy link
Owner

@fritx fritx Sep 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my bad

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mankowitz it should be not defined 'cause itemName is defined in methods not in top-level scope.

}
},

data () {
Expand Down Expand Up @@ -352,7 +357,7 @@ export default {
// hack: 连续两次 可以确保click后 focus回来 range真正生效
applyRange(r)
applyRange(r)
const t = itemName(list[cur]) + suffix
const t = processItem(list, cur, suffix)
this.insertText(t, r)
this.handleInput()
}
Expand Down
1 change: 1 addition & 0 deletions src/AtTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:class="isCur(index) && 'atwho-cur'"
:ref="isCur(index) && 'cur'"
:data-index="index"
:key="index"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mouseenter="handleItemHover"
@click="handleItemClick"
>
Expand Down
2 changes: 1 addition & 1 deletion src/AtTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
const start = index + at.length // 从@后第一位开始
el.selectionStart = start
el.focus() // textarea必须focus回来
const t = itemName(list[cur]) + suffix
const t = processItem(list, cur, suffix)
this.insertText(t, el)
this.handleInput()
}
Expand Down