CopyEmojiMarkdown: Fix copying animated emojis (#3179)
This commit is contained in:
parent
949aad8cc7
commit
971e186335
1 changed files with 5 additions and 5 deletions
|
@ -33,11 +33,11 @@ function getEmojiMarkdown(target: Target, copyUnicode: boolean): string {
|
||||||
: `:${emojiName}:`;
|
: `:${emojiName}:`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const extension = target?.firstChild.src.match(
|
const url = new URL(target.firstChild.src);
|
||||||
/https:\/\/cdn\.discordapp\.com\/emojis\/\d+\.(\w+)/
|
const hasParam = url.searchParams.get("animated") === "true";
|
||||||
)?.[1];
|
const isGif = url.pathname.endsWith(".gif");
|
||||||
|
|
||||||
return `<${extension === "gif" ? "a" : ""}:${emojiName.replace(/~\d+$/, "")}:${emojiId}>`;
|
return `<${(hasParam || isGif) ? "a" : ""}:${emojiName.replace(/~\d+$/, "")}:${emojiId}>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
|
@ -55,7 +55,7 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
contextMenus: {
|
contextMenus: {
|
||||||
"expression-picker"(children, { target }: { target: Target }) {
|
"expression-picker"(children, { target }: { target: Target; }) {
|
||||||
if (target.dataset.type !== "emoji") return;
|
if (target.dataset.type !== "emoji") return;
|
||||||
|
|
||||||
children.push(
|
children.push(
|
||||||
|
|
Loading…
Reference in a new issue