Best way to paste styled text and images into Discourse composer

I often draft content for posting into Discourse in Google Docs. (Not simple messages, obviously, but more formal announcements and the like, where collaborative editing is essential.) Until Monday, I could select all in a Google Doc and paste into Discourse and get semantic text formatting (other than bold and italic character styles) and images. The images came over because Google Docs put them on the macOS clipboard as URLs, and Discourse was happy to ingest them.

However, Google very recently changed things so copying from Google Docs seemingly encodes the images as Base64 instead. (I’m basing this guess on MailChimp’s tool for ingesting formatted text, which used to work fine when there were URLs but started kicking out the Base64 images on Monday.) Regardless of what’s actually happening behind the scenes, copying and pasting from Google Docs no longer brings over images, just the formatted text. Images are replaced with [image].

Obviously, it’s possible to paste an image from the macOS clipboard into a Discourse composer window, so my question is if there’s any way for Discourse to accept a combination of text and images all at once, which is much easier than having to paste text in and then insert images one at a time. I did some testing with copying text and images from various Mac apps to see if they put data on the clipboard differently, but nothing worked—I either got [image] or nothing, apart from one time when I got a little Arc 2023-05-03 at 15.28.15@2x tag.

Is there any information about what sort of data Discourse can accept from the macOS clipboard and in what combinations?

2 Likes

Hello Adam :wave:

If you’re specifically talking about Google Docs, it’s not possible to our knowledge since their change:

I don’t know if it would be possible for Discourse to be able to paste Base64 images as regular images in a post. That could be worth a post on feature I guess.

As a practical example, if we have a Google Doc (Test Discourse base64 image - Google Docs) and we copy all of it, here’s the Windows 11 clipboard content according to Clipview (Windows clipboard raw viewer)

Version:0.9
StartHTML:0000000105
EndHTML:0000001659
StartFragment:0000000141
EndFragment:0000001623
<html>
  <body>
    <!--StartFragment-->
    <meta charset="utf-8">
    <b style="font-weight:normal;" id="docs-internal-guid-86b76b06-7fff-94b7-4ff6-2d981c2951e9">
      <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;">
        <span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">test</span>
      </p>
      <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;">
        <span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">
          <span style="border:none;display:inline-block;overflow:hidden;width:10px;height:10px;">
            <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAExJREFUKFNj/M/A8J+BCMAIU8j4Abvq/wIQcbBCkCKQALpimBiYhikE6UJWjMFGVghTDLYKySkYJhKtkCirifIMupuQAwoleIgIbwYADG839985eBAAAAAASUVORK5CYII=" width="10" height="10" style="margin-left:0px;margin-top:0px;" />
          </span>
        </span>
      </p>
      <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;">
        <span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">img</span>
      </p>
    </b>
    <br class="Apple-interchange-newline">
    <!--EndFragment-->
  </body>
</html>

Thanks—I’ll reply over there about Pages and Word, which don’t work either for pasting text and images.

My question for this topic is what clipboard contents Discourse can accept? It seems to be able to do images on their own and HTML code as long as the images are linked and not embedded.

Do you know of a Mac equivalent to Clipview so I could investigate what different apps are putting on the clipboard?

I’m trying Clipboard Viewer for Mac OS X and it seems to do the job.

Here with my google doc content copy:

1 Like

Alternatively, you have this handy website:

2 Likes