无法让菜单项显示在 google 文档的未发布插件中

Can't get menu item to show in an unpublished add-on for google document

我的代码是这样的:

function onInstall(e) {
  onOpen(e);
}

function onOpen(e) {
  DocumentApp.getUi().createAddonMenu()
  .addItem("Format Your Text", "autoFormatting")
  .addToUi();
}

function autoFormatting() {
  //some code
}

这是什么原因造成的?我该如何解决?

我现在不想发布插件,只想与我域中的其他用户共享。

答案:

如果您希望与域中的成员共享 Google Docs 的附加组件,则必须先将其发布。没有办法解决这个问题。

更多信息:

来自发布 G Suite 附加组件documentation

Private add-ons are only visible to users in the same domain as the add-on publishing account. Only domain accounts can publish private add-ons. They can't be installed by outside users. Private add-ons do not require add-on review. Private visibility is also referred to as My Domain visibility.

And:

Visibility: Only published add-ons have a meaningful visibility status.

如果您希望您域中的其他人可以使用此加载项,您首先需要在使用前私下发布它。

否则,您可以将您的插件脚本发送给其他用户,让他们按照部署步骤将其用于他们的帐户。

参考文献: