Pasting tables into the composer behaves oddly at times

(this was also a problem in the old one)

If you paste into the composer and the clipboard has data available in both an image and text format, they both appear:

![image|171x34](upload://sWXiVew6f5ZJK7SHcyYWgaQyWtV.png)col1	col2

imagecol1 col2

It would be better if only the image appeared when a Paste action happened, and the text appeared when the Paste as plain text action happened.

The formats available for the clipboard data in this case (cells copied from libreoffice) are:

Formats: text/plain;charset=utf-8,text/plain;charset=UTF-8,UTF-8,UTF8_STRING,COMPOUND_TEXT,STRING,application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)",application/x-openoffice-objectdescriptor-xml;windows_formatname="Star Object Descriptor (XML)";classname="47BBB4CB-CE4C-4E80-a591-42d9ae74950f";typename="calc8";viewaspect="1";width="4516";height="904";posx="0";posy="0",application/x-openoffice-gdimetafile;windows_formatname="GDIMetaFile",application/x-openoffice-emf;windows_formatname="Image EMF",application/x-openoffice-wmf;windows_formatname="Image WMF",image/png,application/x-openoffice-bitmap;windows_formatname="Bitmap",PIXMAP,image/bmp,text/html,application/x-openoffice-sylk;windows_formatname="Sylk",application/x-openoffice-link;windows_formatname="Link",application/x-openoffice-dif;windows_formatname="DIF",text/richtext,MULTIPLE```



Right, that or the muggle right-click and paste method :smiley:

Or maybe I’m using this keyboard:


What would be really great would be if the text data became the image’s alt text. In this case, the code would end up being:

![col1	col2
A	B](upload://sWXiVew6f5ZJK7SHcyYWgaQyWtV.png)

I think this is Excel (or clones) specific so I don’t view this as a priority. Can anyone list any other application that does this?

My search-fu is failing me but I remember a similar issue where you would paste an image into the composer and there would be both the image and the url of that image inserted.


What would be awesome here is if we check for a format that excel has and just format the results as a proper CommonMark table (cause it exists in the clipboard as xml), this would be so much magic and so much cool.


If you request the clipboard data as plain text you get probably the most useful thing for turning into a table:



(the closest you have to XML is text/html and that’s a standalone page)

All of them? Very common to have the same object on the clipboard in multiple formats so different programs can use it in the way they see fit. e.g. copy an image in your browser (Right-Click, Copy) and you can retrieve it as any of: TIMESTAMP,TARGETS,SAVE_TARGETS,MULTIPLE,image/png,text/html,text/x-moz-url. That’s why sometimes you get the URL, sometimes you get the image itself depending on the application. Or an object embed.

As much fun as it would be to do something super nifty here, all I think this needs is “just paste the image” for now.

What other apps cause an error on paste though, specifically? Where two sets of data appear when you paste? I believe Excel and its clones are the only one.

I copy and paste tables from Excel all the time. With forumlas in Excel to turn columns into Markdown format. The always forget to copy to notepad before pastuing otherwise it will paste an image. Frustrating, if you post Excel content a lot.

1 Like

Right but it is quite specific to excel and clones, is my point.

1 Like

This seems to occur with Microsoft Word for Mac as well. Testing with Word on Windows shortly.

Edit: This issue does not occur with Word on Windows.


This has come up a fair bit.

Now that we have markdown table support it would be good to have excel paste in as a markdown table @vinothkannans I agree with that.


Don’t forget to put commas and quotes in the table data you’re copying, if it’s coming in as CSV. Proper CSV escaping is everybody’s job!


Some programs, Excel for instance, will use a tab-separated non-quotes format instead of CSV. This should be supported too.


@jomaxro I am unable to see the url you linked to try. I guess this is related to that problem?

That does not sound like the issue I encountered. The try topic is gone due to the daily reset. Here’re the steps I completed to cause the issue:

  1. Created a test document in Word for Mac. I used to generate 5 paragraphs of text. I did not include any formatting or images in the document.
  2. I copied the entirety of the document using Command + A and Command + C
  3. I created a new topic on Discourse, and pasted the content in using Command + V

The text was pasted into the composer. In addition, an “image” of the text was also uploaded.

PR created to prevent duplicate pasting if both image and text available in clipboard.

While copy paste from Word, Excel, etc., composer receives multiple inputs with data types like text/plain, text/html, text/rtf and file image/png from clipboard. (for the same copied content)

By default text/plain getting used. Instead if we use text/html by converting it to markdown then not only tables we can support more HTML tags while copy paste.

Else I can convert plain text to markdown table for now.


Only when both paste types are detected, then we should skip one of them,
the image one. We should not prioritize image pastes unless there is no
other way to do this.

As per Jeff’s advice I am doing it in other way. The images will be skipped if clipboard have file data.


The original example is excel and excel-clones. I can’t think of any reason, ever, that you would want a picture of a table of numbers rather than … an actual table of numbers. :wink: