labnol / apps-script-starter

Setup a local development environment inside Visual Studio Code and build Google Workspace add-ons with Google Apps Script
https://www.youtube.com/watch?v=KxdCIbeO4Uk
MIT License
1.1k stars 176 forks source link

How to setup a menu in bound google doc #39

Closed namelus closed 4 years ago

namelus commented 4 years ago

@labnol

Thank you very much for this awesome repo. Works like a charm!

I am new to webpack and babel and am trying to figure out how to setup a menu in my bound google doc. Typically its onOpen () => { getUi; createMenu; createMenuItem } etc.

I tried adding it in a number of places, but it only works if I manually run the onOpen from the script editor. Also read about adding a trigger, but feel that is only a workaround.

Any help would be really appreciated. Thanks in advance.

labnol commented 4 years ago

I've added a little example here on how you can add menus in container bound scripts.

https://github.com/labnol/apps-script-starter/blob/e7c193a5a5080e25e46f1fd02c703283b766a520/src/server/menu.js