From 5160f906f408aaadf8b10b507eb1a8f823b5b528 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 3 Aug 2024 19:02:48 +0200 Subject: [PATCH] delete MaskedLinkPaste ~ now a stock Discord feature --- src/plugins/_api/messagePopover.ts | 5 ++-- src/plugins/maskedLinkPaste/README.md | 5 ---- src/plugins/maskedLinkPaste/index.ts | 38 --------------------------- 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 src/plugins/maskedLinkPaste/README.md delete mode 100644 src/plugins/maskedLinkPaste/index.ts diff --git a/src/plugins/_api/messagePopover.ts b/src/plugins/_api/messagePopover.ts index 2b0b0c79..57b9b119 100644 --- a/src/plugins/_api/messagePopover.ts +++ b/src/plugins/_api/messagePopover.ts @@ -26,9 +26,8 @@ export default definePlugin({ patches: [{ find: "Messages.MESSAGE_UTILITIES_A11Y_LABEL", replacement: { - // foo && !bar ? createElement(reactionStuffs)... createElement(blah,...makeElement(reply-other)) - match: /\i&&!\i\?\(0,\i\.jsxs?\)\(.{0,200}renderEmojiPicker:.{0,500}\?\(0,\i\.jsx\)\((\i\.\i).{0,200},"reply-other"(?<=message:(\i).+?)/, - replace: "Vencord.Api.MessagePopover._buildPopoverElements($1,$2),$&" + match: /\.jsx\)\((\i\.\i),\{label:\i\.\i\.Messages\.MESSAGE_ACTION_REPLY.{0,200}?"reply-self".{0,50}?\}\):null(?=,.+?message:(\i))/, + replace: "$&,Vencord.Api.MessagePopover._buildPopoverElements($1,$2)" } }], }); diff --git a/src/plugins/maskedLinkPaste/README.md b/src/plugins/maskedLinkPaste/README.md deleted file mode 100644 index 30beccb6..00000000 --- a/src/plugins/maskedLinkPaste/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# MaskedLinkPaste - -Pasting a link while you have text selected will paste your link as a masked link at that location - -![](https://github.com/Vendicated/Vencord/assets/78964224/1d3be2c6-7957-44c9-92ec-551069d46c02) diff --git a/src/plugins/maskedLinkPaste/index.ts b/src/plugins/maskedLinkPaste/index.ts deleted file mode 100644 index bcd622ed..00000000 --- a/src/plugins/maskedLinkPaste/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2023 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { Devs } from "@utils/constants.js"; -import definePlugin from "@utils/types"; -import { findByPropsLazy } from "@webpack"; - -const linkRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; - -const SlateTransforms = findByPropsLazy("insertText", "selectCommandOption"); - -export default definePlugin({ - name: "MaskedLinkPaste", - authors: [Devs.TheSun], - description: "Pasting a link while having text selected will paste a hyperlink", - patches: [ - { - find: ".selection,preventEmojiSurrogates:", - replacement: { - match: /(?<=\i.delete.{0,50})(\i)\.insertText\((\i)\)/, - replace: "$self.handlePaste($1, $2, () => $&)" - } - } - ], - - handlePaste(editor, content: string, originalBehavior: () => void) { - if (content && linkRegex.test(content) && editor.operations?.[0]?.type === "remove_text") { - SlateTransforms.insertText( - editor, - `[${editor.operations[0].text}](${content})` - ); - } - else originalBehavior(); - } -});