Merge branch 'hotfix/issues-in-autocomplete' into 'develop'
#355 hotfix/issues in autocomplete Closes #355 See merge request pleroma/pleroma-fe!574
This commit is contained in:
commit
295becd6c8
|
@ -24,8 +24,7 @@ const AutoCompleteInput = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
caret: 0,
|
caret: 0,
|
||||||
highlighted: 0,
|
highlighted: 0
|
||||||
text: this.value
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -42,7 +41,7 @@ const AutoCompleteInput = {
|
||||||
return (this.wordAtCaret || {}).word || ''
|
return (this.wordAtCaret || {}).word || ''
|
||||||
},
|
},
|
||||||
wordAtCaret () {
|
wordAtCaret () {
|
||||||
const word = Completion.wordAtPosition(this.text, this.caret - 1) || {}
|
const word = Completion.wordAtPosition(this.value, this.caret - 1) || {}
|
||||||
return word
|
return word
|
||||||
},
|
},
|
||||||
candidates () {
|
candidates () {
|
||||||
|
@ -113,8 +112,8 @@ const AutoCompleteInput = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replace (replacement) {
|
replace (replacement) {
|
||||||
this.text = Completion.replaceWord(this.text, this.wordAtCaret, replacement)
|
this.$emit('input', Completion.replaceWord(this.value, this.wordAtCaret, replacement))
|
||||||
const el = this.$el.querySelector('textarea')
|
const el = this.$el.querySelector('textarea') || this.$el.querySelector('input')
|
||||||
el.focus()
|
el.focus()
|
||||||
this.caret = 0
|
this.caret = 0
|
||||||
},
|
},
|
||||||
|
@ -125,8 +124,7 @@ const AutoCompleteInput = {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const candidate = this.candidates[this.highlighted]
|
const candidate = this.candidates[this.highlighted]
|
||||||
const replacement = candidate.utf || (candidate.screen_name + ' ')
|
const replacement = candidate.utf || (candidate.screen_name + ' ')
|
||||||
this.text = Completion.replaceWord(this.text, this.wordAtCaret, replacement)
|
this.$emit('input', Completion.replaceWord(this.value, this.wordAtCaret, replacement))
|
||||||
this.$emit('input', this.text)
|
|
||||||
const el = this.$el.querySelector('textarea') || this.$el.querySelector('input')
|
const el = this.$el.querySelector('textarea') || this.$el.querySelector('input')
|
||||||
el.focus()
|
el.focus()
|
||||||
this.caret = 0
|
this.caret = 0
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
v-if="multiline"
|
v-if="multiline"
|
||||||
ref="textarea"
|
ref="textarea"
|
||||||
rows="1"
|
rows="1"
|
||||||
:value="text" :class="classObj" :id="id" :placeholder="placeholder"
|
:value="value" :class="classObj" :id="id" :placeholder="placeholder"
|
||||||
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
|
@input="$emit('input', $event.target.value), autoResize && resize($event)"
|
||||||
@click="setCaret"
|
@click="setCaret"
|
||||||
@keyup="setCaret"
|
@keyup="setCaret"
|
||||||
@keydown.down="cycleForward"
|
@keydown.down="cycleForward"
|
||||||
|
@ -13,17 +13,17 @@
|
||||||
@keydown.shift.tab="cycleBackward"
|
@keydown.shift.tab="cycleBackward"
|
||||||
@keydown.tab="cycleForward"
|
@keydown.tab="cycleForward"
|
||||||
@keydown.enter="replaceCandidate"
|
@keydown.enter="replaceCandidate"
|
||||||
@drop="drop && drop()"
|
@drop="drop && drop($event)"
|
||||||
@dragover.prevent="dragoverPrevent && dragoverPrevent()"
|
@dragover.prevent="dragoverPrevent && dragoverPrevent($event)"
|
||||||
@paste="paste && paste()"
|
@paste="paste && paste($event)"
|
||||||
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
|
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter($event)"
|
||||||
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()">
|
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter($event)">
|
||||||
</textarea>
|
</textarea>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
ref="textarea"
|
ref="textarea"
|
||||||
:value="text" :class="classObj" :id="id" :placeholder="placeholder"
|
:value="value" :class="classObj" :id="id" :placeholder="placeholder"
|
||||||
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
|
@input="$emit('input', $event.target.value), autoResize && resize($event)"
|
||||||
@click="setCaret"
|
@click="setCaret"
|
||||||
@keyup="setCaret"
|
@keyup="setCaret"
|
||||||
@keydown.down="cycleForward"
|
@keydown.down="cycleForward"
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
@keydown.shift.tab="cycleBackward"
|
@keydown.shift.tab="cycleBackward"
|
||||||
@keydown.tab="cycleForward"
|
@keydown.tab="cycleForward"
|
||||||
@keydown.enter="replaceCandidate"
|
@keydown.enter="replaceCandidate"
|
||||||
@drop="drop && drop()"
|
@drop="drop && drop($event)"
|
||||||
@dragover.prevent="dragoverPrevent && dragoverPrevent()"
|
@dragover.prevent="dragoverPrevent && dragoverPrevent($event)"
|
||||||
@paste="paste && paste()"
|
@paste="paste && paste($event)"
|
||||||
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
|
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter($event)"
|
||||||
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()"/>
|
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter($event)"/>
|
||||||
<div style="position:relative;" v-if="candidates">
|
<div style="position:relative;" v-if="candidates">
|
||||||
<div class="autocomplete-panel">
|
<div class="autocomplete-panel">
|
||||||
<div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))">
|
<div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))">
|
||||||
|
|
Loading…
Reference in New Issue