Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

How can I add an addon to the google docs side pannel?

Is there any way for developers to add icons to the side panel? The documentation I've seen only shows custom side-bars and the addon ui menu, but the built-in side panel is fairly new and has a button to add add-ons, suggesting that addons would be added to it.

enter image description here

I'd like to add an icon to the built-in side panel to avoid extra clicks for my add-on.

UI Reference Custom Sidebar

question from:https://stackoverflow.com/questions/65858484/how-can-i-add-an-addon-to-the-google-docs-side-pannel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to include sheets in the addOns section of the manifest, as specified here. The documentation for add-ons is available at https://developers.google.com/gsuite/add-ons/overview

Here's a simplified example derived from Quickstart: Cats Google Workspace Add-on

Code.gs

function onHomepage(e) {
  return CardService.newCardBuilder().addSection(
    CardService.newCardSection().setHeader('Header').addWidget(
      CardService.newTextParagraph().setText('Paragraph')
    )
  ).build();
}

appsscript.json (manifest)

{
  "timeZone": "Etc/GMT",
  "dependencies": {},
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "addOns": {
    "common": {
      "name": "Cats",
      "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png",
      "homepageTrigger": {
        "runFunction": "onHomepage",
        "enabled": true
      }
    },
    "sheets": {}
  }
}

The homepageTrigger doesn't need to be in the common section. You could include place it directly within sheets instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...