From 8f65d3cae97abb42097e2eb015a51fc4c6d5bc52 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 27 Feb 2025 21:05:43 -0300 Subject: [PATCH] ImageZoom: Fix for new media viewer --- src/plugins/imageZoom/index.tsx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 934a5c775..1a17b6168 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -165,8 +165,35 @@ export default definePlugin({ { find: ".contain,SCALE_DOWN:", replacement: { - match: /\.slide,\i\),/g, - replace: `$&id:"${ELEMENT_ID}",` + match: /imageClassName:/, + replace: `id:"${ELEMENT_ID}",$&` + } + }, + + { + find: ".dimensionlessImage,", + replacement: [ + { + match: /className:\i\.media,/, + replace: `id:"${ELEMENT_ID}",$&` + }, + { + // This patch needs to be above the next one as it uses the zoomed class as an anchor + match: /\.zoomed]:.+?,(?=children:)/, + replace: "$&onClick:()=>{}," + }, + { + match: /className:\i\(\)\(\i\.wrapper,.+?}\),/, + replace: "" + }, + ] + }, + // Make media viewer options not hide when zoomed in with the default Discord feature + { + find: '="FOCUS_SENSITIVE",', + replacement: { + match: /(?<=\.hidden]:)\i/, + replace: "false" } },