一种显示文本并支持基本 HTML 格式的小部件。
适用于 Google Workspace 插件和 Google Chat 应用。
const textParagraph = CardService.newTextParagraph().setText( 'This is a text paragraph widget. Multiple lines are allowed if needed.', );
方法
| 方法 | 返回类型 | 简介 |
|---|---|---|
add | Widget | 添加可在 widget 上执行的事件操作。 |
set | Widget | 设置用于标识要发生变异的 widget 的唯一 ID。 |
set | Text | 设置 widget 中显示的最大文本行数。 |
set | Text | 设置段落的文本。 |
set | Widget | 设置 widget 的可见性。 |
详细文档
add Event Action(eventAction)
set Id(id)
设置用于标识要发生变异的 widget 的唯一 ID。只有在插件中支持 widget 突变。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
id | String | 微件的 ID,最多可包含 64 个字符,格式为 `[a-zA-Z0-9-]+`。 |
返回
Widget - 此对象,用于链式调用。
set Max Lines(maxLines)
设置 widget 中显示的最大文本行数。如果文本超过指定的最大行数,多余的内容会隐藏在“显示更多”按钮后面。如果文本的行数等于或少于指定的最大行数,则不会显示“显示更多”按钮。
适用于 Google Chat 应用。在 Google Workspace 加购项的开发者预览版中。
const textParagraph = CardService.newTextParagraph() .setText( 'This is a text paragraph widget. Multiple lines are allowed if needed.', ) .setMaxLines(1);
参数
| 名称 | 类型 | 说明 |
|---|---|---|
max | Integer | 显示的最大文本行数。 |
返回
Text - 此对象,用于链式调用。