使用插件扩展 Google 文档
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google 文档是一款基于云的文档解决方案,提供实时协作功能和强大的工具,可用于撰写、修改和共享文档。
您可以使用插件扩展 Google 文档的功能,从而打造自定义的工作流程改进方案、建立与第三方系统的连接,以及将文档与其他 Google Workspace 应用(例如 Google 幻灯片)集成。
您可以在 Google Workspace Marketplace 中查看其他人构建的 Google 文档插件。
可以采取的措施
以下是您可以通过扩展 Google 文档的插件执行的一些操作:
- 您可以使用内置的 Apps 脚本文档服务在 Google 文档中读取、编辑、可视化和设置文本格式。该服务还可让您创建和修改 Google 文档中显示的表格、图片、绘图和方程式。
- 您可以使用标准 HTML 和 CSS 创建自定义菜单,并定义多个自定义对话框和边栏界面。
- 您可以使用插件触发器在发生特定触发事件时运行指定函数。
Google 文档插件是使用 Apps 脚本构建的。如需详细了解如何使用 Apps 脚本访问和管理 Google 文档,请参阅扩展 Google 文档。
文档结构
在 Google 文档中创建的文档具有内部树状结构(类似于 HTML 或 JSON),用于定义文本、图片、表格和其他元素显示的位置和方式。Apps 脚本文档服务定义了多个类(例如 Paragraph
或 Table
),以帮助管理不同的元素类型。
如需了解这些元素类以及控制其排列的规则,请参阅文档的结构。
触发器
借助 Apps 脚本触发器,脚本项目可以在满足特定条件时(例如打开文档或安装插件时)执行指定函数。
如需详细了解哪些触发器可用于 Google 文档插件以及使用这些触发器时有哪些限制,请参阅插件触发器。
使用入门
如果您准备好查看一些代码,请参阅我们的插件示例,包括以 Google 翻译为特色的 Docs 插件快速入门。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-31。
[null,null,["最后更新时间 (UTC):2025-07-31。"],[[["\u003cp\u003eGoogle Docs is a cloud-based document solution enabling real-time collaboration and offering robust tools for composing, editing, and sharing documents.\u003c/p\u003e\n"],["\u003cp\u003eDocs add-ons, built using Apps Script, extend functionality by enabling workflow customization, integration with third-party systems, and connectivity with other Google Workspace applications.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons can manipulate document content, create custom interfaces, and automate tasks through triggers based on specific events.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides comprehensive documentation and resources, including code samples, to guide developers in building Docs add-ons.\u003c/p\u003e\n"]]],["Google Docs is a cloud-based document solution that can be extended with add-ons via Apps Script. These add-ons can read, edit, visualize, and format text, create custom menus and dialogs, and integrate with other Google Workspace applications. Add-ons utilize Apps Script triggers to run functions when specific events occur. The documents' tree-like structure is managed through the Apps Script Document service. Resources are available, including add-on samples and a quickstart guide, to help begin developing.\n"],null,["# Extending Google Docs with add-ons\n\n[Google Docs](https://workspace.google.com/products/docs/) is a cloud-based document\nsolution with real-time collaboration and powerful tools to compose, edit,\nand share documents.\n\nYou can extend Docs with add-ons that build customized workflow improvements,\nestablish connectivity to third-party systems, and integrate your documents\nwith other Google Workspace applications (like\nGoogle Slides).\n\nYou can see the Docs add-on others have built on the\n[Google Workspace Marketplace](https://workspace.google.com/marketplace/category/works-with-doc).\n\nWhat you can do\n---------------\n\nHere are a few things you can do with an add-on that extends Google Docs:\n\n- You can read, edit, visualize, and format text in Google Docs using the built-in Apps Script [Document service](/apps-script/reference/document). The service also lets you create and modify tables, images, drawings, and equations appearing in Google Docs.\n- You can create [custom menus](/workspace/add-ons/concepts/menus) and define multiple [custom dialogs and sidebars](/workspace/add-ons/concepts/dialogs) interfaces using standard HTML and CSS.\n- You can use add-on [triggers](#triggers) to run specified functions when certain triggering events occur.\n\nDocs add-ons are built using Apps Script. To learn more about how to access\nand manage Google Docs with Apps Script, see\n[Extending Google Docs](/apps-script/guides/docs).\n\nDocument structure\n------------------\n\nThe documents created in Google Docs have internal, tree-like structures\n(similar to HTML or JSON) that define where and how text, images, tables, and\nother elements appear. The Apps Script\n[Document service](/apps-script/reference/document) defines several\nclasses (such as [`Paragraph`](/apps-script/reference/document/paragraph)\nor [`Table`](/apps-script/reference/document/table)) to help manage the\ndifferent element types.\n\nSee [Structure of a document](/apps-script/guides/docs#structure_of_a_document)\nto learn about these element classes and the rules that govern their\narrangement.\n\nTriggers\n--------\n\nApps Script **triggers** let a script project execute a specified function\nwhen certain conditions are met, such as when a document is opened or when an\nadd-on is installed.\n\nSee [add-on triggers](/workspace/add-ons/concepts/editor-triggers) for more information\non what triggers can be used with Docs add-ons and what restrictions apply to\ntheir use.\n\nGetting started\n---------------\n\nWhen you're ready to take a look at some code, check out our\n[add-on samples](/workspace/add-ons/samples), including the\n[Docs add-on Quickstart](/workspace/add-ons/editors/docs/quickstart/translate)\nfeaturing Google Translate."]]