add option to copy links to images and gifs inside gifcollections (#401)
This commit is contained in:
parent
ac8c696dc8
commit
520da5ad00
1 changed files with 38 additions and 1 deletions
|
|
@ -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 }) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue