From 3917193e8fee9832e958a71c5109d39cb808c1da Mon Sep 17 00:00:00 2001 From: Syncx <47534062+Syncxv@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:50:11 +0530 Subject: [PATCH] fix: ImageZoom (#1864) --- src/plugins/imageZoom/index.tsx | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 1f0d7e127..23dcddde7 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -37,13 +37,6 @@ export const settings = definePluginSettings({ default: true, }, - preventCarouselFromClosingOnClick: { - type: OptionType.BOOLEAN, - // Thanks chat gpt - description: "Allow the image modal in the image slideshow thing / carousel to remain open when clicking on the image", - default: true, - }, - invertScroll: { type: OptionType.BOOLEAN, description: "Invert scroll", @@ -163,10 +156,14 @@ export default definePlugin({ patches: [ { - find: '"renderLinkComponent","maxWidth"', + find: "Messages.OPEN_IN_BROWSER", replacement: { - match: /(return\(.{1,100}\(\)\.wrapper.{1,200})(src)/, - replace: `$1id: '${ELEMENT_ID}',$2` + // there are 2 image thingies. one for carosuel and one for the single image. + // so thats why i added global flag. + // also idk if this patch is good, should it be more specific? + // https://regex101.com/r/xfvNvV/1 + match: /return.{1,200}\.wrapper.{1,200}src:\i,/g, + replace: `$&id: '${ELEMENT_ID}',` } }, @@ -174,28 +171,21 @@ export default definePlugin({ find: "handleImageLoad=", replacement: [ { - match: /showThumbhashPlaceholder:/, + match: /showThumbhashPlaceholder:\i,/, replace: "...$self.makeProps(this),$&" }, { - match: /componentDidMount=function\(\){/, + match: /componentDidMount\(\){/, replace: "$&$self.renderMagnifier(this);", }, { - match: /componentWillUnmount=function\(\){/, + match: /componentWillUnmount\(\){/, replace: "$&$self.unMountMagnifier();" } ] }, - { - find: ".carouselModal,", - replacement: { - match: /onClick:(\i),/, - replace: "onClick:$self.settings.store.preventCarouselFromClosingOnClick ? () => {} : $1," - } - } ], settings,