1

My question is regarding this update (https://workspaceupdates.googleblog.com/2021/05/Google-Docs-Canvas-Based-Rendering-Update.html) from May 2021 that affects our chrome extension, that we are just finding out about now.

We have a Chrome Extension that we wrote in 2020 that needs to manipulate the DOM to highlight passages of text in google docs documents. This has obviously stopped working because Google Docs have switched from DOM to Canvas.

We did some digging around and looks like this extension here - WriQ - (https://chrome.google.com/webstore/detail/wriq/kfkohpkagbjoncihbogfnjnddimfbgea), when installed and activated, seems to force the document to switch from Canvas to DOM mode. I could be wrong, but that's the impression I get when I do this:

  • When I don't have WriQ installed and activated, $(".kix-paragraphrenderer") in the console of a Google Docs document page returns null - meaning the Google Doc renderer is using the new default Canvas mode.

  • When I have WriQ installed and activated, (and refresh the Google Docs page if already open) $(".kix-paragraphrenderer") in the console of a Google Docs document page returns an element - meaning the Google Doc renderer is switching to DOM mode.

Can anyone explain this? Is there a way to programatically trigger the DOM mode? That's what WriQ seems to be doing.

user2950957
  • 157
  • 1
  • 2
  • 8
  • 1
    Google Docs explicitly checks for this extension's id and keeps the legacy mode. You can see the list of all ids by searching for this id in page sources in devtools. If your extension is not popular you'll have to migrate to a special apps script judging by the [documentation](https://developers.google.com/apps-script/add-ons/editors/docs). – wOxxOm Jan 18 '22 at 07:17
  • @wOxxOm thanks! that's exactly what seems to be going on. – user2950957 Jan 18 '22 at 21:37
  • Does this answer your question? [How to force Google Docs to render HTML instead of Canvas from Chrome Extension?](https://stackoverflow.com/questions/69803427/how-to-force-google-docs-to-render-html-instead-of-canvas-from-chrome-extension) – Axtru Mar 02 '22 at 22:04

2 Answers2

0

You can try setting window._docs_force_html_by_ext = <extension-id>. That will force Google Docs to render the HTML DOM instead of Canvas.

Samarth Agarwal
  • 2,044
  • 8
  • 39
  • 79
  • Does this still work for you? It seemed to be working for me until a day or two ago, then it stopped working. Do you know how to force Docs to render as HTML now? Is there some additonal flag that needs to be set or something else? Thanks. (I use Docs in FireFox and the text is very blurry when rendered in Canvas mode.) – Lord Null Apr 06 '22 at 08:58
  • It still seems to work fine for me on Google Chrome. I have not tested this on Firefox. Can you check on Chrome and post back? It is possible that they may be phasing it out since they want to bring in the Canvas rendering mechanism for all. – Samarth Agarwal Apr 06 '22 at 12:41
  • Turns out that now it only works for Google workspace users. I am not sure for how long this will continue to work. – Samarth Agarwal Apr 06 '22 at 19:27
  • What are we supposed to put for the "extension-id"? Must one have an extension already listed on the Chrome webstore to get a valid id? If so, how does one develop and test their extension? – ssaeed May 18 '22 at 22:19
  • I think barely setting it to `true` worked as well but it does not work anymore. Google has completely deprecated it. – Samarth Agarwal Jun 04 '22 at 19:19
0

Google is whitelisting some applications which can use a script forcing the document to a HTML Fallback version which reminds of the time before canvas or as an Annotated Canvas which makes it possible to make extension integrations with the SVG canvas.

You need to apply for whitelisting to access these features: https://docs.google.com/forms/d/e/1FAIpQLScFxMgvXlq2KMsp0UIM66pvThTF1hpojiXQTqyq9txW79OWag/viewform

Axtru
  • 171
  • 1
  • 9
  • Nope the HTML Fallback has been deprecated as far as i know. But it is still possible to get the Annotated Canvas. – Axtru Aug 19 '22 at 11:52