Card
בהמשך מופיעה דוגמה לכרטיס של תוספים.
function createCard() { return CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('CardTitle')) .build(); }
אפשר גם להחזיר כמה כרטיסים, כך:
function createCards() { return [ CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), ]; }
בדוגמה הבאה מוצג איך אפשר להגדיר כרטיס עם כותרת, טקסט, תמונה ופריט בתפריט:
function createWidgetDemoCard() { return CardService.newCardBuilder() .setHeader( CardService.newCardHeader() .setTitle('Widget demonstration') .setSubtitle('Check out these widgets') .setImageStyle(CardService.ImageStyle.SQUARE) .setImageUrl('https://www.example.com/images/headerImage.png'), ) .addSection( CardService.newCardSection() .setHeader('Simple widgets') // optional .addWidget( CardService.newTextParagraph().setText( 'These widgets are display-only. ' + 'A text paragraph can have multiple lines and ' + 'formatting.', ), ) .addWidget( CardService.newImage().setImageUrl( 'https://www.example.com/images/mapsImage.png', ), ), ) .addCardAction( CardService.newCardAction().setText('Gmail').setOpenLink( CardService.newOpenLink().setUrl('https://mail.google.com/mail'), ), ) .build(); }
דוגמה לכרטיס של אפליקציות ל-Chat.
const cardHeader = CardService.newCardHeader() .setTitle('Sasha') .setSubtitle('Software Engineer') .setImageUrl( 'https://developers.google.com/chat/images/quickstart-app-avatar.png', ) .setImageStyle(CardService.ImageStyle.CIRCLE) .setImageAltText('Avatar for Sasha'); const cardSection = CardService.newCardSection() .setHeader('Contact Info') .setCollapsible(true) .setNumUncollapsibleWidgets(1) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.EMAIL)) .setText('sasha@example.com'), ) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.PERSON)) .setText('<font color="#80e27e">Online</font>'), ) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.PHONE)) .setText('+1 (555) 555-1234'), ) .addWidget( CardService.newButtonSet() .addButton( CardService.newTextButton().setText('Share').setOpenLink( CardService.newOpenLink().setUrl( 'https://example.com/share'), ), ) .addButton( CardService.newTextButton() .setText('Edit') .setOnClickAction( CardService.newAction() .setFunctionName('goToView') .setParameters({viewType: 'EDIT'}), ), ), ); const card = CardService.newCardBuilder() .setHeader(cardHeader) .addSection(cardSection) .build();
מאפיינים
Methods
תיעוד מפורט
new Action Response Builder()
new Action Status()
יוצר Action חדש.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const actionStatus = CardService.newActionStatus() .setStatusCode(CardService.Status.OK) .setUserFacingMessage('Success');
חזרה
Action – ActionStatus ריק.
new Attachment()
new Authorization Action()
new Authorization Exception()
new Border Style()
new Calendar Event Action Response Builder()
new Card Action()
new Card Builder()
new Card Header()
new Card Section()
new Card With Id()
יוצר Card חדש. הפרמטר הזה משמש לשליחת כרטיס בהודעה ב-Google Chat. מזהה הכרטיס הוא מזהה ייחודי של כרטיס בהודעה כששולחים כמה כרטיסים.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newTextParagraph().setText('This is a text paragraph widget.'), ); const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .addSection(cardSection) .build(); const cardWithId = CardService.newCardWithId().setCardId('card_id').setCard(card);
חזרה
Card — Card ריק.
new Carousel()
יוצר Carousel.
const carousel = CardService.newCarousel() .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The first text paragraph in carousel'))) .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The second text paragraph in carousel'))) .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The third text paragraph in carousel')))
חזרה
Carousel – קרוסלה ריקה.
new Carousel Card()
יוצר Carousel חדש.
const carouselCard = CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('Text paragraph in carousel'));
חזרה
Carousel – צ'יפ ריק.
new Chat Action Response()
יוצר Chat חדש.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); const dialog = CardService.newDialog().setBody(card); const dialogAction = CardService.newDialogAction().setDialog(dialog); const chatActionResponse = CardService.newChatActionResponse() .setResponseType(CardService.ResponseType.DIALOG) .setDialogAction(dialogAction);
חזרה
Chat — Chat ריק.
new Chat Response Builder()
יוצר Chat חדש.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newTextParagraph().setText('This is a text paragraph widget.'), ); const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .addSection(cardSection) .build(); const cardWithId = CardService.newCardWithId().setCardId('card_id').setCard(card); const chatResponse = CardService.newChatResponseBuilder().addCardsV2(cardWithId).build();
חזרה
Chat — ChatResponseBuilder ריק.
new Chip()
new Chip List()
יוצר Chip חדש.
זמין באפליקציות שפועלות עם Google Chat. בתצוגה מקדימה למפתחים של תוספים ל-Google Workspace.
const chip = CardService.newChip(); // Finish building the text chip... const chipList = CardService.newChipList() .setLayout(CardService.ChipListLayout.WRAPPED) .addChip(chip);
חזרה
Chip — ChipList ריק.
new Collapse Control()
יוצר Collapse חדש.
זמין באפליקציות שפועלות עם Google Chat. בתצוגה מקדימה למפתחים של תוספים ל-Google Workspace.
const collapseControl = CardService.newCollapseControl() .setHorizontalAlign(CardService.HorizontalAlignment.START) .setExpandButton(CardService.newTextButton().setText('Expand')) .setCollapseButton(CardService.newTextButton().setText('Collapse'));
חזרה
Collapse — רכיב CollapseControl ריק.
new Column()
יוצר Column חדש.
זמין לאפליקציות של Google Chat ולתוספים ל-Google Workspace.
const columnWidget = CardService.newTextParagraph(); const column = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER) .addWidget(columnWidget);
חזרה
Column – עמודה ריקה.
new Columns()
יוצר קבוצה חדשה של Columns.
זמין לאפליקציות של Google Chat ולתוספים ל-Google Workspace.
const firstColumn = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER); const secondColumn = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER); const columns = CardService.newColumns() .addColumn(firstColumn) .addColumn(secondColumn) .setWrapStyle(CardService.WrapStyle.WRAP);
חזרה
Columns – קבוצה ריקה של עמודות.
new Compose Action Response Builder()
יוצר Compose חדש.
חזרה
Compose — בונה של ComposeActionResponse ריק.
new Date Picker()
new Date Time Picker()
new Decorated Text()
new Dialog()
יוצר Dialog חדש.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); // Sets the card of the dialog. const dialog = CardService.newDialog().setBody(card);
חזרה
new Dialog Action()
יוצר Dialog חדש.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); const dialog = CardService.newDialog().setBody(card); const dialogAction = CardService.newDialogAction().setDialog(dialog);
חזרה
Dialog — Dialog ריק.
new Divider()
יוצר Divider חדש. בדוגמה הבאה מוצג כרטיס פשוט עם 2 פסקאות
שמופרדות על ידי קו.
function buildCard() { const cardSection1TextParagraph1 = CardService.newTextParagraph().setText('Hello world!'); const cardSection1Divider1 = CardService.newDivider(); const cardSection1TextParagraph2 = CardService.newTextParagraph().setText('Hello world!'); const cardSection1 = CardService.newCardSection() .addWidget(cardSection1TextParagraph1) .addWidget(cardSection1Divider1) .addWidget(cardSection1TextParagraph2); const card = CardService.newCardBuilder().addSection(cardSection1).build(); return card; }
חזרה
Divider — קו מפריד.
new Drive Items Selected Action Response Builder()
new Editor File Scope Action Response Builder()
new Host App Data Source()
new Image Button()
new Image Component()
new Image Crop Style()
new Link Preview()
יוצר Link חדש.
const decoratedText = CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!'); const cardSection = CardService.newCardSection().addWidget(decoratedText); const card = CardService.newCardBuilder().addSection(cardSection).build(); const linkPreview = CardService.newLinkPreview().setPreviewCard(card).setTitle( 'Smart chip title');
חזרה
Link – תצוגה מקדימה ריקה של קישור.
new Material Icon()
יוצר Material חדש.
זמין לאפליקציות של Google Chat ולתוספים ל-Google Workspace.
const materialIcon = CardService.newMaterialIcon().setName('check_box').setFill(true); const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newDecoratedText() .setStartIcon(CardService.newIconImage().setMaterialIcon(materialIcon)) .setText('sasha@example.com'), ); const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card Title')) .addSection(cardSection) .build();
חזרה
Material — MaterialIcon ריק.
new Notification()
new Overflow Menu()
יוצר Overflow חדש.
זמין באפליקציות שפועלות עם Google Chat. בתצוגה מקדימה למפתחים של תוספים ל-Google Workspace.
const overflowMenuItem = CardService.newOverflowMenuItem(); // Finish building the overflow menu item... const overflowMenu = CardService.newOverflowMenu().addMenuItem(overflowMenuItem);
חזרה
Overflow – רכיב OverflowMenu ריק.
new Overflow Menu Item()
יוצר Overflow חדש.
זמין באפליקציות שפועלות עם Google Chat. בתצוגה מקדימה למפתחים של תוספים ל-Google Workspace.
const overflowMenuItem = CardService.newOverflowMenuItem() .setStartIcon( CardService.newIconImage().setIconUrl( 'https://www.google.com/images/branding/googleg/1x/googleg_standard_color_64dp.png', ), ) .setText('Open Link') .setOpenLink( CardService.newOpenLink().setUrl('https://www.google.com'));
חזרה
Overflow – פריט ריק בתפריט האפשרויות הנוספות.
new Selection Input()
new Suggestions()
new Suggestions Response Builder()
יוצר Suggestions חדש.
חזרה
Suggestions — An empty SuggestionsResponse builder.
new Text Button()
new Text Paragraph()
new Time Picker()
new Universal Action Response Builder()
יוצר Universal חדש.
חזרה
Universal — builder ריק של UniversalActionResponse.
new Update Draft Action Response Builder()
יוצר Update חדש.
חזרה
Update — UpdateDraftActionResponseBuilder ריק.
new Update Draft Bcc Recipients Action()
יוצר Update חדש.
חזרה
Update — פעולה ריקה של UpdateDraftBccRecipientsAction.
new Update Draft Body Action()
new Update Draft Cc Recipients Action()
יוצר Update חדש.
חזרה
Update — An Empty UpdateDraftCcRecipientsAction.
new Update Draft Subject Action()
יוצר Update חדש.
חזרה
Update — פעולה ריקה של UpdateDraftSubjectAction.
new Update Draft To Recipients Action()
יוצר Update חדש.
חזרה
Update – פעולה ריקה של UpdateDraftToRecipientsAction.
new Validation()
יוצר Validation חדש.
זמין לאפליקציות של Google Chat ולתוספים ל-Google Workspace.
const validation = CardService.newValidation().setCharacterLimit(5).setInputType( CardService.InputType.EMAIL);
חזרה
Validation — אימות ריק.