0

I'm developing a Google Doc add-on with Apps Script. When clicking on a button, I want to highlight (underline or set a different background color) some given words in the entire document.

I know how to format text with Apps Script. I could underline the words with

text.setUnderline(true)

but in that case it would underline the text changing its actual format in the document. I'm looking for a way to highlight (again, underline or set a background color) the words without changing the internal content of the document. In other words, I don't want the highlights to be persisted for the future.

To better understand what I'm asking, the new format of the highlighted words must not be present when printing the document or sharing it with another user who has not installed the add-on.

The idea is to develop a custom spell/grammar checker, and I want to highlight the misspelled or incorrect text as the Google Docs' integrated spellchecker does, without persisting the red underlines in the document.

Notes:

The question is similar to this one and this one, but for Apps Script instead of Microsoft Office API.

I've been suggested to use "suggested edits", referring to this question. I'd like to note this is not what I'm looking for, because the suggested edits would be persisted and they would be visible for anyone opening the document, having my add-on installed or not.

  • Please add a brief description of your search/research efforts as is suggested in [ask]. – Rubén Nov 01 '20 at 02:54
  • 2
    I don't think there's a way to do it custom. There are "suggested edits", but It's manual, I think. – TheMaster Nov 01 '20 at 14:59
  • 1
    The closest to what you're looking for is suggested edits, as mentioned before, but they cannot be created programmatically, just viewed. I'd suggest you to request this feature in Issue Tracker. Related: https://stackoverflow.com/q/60775916 – Iamblichus Nov 02 '20 at 11:16

0 Answers0