joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Images missing when pasting into webapps and some desktop apps from Joplin

Open personalizedrefrigerator opened this issue 11 months ago • 4 comments

Operating system

Linux

Joplin version

2.14

Desktop version info

No response

Current behaviour

See the corresponding forum issue.

Currently, many apps can't paste the images copied from Joplin's rich text editor or markdown preview pane.

On Linux:

  • LibreOffice Writer: Works (images shown)
  • LibreOffice Calc: Works (images shown)
  • LibreOffice Impress: Doesn't work (text, but no images)
  • GMail in Firefox, GMail in Chrome: Doesn't work (text, but no images)

On Windows,

  • Paste into Word on Windows 11: Works (images shown)
  • Paste into Outlook desktop on Windows 11: Works (images shown)
  • Paste into WordPad on Windows 11: Doesn't work (text, but no images)
  • Paste into Word Online on Windows 11: Doesn't work (text, but no images)

Possible reason why this is happening

I think it's because text copied to the clipboard (at least from the rich text editor) looks like this to a website:

{
   'text/html': '<div id="rendered-md">\n<p>The following is a&nbsp;<strong>test</strong> image:</p>\n<p><img src="file:///home/primary/.config/joplin-desktop/resources/bdef250506d9444cabe9f190358c8b98.png" alt="Screenshot from 2024-03-06 07-23-02.png"></p>\n<p>&nbsp;</p>\n<p>This is a test.</p>\n</div>',
   'text/plain': 'The following is a **test** image:\n\n![Screenshot from 2024-03-06 07-23-02.png](file:///home/primary/.config/joplin-desktop/resources/bdef250506d9444cabe9f190358c8b98.png)\n\n&nbsp;\n\nThis is a test.',
   'files': Empty FileList
}

Notice that above, the <img tags are specifie using file:// URLs, which can't be accessed by most/all websites.

Expected behaviour

No response

Logs

No response

@personalizedrefrigerator maybe we can use data:image/png;base64 urls for loading the image in this way image would be copied correctly including the other content to be fixed,would it be right to do so?

dgbkn avatar Mar 09 '24 06:03 dgbkn

maybe we can use data:image/png;base64 urls for loading the image in this way image would be copied correctly including the other content to be fixed,would it be right to do so?

Good idea! I think that would work. Here's a list of considerations for this:

  • If an image is very large, we may not want to convert it to data:image/png;base64.
  • To avoid duplicating resource files, it might also be necessary to add a data-resourceid field to the img tag when copying.
    • When copy/pasting between Joplin profiles, we'll need logic to make sure a non-existing resource isn't linked to.

Edit: Adjusted formatting.

can I work on this issue?

Niharika0104 avatar Mar 22 '24 11:03 Niharika0104

we don't assign issues, if you feel doing it, simply do it

PackElend avatar Mar 22 '24 12:03 PackElend