diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-05-26 23:20:52 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-05-26 23:20:52 +0900 |
| commit | 67b3461c242e50a3248f99bb164d160db2823db1 (patch) | |
| tree | af1ebad6a8537f367a4572930bda20e1e369face /src | |
| parent | Merge pull request #1652 from l2dy/readme (diff) | |
| download | misskey-67b3461c242e50a3248f99bb164d160db2823db1.tar.gz misskey-67b3461c242e50a3248f99bb164d160db2823db1.tar.bz2 misskey-67b3461c242e50a3248f99bb164d160db2823db1.zip | |
Better mention handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/desktop/views/components/post-form.vue | 12 | ||||
| -rw-r--r-- | src/client/app/mobile/views/components/post-form.vue | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index 0696d4e82b..0e0848524a 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -49,6 +49,7 @@ import Vue from 'vue'; import * as XDraggable from 'vuedraggable'; import getKao from '../../../common/scripts/get-kao'; import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue'; +import parse from '../../../../../text/parse'; export default Vue.extend({ components: { @@ -110,6 +111,17 @@ export default Vue.extend({ this.text = `@${this.reply.user.username}@${this.reply.user.host} `; } + if (this.reply && this.reply.text != null) { + const ast = parse(this.reply.text); + + ast.filter(t => t.type == 'mention').forEach(x => { + const mention = x.host ? `@${x.username}@${x.host}` : `@${x.username}`; + if (this.text.indexOf(`${mention} `) == -1) { + this.text += `${mention} `; + } + }); + } + this.$nextTick(() => { // 書きかけの投稿を復元 const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftId]; diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index b3b5ffd502..55347b7e53 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -49,6 +49,7 @@ import Vue from 'vue'; import * as XDraggable from 'vuedraggable'; import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue'; import getKao from '../../../common/scripts/get-kao'; +import parse from '../../../../../text/parse'; export default Vue.extend({ components: { @@ -78,6 +79,17 @@ export default Vue.extend({ this.text = `@${this.reply.user.username}@${this.reply.user.host} `; } + if (this.reply && this.reply.text != null) { + const ast = parse(this.reply.text); + + ast.filter(t => t.type == 'mention').forEach(x => { + const mention = x.host ? `@${x.username}@${x.host}` : `@${x.username}`; + if (this.text.indexOf(`${mention} `) == -1) { + this.text += `${mention} `; + } + }); + } + this.$nextTick(() => { this.focus(); }); |