Which data types are allowed to drop?
Which data types are allowed to be dropped to NP++?
text/plaindata element from my application obviously works.
Unfortunately I cannot use this type in my application due to an interference with a GUI element I’m using (Sortable.js). Tried with
text/htmlbut it does not work (works if I drop it in Word).
Thanks for your help!
Alan Kilborn last edited by
Can you explain a bit more about what you mean?
My interpretation so far is that you are talking about dragging-and-dropping into Notepad++. You can do this with files (which get opened when “dropped” into Notepad++, or bits of selected text (select some text in one application, drag-and-drop onto Notepad++, and the text gets put into the current document).
But that seems rather obvious so I think that your question probably goes deeper.
artie-finkelstein last edited by
I’m going to make two wild guesses here-
Assumption 1) I believe you are confusing mime ‘application/octet-stream’ data types
text/htmlused for network/internet based applications with Windows clipboard storage formats, e.g.
Many applications will post multiple ‘formats’ to the clipboard, e.g., Vivaldi (a web browser) exports text from this page as:
HTML Format CF_UNICODETEXT CF_LOCALE CF_TEXT CF_OEMTEXT
when text is copied to the clipboard.
While Notepad++ exports text from a random file I had open:
CF_UNICODETEXT CF_LOCALE CF_TEXT CF_OEMTEXT
Assumption 2) Notepad++ is most likely only willing to import text formats that it exports, .i.e., text in it’s plain formats (e.g., no Rich Text Format).
Based on those two assumptions, I think the motivation for your question falls in the gap between those two non-overlapping domains. (a/k/a: You can’t get there from here.) I’d add to that aphorism, it may be possible by using an intermediate program to translate data types, either a clipboard manager or a more data type versatile application, e.g., Write.
Of course, stacked assumptions can easily lead to wrong suggestions, so I second @Alan-Kilborn’s request.
PeterJones last edited by PeterJones
it may be possible by using an intermediate program to translate data types
see for reference “PasteSpecial revisited”, where I used Perl and the Npp-automation-thru-Perl module module to allow you to grab the HTML Format or other entries from the clipboard and paste into Notepad++. (But note that certain types, like CF_BITMAP, currently cause the script to crash; I thought I had it working for binary types, but either I misremembered or something has changed.)
Thanks a lot for your answers!
A bit more explanation: When I drag a text from my application I call
event.dataTransfer.setData()in the drag start handler first with type equal to a custom type for dropping inside the application, then
setData("text/html", html_formatted_text)for dropping to Word, and last
setData("text/plain", plain_text)for dropping text to editors like NP++.
This setting works perfectly except in one place of my application in which the drag&drop of plain text is used to order a list (package Sortable.js). So I’m try to find alternatives that hopefully are not intercepted by the package. I will try soon with the other
CF_*types (after understanding the relationship between them and the MIME types of setData).
Thanks again for now!
@Mario-Valle Yes, I’m not using the Windows clipboard. I’m using plain browser drag and drop support (https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API). Maybe I try to add a copy of the plain text in the clipboard and see what happens. Stay tuned.
OK, copying text to clipboard works but it is not drag and drop.
Anyway, I have to read carefully the @artie-finkelstein part on dropping files. Also I will add a separate “copy to clipboard” functionality that till now is missing (hoping drag&drop suffices).
See you soon!