@pipedream/google_slides 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-image/create-image.mjs +1 -1
- package/actions/create-page-element/create-page-element.mjs +1 -1
- package/actions/create-presentation/create-presentation.mjs +1 -1
- package/actions/create-slide/create-slide.mjs +1 -1
- package/actions/create-table/create-table.mjs +1 -1
- package/actions/delete-page-element/delete-page-element.mjs +1 -1
- package/actions/delete-slide/delete-slide.mjs +1 -1
- package/actions/delete-table-column/delete-table-column.mjs +1 -1
- package/actions/delete-table-row/delete-table-row.mjs +1 -1
- package/actions/find-presentation/find-presentation.mjs +1 -1
- package/actions/format-paragraph/format-paragraph.mjs +236 -0
- package/actions/format-shape/format-shape.mjs +193 -0
- package/actions/format-slide-background/format-slide-background.mjs +74 -0
- package/actions/format-table-cell/format-table-cell.mjs +162 -0
- package/actions/format-text/format-text.mjs +248 -0
- package/actions/get-presentation/get-presentation.mjs +2 -1
- package/actions/insert-table-columns/insert-table-columns.mjs +1 -1
- package/actions/insert-table-rows/insert-table-rows.mjs +1 -1
- package/actions/insert-text/insert-text.mjs +1 -1
- package/actions/insert-text-into-table/insert-text-into-table.mjs +1 -1
- package/actions/merge-data/merge-data.mjs +1 -1
- package/actions/position-element/position-element.mjs +219 -0
- package/actions/refresh-chart/refresh-chart.mjs +1 -1
- package/actions/replace-all-text/replace-all-text.mjs +1 -1
- package/common/constants.mjs +110 -0
- package/common/utils.mjs +115 -0
- package/google_slides.app.mjs +101 -0
- package/package.json +1 -1
- package/sources/new-presentation/new-presentation.mjs +1 -1
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-create-image",
|
|
5
5
|
name: "Create Image",
|
|
6
6
|
description: "Creates an image in a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateImageRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "google_slides-create-page-element",
|
|
6
6
|
name: "Create Page Element",
|
|
7
7
|
description: "Create a new page element in a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateShapeRequest)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-create-presentation",
|
|
5
5
|
name: "Create Presentation",
|
|
6
6
|
description: "Create a blank presentation or duplicate an existing presentation. [See the docs here](https://developers.google.com/slides/api/guides/presentations#copy_an_existing_presentation)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.9",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "google_slides-create-slide",
|
|
6
6
|
name: "Create Slide",
|
|
7
7
|
description: "Create a new slide in a presentation. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateSlideRequest)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-create-table",
|
|
5
5
|
name: "Create Table",
|
|
6
6
|
description: "Create a new table in a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#CreateTableRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.5",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-delete-page-element",
|
|
5
5
|
name: "Delete Page Element",
|
|
6
6
|
description: "Deletes a page element from a slide. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteObjectRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-delete-slide",
|
|
5
5
|
name: "Delete Slide",
|
|
6
6
|
description: "Deletes a slide from a presentation. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteObjectRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-delete-table-column",
|
|
5
5
|
name: "Delete Table Column",
|
|
6
6
|
description: "Delete column from a table. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteTableColumnRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.5",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-delete-table-row",
|
|
5
5
|
name: "Delete Table Row",
|
|
6
6
|
description: "Delete row from a table. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#DeleteTableRowRequest)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.5",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_slides-find-presentation",
|
|
5
5
|
name: "Find a Presentation",
|
|
6
6
|
description: "Find a presentation on Google Drive. [See the docs here](https://developers.google.com/slides/api/samples/presentation#list_existing_presentation_files)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.9",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleSlides from "../../google_slides.app.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ALIGNMENTS, BULLETS_NONE, BULLET_PRESETS, SPACING_MODES, TEXT_DIRECTIONS,
|
|
6
|
+
} from "../../common/constants.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "google_slides-format-paragraph",
|
|
10
|
+
name: "Format Paragraph",
|
|
11
|
+
description: "Apply paragraph formatting (alignment, line spacing, indentation, bullets) to the text of a shape or table cell in a Google Slides presentation. Use **Get Presentation** to find the page element's object ID. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#UpdateParagraphStyleRequest)",
|
|
12
|
+
version: "0.0.1",
|
|
13
|
+
annotations: {
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
openWorldHint: true,
|
|
16
|
+
readOnlyHint: false,
|
|
17
|
+
},
|
|
18
|
+
type: "action",
|
|
19
|
+
props: {
|
|
20
|
+
googleSlides,
|
|
21
|
+
presentationId: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
googleSlides,
|
|
24
|
+
"staticPresentationId",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
objectId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
googleSlides,
|
|
30
|
+
"pageElementId",
|
|
31
|
+
],
|
|
32
|
+
description: "The object ID of the shape or table whose paragraphs should be styled. Use **Get Presentation** and read `slides[].pageElements[].objectId`.",
|
|
33
|
+
},
|
|
34
|
+
rowIndex: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
googleSlides,
|
|
37
|
+
"rowIndex",
|
|
38
|
+
],
|
|
39
|
+
label: "Table Row Index",
|
|
40
|
+
description: "Required only when **Page Element ID** refers to a table: the 0-based row of the cell to style.",
|
|
41
|
+
},
|
|
42
|
+
columnIndex: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
googleSlides,
|
|
45
|
+
"columnIndex",
|
|
46
|
+
],
|
|
47
|
+
label: "Table Column Index",
|
|
48
|
+
description: "Required only when **Page Element ID** refers to a table: the 0-based column of the cell to style.",
|
|
49
|
+
},
|
|
50
|
+
startIndex: {
|
|
51
|
+
propDefinition: [
|
|
52
|
+
googleSlides,
|
|
53
|
+
"startIndex",
|
|
54
|
+
],
|
|
55
|
+
description: "Character index to style from, inclusive. On its own, styles from here to the end of the text. Omit both indices to style all of it.",
|
|
56
|
+
},
|
|
57
|
+
endIndex: {
|
|
58
|
+
propDefinition: [
|
|
59
|
+
googleSlides,
|
|
60
|
+
"endIndex",
|
|
61
|
+
],
|
|
62
|
+
description: "Character index to style up to, exclusive. Requires **Start Index**, and must be greater than it.",
|
|
63
|
+
},
|
|
64
|
+
alignment: {
|
|
65
|
+
type: "string",
|
|
66
|
+
label: "Alignment",
|
|
67
|
+
description: "Paragraph alignment. `START` is left-aligned in a left-to-right deck.",
|
|
68
|
+
options: ALIGNMENTS,
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
lineSpacing: {
|
|
72
|
+
type: "integer",
|
|
73
|
+
label: "Line Spacing",
|
|
74
|
+
description: "Line spacing as a percentage of normal (100 = single, 150 = 1.5x). Range 1-1000.",
|
|
75
|
+
min: 1,
|
|
76
|
+
max: 1000,
|
|
77
|
+
optional: true,
|
|
78
|
+
},
|
|
79
|
+
spaceAbove: {
|
|
80
|
+
type: "integer",
|
|
81
|
+
label: "Space Above",
|
|
82
|
+
description: "Space above each paragraph, in points (0-500).",
|
|
83
|
+
min: 0,
|
|
84
|
+
max: 500,
|
|
85
|
+
optional: true,
|
|
86
|
+
},
|
|
87
|
+
spaceBelow: {
|
|
88
|
+
type: "integer",
|
|
89
|
+
label: "Space Below",
|
|
90
|
+
description: "Space below each paragraph, in points (0-500).",
|
|
91
|
+
min: 0,
|
|
92
|
+
max: 500,
|
|
93
|
+
optional: true,
|
|
94
|
+
},
|
|
95
|
+
indentStart: {
|
|
96
|
+
type: "integer",
|
|
97
|
+
label: "Indent Start",
|
|
98
|
+
description: "Indentation from the start side, in points (0-500).",
|
|
99
|
+
min: 0,
|
|
100
|
+
max: 500,
|
|
101
|
+
optional: true,
|
|
102
|
+
},
|
|
103
|
+
indentEnd: {
|
|
104
|
+
type: "integer",
|
|
105
|
+
label: "Indent End",
|
|
106
|
+
description: "Indentation from the end side, in points (0-500).",
|
|
107
|
+
min: 0,
|
|
108
|
+
max: 500,
|
|
109
|
+
optional: true,
|
|
110
|
+
},
|
|
111
|
+
indentFirstLine: {
|
|
112
|
+
type: "integer",
|
|
113
|
+
label: "First Line Indent",
|
|
114
|
+
description: "Indentation of each paragraph's first line, in points (0-500).",
|
|
115
|
+
min: 0,
|
|
116
|
+
max: 500,
|
|
117
|
+
optional: true,
|
|
118
|
+
},
|
|
119
|
+
direction: {
|
|
120
|
+
type: "string",
|
|
121
|
+
label: "Text Direction",
|
|
122
|
+
description: "Reading direction of the paragraph. Unlike the other options this is not inherited, and defaults to `LEFT_TO_RIGHT` when unset.",
|
|
123
|
+
options: TEXT_DIRECTIONS,
|
|
124
|
+
optional: true,
|
|
125
|
+
},
|
|
126
|
+
spacingMode: {
|
|
127
|
+
type: "string",
|
|
128
|
+
label: "Spacing Mode",
|
|
129
|
+
description: "How paragraph spacing is rendered. `NEVER_COLLAPSE` always renders it; `COLLAPSE_LISTS` skips it between list items.",
|
|
130
|
+
options: SPACING_MODES,
|
|
131
|
+
optional: true,
|
|
132
|
+
},
|
|
133
|
+
bullets: {
|
|
134
|
+
type: "string",
|
|
135
|
+
label: "Bullets",
|
|
136
|
+
description: "Apply a bullet or numbering preset to the paragraphs, or `NONE` to strip existing bullets. `BULLET_*` presets are unordered, `NUMBERED_*` are ordered.",
|
|
137
|
+
options: [
|
|
138
|
+
BULLETS_NONE,
|
|
139
|
+
...BULLET_PRESETS,
|
|
140
|
+
],
|
|
141
|
+
optional: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
async run({ $ }) {
|
|
145
|
+
const {
|
|
146
|
+
googleSlides,
|
|
147
|
+
presentationId,
|
|
148
|
+
objectId,
|
|
149
|
+
rowIndex,
|
|
150
|
+
columnIndex,
|
|
151
|
+
startIndex,
|
|
152
|
+
endIndex,
|
|
153
|
+
alignment,
|
|
154
|
+
lineSpacing,
|
|
155
|
+
spaceAbove,
|
|
156
|
+
spaceBelow,
|
|
157
|
+
indentStart,
|
|
158
|
+
indentEnd,
|
|
159
|
+
indentFirstLine,
|
|
160
|
+
direction,
|
|
161
|
+
spacingMode,
|
|
162
|
+
bullets,
|
|
163
|
+
} = this;
|
|
164
|
+
|
|
165
|
+
const builder = utils.styleBuilder();
|
|
166
|
+
|
|
167
|
+
builder.set("alignment", alignment);
|
|
168
|
+
builder.set("lineSpacing", lineSpacing);
|
|
169
|
+
builder.setDimension("spaceAbove", spaceAbove);
|
|
170
|
+
builder.setDimension("spaceBelow", spaceBelow);
|
|
171
|
+
builder.setDimension("indentStart", indentStart);
|
|
172
|
+
builder.setDimension("indentEnd", indentEnd);
|
|
173
|
+
builder.setDimension("indentFirstLine", indentFirstLine);
|
|
174
|
+
builder.set("direction", direction);
|
|
175
|
+
builder.set("spacingMode", spacingMode);
|
|
176
|
+
|
|
177
|
+
if (builder.isEmpty && !bullets) {
|
|
178
|
+
throw new ConfigurationError("Provide at least one formatting option (for example Alignment, Line Spacing, or Bullets).");
|
|
179
|
+
}
|
|
180
|
+
if ((rowIndex == null) !== (columnIndex == null)) {
|
|
181
|
+
throw new ConfigurationError("Table Row Index and Table Column Index must be provided together.");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const textRange = utils.buildTextRange(startIndex, endIndex);
|
|
185
|
+
const cellLocation = rowIndex != null
|
|
186
|
+
? {
|
|
187
|
+
cellLocation: {
|
|
188
|
+
rowIndex,
|
|
189
|
+
columnIndex,
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
: {};
|
|
193
|
+
|
|
194
|
+
const requests = [];
|
|
195
|
+
if (builder.fields.length) {
|
|
196
|
+
requests.push({
|
|
197
|
+
updateParagraphStyle: {
|
|
198
|
+
objectId,
|
|
199
|
+
style: builder.style,
|
|
200
|
+
textRange,
|
|
201
|
+
fields: builder.mask,
|
|
202
|
+
...cellLocation,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (bullets === BULLETS_NONE) {
|
|
207
|
+
requests.push({
|
|
208
|
+
deleteParagraphBullets: {
|
|
209
|
+
objectId,
|
|
210
|
+
textRange,
|
|
211
|
+
...cellLocation,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
} else if (bullets) {
|
|
215
|
+
requests.push({
|
|
216
|
+
createParagraphBullets: {
|
|
217
|
+
objectId,
|
|
218
|
+
textRange,
|
|
219
|
+
bulletPreset: bullets,
|
|
220
|
+
...cellLocation,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
await googleSlides.batchUpdate(googleSlides.getPresentationId(presentationId), requests);
|
|
226
|
+
|
|
227
|
+
$.export("$summary", `Formatted paragraphs on element ${objectId}`);
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
presentationId,
|
|
231
|
+
objectId,
|
|
232
|
+
fieldsUpdated: builder.fields,
|
|
233
|
+
requestsApplied: requests.map((request) => Object.keys(request)[0]),
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleSlides from "../../google_slides.app.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
import {
|
|
5
|
+
DASH_STYLES, POINTS,
|
|
6
|
+
} from "../../common/constants.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "google_slides-format-shape",
|
|
10
|
+
name: "Format Shape",
|
|
11
|
+
description: "Set the background fill, outline, content alignment, or link of a shape in a Google Slides presentation. Use **Get Presentation** to find the shape's object ID. Shadow is not settable. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#UpdateShapePropertiesRequest)",
|
|
12
|
+
version: "0.0.1",
|
|
13
|
+
annotations: {
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
openWorldHint: true,
|
|
16
|
+
readOnlyHint: false,
|
|
17
|
+
},
|
|
18
|
+
type: "action",
|
|
19
|
+
props: {
|
|
20
|
+
googleSlides,
|
|
21
|
+
presentationId: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
googleSlides,
|
|
24
|
+
"staticPresentationId",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
objectId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
googleSlides,
|
|
30
|
+
"pageElementId",
|
|
31
|
+
],
|
|
32
|
+
description: "The object ID of the shape to format. Use **Get Presentation** and read `slides[].pageElements[].objectId`.",
|
|
33
|
+
},
|
|
34
|
+
backgroundColor: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
googleSlides,
|
|
37
|
+
"backgroundColor",
|
|
38
|
+
],
|
|
39
|
+
description: "Fill color as a hex code (e.g. `#FF0000`) or a theme color name (e.g. `ACCENT1`).",
|
|
40
|
+
},
|
|
41
|
+
backgroundOpacity: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
googleSlides,
|
|
44
|
+
"backgroundOpacity",
|
|
45
|
+
],
|
|
46
|
+
description: "Opacity of the fill as a whole percentage, from `0` (fully transparent) to `100` (fully opaque). Can be set on its own to change an existing fill's opacity without restating its color.",
|
|
47
|
+
},
|
|
48
|
+
outlineColor: {
|
|
49
|
+
type: "string",
|
|
50
|
+
label: "Outline Color",
|
|
51
|
+
description: "Outline color as a 6-digit hex code (e.g. `#FF0000`) or one of the deck's theme colors (e.g. `ACCENT1`, `DARK1`).",
|
|
52
|
+
optional: true,
|
|
53
|
+
},
|
|
54
|
+
outlineOpacity: {
|
|
55
|
+
type: "integer",
|
|
56
|
+
label: "Outline Opacity",
|
|
57
|
+
description: "Opacity of the outline as a whole percentage, from `0` (fully transparent) to `100` (fully opaque).",
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 100,
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
outlineWeight: {
|
|
63
|
+
type: "integer",
|
|
64
|
+
label: "Outline Weight",
|
|
65
|
+
description: "Outline thickness in points (1-100).",
|
|
66
|
+
min: 1,
|
|
67
|
+
max: 100,
|
|
68
|
+
optional: true,
|
|
69
|
+
},
|
|
70
|
+
outlineDashStyle: {
|
|
71
|
+
type: "string",
|
|
72
|
+
label: "Outline Dash Style",
|
|
73
|
+
description: "Dash pattern for the outline. One of `SOLID`, `DOT`, `DASH`, `DASH_DOT`, `LONG_DASH` or `LONG_DASH_DOT` - e.g. `DASH`.",
|
|
74
|
+
options: DASH_STYLES,
|
|
75
|
+
optional: true,
|
|
76
|
+
},
|
|
77
|
+
contentAlignment: {
|
|
78
|
+
propDefinition: [
|
|
79
|
+
googleSlides,
|
|
80
|
+
"contentAlignment",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
link: {
|
|
84
|
+
type: "string",
|
|
85
|
+
label: "Link URL",
|
|
86
|
+
description: "Make the shape link to this absolute URL, e.g. `https://example.com/report`.",
|
|
87
|
+
optional: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
async run({ $ }) {
|
|
91
|
+
const {
|
|
92
|
+
googleSlides,
|
|
93
|
+
presentationId,
|
|
94
|
+
objectId,
|
|
95
|
+
backgroundColor,
|
|
96
|
+
backgroundOpacity,
|
|
97
|
+
outlineColor,
|
|
98
|
+
outlineOpacity,
|
|
99
|
+
outlineWeight,
|
|
100
|
+
outlineDashStyle,
|
|
101
|
+
contentAlignment,
|
|
102
|
+
link,
|
|
103
|
+
} = this;
|
|
104
|
+
|
|
105
|
+
const shapeProperties = {};
|
|
106
|
+
const fields = [];
|
|
107
|
+
|
|
108
|
+
// Colour and opacity are independent: a mask can scope to `...solidFill.alpha`,
|
|
109
|
+
// so either can be set without disturbing the other.
|
|
110
|
+
const buildFill = (color, opacityPercent, label, maskPrefix) => {
|
|
111
|
+
if (!color && opacityPercent == null) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const solidFill = utils.toSolidFill(color, opacityPercent);
|
|
115
|
+
if (!solidFill) {
|
|
116
|
+
throw new ConfigurationError(`${label} "${color}" is not a valid hex color or theme color name. Use a 6-digit hex code such as \`#FF0000\`, or a theme color such as \`ACCENT1\`.`);
|
|
117
|
+
}
|
|
118
|
+
if (solidFill.color) {
|
|
119
|
+
fields.push(`${maskPrefix}.color`);
|
|
120
|
+
}
|
|
121
|
+
if (solidFill.alpha != null) {
|
|
122
|
+
fields.push(`${maskPrefix}.alpha`);
|
|
123
|
+
}
|
|
124
|
+
return solidFill;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const backgroundFill = buildFill(
|
|
128
|
+
backgroundColor, backgroundOpacity, "Background Color", "shapeBackgroundFill.solidFill",
|
|
129
|
+
);
|
|
130
|
+
if (backgroundFill) {
|
|
131
|
+
shapeProperties.shapeBackgroundFill = {
|
|
132
|
+
solidFill: backgroundFill,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const outlineFill = buildFill(
|
|
137
|
+
outlineColor, outlineOpacity, "Outline Color", "outline.outlineFill.solidFill",
|
|
138
|
+
);
|
|
139
|
+
if (outlineFill || outlineWeight != null || outlineDashStyle) {
|
|
140
|
+
shapeProperties.outline = {};
|
|
141
|
+
if (outlineFill) {
|
|
142
|
+
shapeProperties.outline.outlineFill = {
|
|
143
|
+
solidFill: outlineFill,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (outlineWeight != null) {
|
|
147
|
+
shapeProperties.outline.weight = {
|
|
148
|
+
magnitude: outlineWeight,
|
|
149
|
+
unit: POINTS,
|
|
150
|
+
};
|
|
151
|
+
fields.push("outline.weight");
|
|
152
|
+
}
|
|
153
|
+
if (outlineDashStyle) {
|
|
154
|
+
shapeProperties.outline.dashStyle = outlineDashStyle;
|
|
155
|
+
fields.push("outline.dashStyle");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (contentAlignment) {
|
|
160
|
+
shapeProperties.contentAlignment = contentAlignment;
|
|
161
|
+
fields.push("contentAlignment");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (link) {
|
|
165
|
+
shapeProperties.link = {
|
|
166
|
+
url: link,
|
|
167
|
+
};
|
|
168
|
+
fields.push("link");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!fields.length) {
|
|
172
|
+
throw new ConfigurationError("Provide at least one formatting option (for example Background Color, Background Opacity, Outline Color, or Content Alignment).");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
await googleSlides.batchUpdate(googleSlides.getPresentationId(presentationId), [
|
|
176
|
+
{
|
|
177
|
+
updateShapeProperties: {
|
|
178
|
+
objectId,
|
|
179
|
+
shapeProperties,
|
|
180
|
+
fields: fields.join(","),
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
$.export("$summary", `Formatted shape ${objectId}`);
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
presentationId,
|
|
189
|
+
objectId,
|
|
190
|
+
fieldsUpdated: fields,
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleSlides from "../../google_slides.app.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "google_slides-format-slide-background",
|
|
7
|
+
name: "Format Slide Background",
|
|
8
|
+
description: "Set the background fill of a single slide in a Google Slides presentation. Use **Get Presentation** to find the slide's object ID. [See the documentation](https://developers.google.com/workspace/slides/api/reference/rest/v1/presentations/request#UpdatePagePropertiesRequest)",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
15
|
+
type: "action",
|
|
16
|
+
props: {
|
|
17
|
+
googleSlides,
|
|
18
|
+
presentationId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
googleSlides,
|
|
21
|
+
"staticPresentationId",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
slideId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
googleSlides,
|
|
27
|
+
"staticSlideId",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
backgroundColor: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
googleSlides,
|
|
33
|
+
"backgroundColor",
|
|
34
|
+
],
|
|
35
|
+
description: "Slide background as a hex code (e.g. `#102A43`) or a theme color name (e.g. `DARK1`).",
|
|
36
|
+
optional: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
async run({ $ }) {
|
|
40
|
+
const {
|
|
41
|
+
googleSlides,
|
|
42
|
+
presentationId,
|
|
43
|
+
slideId,
|
|
44
|
+
backgroundColor,
|
|
45
|
+
} = this;
|
|
46
|
+
|
|
47
|
+
const solidFill = utils.toSolidFill(backgroundColor);
|
|
48
|
+
if (!solidFill) {
|
|
49
|
+
throw new ConfigurationError(`Background Color "${backgroundColor}" is not a valid hex color or theme color name. Use a 6-digit hex code such as \`#102A43\`, or a theme color such as \`DARK1\`.`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await googleSlides.batchUpdate(googleSlides.getPresentationId(presentationId), [
|
|
53
|
+
{
|
|
54
|
+
updatePageProperties: {
|
|
55
|
+
objectId: slideId,
|
|
56
|
+
pageProperties: {
|
|
57
|
+
pageBackgroundFill: {
|
|
58
|
+
solidFill,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
fields: "pageBackgroundFill.solidFill.color",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
$.export("$summary", `Set background of slide ${slideId}`);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
presentationId,
|
|
70
|
+
slideId,
|
|
71
|
+
backgroundColor,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
};
|