mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 13:43:08 +02:00
Fix #1960
This commit is contained in:
parent
7d99b154c0
commit
f1bbbcfedf
2 changed files with 10 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
import * as getCaretCoordinates from 'textarea-caret';
|
import * as getCaretCoordinates from 'textarea-caret';
|
||||||
import MkAutocomplete from '../components/autocomplete.vue';
|
import MkAutocomplete from '../components/autocomplete.vue';
|
||||||
|
import renderAcct from '../../../../../misc/acct/render';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
bind(el, binding, vn) {
|
bind(el, binding, vn) {
|
||||||
|
@ -187,13 +188,15 @@ class Autocomplete {
|
||||||
const trimmedBefore = before.substring(0, before.lastIndexOf('@'));
|
const trimmedBefore = before.substring(0, before.lastIndexOf('@'));
|
||||||
const after = source.substr(caret);
|
const after = source.substr(caret);
|
||||||
|
|
||||||
|
const acct = renderAcct(value);
|
||||||
|
|
||||||
// 挿入
|
// 挿入
|
||||||
this.text = trimmedBefore + '@' + value.username + ' ' + after;
|
this.text = trimmedBefore + '@' + acct + ' ' + after;
|
||||||
|
|
||||||
// キャレットを戻す
|
// キャレットを戻す
|
||||||
this.vm.$nextTick(() => {
|
this.vm.$nextTick(() => {
|
||||||
this.textarea.focus();
|
this.textarea.focus();
|
||||||
const pos = trimmedBefore.length + (value.username.length + 2);
|
const pos = trimmedBefore.length + (acct.length + 2);
|
||||||
this.textarea.setSelectionRange(pos, pos);
|
this.textarea.setSelectionRange(pos, pos);
|
||||||
});
|
});
|
||||||
} else if (type == 'hashtag') {
|
} else if (type == 'hashtag') {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import { IUser } from '../../models/user';
|
type UserLike = {
|
||||||
|
host: string;
|
||||||
|
username: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default (user: IUser) => {
|
export default (user: UserLike) => {
|
||||||
return user.host === null ? user.username : `${user.username}@${user.host}`;
|
return user.host === null ? user.username : `${user.username}@${user.host}`;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue