diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-07-12 00:38:55 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-12 00:38:55 +0900 |
| commit | 9b73e897df134ba57d4ac4d0e6e6924f8ddbc23d (patch) | |
| tree | 2885511bc46ab67c7ef7b7b40f7598e788edcd18 /src/client/components | |
| parent | feat(client): 無限にダイアログを出すように (diff) | |
| download | sharkey-9b73e897df134ba57d4ac4d0e6e6924f8ddbc23d.tar.gz sharkey-9b73e897df134ba57d4ac4d0e6e6924f8ddbc23d.tar.bz2 sharkey-9b73e897df134ba57d4ac4d0e6e6924f8ddbc23d.zip | |
Plugin system (#6479)
* wip
* wip
* wip
* wip
* Update store.ts
Diffstat (limited to 'src/client/components')
| -rw-r--r-- | src/client/components/note.vue | 15 | ||||
| -rw-r--r-- | src/client/components/post-form.vue | 21 | ||||
| -rw-r--r-- | src/client/components/user-menu.vue | 12 |
3 files changed, 42 insertions, 6 deletions
diff --git a/src/client/components/note.vue b/src/client/components/note.vue index badb9f12f3..63a803c7f4 100644 --- a/src/client/components/note.vue +++ b/src/client/components/note.vue @@ -89,7 +89,7 @@ <script lang="ts"> import Vue from 'vue'; -import { faBolt, faTimes, faBullhorn, faStar, faLink, faExternalLinkSquareAlt, faPlus, faMinus, faRetweet, faReply, faReplyAll, faEllipsisH, faHome, faUnlock, faEnvelope, faThumbtack, faBan, faQuoteRight, faInfoCircle, faBiohazard, faEllipsisH } from '@fortawesome/free-solid-svg-icons'; +import { faBolt, faTimes, faBullhorn, faStar, faLink, faExternalLinkSquareAlt, faPlus, faMinus, faRetweet, faReply, faReplyAll, faEllipsisH, faHome, faUnlock, faEnvelope, faThumbtack, faBan, faQuoteRight, faInfoCircle, faBiohazard, faPlug } from '@fortawesome/free-solid-svg-icons'; import { faCopy, faTrashAlt, faEdit, faEye, faEyeSlash } from '@fortawesome/free-regular-svg-icons'; import { parse } from '../../mfm/parse'; import { sum, unique } from '../../prelude/array'; @@ -108,7 +108,6 @@ import { url } from '../config'; import copyToClipboard from '../scripts/copy-to-clipboard'; export default Vue.extend({ - components: { XSub, XNoteHeader, @@ -145,7 +144,7 @@ export default Vue.extend({ showContent: false, hideThisNote: false, noteBody: this.$refs.noteBody, - faEdit, faBolt, faTimes, faBullhorn, faPlus, faMinus, faRetweet, faReply, faReplyAll, faEllipsisH, faHome, faUnlock, faEnvelope, faThumbtack, faBan, faBiohazard, faEllipsisH + faEdit, faBolt, faTimes, faBullhorn, faPlus, faMinus, faRetweet, faReply, faReplyAll, faEllipsisH, faHome, faUnlock, faEnvelope, faThumbtack, faBan, faBiohazard, faPlug }; }, @@ -612,6 +611,16 @@ export default Vue.extend({ .filter(x => x !== undefined); } + if (this.$store.state.noteActions.length > 0) { + menu = menu.concat([null, ...this.$store.state.noteActions.map(action => ({ + icon: faPlug, + text: action.title, + action: () => { + action.handler(this.appearNote); + } + }))]); + } + this.$root.menu({ items: menu, source: this.$refs.menuButton, diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index 392dd8c48b..f0de602c29 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -44,6 +44,7 @@ <button class="_button" @click="useCw = !useCw" :class="{ active: useCw }" v-tooltip="$t('useCw')"><fa :icon="faEyeSlash"/></button> <button class="_button" @click="insertMention" v-tooltip="$t('mention')"><fa :icon="faAt"/></button> <button class="_button" @click="insertEmoji" v-tooltip="$t('emoji')"><fa :icon="faLaughSquint"/></button> + <button class="_button" @click="showActions" v-tooltip="$t('plugin')" v-if="$store.state.postFormActions.length > 0"><fa :icon="faPlug"/></button> </footer> <input ref="file" class="file _button" type="file" multiple="multiple" @change="onChangeFile"/> </div> @@ -52,7 +53,7 @@ <script lang="ts"> import Vue from 'vue'; -import { faReply, faQuoteRight, faPaperPlane, faTimes, faUpload, faPollH, faGlobe, faHome, faUnlock, faEnvelope, faPlus, faPhotoVideo, faCloud, faLink, faAt, faBiohazard } from '@fortawesome/free-solid-svg-icons'; +import { faReply, faQuoteRight, faPaperPlane, faTimes, faUpload, faPollH, faGlobe, faHome, faUnlock, faEnvelope, faPlus, faPhotoVideo, faCloud, faLink, faAt, faBiohazard, faPlug } from '@fortawesome/free-solid-svg-icons'; import { faEyeSlash, faLaughSquint } from '@fortawesome/free-regular-svg-icons'; import insertTextAtCursor from 'insert-text-at-cursor'; import { length } from 'stringz'; @@ -133,7 +134,7 @@ export default Vue.extend({ draghover: false, quoteId: null, recentHashtags: JSON.parse(localStorage.getItem('hashtags') || '[]'), - faReply, faQuoteRight, faPaperPlane, faTimes, faUpload, faPollH, faGlobe, faHome, faUnlock, faEnvelope, faEyeSlash, faLaughSquint, faPlus, faPhotoVideo, faCloud, faLink, faAt, faBiohazard + faReply, faQuoteRight, faPaperPlane, faTimes, faUpload, faPollH, faGlobe, faHome, faUnlock, faEnvelope, faEyeSlash, faLaughSquint, faPlus, faPhotoVideo, faCloud, faLink, faAt, faBiohazard, faPlug }; }, @@ -580,6 +581,22 @@ export default Vue.extend({ vm.close(); }); }, + + showActions(ev) { + this.$root.menu({ + items: this.$store.state.postFormActions.map(action => ({ + text: action.title, + action: () => { + action.handler({ + text: this.text + }, (key, value) => { + if (key === 'text') { this.text = value; } + }); + } + })), + source: ev.currentTarget || ev.target, + }); + } } }); </script> diff --git a/src/client/components/user-menu.vue b/src/client/components/user-menu.vue index 25937fb3c0..cbfa7b346d 100644 --- a/src/client/components/user-menu.vue +++ b/src/client/components/user-menu.vue @@ -4,7 +4,7 @@ <script lang="ts"> import Vue from 'vue'; -import { faAt, faListUl, faEye, faEyeSlash, faBan, faPencilAlt, faComments, faUsers, faMicrophoneSlash } from '@fortawesome/free-solid-svg-icons'; +import { faAt, faListUl, faEye, faEyeSlash, faBan, faPencilAlt, faComments, faUsers, faMicrophoneSlash, faPlug } from '@fortawesome/free-solid-svg-icons'; import { faSnowflake, faEnvelope } from '@fortawesome/free-regular-svg-icons'; import XMenu from './menu.vue'; import copyToClipboard from '../scripts/copy-to-clipboard'; @@ -80,6 +80,16 @@ export default Vue.extend({ }]); } + if (this.$store.state.userActions.length > 0) { + menu = menu.concat([null, ...this.$store.state.userActions.map(action => ({ + icon: faPlug, + text: action.title, + action: () => { + action.handler(this.user); + } + }))]); + } + return { items: menu }; |