Generated
Vendored
+171
-6
@@ -7,6 +7,22 @@ API docs: `api/API_DOCS.md`
|
||||
`Presentation` is the in-memory API object. A deck is the exported presentation
|
||||
file. A slide is one page in the deck.
|
||||
|
||||
## Text formatting
|
||||
|
||||
Assign formatting to `shape.text.style`, or edit properties on `shape.text`:
|
||||
|
||||
```ts
|
||||
shape.text.style = { fontSize: 24, color: "#123456", bold: true };
|
||||
shape.text.fontSize = 28;
|
||||
shape.text.color = "#2563eb";
|
||||
```
|
||||
|
||||
Reading `shape.text.style` returns a style name or `undefined`. Use
|
||||
`shape.text.fontSize` and `shape.text.color` to read or edit formatting.
|
||||
Assign a config to `shape.text.style` to change several fields at once. See
|
||||
[rich text](api/references/rich-text.spec.md#shape-text-style) for accepted fields
|
||||
and types.
|
||||
|
||||
## Imports
|
||||
|
||||
```ts
|
||||
@@ -36,6 +52,7 @@ async function main(): Promise<void> {
|
||||
const slide = presentation.slides.add();
|
||||
slide.background.fill = "slate-50";
|
||||
|
||||
// Every coordinate has a field name: left, top, width, and height.
|
||||
const page = { left: 72, top: 64, width: 1136, height: 592 };
|
||||
const gutter = 28;
|
||||
const leftCol = 430;
|
||||
@@ -130,6 +147,156 @@ Inspect every final slide at full size before delivery. After repairs, refresh
|
||||
the affected slide previews, including slides affected by inherited changes.
|
||||
Add the [optional inspection exports](#optional-inspection-exports) when needed.
|
||||
|
||||
Every line config requires `style`, including invisible lines such as
|
||||
`{ style: "solid", fill: "none", width: 0 }`. Check the installed runtime's
|
||||
docs for accepted fields before adapting a config from another library.
|
||||
|
||||
## Session callbacks
|
||||
|
||||
Edit the document through the callback's `presentation`. Declare helpers and
|
||||
slide variables inside the callback. Use a loop, helper, or separate block for
|
||||
each slide to reuse names such as `title` without redeclaring them in one scope.
|
||||
|
||||
Spaces' `inspect_artifact` and `execute_artifact_code` take a `code` string
|
||||
containing one complete async function expression:
|
||||
`(async ({ presentation }) => { ... })`. End it at the closing `}`. Omit a
|
||||
trailing statement semicolon, imports, TypeScript types, and JSX. Include the
|
||||
helpers and data needed by this call. Caller variables and declarations from
|
||||
previous callbacks are outside its scope.
|
||||
|
||||
Pass style options to helpers as objects with named fields. For example,
|
||||
`{ fontSize: 28, typeface: "Georgia", color: "#123456", bold: true }`
|
||||
avoids passing a font name as the size or a boolean as the color. See
|
||||
[text styles](api/references/rich-text.spec.md#shape-text-style).
|
||||
|
||||
When building the string in JavaScript, serialize data with `JSON.stringify`:
|
||||
|
||||
```js
|
||||
const labels = ["Cost: $5", "First line\nSecond line", "A quoted \"label\""];
|
||||
const code = `async ({ presentation }) => {
|
||||
const labels = ${JSON.stringify(labels)};
|
||||
for (const label of labels) {
|
||||
const slide = presentation.slides.add();
|
||||
const title = slide.shapes.add({
|
||||
geometry: "textbox",
|
||||
position: { left: 72, top: 64, width: 720, height: 96 },
|
||||
fill: "none",
|
||||
line: { style: "solid", fill: "none", width: 0 },
|
||||
});
|
||||
title.text = label;
|
||||
title.text.style = { fontSize: 28, color: "#123456" };
|
||||
}
|
||||
return { slides: presentation.slides.count };
|
||||
}`;
|
||||
// Pass code as the tool's code argument.
|
||||
```
|
||||
|
||||
Use `JSON.stringify` for values containing quotes, backslashes, dollar signs,
|
||||
or newlines. Use `String.raw` to preserve escape sequences in literal callback
|
||||
source. Put slide code in separate functions or blocks. Splitting source with
|
||||
a regex can break JavaScript syntax. When replacing source text, use
|
||||
`source.replace(marker, () => replacement)` so `$&`, `$'`, and other replacement
|
||||
tokens stay literal.
|
||||
|
||||
When Node is available, compile the assembled string before submitting it:
|
||||
|
||||
```js
|
||||
import { Script } from "node:vm";
|
||||
|
||||
new Script("(\n" + code + "\n)"); // Compile only, without running the callback.
|
||||
```
|
||||
|
||||
The local `artifactSession.run(async ({ presentation }) => { ... }, options)`
|
||||
API takes a JavaScript function and can use variables from the same Node REPL.
|
||||
Spaces takes the function as a string. Keep document reads and edits inside
|
||||
the current callback for both APIs.
|
||||
|
||||
In Spaces, use the callback's `presentation` and `session`. The worker records
|
||||
the edit and initializes CRDT state.
|
||||
|
||||
```js
|
||||
async ({ presentation, session }) => {
|
||||
const slides = await presentation.inspect({
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "title"],
|
||||
});
|
||||
return { sessionId: session.sessionId, slides: slides.records };
|
||||
}
|
||||
```
|
||||
|
||||
`presentation.session` requires an attached local controller. Read `session`
|
||||
from the callback parameter and leave controller and replica setup to the worker.
|
||||
|
||||
### Things to look out for
|
||||
|
||||
- Give elements explicit names such as `"headline"`. Names generated with
|
||||
`text.slice(0,32)` can differ from a later manually shortened lookup.
|
||||
- Inspect current names or canonical IDs before an edit. Editing text can
|
||||
leave the element's name unchanged.
|
||||
- Serialize callback values with `JSON.stringify` to preserve quotes,
|
||||
backslashes, dollar signs, and newlines.
|
||||
- For literal text such as `"Cost: $5"`, use a JSONPath equality filter.
|
||||
Legacy `search` interprets regex characters, including `$`.
|
||||
- Check that a lookup selects the intended element. For zero or multiple
|
||||
matches, inspect current names and text before editing.
|
||||
- Use current inspect IDs for `resolve`/`delete`, raw layout IDs or exact
|
||||
layout names for slide creation, and current zero-based indexes for previews.
|
||||
|
||||
```js
|
||||
const text = "Cost: $5";
|
||||
await presentation.inspect({
|
||||
select: "$.slides[*].elements[?(@.text == " + JSON.stringify(text) + ")]",
|
||||
include: ["id", "name", "text"],
|
||||
});
|
||||
```
|
||||
|
||||
### Image sources in Spaces callbacks
|
||||
|
||||
For a remote Page edit, pass a selected Page or library image reference as
|
||||
`path`. Local filesystem paths and embedded `blob` examples apply to local
|
||||
authoring. The worker needs authorization or an upload through the Page owner
|
||||
before it can render or commit a new source.
|
||||
|
||||
Use the source input field `path` when replacing an image reference:
|
||||
|
||||
```js
|
||||
async ({ presentation }) => {
|
||||
const image = presentation.resolve("im/c3d4e5f6"); // ID from current inspect.
|
||||
image.replace({ path: "library-file:new-image-reference" });
|
||||
}
|
||||
```
|
||||
|
||||
An inspected `asset.uri` identifies the current source. Passing `uri` to
|
||||
`replace` can leave that source unchanged. If the next tool call authorizes
|
||||
only the new reference, hydration fails for the old source still in the deck.
|
||||
|
||||
Before previewing, inspect the current image sources. Set `hydrate_images: true`
|
||||
and include each source needed by the preview in `image_references`. A montage
|
||||
needs sources for the whole deck. A preview of selected slides needs their
|
||||
sources. Each reference must resolve to accessible image bytes. See
|
||||
[image replacement](api/references/images.spec.md#replace-source).
|
||||
|
||||
To replace a selected image and preview it, pass these tool arguments:
|
||||
|
||||
```js
|
||||
const args = {
|
||||
page_id: pageId,
|
||||
idempotency_key: "replace-selected-image-01",
|
||||
hydrate_images: true,
|
||||
image_references: ["library-file:selected-image-reference"],
|
||||
code: String.raw`async ({ presentation }) => {
|
||||
const image = presentation.resolve("im/c3d4e5f6");
|
||||
image.replace({ path: "library-file:selected-image-reference" });
|
||||
await presentation.render({ slide: 0 });
|
||||
}`,
|
||||
};
|
||||
// Pass args to execute_artifact_code.
|
||||
```
|
||||
|
||||
Use the current `pageId`, inspected image ID, and selected reference. This
|
||||
example assumes slide zero needs only this source. Add any other sources on
|
||||
that slide to `image_references`.
|
||||
|
||||
## JSX Compose Equivalent
|
||||
|
||||
Use JSX when the slide is naturally rows, columns, grids, or overlays.
|
||||
@@ -195,9 +362,8 @@ const presentation = await PresentationFile.importPptx(
|
||||
);
|
||||
|
||||
const before = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart,notes,thread,layout",
|
||||
search: "Revenue",
|
||||
maxChars: 8000,
|
||||
select: "$.slides[*].elements[?(search(@.text, 'Revenue'))]",
|
||||
include: ["id", "kind", "text", "position"],
|
||||
});
|
||||
console.log(before.ndjson);
|
||||
|
||||
@@ -216,9 +382,8 @@ await writeBlob(
|
||||
);
|
||||
|
||||
const after = await presentation.inspect({
|
||||
target: { id: anchorIdFromInspect, beforeLines: 2, afterLines: 2 },
|
||||
kind: "textbox,shape,image,table,chart",
|
||||
maxChars: 3000,
|
||||
select: "$.slides[*].elements[?(@.id == " + JSON.stringify(anchorIdFromInspect) + ")]",
|
||||
include: ["id", "kind", "text", "position"],
|
||||
});
|
||||
console.log(after.ndjson);
|
||||
|
||||
|
||||
Generated
Vendored
+11
-12
@@ -12,6 +12,7 @@ Use the presentation facades to create PowerPoint-style decks in TypeScript.
|
||||
- **Config-first authoring**: pass config objects into create/add APIs and grouped setters when the API provides them.
|
||||
- **String values**: options such as geometry, fit, alignment, chart type, line style, and connector kind are strings; reference pages list exact small unions and grep targets for huge catalogs.
|
||||
- **Inline docs types**: reference pages include illustrative `type ... = { ... }` blocks. Treat them as schema-shaped authoring guidance, not imports.
|
||||
- Inspect with `presentation.inspect({ select, include, fileName })`. Filter kinds inside JSONPath `select` and pass an array of fields for `include`. See [legacy exceptions](./references/inspect.md#legacy-compatibility).
|
||||
- **Authoring surfaces**: `slide.compose(...)` covers rows, columns, grids, layers, and token strings. Config-first facade APIs cover exact positions, fixed chrome, native charts/tables/images, and imported deck edits.
|
||||
|
||||
## Common Routes
|
||||
@@ -58,8 +59,8 @@ const previewBlob = await presentation.export({
|
||||
const deckPdfBlob = await presentation.export({ format: "pdf" });
|
||||
const slidePdfBlob = await presentation.export({ slide, format: "pdf" });
|
||||
const snapshot = await presentation.inspect({
|
||||
kind: "slide,textbox,shape",
|
||||
maxChars: 4000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.kind", "elements.text"],
|
||||
});
|
||||
const help = presentation.help("*", {
|
||||
search: "chart axis labels",
|
||||
@@ -106,9 +107,8 @@ Load serialized presentation data with `Presentation.load(proto)`:
|
||||
const presentation = Presentation.load(proto);
|
||||
|
||||
const before = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart,notes,thread,layout",
|
||||
search: "Revenue",
|
||||
maxChars: 8000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.text"],
|
||||
});
|
||||
|
||||
const slide = presentation.resolve(slideAnchorIdFromInspect);
|
||||
@@ -128,9 +128,8 @@ const previewAfter = await presentation.export({
|
||||
scale: 1,
|
||||
});
|
||||
const after = await presentation.inspect({
|
||||
target: { id: anchorIdFromInspect, beforeLines: 2, afterLines: 2 },
|
||||
kind: "textbox,shape,image,table,chart",
|
||||
maxChars: 3000,
|
||||
select: "$.slides[*].elements[?(@.id == " + JSON.stringify(anchorIdFromInspect) + ")]",
|
||||
include: ["id", "text", "position"],
|
||||
});
|
||||
const nextProto = presentation.toProto();
|
||||
```
|
||||
@@ -171,7 +170,7 @@ tags default `width` to `"fill"` when you omit it.
|
||||
- Use `slide.compose(nodeOrJsx, { frame, baseUnit })` for compose-first layouts. JSX lowers into the same compose runtime as the helper-based API.
|
||||
- Author content with config-first calls: `slide.shapes.add({ geometry, position, fill, line })`, `slide.images.add({ ... })`, `slide.tables.add({ ... })`, and `slide.charts.add(chartType, { ... })`.
|
||||
- Format whole-shape text with grouped configs such as `shape.text.style = { fontSize, bold, color, alignment }`.
|
||||
- Edit imported decks with `presentation.inspect({ kind, search, maxChars })`, `presentation.resolve(anchorId)`, and focused facade edits.
|
||||
- Edit imported decks with `presentation.inspect({ select, include })`, `presentation.resolve(anchorId)`, and focused facade edits.
|
||||
- Export previews with `presentation.export({ slide, format, scale })`.
|
||||
- Export all slides as one PDF with `presentation.export({ format: "pdf" })`.
|
||||
- Export deck montages for overview review with `presentation.export({ format: "webp", montage: true })`.
|
||||
@@ -193,7 +192,7 @@ tags default `width` to `"fill"` when you omit it.
|
||||
| Editable PPTX | `presentation.export({ format: "pptx" })` | Editable presentation `Blob` |
|
||||
| Deck montage | `presentation.export({ format: "webp", montage: true, scale })` | One overview image containing the deck slides |
|
||||
| Layout JSON | `slide.export({ format: "layout" })` | Structural JSON with bounds, ids, text, names, and object metadata |
|
||||
| Searchable snapshot | `presentation.inspect({ kind, search, maxChars })` | NDJSON records for locating and resolving objects |
|
||||
| Searchable snapshot | `presentation.inspect({ select, include, fileName })` | NDJSON records for locating and resolving objects |
|
||||
| Runtime handoff | `presentation.toProto()` | Serializable presentation data for host adapters |
|
||||
|
||||
## Minimal Patterns
|
||||
@@ -208,8 +207,8 @@ const presentation = Presentation.create({
|
||||
const slide = presentation.slides.add();
|
||||
const preview = await presentation.export({ slide, format: "png", scale: 1 });
|
||||
const snapshot = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,chart,table",
|
||||
maxChars: 4000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.kind", "elements.text"],
|
||||
});
|
||||
const proto = presentation.toProto();
|
||||
```
|
||||
|
||||
Generated
Vendored
+104
-3
@@ -11,7 +11,9 @@ chart.yAxis = { numberFormatCode: "$#,##0M" };
|
||||
chart.series.getItemAt(0).values = [3.1, 3.7, 4.2, 4.8];
|
||||
```
|
||||
|
||||
Use `presentation.inspect({ kind: "chart", search })` to find the `ch/...`
|
||||
Use `presentation.inspect({ select, include })` with
|
||||
`select: "$.slides[*].elements[?(@.kind == 'chart')]"` and
|
||||
`include: ["id", "title"]` to find the `ch/...`
|
||||
anchor id. If an imported chart resolves as an image, preserve it as an image or
|
||||
rebuild it as a native chart intentionally.
|
||||
|
||||
@@ -24,6 +26,7 @@ const chart = slide.charts.add(chartType, {
|
||||
titleTextStyle,
|
||||
categories,
|
||||
series,
|
||||
groups,
|
||||
hasLegend,
|
||||
legend,
|
||||
barOptions,
|
||||
@@ -42,6 +45,8 @@ const chart = slide.charts.add(chartType, {
|
||||
bubbleOptions,
|
||||
xAxis,
|
||||
yAxis,
|
||||
secondaryXAxis,
|
||||
secondaryYAxis,
|
||||
dataLabels,
|
||||
dataTable,
|
||||
chartFill,
|
||||
@@ -53,6 +58,18 @@ const chart = slide.charts.add(chartType, {
|
||||
|
||||
Small chart option enums are listed below.
|
||||
|
||||
Chart `chartLine`, `plotAreaLine`, series `line`, axis `line`, and gridlines
|
||||
use [LineConfig](./fill.spec.md#line-inline-type). Include `style` even when
|
||||
hiding a border:
|
||||
|
||||
```ts
|
||||
chart.chartLine = { style: "solid", fill: "none", width: 0 };
|
||||
chart.yAxis = {
|
||||
textStyle: { typeface: "Arial", fontSize: 14, fill: "#475569" },
|
||||
majorGridlines: { style: "solid", fill: "#e2e8f0", width: 1 },
|
||||
};
|
||||
```
|
||||
|
||||
## Chart Inline Types
|
||||
|
||||
```ts
|
||||
@@ -70,6 +87,7 @@ type ChartConfig = {
|
||||
titleTextStyle?: ChartTextStyleConfig;
|
||||
categories?: string[];
|
||||
series?: ChartSeriesConfig[];
|
||||
groups?: ChartGroupConfig[];
|
||||
hasLegend?: boolean;
|
||||
legend?: ChartLegendConfig;
|
||||
barOptions?: { direction?: "bar" | "column"; grouping?: "clustered" | "stacked" | "percentStacked"; varyColors?: boolean; gapWidth?: number; gapDepth?: number; overlap?: number; bar3dShape?: number };
|
||||
@@ -88,6 +106,8 @@ type ChartConfig = {
|
||||
bubbleOptions?: { scale?: number | null; sizeRepresents?: "area" | "width" | null; showNegative?: boolean | null };
|
||||
xAxis?: ChartAxisConfig;
|
||||
yAxis?: ChartAxisConfig;
|
||||
secondaryXAxis?: ChartAxisConfig;
|
||||
secondaryYAxis?: ChartAxisConfig;
|
||||
dataLabels?: ChartDataLabelsConfig;
|
||||
dataTable?: ChartDataTableConfig;
|
||||
chartFill?: FillConfig;
|
||||
@@ -101,6 +121,68 @@ type ChartConfig = {
|
||||
|
||||
## Chart Family Options
|
||||
|
||||
### Combo Charts
|
||||
|
||||
```ts
|
||||
const chart = slide.charts.add("combo", {
|
||||
categories,
|
||||
groups: [
|
||||
{
|
||||
type: "bar",
|
||||
barOptions: { grouping: "clustered", gapWidth: 150 },
|
||||
series: [{ name: firstSeriesName, values: firstValues, fill: firstColor }],
|
||||
},
|
||||
{
|
||||
type: "line",
|
||||
axis: "secondary",
|
||||
lineOptions: { smooth: false },
|
||||
series: [{ name: secondSeriesName, values: secondValues, line: { style: "solid", fill: secondColor, width: 2 } }],
|
||||
},
|
||||
],
|
||||
yAxis: { min: 0, max: primaryMaximum },
|
||||
secondaryYAxis: { min: 0, max: secondaryMaximum, numberFormatCode: "0%" },
|
||||
});
|
||||
|
||||
chart.secondaryYAxis = { max: updatedMaximum };
|
||||
const group = chart.groups.getItemAt(1);
|
||||
group.series.getItemAt(0).values = updatedValues;
|
||||
group.lineOptions.smooth = false;
|
||||
group.dataLabels.showValue = true;
|
||||
group.axis = "primary";
|
||||
group.type = "area";
|
||||
group.areaOptions.grouping = "stacked";
|
||||
|
||||
const series = group.series.add(addedSeriesName);
|
||||
series.values = addedValues;
|
||||
group.series.deleteAt(seriesIndex);
|
||||
chart.groups.add({ type: "line", series: [{ name: addedSeriesName, values: addedValues }] });
|
||||
chart.groups.deleteAt(groupIndex);
|
||||
const groupConfigs = chart.groups.toConfig();
|
||||
chart.groups = replacementGroups;
|
||||
|
||||
type ChartGroupConfig = {
|
||||
id?: string;
|
||||
axis?: "primary" | "secondary";
|
||||
series: ChartSeriesConfig[];
|
||||
dataLabels?: ChartDataLabelsConfig;
|
||||
} & (
|
||||
| { type: "bar"; barOptions?: { direction?: "column"; grouping?: "clustered" | "stacked" | "percentStacked"; gapWidth?: number; overlap?: number; varyColors?: boolean } }
|
||||
| { type: "line"; lineOptions?: { grouping?: "standard" | "stacked" | "percentStacked"; smooth?: boolean; varyColors?: boolean } }
|
||||
| { type: "area"; areaOptions?: { grouping?: "standard" | "stacked" | "percentStacked"; varyColors?: boolean } }
|
||||
);
|
||||
```
|
||||
|
||||
`toConfig()` includes group and series IDs. Keep these IDs when editing or
|
||||
reordering configurations; omit them when adding new groups or series. Group IDs
|
||||
and series IDs must each be unique within a chart.
|
||||
|
||||
Combo charts use `groups` to supply series. Include at least one primary-axis
|
||||
group. Each group has its own chart family and stacking options; groups sharing
|
||||
an axis share its scale. `chart.groups.items` contains the editable groups;
|
||||
`chart.groups.length` gives their count. `chart.series` exposes the same series
|
||||
in group order. Secondary groups create a right value axis and a hidden category
|
||||
axis, styled with `secondaryYAxis` and `secondaryXAxis`.
|
||||
|
||||
```ts
|
||||
histogram.histogramOptions = { binWidth: 5 };
|
||||
histogram.histogramOptions = { binCount: 8, underflow: 0, overflow: 30 };
|
||||
@@ -173,8 +255,16 @@ const chart = slide.charts.add(chartType, {
|
||||
|
||||
## Series Inline Type
|
||||
|
||||
Use `chart.series.getItemAt(index)` for a series and
|
||||
`presentation.slides.getItem(index)` for a slide.
|
||||
|
||||
`marker.size` is a diameter in points. If supplied, it must be an integer from
|
||||
2 through 72, even when `symbol` is `"none"`. To hide a marker, use
|
||||
`marker: { symbol: "none" }` and omit `size`. `size: 0` is rejected.
|
||||
|
||||
```ts
|
||||
type ChartSeriesConfig = {
|
||||
id?: string;
|
||||
name: string;
|
||||
categories?: string[];
|
||||
values?: Array<number | null>;
|
||||
@@ -189,7 +279,7 @@ type ChartSeriesConfig = {
|
||||
line?: LineConfig;
|
||||
stroke?: LineConfig;
|
||||
// Scatter outline color defaults to the marker's solid fill; explicit stroke fills take precedence.
|
||||
marker?: { symbol?: "circle" | "diamond" | "dot" | "none" | "plus" | "square" | "star" | "triangle" | "x"; size?: number; fill?: FillConfig };
|
||||
marker?: { symbol?: "circle" | "diamond" | "dot" | "none" | "plus" | "square" | "star" | "triangle" | "x"; size?: number; fill?: FillConfig; line?: LineConfig };
|
||||
points?: Array<{ idx: number; fill?: FillConfig; line?: LineConfig; stroke?: LineConfig }>;
|
||||
dataLabels?: ChartDataLabelsConfig;
|
||||
dataLabelOverrides?: Array<{ idx: number; text?: string; separator?: string; position?: string; fill?: FillConfig; line?: LineConfig; stroke?: LineConfig; showValue?: boolean; showSeriesName?: boolean; showCategoryName?: boolean; showPercent?: boolean; textStyle?: ChartTextStyleConfig }>;
|
||||
@@ -239,8 +329,14 @@ const chart = slide.charts.add(chartType, {
|
||||
|
||||
```ts
|
||||
type ChartTextStyleConfig = {
|
||||
fontSize?: number;
|
||||
typeface?: string;
|
||||
fontSize?: number | string; // Numeric pixels or a unit string such as "14pt".
|
||||
fontSizePt?: number;
|
||||
rotation?: number;
|
||||
name?: string;
|
||||
family?: number;
|
||||
fill?: FillConfig;
|
||||
color?: ColorConfig;
|
||||
bold?: boolean;
|
||||
italic?: boolean;
|
||||
underline?: string;
|
||||
@@ -292,6 +388,11 @@ type ChartAxisConfig = {
|
||||
};
|
||||
```
|
||||
|
||||
Set chart fonts with `textStyle.typeface`, as in
|
||||
`{ typeface: "Arial", fontSize: 14 }`. `ChartTextStyleConfig` does not accept
|
||||
`fontFamily`. Use a string for `typeface` and booleans for `bold` and `italic`
|
||||
in axis, legend, title, and data-label configs.
|
||||
|
||||
## Cookbook
|
||||
|
||||
```ts
|
||||
|
||||
Generated
Vendored
+1
@@ -95,6 +95,7 @@ const thread = presentation.resolve(threadAnchorId);
|
||||
thread.addReply("Updated the chart title and source note.", { author: self });
|
||||
thread.resolve(self);
|
||||
|
||||
// Legacy exception: comment threads are absent from the JSONPath tree.
|
||||
const verified = await presentation.inspect({
|
||||
kind: "thread",
|
||||
target: { id: threadAnchorId, beforeLines: 0, afterLines: 2 },
|
||||
|
||||
Generated
Vendored
+3
-1
@@ -175,7 +175,9 @@ connector.line = { style: "solid", fill: "slate-800", width: 2 };
|
||||
connector.bringToFront();
|
||||
```
|
||||
|
||||
Use `presentation.inspect({ kind: "shape", search })` to find connector anchor
|
||||
Use `presentation.inspect({ select, include })` with
|
||||
`select: "$.slides[*].elements[?(@.kind == 'shape')]"` and
|
||||
`include: ["id", "name", "geometry"]` to find connector anchor
|
||||
ids. Connector facades expose `connector`, `connectorLineStyle`,
|
||||
`connectorHead`, and `connectorTail` for readback.
|
||||
|
||||
|
||||
Generated
Vendored
+28
-23
@@ -17,12 +17,11 @@ const presentation = await Presentation.load("input.pptx");
|
||||
|
||||
```ts
|
||||
const before = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart,notes,thread,layout",
|
||||
search: "Revenue",
|
||||
maxChars: 8000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.name", "elements.text"],
|
||||
});
|
||||
|
||||
// Pick an exact anchor id from `before`; use inspect ids instead of slide indexes.
|
||||
// Pick an exact elements.id from `before` for the edit target.
|
||||
const target = presentation.resolve(anchorId);
|
||||
|
||||
// slideAnchorId is the `sl/...` id from inspect for the affected slide.
|
||||
@@ -46,9 +45,8 @@ const montageAfter = await presentation.export({
|
||||
});
|
||||
|
||||
const after = await presentation.inspect({
|
||||
target: { id: anchorId, beforeLines: 2, afterLines: 2 },
|
||||
kind: "textbox,shape",
|
||||
maxChars: 2000,
|
||||
select: "$.slides[*].elements[?(@.id == " + JSON.stringify(anchorId) + ")]",
|
||||
include: ["id", "name", "text", "position"],
|
||||
});
|
||||
```
|
||||
|
||||
@@ -56,9 +54,8 @@ const after = await presentation.inspect({
|
||||
|
||||
```ts
|
||||
const layoutSnapshot = await presentation.inspect({
|
||||
kind: "slide,layout,textbox,shape",
|
||||
search: "Click to add title",
|
||||
maxChars: 6000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "layout", "elements.id", "elements.text", "elements.isPlaceholder"],
|
||||
});
|
||||
|
||||
// slideAnchorId is the `sl/...` id from inspect for this slide.
|
||||
@@ -69,17 +66,17 @@ title.text = "Updated executive summary";
|
||||
|
||||
Edit a slide placeholder for a local content change. Edit a layout or master
|
||||
only when the intended change is global.
|
||||
Inspect records use 1-based `slide` numbers for display; `slides.getItem(index)`
|
||||
is 0-based. Prefer resolving the `sl/...` anchor from inspect.
|
||||
JSONPath slide records expose a zero-based `index`, matching
|
||||
`slides.getItem(index)`. Prefer resolving the `sl/...` anchor from inspect
|
||||
when identifying a slide across edits.
|
||||
|
||||
## Master/Layout Blast Radius
|
||||
|
||||
```ts
|
||||
// layoutId comes from inspect/layout export metadata; use it for search and comparison.
|
||||
const affected = await presentation.inspect({
|
||||
kind: "slide,layout",
|
||||
search: layoutId,
|
||||
maxChars: 6000,
|
||||
select: "$.slides[?(@.layout.id == " + JSON.stringify(layoutId) + ")]",
|
||||
include: ["id", "index", "layout"],
|
||||
});
|
||||
```
|
||||
|
||||
@@ -139,9 +136,8 @@ chart.yAxis = { numberFormatCode: "$#,##0M" };
|
||||
chart.series.getItemAt(0).values = [3.1, 3.7, 4.2, 4.8];
|
||||
|
||||
await presentation.inspect({
|
||||
kind: "table,chart",
|
||||
target: { id: chartAnchorId, beforeLines: 3, afterLines: 3 },
|
||||
maxChars: 3000,
|
||||
select: "$.slides[*].elements[?(@.id == " + JSON.stringify(chartAnchorId) + ")]",
|
||||
include: ["id", "title", "chartType", "position"],
|
||||
});
|
||||
```
|
||||
|
||||
@@ -152,9 +148,14 @@ rebuild it as a native chart/table intentionally.
|
||||
|
||||
```ts
|
||||
const review = await presentation.inspect({
|
||||
kind: "thread,notes,slide,textbox",
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "notes", "elements.id", "elements.text"],
|
||||
});
|
||||
// Legacy exception: comment threads are absent from the JSONPath tree.
|
||||
const threads = await presentation.inspect({
|
||||
kind: "thread",
|
||||
search: "TODO",
|
||||
maxChars: 8000,
|
||||
maxChars: 4000,
|
||||
});
|
||||
|
||||
const self = presentation.comments.setSelf({
|
||||
@@ -177,9 +178,13 @@ notes.text = [
|
||||
notes.setVisible(true);
|
||||
|
||||
const verified = await presentation.inspect({
|
||||
kind: "thread,notes",
|
||||
target: { id: slideAnchorId, beforeLines: 1, afterLines: 4 },
|
||||
maxChars: 3000,
|
||||
select: "$.slides[?(@.id == " + JSON.stringify(slideAnchorId) + ")]",
|
||||
include: ["id", "notes"],
|
||||
});
|
||||
const verifiedThread = await presentation.inspect({
|
||||
kind: "thread",
|
||||
target: { id: commentThreadAnchorId },
|
||||
maxChars: 2000,
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -410,8 +410,8 @@ Inspect the layout tree when spans or wrapping matter:
|
||||
const layout = await slide.export({ format: "layout" });
|
||||
const png = await slide.export({ format: "png", scale: 1 });
|
||||
const snapshot = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart",
|
||||
maxChars: 8000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.name", "elements.position", "elements.text"],
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Generated
Vendored
+7
@@ -135,6 +135,13 @@ dottedDiamond, plaid, sphere, weave, divot, shingle, wave, trellis, zigZag
|
||||
|
||||
## Line
|
||||
|
||||
Every `LineConfig` requires `style`, including chart borders, gridlines, and
|
||||
invisible outlines. Use
|
||||
`{ style: "solid", fill: "#e2e8f0", width: 1 }` for a visible line and
|
||||
`{ style: "solid", fill: "none", width: 0 }` for an invisible one.
|
||||
Set the fill with `fill` and pixel width with `width`. `LineConfig` does not
|
||||
accept CSS fields such as `borderColor` and `borderWidth`.
|
||||
|
||||
```ts
|
||||
const lineConfig = {
|
||||
style: lineStyle,
|
||||
|
||||
Generated
Vendored
+6
-8
@@ -157,8 +157,8 @@ shape.text = "Launch plan";
|
||||
|
||||
// Inspect the live deck after editing.
|
||||
const snapshot = await presentation.inspect({
|
||||
kind: "slide,textbox,shape",
|
||||
maxChars: 4000,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "elements.id", "elements.name", "elements.text"],
|
||||
});
|
||||
```
|
||||
|
||||
@@ -209,15 +209,13 @@ const help = presentation.help("shape.text.replace", {
|
||||
include: ["examples", "notes"],
|
||||
});
|
||||
const before = await presentation.inspect({
|
||||
kind: "textbox,shape",
|
||||
search: "Placeholder",
|
||||
maxChars: 4000,
|
||||
select: "$.slides[*].elements[?(search(@.text, 'Placeholder'))]",
|
||||
include: ["id", "text"],
|
||||
});
|
||||
const target = presentation.resolve(anchorId);
|
||||
target.text.replace("Placeholder", "Updated text");
|
||||
const after = await presentation.inspect({
|
||||
target: { id: anchorId, beforeLines: 2, afterLines: 2 },
|
||||
kind: "textbox,shape",
|
||||
maxChars: 2000,
|
||||
select: "$.slides[*].elements[?(@.id == " + JSON.stringify(anchorId) + ")]",
|
||||
include: ["id", "text"],
|
||||
});
|
||||
```
|
||||
|
||||
Generated
Vendored
+13
-1
@@ -96,7 +96,9 @@ image.flipVertical = oldFlipVertical;
|
||||
image.lockAspectRatio = oldLockAspectRatio;
|
||||
```
|
||||
|
||||
Use `presentation.inspect({ kind: "image", search })` to find the `im/...`
|
||||
Use `presentation.inspect({ select, include })` with
|
||||
`select: "$.slides[*].elements[?(@.kind == 'image')]"` and
|
||||
`include: ["id", "alt", "asset"]` to find the `im/...`
|
||||
anchor id. Preserve frame, crop, fit, alt text, mask geometry, and border radius
|
||||
unless the edit explicitly changes them.
|
||||
Concrete source replacements produce concrete images; pass `prompt` when it
|
||||
@@ -147,6 +149,16 @@ image.replace({
|
||||
field as with `add`. Preserve or set placement, crop, mask geometry, and border
|
||||
radius on the image facade itself.
|
||||
|
||||
For a source reference, pass `path`:
|
||||
|
||||
```ts
|
||||
image.replace({ path: nextImagePath, alt: "Updated product screenshot" });
|
||||
```
|
||||
|
||||
Inspection returns the current image source in `asset.uri`. Pass a replacement
|
||||
reference as `path`. `image.replace({ uri: nextImagePath })` can leave the old
|
||||
source unchanged. Inspect the source again before rendering it.
|
||||
|
||||
## Replace And Regenerate Inline Types
|
||||
|
||||
```ts
|
||||
|
||||
Generated
Vendored
+31
-2
@@ -4,6 +4,14 @@
|
||||
presentation tree with [RFC 9535 JSONPath](https://www.rfc-editor.org/rfc/rfc9535.html).
|
||||
The [JSON Schema](./inspect.schema.json) describes its content and layout fields.
|
||||
`select` finds nodes; `include` chooses exact fields from those nodes.
|
||||
Use this form for new queries and when updating queries for slides, elements,
|
||||
layouts, or speaker notes. Filter by element kind inside `select`, as in
|
||||
`$.slides[*].elements[?(@.kind == 'chart')]`.
|
||||
|
||||
Queries with `select` accept only `select`, `include`, and `fileName`.
|
||||
Deprecated options such as `kind`, `search`, `target`, and `maxChars` cannot be
|
||||
mixed into them. Use an array for `include`. The legacy overloads expect a
|
||||
string and can fail with `t.split is not a function` if passed an array.
|
||||
|
||||
## Read content
|
||||
|
||||
@@ -45,6 +53,12 @@ Only canonical prefix/hash IDs are exposed. Pass editable `sl/`, `sh/`, `im/`,
|
||||
The read-only `ly/` ID identifies the applied layout. `index` is zero-based;
|
||||
positions and computed font sizes use pixels.
|
||||
|
||||
Copy the complete IDs returned by inspection. Prefixing a raw facade ID or
|
||||
imported relationship path does not create an inspect ID. To create a slide
|
||||
from an inspected layout, pass its exact `layout.name` as `layout`.
|
||||
`layoutId` expects the layout facade's raw ID. See
|
||||
[Presentation](./presentation.spec.md#presentation-slide-collection).
|
||||
|
||||
## Find and edit
|
||||
|
||||
```ts
|
||||
@@ -62,6 +76,10 @@ for example, `$.slides[*].title` returns title strings.
|
||||
|
||||
Use `search(@.text, 'overview|steps')` for a text pattern, or `match()` to match
|
||||
the entire string. Patterns follow [I-Regexp](https://www.rfc-editor.org/rfc/rfc9485.html).
|
||||
Use `==` for literal text containing dollar signs, backslashes, or other regex
|
||||
characters. The deprecated `search` option treats the text as a JavaScript
|
||||
regex, where `$` marks the end of the string.
|
||||
|
||||
`length()` measures a value, `count()` counts selected nodes, and `value()`
|
||||
extracts a value when a query selects exactly one node. Filters use `==` and
|
||||
`!=`; JavaScript expressions and method calls are not part of JSONPath.
|
||||
@@ -127,5 +145,16 @@ type PresentationInspectQueryResult = {
|
||||
};
|
||||
```
|
||||
|
||||
The earlier preset and record-filter overloads remain deprecated compatibility
|
||||
entry points. New callers should use the explicit query above.
|
||||
## Legacy compatibility
|
||||
|
||||
Use `select` for new queries. The earlier `kind` and record-filter overloads
|
||||
are deprecated.
|
||||
|
||||
Keep a legacy call only when an integration needs its old record format, the
|
||||
installed runtime lacks `select`, or the query targets comment threads.
|
||||
The current JSONPath tree includes slides, elements, layouts, and notes.
|
||||
Comment threads still require the legacy queries in [Comments](./comments.md).
|
||||
|
||||
With `select`, use an array for `include` and omit `kind`, `search`,
|
||||
`target`, `limit`, `offset`, and `maxChars`. Legacy overloads use a
|
||||
string for `include`. Convert the whole query when switching between forms.
|
||||
|
||||
Generated
Vendored
+41
-6
@@ -24,10 +24,32 @@ slide.setLayout(layout);
|
||||
## Master Inline Types
|
||||
|
||||
```ts
|
||||
type ColorMapConfig = Partial<Record<
|
||||
"bg1" | "tx1" | "bg2" | "tx2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hlink" | "folHlink",
|
||||
"bg1" | "tx1" | "bg2" | "tx2" | "accent1" | "accent2" | "accent3" | "accent4" | "accent5" | "accent6" | "hlink" | "folHlink"
|
||||
>>;
|
||||
type ColorMapConfig = Record<
|
||||
| "bg1"
|
||||
| "tx1"
|
||||
| "bg2"
|
||||
| "tx2"
|
||||
| "accent1"
|
||||
| "accent2"
|
||||
| "accent3"
|
||||
| "accent4"
|
||||
| "accent5"
|
||||
| "accent6"
|
||||
| "hlink"
|
||||
| "folHlink",
|
||||
| "lt1"
|
||||
| "dk1"
|
||||
| "lt2"
|
||||
| "dk2"
|
||||
| "accent1"
|
||||
| "accent2"
|
||||
| "accent3"
|
||||
| "accent4"
|
||||
| "accent5"
|
||||
| "accent6"
|
||||
| "hlink"
|
||||
| "folHlink"
|
||||
>;
|
||||
```
|
||||
|
||||
## Resolve
|
||||
@@ -41,8 +63,21 @@ const resolved = presentation.layouts.getById(master.id);
|
||||
```ts
|
||||
// Shared brand master with inherited layout.
|
||||
const master = presentation.masters.add("Brand Master");
|
||||
master.setColorMap({ bg1: "bg1", tx1: "tx1", accent1: "accent1" });
|
||||
master.background.ref = "bg1";
|
||||
master.setColorMap({
|
||||
bg1: "lt1",
|
||||
tx1: "dk1",
|
||||
bg2: "lt2",
|
||||
tx2: "dk2",
|
||||
accent1: "accent1",
|
||||
accent2: "accent2",
|
||||
accent3: "accent3",
|
||||
accent4: "accent4",
|
||||
accent5: "accent5",
|
||||
accent6: "accent6",
|
||||
hlink: "hlink",
|
||||
folHlink: "folHlink",
|
||||
});
|
||||
master.background.ref = { index: 1001, schemeColor: "bg1" };
|
||||
|
||||
const layout = presentation.layouts.add("Brand Title");
|
||||
layout.setParentLayoutId(master.id);
|
||||
|
||||
Generated
Vendored
+74
-9
@@ -26,6 +26,43 @@ presentation.slides.keep([0, 2, 4]);
|
||||
presentation.slides.reorder(orderedSlideIds);
|
||||
```
|
||||
|
||||
Slide indexes start at zero and must be less than
|
||||
`presentation.slides.items.length`. After an edit completes, read the current
|
||||
slide list before selecting or rendering a slide. If creation fails or its
|
||||
outcome is unknown, inspect the saved document to see which slides exist.
|
||||
|
||||
Use `presentation.slides.getItem(0)` for a slide and
|
||||
`chart.series.getItemAt(0)` for a chart series.
|
||||
`presentation.slides.getItemAt` is not a method.
|
||||
|
||||
```ts
|
||||
const firstSlide = presentation.slides.getItem(0);
|
||||
const firstSeries = chart.series.getItemAt(0);
|
||||
```
|
||||
|
||||
`layout` expects an existing layout's exact name, including case.
|
||||
`layoutId` expects the layout facade's raw `.id`, as in
|
||||
`presentation.slides.add({ layoutId: layout.id })`. Inspection returns a
|
||||
read-only `ly/...` ID that cannot be passed as `layoutId`. To reuse an
|
||||
inspected layout, pass its exact `name` as `layout`.
|
||||
|
||||
```ts
|
||||
// "Title and image" must be an existing layout's exact name.
|
||||
const layout = presentation.layouts.getItem("Title and image");
|
||||
const slideByRawId = presentation.slides.add({ layoutId: layout.id });
|
||||
const slideByName = presentation.slides.add({ layout: layout.name });
|
||||
```
|
||||
|
||||
After an edit completes, select from the saved document's current slide list:
|
||||
|
||||
```ts
|
||||
const slideCount = presentation.slides.items.length;
|
||||
if (slideCount > 0) {
|
||||
const lastSlide = presentation.slides.getItem(slideCount - 1);
|
||||
await presentation.render({ slide: lastSlide });
|
||||
}
|
||||
```
|
||||
|
||||
`keep` accepts an array of zero-based indexes or an array of canonical `sl/` IDs.
|
||||
It validates the selection against the current slide list, then preserves the
|
||||
selected slides in their existing relative order. Repeated selections are ignored;
|
||||
@@ -61,10 +98,8 @@ interface Presentation {
|
||||
|
||||
```ts
|
||||
const snapshot = await presentation.inspect({
|
||||
kind,
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
select: "$.slides[*].elements[*]",
|
||||
include: ["id", "kind", "text"],
|
||||
});
|
||||
|
||||
const target = presentation.resolve(anchorId);
|
||||
@@ -80,6 +115,37 @@ and the presentation itself are not delete targets.
|
||||
|
||||
`inspect` returns stable anchor ids for slides, shapes, images, tables, charts, text ranges, speaker notes, and comment threads. `resolve` maps one anchor id to its facade, or an array of ids to facades in the same order. Layout records expose canonical `ly/...` IDs with `editable: false` for search and comparison; pass only `pr/`, `sl/`, `sh/`, `im/`, `tb/`, `ch/`, `nt/`, `th/`, and `tr/` anchors to `resolve`.
|
||||
|
||||
Copy the complete canonical ID from the current inspect or rendered layout
|
||||
result. Adding `sh/`, `ch/`, or another prefix to a facade's raw `.id` does not
|
||||
create an inspect ID. After deleting, replacing, or rebuilding an element,
|
||||
inspect again before resolving it. Give elements explicit names for later
|
||||
lookups. Names made from truncated text can differ from a later lookup string.
|
||||
|
||||
```js
|
||||
// "headline" is an explicit authored name, not a slice of its text.
|
||||
const headings = await presentation.inspect({
|
||||
select: "$.slides[*].elements[?(@.name == 'headline')]",
|
||||
include: ["id", "name", "text"],
|
||||
});
|
||||
if (headings.recordCount !== 1) {
|
||||
throw new Error("Expected one headline. Inspect current element names before editing.");
|
||||
}
|
||||
const headingId = headings.records[0].id;
|
||||
presentation.resolve(headingId).text = "Updated headline";
|
||||
```
|
||||
|
||||
```js
|
||||
// Delete only the currently inspected obsolete captions.
|
||||
const obsolete = await presentation.inspect({
|
||||
select: "$.slides[*].elements[?(@.name == 'obsolete-caption')]",
|
||||
include: ["id"],
|
||||
});
|
||||
const obsoleteIds = obsolete.records.map(record => record.id);
|
||||
if (obsoleteIds.length > 0) {
|
||||
presentation.delete(obsoleteIds);
|
||||
}
|
||||
```
|
||||
|
||||
## Inspect
|
||||
|
||||
Use `presentation.inspect({ select, include, fileName })` with JSONPath over the
|
||||
@@ -275,17 +341,16 @@ await presentation.render({
|
||||
scale: 1,
|
||||
});
|
||||
const snapshot = await presentation.inspect({
|
||||
kind: "deck,slide,textbox,chart,table",
|
||||
limit: 20,
|
||||
select: "$.slides[*]",
|
||||
include: ["id", "index", "title", "elements.id", "elements.kind", "elements.text"],
|
||||
});
|
||||
```
|
||||
|
||||
```ts
|
||||
// Existing deck: inspect first, then resolve exact anchors.
|
||||
const before = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart,notes,thread,layout",
|
||||
search: "Customer growth",
|
||||
limit: 20,
|
||||
select: "$.slides[*].elements[?(search(@.text, 'Customer growth'))]",
|
||||
include: ["id", "name", "text"],
|
||||
});
|
||||
const target = presentation.resolve(anchorIdFromBefore);
|
||||
```
|
||||
|
||||
Generated
Vendored
+21
@@ -143,6 +143,27 @@ shape.text.wrap = wrapMode;
|
||||
shape.text.insets = 0; // Set all four sides; use an object for individual sides.
|
||||
```
|
||||
|
||||
Assign a config to `shape.text.style` to set formatting. Reading it returns a
|
||||
style name or `undefined`. Read or edit `shape.text.fontSize` and
|
||||
`shape.text.color` directly. `shape.text.style.fontSize` and
|
||||
`shape.text.style.color` do not read formatting fields.
|
||||
|
||||
Use named fields in text helpers to keep font names, sizes, colors, and
|
||||
booleans in the right places:
|
||||
|
||||
```ts
|
||||
const headingStyle = {
|
||||
typeface: "Georgia", // Font family is a string.
|
||||
fontSize: 28, // Shape font size is numeric pixels.
|
||||
color: "#123456", // Color is a ColorConfig, not a boolean.
|
||||
bold: true,
|
||||
};
|
||||
shape.text.style = headingStyle;
|
||||
```
|
||||
|
||||
Pass this config as an object. Swapping positional values can pass a font name
|
||||
as `fontSize` or a boolean as `color`.
|
||||
|
||||
`shape.text.color` uses `ColorConfig`. `shape.text.fill`, run `style.fill`,
|
||||
and text ranges accept the shared `FillConfig`, including linear and path
|
||||
gradients. `shape.text.outline`, run `style.outline`, and text ranges accept
|
||||
|
||||
Generated
Vendored
+3
-1
@@ -38,7 +38,9 @@ shape.borderRadius = "rounded-2xl";
|
||||
shape.shadow = "shadow-sm";
|
||||
```
|
||||
|
||||
Use `presentation.inspect({ kind: "shape,textbox", search })` to find the
|
||||
Use `presentation.inspect({ select, include })` with
|
||||
`select: "$.slides[*].elements[?(@.kind == 'shape' || @.kind == 'textbox')]"`
|
||||
and `include: ["id", "name", "text"]` to find the
|
||||
`sh/...` anchor id. Keep the resolved facade type-aware; do not rebuild an
|
||||
imported shape unless the task requires a new object.
|
||||
|
||||
|
||||
Generated
Vendored
+2
-3
@@ -165,9 +165,8 @@ slide.speakerNotes.setVisible(visible);
|
||||
const preview = await slide.export({ format: "png", scale: 2 });
|
||||
const layout = await slide.export({ format: "layout" });
|
||||
const after = await presentation.inspect({
|
||||
kind: "slide,textbox,shape,image,table,chart,notes",
|
||||
target: { id: slideAnchorId, beforeLines: 2, afterLines: 8 },
|
||||
maxChars: 4000,
|
||||
select: "$.slides[?(@.id == " + JSON.stringify(slideAnchorId) + ")]",
|
||||
include: ["id", "index", "elements.id", "elements.name", "elements.text", "notes.text"],
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Generated
Vendored
+8
-1
@@ -11,7 +11,9 @@ table.getCell(1, 2).text.style = "Body Small";
|
||||
table.borders.assign({ style: "solid", fill: "slate-200", width: 1 });
|
||||
```
|
||||
|
||||
Use `presentation.inspect({ kind: "table", search })` to find the `tb/...`
|
||||
Use `presentation.inspect({ select, include })` with
|
||||
`select: "$.slides[*].elements[?(@.kind == 'table')]"` and
|
||||
`include: ["id", "text"]` to find the `tb/...`
|
||||
anchor id. If an imported table resolves as an image, preserve it as an image or
|
||||
rebuild it as a native table intentionally.
|
||||
|
||||
@@ -32,6 +34,11 @@ const table = slide.tables.add({
|
||||
|
||||
Primitive matrices and structured text runs are accepted for `values`. Use `columnTracks` with `fr(...)` and `fixed(...)` when a table should fill its frame with proportional columns. Use `columnWidths` only for explicit pixel widths.
|
||||
|
||||
Use `columnWidths: [240, 445, 505]` for numeric pixel widths, or
|
||||
`columnTracks: [fixed(240), fixed(445), fixed(505)]` for fixed tracks.
|
||||
Each track is an object with `mode` and `value`. Passing numbers as
|
||||
`columnTracks: [240, 445, 505]` is rejected.
|
||||
|
||||
## Table Inline Types
|
||||
|
||||
```ts
|
||||
|
||||
Reference in New Issue
Block a user