با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
وقتی کاربر از Google Drive استفاده می کند، افزونه های Google Workspace می توانند رابط های سفارشی سازی شده را ارائه دهند. این به شما امکان می دهد اطلاعات مرتبط اضافی را در اختیار کاربر قرار دهید، وظایف را خودکار کنید و سیستم های شخص ثالث را به Google Drive متصل کنید.
دسترسی به رابط کاربری افزونه
اگر نماد آن در ستون نماد در سمت راست رابط کاربری Drive ظاهر شود، میتوانید یک افزونه Google Workspace را در Google Drive باز کنید. یک افزونه Google Workspace می تواند یک رابط صفحه اصلی، یک رابط انتخاب مورد یا هر دو را تعریف کند:
اگر کاربر در حین حضور در Google Drive روی نماد افزونه کلیک کند، این افزونه عملکرد drive.homepageTrigger مربوطه را (در صورت وجود) اجرا می کند. این تابع یک کارت صفحه اصلی را برای نمایش به Google Drive می سازد و برمی گرداند. اگر عملکرد drive.homepageTrigger تعریف نشده باشد، به جای آن یک کارت صفحه اصلی عمومی نمایش داده می شود.
اگر کاربر یک یا چند مورد را در Google Drive انتخاب کند و سپس روی نماد برافزا کلیک کند، یا در حالی که افزونه باز است، موارد را انتخاب کند، برافزا تابع متنی drive.onItemsSelectedTrigger مربوطه را (در صورت وجود) اجرا میکند. این تابع رابط کاربری متنی «اقلام انتخاب شده» Google Drive افزونه را می سازد و آن را برای نمایش به Google Drive برمی گرداند.
ساخت رابط افزودنی Drive
با دنبال کردن این مراحل کلی میتوانید رابطهایی بسازید که Google Drive را گسترش دهند:
تصمیم بگیرید که آیا میخواهید افزونه شما یک صفحه اصلی مخصوص Drive داشته باشد یا خیر. همچنین تصمیم بگیرید که آیا میخواهید یک رابط متنی برای زمانی که کاربر موارد Drive را انتخاب میکند ارائه دهید.
توابع مربوط به پاسخ به تماس مورد نیاز برای پاسخگویی به تعاملات رابط کاربری کاربر، مانند کلیک روی دکمه، را اجرا کنید.
درایو صفحات اصلی
Google Drive از نمایش صفحات اصلی افزونه Google Workspace پشتیبانی می کند. برای نشان دادن صفحه اصلی مشترک افزونه خود در Google Drive، فقط مطمئن شوید که یک فیلد addOns.drive در مانیفست افزونه وجود دارد.
از طرف دیگر، یک drive.homepageTrigger به مانیفست افزودنی اضافه کنید تا یک صفحه اصلی مخصوص Drive ارائه شود.
در هر صورت، باید نام یک تابع راهاندازی صفحه اصلی را در پروژه اسکریپت افزونه خود وارد کنید. این تابع به طور خودکار برای ساختن صفحه اصلی Drive در صورت نیاز فراخوانی می شود. شما باید این تابع را برای ساختن و برگرداندن یک Card یا آرایه ای از اشیاء Card که صفحه اصلی را تشکیل می دهند، پیاده سازی کنید. تابع ماشه صفحه اصلی به یک شی رویداد به عنوان پارامتر ارسال می شود که حاوی برخی اطلاعات کلی مانند پلت فرم مشتری است. میتوانید از دادههای شی رویداد برای تنظیم ساخت صفحه اصلی استفاده کنید.
رابط متنی را برای موارد انتخاب شده هدایت کنید
Google Drive برای تعیین اینکه چه رابطی (در صورت وجود) هنگام انتخاب یک یا چند مورد Google Drive توسط کاربر نمایش داده شود، به یک راهانداز متنی متکی است. هنگامی که تریگر فعال می شود، تابع تریگر متنی مشخص شده توسط قسمت drive.onItemsSelectedTrigger.runFunction در مانیفست افزودنی را اجرا می کند.
برای ایجاد یک رابط انتخاب مورد متنی برای Drive، باید موارد زیر را انجام دهید:
مطمئن شوید که مانیفست افزونه شامل https://www.googleapis.com/auth/drive.addons.metadata.readonlyمحدوده
مانند هر کارت دیگری، باید هر توابع پاسخ به تماسی را که برای ارائه تعامل ویجت برای رابط استفاده می شود، پیاده سازی کنید. برای مثال، اگر دکمهای را در اینترفیس قرار دهید، باید یک Action پیوست و یک تابع callback اجرا شده داشته باشد که با کلیک روی دکمه اجرا شود.
اشیاء رویداد
هنگامی که آن توابع فراخوانی می شوند، یک شی رویداد ایجاد می شود و به تابع محرک drive.homepageTrigger یا drive.onItemsSelectedTrigger ارسال می شود. تابع ماشه می تواند از اطلاعات موجود در این شی رویداد برای تعیین نحوه ساخت کارت های افزودنی یا کنترل رفتار افزونه استفاده کند.
ساختار کامل اشیاء رویداد در اشیاء رویداد توضیح داده شده است. وقتی Drive برنامه میزبان فعال افزونه است، اشیاء رویداد متنی شامل فیلد شی رویداد Drive است که اطلاعات مشتری خاص Drive را حمل می کند.
اشیاء رویداد Contextual Drive برای محرکهای انتخاب مورد شامل اطلاعات مواردی است که کاربر هنگام فعال شدن ماشه انتخاب کرده است. وقتی کاربر بیش از یک مورد را در Drive انتخاب میکند، یکی از موارد مورد علاقه اصلی در نظر گرفته میشود. این مورد به عنوان آیتم مکان نما فعال نامیده می شود.
تاریخ آخرین بهروزرسانی 2025-07-30 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-30 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle Workspace add-ons extend Google Drive functionality by offering custom interfaces for automation, insights, and third-party integrations.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons can provide a homepage within Google Drive and a contextual interface that appears when Drive items are selected.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers build these interfaces using Apps Script, defining triggers and functions in the add-on's manifest file.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons utilize event objects, including Drive-specific data, to tailor their behavior based on user interactions and selected items.\u003c/p\u003e\n"],["\u003cp\u003eWhen multiple items are selected in Google Drive, add-ons can access both the active cursor item and the full list of selected items for context.\u003c/p\u003e\n"]]],["Google Workspace add-ons enhance Google Drive with custom interfaces, triggered by user actions. Add-ons can display a homepage when the icon is clicked or a contextual interface upon item selection. Developers define these interfaces by implementing `homepageTrigger` or `onItemsSelectedTrigger` functions in the add-on's manifest. These functions build and return card-based UIs. Contextual triggers utilize event objects containing information about selected items, including an active cursor item for single-item interactions, to tailor the add-on's behavior.\n"],null,["# Building Google Drive interfaces\n\nGoogle Workspace add-ons can provide customized\ninterfaces when the user is using Google Drive. This lets you provide the user\nwith additional relevant information, automate tasks, and connect third-party\nsystems to Google Drive.\n\nAccessing the add-on UI\n-----------------------\n\nYou can open a Google Workspace add-on in\nGoogle Drive if its icon appears in the\nicon column on the right side of the Drive user interface. A\nGoogle Workspace add-on can\ndefine a homepage interface, an item select interface, or both:\n\n- If a user clicks the add-on icon while in Google Drive, the add-on executes the corresponding [`drive.homepageTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.homepageTrigger) function (if present). This function builds and returns a [homepage card](/workspace/add-ons/concepts/homepages) to Google Drive for display. If no [`drive.homepageTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.homepageTrigger) function is defined, a generic homepage card is displayed instead.\n- If the user selects one or more items in Google Drive and then clicks the add-on icon, or selects items while the add-on is open, the add-on executes the corresponding [`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger) contextual function (if present). This function builds the add-on's Google Drive [contextual \"items selected\" interface](#drive_contextual_interface_for_items_selected) and returns it to Google Drive for display.\n\nBuilding the add-on Drive interface\n-----------------------------------\n\nYou can build interfaces that extend Google Drive by following these general\nsteps:\n\n1. Decide whether you want your add-on to have a Drive-specific [homepage](/workspace/add-ons/concepts/homepages). Also decide if you want to provide a contextual interface for when the user selects Drive items.\n2. Add the appropriate [`addOns.common`](/apps-script/manifest/addons#AddOns.FIELDS.common) and [`addOns.drive`](/apps-script/manifest/addons#AddOns.FIELDS.drive) fields to the add-on script project [manifest](/workspace/add-ons/concepts/workspace-manifests), including any [Drive scopes](/workspace/add-ons/concepts/workspace-scopes#drive_scopes) required.\n3. If you are providing a [Drive-specific homepage](#drive_homepages), implement the [`drive.homepageTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.homepageTrigger) function to build this interface. You can also choose to use the [`common.homepageTrigger`](/apps-script/manifest/addons#Common.FIELDS.homepageTrigger) interface for multiple Google Workspace hosts.\n4. If you are providing a Drive contextual item selection interface, you must implement a [`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger) contextual trigger function to build this interface. See [Drive contextual interface for items selected](#drive_contextual_interface_for_items_selected)) for details.\n5. Implement the associated callback functions needed to respond to the user's UI interactions, such as button clicks.\n\n### Drive homepages\n\nGoogle Drive supports displaying Google Workspace add-on\n[homepages](/workspace/add-ons/concepts/homepages).\nTo show your add-on's common homepage in Google Drive simply make sure there\nis a [`addOns.drive`](/apps-script/manifest/addons#AddOns.FIELDS.drive) field\nin the add-on's manifest.\n\nAlternatively, add a\n[`drive.homepageTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.homepageTrigger)\nto the add-on manifest to provide a Drive-specific homepage.\n\nIn either case, you must provide the name of a homepage trigger function in your\nadd-on's script project. This function is automatically called to build the\nDrive homepage when it is needed. You must implement this function to build and\nreturn a single\n[`Card`](/apps-script/reference/card-service/card) or an array of\n[`Card`](/apps-script/reference/card-service/card)\nobjects that make up the homepage. The homepage trigger function is passed an\n[event object](/workspace/add-ons/concepts/event-objects)\nas a parameter that contains some general information such as the client's\nplatform. You can use the event object data to tailor the construction of the\nhomepage.\n\n### Drive contextual interface for items selected\n\nGoogle Drive relies on a contextual trigger to determine what interface\n(if any) to display when the user selects one or more Google Drive items. When the\ntrigger fires, it executes the contextual trigger function specified by the\n[`drive.onItemsSelectedTrigger.runFunction`](/apps-script/manifest/drive-addons#OnItemsSelectedTrigger.FIELDS.runFunction)\nfield in the add-on [manifest](/workspace/add-ons/concepts/workspace-manifests).\n\nTo create a contextual item selection interface for Drive, you must do the\nfollowing:\n\n1. Ensure the add-on's manifest includes the\n `https://www.googleapis.com/auth/drive.addons.metadata.readonly`\n [scope](/workspace/add-ons/concepts/workspace-scopes#drive_scopes)\n\n2. Ensure the manifest includes a\n [`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger)\n section.\n\n3. Implement the function named in the\n [`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger)\n field.\n This function accepts an [event object](#event_objects) as an argument\n and must return either a single\n [`Card`](/apps-script/reference/card-service/card) object or an array of\n [`Card`](/apps-script/reference/card-service/card) objects.\n\n4. As with any card, you must implement any callback functions used to provide\n widget interactivity for the interface. For example, if you include a button\n in the interface, it should have an attached\n [Action](/apps-script/reference/card-service/action)\n and an implemented callback function that run when the button is clicked.\n\n### Event objects\n\nAn [event object](/workspace/add-ons/concepts/event-objects) is created and passed\nto the [`drive.homepageTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.homepageTrigger)\nor [`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger)\ntrigger function when those functions are called. The trigger function can use\nthe information in this event object to determine how to construct add-on cards\nor otherwise control the add-on behavior.\n\nThe full structure of event objects is described in\n[Event objects](/workspace/add-ons/concepts/event-objects).\nWhen Drive is the acting host app of the add-on, contextual event objects\ninclude the\n[Drive event object](/workspace/add-ons/concepts/event-objects#drive_event_object)\nfield that carries Drive-specific client information.\n\nContextual Drive event objects for item selection triggers include information\nabout the items the user has selected when the trigger fires. When a user\nselects more than one item in Drive, one of the items is deemed to be one of\nprimary interest; this item is referred to as the *active cursor item*.\n| **Note:** If the add-on's behavior is meant to apply to multiple selected items, use the information provided in the [`drive.selectedItems`](/workspace/add-ons/concepts/event-objects#drive_event_object) array in the event object to identify them all. \n|\n| When an add-on's behavior should only be applied to a single selected item, use the information provided in the [`drive.activeCursorItem`](/workspace/add-ons/concepts/event-objects#drive_event_object) field of the event object to identify the item out of the full selection. Don't attempt to infer which item to use from the [`drive.selectedItems`](/workspace/add-ons/concepts/event-objects#drive_event_object) array.\n\nThe following example shows a\n[Drive event object](/workspace/add-ons/concepts/event-objects#drive_event_object)\nthat is passed to a\n[`drive.onItemsSelectedTrigger`](/apps-script/manifest/drive-addons#Drive.FIELDS.onItemsSelectedTrigger)\nfunction: \n\n {\n \"commonEventObject\": { ... },\n \"drive\": {\n \"activeCursorItem\":{\n \"addonHasFileScopePermission\": true,\n \"id\":\"0B_sX1fXRRU6Ac3RhcnRlcl9maWxl\",\n \"iconUrl\": \"https://drive-thirdparty.googleusercontent.com...\",\n \"mimeType\":\"application/pdf\",\n \"title\":\"How to get started with Drive\"\n },\n \"selectedItems\": [\n {\n \"addonHasFileScopePermission\": true,\n \"id\":\"0B_sX1fXRRU6Ac3RhcnRlcl9maWxl\",\n \"iconUrl\":\"https://drive-thirdparty.googleusercontent.com...\",\n \"mimeType\":\"application/pdf\",\n \"title\":\"How to get started with Drive\"\n },\n ...\n ]\n },\n ...\n }"]]