From de514f7d766891f72561f518f1fbea4439b3aea3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Mar 2021 22:04:46 -0700 Subject: [PATCH] Add Autocomplete for hashtags + mentions --- .../assets/js/components/ComposeModal.vue | 43 +++++++++++++- .../assets/js/components/PostComponent.vue | 45 ++++++++++++++- resources/assets/js/components/Timeline.vue | 49 ---------------- resources/assets/sass/custom.scss | 56 ++++++++++++++++++- 4 files changed, 138 insertions(+), 55 deletions(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index a98028efe..e2c054ac3 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -295,7 +295,9 @@
- + + +

{{composeTextLength}}/{{config.uploader.max_caption_length}}

@@ -647,11 +649,14 @@ import VueCropper from 'vue-cropperjs'; import 'cropperjs/dist/cropper.css'; import Autocomplete from '@trevoreyre/autocomplete-vue' import '@trevoreyre/autocomplete-vue/dist/style.css' +import VueTribute from 'vue-tribute' export default { + components: { VueCropper, - Autocomplete + Autocomplete, + VueTribute }, data() { @@ -707,7 +712,39 @@ export default { cameraRollMedia: [], taggedUsernames: [], taggedPeopleSearch: null, - textMode: false + textMode: false, + tributeSettings: { + collection: [ + { + trigger: '@', + menuShowMinLength: 2, + values: (function (text, cb) { + let url = '/api/compose/v0/search/mention'; + axios.get(url, { params: { q: text }}) + .then(res => { + cb(res.data); + }) + .catch(err => { + console.log(err); + }) + }) + }, + { + trigger: '#', + menuShowMinLength: 2, + values: (function (text, cb) { + let url = '/api/compose/v0/search/hashtag'; + axios.get(url, { params: { q: text }}) + .then(res => { + cb(res.data); + }) + .catch(err => { + console.log(err); + }) + }) + } + ] + } } }, diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 7525db9c9..b9302f9ba 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -643,8 +643,10 @@ size="md" body-class="p-2 rounded">
- + + +