Update ImageUtilities.plugin.js

This commit is contained in:
Mirco Wittrien 2024-06-22 12:27:56 +02:00
parent 27f0240cdd
commit e9d69b7a12
1 changed files with 95 additions and 76 deletions

View File

@ -2,7 +2,7 @@
* @name ImageUtilities * @name ImageUtilities
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 5.4.4 * @version 5.4.5
* @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.) * @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.)
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -438,11 +438,16 @@ module.exports = (_ => {
position: absolute; position: absolute;
display: flex; display: flex;
} }
${BDFDB.dotCNS._imageutilitiesoperations + BDFDB.dotCN.downloadlink} { ${BDFDB.dotCNS._imageutilitiesoperations + BDFDB.dotCN.imagemodalimageoptionscontainer} {
position: static !important;
display: flex !important;
flex-wrap: unset !important;
}
${BDFDB.dotCNS._imageutilitiesoperations + BDFDB.dotCN.imagemodalimagedownloadlink} {
position: relative !important; position: relative !important;
white-space: nowrap !important; white-space: nowrap !important;
} }
${BDFDB.dotCNS._imageutilitiesoperations + BDFDB.dotCN.anchor + BDFDB.dotCN.downloadlink} { ${BDFDB.dotCNS._imageutilitiesoperations + BDFDB.dotCN.anchor + BDFDB.dotCN.imagemodalimagedownloadlink} {
margin: 0 !important; margin: 0 !important;
} }
`; `;
@ -900,6 +905,7 @@ module.exports = (_ => {
naturalWidth: this.videoWidth, naturalWidth: this.videoWidth,
height: this.videoHeight, height: this.videoHeight,
naturalHeight: this.videoHeight, naturalHeight: this.videoHeight,
renderForwardComponent: _ => {},
renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props) renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props)
}) : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ImageModal, { }) : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ImageModal, {
src: imageThrowaway.src, src: imageThrowaway.src,
@ -907,6 +913,7 @@ module.exports = (_ => {
width: this.width, width: this.width,
height: this.height, height: this.height,
className: BDFDB.disCN.imagemodalimage, className: BDFDB.disCN.imagemodalimage,
renderForwardComponent: _ => {},
renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props) renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props)
}) })
}), true); }), true);
@ -988,7 +995,7 @@ module.exports = (_ => {
else { else {
let url = this.getImageSrc(viewedImage && viewedImage.proxy_url || typeof e.instance.props.children == "function" && e.instance.props.children(Object.assign({}, e.instance.props, {size: e.instance.props})).props.src || e.instance.props.src); let url = this.getImageSrc(viewedImage && viewedImage.proxy_url || typeof e.instance.props.children == "function" && e.instance.props.children(Object.assign({}, e.instance.props, {size: e.instance.props})).props.src || e.instance.props.src);
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.downloadlink]]}); let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: ["renderForwardComponent"]});
if (index > -1) { if (index > -1) {
let type = filterForVideos ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; let type = filterForVideos ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE;
let openContext = event => BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { let openContext = event => BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
@ -1037,14 +1044,16 @@ module.exports = (_ => {
className: BDFDB.disCN._imageutilitiesoperations, className: BDFDB.disCN._imageutilitiesoperations,
children: [ children: [
children[index], children[index],
this.settings.viewerSettings.saveImage && [ this.settings.viewerSettings.saveImage && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.imagemodalimageoptionscontainer,
children: [
BDFDB.ReactUtils.createElement("span", { BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: "|", children: "|",
style: {margin: "0 5px"} style: {margin: "0 5px"}
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: this.labels.context_saveas.replace("{{var0}}", type), children: this.labels.context_saveas.replace("{{var0}}", type),
onClick: event => { onClick: event => {
BDFDB.ListenerUtils.stopEvent(event); BDFDB.ListenerUtils.stopEvent(event);
@ -1061,30 +1070,36 @@ module.exports = (_ => {
})); }));
} }
}) })
], ]
this.settings.viewerSettings.copyImage && this.isValid(url, "copyable") && [ }),
this.settings.viewerSettings.copyImage && this.isValid(url, "copyable") && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.imagemodalimageoptionscontainer,
children: [
BDFDB.ReactUtils.createElement("span", { BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: "|", children: "|",
style: {margin: "0 5px"} style: {margin: "0 5px"}
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: this.labels.context_copy.replace("{{var0}}", type), children: this.labels.context_copy.replace("{{var0}}", type),
onClick: event => { onClick: event => {
BDFDB.ListenerUtils.stopEvent(event); BDFDB.ListenerUtils.stopEvent(event);
this.copyFile({url: e.instance.props.original, fallbackUrl: url}); this.copyFile({url: e.instance.props.original, fallbackUrl: url});
} }
}) })
], ]
this.settings.viewerSettings.galleryMode && viewedImage && this.settings.viewerSettings.jumpTo && [ }),
this.settings.viewerSettings.galleryMode && viewedImage && this.settings.viewerSettings.jumpTo && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.imagemodalimageoptionscontainer,
children: [
BDFDB.ReactUtils.createElement("span", { BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: "|", children: "|",
style: {margin: "0 5px"} style: {margin: "0 5px"}
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: BDFDB.LanguageUtils.LanguageStrings.JUMP, children: BDFDB.LanguageUtils.LanguageStrings.JUMP,
onClick: event => { onClick: event => {
let layerContainer = !event.shiftKey && BDFDB.DOMUtils.getParent(BDFDB.dotCN.itemlayercontainer, event.currentTarget) let layerContainer = !event.shiftKey && BDFDB.DOMUtils.getParent(BDFDB.dotCN.itemlayercontainer, event.currentTarget)
@ -1094,20 +1109,24 @@ module.exports = (_ => {
if (channel) BDFDB.LibraryModules.HistoryUtils.transitionTo(BDFDB.DiscordConstants.Routes.CHANNEL(channel.guild_id, channel.id, viewedImage.messageId)); if (channel) BDFDB.LibraryModules.HistoryUtils.transitionTo(BDFDB.DiscordConstants.Routes.CHANNEL(channel.guild_id, channel.id, viewedImage.messageId));
} }
}) })
], ]
this.settings.viewerSettings.zoomMode && !filterForVideos && !this.isValid(e.instance.props.src, "gif") && [ }),
this.settings.viewerSettings.zoomMode && !filterForVideos && !this.isValid(e.instance.props.src, "gif") && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.imagemodalimageoptionscontainer,
children: [
BDFDB.ReactUtils.createElement("span", { BDFDB.ReactUtils.createElement("span", {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: "|", children: "|",
style: {margin: "0 5px"} style: {margin: "0 5px"}
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
className: BDFDB.disCN.downloadlink, className: BDFDB.disCN.imagemodalimagedownloadlink,
children: `Zoom ${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}`, children: `Zoom ${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}`,
onClick: openContext, onClick: openContext,
onContextMenu: openContext onContextMenu: openContext
}) })
] ]
})
].flat(10).filter(n => n) ].flat(10).filter(n => n)
}); });