API 參考
Text
放置可編輯的標題、內文、標示或數字文字圖層。
presentation.tsx
<Text id="headline" role="title" x={8} y={8} w={70} h={14} color="#171717" fontFamily="Arial" fontSize={42} fontWeight={700} lineHeight={1.1}>
清楚的標題
</Text>屬性參考
屬性值應保持字面且可序列化,才能由 Canvas、Inspector、驗證與匯出流程可靠處理。
| API | 屬性 | 型別/值 | 必要 | 說明 |
|---|---|---|---|---|
| 所有原生圖層共用 props | id | string | 是 | 穩定且唯一的圖層識別字。每個可見的原生圖層都必須提供。 |
| x | number | 是 | 相對於投影片畫布左側的位置百分比。 | |
| y | number | 是 | 相對於投影片畫布頂端的位置百分比。 | |
| w | number | 是 | 圖層寬度,單位為畫布百分比。 | |
| h | number | 是 | 圖層高度,單位為畫布百分比。 | |
| groupId | string | — | 在不加入 wrapper 元素的情況下,將原生子圖層編組。 | |
| groupName | string | — | 在 Workbench 顯示的群組名稱。 | |
| sharedId | string | — | 連接相鄰 Morph 投影片中的同型圖層;在同一張投影片內必須唯一。 | |
| rotation | number | — | 順時針旋轉角度。 | |
| opacity | number | — | 圖層不透明度,範圍為 0 到 1。 | |
| motion | JSON string | — | 版本化的宣告式動作序列 JSON 字串;仍須保留完整的靜態最終畫面。 | |
| interaction | JSON string | — | 版本化的點擊互動 JSON 字串,可用於投影片導覽或連結。 | |
| Text | children | ReactNode | 是 | 圖層中的文字內容。 |
| role | "title" | string | — | 主要投影片標題請使用 title。 | |
| fontFamily | string | — | 字型名稱。 | |
| fontSize | number | — | Slide 設定 fontSizeUnit="pt" 時的字級(point)。 | |
| fontWeight | number | string | — | 字重,例如 400 或 700。 | |
| fontStyle | "italic" | — | 斜體文字樣式。 | |
| color | color string | — | 文字顏色。 | |
| background | color string | — | 文字框背景顏色。 | |
| radius | number | — | 文字框圓角半徑。 | |
| lineHeight | number | — | 行高倍率。 | |
| letterSpacing | number | — | 字距,單位為 point。 | |
| textAlign | left | center | right | — | 文字水平對齊。 | |
| textVerticalAlign | top | middle | bottom | — | 文字在框內的垂直對齊。 | |
| listType | bullet | ordered | — | 選用的清單格式。 | |
| listStart | number | — | 有序清單的起始編號。 |
必要語法
Text 以 children 作為內容,並需要 id、x、y、w、h;一頁的主要標題使用 role="title"。
常用樣式
color、fontFamily、fontSize、fontWeight、lineHeight、letterSpacing 與 textAlign 都使用固定值。若 Slide 設定 fontSizeUnit="pt",fontSize 單位就是 point。