standartized autocomplete panel suggesions format, fixed some bugs

This commit is contained in:
Henry Jameson 2019-06-08 16:23:58 +03:00
parent ca3140fd3e
commit 8872b4802e
7 changed files with 129 additions and 112 deletions

View file

@ -83,43 +83,6 @@ const PostStatusForm = {
}
},
computed: {
candidates () {
const firstchar = this.textAtCaret.charAt(0)
if (firstchar === '@') {
const query = this.textAtCaret.slice(1).toUpperCase()
const matchedUsers = filter(this.users, (user) => {
return user.screen_name.toUpperCase().startsWith(query) ||
user.name && user.name.toUpperCase().startsWith(query)
})
if (matchedUsers.length <= 0) {
return false
}
// eslint-disable-next-line camelcase
return map(take(matchedUsers, 5), ({screen_name, name, profile_image_url_original}, index) => ({
// eslint-disable-next-line camelcase
screen_name: `@${screen_name}`,
name: name,
img: profile_image_url_original,
highlighted: index === this.highlighted
}))
} else if (firstchar === ':') {
if (this.textAtCaret === ':') { return }
const matchedEmoji = filter(this.emoji.concat(this.customEmoji), (emoji) => emoji.shortcode.startsWith(this.textAtCaret.slice(1)))
if (matchedEmoji.length <= 0) {
return false
}
return map(take(matchedEmoji, 5), ({shortcode, image_url, utf}, index) => ({
screen_name: `:${shortcode}:`,
name: '',
utf: utf || '',
// eslint-disable-next-line camelcase
img: utf ? '' : this.$store.state.instance.server + image_url,
highlighted: index === this.highlighted
}))
} else {
return false
}
},
users () {
return this.$store.state.users.users
},

View file

@ -32,24 +32,29 @@
<span v-else>{{ $t('post_status.direct_warning_to_all') }}</span>
</p>
<emoji-input
:suggest="emojiSuggestor" v-model="newStatus.spoilerText"
v-if="newStatus.spoilerText || alwaysShowSubject"
:suggest="emojiSuggestor"
v-model="newStatus.spoilerText"
class="form-control"
>
<input
type="text"
:placeholder="$t('post_status.content_warning')"
v-model="newStatus.spoilerText"
classname="form-control"
class="form-post-subject"
/>
</emoji-input>
<emoji-input :suggest="emojiUserSuggestor" v-model="newStatus.status">
<emoji-input
:suggest="emojiUserSuggestor"
v-model="newStatus.status"
class="form-control"
>
<textarea
ref="textarea"
v-model="newStatus.status"
:placeholder="$t('post_status.default')"
rows="1"
class="form-control"
@keydown.meta.enter="postStatus(newStatus)"
@keyup.ctrl.enter="postStatus(newStatus)"
@drop="fileDrop"
@ -57,6 +62,7 @@
@input="resize"
@paste="paste"
:disabled="posting"
class="form-post-body"
>
</textarea>
</emoji-input>
@ -251,7 +257,7 @@
min-height: 1px;
}
form textarea.form-control {
.form-post-body {
line-height:16px;
resize: none;
overflow: hidden;
@ -260,7 +266,7 @@
box-sizing: content-box;
}
form textarea.form-control:focus {
.form-post-body:focus {
min-height: 48px;
}