diff options
-rw-r--r-- | src/plugins/favEmojiFirst/README.md | 6 | ||||
-rw-r--r-- | src/plugins/favEmojiFirst/index.ts (renamed from src/plugins/favEmojiFirst.ts) | 0 | ||||
-rw-r--r-- | src/plugins/favGifSearch/README.md | 5 | ||||
-rw-r--r-- | src/plugins/favGifSearch/index.tsx (renamed from src/plugins/favGifSearch.tsx) | 2 | ||||
-rw-r--r-- | src/plugins/imageZoom/README.md | 6 | ||||
-rw-r--r-- | src/plugins/imageZoom/index.tsx | 9 | ||||
-rw-r--r-- | src/plugins/previewMessage/README.md | 5 | ||||
-rw-r--r-- | src/plugins/previewMessage/index.tsx (renamed from src/plugins/previewMessage.tsx) | 69 | ||||
-rw-r--r-- | src/plugins/searchReply/README.md | 5 | ||||
-rw-r--r-- | src/plugins/searchReply/index.tsx (renamed from src/plugins/searchReply.tsx) | 0 | ||||
-rw-r--r-- | src/webpack/common/types/menu.d.ts | 9 |
11 files changed, 108 insertions, 8 deletions
diff --git a/src/plugins/favEmojiFirst/README.md b/src/plugins/favEmojiFirst/README.md new file mode 100644 index 0000000..dc84480 --- /dev/null +++ b/src/plugins/favEmojiFirst/README.md @@ -0,0 +1,6 @@ +# FavoriteEmojiFirst + +Puts your favorite emoji first in the emoji autocomplete. + +![FavEmojis](https://i.imgur.com/mEFCoZG.png) +![Example](https://i.imgur.com/wY3Tc43.png) diff --git a/src/plugins/favEmojiFirst.ts b/src/plugins/favEmojiFirst/index.ts index fec0b04..fec0b04 100644 --- a/src/plugins/favEmojiFirst.ts +++ b/src/plugins/favEmojiFirst/index.ts diff --git a/src/plugins/favGifSearch/README.md b/src/plugins/favGifSearch/README.md new file mode 100644 index 0000000..c076885 --- /dev/null +++ b/src/plugins/favGifSearch/README.md @@ -0,0 +1,5 @@ +# FavoriteGifSearch + +Adds a search bar to favorite gifs. + +![Screenshot](https://i.imgur.com/Bcgb7PD.png) diff --git a/src/plugins/favGifSearch.tsx b/src/plugins/favGifSearch/index.tsx index db575a0..d10c515 100644 --- a/src/plugins/favGifSearch.tsx +++ b/src/plugins/favGifSearch/index.tsx @@ -87,7 +87,7 @@ export const settings = definePluginSettings({ export default definePlugin({ name: "FavoriteGifSearch", authors: [Devs.Aria], - description: "Adds a search bar for favorite gifs", + description: "Adds a search bar to favorite gifs.", patches: [ { diff --git a/src/plugins/imageZoom/README.md b/src/plugins/imageZoom/README.md new file mode 100644 index 0000000..8e3b7ef --- /dev/null +++ b/src/plugins/imageZoom/README.md @@ -0,0 +1,6 @@ +# ImageZoom + +Lets you zoom in to images and gifs. Use scroll wheel to zoom in and shift + scroll wheel to increase lens radius / size + +![Example](https://i.imgur.com/VJdo4aq.png) +![ContextMenu](https://i.imgur.com/0oaRM2s.png) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 71540f2..cca0db0 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -99,6 +99,15 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => { ContextMenu.close(); }} /> + <Menu.MenuCheckboxItem + id="vc-nearest-neighbour" + label="Nearset Neighbour" + checked={settings.store.nearestNeighbour} + action={() => { + settings.store.nearestNeighbour = !settings.store.nearestNeighbour; + ContextMenu.close(); + }} + /> <Menu.MenuControlItem id="vc-zoom" label="Zoom" diff --git a/src/plugins/previewMessage/README.md b/src/plugins/previewMessage/README.md new file mode 100644 index 0000000..e0043b2 --- /dev/null +++ b/src/plugins/previewMessage/README.md @@ -0,0 +1,5 @@ +# PreviewMessage + +Lets you preview your message before sending it. + +![Example](https://i.imgur.com/etqbkzu.png) diff --git a/src/plugins/previewMessage.tsx b/src/plugins/previewMessage/index.tsx index 9bea221..393b520 100644 --- a/src/plugins/previewMessage.tsx +++ b/src/plugins/previewMessage/index.tsx @@ -16,37 +16,96 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { sendBotMessage } from "@api/Commands"; +import { generateId, sendBotMessage } from "@api/Commands"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; +import { MessageAttachment } from "discord-types/general"; interface Props { type: { analyticsName: string; + isEmpty: boolean; + attachments: boolean; }; } +const UploadStore = findByPropsLazy("getUploads"); + const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage); + +const getImageBox = (url: string): Promise<{ width: number, height: number; } | null> => + new Promise(res => { + const img = new Image(); + img.onload = () => + res({ width: img.width, height: img.height }); + + img.onerror = () => + res(null); + + img.src = url; + }); + + +const getAttachments = async (channelId: string) => + await Promise.all( + UploadStore.getUploads(channelId, DraftType.ChannelMessage) + .map(async (upload: any) => { + const { isImage, filename, spoiler, item: { file } } = upload; + const url = URL.createObjectURL(file); + const attachment: MessageAttachment = { + id: generateId(), + filename: spoiler ? "SPOILER_" + filename : filename, + // weird eh? if i give it the normal content type the preview doenst work + content_type: undefined, + size: await upload.getSize(), + spoiler, + // discord adds query params to the url, so we need to add a hash to prevent that + url: url + "#", + proxy_url: url + "#", + }; + + if (isImage) { + const box = await getImageBox(url); + if (!box) return attachment; + + attachment.width = box.width; + attachment.height = box.height; + } + + return attachment; + }) + ); + + export function PreviewButton(chatBoxProps: Props) { + const { isEmpty, attachments } = chatBoxProps.type; + const channelId = SelectedChannelStore.getChannelId(); const draft = useStateFromStores([DraftStore], () => getDraft(channelId)); + if (chatBoxProps.type.analyticsName !== "normal") return null; - if (!draft) return null; + + const hasAttachments = attachments && UploadStore.getUploads(channelId, DraftType.ChannelMessage).length > 0; + const hasContent = !isEmpty && draft?.length > 0; + + if (!hasContent && !hasAttachments) return null; return ( <Tooltip text="Preview Message"> {tooltipProps => ( <Button {...tooltipProps} - onClick={() => + onClick={async () => sendBotMessage( channelId, { content: getDraft(channelId), - author: UserStore.getCurrentUser() + author: UserStore.getCurrentUser(), + attachments: hasAttachments ? await getAttachments(channelId) : undefined, } )} size="" @@ -66,7 +125,7 @@ export function PreviewButton(chatBoxProps: Props) { export default definePlugin({ name: "PreviewMessage", - description: "Lets you preview your message before sending it", + description: "Lets you preview your message before sending it.", authors: [Devs.Aria], patches: [ { diff --git a/src/plugins/searchReply/README.md b/src/plugins/searchReply/README.md new file mode 100644 index 0000000..6938def --- /dev/null +++ b/src/plugins/searchReply/README.md @@ -0,0 +1,5 @@ +# SearchReply + +Adds a reply button to search results. + +![Screenshot](https://i.imgur.com/SjIEHpw.png) diff --git a/src/plugins/searchReply.tsx b/src/plugins/searchReply/index.tsx index 9e53436..9e53436 100644 --- a/src/plugins/searchReply.tsx +++ b/src/plugins/searchReply/index.tsx diff --git a/src/webpack/common/types/menu.d.ts b/src/webpack/common/types/menu.d.ts index 1988617..29f3ffa 100644 --- a/src/webpack/common/types/menu.d.ts +++ b/src/webpack/common/types/menu.d.ts @@ -65,8 +65,13 @@ export interface Menu { id: string; interactive?: boolean; }>; - // TODO: Type me - MenuSliderControl: RC<any>; + MenuSliderControl: RC<{ + minValue: number, + maxValue: number, + value: number, + onChange(value: number): void, + renderValue?(value: number): string, + }>; } export interface ContextMenuApi { |