Structure Text editor does not copy/paste styles anymore

Side note: I just wanted to share an interesting aside from the investigation so far. This is one of the stranger bugs I’ve seen… and in this case, it actually looks to be a GDocs issue — one that we’ve had a workaround for for many years, but apparently that workaround regressed and isn’t currently working. We’ll fix it ASAP.

But I had no idea just how pervasive this underlying bug was… apparently it’s been around forever, and it’s because Google Docs’s copied HTML has a <b></b> tag that wraps everything… but only when copied in Chrome and Safari:

<b style="font-weight:normal;" id="docs-internal-guid-4a573200-7fff-848b-1bde-d320d4e94ac8"><p
        dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span
        style="font-size:11pt;font-family:Arial,sans-serif;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;">This is a </span><span
        style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">test</span><span
        style="font-size:11pt;font-family:Arial,sans-serif;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;"> of </span><span
        style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:italic;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">rich</span><span
        style="font-size:11pt;font-family:Arial,sans-serif;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><span
        style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:italic;font-variant:normal;text-decoration:underline;-webkit-text-decoration-skip:none;text-decoration-skip-ink:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">text</span><span
        style="font-size:11pt;font-family:Arial,sans-serif;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>
</p></b>

They’re using it to hold an internal GUID. But this causes all sorts of headaches for everyone downstream, e.g.

I don’t know why Google Docs does this. But apparently Firefox stealth-fixes it on copy in a way Chrome and Safari do not (maybe it’s a GDocs + Webkit/Blink bug that doesn’t affect Gecko?).

We’ve even had our own preprocessor specifically for this Google Docs bug: https://github.com/datocms/structured-text/blob/main/packages/html-to-structured-text/src/preprocessors/google-docs.ts but it must’ve stopped working recently. We’ll fix it as soon as we can!

Just thought I’d share because it’s interesting how many people this one GDocs issue has affected over the years, at companies big and small…