Class TextParagraph
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ข้อความย่อหน้า
วิดเจ็ตที่แสดงข้อความและรองรับการจัดรูปแบบ HTML พื้นฐาน
พร้อมใช้งานสำหรับส่วนเสริมของ Google Workspace และแอป Google Chat
const textParagraph = CardService.newTextParagraph().setText(
'This is a text paragraph widget. Multiple lines are allowed if needed.',
);
เอกสารประกอบโดยละเอียด
setMaxLines(maxLines)
กำหนดจำนวนบรรทัดข้อความสูงสุดที่จะแสดงในวิดเจ็ต หากข้อความมีบรรทัดเกินจำนวนสูงสุดที่ระบุไว้ ระบบจะซ่อนเนื้อหาส่วนเกินไว้หลังปุ่ม "แสดงเพิ่มเติม" หากข้อความมีความยาวเท่ากับหรือสั้นกว่าจำนวนบรรทัดสูงสุดที่ระบุ ปุ่ม "แสดงเพิ่มเติม" จะไม่แสดง
พร้อมใช้งานสำหรับแอป Google Chat อยู่ในเวอร์ชันตัวอย่างสำหรับนักพัฒนาซอฟต์แวร์สำหรับส่วนเสริมของ Google Workspace
const textParagraph =
CardService.newTextParagraph()
.setText(
'This is a text paragraph widget. Multiple lines are allowed if needed.',
)
.setMaxLines(1);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
maxLines | Integer | จำนวนบรรทัดข้อความสูงสุดที่แสดง |
รีเทิร์น
TextParagraph
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setText(text)
ตั้งค่าข้อความของย่อหน้า ต้องระบุ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
text | String | ข้อความที่จะแสดง |
รีเทิร์น
TextParagraph
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eTextParagraph\u003c/code\u003e widget displays text with basic HTML formatting support.\u003c/p\u003e\n"],["\u003cp\u003eIt is usable in Google Workspace Add-ons and Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can set the displayed text using the \u003ccode\u003esetText()\u003c/code\u003e method and can chain additional methods for further customization.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetText()\u003c/code\u003e method requires a string argument representing the desired text content.\u003c/p\u003e\n"]]],["The `TextParagraph` widget displays text with basic HTML formatting in Google Workspace add-ons and Google Chat apps. Key actions include `setText(text)` to define the displayed text and `setMaxLines(maxLines)` to limit the visible lines; exceeding this limit adds a \"show more\" button. `setMaxLines` is in developer preview for Google Workspace and available for Google Chat, whereas `setText` is fully available. Both methods return the `TextParagraph` object to enable method chaining.\n"],null,["# Class TextParagraph\n\nTextParagraph\n\nA widget that displays text and supports [basic HTML formatting](/gmail/add-ons/concepts/widgets#text_formatting).\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst textParagraph = CardService.newTextParagraph().setText(\n 'This is a text paragraph widget. Multiple lines are allowed if needed.',\n);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------|--------------------|----------------------------------------------------------------------------|\n| [setMaxLines(maxLines)](#setMaxLines(Integer)) | [TextParagraph](#) | Sets the maximum number of lines of text that are displayed in the widget. |\n| [setText(text)](#setText(String)) | [TextParagraph](#) | Sets the text of the paragraph. |\n\nDetailed documentation\n----------------------\n\n### `set``Max``Lines(maxLines)`\n\nSets the maximum number of lines of text that are displayed in the widget. If the text exceeds\nthe specified maximum number of lines, the excess content is concealed behind a \"show more\"\nbutton. If the text is equal or shorter than the specified maximum number of lines, a \"show\nmore\" button isn't displayed.\n\nAvailable for Google Chat apps. In developer preview for Google Workspace add-ons.\n\n\n| **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.\n\n\u003cbr /\u003e\n\n```javascript\nconst textParagraph =\n CardService.newTextParagraph()\n .setText(\n 'This is a text paragraph widget. Multiple lines are allowed if needed.',\n )\n .setMaxLines(1);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|-----------|---------------------------------------------------------|\n| `max``Lines` | `Integer` | The maximum number of lines of text that are displayed. |\n\n#### Return\n\n\n[TextParagraph](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Text(text)`\n\nSets the text of the paragraph. Required.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|----------------------|\n| `text` | `String` | The text to display. |\n\n#### Return\n\n\n[TextParagraph](#) --- This object, for chaining."]]