@canva/design 1.10.0 → 2.0.0
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/index.d.ts +947 -527
- package/lib/cjs/sdk/design/index.js +4 -2
- package/lib/cjs/sdk/design/public.js +28 -29
- package/lib/esm/sdk/design/index.js +3 -1
- package/lib/esm/sdk/design/public.js +21 -78
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -3,59 +3,89 @@
|
|
|
3
3
|
* @public
|
|
4
4
|
* @param audioTrack - The audio track to add to the user's design.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare const addAudioTrack: (audioTrack: AudioTrack) => Promise<void>;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* @public
|
|
10
|
+
* Add element to responsive documents, which slot things into a text stream
|
|
11
|
+
*/
|
|
12
|
+
export declare const addElementAtCursor: (
|
|
13
|
+
element: ElementAtCursor | TableElement
|
|
14
|
+
) => Promise<void>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* Add element to fixed designs, which use a coordinate-based positioning system.
|
|
19
|
+
*/
|
|
20
|
+
export declare const addElementAtPoint: (
|
|
21
|
+
element: DesignElement | ElementAtPoint | TableElement | RichtextElement
|
|
22
|
+
) => Promise<void>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
9
26
|
* @public
|
|
10
27
|
* Adds a native element to the user's design.
|
|
11
28
|
* @param element - The element to add to the user's design.
|
|
12
29
|
*/
|
|
13
|
-
export declare
|
|
30
|
+
export declare const addNativeElement: (
|
|
14
31
|
element: NativeElement | NativeElementWithBox
|
|
15
|
-
)
|
|
32
|
+
) => Promise<void>;
|
|
16
33
|
|
|
17
34
|
/**
|
|
18
35
|
* @public
|
|
19
36
|
* Adds a new page immediately after the currently selected page.
|
|
20
37
|
* @param opts - Configuration for the new page to be added.
|
|
21
38
|
*/
|
|
22
|
-
export declare
|
|
39
|
+
export declare const addPage: (opts?: {
|
|
23
40
|
/** Elements to be added to the page */
|
|
24
|
-
elements?:
|
|
41
|
+
elements?: ElementAtPoint[];
|
|
25
42
|
/**
|
|
26
43
|
* The page background. This can be a solid color, an image or a video.
|
|
27
44
|
**/
|
|
28
45
|
background?: PageBackgroundFill;
|
|
29
46
|
/** A page title which must be no longer than 255 characters */
|
|
30
47
|
title?: string;
|
|
31
|
-
})
|
|
48
|
+
}) => Promise<void>;
|
|
32
49
|
|
|
33
50
|
/**
|
|
34
51
|
* @public
|
|
35
|
-
*
|
|
52
|
+
* Alternative text for a11y compliance.
|
|
36
53
|
*/
|
|
37
54
|
export declare type AltText = {
|
|
38
55
|
/**
|
|
39
|
-
* The text
|
|
56
|
+
* The text content.
|
|
40
57
|
*/
|
|
41
58
|
text: string;
|
|
42
59
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
60
|
+
* Indicates where the alternative text should be displayed.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - If `true`, the alternative text will only be displayed in the editor.
|
|
64
|
+
* - If `false`, the alternative text will be displayed in the editor and in view-only mode.
|
|
46
65
|
*/
|
|
47
66
|
decorative: boolean | undefined;
|
|
48
67
|
};
|
|
49
68
|
|
|
50
69
|
/**
|
|
51
70
|
* @public
|
|
52
|
-
* A callback that runs when
|
|
53
|
-
*
|
|
71
|
+
* A callback that runs when:
|
|
72
|
+
*
|
|
73
|
+
* - the app element is created
|
|
74
|
+
* - the app element's data is updated
|
|
75
|
+
* - the user selects an existing app element
|
|
76
|
+
*
|
|
77
|
+
* @param appElement - Information about the app element that was changed.
|
|
54
78
|
*/
|
|
55
79
|
export declare type AppElementChangeHandler<A extends AppElementData> = (
|
|
56
80
|
appElement:
|
|
57
81
|
| {
|
|
82
|
+
/**
|
|
83
|
+
* The app element data in its most recent state.
|
|
84
|
+
*/
|
|
58
85
|
data: A;
|
|
86
|
+
/**
|
|
87
|
+
* The version number of the app.
|
|
88
|
+
*/
|
|
59
89
|
version: number;
|
|
60
90
|
}
|
|
61
91
|
| undefined
|
|
@@ -63,47 +93,49 @@ export declare type AppElementChangeHandler<A extends AppElementData> = (
|
|
|
63
93
|
|
|
64
94
|
/**
|
|
65
95
|
* @public
|
|
66
|
-
* A client
|
|
96
|
+
* A client that provides methods for creating and managing the lifecycle of an app element.
|
|
67
97
|
*/
|
|
68
98
|
export declare interface AppElementClient<A extends AppElementData> {
|
|
69
99
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param appElementData - The data to attach to the app element.
|
|
100
|
+
* If an app element is selected, the element's data is overwritten and the element is re-rendered.
|
|
101
|
+
* Otherwise, the provided data is used to create a new app element.
|
|
102
|
+
* @param appElementData - The data to attach to the app element. Existing data will be overwritten.
|
|
103
|
+
* @param placement - The position, dimensions, and rotation of the app element.
|
|
73
104
|
*/
|
|
74
105
|
addOrUpdateElement(appElementData: A, placement?: Placement): Promise<void>;
|
|
75
106
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
107
|
+
* A callback that runs when:
|
|
108
|
+
*
|
|
109
|
+
* - the app element is created
|
|
110
|
+
* - the app element's data is updated
|
|
111
|
+
* - the user selects an existing app element
|
|
112
|
+
*
|
|
113
|
+
* @param handler - The callback to run when the app element changes.
|
|
80
114
|
*/
|
|
81
115
|
registerOnElementChange(handler: AppElementChangeHandler<A>): void;
|
|
82
116
|
}
|
|
83
117
|
|
|
84
118
|
/**
|
|
85
119
|
* @public
|
|
86
|
-
*
|
|
120
|
+
* Options for creating an app element client.
|
|
87
121
|
*/
|
|
88
122
|
export declare type AppElementClientConfiguration<A extends AppElementData> = {
|
|
89
123
|
/**
|
|
90
|
-
*
|
|
124
|
+
* Registers a callback that renders an app element based on the data it receives.
|
|
91
125
|
*/
|
|
92
126
|
render: AppElementRenderer<A>;
|
|
93
127
|
};
|
|
94
128
|
|
|
95
129
|
/**
|
|
96
130
|
* @public
|
|
97
|
-
* The data
|
|
131
|
+
* The data associated with an app element.
|
|
98
132
|
*/
|
|
99
133
|
export declare type AppElementData = Record<string, Value>;
|
|
100
134
|
|
|
101
135
|
/**
|
|
102
136
|
* @public
|
|
103
|
-
* A callback that
|
|
104
|
-
*
|
|
105
|
-
* @remarks
|
|
106
|
-
* This callback must return one or more elements to render within the app element.
|
|
137
|
+
* A callback function that renders an app element based on the data it receives.
|
|
138
|
+
* @param appElementData - The data the callback must use to render the app element.
|
|
107
139
|
*/
|
|
108
140
|
export declare type AppElementRenderer<A extends AppElementData> = (
|
|
109
141
|
appElementData: A
|
|
@@ -111,8 +143,7 @@ export declare type AppElementRenderer<A extends AppElementData> = (
|
|
|
111
143
|
|
|
112
144
|
/**
|
|
113
145
|
* @public
|
|
114
|
-
*
|
|
115
|
-
* It is an array of elements to render within an app element.
|
|
146
|
+
* An array of one or more elements to render as output of an app element.
|
|
116
147
|
*/
|
|
117
148
|
export declare type AppElementRendererOutput = NativeSimpleElementWithBox[];
|
|
118
149
|
|
|
@@ -126,13 +157,13 @@ export declare type AppProcessId = string & {
|
|
|
126
157
|
|
|
127
158
|
/**
|
|
128
159
|
* @public
|
|
129
|
-
*
|
|
160
|
+
* Audio track to be added to the design at the end of a drag event.
|
|
130
161
|
*/
|
|
131
162
|
export declare type AudioDragConfig = {
|
|
132
163
|
/**
|
|
133
164
|
* The type of element.
|
|
134
165
|
*/
|
|
135
|
-
type: "
|
|
166
|
+
type: "audio";
|
|
136
167
|
/**
|
|
137
168
|
* A function that returns a reference (ref) to an audio asset in Canva's backend.
|
|
138
169
|
*/
|
|
@@ -159,112 +190,218 @@ export declare type AudioRef = string & {
|
|
|
159
190
|
|
|
160
191
|
/**
|
|
161
192
|
* @public
|
|
162
|
-
* An audio track that can be added to a
|
|
193
|
+
* An audio track that can be added to a design.
|
|
163
194
|
*/
|
|
164
195
|
export declare type AudioTrack = {
|
|
165
196
|
/**
|
|
166
|
-
* A unique identifier that
|
|
197
|
+
* A unique identifier that points to an audio asset in Canva's backend.
|
|
167
198
|
*/
|
|
168
199
|
ref: AudioRef;
|
|
169
200
|
};
|
|
170
201
|
|
|
171
202
|
/**
|
|
172
203
|
* @public
|
|
173
|
-
*
|
|
204
|
+
* A segment of a richtext range.
|
|
205
|
+
*/
|
|
206
|
+
export declare type Bounds = {
|
|
207
|
+
/**
|
|
208
|
+
* The starting position of the segment.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* This is zero-based, meaning the first character of the range is at index 0.
|
|
212
|
+
*/
|
|
213
|
+
index: number;
|
|
214
|
+
/**
|
|
215
|
+
* The number of characters in the segment, starting from the index.
|
|
216
|
+
*/
|
|
217
|
+
length: number;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated
|
|
222
|
+
* @public
|
|
223
|
+
* A position, rotation, and set of dimensions.
|
|
174
224
|
*
|
|
175
225
|
* @remarks
|
|
176
|
-
*
|
|
226
|
+
* The position and dimensions are relative to the container.
|
|
177
227
|
*/
|
|
178
228
|
export declare type Box = Position & (WidthAndHeight | Width | Height);
|
|
179
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @public
|
|
232
|
+
* An individual cell in a table element.
|
|
233
|
+
*/
|
|
234
|
+
export declare type Cell = {
|
|
235
|
+
/**
|
|
236
|
+
* The attributes of the cell.
|
|
237
|
+
*/
|
|
238
|
+
attributes?: CellAttributes;
|
|
239
|
+
/**
|
|
240
|
+
* The number of columns that the cell occupies.
|
|
241
|
+
*/
|
|
242
|
+
colSpan?: number;
|
|
243
|
+
/**
|
|
244
|
+
* The number of rows that the cell occupies.
|
|
245
|
+
*/
|
|
246
|
+
rowSpan?: number;
|
|
247
|
+
} & CellContent;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @public
|
|
251
|
+
* Additional attributes of table cell.
|
|
252
|
+
*/
|
|
253
|
+
declare type CellAttributes = {
|
|
254
|
+
/**
|
|
255
|
+
* The background color of the cell, as a hex code.
|
|
256
|
+
*/
|
|
257
|
+
backgroundColor?: string;
|
|
258
|
+
} & TextAttributes;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @public
|
|
262
|
+
* The content of a table element's cell.
|
|
263
|
+
* Cell only supports plain text.
|
|
264
|
+
*/
|
|
265
|
+
declare type CellContent =
|
|
266
|
+
| {
|
|
267
|
+
/**
|
|
268
|
+
* Indicates that the cell doesn't have any content.
|
|
269
|
+
*/
|
|
270
|
+
type: "empty";
|
|
271
|
+
}
|
|
272
|
+
| {
|
|
273
|
+
/**
|
|
274
|
+
* Indicates that the cell contains plaintext content.
|
|
275
|
+
*/
|
|
276
|
+
type: "string";
|
|
277
|
+
/**
|
|
278
|
+
* The plaintext content of the cell.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* If an empty string is provided, the `type` will change to `"empty"`.
|
|
282
|
+
*/
|
|
283
|
+
value: string;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Image element or content to be added to the design at the end of a drag event.
|
|
288
|
+
*/
|
|
180
289
|
declare type CommonImageDragConfig = {
|
|
181
290
|
/**
|
|
182
291
|
* The type of element.
|
|
183
292
|
*/
|
|
184
|
-
type: "
|
|
293
|
+
type: "image";
|
|
185
294
|
/**
|
|
186
295
|
* The dimensions of the preview image.
|
|
187
|
-
*
|
|
188
|
-
* @remarks
|
|
189
|
-
* The preview image is the image that users see under their cursor while dragging
|
|
190
|
-
* it into their design.
|
|
191
296
|
*/
|
|
192
297
|
previewSize: Dimensions;
|
|
193
298
|
};
|
|
194
299
|
|
|
195
300
|
/**
|
|
196
301
|
* @public
|
|
197
|
-
* A snapshot of
|
|
198
|
-
*
|
|
199
|
-
* @remarks
|
|
200
|
-
* You can mutate the values in the `contents` array and then persist those changes with the `save` method.
|
|
302
|
+
* A snapshot of content from a user's design.
|
|
201
303
|
*/
|
|
202
304
|
export declare interface ContentDraft<T> {
|
|
203
305
|
/**
|
|
204
|
-
* The
|
|
306
|
+
* The individual content items that exist within the snapshot.
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* Any changes made to this array won't be reflected in the user's design until the `save` method is called.
|
|
205
310
|
*/
|
|
206
311
|
readonly contents: readonly T[];
|
|
207
312
|
/**
|
|
208
|
-
* Saves changes made to items in the `contents` array.
|
|
209
|
-
* Once saved, those changes are reflected in the user's design.
|
|
313
|
+
* Saves changes made to the content items in the `contents` array.
|
|
210
314
|
*
|
|
211
315
|
* @remarks
|
|
212
|
-
*
|
|
213
|
-
*
|
|
316
|
+
* Once this method is called:
|
|
317
|
+
*
|
|
318
|
+
* - Any changes the app has made to to the content will be reflected in the user's design.
|
|
319
|
+
* - Any changes the user has made to the content since the snapshot was created may be overwritten.
|
|
320
|
+
* - Only properties that are different from the original state will be written to the design.
|
|
214
321
|
*/
|
|
215
322
|
save(): Promise<void>;
|
|
216
323
|
}
|
|
217
324
|
|
|
218
325
|
/**
|
|
219
326
|
* @public
|
|
220
|
-
*
|
|
327
|
+
* A type of content that can be read from a user's design.
|
|
328
|
+
*/
|
|
329
|
+
export declare type ContentType = "richtext";
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* @public
|
|
333
|
+
* A set of X and Y coordinates.
|
|
221
334
|
*/
|
|
222
335
|
export declare type Coordinates = {
|
|
223
336
|
/**
|
|
224
|
-
*
|
|
337
|
+
* X coordinate, in pixels.
|
|
225
338
|
*/
|
|
226
339
|
x: number;
|
|
227
340
|
/**
|
|
228
|
-
*
|
|
341
|
+
* Y coordinate, in pixels.
|
|
229
342
|
*/
|
|
230
343
|
y: number;
|
|
231
344
|
};
|
|
232
345
|
|
|
233
346
|
/**
|
|
234
347
|
* @public
|
|
235
|
-
*
|
|
348
|
+
* Creates a new RichtextRange object, which contains methods to manipulate text.
|
|
349
|
+
*/
|
|
350
|
+
export declare function createRichtextRange(): RichtextRange;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @public
|
|
354
|
+
* An element that's natively supported by the Canva editor.
|
|
355
|
+
*/
|
|
356
|
+
export declare type DesignElement = NativeElement;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @public
|
|
360
|
+
* Provides methods for managing the lifecycle of overlays, such as selected image overlays.
|
|
236
361
|
*/
|
|
237
362
|
export declare type DesignOverlay = {
|
|
238
363
|
/**
|
|
239
|
-
* Registers a callback that runs when
|
|
240
|
-
*
|
|
241
|
-
* @remarks
|
|
242
|
-
* The callback fires immediately
|
|
364
|
+
* Registers a callback that runs when the `canOpen` state of an overlay target changes.
|
|
365
|
+
* @param opts - Options for configuring the callback.
|
|
243
366
|
*/
|
|
244
367
|
registerOnCanOpen<Target extends OverlayTarget>(opts: {
|
|
368
|
+
/**
|
|
369
|
+
* The target to check the `canOpen` state of.
|
|
370
|
+
*/
|
|
245
371
|
target: Target;
|
|
372
|
+
/**
|
|
373
|
+
* A callback that runs when the `canOpen` state of the specified target changes.
|
|
374
|
+
*
|
|
375
|
+
* @param event - Information about whether or not an overlay can be opened for the specified target.
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
* This callback fires immediately.
|
|
379
|
+
*/
|
|
246
380
|
onCanOpen(event: OverlayOpenableEvent<Target>): void;
|
|
247
381
|
}): () => void;
|
|
248
382
|
};
|
|
249
383
|
|
|
250
384
|
/**
|
|
251
385
|
* @public
|
|
252
|
-
* Provides methods for interacting with
|
|
386
|
+
* Provides methods for interacting with selected content.
|
|
253
387
|
*/
|
|
254
388
|
export declare type DesignSelection = {
|
|
255
389
|
/**
|
|
256
|
-
* Registers a callback that runs when
|
|
390
|
+
* Registers a callback that runs when the specified type of content is selected.
|
|
391
|
+
*
|
|
392
|
+
* @param opts - Options for configuring the content selection callback.
|
|
257
393
|
*
|
|
258
394
|
* @remarks
|
|
259
|
-
*
|
|
395
|
+
* This callback fires immediately if content is already selected when the callback is registered.
|
|
260
396
|
*/
|
|
261
397
|
registerOnChange<Scope extends SelectionScope>(opts: {
|
|
262
398
|
/**
|
|
263
|
-
* The type of content that
|
|
399
|
+
* The type of content that triggers a selection change event.
|
|
264
400
|
*/
|
|
265
401
|
scope: Scope;
|
|
266
402
|
/**
|
|
267
|
-
* The callback to run when the
|
|
403
|
+
* The callback to run when the selected content changes.
|
|
404
|
+
* @param event - Information about the selection change event.
|
|
268
405
|
*/
|
|
269
406
|
onChange(event: SelectionEvent<Scope>): void;
|
|
270
407
|
}): () => void;
|
|
@@ -280,47 +417,45 @@ export declare type DesignToken = {
|
|
|
280
417
|
|
|
281
418
|
/**
|
|
282
419
|
* @public
|
|
283
|
-
*
|
|
420
|
+
* A set of dimensions.
|
|
284
421
|
*/
|
|
285
422
|
export declare type Dimensions = {
|
|
286
423
|
/**
|
|
287
|
-
*
|
|
424
|
+
* A width, in pixels.
|
|
288
425
|
*/
|
|
289
426
|
width: number;
|
|
290
427
|
/**
|
|
291
|
-
*
|
|
428
|
+
* A height, in pixels.
|
|
292
429
|
*/
|
|
293
430
|
height: number;
|
|
294
431
|
};
|
|
295
432
|
|
|
296
433
|
/**
|
|
297
434
|
* @public
|
|
298
|
-
* Callbacks
|
|
435
|
+
* Callbacks for handling drag and drop events.
|
|
299
436
|
*/
|
|
300
437
|
export declare type DragCallback = {
|
|
301
438
|
/**
|
|
302
|
-
* A callback that runs
|
|
303
|
-
*
|
|
304
|
-
* @param element - The element being dragged into the user's design.
|
|
439
|
+
* A callback that runs at the start of a drag event.
|
|
440
|
+
* @param element - The element being dragged.
|
|
305
441
|
*/
|
|
306
442
|
onDragStart: (element: HTMLElement) => void;
|
|
307
443
|
/**
|
|
308
|
-
* A callback that runs
|
|
309
|
-
*
|
|
310
|
-
* @param element - The element being dragged into the user's design.
|
|
444
|
+
* A callback that runs at the end of a drag event.
|
|
445
|
+
* @param element - The element being dragged.
|
|
311
446
|
*/
|
|
312
447
|
onDragEnd: (element: HTMLElement) => void;
|
|
313
448
|
};
|
|
314
449
|
|
|
315
450
|
/**
|
|
316
451
|
* @public
|
|
317
|
-
* Options for
|
|
452
|
+
* Options for adding drag and drop behavior to an `HTMLElement`.
|
|
318
453
|
*/
|
|
319
454
|
export declare type DraggableElementData = ElementData | ImageElementData;
|
|
320
455
|
|
|
321
456
|
/**
|
|
322
457
|
* @public
|
|
323
|
-
*
|
|
458
|
+
* An event that occurs when a user starts dragging an HTML element.
|
|
324
459
|
*/
|
|
325
460
|
export declare type DragStartEvent<E extends Element> = Pick<
|
|
326
461
|
DragEvent,
|
|
@@ -331,61 +466,81 @@ export declare type DragStartEvent<E extends Element> = Pick<
|
|
|
331
466
|
|
|
332
467
|
/**
|
|
333
468
|
* @public
|
|
334
|
-
*
|
|
469
|
+
* Elements targeting a cursor are a subset of the base Element
|
|
470
|
+
**/
|
|
471
|
+
export declare type ElementAtCursor =
|
|
472
|
+
| ImageElement
|
|
473
|
+
| VideoElement
|
|
474
|
+
| EmbedElement
|
|
475
|
+
| TextElement
|
|
476
|
+
| RichtextElement;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @public
|
|
480
|
+
* An element that's natively supported by the Canva editor and has positional properties.
|
|
481
|
+
*/
|
|
482
|
+
export declare type ElementAtPoint =
|
|
483
|
+
| NativeElementWithBox
|
|
484
|
+
| RichtextElementAtPoint;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @public
|
|
488
|
+
* Options for adding drag and drop behavior to an `HTMLElement`.
|
|
335
489
|
*/
|
|
336
490
|
export declare type ElementData = DragCallback & {
|
|
337
491
|
/**
|
|
338
|
-
* The
|
|
492
|
+
* The `HTMLElement` to be made draggable.
|
|
339
493
|
*/
|
|
340
494
|
node: HTMLElement;
|
|
341
|
-
/**
|
|
342
|
-
* Options for defining the drag-and-drop behavior.
|
|
343
|
-
*
|
|
344
|
-
* @remarks
|
|
345
|
-
* This data is required because it can't be inferred from the `node` property.
|
|
346
|
-
*/
|
|
347
|
-
dragData: UserSuppliedDragData;
|
|
348
495
|
};
|
|
349
496
|
|
|
350
497
|
/**
|
|
351
498
|
* @public
|
|
352
|
-
*
|
|
353
|
-
* Options for defining the drag-and-drop behaviour for embeds.
|
|
499
|
+
* Embed element to be added to the design at the end of a drag event.
|
|
354
500
|
*/
|
|
355
501
|
export declare type EmbedDragConfig = {
|
|
356
502
|
/**
|
|
357
503
|
* The type of element.
|
|
358
504
|
*/
|
|
359
|
-
type: "
|
|
505
|
+
type: "embed";
|
|
360
506
|
/**
|
|
361
507
|
* The dimensions of the preview image.
|
|
362
|
-
* The preview image is the image that users see under their cursor
|
|
363
|
-
* while dragging it into their design.
|
|
364
508
|
*/
|
|
365
509
|
previewSize: Dimensions;
|
|
366
510
|
/**
|
|
367
|
-
*
|
|
511
|
+
* The URL of an image to display under the user's cursor during the drag and drop event.
|
|
368
512
|
*/
|
|
369
513
|
previewUrl: string;
|
|
370
514
|
/**
|
|
371
|
-
*
|
|
515
|
+
* The URL of media that can be embedded, such as the URL of a YouTube video.
|
|
516
|
+
*
|
|
517
|
+
* @remarks
|
|
518
|
+
* This URL must be supported by the Iframely API.
|
|
372
519
|
*/
|
|
373
520
|
embedUrl: string;
|
|
374
521
|
};
|
|
375
522
|
|
|
376
523
|
/**
|
|
377
524
|
* @public
|
|
378
|
-
*
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
525
|
+
* An element that renders rich media, such as a YouTube video.
|
|
526
|
+
*/
|
|
527
|
+
export declare type EmbedElement = NativeEmbedElement;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* @public
|
|
531
|
+
* An element that renders rich media, such as a YouTube video, and has positional properties.
|
|
532
|
+
*/
|
|
533
|
+
export declare type EmbedElementAtPoint = NativeEmbedElementWithBox;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @public
|
|
537
|
+
* The result when a user abandons the export flow, such as by closing the export menu.
|
|
383
538
|
*/
|
|
384
539
|
export declare type ExportAborted = {
|
|
385
540
|
/**
|
|
386
|
-
* The status of the export flow
|
|
541
|
+
* The status of the export flow.
|
|
387
542
|
*/
|
|
388
|
-
status: "
|
|
543
|
+
status: "aborted";
|
|
389
544
|
};
|
|
390
545
|
|
|
391
546
|
/**
|
|
@@ -397,13 +552,14 @@ export declare type ExportBlob = {
|
|
|
397
552
|
* The URL of the exported design.
|
|
398
553
|
*
|
|
399
554
|
* @remarks
|
|
400
|
-
* If
|
|
555
|
+
* If a user's design contains multiple pages but is exported in a format that doesn't support multiple pages,
|
|
556
|
+
* this URL will point to a ZIP file that contains each page as a separate file.
|
|
401
557
|
*
|
|
402
558
|
* For example:
|
|
403
559
|
*
|
|
404
|
-
* - If a single-page design is exported as a JPG, the URL will point to a JPG file
|
|
405
|
-
* - If a multi-page design is exported as a JPG, the URL will point to a ZIP file that contains a
|
|
406
|
-
* - If a multi-page design is exported as a PDF, the URL will point to a PDF file
|
|
560
|
+
* - If a single-page design is exported as a JPG, the URL will point to a JPG file.
|
|
561
|
+
* - If a multi-page design is exported as a JPG, the URL will point to a ZIP file that contains a JPG file for each page.
|
|
562
|
+
* - If a multi-page design is exported as a PDF file, the URL will point to a PDF file.
|
|
407
563
|
*
|
|
408
564
|
* The following file types support multiple pages:
|
|
409
565
|
*
|
|
@@ -423,22 +579,23 @@ export declare type ExportBlob = {
|
|
|
423
579
|
|
|
424
580
|
/**
|
|
425
581
|
* @public
|
|
426
|
-
*
|
|
582
|
+
* The result when a user successfully completes an export flow.
|
|
427
583
|
*/
|
|
428
584
|
export declare type ExportCompleted = {
|
|
429
585
|
/**
|
|
430
|
-
* The status of the export flow
|
|
586
|
+
* The status of the export flow.
|
|
431
587
|
*/
|
|
432
|
-
status: "
|
|
588
|
+
status: "completed";
|
|
433
589
|
/**
|
|
434
|
-
* The title of the
|
|
590
|
+
* The title of the design, if set by the user.
|
|
435
591
|
*/
|
|
436
592
|
title?: string;
|
|
437
593
|
/**
|
|
438
594
|
* The exported files.
|
|
439
595
|
*
|
|
440
596
|
* @remarks
|
|
441
|
-
* This array only contains one element. This is because, if a multi-page design is exported as multiple files, the files
|
|
597
|
+
* This array only contains one element. This is because, if a multi-page design is exported as multiple files, the files
|
|
598
|
+
* are exported in a ZIP file. In the future, there'll be an option for each file to be a separate element in the array.
|
|
442
599
|
*/
|
|
443
600
|
exportBlobs: ExportBlob[];
|
|
444
601
|
};
|
|
@@ -448,17 +605,17 @@ export declare type ExportCompleted = {
|
|
|
448
605
|
* The types of files that Canva supports for exported designs.
|
|
449
606
|
*/
|
|
450
607
|
export declare type ExportFileType =
|
|
451
|
-
| "
|
|
452
|
-
| "
|
|
453
|
-
| "
|
|
454
|
-
| "
|
|
455
|
-
| "
|
|
456
|
-
| "
|
|
457
|
-
| "
|
|
608
|
+
| "png"
|
|
609
|
+
| "jpg"
|
|
610
|
+
| "pdf_standard"
|
|
611
|
+
| "video"
|
|
612
|
+
| "gif"
|
|
613
|
+
| "pptx"
|
|
614
|
+
| "svg";
|
|
458
615
|
|
|
459
616
|
/**
|
|
460
617
|
* @public
|
|
461
|
-
*
|
|
618
|
+
* Options for configuring the export of a design.
|
|
462
619
|
*/
|
|
463
620
|
export declare type ExportRequest = {
|
|
464
621
|
/**
|
|
@@ -472,44 +629,30 @@ export declare type ExportRequest = {
|
|
|
472
629
|
|
|
473
630
|
/**
|
|
474
631
|
* @public
|
|
475
|
-
* The
|
|
632
|
+
* The result of exporting a design.
|
|
476
633
|
*/
|
|
477
634
|
export declare type ExportResponse = ExportCompleted | ExportAborted;
|
|
478
635
|
|
|
479
636
|
/**
|
|
480
637
|
* @public
|
|
638
|
+
* Image element or content to be added to the design at the end of a drag event.
|
|
481
639
|
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
640
|
+
* @remarks
|
|
641
|
+
* This type is only used when the image data is from an external URL.
|
|
484
642
|
*/
|
|
485
643
|
export declare type ExternalImageDragConfig = CommonImageDragConfig & {
|
|
486
644
|
/**
|
|
487
|
-
*
|
|
488
|
-
* @remarks
|
|
489
|
-
*
|
|
490
|
-
* This function will be run during the drag process in order to fetch the media ref of the
|
|
491
|
-
* external image being fetched. This function should return the result of `upload`
|
|
492
|
-
* from the content capability.
|
|
645
|
+
* A function that returns a reference (ref) to an audio asset in Canva's backend.
|
|
493
646
|
*/
|
|
494
647
|
resolveImageRef: () => Promise<{
|
|
495
648
|
ref: ImageRef;
|
|
496
649
|
}>;
|
|
497
650
|
/**
|
|
498
|
-
* The URL of the
|
|
499
|
-
*
|
|
500
|
-
* @remarks
|
|
501
|
-
* The preview image is the image that users see under their cursor while dragging
|
|
502
|
-
* it into their design.
|
|
651
|
+
* The URL of an image to display under the user's cursor during the drag and drop event.
|
|
503
652
|
*/
|
|
504
653
|
previewUrl: string;
|
|
505
654
|
/**
|
|
506
655
|
* The dimensions of the full-size image.
|
|
507
|
-
*
|
|
508
|
-
* @remarks
|
|
509
|
-
* The full-size image is the image that Canva uploads to the user's account and
|
|
510
|
-
* adds to their design.
|
|
511
|
-
*
|
|
512
|
-
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
513
656
|
*/
|
|
514
657
|
fullSize?: Dimensions;
|
|
515
658
|
};
|
|
@@ -517,26 +660,27 @@ export declare type ExternalImageDragConfig = CommonImageDragConfig & {
|
|
|
517
660
|
/**
|
|
518
661
|
* @public
|
|
519
662
|
* The appearance of a path's interior.
|
|
663
|
+
*
|
|
664
|
+
* @remarks
|
|
665
|
+
* The `color` and `asset` properties are mutually exclusive.
|
|
520
666
|
*/
|
|
521
667
|
export declare type Fill = {
|
|
522
668
|
/**
|
|
523
|
-
*
|
|
524
|
-
* If set to true, images or videos can be dropped on the fill.
|
|
669
|
+
* If `true`, users can replace a fill by dropping an image or video onto it.
|
|
525
670
|
*/
|
|
526
671
|
dropTarget?: boolean;
|
|
527
672
|
/**
|
|
528
673
|
* The color of the fill as a hex code.
|
|
529
674
|
*
|
|
530
675
|
* @remarks
|
|
531
|
-
* The hex code must include all six characters and be prefixed with a
|
|
532
|
-
*
|
|
676
|
+
* The hex code must include all six characters and be prefixed with a `#` symbol.
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* " #ff0099"
|
|
533
680
|
*/
|
|
534
681
|
color?: string;
|
|
535
682
|
/**
|
|
536
|
-
* An
|
|
537
|
-
*
|
|
538
|
-
* @remarks
|
|
539
|
-
* Only one type of fill (color, image or video) can be set.
|
|
683
|
+
* An image or video to use as the fill.
|
|
540
684
|
*/
|
|
541
685
|
asset?: ImageFill | VideoFill;
|
|
542
686
|
};
|
|
@@ -569,7 +713,7 @@ export declare type FontWeight =
|
|
|
569
713
|
* @public
|
|
570
714
|
* @returns Page context of currently selected page
|
|
571
715
|
*/
|
|
572
|
-
export declare
|
|
716
|
+
export declare const getCurrentPageContext: () => Promise<PageContext>;
|
|
573
717
|
|
|
574
718
|
/**
|
|
575
719
|
* @public
|
|
@@ -580,7 +724,7 @@ export declare function getCurrentPageContext(): Promise<PageContext>;
|
|
|
580
724
|
*
|
|
581
725
|
* Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
|
|
582
726
|
*/
|
|
583
|
-
export declare
|
|
727
|
+
export declare const getDefaultPageDimensions: () => Promise<
|
|
584
728
|
Dimensions | undefined
|
|
585
729
|
>;
|
|
586
730
|
|
|
@@ -590,21 +734,52 @@ export declare function getDefaultPageDimensions(): Promise<
|
|
|
590
734
|
*/
|
|
591
735
|
export declare function getDesignToken(): Promise<DesignToken>;
|
|
592
736
|
|
|
737
|
+
/**
|
|
738
|
+
* @public
|
|
739
|
+
* An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
|
|
740
|
+
*/
|
|
741
|
+
export declare type GroupContentAtPoint = NativeSimpleElementWithBox;
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* @public
|
|
745
|
+
* An element that contains two or more elements.
|
|
746
|
+
*/
|
|
747
|
+
export declare type GroupElement = NativeGroupElement;
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* @public
|
|
751
|
+
* An element that contains two or more elements and has positional properties.
|
|
752
|
+
*/
|
|
753
|
+
export declare type GroupElementAtPoint = NativeGroupElementWithBox;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* A set of dimensions with an auto-calculated width.
|
|
757
|
+
*/
|
|
593
758
|
declare type Height = {
|
|
759
|
+
/**
|
|
760
|
+
* Indicates that the width should be auto-calculated.
|
|
761
|
+
*/
|
|
594
762
|
width: "auto";
|
|
763
|
+
/**
|
|
764
|
+
* A height, in pixels.
|
|
765
|
+
*
|
|
766
|
+
* @remarks
|
|
767
|
+
* - The pixels are relative to their container.
|
|
768
|
+
* - Minimum: 0
|
|
769
|
+
* - Maximum: 32767
|
|
770
|
+
*/
|
|
595
771
|
height: number;
|
|
596
772
|
};
|
|
597
773
|
|
|
598
774
|
/**
|
|
599
775
|
* @public
|
|
600
|
-
*
|
|
601
|
-
* app developer.
|
|
776
|
+
* Image element or content to be added to the design at the end of a drag event.
|
|
602
777
|
*/
|
|
603
778
|
export declare type ImageDragConfig = ExternalImageDragConfig;
|
|
604
779
|
|
|
605
780
|
/**
|
|
606
781
|
* @public
|
|
607
|
-
*
|
|
782
|
+
* Image element or content to be added to the design at the end of a drag event.
|
|
608
783
|
*/
|
|
609
784
|
export declare type ImageDragConfigForElement<E extends Element> =
|
|
610
785
|
E extends HTMLImageElement
|
|
@@ -613,36 +788,38 @@ export declare type ImageDragConfigForElement<E extends Element> =
|
|
|
613
788
|
|
|
614
789
|
/**
|
|
615
790
|
* @public
|
|
616
|
-
*
|
|
791
|
+
* An element that renders image content.
|
|
792
|
+
*/
|
|
793
|
+
export declare type ImageElement = NativeImageElement;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* @public
|
|
797
|
+
* An element that renders image content and has positional properties.
|
|
798
|
+
*/
|
|
799
|
+
export declare type ImageElementAtPoint = NativeImageElementWithBox;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* @public
|
|
803
|
+
* Options for adding drag and drop behavior to an `HTMLImageElement`.
|
|
617
804
|
*/
|
|
618
805
|
export declare type ImageElementData = DragCallback & {
|
|
619
806
|
/**
|
|
620
|
-
* The
|
|
807
|
+
* The `HTMLImageElement` to be made draggable.
|
|
621
808
|
*/
|
|
622
809
|
node: HTMLImageElement;
|
|
623
|
-
/**
|
|
624
|
-
* Options for defining the drag-and-drop behavior.
|
|
625
|
-
*
|
|
626
|
-
* @remarks
|
|
627
|
-
* If any of this data is omitted, it's inferred from the `node` property.
|
|
628
|
-
*/
|
|
629
|
-
dragData?:
|
|
630
|
-
| Partial<UserSuppliedImageDragData>
|
|
631
|
-
| (Partial<UserSuppliedVideoDragData> &
|
|
632
|
-
Pick<UserSuppliedVideoDragData, "type" | "resolveVideoRef">);
|
|
633
810
|
};
|
|
634
811
|
|
|
635
812
|
/**
|
|
636
813
|
* @public
|
|
637
|
-
* An image asset that
|
|
814
|
+
* An image asset that fills a path's interior.
|
|
638
815
|
*/
|
|
639
816
|
export declare type ImageFill = {
|
|
640
817
|
/**
|
|
641
|
-
*
|
|
818
|
+
* The type of fill.
|
|
642
819
|
*/
|
|
643
|
-
type: "
|
|
820
|
+
type: "image";
|
|
644
821
|
/**
|
|
645
|
-
* A unique identifier that
|
|
822
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
646
823
|
*/
|
|
647
824
|
ref: ImageRef;
|
|
648
825
|
};
|
|
@@ -665,7 +842,53 @@ export declare function initAppElement<A extends AppElementData>(
|
|
|
665
842
|
|
|
666
843
|
/**
|
|
667
844
|
* @public
|
|
668
|
-
*
|
|
845
|
+
* Options for formatting inline richtext.
|
|
846
|
+
*/
|
|
847
|
+
export declare type InlineFormatting = {
|
|
848
|
+
/**
|
|
849
|
+
* The color of the text as a hex code.
|
|
850
|
+
*
|
|
851
|
+
* @remarks
|
|
852
|
+
* The hex code must include all six characters and be prefixed with a `#` symbol.
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* "#ff0099"
|
|
856
|
+
*/
|
|
857
|
+
color?: string;
|
|
858
|
+
/**
|
|
859
|
+
* The weight (thickness) of the font.
|
|
860
|
+
*
|
|
861
|
+
* @remarks
|
|
862
|
+
* The available font weights depend on the font.
|
|
863
|
+
*
|
|
864
|
+
* @defaultValue "normal"
|
|
865
|
+
*/
|
|
866
|
+
fontWeight?: FontWeight;
|
|
867
|
+
/**
|
|
868
|
+
* The style of the font.
|
|
869
|
+
* @defaultValue "normal"
|
|
870
|
+
*/
|
|
871
|
+
fontStyle?: "normal" | "italic";
|
|
872
|
+
/**
|
|
873
|
+
* The decoration of the text.
|
|
874
|
+
* @defaultValue "none"
|
|
875
|
+
*/
|
|
876
|
+
decoration?: "none" | "underline";
|
|
877
|
+
/**
|
|
878
|
+
* The strikethrough of the text.
|
|
879
|
+
* @defaultValue "none"
|
|
880
|
+
*/
|
|
881
|
+
strikethrough?: "none" | "strikethrough";
|
|
882
|
+
/**
|
|
883
|
+
* An external URL that the text links to.
|
|
884
|
+
*/
|
|
885
|
+
link?: string;
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* @deprecated
|
|
890
|
+
* @public
|
|
891
|
+
* An element that's natively supported by the Canva editor.
|
|
669
892
|
*/
|
|
670
893
|
export declare type NativeElement =
|
|
671
894
|
| NativeImageElement
|
|
@@ -680,15 +903,16 @@ export declare type NativeElement =
|
|
|
680
903
|
* The types of elements an app can add to a user's design.
|
|
681
904
|
*/
|
|
682
905
|
export declare type NativeElementType =
|
|
683
|
-
| "
|
|
684
|
-
| "
|
|
685
|
-
| "
|
|
686
|
-
| "
|
|
687
|
-
| "
|
|
906
|
+
| "image"
|
|
907
|
+
| "embed"
|
|
908
|
+
| "text"
|
|
909
|
+
| "shape"
|
|
910
|
+
| "video";
|
|
688
911
|
|
|
689
912
|
/**
|
|
913
|
+
* @deprecated The type has been superseded by `ElementAtPoint`.
|
|
690
914
|
* @public
|
|
691
|
-
* An element that
|
|
915
|
+
* An element that's natively supported by the Canva editor and has positional properties.
|
|
692
916
|
*/
|
|
693
917
|
export declare type NativeElementWithBox =
|
|
694
918
|
| NativeImageElementWithBox
|
|
@@ -699,37 +923,36 @@ export declare type NativeElementWithBox =
|
|
|
699
923
|
| NativeGroupElementWithBox;
|
|
700
924
|
|
|
701
925
|
/**
|
|
926
|
+
* @deprecated The type has been superseded by `EmbedElement`.
|
|
702
927
|
* @public
|
|
703
|
-
* An element that renders
|
|
928
|
+
* An element that renders rich media, such as a YouTube video.
|
|
704
929
|
*/
|
|
705
930
|
export declare type NativeEmbedElement = {
|
|
706
931
|
/**
|
|
707
932
|
* The type of element.
|
|
708
933
|
*/
|
|
709
|
-
type: "
|
|
934
|
+
type: "embed";
|
|
710
935
|
/**
|
|
711
|
-
* The URL of the
|
|
936
|
+
* The URL of the rich media.
|
|
937
|
+
*
|
|
938
|
+
* @remarks
|
|
939
|
+
* This URL must be supported by the Iframely API.
|
|
712
940
|
*/
|
|
713
941
|
url: string;
|
|
714
942
|
};
|
|
715
943
|
|
|
716
944
|
/**
|
|
945
|
+
* @deprecated The type has been superseded by `EmbedElementAtPoint`.
|
|
717
946
|
* @public
|
|
718
|
-
* An element that renders
|
|
719
|
-
*
|
|
720
|
-
* @remarks
|
|
721
|
-
* This type includes properties for controlling the position and dimensions of the
|
|
722
|
-
* element.
|
|
723
|
-
* It will be positioned and sized relative to its parent container.
|
|
724
|
-
* The parent container may be an app element, or the current page.
|
|
947
|
+
* An element that renders rich media, such as a YouTube video, and has positional properties.
|
|
725
948
|
*/
|
|
726
949
|
export declare type NativeEmbedElementWithBox = {
|
|
727
950
|
/**
|
|
728
951
|
* The type of element.
|
|
729
952
|
*/
|
|
730
|
-
type: "
|
|
953
|
+
type: "embed";
|
|
731
954
|
/**
|
|
732
|
-
* The URL of the
|
|
955
|
+
* The URL of the rich media.
|
|
733
956
|
*
|
|
734
957
|
* @remarks
|
|
735
958
|
* This URL must be supported by the Iframely API.
|
|
@@ -738,54 +961,59 @@ export declare type NativeEmbedElementWithBox = {
|
|
|
738
961
|
} & Box;
|
|
739
962
|
|
|
740
963
|
/**
|
|
964
|
+
* @deprecated The type has been superseded by `GroupElement`.
|
|
741
965
|
* @public
|
|
742
|
-
* An element
|
|
966
|
+
* An element that contains two or more elements.
|
|
743
967
|
*/
|
|
744
968
|
export declare type NativeGroupElement = {
|
|
745
969
|
/**
|
|
746
970
|
* The type of element.
|
|
747
971
|
*/
|
|
748
|
-
type: "
|
|
972
|
+
type: "group";
|
|
749
973
|
/**
|
|
750
|
-
* The
|
|
751
|
-
*
|
|
974
|
+
* The elements to render within the group.
|
|
975
|
+
*
|
|
976
|
+
* @remarks
|
|
977
|
+
* - Each element within a group must have dimensions and a position.
|
|
978
|
+
* - The dimensions and positions are relative to the dimensions and positions of the group.
|
|
752
979
|
*/
|
|
753
980
|
children: NativeSimpleElementWithBox[];
|
|
754
981
|
};
|
|
755
982
|
|
|
756
983
|
/**
|
|
984
|
+
* @deprecated The type has been superseded by `GroupElementAtPoint`.
|
|
757
985
|
* @public
|
|
758
|
-
* An element
|
|
759
|
-
*
|
|
760
|
-
* @remarks
|
|
761
|
-
* This type includes properties for controlling the position and dimensions
|
|
762
|
-
* of the element
|
|
986
|
+
* An element that contains two or more elements and has positional properties.
|
|
763
987
|
*/
|
|
764
988
|
export declare type NativeGroupElementWithBox = {
|
|
765
989
|
/**
|
|
766
990
|
* The type of element.
|
|
767
991
|
*/
|
|
768
|
-
type: "
|
|
992
|
+
type: "group";
|
|
769
993
|
/**
|
|
770
|
-
* The
|
|
771
|
-
*
|
|
994
|
+
* The elements to render within the group.
|
|
995
|
+
*
|
|
996
|
+
* @remarks
|
|
997
|
+
* - Each element within a group must have dimensions and a position.
|
|
998
|
+
* - The dimensions and positions are relative to the dimensions and positions of the group.
|
|
772
999
|
*/
|
|
773
1000
|
children: NativeSimpleElementWithBox[];
|
|
774
1001
|
} & Box;
|
|
775
1002
|
|
|
776
1003
|
/**
|
|
1004
|
+
* @deprecated The type has been superseded by `ImageElement`.
|
|
777
1005
|
* @public
|
|
778
|
-
* An element that renders
|
|
1006
|
+
* An element that renders image content.
|
|
779
1007
|
*/
|
|
780
1008
|
export declare type NativeImageElement = {
|
|
781
1009
|
/**
|
|
782
1010
|
* The type of element.
|
|
783
1011
|
*/
|
|
784
|
-
type: "
|
|
1012
|
+
type: "image";
|
|
785
1013
|
/**
|
|
786
|
-
*
|
|
1014
|
+
* A description of the image content.
|
|
787
1015
|
*/
|
|
788
|
-
altText
|
|
1016
|
+
altText: AltText | undefined;
|
|
789
1017
|
} & (
|
|
790
1018
|
| {
|
|
791
1019
|
/**
|
|
@@ -793,7 +1021,7 @@ export declare type NativeImageElement = {
|
|
|
793
1021
|
*/
|
|
794
1022
|
dataUrl: string;
|
|
795
1023
|
/**
|
|
796
|
-
* A unique identifier that
|
|
1024
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
797
1025
|
*/
|
|
798
1026
|
ref?: never;
|
|
799
1027
|
}
|
|
@@ -803,25 +1031,21 @@ export declare type NativeImageElement = {
|
|
|
803
1031
|
*/
|
|
804
1032
|
dataUrl?: never;
|
|
805
1033
|
/**
|
|
806
|
-
* A unique identifier that
|
|
1034
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
807
1035
|
*/
|
|
808
1036
|
ref: ImageRef;
|
|
809
1037
|
}
|
|
810
1038
|
);
|
|
811
1039
|
|
|
812
1040
|
/**
|
|
1041
|
+
* @deprecated The type has been superseded by `ImageElementAtPoint`.
|
|
813
1042
|
* @public
|
|
814
|
-
* An element that renders
|
|
815
|
-
*
|
|
816
|
-
* @remarks
|
|
817
|
-
* This type includes properties for controlling the position and dimensions
|
|
818
|
-
* of the element.
|
|
819
|
-
* It will be positioned and sized relative to its parent container.
|
|
820
|
-
* The parent container may be an app element, or the current page.
|
|
1043
|
+
* An element that renders image content and has positional properties.
|
|
821
1044
|
*/
|
|
822
1045
|
export declare type NativeImageElementWithBox = NativeImageElement & Box;
|
|
823
1046
|
|
|
824
1047
|
/**
|
|
1048
|
+
* @deprecated The type has been superseded by `ShapeElement`.
|
|
825
1049
|
* @public
|
|
826
1050
|
* An element that renders a vector shape.
|
|
827
1051
|
*/
|
|
@@ -829,55 +1053,51 @@ export declare type NativeShapeElement = {
|
|
|
829
1053
|
/**
|
|
830
1054
|
* The type of element.
|
|
831
1055
|
*/
|
|
832
|
-
type: "
|
|
1056
|
+
type: "shape";
|
|
833
1057
|
/**
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
* @remarks
|
|
837
|
-
* This is similar to the `viewBox` attribute of the <svg> element.
|
|
1058
|
+
* Options for configuring the scale and cropping of the shape.
|
|
838
1059
|
*/
|
|
839
1060
|
viewBox: ShapeViewBox;
|
|
840
1061
|
/**
|
|
841
|
-
* The paths that define the
|
|
1062
|
+
* The paths that define the structure of the shape.
|
|
842
1063
|
*
|
|
843
1064
|
* @remarks
|
|
844
|
-
* There must be between 1 and 30 paths.
|
|
845
|
-
*
|
|
1065
|
+
* - There must be between 1 and 30 paths (inclusive).
|
|
1066
|
+
* - The maximum combined size of all paths must not exceed 2kb.
|
|
1067
|
+
* - The maximum number of unique fill colors across all paths is 6.
|
|
846
1068
|
*/
|
|
847
1069
|
paths: ShapePath[];
|
|
848
1070
|
};
|
|
849
1071
|
|
|
850
1072
|
/**
|
|
1073
|
+
* @deprecated The type has been superseded by `ShapeElementAtPoint`.
|
|
851
1074
|
* @public
|
|
852
|
-
* An element that renders a vector shape.
|
|
853
|
-
*
|
|
854
|
-
* @remarks
|
|
855
|
-
* This type includes properties for controlling the position and dimensions of the
|
|
856
|
-
* element.
|
|
857
|
-
* It will be positioned and sized relative to its parent container.
|
|
858
|
-
* The parent container may be an app element, or the current page.
|
|
1075
|
+
* An element that renders a vector shape and has positional properties.
|
|
859
1076
|
*/
|
|
860
1077
|
export declare type NativeShapeElementWithBox = {
|
|
861
1078
|
/**
|
|
862
1079
|
* The type of element.
|
|
863
1080
|
*/
|
|
864
|
-
type: "
|
|
1081
|
+
type: "shape";
|
|
865
1082
|
/**
|
|
866
|
-
*
|
|
867
|
-
*
|
|
868
|
-
* @remarks
|
|
869
|
-
* This is similar to the `viewBox` attribute of the <svg> element.
|
|
1083
|
+
* Options for configuring the scale and cropping of a shape.
|
|
870
1084
|
*/
|
|
871
1085
|
viewBox: ShapeViewBox;
|
|
872
1086
|
/**
|
|
873
|
-
* The paths that define the
|
|
1087
|
+
* The paths that define the structure of the shape.
|
|
1088
|
+
*
|
|
1089
|
+
* @remarks
|
|
1090
|
+
* - There must be between 1 and 30 paths (inclusive).
|
|
1091
|
+
* - The maximum combined size of all paths must not exceed 2kb.
|
|
1092
|
+
* - The maximum number of unique fill colors across all paths is 6.
|
|
874
1093
|
*/
|
|
875
1094
|
paths: ShapePath[];
|
|
876
1095
|
} & Box;
|
|
877
1096
|
|
|
878
1097
|
/**
|
|
1098
|
+
* @deprecated The type has been superseded by `GroupContentAtPoint`.
|
|
879
1099
|
* @public
|
|
880
|
-
* An element that
|
|
1100
|
+
* An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
|
|
881
1101
|
*/
|
|
882
1102
|
export declare type NativeSimpleElementWithBox = Exclude<
|
|
883
1103
|
NativeElementWithBox,
|
|
@@ -885,106 +1105,104 @@ export declare type NativeSimpleElementWithBox = Exclude<
|
|
|
885
1105
|
>;
|
|
886
1106
|
|
|
887
1107
|
/**
|
|
1108
|
+
* @deprecated The type has been superseded by `TextElement`.
|
|
888
1109
|
* @public
|
|
889
|
-
* An element that renders text.
|
|
1110
|
+
* An element that renders text content.
|
|
890
1111
|
*/
|
|
891
1112
|
export declare type NativeTextElement = {
|
|
892
1113
|
/**
|
|
893
1114
|
* The type of element.
|
|
894
1115
|
*/
|
|
895
|
-
type: "
|
|
1116
|
+
type: "text";
|
|
896
1117
|
/**
|
|
897
|
-
* The text
|
|
898
|
-
*
|
|
1118
|
+
* The text content.
|
|
1119
|
+
*
|
|
1120
|
+
* @remarks
|
|
1121
|
+
* Only the first element in this array is used.
|
|
899
1122
|
*/
|
|
900
1123
|
children: string[];
|
|
901
1124
|
} & TextAttributes;
|
|
902
1125
|
|
|
903
1126
|
/**
|
|
1127
|
+
* @deprecated The type has been superseded by `TextElementAtPoint`.
|
|
904
1128
|
* @public
|
|
905
|
-
* An element that renders text.
|
|
906
|
-
*
|
|
907
|
-
* @remarks
|
|
908
|
-
* This type includes properties for controlling the position and dimensions of the
|
|
909
|
-
* element.
|
|
910
|
-
* It will be positioned and sized relative to its parent container.
|
|
911
|
-
* The parent container may be an app element, or the current page.
|
|
1129
|
+
* An element that renders text content and has positional properties.
|
|
912
1130
|
*/
|
|
913
1131
|
export declare type NativeTextElementWithBox = {
|
|
914
1132
|
/**
|
|
915
1133
|
* The type of element.
|
|
916
1134
|
*/
|
|
917
|
-
type: "
|
|
1135
|
+
type: "text";
|
|
918
1136
|
/**
|
|
919
|
-
* The text
|
|
1137
|
+
* The text content.
|
|
920
1138
|
*
|
|
921
1139
|
* @remarks
|
|
922
|
-
*
|
|
923
|
-
* only one item is supported.
|
|
1140
|
+
* Only the first element in this array is used.
|
|
924
1141
|
*/
|
|
925
1142
|
children: [string];
|
|
926
1143
|
/**
|
|
927
|
-
* The width of the element
|
|
1144
|
+
* The width of the element, in pixels.
|
|
1145
|
+
*
|
|
1146
|
+
* @remarks
|
|
1147
|
+
* - Minimum: 0
|
|
1148
|
+
* - Maximum: 32767
|
|
928
1149
|
*/
|
|
929
1150
|
width?: number;
|
|
930
1151
|
/**
|
|
931
|
-
* The distance from the top edge of the container.
|
|
1152
|
+
* The distance from the top edge of the container, in pixels.
|
|
932
1153
|
*
|
|
933
1154
|
* @remarks
|
|
934
|
-
*
|
|
935
|
-
*
|
|
1155
|
+
* - Minimum: -32768
|
|
1156
|
+
* - Maximum: 32767
|
|
936
1157
|
*/
|
|
937
1158
|
top: number;
|
|
938
1159
|
/**
|
|
939
|
-
* The distance from the left edge of the container.
|
|
1160
|
+
* The distance from the left edge of the container, in pixels.
|
|
940
1161
|
*
|
|
941
1162
|
* @remarks
|
|
942
|
-
*
|
|
943
|
-
*
|
|
1163
|
+
* - Minimum: -32768
|
|
1164
|
+
* - Maximum: 32767
|
|
944
1165
|
*/
|
|
945
1166
|
left: number;
|
|
946
1167
|
/**
|
|
947
1168
|
* The rotation of the element, in degrees.
|
|
948
1169
|
*
|
|
949
1170
|
* @remarks
|
|
950
|
-
*
|
|
1171
|
+
* - Minimum: -180
|
|
1172
|
+
* - Maximum: 180
|
|
951
1173
|
*/
|
|
952
1174
|
rotation?: number;
|
|
953
1175
|
} & TextAttributes;
|
|
954
1176
|
|
|
955
1177
|
/**
|
|
1178
|
+
* @deprecated The type has been superseded by `VideoElement`.
|
|
956
1179
|
* @public
|
|
957
|
-
* An element that renders
|
|
1180
|
+
* An element that renders video content.
|
|
958
1181
|
*/
|
|
959
1182
|
export declare type NativeVideoElement = {
|
|
960
1183
|
/**
|
|
961
1184
|
* The type of element.
|
|
962
1185
|
*/
|
|
963
|
-
type: "
|
|
1186
|
+
type: "video";
|
|
964
1187
|
/**
|
|
965
|
-
* A unique identifier that
|
|
1188
|
+
* A unique identifier that points to a video asset in Canva's backend.
|
|
966
1189
|
*/
|
|
967
1190
|
ref: VideoRef;
|
|
968
1191
|
/**
|
|
969
|
-
*
|
|
1192
|
+
* A description of the video content.
|
|
970
1193
|
*/
|
|
971
|
-
altText
|
|
1194
|
+
altText: AltText | undefined;
|
|
972
1195
|
};
|
|
973
1196
|
|
|
974
1197
|
/**
|
|
1198
|
+
* @deprecated The type has been superseded by `VideoElementAtPoint`.
|
|
975
1199
|
* @public
|
|
976
|
-
* An element that renders
|
|
977
|
-
*
|
|
978
|
-
* @remarks
|
|
979
|
-
* This type includes properties for controlling the position and dimensions
|
|
980
|
-
* of the element.
|
|
981
|
-
* It will be positioned and sized relative to its parent container.
|
|
982
|
-
* The parent container may be an app element, or the current page.
|
|
1200
|
+
* An element that renders video content and has positional properties.
|
|
983
1201
|
*/
|
|
984
1202
|
export declare type NativeVideoElementWithBox = NativeVideoElement & Box;
|
|
985
1203
|
|
|
986
1204
|
/**
|
|
987
|
-
*
|
|
1205
|
+
* An object primitive data type that can be used in app element data.
|
|
988
1206
|
*/
|
|
989
1207
|
declare type ObjectPrimitive = Boolean | String;
|
|
990
1208
|
|
|
@@ -996,23 +1214,30 @@ export declare const overlay: DesignOverlay;
|
|
|
996
1214
|
|
|
997
1215
|
/**
|
|
998
1216
|
* @public
|
|
999
|
-
* Information about whether
|
|
1217
|
+
* Information about whether or not an overlay can be opened for the specified target.
|
|
1000
1218
|
*/
|
|
1001
1219
|
export declare type OverlayOpenableEvent<Target extends OverlayTarget> = {
|
|
1002
1220
|
/**
|
|
1003
|
-
*
|
|
1221
|
+
* Information about whether or not an overlay can be opened or not for a selected image.
|
|
1004
1222
|
*/
|
|
1005
1223
|
["image_selection"]:
|
|
1006
1224
|
| OverlayUnopenableEvent
|
|
1007
1225
|
| {
|
|
1226
|
+
/**
|
|
1227
|
+
* Indicates that the overlay can be opened for the selected image.
|
|
1228
|
+
*/
|
|
1008
1229
|
canOpen: true;
|
|
1009
1230
|
/**
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
* @remarks
|
|
1013
|
-
* `launchParameters` specifies the type of data that are provided to an app process at its launch
|
|
1231
|
+
* Opens an overlay for the selected image.
|
|
1232
|
+
* @param opts - Options for launching the process associated with the overlay.
|
|
1014
1233
|
*/
|
|
1015
1234
|
readonly open: (options: {
|
|
1235
|
+
/**
|
|
1236
|
+
* Parameters to pass to the overlay when it opens.
|
|
1237
|
+
*
|
|
1238
|
+
* @remarks
|
|
1239
|
+
* This can be any type of structured data.
|
|
1240
|
+
*/
|
|
1016
1241
|
launchParameters?: any;
|
|
1017
1242
|
}) => Promise<AppProcessId>;
|
|
1018
1243
|
};
|
|
@@ -1020,16 +1245,22 @@ export declare type OverlayOpenableEvent<Target extends OverlayTarget> = {
|
|
|
1020
1245
|
|
|
1021
1246
|
/**
|
|
1022
1247
|
* @public
|
|
1023
|
-
*
|
|
1248
|
+
* An entity that an overlay can be opened for.
|
|
1024
1249
|
*/
|
|
1025
1250
|
export declare type OverlayTarget = "image_selection";
|
|
1026
1251
|
|
|
1027
1252
|
/**
|
|
1028
1253
|
* @public
|
|
1029
|
-
* Information about
|
|
1254
|
+
* Information about an overlay that can't be opened for the specified target.
|
|
1030
1255
|
*/
|
|
1031
1256
|
declare type OverlayUnopenableEvent = {
|
|
1257
|
+
/**
|
|
1258
|
+
* Indicates that the overlay can't be opened for the specified target.
|
|
1259
|
+
*/
|
|
1032
1260
|
canOpen: false;
|
|
1261
|
+
/**
|
|
1262
|
+
* Indicates the reason the overlay can't be opened for the specified target.
|
|
1263
|
+
*/
|
|
1033
1264
|
reason: string;
|
|
1034
1265
|
};
|
|
1035
1266
|
|
|
@@ -1041,24 +1272,30 @@ export declare type PageBackgroundFill = Pick<Fill, "asset" | "color">;
|
|
|
1041
1272
|
|
|
1042
1273
|
/**
|
|
1043
1274
|
* @public
|
|
1044
|
-
*
|
|
1275
|
+
* Information about a page.
|
|
1045
1276
|
*/
|
|
1046
1277
|
export declare type PageContext = {
|
|
1047
1278
|
/**
|
|
1048
|
-
*
|
|
1279
|
+
* The dimensions of the page, in pixels.
|
|
1049
1280
|
*
|
|
1050
1281
|
* @remarks
|
|
1051
|
-
* This
|
|
1282
|
+
* This may be `undefined` because some types of pages don't have dimensions, such as whiteboards.
|
|
1052
1283
|
*/
|
|
1053
1284
|
dimensions: PageDimensions | undefined;
|
|
1054
1285
|
};
|
|
1055
1286
|
|
|
1056
1287
|
/**
|
|
1057
1288
|
* @public
|
|
1058
|
-
*
|
|
1289
|
+
* A set of page dimensions, in pixels.
|
|
1059
1290
|
*/
|
|
1060
1291
|
export declare type PageDimensions = {
|
|
1292
|
+
/**
|
|
1293
|
+
* The width of the page, in pixels.
|
|
1294
|
+
*/
|
|
1061
1295
|
width: number;
|
|
1296
|
+
/**
|
|
1297
|
+
* The height of the page, in pixels.
|
|
1298
|
+
*/
|
|
1062
1299
|
height: number;
|
|
1063
1300
|
};
|
|
1064
1301
|
|
|
@@ -1068,59 +1305,73 @@ export declare type PageDimensions = {
|
|
|
1068
1305
|
*/
|
|
1069
1306
|
export declare type PathStroke = {
|
|
1070
1307
|
/**
|
|
1071
|
-
* The weight of the stroke.
|
|
1072
|
-
|
|
1308
|
+
* The weight (thickness) of the stroke.
|
|
1309
|
+
*
|
|
1310
|
+
* @remarks
|
|
1311
|
+
* - Minimum: 0
|
|
1312
|
+
* - Maximum: 100
|
|
1313
|
+
*/
|
|
1073
1314
|
weight: number;
|
|
1074
1315
|
/**
|
|
1075
1316
|
* The color of the stroke as a hex code.
|
|
1076
1317
|
*
|
|
1077
1318
|
* @remarks
|
|
1078
|
-
* The hex code must include all six characters and be prefixed with a
|
|
1319
|
+
* The hex code must include all six characters and be prefixed with a `#` symbol.
|
|
1320
|
+
*
|
|
1321
|
+
* @example
|
|
1322
|
+
* "#ff0099"
|
|
1079
1323
|
*/
|
|
1080
1324
|
color: string;
|
|
1081
1325
|
/**
|
|
1082
|
-
* The alignment of the stroke.
|
|
1326
|
+
* The alignment of the stroke.
|
|
1083
1327
|
*/
|
|
1084
1328
|
strokeAlign: "inset";
|
|
1085
1329
|
};
|
|
1086
1330
|
|
|
1087
1331
|
/**
|
|
1088
1332
|
* @public
|
|
1089
|
-
*
|
|
1333
|
+
* A position, set of dimensions, and rotation.
|
|
1090
1334
|
*/
|
|
1091
1335
|
export declare type Placement = Position & (WidthAndHeight | Width | Height);
|
|
1092
1336
|
|
|
1337
|
+
/**
|
|
1338
|
+
* @deprecated
|
|
1339
|
+
* A position and rotation.
|
|
1340
|
+
*/
|
|
1093
1341
|
declare type Position = {
|
|
1094
1342
|
/**
|
|
1095
|
-
* The distance from the top edge of the container.
|
|
1343
|
+
* The distance from the top edge of the container, in pixels.
|
|
1096
1344
|
*
|
|
1097
1345
|
* @remarks
|
|
1098
|
-
*
|
|
1099
|
-
*
|
|
1346
|
+
* - The pixels are relative to their container.
|
|
1347
|
+
* - Minimum: -32768
|
|
1348
|
+
* - Maximum: 32767
|
|
1100
1349
|
*/
|
|
1101
1350
|
top: number;
|
|
1102
1351
|
/**
|
|
1103
|
-
* The distance from the left edge of the container.
|
|
1352
|
+
* The distance from the left edge of the container, in pixels.
|
|
1104
1353
|
*
|
|
1105
1354
|
* @remarks
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1355
|
+
* - The pixels are relative to their container.
|
|
1356
|
+
* - Minimum: -32768
|
|
1357
|
+
* - Maximum: 32767
|
|
1108
1358
|
*/
|
|
1109
1359
|
left: number;
|
|
1110
1360
|
/**
|
|
1111
|
-
*
|
|
1361
|
+
* A rotation, in degrees.
|
|
1112
1362
|
*
|
|
1113
1363
|
* @remarks
|
|
1114
|
-
*
|
|
1364
|
+
* - Minimum: -180
|
|
1365
|
+
* - Maximum: 180
|
|
1115
1366
|
*/
|
|
1116
1367
|
rotation?: number;
|
|
1117
1368
|
};
|
|
1118
1369
|
|
|
1119
1370
|
/**
|
|
1120
|
-
*
|
|
1371
|
+
* A primitive data type that can be used in app element data.
|
|
1121
1372
|
*
|
|
1122
1373
|
* @remarks
|
|
1123
|
-
* All
|
|
1374
|
+
* All primitive data types are supported except for symbols and bigints.
|
|
1124
1375
|
*/
|
|
1125
1376
|
declare type Primitive = undefined | null | number | boolean | string;
|
|
1126
1377
|
|
|
@@ -1129,9 +1380,148 @@ declare type Primitive = undefined | null | number | boolean | string;
|
|
|
1129
1380
|
* Exports the user's design as one or more static files.
|
|
1130
1381
|
* @param request - The request object containing configurations of the design export.
|
|
1131
1382
|
*/
|
|
1132
|
-
export declare
|
|
1383
|
+
export declare const requestExport: (
|
|
1133
1384
|
request: ExportRequest
|
|
1134
|
-
)
|
|
1385
|
+
) => Promise<ExportResponse>;
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* @public
|
|
1389
|
+
* An element that renders richtext content.
|
|
1390
|
+
*/
|
|
1391
|
+
export declare type RichtextElement = {
|
|
1392
|
+
/**
|
|
1393
|
+
* The type of element.
|
|
1394
|
+
*/
|
|
1395
|
+
type: "richtext";
|
|
1396
|
+
/**
|
|
1397
|
+
* The richtext content.
|
|
1398
|
+
*/
|
|
1399
|
+
range: RichtextRange;
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* @public
|
|
1404
|
+
* An element that renders richtext content.
|
|
1405
|
+
*
|
|
1406
|
+
* @remarks
|
|
1407
|
+
* This type includes properties for controlling the position and dimensions of the
|
|
1408
|
+
* element.
|
|
1409
|
+
* It will be positioned and sized relative to its parent container.
|
|
1410
|
+
* The parent container may be an app element, or the current page.
|
|
1411
|
+
*/
|
|
1412
|
+
export declare type RichtextElementAtPoint = RichtextElement & TextBox;
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* @public
|
|
1416
|
+
* Options for formatting richtext.
|
|
1417
|
+
*/
|
|
1418
|
+
export declare type RichtextFormatting = InlineFormatting & {
|
|
1419
|
+
/**
|
|
1420
|
+
* @public
|
|
1421
|
+
* A unique identifier that points to a font asset in Canva's backend.
|
|
1422
|
+
*/
|
|
1423
|
+
fontRef?: FontRef;
|
|
1424
|
+
/**
|
|
1425
|
+
* The size of the text, in pixels.
|
|
1426
|
+
*
|
|
1427
|
+
* @remarks
|
|
1428
|
+
* - In the Canva editor, this number is shown as points (pts), not pixels.
|
|
1429
|
+
* - Minimum: 1
|
|
1430
|
+
* - Maximum: 100
|
|
1431
|
+
*/
|
|
1432
|
+
fontSize?: number;
|
|
1433
|
+
/**
|
|
1434
|
+
* The alignment of the text.
|
|
1435
|
+
* @defaultValue "start"
|
|
1436
|
+
*/
|
|
1437
|
+
textAlign?: "start" | "center" | "end" | "justify";
|
|
1438
|
+
/**
|
|
1439
|
+
* The list indentation level of the paragraph.
|
|
1440
|
+
*/
|
|
1441
|
+
listLevel?: number;
|
|
1442
|
+
/**
|
|
1443
|
+
* The appearance of list item markers.
|
|
1444
|
+
*
|
|
1445
|
+
* @remarks
|
|
1446
|
+
* This property only has an effect if `listLevel` is greater than 0.
|
|
1447
|
+
*
|
|
1448
|
+
* @defaultValue "none"
|
|
1449
|
+
*/
|
|
1450
|
+
listMarker?:
|
|
1451
|
+
| "none"
|
|
1452
|
+
| "disc"
|
|
1453
|
+
| "circle"
|
|
1454
|
+
| "square"
|
|
1455
|
+
| "decimal"
|
|
1456
|
+
| "lower-alpha"
|
|
1457
|
+
| "lower-roman"
|
|
1458
|
+
| "checked"
|
|
1459
|
+
| "unchecked";
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* @public
|
|
1464
|
+
* Provides methods for interacting with a range of formatted text.
|
|
1465
|
+
*/
|
|
1466
|
+
export declare type RichtextRange = {
|
|
1467
|
+
/**
|
|
1468
|
+
* Formats all of the paragraphs that overlap the given bounds.
|
|
1469
|
+
*
|
|
1470
|
+
* @param bounds - The segment of the range on which to apply the formatting.
|
|
1471
|
+
* @param formatting - The formatting to apply to the paragraph(s).
|
|
1472
|
+
*
|
|
1473
|
+
* @remarks
|
|
1474
|
+
* - The `\n` character indicates the end of a paragraph.
|
|
1475
|
+
* - All paragraphs that overlap the provided bounds will be formatted in their entirety.
|
|
1476
|
+
*
|
|
1477
|
+
*/
|
|
1478
|
+
formatParagraph(bounds: Bounds, formatting: RichtextFormatting): void;
|
|
1479
|
+
/**
|
|
1480
|
+
* Formats a region of text with inline formatting properties.
|
|
1481
|
+
*
|
|
1482
|
+
* @param bounds - The segment of the range on which to apply the formatting.
|
|
1483
|
+
* @param formatting - The formatting to apply to the text.
|
|
1484
|
+
*/
|
|
1485
|
+
formatText(bounds: Bounds, formatting: InlineFormatting): void;
|
|
1486
|
+
/**
|
|
1487
|
+
* Appends the specified characters to the end of the range.
|
|
1488
|
+
*
|
|
1489
|
+
* @param characters - The characters to append to the richtext range.
|
|
1490
|
+
* @param fo -
|
|
1491
|
+
*/
|
|
1492
|
+
appendText(
|
|
1493
|
+
characters: string,
|
|
1494
|
+
formatting?: InlineFormatting
|
|
1495
|
+
): {
|
|
1496
|
+
bounds: Bounds;
|
|
1497
|
+
};
|
|
1498
|
+
/**
|
|
1499
|
+
* Replaces a region of text with the specified characters.
|
|
1500
|
+
*
|
|
1501
|
+
* @param bounds - The segment of the range to replace.
|
|
1502
|
+
* @param characters - The replacement characters.
|
|
1503
|
+
* @param formatting - The formatting to apply to the replaced text.
|
|
1504
|
+
*/
|
|
1505
|
+
replaceText(
|
|
1506
|
+
bounds: Bounds,
|
|
1507
|
+
characters: string,
|
|
1508
|
+
formatting?: InlineFormatting
|
|
1509
|
+
): {
|
|
1510
|
+
/**
|
|
1511
|
+
* The bounds of the replacement characters within the updated range.
|
|
1512
|
+
*/
|
|
1513
|
+
bounds: Bounds;
|
|
1514
|
+
};
|
|
1515
|
+
/**
|
|
1516
|
+
* Returns the current state of the richtext as plaintext.
|
|
1517
|
+
*/
|
|
1518
|
+
readPlaintext(): string;
|
|
1519
|
+
/**
|
|
1520
|
+
* Returns the current state of the richtext as one or more text regions.
|
|
1521
|
+
* Each region is an object that contains the text content and its formatting.
|
|
1522
|
+
*/
|
|
1523
|
+
readTextRegions(): TextRegion[];
|
|
1524
|
+
};
|
|
1135
1525
|
|
|
1136
1526
|
/**
|
|
1137
1527
|
* @public
|
|
@@ -1176,29 +1566,55 @@ export declare interface SelectionEvent<Scope extends SelectionScope> {
|
|
|
1176
1566
|
|
|
1177
1567
|
/**
|
|
1178
1568
|
* @public
|
|
1179
|
-
*
|
|
1569
|
+
* Information about a user's selection.
|
|
1180
1570
|
*/
|
|
1181
|
-
export declare
|
|
1571
|
+
export declare interface SelectionEvent<Scope extends SelectionScope> {
|
|
1572
|
+
/**
|
|
1573
|
+
* The type of content.
|
|
1574
|
+
*/
|
|
1575
|
+
readonly scope: Scope;
|
|
1576
|
+
/**
|
|
1577
|
+
* The number of content items in the user's selection.
|
|
1578
|
+
*/
|
|
1579
|
+
readonly count: number;
|
|
1580
|
+
/**
|
|
1581
|
+
* Returns a snapshot of the content in the user's selection.
|
|
1582
|
+
*
|
|
1583
|
+
* @remarks
|
|
1584
|
+
* The snapshot is known as the *draft*.
|
|
1585
|
+
*/
|
|
1586
|
+
read(): Promise<ContentDraft<SelectionValue<Scope>>>;
|
|
1587
|
+
}
|
|
1182
1588
|
|
|
1183
1589
|
/**
|
|
1184
1590
|
* @public
|
|
1185
|
-
*
|
|
1591
|
+
* A type of content that supports selection events.
|
|
1592
|
+
*/
|
|
1593
|
+
export declare type SelectionScope =
|
|
1594
|
+
| "plaintext"
|
|
1595
|
+
| "image"
|
|
1596
|
+
| "video"
|
|
1597
|
+
| "richtext";
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* @public
|
|
1601
|
+
* A piece of selected content.
|
|
1186
1602
|
*
|
|
1187
1603
|
* @remarks
|
|
1188
|
-
* The
|
|
1604
|
+
* The available properties depend on the type (scope) of content.
|
|
1189
1605
|
*/
|
|
1190
1606
|
export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
1191
1607
|
/**
|
|
1192
|
-
*
|
|
1608
|
+
* A selected range of plaintext.
|
|
1193
1609
|
*/
|
|
1194
1610
|
["plaintext"]: {
|
|
1195
1611
|
/**
|
|
1196
|
-
* The text content
|
|
1612
|
+
* The text content.
|
|
1197
1613
|
*/
|
|
1198
1614
|
text: string;
|
|
1199
1615
|
};
|
|
1200
1616
|
/**
|
|
1201
|
-
*
|
|
1617
|
+
* A selected image.
|
|
1202
1618
|
*/
|
|
1203
1619
|
["image"]: {
|
|
1204
1620
|
/**
|
|
@@ -1207,7 +1623,7 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1207
1623
|
ref: ImageRef;
|
|
1208
1624
|
};
|
|
1209
1625
|
/**
|
|
1210
|
-
*
|
|
1626
|
+
* A selected video.
|
|
1211
1627
|
*/
|
|
1212
1628
|
["video"]: {
|
|
1213
1629
|
/**
|
|
@@ -1215,6 +1631,10 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1215
1631
|
*/
|
|
1216
1632
|
ref: VideoRef;
|
|
1217
1633
|
};
|
|
1634
|
+
/**
|
|
1635
|
+
* A selected range of formatted text.
|
|
1636
|
+
*/
|
|
1637
|
+
["richtext"]: RichtextRange;
|
|
1218
1638
|
}[Scope];
|
|
1219
1639
|
|
|
1220
1640
|
/**
|
|
@@ -1222,29 +1642,39 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1222
1642
|
* Updates the background of the user's current page. The background can be a solid color,
|
|
1223
1643
|
* an image or a video.
|
|
1224
1644
|
*/
|
|
1225
|
-
export declare
|
|
1645
|
+
export declare const setCurrentPageBackground: (
|
|
1226
1646
|
opts: PageBackgroundFill
|
|
1227
|
-
)
|
|
1647
|
+
) => Promise<void>;
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* @public
|
|
1651
|
+
* An element that renders a vector shape.
|
|
1652
|
+
*/
|
|
1653
|
+
export declare type ShapeElement = NativeShapeElement;
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* @public
|
|
1657
|
+
* An element that renders a vector shape and has positional properties.
|
|
1658
|
+
*/
|
|
1659
|
+
export declare type ShapeElementAtPoint = NativeShapeElementWithBox;
|
|
1228
1660
|
|
|
1229
1661
|
/**
|
|
1230
1662
|
* @public
|
|
1231
|
-
* A path that defines the
|
|
1663
|
+
* A path that defines the structure of a shape element.
|
|
1232
1664
|
*/
|
|
1233
1665
|
export declare type ShapePath = {
|
|
1234
1666
|
/**
|
|
1235
1667
|
* The shape of the path.
|
|
1236
1668
|
*
|
|
1237
1669
|
* @remarks
|
|
1238
|
-
* This
|
|
1239
|
-
* with some limitations.
|
|
1670
|
+
* This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
|
|
1240
1671
|
*
|
|
1241
|
-
* The path must
|
|
1242
|
-
*
|
|
1243
|
-
* -
|
|
1244
|
-
* -
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
* coordinate match the first coordinate
|
|
1672
|
+
* - The path must start with an M command.
|
|
1673
|
+
* - The path must not have more than one M command.
|
|
1674
|
+
* - The path must not use the Q command.
|
|
1675
|
+
* - The path must be closed, either by:
|
|
1676
|
+
* - Using a Z command at the end of the path
|
|
1677
|
+
* - Having the last coordinate match the first coordinate
|
|
1248
1678
|
*/
|
|
1249
1679
|
d: string;
|
|
1250
1680
|
/**
|
|
@@ -1259,308 +1689,269 @@ export declare type ShapePath = {
|
|
|
1259
1689
|
|
|
1260
1690
|
/**
|
|
1261
1691
|
* @public
|
|
1262
|
-
*
|
|
1692
|
+
* Options for configuring the scale and cropping of a shape.
|
|
1263
1693
|
*
|
|
1264
1694
|
* @remarks
|
|
1265
|
-
* This is similar to the `viewBox` attribute of
|
|
1695
|
+
* This is similar to the `viewBox` attribute of an `SVGElement`.
|
|
1266
1696
|
*/
|
|
1267
1697
|
export declare type ShapeViewBox = {
|
|
1268
1698
|
/**
|
|
1269
|
-
* The distance of the shape from the top edge of the element.
|
|
1699
|
+
* The distance of the shape from the top edge of the element, in pixels.
|
|
1270
1700
|
*/
|
|
1271
1701
|
top: number;
|
|
1272
1702
|
/**
|
|
1273
|
-
* The distance of the shape from the left edge of the element.
|
|
1703
|
+
* The distance of the shape from the left edge of the element, in pixels.
|
|
1274
1704
|
*/
|
|
1275
1705
|
left: number;
|
|
1276
1706
|
/**
|
|
1277
|
-
* The width of the view box.
|
|
1707
|
+
* The width of the view box, in pixels.
|
|
1278
1708
|
*/
|
|
1279
1709
|
width: number;
|
|
1280
1710
|
/**
|
|
1281
|
-
* The height of the view box.
|
|
1711
|
+
* The height of the view box, in pixels.
|
|
1282
1712
|
*/
|
|
1283
1713
|
height: number;
|
|
1284
1714
|
};
|
|
1285
1715
|
|
|
1286
1716
|
/**
|
|
1287
1717
|
* @public
|
|
1288
|
-
*
|
|
1718
|
+
* An element that renders a table.
|
|
1719
|
+
*/
|
|
1720
|
+
export declare type TableElement = {
|
|
1721
|
+
/**
|
|
1722
|
+
* The type of element.
|
|
1723
|
+
*/
|
|
1724
|
+
type: "table";
|
|
1725
|
+
/**
|
|
1726
|
+
* The rows of the table.
|
|
1727
|
+
*/
|
|
1728
|
+
rows: {
|
|
1729
|
+
/**
|
|
1730
|
+
* The cells (columns) of the row.
|
|
1731
|
+
*
|
|
1732
|
+
* @remarks
|
|
1733
|
+
* Each row must have the same number of cells.
|
|
1734
|
+
*/
|
|
1735
|
+
cells: (Cell | null | undefined)[];
|
|
1736
|
+
}[];
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* @public
|
|
1741
|
+
* Options for configuring the appearance of text.
|
|
1289
1742
|
*/
|
|
1290
1743
|
export declare type TextAttributes = {
|
|
1291
1744
|
/**
|
|
1292
1745
|
* The size of the text.
|
|
1293
1746
|
*
|
|
1294
1747
|
* @remarks
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1748
|
+
* - Minimum: 1
|
|
1749
|
+
* - Maximum: 100
|
|
1750
|
+
*
|
|
1751
|
+
* @defaultValue 16
|
|
1297
1752
|
*/
|
|
1298
1753
|
fontSize?: number;
|
|
1299
1754
|
/**
|
|
1300
1755
|
* The alignment of the text.
|
|
1301
|
-
* @defaultValue
|
|
1756
|
+
* @defaultValue "start"
|
|
1302
1757
|
*/
|
|
1303
1758
|
textAlign?: "start" | "center" | "end" | "justify";
|
|
1304
1759
|
/**
|
|
1305
1760
|
* The color of the text as a hex code.
|
|
1306
1761
|
*
|
|
1307
1762
|
* @remarks
|
|
1308
|
-
* The hex code must include all six characters and be prefixed with a
|
|
1309
|
-
*
|
|
1763
|
+
* The hex code must include all six characters and be prefixed with a `#` symbol.
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* "#ff0099"
|
|
1310
1767
|
*/
|
|
1311
1768
|
color?: string;
|
|
1312
1769
|
/**
|
|
1313
1770
|
* @public
|
|
1314
|
-
* A
|
|
1771
|
+
* A unique identifier that points to a font asset in Canva's backend.
|
|
1315
1772
|
*/
|
|
1316
1773
|
fontRef?: FontRef;
|
|
1317
1774
|
/**
|
|
1318
|
-
* The weight of the font.
|
|
1319
|
-
* @defaultValue
|
|
1775
|
+
* The weight (thickness) of the font.
|
|
1776
|
+
* @defaultValue "normal"
|
|
1320
1777
|
*/
|
|
1321
1778
|
fontWeight?: FontWeight;
|
|
1322
1779
|
/**
|
|
1323
1780
|
* The style of the font.
|
|
1324
|
-
* @defaultValue
|
|
1781
|
+
* @defaultValue "normal"
|
|
1325
1782
|
*/
|
|
1326
1783
|
fontStyle?: "normal" | "italic";
|
|
1327
1784
|
/**
|
|
1328
1785
|
* The decoration of the font.
|
|
1329
|
-
* @defaultValue
|
|
1786
|
+
* @defaultValue "none"
|
|
1330
1787
|
*/
|
|
1331
1788
|
decoration?: "none" | "underline";
|
|
1332
1789
|
};
|
|
1333
1790
|
|
|
1334
1791
|
/**
|
|
1335
1792
|
* @public
|
|
1336
|
-
*
|
|
1793
|
+
* The dimensions, position, and rotation of a text element.
|
|
1794
|
+
*/
|
|
1795
|
+
declare type TextBox = {
|
|
1796
|
+
/**
|
|
1797
|
+
* The width, in pixels.
|
|
1798
|
+
*
|
|
1799
|
+
* @remarks
|
|
1800
|
+
* - Minimum: 0
|
|
1801
|
+
* - Maximum: 32767
|
|
1802
|
+
*/
|
|
1803
|
+
width?: number;
|
|
1804
|
+
/**
|
|
1805
|
+
* The distance from the top edge of the container, in pixels.
|
|
1806
|
+
*
|
|
1807
|
+
* @remarks
|
|
1808
|
+
* - Minimum: -32767
|
|
1809
|
+
* - Maximum: 32767
|
|
1810
|
+
*/
|
|
1811
|
+
top: number;
|
|
1812
|
+
/**
|
|
1813
|
+
* The distance from the left edge of the container, in pixels.
|
|
1814
|
+
*
|
|
1815
|
+
* @remarks
|
|
1816
|
+
* - Minimum: -32767
|
|
1817
|
+
* - Maximum: 32767
|
|
1818
|
+
*/
|
|
1819
|
+
left: number;
|
|
1820
|
+
/**
|
|
1821
|
+
* The rotation, in degrees.
|
|
1822
|
+
*
|
|
1823
|
+
* @remarks
|
|
1824
|
+
* - Minimum: -180
|
|
1825
|
+
* - Maximum: 180
|
|
1826
|
+
*/
|
|
1827
|
+
rotation?: number;
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* @public
|
|
1832
|
+
* Text element or content to be added to the design at the end of a drag event.
|
|
1337
1833
|
*/
|
|
1338
1834
|
export declare type TextDragConfig = {
|
|
1339
1835
|
/**
|
|
1340
1836
|
* The type of element.
|
|
1341
1837
|
*/
|
|
1342
|
-
type: "
|
|
1838
|
+
type: "text";
|
|
1343
1839
|
/**
|
|
1344
1840
|
* The text content to drag.
|
|
1345
1841
|
*/
|
|
1346
1842
|
children?: string[];
|
|
1347
1843
|
/**
|
|
1348
1844
|
* The alignment of the text.
|
|
1349
|
-
* @defaultValue
|
|
1845
|
+
* @defaultValue "start"
|
|
1350
1846
|
*/
|
|
1351
1847
|
textAlign?: "start" | "center" | "end" | "justify";
|
|
1352
1848
|
/**
|
|
1353
|
-
* The weight of the font.
|
|
1354
|
-
* @defaultValue
|
|
1849
|
+
* The weight (thickness) of the font.
|
|
1850
|
+
* @defaultValue "normal"
|
|
1355
1851
|
*/
|
|
1356
1852
|
fontWeight?: FontWeight;
|
|
1357
1853
|
/**
|
|
1358
1854
|
* The style of the font.
|
|
1359
|
-
* @defaultValue
|
|
1855
|
+
* @defaultValue "normal"
|
|
1360
1856
|
*/
|
|
1361
1857
|
fontStyle?: "normal" | "italic";
|
|
1362
1858
|
/**
|
|
1363
1859
|
* The decoration of the font.
|
|
1364
|
-
* @defaultValue
|
|
1860
|
+
* @defaultValue "none"
|
|
1365
1861
|
*/
|
|
1366
1862
|
decoration?: "none" | "underline";
|
|
1367
1863
|
};
|
|
1368
1864
|
|
|
1369
1865
|
/**
|
|
1370
1866
|
* @public
|
|
1371
|
-
*
|
|
1867
|
+
* An element that renders text content.
|
|
1372
1868
|
*/
|
|
1373
|
-
export declare
|
|
1374
|
-
/**
|
|
1375
|
-
* @public
|
|
1376
|
-
* Makes the specified node draggable.
|
|
1377
|
-
*
|
|
1378
|
-
* @deprecated use `UI.startDrag` instead
|
|
1379
|
-
*
|
|
1380
|
-
* @param options - Options for making an element draggable.
|
|
1381
|
-
*/
|
|
1382
|
-
makeDraggable(options: DraggableElementData): void;
|
|
1383
|
-
/**
|
|
1384
|
-
* @public
|
|
1385
|
-
* Handles a drag event initiated inside the app to Canva, enables drag-and_drop interactions with elements outside of the app.
|
|
1386
|
-
* @param event - The drag start event.
|
|
1387
|
-
* @param dragData - The data to be passed to the drag handler.
|
|
1388
|
-
*/
|
|
1389
|
-
startDrag<E extends HTMLElement>(
|
|
1390
|
-
event: DragStartEvent<E>,
|
|
1391
|
-
dragData:
|
|
1392
|
-
| TextDragConfig
|
|
1393
|
-
| AudioDragConfig
|
|
1394
|
-
| EmbedDragConfig
|
|
1395
|
-
| VideoDragConfigForElement<E>
|
|
1396
|
-
| ImageDragConfigForElement<E>
|
|
1397
|
-
): Promise<void>;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
* An alias for the UI interface, providing access to ui related functionality
|
|
1402
|
-
* @public
|
|
1403
|
-
*/
|
|
1404
|
-
export declare const ui: UI;
|
|
1869
|
+
export declare type TextElement = NativeTextElement;
|
|
1405
1870
|
|
|
1406
1871
|
/**
|
|
1407
|
-
* @deprecated
|
|
1408
1872
|
* @public
|
|
1409
|
-
*
|
|
1873
|
+
* An element that renders text content and has positional properties.
|
|
1410
1874
|
*/
|
|
1411
|
-
export declare type
|
|
1875
|
+
export declare type TextElementAtPoint = NativeTextElementWithBox;
|
|
1412
1876
|
|
|
1413
1877
|
/**
|
|
1414
|
-
* @deprecated
|
|
1415
1878
|
* @public
|
|
1416
|
-
*
|
|
1417
|
-
* Options for defining the Drag and Drop behaviour for images
|
|
1418
|
-
* which have been supplied as data urls
|
|
1879
|
+
* A region of richtext.
|
|
1419
1880
|
*/
|
|
1420
|
-
export declare type
|
|
1881
|
+
export declare type TextRegion = {
|
|
1421
1882
|
/**
|
|
1422
|
-
* The
|
|
1423
|
-
*
|
|
1424
|
-
* @remarks
|
|
1425
|
-
* The full-size image is the image that Canva uploads to the user's account and
|
|
1426
|
-
* adds to their design.
|
|
1427
|
-
*
|
|
1428
|
-
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
1883
|
+
* The plaintext content of the region.
|
|
1429
1884
|
*/
|
|
1430
|
-
|
|
1431
|
-
/**
|
|
1432
|
-
* The data URL of the preview image.
|
|
1433
|
-
*
|
|
1434
|
-
* @remarks
|
|
1435
|
-
* The preview image is the image that users see under their cursor while dragging
|
|
1436
|
-
* it into their design.
|
|
1437
|
-
*
|
|
1438
|
-
* If omitted, the value of the `fullSizeSrc` property is used as a fallback.
|
|
1439
|
-
*/
|
|
1440
|
-
previewSrc?: string;
|
|
1885
|
+
text: string;
|
|
1441
1886
|
/**
|
|
1442
|
-
* The
|
|
1443
|
-
*
|
|
1444
|
-
* @remarks
|
|
1445
|
-
* The full-size image is the image that Canva uploads to the user's account and
|
|
1446
|
-
* adds to their design.
|
|
1887
|
+
* The formatting of the region.
|
|
1447
1888
|
*/
|
|
1448
|
-
|
|
1889
|
+
formatting?: Partial<RichtextFormatting>;
|
|
1449
1890
|
};
|
|
1450
1891
|
|
|
1451
1892
|
/**
|
|
1452
|
-
* @deprecated
|
|
1453
1893
|
* @public
|
|
1454
|
-
*
|
|
1894
|
+
* Provides methods for adding drag and drop behavior to an app.
|
|
1455
1895
|
*/
|
|
1456
|
-
export declare
|
|
1457
|
-
| UserSuppliedImageDragData
|
|
1458
|
-
| UserSuppliedTextDragData
|
|
1459
|
-
| UserSuppliedVideoDragData
|
|
1460
|
-
| UserSuppliedAudioDragData;
|
|
1461
|
-
|
|
1462
|
-
/**
|
|
1463
|
-
* @deprecated
|
|
1464
|
-
* @public
|
|
1465
|
-
*
|
|
1466
|
-
* Options for defining the Drag and Drop behaviour for images uploaded
|
|
1467
|
-
* via the Content capability.
|
|
1468
|
-
*/
|
|
1469
|
-
export declare type UserSuppliedExternalImageDragData =
|
|
1470
|
-
CommonImageDragConfig & {
|
|
1471
|
-
/**
|
|
1472
|
-
* The function that resolves an image ref
|
|
1473
|
-
* @remarks
|
|
1474
|
-
*
|
|
1475
|
-
* This function will be run during the drag process in order to fetch the media ref of the
|
|
1476
|
-
* external image being fetched. This function should return the result of `upload`
|
|
1477
|
-
* from the content capability.
|
|
1478
|
-
*/
|
|
1479
|
-
resolveImageRef: () => Promise<{
|
|
1480
|
-
ref: ImageRef;
|
|
1481
|
-
}>;
|
|
1482
|
-
/**
|
|
1483
|
-
* The URL of the preview image.
|
|
1484
|
-
*
|
|
1485
|
-
* @remarks
|
|
1486
|
-
* The preview image is the image that users see under their cursor while dragging
|
|
1487
|
-
* it into their design.
|
|
1488
|
-
*/
|
|
1489
|
-
previewSrc: string;
|
|
1490
|
-
/**
|
|
1491
|
-
* The dimensions of the full-size image.
|
|
1492
|
-
*
|
|
1493
|
-
* @remarks
|
|
1494
|
-
* The full-size image is the image that Canva uploads to the user's account and
|
|
1495
|
-
* adds to their design.
|
|
1496
|
-
*
|
|
1497
|
-
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
1498
|
-
*/
|
|
1499
|
-
fullSize?: Dimensions;
|
|
1500
|
-
};
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* @deprecated
|
|
1504
|
-
* @public
|
|
1505
|
-
* Options for defining the drag-and-drop behavior of an image element that can be defined by an
|
|
1506
|
-
* app developer.
|
|
1507
|
-
*/
|
|
1508
|
-
export declare type UserSuppliedImageDragData =
|
|
1509
|
-
| UserSuppliedDataUrlImageDragData
|
|
1510
|
-
| UserSuppliedExternalImageDragData;
|
|
1511
|
-
|
|
1512
|
-
/**
|
|
1513
|
-
* @deprecated
|
|
1514
|
-
* @public
|
|
1515
|
-
* Options for defining the drag-and-drop behavior of a text element.
|
|
1516
|
-
*/
|
|
1517
|
-
export declare type UserSuppliedTextDragData = TextDragConfig;
|
|
1518
|
-
|
|
1519
|
-
/**
|
|
1520
|
-
* @deprecated
|
|
1521
|
-
* @public
|
|
1522
|
-
* Options for defining the drag-and-drop behavior for videos.
|
|
1523
|
-
*/
|
|
1524
|
-
export declare type UserSuppliedVideoDragData = {
|
|
1525
|
-
/**
|
|
1526
|
-
* The type of element.
|
|
1527
|
-
*/
|
|
1528
|
-
type: "VIDEO";
|
|
1529
|
-
/**
|
|
1530
|
-
* The function used resolve the video ref.
|
|
1531
|
-
* This is used in conjunction with content import.
|
|
1532
|
-
*/
|
|
1533
|
-
resolveVideoRef: () => Promise<{
|
|
1534
|
-
ref: VideoRef;
|
|
1535
|
-
}>;
|
|
1896
|
+
export declare interface UI {
|
|
1536
1897
|
/**
|
|
1537
|
-
* The
|
|
1538
|
-
* @
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1898
|
+
* @deprecated The method has been superseded by `startDragToPoint`.
|
|
1899
|
+
* @public
|
|
1900
|
+
* Adds the specified element or content to a design at the end of a drag event.
|
|
1901
|
+
*
|
|
1902
|
+
* @param event - A drag start event.
|
|
1903
|
+
* @param dragData - Element or content to be added to the design at the end of the drag event.
|
|
1541
1904
|
*/
|
|
1542
|
-
|
|
1905
|
+
startDrag<E extends HTMLElement>(
|
|
1906
|
+
event: DragStartEvent<E>,
|
|
1907
|
+
dragData:
|
|
1908
|
+
| TextDragConfig
|
|
1909
|
+
| AudioDragConfig
|
|
1910
|
+
| EmbedDragConfig
|
|
1911
|
+
| VideoDragConfigForElement<E>
|
|
1912
|
+
| ImageDragConfigForElement<E>
|
|
1913
|
+
): Promise<void>;
|
|
1543
1914
|
/**
|
|
1544
|
-
*
|
|
1545
|
-
*
|
|
1915
|
+
* @public
|
|
1916
|
+
* Adds the specified element or content to fixed designs, which use a coordinate-based positioning system at the end of a drag event.
|
|
1546
1917
|
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1918
|
+
* @param event - A drag start event.
|
|
1919
|
+
* @param dragData - Element or content to be added to the design at the end of the drag event.
|
|
1549
1920
|
*/
|
|
1550
|
-
|
|
1921
|
+
startDragToPoint<E extends HTMLElement>(
|
|
1922
|
+
event: DragStartEvent<E>,
|
|
1923
|
+
dragData:
|
|
1924
|
+
| TextDragConfig
|
|
1925
|
+
| AudioDragConfig
|
|
1926
|
+
| EmbedDragConfig
|
|
1927
|
+
| VideoDragConfigForElement<E>
|
|
1928
|
+
| ImageDragConfigForElement<E>
|
|
1929
|
+
): Promise<void>;
|
|
1551
1930
|
/**
|
|
1552
|
-
*
|
|
1931
|
+
* @public
|
|
1932
|
+
* Adds the specified element or content to responsive documents, which slot things into a text stream at the end of a drag event.
|
|
1553
1933
|
*
|
|
1554
|
-
* @
|
|
1555
|
-
*
|
|
1556
|
-
* it into their design.
|
|
1934
|
+
* @param event - A drag start event.
|
|
1935
|
+
* @param dragData - Element or content to be added to the design at the end of the drag event.
|
|
1557
1936
|
*/
|
|
1558
|
-
|
|
1559
|
-
|
|
1937
|
+
startDragToCursor<E extends HTMLElement>(
|
|
1938
|
+
event: DragStartEvent<E>,
|
|
1939
|
+
dragData:
|
|
1940
|
+
| EmbedDragConfig
|
|
1941
|
+
| VideoDragConfigForElement<E>
|
|
1942
|
+
| ImageDragConfigForElement<E>
|
|
1943
|
+
): Promise<void>;
|
|
1944
|
+
}
|
|
1560
1945
|
|
|
1561
1946
|
/**
|
|
1947
|
+
* An alias for the UI interface, providing access to ui related functionality
|
|
1562
1948
|
* @public
|
|
1563
|
-
|
|
1949
|
+
*/
|
|
1950
|
+
export declare const ui: UI;
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* @public
|
|
1954
|
+
* A data type that can be used in app element data.
|
|
1564
1955
|
*/
|
|
1565
1956
|
export declare type Value =
|
|
1566
1957
|
| Primitive
|
|
@@ -1572,48 +1963,40 @@ export declare type Value =
|
|
|
1572
1963
|
|
|
1573
1964
|
/**
|
|
1574
1965
|
* @public
|
|
1575
|
-
*
|
|
1966
|
+
* Video element or content to be added to the design at the end of a drag event.
|
|
1576
1967
|
*/
|
|
1577
1968
|
export declare type VideoDragConfig = {
|
|
1578
1969
|
/**
|
|
1579
1970
|
* The type of element.
|
|
1580
1971
|
*/
|
|
1581
|
-
type: "
|
|
1972
|
+
type: "video";
|
|
1582
1973
|
/**
|
|
1583
|
-
*
|
|
1584
|
-
* This is used in conjunction with content import.
|
|
1974
|
+
* A function that returns a reference (ref) to a video asset in Canva's backend.
|
|
1585
1975
|
*/
|
|
1586
1976
|
resolveVideoRef: () => Promise<{
|
|
1587
1977
|
ref: VideoRef;
|
|
1588
1978
|
}>;
|
|
1589
1979
|
/**
|
|
1590
1980
|
* The dimensions of the preview image.
|
|
1591
|
-
* @remarks
|
|
1592
|
-
* The preview image is the image that users see under their cursor
|
|
1593
|
-
* while dragging it into their design.
|
|
1594
1981
|
*/
|
|
1595
1982
|
previewSize: Dimensions;
|
|
1596
1983
|
/**
|
|
1597
1984
|
* The dimensions of the full-size video.
|
|
1598
|
-
* These dimensions are used when adding the video to the design
|
|
1599
1985
|
*
|
|
1600
|
-
*
|
|
1601
|
-
* used
|
|
1986
|
+
* @remarks
|
|
1987
|
+
* - These dimensions are used when adding the video to the design
|
|
1988
|
+
* - If omitted, the `previewSize` dimensions are used as a fallback.
|
|
1602
1989
|
*/
|
|
1603
1990
|
fullSize?: Dimensions;
|
|
1604
1991
|
/**
|
|
1605
|
-
* The URL of the
|
|
1606
|
-
*
|
|
1607
|
-
* @remarks
|
|
1608
|
-
* The preview image is the image that users see under their cursor while dragging
|
|
1609
|
-
* it into their design.
|
|
1992
|
+
* The URL of an image to display under the user's cursor during the drag and drop event.
|
|
1610
1993
|
*/
|
|
1611
1994
|
previewUrl: string;
|
|
1612
1995
|
};
|
|
1613
1996
|
|
|
1614
1997
|
/**
|
|
1615
1998
|
* @public
|
|
1616
|
-
*
|
|
1999
|
+
* Video element or content to be added to the design at the end of a drag event.
|
|
1617
2000
|
*/
|
|
1618
2001
|
export declare type VideoDragConfigForElement<E extends Element> =
|
|
1619
2002
|
E extends HTMLImageElement
|
|
@@ -1623,15 +2006,27 @@ export declare type VideoDragConfigForElement<E extends Element> =
|
|
|
1623
2006
|
|
|
1624
2007
|
/**
|
|
1625
2008
|
* @public
|
|
1626
|
-
*
|
|
2009
|
+
* An element that renders video content.
|
|
2010
|
+
*/
|
|
2011
|
+
export declare type VideoElement = NativeVideoElement;
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* @public
|
|
2015
|
+
* An element that renders video content and has positional properties.
|
|
2016
|
+
*/
|
|
2017
|
+
export declare type VideoElementAtPoint = NativeVideoElementWithBox;
|
|
2018
|
+
|
|
2019
|
+
/**
|
|
2020
|
+
* @public
|
|
2021
|
+
* A video asset that fills a path's interior.
|
|
1627
2022
|
*/
|
|
1628
2023
|
export declare type VideoFill = {
|
|
1629
2024
|
/**
|
|
1630
|
-
*
|
|
2025
|
+
* The type of fill.
|
|
1631
2026
|
*/
|
|
1632
|
-
type: "
|
|
2027
|
+
type: "video";
|
|
1633
2028
|
/**
|
|
1634
|
-
* A unique identifier that
|
|
2029
|
+
* A unique identifier that points to a video asset in Canva's backend.
|
|
1635
2030
|
*/
|
|
1636
2031
|
ref: VideoRef;
|
|
1637
2032
|
};
|
|
@@ -1644,20 +2039,45 @@ export declare type VideoRef = string & {
|
|
|
1644
2039
|
__videoRef: never;
|
|
1645
2040
|
};
|
|
1646
2041
|
|
|
2042
|
+
/**
|
|
2043
|
+
* A set of dimensions with an auto-calculated height.
|
|
2044
|
+
*/
|
|
1647
2045
|
declare type Width = {
|
|
2046
|
+
/**
|
|
2047
|
+
* A width, in pixels.
|
|
2048
|
+
*
|
|
2049
|
+
* @remarks
|
|
2050
|
+
* - The pixels are relative to their container.
|
|
2051
|
+
* - Minimum: 0
|
|
2052
|
+
* - Maximum: 32767
|
|
2053
|
+
*/
|
|
1648
2054
|
width: number;
|
|
2055
|
+
/**
|
|
2056
|
+
* Indicates that the height should be auto-calculated.
|
|
2057
|
+
*/
|
|
1649
2058
|
height: "auto";
|
|
1650
2059
|
};
|
|
1651
2060
|
|
|
2061
|
+
/**
|
|
2062
|
+
* A set of dimensions, in pixels.
|
|
2063
|
+
*/
|
|
1652
2064
|
declare type WidthAndHeight = {
|
|
1653
2065
|
/**
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
2066
|
+
* A width, in pixels.
|
|
2067
|
+
*
|
|
2068
|
+
* @remarks
|
|
2069
|
+
* - The pixels are relative to their container.
|
|
2070
|
+
* - Minimum: 0
|
|
2071
|
+
* - Maximum: 32767
|
|
1656
2072
|
*/
|
|
1657
2073
|
width: number;
|
|
1658
2074
|
/**
|
|
1659
|
-
*
|
|
1660
|
-
*
|
|
2075
|
+
* A height, in pixels.
|
|
2076
|
+
*
|
|
2077
|
+
* @remarks
|
|
2078
|
+
* - The pixels are relative to their container.
|
|
2079
|
+
* - Minimum: 0
|
|
2080
|
+
* - Maximum: 32767
|
|
1661
2081
|
*/
|
|
1662
2082
|
height: number;
|
|
1663
2083
|
};
|