mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 10:13:09 +02:00
parent
2faa58928f
commit
b7c5c71c6f
7 changed files with 31 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
||||||
@keypress="onKeypress"
|
@keypress="onKeypress"
|
||||||
@paste="onPaste"
|
@paste="onPaste"
|
||||||
:placeholder="$t('input-message-here')"
|
:placeholder="$t('input-message-here')"
|
||||||
v-autocomplete="'text'"
|
v-autocomplete="{ model: 'text' }"
|
||||||
></textarea>
|
></textarea>
|
||||||
<div class="file" @click="file = null" v-if="file">{{ file.name }}</div>
|
<div class="file" @click="file = null" v-if="file">{{ file.name }}</div>
|
||||||
<mk-uploader ref="uploader" @uploaded="onUploaded"/>
|
<mk-uploader ref="uploader" @uploaded="onUploaded"/>
|
||||||
|
|
|
@ -21,21 +21,23 @@ class Autocomplete {
|
||||||
private suggestion: any;
|
private suggestion: any;
|
||||||
private textarea: any;
|
private textarea: any;
|
||||||
private vm: any;
|
private vm: any;
|
||||||
private model: any;
|
|
||||||
private currentType: string;
|
private currentType: string;
|
||||||
|
private opts: {
|
||||||
|
model: string;
|
||||||
|
};
|
||||||
|
|
||||||
private get text(): string {
|
private get text(): string {
|
||||||
return this.vm[this.model];
|
return this.vm[this.opts.model];
|
||||||
}
|
}
|
||||||
|
|
||||||
private set text(text: string) {
|
private set text(text: string) {
|
||||||
this.vm[this.model] = text;
|
this.vm[this.opts.model] = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 対象のテキストエリアを与えてインスタンスを初期化します。
|
* 対象のテキストエリアを与えてインスタンスを初期化します。
|
||||||
*/
|
*/
|
||||||
constructor(textarea, vm, model) {
|
constructor(textarea, vm, opts) {
|
||||||
//#region BIND
|
//#region BIND
|
||||||
this.onInput = this.onInput.bind(this);
|
this.onInput = this.onInput.bind(this);
|
||||||
this.complete = this.complete.bind(this);
|
this.complete = this.complete.bind(this);
|
||||||
|
@ -45,7 +47,7 @@ class Autocomplete {
|
||||||
this.suggestion = null;
|
this.suggestion = null;
|
||||||
this.textarea = textarea;
|
this.textarea = textarea;
|
||||||
this.vm = vm;
|
this.vm = vm;
|
||||||
this.model = model;
|
this.opts = opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
<a v-for="tag in recentHashtags.slice(0, 5)" @click="addTag(tag)" :title="$t('click-to-tagging')">#{{ tag }}</a>
|
<a v-for="tag in recentHashtags.slice(0, 5)" @click="addTag(tag)" :title="$t('click-to-tagging')">#{{ tag }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="local-only" v-if="localOnly == true">{{ $t('local-only-message') }}</div>
|
<div class="local-only" v-if="localOnly == true">{{ $t('local-only-message') }}</div>
|
||||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
|
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="{ model: 'cw' }">
|
||||||
<div class="textarea">
|
<div class="textarea">
|
||||||
<textarea :class="{ with: (files.length != 0 || poll) }"
|
<textarea :class="{ with: (files.length != 0 || poll) }"
|
||||||
ref="text" v-model="text" :disabled="posting"
|
ref="text" v-model="text" :disabled="posting"
|
||||||
@keydown="onKeydown" @paste="onPaste" :placeholder="placeholder"
|
@keydown="onKeydown" @paste="onPaste" :placeholder="placeholder"
|
||||||
v-autocomplete="'text'"
|
v-autocomplete="{ model: 'text' }"
|
||||||
></textarea>
|
></textarea>
|
||||||
<button class="emoji" @click="emoji" ref="emoji">
|
<button class="emoji" @click="emoji" ref="emoji">
|
||||||
<fa :icon="['far', 'laugh']"/>
|
<fa :icon="['far', 'laugh']"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<form class="search" @submit.prevent="onSubmit">
|
<form class="wlvfdpkp" @submit.prevent="onSubmit">
|
||||||
<i><fa icon="search"/></i>
|
<i><fa icon="search"/></i>
|
||||||
<input v-model="q" type="search" :placeholder="$t('placeholder')"/>
|
<input v-model="q" type="search" :placeholder="$t('placeholder')" v-autocomplete="{ model: 'q' }"/>
|
||||||
<div class="result"></div>
|
<div class="result"></div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -19,10 +19,13 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
if (this.q.startsWith('#')) {
|
const q = this.q.trim();
|
||||||
this.$router.push(`/tags/${encodeURIComponent(this.q.substr(1))}`);
|
if (q.startsWith('@')) {
|
||||||
|
this.$router.push(`/${q}`);
|
||||||
|
} else if (q.startsWith('#')) {
|
||||||
|
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||||
} else {
|
} else {
|
||||||
this.$router.push(`/search?q=${encodeURIComponent(this.q)}`);
|
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +33,7 @@ export default Vue.extend({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
.search
|
.wlvfdpkp
|
||||||
@media (max-width 800px)
|
@media (max-width 800px)
|
||||||
display none !important
|
display none !important
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
@paste="onPaste"
|
@paste="onPaste"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
ref="text"
|
ref="text"
|
||||||
v-autocomplete="'text'"
|
v-autocomplete="{ model: 'text' }"
|
||||||
></textarea>
|
></textarea>
|
||||||
<button class="emoji" @click="emoji" ref="emoji">
|
<button class="emoji" @click="emoji" ref="emoji">
|
||||||
<fa :icon="['far', 'laugh']"/>
|
<fa :icon="['far', 'laugh']"/>
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
</span>
|
</span>
|
||||||
<a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a>
|
<a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a>
|
||||||
</div>
|
</div>
|
||||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
|
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="{ model: 'cw' }">
|
||||||
<textarea v-model="text" ref="text" :disabled="posting" :placeholder="placeholder" v-autocomplete="'text'"></textarea>
|
<textarea v-model="text" ref="text" :disabled="posting" :placeholder="placeholder" v-autocomplete="{ model: 'text' }"></textarea>
|
||||||
<div class="attaches" v-show="files.length != 0">
|
<div class="attaches" v-show="files.length != 0">
|
||||||
<x-draggable class="files" :list="files" :options="{ animation: 150 }">
|
<x-draggable class="files" :list="files" :options="{ animation: 150 }">
|
||||||
<div class="file" v-for="file in files" :key="file.id">
|
<div class="file" v-for="file in files" :key="file.id">
|
||||||
|
|
|
@ -100,7 +100,15 @@ export default Vue.extend({
|
||||||
input: true
|
input: true
|
||||||
}).then(({ canceled, result: query }) => {
|
}).then(({ canceled, result: query }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
this.$router.push(`/search?q=${encodeURIComponent(query)}`);
|
|
||||||
|
const q = query.trim();
|
||||||
|
if (q.startsWith('@')) {
|
||||||
|
this.$router.push(`/${q}`);
|
||||||
|
} else if (q.startsWith('#')) {
|
||||||
|
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||||
|
} else {
|
||||||
|
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue