add option to copy links to images and gifs inside gifcollections (#401)

This commit is contained in:
creations 2025-09-18 17:11:05 -04:00 • committed by GitHub
parent ac8c696dc8
commit 520da5ad00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,6 +41,20 @@ const addCollectionContextMenuPatch: NavContextMenuPatchCallback = (children, pr
if (group && !group.some(child => child?.props?.id === "add-to-collection")) {
const collections = cache_collections;
if (settings.store.showCopyImageLink) {
group.push(
<Menu.MenuItem
label="Copy Image Link"
key="copy-image-link"
id="copy-image-link"
action={() => {
copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS);
}}
/>
);
}
group.push(
<Menu.MenuItem
label="Add To Collection"
@ -112,6 +126,11 @@ export const settings = definePluginSettings({
type: OptionType.BOOLEAN,
default: false,
},
showCopyImageLink: {
description: "Show 'Copy Image Link' option in context menus",
type: OptionType.BOOLEAN,
default: false,
},
defaultEmptyCollectionImage: {
description: "The image / gif that will be shown when a collection has no images / gifs",
type: OptionType.STRING,
@ -642,7 +661,23 @@ const RemoveItemContextMenu = ({ type, nameOrId, instance }) => (
const MenuThingy = ({ gif }) => {
const collections = cache_collections;
return (
const menuItems: React.ReactNode[] = [];
if (settings.store.showCopyImageLink) {
menuItems.push(
<Menu.MenuItem
label="Copy Image Link"
key="copy-image-link"
id="copy-image-link"
action={() => {
copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS);
}}
/>
);
}
menuItems.push(
<Menu.MenuItem label="Add To Collection" key="add-to-collection" id="add-to-collection">
{collections.map(col => (
<Menu.MenuItem
@ -663,6 +698,8 @@ const MenuThingy = ({ gif }) => {
/>
</Menu.MenuItem>
);
return <>{menuItems}</>;
};
function CreateCollectionModal({ gif, onClose, modalProps }) {