Feature: Add ability to drag and drop images to MarkdownEditor#14587
Feature: Add ability to drag and drop images to MarkdownEditor#14587koppor merged 15 commits intoJabRef:mainfrom
Conversation
|
Which OS are you using? Windows? Mac? Linux? |
|
I'm using Linux (Fedora) |
Do a breakpoint at org.jabref.gui.fieldeditors.LinkedFilesEditor#handleOnDragDropped - and drop a file into the linked files editor (which is part of the Entry Editor) |
Jabref-LinkedFilesEditor.mp4I looked at the class and assume me dragging one file below the other or vice versa should reorder them, but as you can see from the video only the |
|
@Siedlerchr @koppor Please take a look when you find the time |
|
@ganesh-vk Thanks for the video. I could reproduce it. It's a bug. |
|
If you merge in the latest main it will probably also work for your case |
Yes, it works now, thanks for the fix! However I'm unable to figure out how Related to the original issue, JavaFX WebView does not support all image types ref. Do I change |
koppor
left a comment
There was a problem hiding this comment.
- Steps to test missing - why?
- Screenshot missing - you can update the PR description to guide maintainers
Related to the original issue, JavaFX WebView does not support all image types ref.
What are "all images types"?
I think, it does not matter here. I just want to drag'n'drop an image from Windows explorer to the text field.
"png" from the issue description is listed there. So, what is the issue?
You can allow attachment of any file - the bibtex could be rendered by another tool, too. It is "just" an exchange format.
PreviewViewer'ssetPreviewTextwill need a<base>tag to specify the relative file path as well looks like.
Follow https://devdocs.jabref.org/code-howtos/#get-a-relative-filename-or-path-for-a-file
Use sub directory "assets" (make it a constant in JabRef, so that we could change later)
(Maybe you find another solution at the related feature #14330 , but I don't remember)
…dered by preview viewer
For e.g. webp is not rendered correctly, but webp is an image format so Currently all supported formats get rendered and the image gets saved in the directory specified in preferences. Adding Steps to test and screenshots now, since the PR was incomplete and still a draft I didn't add them. |
jabgui/src/main/java/org/jabref/gui/preview/assets/PreviewText.java
Outdated
Show resolved
Hide resolved
jabgui/src/main/java/org/jabref/gui/fieldeditors/MarkdownEditor.java
Outdated
Show resolved
Hide resolved
jabgui/src/main/java/org/jabref/gui/fieldeditors/MarkdownEditor.java
Outdated
Show resolved
Hide resolved
| Files.copy(file.toPath(), destination, StandardCopyOption.REPLACE_EXISTING); | ||
| String relativePath = FileUtil.relativize(destination, databaseContext.getFileDirectories(filePreferences)).toString(); | ||
| String markdownText = "\n"; | ||
| textArea.appendText(markdownText); |
There was a problem hiding this comment.
Is it possible to insert the link at the place where the mouse pointer was placed when the drop was triggered.
There was a problem hiding this comment.
I've changed it to insert at caret position, I wasn't sure if it is better if it's pasted where the caret is compared to just appending since it might lead to formatting errors.
…rted at caret position and not appended
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
|
Note that I merged |
CHANGELOG.md
Outdated
| ### Added | ||
|
|
||
| - We added the ability to drag and drop images to the comments field. [14620](https://github.com/JabRef/jabref/pull/14620/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed) | ||
| - We added the ability to drag and drop images to the comments field. [#14620](https://github.com/JabRef/jabref/issues/10559) |
There was a problem hiding this comment.
Really? Are you sure???
Did you or your AI not perform? What time is it? I am awake since 17 hours and still see it.
Why are you doing this to us?
There was a problem hiding this comment.
Note #10559 is the right link and #10559 the right issue number
| - We added the ability to drag and drop images to the comments field. [#14620](https://github.com/JabRef/jabref/issues/10559) | |
| - We added the ability to drag and drop images to the comments field. [#10559](https://github.com/JabRef/jabref/issues/10559) |
There was a problem hiding this comment.
It's 4 AM, I'm sorry I missed that, only copy pasted the correct link and forgot to change that :)
| } | ||
| } | ||
|
|
||
| layoutText = formatPreviewText(baseUrl, text); |
There was a problem hiding this comment.
For an unsaved library no preview will ever be generated - why?
| List<Path> fileDirList = databaseContext.getFileDirectories(filePreferences); | ||
| Path relativePath = FileUtil.relativize(file.toPath(), fileDirList); | ||
|
|
||
| // If the path is already relative, just insert the Markdown text |
There was a problem hiding this comment.
| // If the path is already relative, just insert the Markdown text | |
| // If the path can be reached from the configured directories somehow, just insert the Markdown text |
I didn't understand, could you please elaborate? I am using Linux (Fedora) Jabref-DragDropBug.mp4 |
|
Looks like this is a windows path problem, I will look into this tomorrow, do you have any hints on what I should try? |
| } | ||
|
|
||
| private void insertMarkdownText(String relativePath, EditorTextArea textArea) { | ||
| String markdownText = "\n"; |
There was a problem hiding this comment.
Markdown only understands forward / slashes! Backslash \ is an escape character. This might explain the path issue
replace \ by / in the path - locally in insertMarkdownText |
Welcome to the hell of drag and drop... One "just" need to add LOGGERR.trace statements for the drag type, read the output, think etc... but I would postpone that for a follow-up. Basically, this will work (if the windows path issue is solved) See https://devdocs.jabref.org/code-howtos/logging.html for loggin |
I've done this, could you please test it out in Windows and see if it works? I can't test this since I'm on linux |
|
@ganesh-vk Works well - thank you for the quick follow ups. This values our time. |
Thank you for the reviews! |


Closes #10559
I've looked at the JavaFX documentation for dragging and dropping events and think I'm doing everything correctly. However I cannot seem to trigger the
DRAG_DROPPEDevent at all. I've tried to debug and theDRAG_OVERevent is being triggered everytime but the dropping isn't working. Please let me know what I should try to fix this.Steps to test
Screenshots:
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)