Skip to content

Commit f34200c

Browse files
ElizabethSamuel-MSFTgithub-actions
andauthored
Automatically generated docs (#2269)
Co-authored-by: github-actions <[email protected]>
1 parent e1f13cf commit f34200c

File tree

62 files changed

+7505
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7505
-211
lines changed

docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.binding.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ remarks: >-
99
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
1010
\]
1111
12+
13+
#### Examples
14+
15+
16+
```TypeScript
17+
18+
// Link to full sample:
19+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
20+
21+
22+
async function getShapeForBindingId(bindingId: string):
23+
Promise<PowerPoint.Shape | undefined> {
24+
// Gets shape associated with binding ID.
25+
return PowerPoint.run(async (context) => {
26+
const binding = context.presentation.bindings.getItem(bindingId);
27+
const shape = binding.getShape();
28+
return shape;
29+
});
30+
}
31+
32+
```
33+
1234
isPreview: false
1335
isDeprecated: false
1436
type: class
@@ -90,6 +112,28 @@ methods:
90112
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
91113
\]
92114
115+
116+
#### Examples
117+
118+
119+
```TypeScript
120+
121+
// Link to full sample:
122+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
123+
124+
125+
async function getShapeForBindingId(bindingId: string):
126+
Promise<PowerPoint.Shape | undefined> {
127+
// Gets shape associated with binding ID.
128+
return PowerPoint.run(async (context) => {
129+
const binding = context.presentation.bindings.getItem(bindingId);
130+
const shape = binding.getShape();
131+
return shape;
132+
});
133+
}
134+
135+
```
136+
93137
isPreview: false
94138
isDeprecated: false
95139
syntax:

docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.bindingcollection.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,47 @@ remarks: >-
1111
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
1212
\]
1313
14+
15+
#### Examples
16+
17+
18+
```TypeScript
19+
20+
// Link to full sample:
21+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
22+
23+
24+
// Loads bindings.
25+
26+
await PowerPoint.run(async (context) => {
27+
const bindings = context.presentation.bindings;
28+
bindings.load("items");
29+
await context.sync();
30+
31+
const bindingCount = bindings.items.length;
32+
if (bindingCount === 0) {
33+
console.log(`There are no bindings.`);
34+
} else if (bindingCount === 1) {
35+
console.log("There's 1 binding.");
36+
} else {
37+
console.log(`There are ${bindingCount} bindings.`);
38+
}
39+
40+
bindings.items.forEach((binding) => {
41+
getShapeForBindingId(binding.id).then((shape) => {
42+
if (shape) {
43+
console.log(`Binding ID: ${binding.id} refers to shape ID ${shape.id}`);
44+
} else {
45+
console.log(`Binding ID: ${binding.id} doesn't refers to shape.`);
46+
}
47+
});
48+
});
49+
50+
populateBindingsDropdown(bindings.items);
51+
});
52+
53+
```
54+
1455
isPreview: false
1556
isDeprecated: false
1657
type: class
@@ -56,6 +97,49 @@ methods:
5697
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
5798
\]
5899
100+
101+
#### Examples
102+
103+
104+
```TypeScript
105+
106+
// Link to full sample:
107+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
108+
109+
110+
// Inserts an image with binding.
111+
112+
await PowerPoint.run(async (context) => {
113+
const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value;
114+
const slide = context.presentation.getSelectedSlides().getItemAt(0);
115+
const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, {
116+
top: 100,
117+
left: 30,
118+
width: 200,
119+
height: 200
120+
});
121+
122+
myShape.fill.setImage(flowerImage);
123+
context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId);
124+
await context.sync();
125+
126+
const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement;
127+
128+
const option = new Option(`Binding ${bindingId}`, bindingId);
129+
130+
// When a binding ID already exists, the binding is updated to refer to the new shape
131+
// so select the existing item rather than add a new one.
132+
const foundIndex = findDropdownItem(bindingsDropdown, option.text);
133+
if (foundIndex < 0) {
134+
bindingsDropdown.add(option);
135+
bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1;
136+
} else {
137+
bindingsDropdown.selectedIndex = foundIndex;
138+
}
139+
});
140+
141+
```
142+
59143
isPreview: false
60144
isDeprecated: false
61145
syntax:
@@ -191,6 +275,28 @@ methods:
191275
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
192276
\]
193277
278+
279+
#### Examples
280+
281+
282+
```TypeScript
283+
284+
// Link to full sample:
285+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
286+
287+
288+
async function getShapeForBindingId(bindingId: string):
289+
Promise<PowerPoint.Shape | undefined> {
290+
// Gets shape associated with binding ID.
291+
return PowerPoint.run(async (context) => {
292+
const binding = context.presentation.bindings.getItem(bindingId);
293+
const shape = binding.getShape();
294+
return shape;
295+
});
296+
}
297+
298+
```
299+
194300
isPreview: false
195301
isDeprecated: false
196302
syntax:

docs/docs-ref-autogen/powerpoint/powerpoint/powerpoint.bindingtype.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,49 @@ remarks: >-
99
1.8](/javascript/api/requirement-sets/powerpoint/powerpoint-api-requirement-sets)
1010
\]
1111
12+
13+
#### Examples
14+
15+
16+
```TypeScript
17+
18+
// Link to full sample:
19+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/binding-to-shapes.yaml
20+
21+
22+
// Inserts an image with binding.
23+
24+
await PowerPoint.run(async (context) => {
25+
const bindingId = (document.getElementById("temp-binding-id") as HTMLInputElement).value;
26+
const slide = context.presentation.getSelectedSlides().getItemAt(0);
27+
const myShape = slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.rectangle, {
28+
top: 100,
29+
left: 30,
30+
width: 200,
31+
height: 200
32+
});
33+
34+
myShape.fill.setImage(flowerImage);
35+
context.presentation.bindings.add(myShape, PowerPoint.BindingType.shape, bindingId);
36+
await context.sync();
37+
38+
const bindingsDropdown = document.getElementById("bindings-dropdown") as HTMLSelectElement;
39+
40+
const option = new Option(`Binding ${bindingId}`, bindingId);
41+
42+
// When a binding ID already exists, the binding is updated to refer to the new shape
43+
// so select the existing item rather than add a new one.
44+
const foundIndex = findDropdownItem(bindingsDropdown, option.text);
45+
if (foundIndex < 0) {
46+
bindingsDropdown.add(option);
47+
bindingsDropdown.selectedIndex = bindingsDropdown.options.length - 1;
48+
} else {
49+
bindingsDropdown.selectedIndex = foundIndex;
50+
}
51+
});
52+
53+
```
54+
1255
isPreview: false
1356
isDeprecated: false
1457
fields:

0 commit comments

Comments
 (0)