Compare commits

..

3 commits

Author SHA1 Message Date
1f0c9c985f BetterGifSend: improve option readability
Some checks failed
Sync to Codeberg / codeberg (push) Has been cancelled
test / test (push) Has been cancelled
2024-09-08 22:48:03 +08:00
7735d1a07b BetterGifSend: make readme more concise 2024-09-08 22:47:06 +08:00
af1c5c3c47 BetterGifSend: fix and add option to toggle reply behavior 2024-09-08 21:17:51 +08:00
2 changed files with 30 additions and 17 deletions

View file

@ -1,21 +1,21 @@
# BetterGifSend
This plugin enhances your GIF-sharing experience by providing control over how GIFs are inserted or sent and whether the GIF picker remains open or closes after sending a GIF.
This plugin adds configuration options regarding the GIF picker visibility/send behavior
## Configuration
## Configuration Options
### GIF Picker Behavior
### GIF picker visibility after selection
Control the visibility of the GIF picker after sending a GIF:
- Close after sending (Default)
- Always open
- Stay open with SHIFT
- **Close after sending**: The picker will close immediately after sending a GIF. (Default)
- **Always keep open**: The picker will always remain open after selecting a GIF.
- **Keep open when SHIFT is held**: Keeps the GIF picker open if the SHIFT key is held down.
### GIF selection behavior
### GIF Send Behavior
- Send immediately (Default)
- Insert into chatbox (also known as GifPaste)
- Insert into chatbox with SHIFT
Control how GIFs are sent:
### Clear Reply Context (Toggle, Enabled by default)
- **Send immediately**: Sends the GIF directly to the chat. (Default)
- **Insert into chatbox**: Inserts the GIF URL into the chatbox, allowing you to add additional text before sending.
- **Insert link if SHIFT is held**: Inserts the GIF URL into the chatbox if the SHIFT key is held down.
- Clears the reply context after selecting a single GIF

View file

@ -6,9 +6,10 @@
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { insertTextIntoChatInputBox, sendMessage } from "@utils/discord";
import { insertTextIntoChatInputBox } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { ExpressionPickerStore, SelectedChannelStore } from "@webpack/common";
import { findByPropsLazy } from "@webpack";
import { ExpressionPickerStore, FluxDispatcher, MessageActions, SelectedChannelStore } from "@webpack/common";
interface Gif {
url: string;
@ -29,16 +30,24 @@ const settings = definePluginSettings({
sendBehavior: {
type: OptionType.SELECT,
default: "Send",
description: "Choose how GIFs are added to your chats",
description: "Choose how GIF selection is handled",
restartNeeded: false,
options: [
{ value: "Send", label: "Send immediately" },
{ value: "Insert", label: "Insert into chatbox" },
{ value: "Insert", label: "Insert into chatbox (GifPaste behavior)" },
{ value: "InsertWithShift", label: "Insert link if SHIFT is held" }
]
},
clearReply: {
type: OptionType.BOOLEAN,
default: true,
description: "Clear the reply context after sending a singular GIF",
restartNeeded: false
}
});
const PendingReplyStore = findByPropsLazy("getPendingReply");
let shiftHeld = false;
function handleShift(event: KeyboardEvent): void {
@ -78,7 +87,11 @@ export default definePlugin({
if (sendBehavior === "Insert" || (sendBehavior === "InsertWithShift" && shiftHeld)) {
insertTextIntoChatInputBox(gif.url + " ");
} else {
sendMessage(channel, { content: gif.url });
const reply = PendingReplyStore.getPendingReply(channel);
MessageActions.sendMessage(channel, { content: gif.url }, void 0, true, MessageActions.getSendMessageOptionsForReply(reply));
if (settings.store.clearReply && reply) {
FluxDispatcher.dispatch({ type: "DELETE_PENDING_REPLY", channelId: channel });
}
}
if (closeBehavior === "Close" || (closeBehavior === "ShiftOpen" && !shiftHeld)) {