Skip to content

Hook for drag_and_drop #125

@Chiarandini

Description

@Chiarandini

Is your feature request related to a problem? Please describe.
I often take many screenshots and add them to a latex document. Currently, I copy the screenshot and paste it in my document using the paste_image API. When I paste the image in this way, it will be put into my ./image/ folder and allow me to rename it.

It would be convenient if there is an option for this to happen when I drag and drop the image as well.

Describe the solution you'd like
I would like it so that drag_and_drop could be made to be file-type specific, and also have a new parameter called "hook" (or something else that is more appropriate). When an image is dragged and dropped (in a certain filetype, or file, or directory, etc.), the hook is triggered and will call the function that allows you to manipulate/move the image:

         latex = {
         ...
        drag_and_drop = {
          enabled = true, ---@type boolean | fun(): boolean
          insert_mode = false, ---@type boolean | fun(): boolean
          hook = function(context) ---@type string | func(context): string
             ...
         end,
        },
},

The returned string will be what's pasted into the file (it can act like "template" with variables like $FILE_PATH)

Describe alternatives you've considered
So far, I am using the "two step process" of copying the image and then pressing p, which works perfectly, but it would be great to have the ability to have the drag-and-drop feature automatically do this

Additional context
I am using Raycast, so I can quickly open my screenshots with a keyboard shortcut in a floating window and drag my images from there. For this reason, being able to automatically move the image to a folder relative to my latex file and re-name the image would be an amazing feature

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions