google-slides
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Slides authoring
Google Slides 编写指南
Coordinates are POINTS from the slide's top-left; a standard slide is 720x405
(read_slide_layout reports the real size). Everything is addressed by
objectId from . Pass from the latest
read or write so a concurrent edit fails the write instead of corrupting it.
read_presentationrequiredRevisionId坐标以幻灯片左上角为原点的 POINTS(磅)为单位;标准幻灯片为 720x405( 会报告实际尺寸)。所有元素都通过 返回的 来引用。请传递最新读取或写入操作获得的 ,这样并发编辑时写入会失败,而不会损坏幻灯片。
read_slide_layoutread_presentationobjectIdrequiredRevisionIdBuilding a new deck: compose, then look
构建新演示文稿:先编排,再查看
Write each slide as a layout, not as coordinates. takes a
tree (stacks, grids, cards, text, images) or an HTML/CSS subset and lays
the whole slide out in one call: equal peer sizes, even gutters, vertical
centering, and contrast pairs hold by construction, text can , and the reply carries every element's box plus lints on the
plan. Per slide:
compose_slidefit: "shrink"- layout BLANK (or the deck's first slide with
add_slide), thenclear: truewith the SAMEcompose_slideevery time (palette roles background/surface/primary/textSecondary and the font family). Colors in the tree are roles, not hexes, so one theme change restyles a deck.theme - Read the reply's .
issuesmeans shorten,text_overflow, or give the node morefit: "shrink"; ansizemeans two nodes share a box (usually a row that needsoverlap).gap - (LARGE) once per slide and LOOK at it: crowding, dead corners, a title that reads as body text, an image fighting the palette. Fix by re-composing the slide (delete the old elements first, or compose onto a fresh BLANK slide and
get_slide_thumbnailthe old one).delete_object
Tree recipes (column root; the root box is the slide minus a 48 pt margin):
- Title slide: with a
stack column justify:centertext and andisplaysubtitle inh2, bothtextSecondary.align:center - KPI cards: , then a
h1ofstack row size:150 gap:24s, each with acardlabel (caption) over atextSecondaryvalue.kpi - Text + image: of a
stack row gap:32text (body,bullets:true) and ansize:{flex:1}(image); the image aspect-fits.size:{flex:1} - Agenda: one text with newline-separated items and
body.bullets:true
HTML form, same result: with ,
of , bullets, .
Only the documented tags and properties compile; anything else is refused
by name, never dropped.
<section style="background:#0B2A4A; padding:48pt; gap:24pt"><h1><div style="display:flex; gap:24pt; height:150pt"><article class="card"><span class="caption">…</span><span class="kpi">…</span></article><ul><li><img style="flex:1">将每张幻灯片编写为布局,而不是坐标。 接受一个树(堆栈、网格、卡片、文本、图片)或 HTML/CSS 子集,并在一次调用中完成整张幻灯片的布局:同级元素等大、间距均匀、垂直居中、对比度配对由构造保证,文本可以使用 ,响应会返回每个元素的盒子(box)以及对布局的检查(lint)。每张幻灯片:
compose_slidefit:"shrink"- 使用 添加一个 BLANK 布局(或对演示文稿的第一张幻灯片使用
add_slide),然后每次都用相同的clear: true调用theme(调色板角色:background/surface/primary/textSecondary 以及字体族)。树中的颜色是角色(role),不是十六进制值,因此一次主题更改即可为整个演示文稿重新设置样式。compose_slide - 阅读响应中的 。
issues表示需要缩短文本、使用text_overflow,或给节点更大的fit:"shrink";size表示两个节点共用一个盒子(通常是需要overlap的行)。gap - 对每张幻灯片调用一次 (LARGE)并查看:是否有拥挤、死角、标题看起来像正文、图片与配色冲突。通过重新编排幻灯片来修复(先删除旧元素,或先在一张新的 BLANK 幻灯片上编排,然后
get_slide_thumbnail删除旧的)。delete_object
树形配方(以列作为根;根盒子是幻灯片除去 48 pt 边距后的区域):
- 标题幻灯片:,包含一个
stack column justify:center文本和一个使用display颜色的textSecondary副标题,两者都h2。align:center - KPI 卡片:,然后是一个包含
h1的card,每张卡片有一个stack row size:150 gap:24标签(caption)在textSecondary值上方。kpi - 文本+图片:,包含一个
stack row gap:32文本(body,bullets:true)和一个size:{flex:1}(image);图片按宽高比适配。size:{flex:1} - 议程:一个 文本,包含换行分隔的项目并设置
body。bullets:true
HTML 形式,结果相同: 包含 、 内的 、 项目符号、。只有文档中描述的标签和属性会被编译;其他任何内容都会按名称被拒绝,而不会被静默丢弃。
<section style="background:#0B2A4A; padding:48pt; gap:24pt"><h1><div style="display:flex; gap:24pt; height:150pt"><article class="card"><span class="caption">…</span><span class="kpi">…</span></article><ul><li><img style="flex:1">Editing an existing deck: place, inspect, fix, look
编辑现有演示文稿:放置、检查、修复、查看
For decks that already have content, or elements the tree does not model:
- for any row, column, or grid of cards/text/images (one call, aligned, equal sizes);
insert_grid/insert_text_box/insert_shapefor singletons.insert_image - : every element's box, z-order, text style, estimated wrapped height (
read_slide_layout), andtextFit.fits. Fix everyissuesanderror(warn,text_overflow,overlap,off_slidewith the fill actually behind the text named) and thelow_contrastitems when cheap (info,near_miss_alignment,unequal_peers,tight_margin).empty_placeholder - once the lints are clean, and look.
get_slide_thumbnail
对于已有内容或树无法涵盖的元素:
- 对于任何行、列或卡片/文本/图片的网格,使用 (一次调用,对齐,等尺寸);对于单个元素,使用
insert_grid/insert_text_box/insert_shape。insert_image - :每个元素的盒子、z 顺序、文本样式、估算的换行高度(
read_slide_layout)以及textFit.fits。修复所有issues和error(warn、text_overflow、overlap、off_slide——会指出文本实际背后的填充色),并在代价较低时处理low_contrast项(info、near_miss_alignment、unequal_peers、tight_margin)。empty_placeholder - 检查(lint)通过后,调用 并查看。
get_slide_thumbnail
Grid conventions (when placing by hand)
网格约定(手动放置时)
Title at x 40, y 32, 640 wide, height 60-70 for one line of 28-34 pt (two
lines need ~110); subtitle under it at 16-18 pt. Content region x 40, y 130,
640 x 235 (insert_grid's default). Footer at y 370, 12 pt. Keep 40 pt side
margins unless an element is deliberately full-bleed. Process flows:
the step shapes (columns = steps), then
between neighbors; connectors follow shapes when moved.
insert_gridconnect_shapesA 34 pt bold title wraps past ~32 characters in a 600 pt box and spills over
whatever sits below (the API does not grow boxes). in the layout
read and in the compose reply predict this; long titles go to
24-28 pt, , or two lines with the subtitle pushed down.
textFitissuesfit: "shrink"标题:x 40, y 32,宽 640,高度 60-70,用于一行 28-34 pt 的文本(两行需要约 110);副标题在其下方,16-18 pt。内容区域:x 40, y 130, 640 x 235( 的默认值)。页脚:y 370,12 pt。除非元素故意出血铺满,否则保持 40 pt 的侧边距。流程:用 插入步骤形状(列 = 步骤),然后用 连接相邻形状;连接线会随形状移动。
insert_gridinsert_gridconnect_shapes34 pt 粗体标题在 600 pt 的盒子中超过约 32 个字符就会换行,并溢出到下方内容(API 不会自动扩展盒子)。布局读取中的 和编排回复中的 可以预测这一点;长标题请使用 24-28 pt、,或分两行并将副标题下移。
textFitissuesfit: "shrink"Palette and contrast
调色板与对比度
Pick a palette FIRST and reuse it on every slide (as 's
): background, one card/surface color, one accent, and a
secondary text color; on-colors derive automatically. When the user names a
template or brand, take its colors; otherwise these pairs pass WCAG AA as-is:
compose_slidetheme.palette- Dark: background #0B2A4A, cards #1E4976, accent #4FC3F7, titles/text #FFFFFF, secondary #B8CCE0.
- Light: background #FFFFFF, cards #F1F3F4, accent #0B57D0 (white text on it), text #202124, secondary #444746.
Text color never defaults sensibly on a colored fill: every text-bearing
call picks its color against the fill BEHIND the text (the card's, not the
slide's). No mid-gray on mid-anything; on white, secondary text is #444746
or darker (#5F6368 is borderline, lighter fails). For a template or brand
palette, run on every text/fill pair you intend to use
before writing (it returns a passing tint or shade for each failing pair);
in the layout read is the check afterwards.
check_contrastlow_contrastTables on colored slides render dark-on-dark from theme fills:
every cell (light fill + dark text, or accent + white)
and restyle with (cellRow/cellColumn). Prefer stat cards
over a grid of numbers on title and summary slides; a table only for
genuinely tabular data, with the header row filled in the accent and kept
to a handful of rows.
set_table_cell_fillset_text_style首先选择调色板,并在每张幻灯片上重复使用(作为 的 ):背景色、一种卡片/表面色、一种强调色和一种次要文本色;前景色自动派生。当用户指定模板或品牌时,使用其颜色;否则以下颜色对可直接通过 WCAG AA:
compose_slidetheme.palette- 深色:背景 #0B2A4A,卡片 #1E4976,强调 #4FC3F7,标题/文本 #FFFFFF,次要 #B8CCE0。
- 浅色:背景 #FFFFFF,卡片 #F1F3F4,强调 #0B57D0(其上白色文本),文本 #202124,次要 #444746。
文本颜色在彩色填充上永远不会自动合理:每个包含文本的调用都会根据文本背后的填充(是卡片的,不是幻灯片的)来选择颜色。不要在中间色调上使用中灰色;在白色上,次要文本使用 #444746 或更暗(#5F6368 处于临界,更浅则不合格)。对于模板或品牌调色板,在写入之前对打算使用的每个文本/填充对运行 (它会为每个不合格的对返回一个通过的颜色变体);布局读取中的 是之后的检查。
check_contrastlow_contrast彩色幻灯片上的表格会因主题填充而呈现深色上加深色:用 设置每个单元格(浅色填充 + 深色文本,或强调色 + 白色),并用 (cellRow/cellColumn)重新设置样式。在标题和摘要幻灯片上,优先使用统计卡片而不是数字网格;表格仅用于真正需要表格化的数据,标题行使用强调色填充,并保持少量行数。
set_table_cell_fillset_text_styleSlides and repetition
幻灯片与重复
- starts with one blank slide (delete its placeholders, or fill them with
create_presentation); it cannot target a folder, so move it after with google-driveset_shape_text.google_drive_move_or_rename - with a predefined layout fills title/body placeholders in the same call (fastest theme-consistent slide);
add_slidereorders.move_slide - Repeated layouts (one template, N variants): build the first slide
fully, then per variant on the slide id (the copy lands right after) and
duplicate_objectscoped byreplace_textto the copy; distinct placeholders like {{TITLE}} keep the replaces unambiguous.pageObjectIds - REPLACES a shape's or cell's whole text (cell = {rowIndex, columnIndex});
set_shape_textrestyles all of one shape or cell, not a range.set_text_stylemoves but does not resize: delete and re-create at the right size instead.update_element_position - Speaker notes: with pageObjectId = the slide's notesPageId and objectId = speakerNotesObjectId from
set_shape_text.read_presentation - Whole-deck render: google-drive (pdf).
google_drive_export_file
- 会先创建一张空白幻灯片(删除其占位符,或用
create_presentation填充它们);它不能指定文件夹,因此之后用 google-drive 的set_shape_text移动它。google_drive_move_or_rename - 使用预定义布局的 会在同一次调用中填充标题/正文占位符(最快的主题一致幻灯片);
add_slide用于重新排序。move_slide - 重复布局(一个模板,N 个变体):先完整构建第一张幻灯片,然后对每个变体,在幻灯片 id 上使用 (副本紧随其后),并使用
duplicate_object限定范围的pageObjectIds只替换副本中的文本;使用 {{TITLE}} 这样的独特占位符可以确保替换无歧义。replace_text - 会替换形状或单元格的整个文本(单元格 = {rowIndex, columnIndex});
set_shape_text重新设置整个形状或单元格的样式,而不是一个范围。set_text_style移动但不会调整大小:应删除并在正确大小下重新创建。update_element_position - 演讲者备注:,其中 pageObjectId = 幻灯片的 notesPageId,objectId =
set_shape_text中的 speakerNotesObjectId。read_presentation - 整个演示文稿渲染:google-drive 的 (pdf)。
google_drive_export_file